@inneranimalmedia/agentsam-sdk 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.js +106 -5
- package/src/lib/scaffold.js +162 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inneranimalmedia/agentsam-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Agent Sam is a full-stack AI agent SDK for autonomous task execution — covering data management, creative workflows, design commands, and multi-step agentic pipelines.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
package/src/cli.js
CHANGED
|
@@ -1,16 +1,117 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import readline from 'readline';
|
|
4
|
+
import { scaffoldProject } from './lib/scaffold.js';
|
|
5
|
+
|
|
6
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
7
|
+
const ask = (q) => new Promise(resolve => rl.question(q, resolve));
|
|
8
|
+
|
|
9
|
+
const LANES = {
|
|
10
|
+
'1': 'Full Stack',
|
|
11
|
+
'2': 'Data Solutions',
|
|
12
|
+
'3': 'Customer Management',
|
|
13
|
+
'4': 'Creative & Design',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const PROVIDERS = {
|
|
17
|
+
'1': 'Cloudflare Workers',
|
|
18
|
+
'2': 'GitHub + Cloudflare',
|
|
19
|
+
'3': 'Local / Self-hosted',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const AGENTS = {
|
|
23
|
+
'1': 'orchestrator',
|
|
24
|
+
'2': 'data',
|
|
25
|
+
'3': 'crm',
|
|
26
|
+
'4': 'creative',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
async function init() {
|
|
30
|
+
console.log(`
|
|
31
|
+
╔═══════════════════════════════════╗
|
|
32
|
+
║ Agent Sam SDK — Init ║
|
|
33
|
+
╚═══════════════════════════════════╝
|
|
34
|
+
`);
|
|
35
|
+
|
|
36
|
+
const projectName = await ask(' Project name: ');
|
|
37
|
+
|
|
38
|
+
console.log(`
|
|
39
|
+
Select a lane:
|
|
40
|
+
1) Full Stack
|
|
41
|
+
2) Data Solutions
|
|
42
|
+
3) Customer Management
|
|
43
|
+
4) Creative & Design
|
|
44
|
+
`);
|
|
45
|
+
const laneKey = await ask(' Lane [1-4]: ');
|
|
46
|
+
const lane = LANES[laneKey] ?? 'Full Stack';
|
|
47
|
+
|
|
48
|
+
let provider = 'Cloudflare Workers';
|
|
49
|
+
if (laneKey === '1') {
|
|
50
|
+
console.log(`
|
|
51
|
+
Select a provider:
|
|
52
|
+
1) Cloudflare Workers
|
|
53
|
+
2) GitHub + Cloudflare
|
|
54
|
+
3) Local / Self-hosted
|
|
55
|
+
`);
|
|
56
|
+
const providerKey = await ask(' Provider [1-3]: ');
|
|
57
|
+
provider = PROVIDERS[providerKey] ?? 'Cloudflare Workers';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log(`
|
|
61
|
+
Select your default Agent Sam:
|
|
62
|
+
1) Orchestrator — general purpose, routes to all lanes
|
|
63
|
+
2) Data Agent — database ops, migrations, queries
|
|
64
|
+
3) CRM Agent — customer management, contacts, billing
|
|
65
|
+
4) Creative Agent — design, 3D, media, content
|
|
66
|
+
`);
|
|
67
|
+
const agentKey = await ask(' Agent [1-4]: ');
|
|
68
|
+
const agent = AGENTS[agentKey] ?? 'orchestrator';
|
|
69
|
+
|
|
70
|
+
const cfAccountId = await ask(' Cloudflare Account ID (enter to skip): ');
|
|
71
|
+
|
|
72
|
+
console.log(`
|
|
73
|
+
┌─────────────────────────────────────┐
|
|
74
|
+
│ Agent Sam Project Config │
|
|
75
|
+
├─────────────────────────────────────┤
|
|
76
|
+
│ Project: ${projectName.padEnd(25)}│
|
|
77
|
+
│ Lane: ${lane.padEnd(25)}│
|
|
78
|
+
│ Provider: ${provider.padEnd(25)}│
|
|
79
|
+
│ Agent: ${agent.padEnd(25)}│
|
|
80
|
+
│ CF Acct: ${(cfAccountId || 'not set').padEnd(25)}│
|
|
81
|
+
└─────────────────────────────────────┘
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
const confirm = await ask(' Scaffold project? (y/n): ');
|
|
85
|
+
|
|
86
|
+
if (confirm.toLowerCase() === 'y') {
|
|
87
|
+
const dir = scaffoldProject({ projectName, lane, provider, agent, cfAccountId });
|
|
88
|
+
console.log(`
|
|
89
|
+
✓ Project created at ${dir}
|
|
90
|
+
|
|
91
|
+
Next steps:
|
|
92
|
+
cd ${projectName}
|
|
93
|
+
cp .env.example .env
|
|
94
|
+
npm install
|
|
95
|
+
npm run dev
|
|
96
|
+
`);
|
|
97
|
+
} else {
|
|
98
|
+
console.log('\n Cancelled.\n');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
rl.close();
|
|
102
|
+
}
|
|
103
|
+
|
|
3
104
|
const command = process.argv[2];
|
|
4
105
|
|
|
5
106
|
if (command === 'init') {
|
|
6
|
-
|
|
107
|
+
init();
|
|
7
108
|
} else {
|
|
8
109
|
console.log(`
|
|
9
|
-
Agent Sam SDK — CLI
|
|
110
|
+
Agent Sam SDK — CLI
|
|
10
111
|
|
|
11
|
-
Usage:
|
|
12
|
-
|
|
112
|
+
Usage:
|
|
113
|
+
agentsam init Initialize a new Agent Sam project
|
|
13
114
|
|
|
14
|
-
Version: 1.0.0
|
|
115
|
+
Version: 1.0.0
|
|
15
116
|
`);
|
|
16
117
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export function scaffoldProject({ projectName, lane, provider, agent, cfAccountId }) {
|
|
5
|
+
const dir = path.resolve(process.cwd(), projectName);
|
|
6
|
+
|
|
7
|
+
if (fs.existsSync(dir)) {
|
|
8
|
+
console.error(`\n ✗ Directory "${projectName}" already exists.\n`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
13
|
+
fs.mkdirSync(`${dir}/src`, { recursive: true });
|
|
14
|
+
|
|
15
|
+
// agentsam.config.js
|
|
16
|
+
fs.writeFileSync(`${dir}/agentsam.config.js`, `
|
|
17
|
+
export default {
|
|
18
|
+
project: '${projectName}',
|
|
19
|
+
lane: '${lane}',
|
|
20
|
+
provider: '${provider}',
|
|
21
|
+
agent: '${agent}',
|
|
22
|
+
cloudflare: {
|
|
23
|
+
accountId: '${cfAccountId || ''}',
|
|
24
|
+
},
|
|
25
|
+
api: {
|
|
26
|
+
baseUrl: 'https://api.inneranimalmedia.com',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
`.trimStart());
|
|
30
|
+
|
|
31
|
+
// .env.example
|
|
32
|
+
fs.writeFileSync(`${dir}/.env.example`, `
|
|
33
|
+
AGENTSAM_API_KEY=
|
|
34
|
+
CLOUDFLARE_ACCOUNT_ID=${cfAccountId || ''}
|
|
35
|
+
CLOUDFLARE_API_TOKEN=
|
|
36
|
+
`.trimStart());
|
|
37
|
+
|
|
38
|
+
// .gitignore
|
|
39
|
+
fs.writeFileSync(`${dir}/.gitignore`, `
|
|
40
|
+
node_modules/
|
|
41
|
+
.env
|
|
42
|
+
.dev.vars
|
|
43
|
+
dist/
|
|
44
|
+
`.trimStart());
|
|
45
|
+
|
|
46
|
+
// package.json
|
|
47
|
+
fs.writeFileSync(`${dir}/package.json`, JSON.stringify({
|
|
48
|
+
name: projectName,
|
|
49
|
+
version: '0.1.0',
|
|
50
|
+
type: 'module',
|
|
51
|
+
scripts: {
|
|
52
|
+
dev: 'wrangler dev',
|
|
53
|
+
deploy: 'wrangler deploy',
|
|
54
|
+
},
|
|
55
|
+
dependencies: {
|
|
56
|
+
'@inneranimalmedia/agentsam-sdk': '^1.0.0',
|
|
57
|
+
},
|
|
58
|
+
}, null, 2));
|
|
59
|
+
|
|
60
|
+
// Lane-specific files
|
|
61
|
+
if (lane === 'Full Stack' || lane === 'Data Solutions') {
|
|
62
|
+
fs.mkdirSync(`${dir}/migrations`, { recursive: true });
|
|
63
|
+
fs.writeFileSync(`${dir}/migrations/0001_init.sql`, `
|
|
64
|
+
-- Initial schema for ${projectName}
|
|
65
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
66
|
+
id TEXT PRIMARY KEY,
|
|
67
|
+
user_id TEXT NOT NULL,
|
|
68
|
+
created_at INTEGER DEFAULT (unixepoch())
|
|
69
|
+
);
|
|
70
|
+
`.trimStart());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (lane === 'Full Stack' || provider === 'Cloudflare Workers' || provider === 'GitHub + Cloudflare') {
|
|
74
|
+
fs.writeFileSync(`${dir}/wrangler.toml`, `
|
|
75
|
+
name = "${projectName}"
|
|
76
|
+
main = "src/index.js"
|
|
77
|
+
compatibility_date = "2025-01-01"
|
|
78
|
+
|
|
79
|
+
[[d1_databases]]
|
|
80
|
+
binding = "DB"
|
|
81
|
+
database_name = "${projectName}-db"
|
|
82
|
+
database_id = ""
|
|
83
|
+
`.trimStart());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/index.js — lane-specific worker
|
|
87
|
+
const workers = {
|
|
88
|
+
'Full Stack': `
|
|
89
|
+
import { AgentSam } from '@inneranimalmedia/agentsam-sdk';
|
|
90
|
+
|
|
91
|
+
export default {
|
|
92
|
+
async fetch(request, env, ctx) {
|
|
93
|
+
const agent = new AgentSam({ env, agent: 'orchestrator' });
|
|
94
|
+
return agent.handle(request);
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
`,
|
|
98
|
+
'Data Solutions': `
|
|
99
|
+
import { AgentSam } from '@inneranimalmedia/agentsam-sdk';
|
|
100
|
+
|
|
101
|
+
export default {
|
|
102
|
+
async fetch(request, env, ctx) {
|
|
103
|
+
const agent = new AgentSam({ env, agent: 'data' });
|
|
104
|
+
return agent.handle(request);
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
`,
|
|
108
|
+
'Customer Management': `
|
|
109
|
+
import { AgentSam } from '@inneranimalmedia/agentsam-sdk';
|
|
110
|
+
|
|
111
|
+
export default {
|
|
112
|
+
async fetch(request, env, ctx) {
|
|
113
|
+
const agent = new AgentSam({ env, agent: 'crm' });
|
|
114
|
+
return agent.handle(request);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
`,
|
|
118
|
+
'Creative & Design': `
|
|
119
|
+
import { AgentSam } from '@inneranimalmedia/agentsam-sdk';
|
|
120
|
+
|
|
121
|
+
export default {
|
|
122
|
+
async fetch(request, env, ctx) {
|
|
123
|
+
const agent = new AgentSam({ env, agent: 'creative' });
|
|
124
|
+
return agent.handle(request);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
`,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
fs.writeFileSync(`${dir}/src/index.js`, workers[lane].trimStart());
|
|
131
|
+
|
|
132
|
+
// README
|
|
133
|
+
fs.writeFileSync(`${dir}/README.md`, `
|
|
134
|
+
# ${projectName}
|
|
135
|
+
|
|
136
|
+
Scaffolded with [Agent Sam SDK](https://www.npmjs.com/package/@inneranimalmedia/agentsam-sdk).
|
|
137
|
+
|
|
138
|
+
## Lane
|
|
139
|
+
**${lane}** — ${agent} agent, ${provider}
|
|
140
|
+
|
|
141
|
+
## Setup
|
|
142
|
+
|
|
143
|
+
\`\`\`bash
|
|
144
|
+
cp .env.example .env
|
|
145
|
+
npm install
|
|
146
|
+
\`\`\`
|
|
147
|
+
|
|
148
|
+
## Dev
|
|
149
|
+
|
|
150
|
+
\`\`\`bash
|
|
151
|
+
npm run dev
|
|
152
|
+
\`\`\`
|
|
153
|
+
|
|
154
|
+
## Deploy
|
|
155
|
+
|
|
156
|
+
\`\`\`bash
|
|
157
|
+
npm run deploy
|
|
158
|
+
\`\`\`
|
|
159
|
+
`.trimStart());
|
|
160
|
+
|
|
161
|
+
return dir;
|
|
162
|
+
}
|