Skip to content

Commit 0bacd48

Browse files
committed
agentbot deploy — connect to Agentbot Cloud API
All 6 CLI commands now work: agentbot init → create agent.md agentbot dev → watch for changes agentbot run → validate + display agentbot test → validate all agents agentbot bundle → package for deployment agentbot deploy → push to Agentbot Cloud Zero stubs remaining.
1 parent 67a697d commit 0bacd48

2 files changed

Lines changed: 90 additions & 2 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { readFileSync, existsSync } from 'fs';
2+
import { resolve, join } from 'path';
3+
4+
const CLOUD_API = 'https://agentbot.sh';
5+
6+
export async function deployCommand(args: string[]) {
7+
const targetDir = args[0] || '.';
8+
const resolved = resolve(targetDir);
9+
const bundleDir = join(resolved, '.agentbot/dist');
10+
11+
console.log('');
12+
console.log(' 🚀 Agentbot Deploy');
13+
console.log(' ──────────────────');
14+
15+
// Check for bundled agents
16+
const indexFile = join(bundleDir, 'index.json');
17+
if (!existsSync(indexFile)) {
18+
console.log(' ⚠️ No bundle found. Run `agentbot bundle` first.');
19+
console.log('');
20+
console.log(' Or bundle and deploy in one step:');
21+
console.log(' agentbot bundle && agentbot deploy');
22+
console.log('');
23+
process.exit(1);
24+
}
25+
26+
const index = JSON.parse(readFileSync(indexFile, 'utf-8'));
27+
console.log(` Found ${index.total} agent(s) to deploy.`);
28+
console.log('');
29+
30+
// Check for API key
31+
const apiKey = process.env.AGENTBOT_API_KEY;
32+
if (!apiKey) {
33+
console.log(' ❌ AGENTBOT_API_KEY not set.');
34+
console.log('');
35+
console.log(' Get your API key:');
36+
console.log(' 1. Sign up at https://agentbot.sh');
37+
console.log(' 2. Go to Settings → API Keys');
38+
console.log(' 3. Create a new key');
39+
console.log('');
40+
console.log(' Then run:');
41+
console.log(' AGENTBOT_API_KEY=sk-... agentbot deploy');
42+
console.log('');
43+
process.exit(1);
44+
}
45+
46+
// Deploy each agent
47+
for (const agent of index.agents) {
48+
const agentFile = join(bundleDir, `${agent.name}.md`);
49+
const content = readFileSync(agentFile, 'utf-8');
50+
51+
console.log(` 📤 Deploying ${agent.name}...`);
52+
53+
try {
54+
const res = await fetch(`${CLOUD_API}/api/agents/provision`, {
55+
method: 'POST',
56+
headers: {
57+
'Content-Type': 'application/json',
58+
'Authorization': `Bearer ${apiKey}`,
59+
},
60+
body: JSON.stringify({
61+
name: agent.name,
62+
description: agent.description,
63+
definition: content,
64+
model: agent.model,
65+
tools: agent.tools,
66+
}),
67+
});
68+
69+
if (res.ok) {
70+
const data = await res.json() as { url?: string };
71+
console.log(` ✅ ${agent.name} deployed!`);
72+
if (data.url) {
73+
console.log(` ${data.url}`);
74+
}
75+
} else {
76+
const err = await res.text();
77+
console.log(` ❌ ${agent.name} failed: ${res.status} ${err}`);
78+
}
79+
} catch (err) {
80+
console.log(` ❌ ${agent.name} error: ${err instanceof Error ? err.message : String(err)}`);
81+
}
82+
}
83+
84+
console.log('');
85+
console.log(' 🎉 Deploy complete!');
86+
console.log(` Dashboard: ${CLOUD_API}/dashboard`);
87+
console.log('');
88+
}

packages/cli/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { runCommand } from './commands/run.js';
55
import { devCommand } from './commands/dev.js';
66
import { testCommand } from './commands/test.js';
77
import { bundleCommand } from './commands/bundle.js';
8+
import { deployCommand } from './commands/deploy.js';
89

910
const args = process.argv.slice(2);
1011
const command = args[0];
@@ -69,8 +70,7 @@ async function main() {
6970
break;
7071

7172
case 'deploy':
72-
console.log(' 🚀 agentbot deploy — coming in v0.2.0');
73-
console.log(' Deploy to Agentbot Cloud: https://agentbot.sh');
73+
await deployCommand(args.slice(1));
7474
break;
7575

7676
default:

0 commit comments

Comments
 (0)