ai-code-agents 0.1.0-beta.1 → 0.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/README.md +13 -8
- package/dist/index.cjs +22 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +22 -12
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -13,10 +13,14 @@ A TypeScript SDK for creating AI agents that interact with sandboxed code execut
|
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
|
-
You will need
|
|
16
|
+
You will need:
|
|
17
|
+
|
|
18
|
+
- Node.js 20+
|
|
19
|
+
- `npm` or another package manager
|
|
20
|
+
- AI SDK v5+ and zod v4+ (see below)
|
|
17
21
|
|
|
18
22
|
```bash
|
|
19
|
-
npm install ai-code-agents
|
|
23
|
+
npm install ai-code-agents ai zod
|
|
20
24
|
```
|
|
21
25
|
|
|
22
26
|
## Quick Start
|
|
@@ -37,10 +41,11 @@ const agent = createCodeAgent({
|
|
|
37
41
|
environment,
|
|
38
42
|
environmentToolsDefinition: 'all',
|
|
39
43
|
maxSteps: 10,
|
|
44
|
+
logStep: (log: string) => console.log(log),
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
// Run the agent
|
|
43
|
-
const result = await agent.
|
|
48
|
+
const result = await agent.generate({
|
|
44
49
|
prompt: 'Create a simple Node.js HTTP server in server.js',
|
|
45
50
|
});
|
|
46
51
|
|
|
@@ -119,7 +124,7 @@ const environment = createEnvironment('unsafe-local', {
|
|
|
119
124
|
});
|
|
120
125
|
|
|
121
126
|
const agent = createCodeAgent({
|
|
122
|
-
model: anthropic('claude-
|
|
127
|
+
model: anthropic('claude-sonnet-4.5'),
|
|
123
128
|
environment,
|
|
124
129
|
environmentToolsDefinition: 'basic', // Read/write only, no deletions
|
|
125
130
|
maxSteps: 15,
|
|
@@ -128,7 +133,7 @@ const agent = createCodeAgent({
|
|
|
128
133
|
},
|
|
129
134
|
});
|
|
130
135
|
|
|
131
|
-
const result = await agent.
|
|
136
|
+
const result = await agent.generate({
|
|
132
137
|
prompt: 'Create a Python script that calculates fibonacci numbers',
|
|
133
138
|
});
|
|
134
139
|
```
|
|
@@ -162,7 +167,7 @@ const agent = createCodeAgent({
|
|
|
162
167
|
maxSteps: 20,
|
|
163
168
|
});
|
|
164
169
|
|
|
165
|
-
const result = await agent.
|
|
170
|
+
const result = await agent.generate({
|
|
166
171
|
prompt: 'Create a React frontend and Flask backend for a todo app',
|
|
167
172
|
});
|
|
168
173
|
```
|
|
@@ -178,7 +183,7 @@ const environment = createEnvironment('node-filesystem', {
|
|
|
178
183
|
});
|
|
179
184
|
|
|
180
185
|
const agent = createCodeAgent({
|
|
181
|
-
model: google('gemini-2.
|
|
186
|
+
model: google('gemini-2.5-pro'),
|
|
182
187
|
environment,
|
|
183
188
|
environmentToolsDefinition: [
|
|
184
189
|
'read_file',
|
|
@@ -215,7 +220,7 @@ Track agent execution with detailed step logs:
|
|
|
215
220
|
|
|
216
221
|
```typescript
|
|
217
222
|
const agent = createCodeAgent({
|
|
218
|
-
model: anthropic('claude-
|
|
223
|
+
model: anthropic('claude-sonnet-4.5'),
|
|
219
224
|
environment,
|
|
220
225
|
environmentToolsDefinition: 'all',
|
|
221
226
|
maxSteps: 15,
|
package/dist/index.cjs
CHANGED
|
@@ -84,6 +84,10 @@ __export(index_exports, {
|
|
|
84
84
|
RunCommandToolInput: () => RunCommandToolInput,
|
|
85
85
|
RunCommandToolName: () => RunCommandToolName,
|
|
86
86
|
RunCommandToolOutput: () => RunCommandToolOutput,
|
|
87
|
+
SubmitTool: () => SubmitTool,
|
|
88
|
+
SubmitToolInput: () => SubmitToolInput,
|
|
89
|
+
SubmitToolName: () => SubmitToolName,
|
|
90
|
+
SubmitToolOutput: () => SubmitToolOutput,
|
|
87
91
|
UnsafeLocalEnvironment: () => UnsafeLocalEnvironment,
|
|
88
92
|
UnsafeLocalEnvironmentName: () => UnsafeLocalEnvironmentName,
|
|
89
93
|
WriteFileResult: () => WriteFileResult,
|
|
@@ -110,6 +114,12 @@ function escapeCommandArg(arg) {
|
|
|
110
114
|
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
111
115
|
}
|
|
112
116
|
|
|
117
|
+
// src/util/escape-command.ts
|
|
118
|
+
function escapeCommand(command) {
|
|
119
|
+
const escaped = command.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
120
|
+
return `"${escaped}"`;
|
|
121
|
+
}
|
|
122
|
+
|
|
113
123
|
// src/util/validate-relative-path.ts
|
|
114
124
|
var path = __toESM(require("path"), 1);
|
|
115
125
|
function validateRelativePath(filePath) {
|
|
@@ -413,7 +423,7 @@ var DockerEnvironment = class extends UnixEnvironmentBase {
|
|
|
413
423
|
async executeCommand(command) {
|
|
414
424
|
return new Promise((resolve) => {
|
|
415
425
|
(0, import_node_child_process.exec)(
|
|
416
|
-
`docker exec ${this._envConfig.containerId} ${this._commandPrefix
|
|
426
|
+
`docker exec ${this._envConfig.containerId} sh -c ${escapeCommand(this._commandPrefix + command)}`,
|
|
417
427
|
(error, stdout, stderr) => {
|
|
418
428
|
const exitCode = error ? error.code ?? 1 : 0;
|
|
419
429
|
resolve([exitCode, stdout, stderr]);
|
|
@@ -2200,9 +2210,6 @@ var WriteFileTool = class extends EnvironmentToolBase {
|
|
|
2200
2210
|
}
|
|
2201
2211
|
};
|
|
2202
2212
|
|
|
2203
|
-
// src/agent-creators.ts
|
|
2204
|
-
var import_ai = require("ai");
|
|
2205
|
-
|
|
2206
2213
|
// src/tools/submit-tool.ts
|
|
2207
2214
|
var import_zod12 = require("zod");
|
|
2208
2215
|
var SubmitToolName = "submit";
|
|
@@ -2257,6 +2264,9 @@ var SubmitTool = class extends ToolBase {
|
|
|
2257
2264
|
}
|
|
2258
2265
|
};
|
|
2259
2266
|
|
|
2267
|
+
// src/agent-creators.ts
|
|
2268
|
+
var import_ai = require("ai");
|
|
2269
|
+
|
|
2260
2270
|
// src/instructions.ts
|
|
2261
2271
|
function getAdditionalInstructions(config) {
|
|
2262
2272
|
const { maxSteps, allowSubmit, tools } = config;
|
|
@@ -2503,18 +2513,18 @@ function createCodeAgent(agentConfig) {
|
|
|
2503
2513
|
`No tools definition provided for environment "${environmentName}". Please provide a tools definition for each environment.`
|
|
2504
2514
|
);
|
|
2505
2515
|
}
|
|
2506
|
-
const
|
|
2516
|
+
const envTools = createToolsForNamedEnvironment(
|
|
2507
2517
|
environmentName,
|
|
2508
2518
|
environment,
|
|
2509
2519
|
environmentToolsDefinition[environmentName]
|
|
2510
2520
|
);
|
|
2511
|
-
for (const [toolName, tool] of Object.entries(
|
|
2512
|
-
if (toolName in
|
|
2521
|
+
for (const [toolName, tool] of Object.entries(envTools)) {
|
|
2522
|
+
if (toolName in environmentTools) {
|
|
2513
2523
|
throw new Error(
|
|
2514
2524
|
`Tool name conflict: The tool name "${toolName}" from environment "${environmentName}" is already used by another environment's tools.`
|
|
2515
2525
|
);
|
|
2516
2526
|
}
|
|
2517
|
-
|
|
2527
|
+
environmentTools[toolName] = tool;
|
|
2518
2528
|
}
|
|
2519
2529
|
}
|
|
2520
2530
|
} else if ("environment" in remainingConfig) {
|
|
@@ -2672,6 +2682,10 @@ function createEnvironment(environmentName, config) {
|
|
|
2672
2682
|
RunCommandToolInput,
|
|
2673
2683
|
RunCommandToolName,
|
|
2674
2684
|
RunCommandToolOutput,
|
|
2685
|
+
SubmitTool,
|
|
2686
|
+
SubmitToolInput,
|
|
2687
|
+
SubmitToolName,
|
|
2688
|
+
SubmitToolOutput,
|
|
2675
2689
|
UnsafeLocalEnvironment,
|
|
2676
2690
|
UnsafeLocalEnvironmentName,
|
|
2677
2691
|
WriteFileResult,
|