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/dist/index.d.cts
CHANGED
|
@@ -1136,6 +1136,47 @@ declare class WriteFileTool extends EnvironmentToolBase<WriteFileToolConfig, Wri
|
|
|
1136
1136
|
get examples(): Array<ToolExample<WriteFileToolInput, WriteFileToolOutput>>;
|
|
1137
1137
|
}
|
|
1138
1138
|
|
|
1139
|
+
declare const SubmitToolName = "submit";
|
|
1140
|
+
type SubmitToolConfig = ToolConfig;
|
|
1141
|
+
declare const SubmitToolInput: z$1.ZodObject<{}, z$1.core.$strip>;
|
|
1142
|
+
type SubmitToolInput = z$1.infer<typeof SubmitToolInput>;
|
|
1143
|
+
declare const SubmitToolOutput: z$1.ZodObject<{}, z$1.core.$strip>;
|
|
1144
|
+
type SubmitToolOutput = z$1.infer<typeof SubmitToolOutput>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Class for the Submit tool.
|
|
1147
|
+
*/
|
|
1148
|
+
declare class SubmitTool extends ToolBase<SubmitToolConfig, SubmitToolInput, SubmitToolOutput> {
|
|
1149
|
+
/**
|
|
1150
|
+
* Returns the metadata for the tool.
|
|
1151
|
+
*
|
|
1152
|
+
* The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
|
|
1153
|
+
*
|
|
1154
|
+
* @returns The tool metadata.
|
|
1155
|
+
*/
|
|
1156
|
+
protected getMetadata(): ToolMetadata<SubmitToolInput, SubmitToolOutput>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Executes the tool with the given input.
|
|
1159
|
+
*
|
|
1160
|
+
* @param _ - The input for the tool. Unused.
|
|
1161
|
+
* @param __ - Options from the tool call. Unused.
|
|
1162
|
+
* @returns A promise that resolves to the tool execution result.
|
|
1163
|
+
*/
|
|
1164
|
+
execute(_: SubmitToolInput, __: ToolCallOptions): Promise<SubmitToolOutput>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Converts the tool output to a format suitable for model consumption.
|
|
1167
|
+
*
|
|
1168
|
+
* @param _ - The output from the tool execution. Unused.
|
|
1169
|
+
* @returns The formatted tool result.
|
|
1170
|
+
*/
|
|
1171
|
+
toModelOutput(_: SubmitToolOutput): ModelFormattedToolResult;
|
|
1172
|
+
/**
|
|
1173
|
+
* Gets the examples for the tool.
|
|
1174
|
+
*
|
|
1175
|
+
* @returns The tool examples.
|
|
1176
|
+
*/
|
|
1177
|
+
get examples(): Array<ToolExample<SubmitToolInput, SubmitToolOutput>>;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1139
1180
|
declare const availableEnvironmentTools: {
|
|
1140
1181
|
read_file: typeof ReadFileTool;
|
|
1141
1182
|
write_file: typeof WriteFileTool;
|
|
@@ -1257,4 +1298,4 @@ declare const EnvironmentNames: EnvironmentName[];
|
|
|
1257
1298
|
*/
|
|
1258
1299
|
declare function createEnvironment<T extends EnvironmentName>(environmentName: T, config: EnvironmentConfigOf<EnvironmentClasses[T]>): EnvironmentClasses[T];
|
|
1259
1300
|
|
|
1260
|
-
export { type CodeAgentCreatorConfig, type CommandLineEnvironmentInterface, CopyFileResult, CopyFileTool, type CopyFileToolConfig, CopyFileToolInput, CopyFileToolName, CopyFileToolOutput, DeleteFileResult, DeleteFileTool, type DeleteFileToolConfig, DeleteFileToolInput, DeleteFileToolName, DeleteFileToolOutput, DockerEnvironment, type DockerEnvironmentConfig, DockerEnvironmentName, EditFileTool, type EditFileToolConfig, EditFileToolInput, EditFileToolName, EditFileToolOutput, type Environment, type EnvironmentName, EnvironmentNames, type EnvironmentToolInterface, type EnvironmentToolName, EnvironmentToolNames, type EnvironmentToolSafetyLevel, EnvironmentToolSafetyLevels, type FilesystemEnvironmentInterface, GetProjectFileStructureTool, type GetProjectFileStructureToolConfig, GetProjectFileStructureToolInput, GetProjectFileStructureToolName, GetProjectFileStructureToolOutput, GlobTool, type GlobToolConfig, GlobToolInput, GlobToolName, GlobToolOutput, ListDirectoryTool, type ListDirectoryToolConfig, ListDirectoryToolInput, ListDirectoryToolName, ListDirectoryToolOutput, MockFilesystemEnvironment, type MockFilesystemEnvironmentConfig, MockFilesystemEnvironmentName, type ModelFormattedToolResult, MoveFileResult, MoveFileTool, type MoveFileToolConfig, MoveFileToolInput, MoveFileToolName, MoveFileToolOutput, NodeFilesystemEnvironment, type NodeFilesystemEnvironmentConfig, NodeFilesystemEnvironmentName, ReadFileResult, ReadFileTool, type ReadFileToolConfig, ReadFileToolInput, ReadFileToolName, ReadFileToolOutput, ReadManyFilesTool, type ReadManyFilesToolConfig, ReadManyFilesToolInput, ReadManyFilesToolName, ReadManyFilesToolOutput, RunCommandResult, RunCommandTool, type RunCommandToolConfig, RunCommandToolInput, RunCommandToolName, RunCommandToolOutput, type ToolConfig, type ToolExample, type ToolInterface, type ToolsDefinition, UnsafeLocalEnvironment, type UnsafeLocalEnvironmentConfig, UnsafeLocalEnvironmentName, WriteFileResult, WriteFileTool, type WriteFileToolConfig, WriteFileToolInput, WriteFileToolName, WriteFileToolOutput, createCodeAgent, createEnvironment, createEnvironmentTool, createToolsForEnvironment, createToolsForNamedEnvironment };
|
|
1301
|
+
export { type CodeAgentCreatorConfig, type CommandLineEnvironmentInterface, CopyFileResult, CopyFileTool, type CopyFileToolConfig, CopyFileToolInput, CopyFileToolName, CopyFileToolOutput, DeleteFileResult, DeleteFileTool, type DeleteFileToolConfig, DeleteFileToolInput, DeleteFileToolName, DeleteFileToolOutput, DockerEnvironment, type DockerEnvironmentConfig, DockerEnvironmentName, EditFileTool, type EditFileToolConfig, EditFileToolInput, EditFileToolName, EditFileToolOutput, type Environment, type EnvironmentName, EnvironmentNames, type EnvironmentToolInterface, type EnvironmentToolName, EnvironmentToolNames, type EnvironmentToolSafetyLevel, EnvironmentToolSafetyLevels, type FilesystemEnvironmentInterface, GetProjectFileStructureTool, type GetProjectFileStructureToolConfig, GetProjectFileStructureToolInput, GetProjectFileStructureToolName, GetProjectFileStructureToolOutput, GlobTool, type GlobToolConfig, GlobToolInput, GlobToolName, GlobToolOutput, ListDirectoryTool, type ListDirectoryToolConfig, ListDirectoryToolInput, ListDirectoryToolName, ListDirectoryToolOutput, MockFilesystemEnvironment, type MockFilesystemEnvironmentConfig, MockFilesystemEnvironmentName, type ModelFormattedToolResult, MoveFileResult, MoveFileTool, type MoveFileToolConfig, MoveFileToolInput, MoveFileToolName, MoveFileToolOutput, NodeFilesystemEnvironment, type NodeFilesystemEnvironmentConfig, NodeFilesystemEnvironmentName, ReadFileResult, ReadFileTool, type ReadFileToolConfig, ReadFileToolInput, ReadFileToolName, ReadFileToolOutput, ReadManyFilesTool, type ReadManyFilesToolConfig, ReadManyFilesToolInput, ReadManyFilesToolName, ReadManyFilesToolOutput, RunCommandResult, RunCommandTool, type RunCommandToolConfig, RunCommandToolInput, RunCommandToolName, RunCommandToolOutput, SubmitTool, type SubmitToolConfig, SubmitToolInput, SubmitToolName, SubmitToolOutput, type ToolConfig, type ToolExample, type ToolInterface, type ToolsDefinition, UnsafeLocalEnvironment, type UnsafeLocalEnvironmentConfig, UnsafeLocalEnvironmentName, WriteFileResult, WriteFileTool, type WriteFileToolConfig, WriteFileToolInput, WriteFileToolName, WriteFileToolOutput, createCodeAgent, createEnvironment, createEnvironmentTool, createToolsForEnvironment, createToolsForNamedEnvironment };
|
package/dist/index.d.ts
CHANGED
|
@@ -1136,6 +1136,47 @@ declare class WriteFileTool extends EnvironmentToolBase<WriteFileToolConfig, Wri
|
|
|
1136
1136
|
get examples(): Array<ToolExample<WriteFileToolInput, WriteFileToolOutput>>;
|
|
1137
1137
|
}
|
|
1138
1138
|
|
|
1139
|
+
declare const SubmitToolName = "submit";
|
|
1140
|
+
type SubmitToolConfig = ToolConfig;
|
|
1141
|
+
declare const SubmitToolInput: z$1.ZodObject<{}, z$1.core.$strip>;
|
|
1142
|
+
type SubmitToolInput = z$1.infer<typeof SubmitToolInput>;
|
|
1143
|
+
declare const SubmitToolOutput: z$1.ZodObject<{}, z$1.core.$strip>;
|
|
1144
|
+
type SubmitToolOutput = z$1.infer<typeof SubmitToolOutput>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Class for the Submit tool.
|
|
1147
|
+
*/
|
|
1148
|
+
declare class SubmitTool extends ToolBase<SubmitToolConfig, SubmitToolInput, SubmitToolOutput> {
|
|
1149
|
+
/**
|
|
1150
|
+
* Returns the metadata for the tool.
|
|
1151
|
+
*
|
|
1152
|
+
* The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
|
|
1153
|
+
*
|
|
1154
|
+
* @returns The tool metadata.
|
|
1155
|
+
*/
|
|
1156
|
+
protected getMetadata(): ToolMetadata<SubmitToolInput, SubmitToolOutput>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Executes the tool with the given input.
|
|
1159
|
+
*
|
|
1160
|
+
* @param _ - The input for the tool. Unused.
|
|
1161
|
+
* @param __ - Options from the tool call. Unused.
|
|
1162
|
+
* @returns A promise that resolves to the tool execution result.
|
|
1163
|
+
*/
|
|
1164
|
+
execute(_: SubmitToolInput, __: ToolCallOptions): Promise<SubmitToolOutput>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Converts the tool output to a format suitable for model consumption.
|
|
1167
|
+
*
|
|
1168
|
+
* @param _ - The output from the tool execution. Unused.
|
|
1169
|
+
* @returns The formatted tool result.
|
|
1170
|
+
*/
|
|
1171
|
+
toModelOutput(_: SubmitToolOutput): ModelFormattedToolResult;
|
|
1172
|
+
/**
|
|
1173
|
+
* Gets the examples for the tool.
|
|
1174
|
+
*
|
|
1175
|
+
* @returns The tool examples.
|
|
1176
|
+
*/
|
|
1177
|
+
get examples(): Array<ToolExample<SubmitToolInput, SubmitToolOutput>>;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1139
1180
|
declare const availableEnvironmentTools: {
|
|
1140
1181
|
read_file: typeof ReadFileTool;
|
|
1141
1182
|
write_file: typeof WriteFileTool;
|
|
@@ -1257,4 +1298,4 @@ declare const EnvironmentNames: EnvironmentName[];
|
|
|
1257
1298
|
*/
|
|
1258
1299
|
declare function createEnvironment<T extends EnvironmentName>(environmentName: T, config: EnvironmentConfigOf<EnvironmentClasses[T]>): EnvironmentClasses[T];
|
|
1259
1300
|
|
|
1260
|
-
export { type CodeAgentCreatorConfig, type CommandLineEnvironmentInterface, CopyFileResult, CopyFileTool, type CopyFileToolConfig, CopyFileToolInput, CopyFileToolName, CopyFileToolOutput, DeleteFileResult, DeleteFileTool, type DeleteFileToolConfig, DeleteFileToolInput, DeleteFileToolName, DeleteFileToolOutput, DockerEnvironment, type DockerEnvironmentConfig, DockerEnvironmentName, EditFileTool, type EditFileToolConfig, EditFileToolInput, EditFileToolName, EditFileToolOutput, type Environment, type EnvironmentName, EnvironmentNames, type EnvironmentToolInterface, type EnvironmentToolName, EnvironmentToolNames, type EnvironmentToolSafetyLevel, EnvironmentToolSafetyLevels, type FilesystemEnvironmentInterface, GetProjectFileStructureTool, type GetProjectFileStructureToolConfig, GetProjectFileStructureToolInput, GetProjectFileStructureToolName, GetProjectFileStructureToolOutput, GlobTool, type GlobToolConfig, GlobToolInput, GlobToolName, GlobToolOutput, ListDirectoryTool, type ListDirectoryToolConfig, ListDirectoryToolInput, ListDirectoryToolName, ListDirectoryToolOutput, MockFilesystemEnvironment, type MockFilesystemEnvironmentConfig, MockFilesystemEnvironmentName, type ModelFormattedToolResult, MoveFileResult, MoveFileTool, type MoveFileToolConfig, MoveFileToolInput, MoveFileToolName, MoveFileToolOutput, NodeFilesystemEnvironment, type NodeFilesystemEnvironmentConfig, NodeFilesystemEnvironmentName, ReadFileResult, ReadFileTool, type ReadFileToolConfig, ReadFileToolInput, ReadFileToolName, ReadFileToolOutput, ReadManyFilesTool, type ReadManyFilesToolConfig, ReadManyFilesToolInput, ReadManyFilesToolName, ReadManyFilesToolOutput, RunCommandResult, RunCommandTool, type RunCommandToolConfig, RunCommandToolInput, RunCommandToolName, RunCommandToolOutput, type ToolConfig, type ToolExample, type ToolInterface, type ToolsDefinition, UnsafeLocalEnvironment, type UnsafeLocalEnvironmentConfig, UnsafeLocalEnvironmentName, WriteFileResult, WriteFileTool, type WriteFileToolConfig, WriteFileToolInput, WriteFileToolName, WriteFileToolOutput, createCodeAgent, createEnvironment, createEnvironmentTool, createToolsForEnvironment, createToolsForNamedEnvironment };
|
|
1301
|
+
export { type CodeAgentCreatorConfig, type CommandLineEnvironmentInterface, CopyFileResult, CopyFileTool, type CopyFileToolConfig, CopyFileToolInput, CopyFileToolName, CopyFileToolOutput, DeleteFileResult, DeleteFileTool, type DeleteFileToolConfig, DeleteFileToolInput, DeleteFileToolName, DeleteFileToolOutput, DockerEnvironment, type DockerEnvironmentConfig, DockerEnvironmentName, EditFileTool, type EditFileToolConfig, EditFileToolInput, EditFileToolName, EditFileToolOutput, type Environment, type EnvironmentName, EnvironmentNames, type EnvironmentToolInterface, type EnvironmentToolName, EnvironmentToolNames, type EnvironmentToolSafetyLevel, EnvironmentToolSafetyLevels, type FilesystemEnvironmentInterface, GetProjectFileStructureTool, type GetProjectFileStructureToolConfig, GetProjectFileStructureToolInput, GetProjectFileStructureToolName, GetProjectFileStructureToolOutput, GlobTool, type GlobToolConfig, GlobToolInput, GlobToolName, GlobToolOutput, ListDirectoryTool, type ListDirectoryToolConfig, ListDirectoryToolInput, ListDirectoryToolName, ListDirectoryToolOutput, MockFilesystemEnvironment, type MockFilesystemEnvironmentConfig, MockFilesystemEnvironmentName, type ModelFormattedToolResult, MoveFileResult, MoveFileTool, type MoveFileToolConfig, MoveFileToolInput, MoveFileToolName, MoveFileToolOutput, NodeFilesystemEnvironment, type NodeFilesystemEnvironmentConfig, NodeFilesystemEnvironmentName, ReadFileResult, ReadFileTool, type ReadFileToolConfig, ReadFileToolInput, ReadFileToolName, ReadFileToolOutput, ReadManyFilesTool, type ReadManyFilesToolConfig, ReadManyFilesToolInput, ReadManyFilesToolName, ReadManyFilesToolOutput, RunCommandResult, RunCommandTool, type RunCommandToolConfig, RunCommandToolInput, RunCommandToolName, RunCommandToolOutput, SubmitTool, type SubmitToolConfig, SubmitToolInput, SubmitToolName, SubmitToolOutput, type ToolConfig, type ToolExample, type ToolInterface, type ToolsDefinition, UnsafeLocalEnvironment, type UnsafeLocalEnvironmentConfig, UnsafeLocalEnvironmentName, WriteFileResult, WriteFileTool, type WriteFileToolConfig, WriteFileToolInput, WriteFileToolName, WriteFileToolOutput, createCodeAgent, createEnvironment, createEnvironmentTool, createToolsForEnvironment, createToolsForNamedEnvironment };
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,12 @@ function escapeCommandArg(arg) {
|
|
|
9
9
|
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// src/util/escape-command.ts
|
|
13
|
+
function escapeCommand(command) {
|
|
14
|
+
const escaped = command.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
15
|
+
return `"${escaped}"`;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
// src/util/validate-relative-path.ts
|
|
13
19
|
import * as path from "path";
|
|
14
20
|
function validateRelativePath(filePath) {
|
|
@@ -312,7 +318,7 @@ var DockerEnvironment = class extends UnixEnvironmentBase {
|
|
|
312
318
|
async executeCommand(command) {
|
|
313
319
|
return new Promise((resolve) => {
|
|
314
320
|
exec(
|
|
315
|
-
`docker exec ${this._envConfig.containerId} ${this._commandPrefix
|
|
321
|
+
`docker exec ${this._envConfig.containerId} sh -c ${escapeCommand(this._commandPrefix + command)}`,
|
|
316
322
|
(error, stdout, stderr) => {
|
|
317
323
|
const exitCode = error ? error.code ?? 1 : 0;
|
|
318
324
|
resolve([exitCode, stdout, stderr]);
|
|
@@ -2099,13 +2105,6 @@ var WriteFileTool = class extends EnvironmentToolBase {
|
|
|
2099
2105
|
}
|
|
2100
2106
|
};
|
|
2101
2107
|
|
|
2102
|
-
// src/agent-creators.ts
|
|
2103
|
-
import {
|
|
2104
|
-
Experimental_Agent as Agent,
|
|
2105
|
-
stepCountIs,
|
|
2106
|
-
hasToolCall
|
|
2107
|
-
} from "ai";
|
|
2108
|
-
|
|
2109
2108
|
// src/tools/submit-tool.ts
|
|
2110
2109
|
import { z as z13 } from "zod";
|
|
2111
2110
|
var SubmitToolName = "submit";
|
|
@@ -2160,6 +2159,13 @@ var SubmitTool = class extends ToolBase {
|
|
|
2160
2159
|
}
|
|
2161
2160
|
};
|
|
2162
2161
|
|
|
2162
|
+
// src/agent-creators.ts
|
|
2163
|
+
import {
|
|
2164
|
+
Experimental_Agent as Agent,
|
|
2165
|
+
stepCountIs,
|
|
2166
|
+
hasToolCall
|
|
2167
|
+
} from "ai";
|
|
2168
|
+
|
|
2163
2169
|
// src/instructions.ts
|
|
2164
2170
|
function getAdditionalInstructions(config) {
|
|
2165
2171
|
const { maxSteps, allowSubmit, tools } = config;
|
|
@@ -2406,18 +2412,18 @@ function createCodeAgent(agentConfig) {
|
|
|
2406
2412
|
`No tools definition provided for environment "${environmentName}". Please provide a tools definition for each environment.`
|
|
2407
2413
|
);
|
|
2408
2414
|
}
|
|
2409
|
-
const
|
|
2415
|
+
const envTools = createToolsForNamedEnvironment(
|
|
2410
2416
|
environmentName,
|
|
2411
2417
|
environment,
|
|
2412
2418
|
environmentToolsDefinition[environmentName]
|
|
2413
2419
|
);
|
|
2414
|
-
for (const [toolName, tool] of Object.entries(
|
|
2415
|
-
if (toolName in
|
|
2420
|
+
for (const [toolName, tool] of Object.entries(envTools)) {
|
|
2421
|
+
if (toolName in environmentTools) {
|
|
2416
2422
|
throw new Error(
|
|
2417
2423
|
`Tool name conflict: The tool name "${toolName}" from environment "${environmentName}" is already used by another environment's tools.`
|
|
2418
2424
|
);
|
|
2419
2425
|
}
|
|
2420
|
-
|
|
2426
|
+
environmentTools[toolName] = tool;
|
|
2421
2427
|
}
|
|
2422
2428
|
}
|
|
2423
2429
|
} else if ("environment" in remainingConfig) {
|
|
@@ -2574,6 +2580,10 @@ export {
|
|
|
2574
2580
|
RunCommandToolInput,
|
|
2575
2581
|
RunCommandToolName,
|
|
2576
2582
|
RunCommandToolOutput,
|
|
2583
|
+
SubmitTool,
|
|
2584
|
+
SubmitToolInput,
|
|
2585
|
+
SubmitToolName,
|
|
2586
|
+
SubmitToolOutput,
|
|
2577
2587
|
UnsafeLocalEnvironment,
|
|
2578
2588
|
UnsafeLocalEnvironmentName,
|
|
2579
2589
|
WriteFileResult,
|