@agentage/cli 0.10.0 → 0.11.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/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +33 -96
- package/dist/commands/create.js.map +1 -1
- package/dist/examples/claude-agent.agent.d.ts +3 -0
- package/dist/examples/claude-agent.agent.d.ts.map +1 -0
- package/dist/examples/claude-agent.agent.js +13 -0
- package/dist/examples/claude-agent.agent.js.map +1 -0
- package/dist/examples/code-reviewer.agent.d.ts +3 -0
- package/dist/examples/code-reviewer.agent.d.ts.map +1 -0
- package/dist/examples/code-reviewer.agent.js +11 -0
- package/dist/examples/code-reviewer.agent.js.map +1 -0
- package/dist/examples/copilot.agent.d.ts +3 -0
- package/dist/examples/copilot.agent.d.ts.map +1 -0
- package/dist/examples/copilot.agent.js +9 -0
- package/dist/examples/copilot.agent.js.map +1 -0
- package/dist/examples/countdown.agent.d.ts +2 -2
- package/dist/examples/countdown.agent.d.ts.map +1 -1
- package/dist/examples/countdown.agent.js +8 -44
- package/dist/examples/countdown.agent.js.map +1 -1
- package/dist/examples/hello.agent.d.ts +3 -0
- package/dist/examples/hello.agent.d.ts.map +1 -0
- package/dist/examples/hello.agent.js +9 -0
- package/dist/examples/hello.agent.js.map +1 -0
- package/dist/examples/shell.agent.d.ts +2 -2
- package/dist/examples/shell.agent.d.ts.map +1 -1
- package/dist/examples/shell.agent.js +4 -93
- package/dist/examples/shell.agent.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2EpC,eAAO,MAAM,mBAAmB,QAAO,OAiDtC,CAAC"}
|
package/dist/commands/create.js
CHANGED
|
@@ -4,133 +4,70 @@ import { Command } from 'commander';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
const TEMPLATES = {
|
|
6
6
|
simple: {
|
|
7
|
-
content: (name) => `import {
|
|
7
|
+
content: (name) => `import { agent, output } from '@agentage/core';
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export default agent({
|
|
10
10
|
name: '${name}',
|
|
11
11
|
description: 'A simple agent',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
yield {
|
|
15
|
-
type: 'output',
|
|
16
|
-
data: { type: 'output', content: \`Running: \${input.task}\`, format: 'text' },
|
|
17
|
-
timestamp: Date.now(),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
yield {
|
|
21
|
-
type: 'result',
|
|
22
|
-
data: { type: 'result', success: true, output: 'Done' },
|
|
23
|
-
timestamp: Date.now(),
|
|
24
|
-
};
|
|
12
|
+
async *run({ task }) {
|
|
13
|
+
yield output(\`Running: \${task}\`);
|
|
25
14
|
},
|
|
26
15
|
});
|
|
27
|
-
|
|
28
|
-
export default agent;
|
|
29
16
|
`,
|
|
30
17
|
},
|
|
31
18
|
shell: {
|
|
32
|
-
content: (name) => `import {
|
|
33
|
-
import { spawn } from 'node:child_process';
|
|
34
|
-
import { createInterface } from 'node:readline';
|
|
19
|
+
content: (name) => `import { agent, shell } from '@agentage/core';
|
|
35
20
|
|
|
36
|
-
export
|
|
21
|
+
export default agent({
|
|
37
22
|
name: '${name}',
|
|
38
23
|
description: 'Executes a shell command and streams output',
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const events: RunEvent[] = [];
|
|
42
|
-
let exitCode: number | null = null;
|
|
43
|
-
|
|
44
|
-
await new Promise<void>((resolve) => {
|
|
45
|
-
const proc = spawn(input.task, { shell: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
46
|
-
signal.addEventListener('abort', () => proc.kill(), { once: true });
|
|
47
|
-
|
|
48
|
-
if (proc.stdout) {
|
|
49
|
-
const rl = createInterface({ input: proc.stdout });
|
|
50
|
-
rl.on('line', (line) => {
|
|
51
|
-
events.push({ type: 'output', data: { type: 'output', content: line, format: 'text' }, timestamp: Date.now() });
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
proc.on('close', (code) => { exitCode = code; resolve(); });
|
|
56
|
-
proc.on('error', () => resolve());
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
for (const event of events) yield event;
|
|
60
|
-
|
|
61
|
-
yield {
|
|
62
|
-
type: 'result',
|
|
63
|
-
data: { type: 'result', success: exitCode === 0, output: exitCode === 0 ? 'Done' : \`Exited with code \${exitCode}\` },
|
|
64
|
-
timestamp: Date.now(),
|
|
65
|
-
};
|
|
24
|
+
async *run({ task }) {
|
|
25
|
+
yield* shell(task);
|
|
66
26
|
},
|
|
67
27
|
});
|
|
68
|
-
|
|
69
|
-
export default agent;
|
|
70
28
|
`,
|
|
71
29
|
},
|
|
72
30
|
claude: {
|
|
73
31
|
deps: ['@anthropic-ai/claude-agent-sdk'],
|
|
74
|
-
content: (name) => `import {
|
|
75
|
-
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
32
|
+
content: (name) => `import { agent, claude } from '@agentage/core';
|
|
76
33
|
|
|
77
|
-
export
|
|
34
|
+
export default agent({
|
|
78
35
|
name: '${name}',
|
|
79
36
|
description: 'Runs a task using Claude Code',
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const controller = new AbortController();
|
|
89
|
-
signal.addEventListener('abort', () => controller.abort(), { once: true });
|
|
90
|
-
|
|
91
|
-
for await (const message of query({
|
|
92
|
-
prompt: input.task,
|
|
93
|
-
options: { allowedTools: ['Read', 'Glob', 'Grep', 'Bash'], abortController: controller, maxTurns: 10 },
|
|
94
|
-
})) {
|
|
95
|
-
if (message.type === 'result') {
|
|
96
|
-
yield { type: 'result', data: { type: 'result', success: message.subtype === 'success' }, timestamp: Date.now() };
|
|
97
|
-
}
|
|
98
|
-
}
|
|
37
|
+
async *run({ task }, { signal }) {
|
|
38
|
+
yield* claude(task, {
|
|
39
|
+
signal,
|
|
40
|
+
tools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
41
|
+
maxTurns: 10,
|
|
42
|
+
});
|
|
99
43
|
},
|
|
100
44
|
});
|
|
101
|
-
|
|
102
|
-
export default agent;
|
|
103
45
|
`,
|
|
104
46
|
},
|
|
105
47
|
copilot: {
|
|
106
48
|
deps: ['@github/copilot-sdk'],
|
|
107
|
-
content: (name) => `import {
|
|
108
|
-
import { CopilotClient, approveAll } from '@github/copilot-sdk';
|
|
49
|
+
content: (name) => `import { agent, copilot } from '@agentage/core';
|
|
109
50
|
|
|
110
|
-
export
|
|
51
|
+
export default agent({
|
|
111
52
|
name: '${name}',
|
|
112
53
|
description: 'Runs a task using GitHub Copilot',
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const client = new CopilotClient();
|
|
116
|
-
try {
|
|
117
|
-
await client.start();
|
|
118
|
-
const session = await client.createSession({ model: 'gpt-4o', onPermissionRequest: approveAll });
|
|
119
|
-
signal.addEventListener('abort', () => session.abort(), { once: true });
|
|
120
|
-
|
|
121
|
-
const idle = new Promise<void>((resolve) => { session.on('session.idle', () => resolve()); });
|
|
122
|
-
await session.send({ prompt: input.task });
|
|
123
|
-
await idle;
|
|
124
|
-
|
|
125
|
-
yield { type: 'result', data: { type: 'result', success: true }, timestamp: Date.now() };
|
|
126
|
-
await session.disconnect();
|
|
127
|
-
} finally {
|
|
128
|
-
await client.stop().catch(() => {});
|
|
129
|
-
}
|
|
54
|
+
async *run({ task }, { signal }) {
|
|
55
|
+
yield* copilot(task, { signal, model: 'gpt-4o' });
|
|
130
56
|
},
|
|
131
57
|
});
|
|
58
|
+
`,
|
|
59
|
+
},
|
|
60
|
+
llm: {
|
|
61
|
+
content: (name) => `import { agent } from '@agentage/core';
|
|
132
62
|
|
|
133
|
-
export default agent
|
|
63
|
+
export default agent({
|
|
64
|
+
name: '${name}',
|
|
65
|
+
description: 'An LLM-powered agent',
|
|
66
|
+
model: 'claude-sonnet-4-6',
|
|
67
|
+
tools: ['read', 'glob', 'grep'],
|
|
68
|
+
prompt: \`You are a helpful assistant.
|
|
69
|
+
Respond concisely and cite sources when possible.\`,
|
|
70
|
+
});
|
|
134
71
|
`,
|
|
135
72
|
},
|
|
136
73
|
};
|
|
@@ -139,7 +76,7 @@ export const createCreateCommand = () => {
|
|
|
139
76
|
const cmd = new Command('create')
|
|
140
77
|
.description('Scaffold a new agent from a template')
|
|
141
78
|
.argument('<name>', 'Agent name (kebab-case)')
|
|
142
|
-
.option('-t, --template <template>', 'Template: simple, shell, claude, copilot', 'simple')
|
|
79
|
+
.option('-t, --template <template>', 'Template: simple, shell, claude, copilot, llm', 'simple')
|
|
143
80
|
.option('-d, --dir <dir>', 'Output directory', '.')
|
|
144
81
|
.action(async (name, options) => {
|
|
145
82
|
if (!KEBAB_CASE.test(name)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,SAAS,GAA2E;IACxF,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;;;WAGZ,IAAI
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA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ACT,KAAK,CAAC,MAAM,CAAC,0CAA0C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAClF,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CAAC,mBAAmB,QAAQ,mDAAmD,CAAC,CAC1F,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-agent.agent.d.ts","sourceRoot":"","sources":["../../src/examples/claude-agent.agent.ts"],"names":[],"mappings":";AAEA,wBAUG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { agent, claude } from '@agentage/core';
|
|
2
|
+
export default agent({
|
|
3
|
+
name: 'claude-agent',
|
|
4
|
+
description: 'Runs a task using Claude Code with Read, Glob, Grep, Bash tools',
|
|
5
|
+
async *run({ task }, { signal }) {
|
|
6
|
+
yield* claude(task, {
|
|
7
|
+
signal,
|
|
8
|
+
tools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
9
|
+
maxTurns: 10,
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=claude-agent.agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-agent.agent.js","sourceRoot":"","sources":["../../src/examples/claude-agent.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE/C,eAAe,KAAK,CAAC;IACnB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,iEAAiE;IAC9E,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE;QAC7B,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE;YAClB,MAAM;YACN,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YACxD,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-reviewer.agent.d.ts","sourceRoot":"","sources":["../../src/examples/code-reviewer.agent.ts"],"names":[],"mappings":";AAEA,wBAQG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { agent } from '@agentage/core';
|
|
2
|
+
export default agent({
|
|
3
|
+
name: 'code-reviewer',
|
|
4
|
+
description: 'Reviews code for quality issues',
|
|
5
|
+
model: 'claude-sonnet-4-6',
|
|
6
|
+
tools: ['read', 'glob', 'grep'],
|
|
7
|
+
prompt: `You are a senior code reviewer.
|
|
8
|
+
Focus on correctness, performance, and readability.
|
|
9
|
+
Always cite file:line when reporting issues.`,
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=code-reviewer.agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-reviewer.agent.js","sourceRoot":"","sources":["../../src/examples/code-reviewer.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,eAAe,KAAK,CAAC;IACnB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,iCAAiC;IAC9C,KAAK,EAAE,mBAAmB;IAC1B,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAC/B,MAAM,EAAE;;6CAEmC;CAC5C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.agent.d.ts","sourceRoot":"","sources":["../../src/examples/copilot.agent.ts"],"names":[],"mappings":";AAEA,wBAMG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { agent, copilot } from '@agentage/core';
|
|
2
|
+
export default agent({
|
|
3
|
+
name: 'copilot',
|
|
4
|
+
description: 'Runs a task using GitHub Copilot',
|
|
5
|
+
async *run({ task }, { signal }) {
|
|
6
|
+
yield* copilot(task, { signal, model: 'gpt-4o' });
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=copilot.agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.agent.js","sourceRoot":"","sources":["../../src/examples/copilot.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAe,KAAK,CAAC;IACnB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,kCAAkC;IAC/C,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE;QAC7B,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
1
|
+
declare const _default: import("@agentage/core").Agent;
|
|
2
|
+
export default _default;
|
|
3
3
|
//# sourceMappingURL=countdown.agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countdown.agent.d.ts","sourceRoot":"","sources":["../../src/examples/countdown.agent.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"countdown.agent.d.ts","sourceRoot":"","sources":["../../src/examples/countdown.agent.ts"],"names":[],"mappings":";AAEA,wBAWG"}
|
|
@@ -1,51 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { agent, output, progress } from '@agentage/core';
|
|
2
|
+
export default agent({
|
|
3
3
|
name: 'countdown',
|
|
4
4
|
description: 'Counts down from 5 to 0 with 1-second delays',
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
path: '',
|
|
8
|
-
async *run(input, { signal }) {
|
|
9
|
-
const start = input.config?.start ? Number(input.config.start) : 5;
|
|
5
|
+
async *run({ config }, { sleep }) {
|
|
6
|
+
const start = Number(config?.start ?? 5);
|
|
10
7
|
for (let i = start; i >= 0; i--) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
data: { type: 'output', content: `${i}`, format: 'text' },
|
|
16
|
-
timestamp: Date.now(),
|
|
17
|
-
};
|
|
18
|
-
yield {
|
|
19
|
-
type: 'output',
|
|
20
|
-
data: {
|
|
21
|
-
type: 'output',
|
|
22
|
-
content: { percent: ((start - i) / start) * 100, message: `${i}...` },
|
|
23
|
-
format: 'progress',
|
|
24
|
-
},
|
|
25
|
-
timestamp: Date.now(),
|
|
26
|
-
};
|
|
27
|
-
if (i > 0) {
|
|
28
|
-
await new Promise((resolve, reject) => {
|
|
29
|
-
const timer = setTimeout(resolve, 1000);
|
|
30
|
-
signal.addEventListener('abort', () => {
|
|
31
|
-
clearTimeout(timer);
|
|
32
|
-
reject(new DOMException('Aborted', 'AbortError'));
|
|
33
|
-
}, { once: true });
|
|
34
|
-
}).catch((err) => {
|
|
35
|
-
if (err instanceof DOMException && err.name === 'AbortError')
|
|
36
|
-
return;
|
|
37
|
-
throw err;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (!signal.aborted) {
|
|
42
|
-
yield {
|
|
43
|
-
type: 'result',
|
|
44
|
-
data: { type: 'result', success: true, output: 'Countdown complete' },
|
|
45
|
-
timestamp: Date.now(),
|
|
46
|
-
};
|
|
8
|
+
yield output(`${i}`);
|
|
9
|
+
yield progress(((start - i) / start) * 100, `${i}...`);
|
|
10
|
+
if (i > 0)
|
|
11
|
+
await sleep(1000);
|
|
47
12
|
}
|
|
48
13
|
},
|
|
49
14
|
});
|
|
50
|
-
export default agent;
|
|
51
15
|
//# sourceMappingURL=countdown.agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countdown.agent.js","sourceRoot":"","sources":["../../src/examples/countdown.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"countdown.agent.js","sourceRoot":"","sources":["../../src/examples/countdown.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEzD,eAAe,KAAK,CAAC;IACnB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,8CAA8C;IAC3D,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;QACzC,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrB,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YACvD,IAAI,CAAC,GAAG,CAAC;gBAAE,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello.agent.d.ts","sourceRoot":"","sources":["../../src/examples/hello.agent.ts"],"names":[],"mappings":";AAEA,wBAMG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello.agent.js","sourceRoot":"","sources":["../../src/examples/hello.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE/C,eAAe,KAAK,CAAC;IACnB,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,YAAY;IACzB,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACjB,MAAM,MAAM,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
1
|
+
declare const _default: import("@agentage/core").Agent;
|
|
2
|
+
export default _default;
|
|
3
3
|
//# sourceMappingURL=shell.agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.agent.d.ts","sourceRoot":"","sources":["../../src/examples/shell.agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell.agent.d.ts","sourceRoot":"","sources":["../../src/examples/shell.agent.ts"],"names":[],"mappings":";AAEA,wBAMG"}
|
|
@@ -1,98 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { createInterface } from 'node:readline';
|
|
4
|
-
export const agent = createAgent({
|
|
1
|
+
import { agent, shell } from '@agentage/core';
|
|
2
|
+
export default agent({
|
|
5
3
|
name: 'shell',
|
|
6
4
|
description: 'Executes a shell command and streams output',
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
path: '',
|
|
10
|
-
async *run(input, { signal }) {
|
|
11
|
-
if (!input.task.trim()) {
|
|
12
|
-
yield {
|
|
13
|
-
type: 'error',
|
|
14
|
-
data: {
|
|
15
|
-
type: 'error',
|
|
16
|
-
code: 'EMPTY_COMMAND',
|
|
17
|
-
message: 'No command provided',
|
|
18
|
-
recoverable: false,
|
|
19
|
-
},
|
|
20
|
-
timestamp: Date.now(),
|
|
21
|
-
};
|
|
22
|
-
yield {
|
|
23
|
-
type: 'result',
|
|
24
|
-
data: { type: 'result', success: false, output: 'No command provided' },
|
|
25
|
-
timestamp: Date.now(),
|
|
26
|
-
};
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (signal.aborted)
|
|
30
|
-
return;
|
|
31
|
-
const events = [];
|
|
32
|
-
let exitCode = null;
|
|
33
|
-
await new Promise((resolve) => {
|
|
34
|
-
const proc = spawn(input.task, {
|
|
35
|
-
shell: true,
|
|
36
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
37
|
-
});
|
|
38
|
-
if (signal.aborted) {
|
|
39
|
-
proc.kill('SIGKILL');
|
|
40
|
-
resolve();
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const onAbort = () => {
|
|
44
|
-
proc.kill('SIGKILL');
|
|
45
|
-
};
|
|
46
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
47
|
-
if (proc.stdout) {
|
|
48
|
-
const rl = createInterface({ input: proc.stdout });
|
|
49
|
-
rl.on('line', (line) => {
|
|
50
|
-
events.push({
|
|
51
|
-
type: 'output',
|
|
52
|
-
data: { type: 'output', content: line, format: 'text' },
|
|
53
|
-
timestamp: Date.now(),
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if (proc.stderr) {
|
|
58
|
-
const rl = createInterface({ input: proc.stderr });
|
|
59
|
-
rl.on('line', (line) => {
|
|
60
|
-
events.push({
|
|
61
|
-
type: 'error',
|
|
62
|
-
data: { type: 'error', code: 'STDERR', message: line, recoverable: true },
|
|
63
|
-
timestamp: Date.now(),
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
proc.on('error', (err) => {
|
|
68
|
-
events.push({
|
|
69
|
-
type: 'error',
|
|
70
|
-
data: { type: 'error', code: 'SPAWN_ERROR', message: err.message, recoverable: false },
|
|
71
|
-
timestamp: Date.now(),
|
|
72
|
-
});
|
|
73
|
-
resolve();
|
|
74
|
-
});
|
|
75
|
-
proc.on('close', (code) => {
|
|
76
|
-
exitCode = code;
|
|
77
|
-
signal.removeEventListener('abort', onAbort);
|
|
78
|
-
resolve();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
for (const event of events) {
|
|
82
|
-
yield event;
|
|
83
|
-
}
|
|
84
|
-
if (!signal.aborted) {
|
|
85
|
-
yield {
|
|
86
|
-
type: 'result',
|
|
87
|
-
data: {
|
|
88
|
-
type: 'result',
|
|
89
|
-
success: exitCode === 0,
|
|
90
|
-
output: exitCode === 0 ? 'Command completed' : `Exited with code ${exitCode}`,
|
|
91
|
-
},
|
|
92
|
-
timestamp: Date.now(),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
5
|
+
async *run({ task }) {
|
|
6
|
+
yield* shell(task);
|
|
95
7
|
},
|
|
96
8
|
});
|
|
97
|
-
export default agent;
|
|
98
9
|
//# sourceMappingURL=shell.agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.agent.js","sourceRoot":"","sources":["../../src/examples/shell.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"shell.agent.js","sourceRoot":"","sources":["../../src/examples/shell.agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAe,KAAK,CAAC;IACnB,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,6CAA6C;IAC1D,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACjB,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentage/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Agentage CLI and daemon — control plane for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"prepublishOnly": "npm run verify"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agentage/core": "^0.
|
|
32
|
+
"@agentage/core": "^0.4.0",
|
|
33
33
|
"@agentage/platform": "^0.2.1",
|
|
34
34
|
"@supabase/supabase-js": "2.100.1",
|
|
35
35
|
"chalk": "latest",
|