Automate Infrastructure with AI Agents
Dalang CLI provides machine-readable commands for provisioning and managing compute. Your authorized agent or script supplies the approvals, policies, health checks, and recovery logic.
Agent-Authored Provisioning Workflow
An authorized AI system can call a customer-authored workflow that creates VMs and deploys code. The CLI exposes the primitives; your automation decides when and how they run:
- Provision new instances when an approved policy requests more compute
- Deploy a codebase to a newly created VM
- Manage a permitted fleet of worker instances
- Run recovery logic written and secured by the customer
#!/bin/bash # AI Agent Self-Replication Script # Creates a new VM and deploys a copy of itself REPLICA_NAME="agent-$(date +%s)" # 1. Create new VM instance dalang service create \ --name "$REPLICA_NAME" \ --cpu 2 --ram 2G --storage 20G \ --image ubuntu:24.04 -y # 2. Wait until the VM is RUNNING until [ "$(dalang service info "$REPLICA_NAME" --json | jq -r .status)" = "RUNNING" ]; do sleep 5 done # 3. Deploy the agent β use 'exec' (non-interactive), not 'shell' dalang exec "$REPLICA_NAME" "apt-get update && apt-get install -y python3 python3-pip git" dalang exec "$REPLICA_NAME" "git clone https://github.com/your-org/your-agent.git /opt/agent" dalang exec "$REPLICA_NAME" "cd /opt/agent && pip3 install -r requirements.txt" # (or push local files instead of cloning) # dalang scp -r ./agent "$REPLICA_NAME":/opt/agent # 4. Start the agent process (detached) dalang exec "$REPLICA_NAME" "cd /opt/agent && nohup python3 main.py > /var/log/agent.log 2>&1 &" echo "Replica $REPLICA_NAME deployed successfully"
AI Agent Capabilities
Scripted Replication
A customer-authored script can create a VM, install dependencies, deploy code, and start a process.
dalang service create ... && dalang exec ...Horizontal Scaling
Spawn multiple worker instances in parallel based on workload.
for i in 1 2 3..10; do dalang create ... & doneCustomer-Authored Recovery
Use JSON status output in your own monitoring and replacement workflow.
dalang service info --json | jq '.status'Resource Management
Check balance, manage credits, track resource usage programmatically.
dalang credit --json | jq '.balance'Fleet Control
List, start, stop, delete VMs. Full lifecycle management.
dalang service list --jsonNon-Interactive Execution
Use -y only in an approved workflow with appropriate spending and deletion safeguards.
dalang service create ... -yCode Examples
Horizontal Scaling
#!/bin/bash
# Horizontal Scaling: Create multiple agent instances
AGENT_COUNT=${1:-3}
BASE_NAME="worker"
for i in $(seq 1 $AGENT_COUNT); do
dalang service create \
--name "${BASE_NAME}-${i}" \
--cpu 2 --ram 2G --storage 10G \
-y &
done
wait
echo "Created $AGENT_COUNT worker instances"
# List all workers
dalang service list --json | jq '.[] | select(.name | startswith("worker"))'Customer-Authored Recovery Monitor
#!/bin/bash
# Self-Healing: Monitor and recreate failed instances
while true; do
# Get all agent instances
AGENTS=$(dalang service list --json | jq -r '.[] | select(.name | startswith("agent")) | .name')
for AGENT in $AGENTS; do
STATUS=$(dalang service info "$AGENT" --json | jq -r '.status')
if [ "$STATUS" != "RUNNING" ]; then
echo "Agent $AGENT is $STATUS, recreating..."
dalang delete "$AGENT" -y
dalang service create --name "$AGENT" --cpu 2 --ram 2G -y
fi
done
sleep 60
donePython Integration
# Python: Programmatic infrastructure control
import subprocess
import json
def run_dalang(cmd):
result = subprocess.run(
f"dalang {cmd} --json",
shell=True, capture_output=True, text=True
)
return json.loads(result.stdout) if result.stdout else None
# List all services
services = run_dalang("service list")
running = [s for s in services if s['status'] == 'RUNNING']
# Get specific VM info
vm = run_dalang("service info my-agent")
print(f"VM IP: {vm['public_ip']}")
print(f"Balance: {run_dalang('credit')['balance']}")
# Create new VM programmatically
import os
os.system("dalang service create --name new-agent --cpu 2 --ram 2G -y")Why Dalang for AI Agents
1 Simple CLI Interface
Single binary, no complex SDKs. AI agents can execute bash commands directly. Works with any language that can run shell commands.
2 JSON Output
All commands support --json for machine-readable output.
Easy parsing with jq, Python, or any language.
3 No Human Prompts
Use -y flag to skip all confirmations.
Fully automated operation without human intervention.
4 Affordable Compute
Starting at Rp 30.000/month (~$2 USD). Cost-effective for spawning multiple instances. Pay only for what you use.
5 Direct Shell & Exec
dalang exec runs commands and returns output for
unattended automation; dalang shell gives an
interactive session. Install software, deploy code, run commands β all programmatically.
6 Persistent Auth
Authenticate once, operate forever. Credentials stored securely. No need to re-authenticate for each operation.
Teach Your AI Agent
Download the SKILL.md file and add it to your AI agent's context. It contains all commands, patterns, and best practices for autonomous operation.
Compatible with: Claude Code, Cursor, GitHub Copilot, OpenAI Assistants, Custom Agents
Ready to Build Autonomous AI?
Give your AI agent the infrastructure it needs to operate independently.