concevent-ai-agent-sdk 2.2.0 → 2.3.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 +279 -0
- package/dist/core/orchestrator.d.ts.map +1 -1
- package/dist/core/orchestrator.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/bash-output.d.ts +19 -0
- package/dist/tools/bash-output.d.ts.map +1 -0
- package/dist/tools/bash-output.js +47 -0
- package/dist/tools/bash-output.js.map +1 -0
- package/dist/tools/bash.d.ts +25 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +79 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit.d.ts +28 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +97 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/glob.d.ts +25 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +88 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/grep.d.ts +31 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +195 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/index.d.ts +85 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +141 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/kill-bash.d.ts +19 -0
- package/dist/tools/kill-bash.d.ts.map +1 -0
- package/dist/tools/kill-bash.js +49 -0
- package/dist/tools/kill-bash.js.map +1 -0
- package/dist/tools/read.d.ts +25 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +103 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/task.d.ts +25 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +71 -0
- package/dist/tools/task.js.map +1 -0
- package/dist/tools/todo-write.d.ts +46 -0
- package/dist/tools/todo-write.d.ts.map +1 -0
- package/dist/tools/todo-write.js +151 -0
- package/dist/tools/todo-write.js.map +1 -0
- package/dist/tools/types.d.ts +147 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +16 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/utils/index.d.ts +3 -0
- package/dist/tools/utils/index.d.ts.map +1 -0
- package/dist/tools/utils/index.js +3 -0
- package/dist/tools/utils/index.js.map +1 -0
- package/dist/tools/utils/path.d.ts +40 -0
- package/dist/tools/utils/path.d.ts.map +1 -0
- package/dist/tools/utils/path.js +146 -0
- package/dist/tools/utils/path.js.map +1 -0
- package/dist/tools/utils/shell.d.ts +49 -0
- package/dist/tools/utils/shell.d.ts.map +1 -0
- package/dist/tools/utils/shell.js +232 -0
- package/dist/tools/utils/shell.js.map +1 -0
- package/dist/tools/write.d.ts +22 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +70 -0
- package/dist/tools/write.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { TOOL_NAMES } from './types.js';
|
|
2
|
+
import { createProcessManagerWithInternal } from './utils/shell.js';
|
|
3
|
+
// Export individual tool creators
|
|
4
|
+
export { createReadTool } from './read.js';
|
|
5
|
+
export { createWriteTool } from './write.js';
|
|
6
|
+
export { createEditTool } from './edit.js';
|
|
7
|
+
export { createGlobTool } from './glob.js';
|
|
8
|
+
export { createGrepTool } from './grep.js';
|
|
9
|
+
export { createBashTool } from './bash.js';
|
|
10
|
+
export { createBashOutputTool } from './bash-output.js';
|
|
11
|
+
export { createKillBashTool } from './kill-bash.js';
|
|
12
|
+
export { createTaskTool } from './task.js';
|
|
13
|
+
export { createTodoWriteTool, createTodoReadTool } from './todo-write.js';
|
|
14
|
+
export { TOOL_NAMES } from './types.js';
|
|
15
|
+
// Export schemas for consumers who want to validate parameters
|
|
16
|
+
export { readSchema } from './read.js';
|
|
17
|
+
export { writeSchema } from './write.js';
|
|
18
|
+
export { editSchema } from './edit.js';
|
|
19
|
+
export { globSchema } from './glob.js';
|
|
20
|
+
export { grepSchema } from './grep.js';
|
|
21
|
+
export { bashSchema } from './bash.js';
|
|
22
|
+
export { bashOutputSchema } from './bash-output.js';
|
|
23
|
+
export { killBashSchema } from './kill-bash.js';
|
|
24
|
+
export { taskSchema } from './task.js';
|
|
25
|
+
export { todoWriteSchema } from './todo-write.js';
|
|
26
|
+
// Import tool creators for factory
|
|
27
|
+
import { createReadTool } from './read.js';
|
|
28
|
+
import { createWriteTool } from './write.js';
|
|
29
|
+
import { createEditTool } from './edit.js';
|
|
30
|
+
import { createGlobTool } from './glob.js';
|
|
31
|
+
import { createGrepTool } from './grep.js';
|
|
32
|
+
import { createBashTool } from './bash.js';
|
|
33
|
+
import { createBashOutputTool } from './bash-output.js';
|
|
34
|
+
import { createKillBashTool } from './kill-bash.js';
|
|
35
|
+
import { createTaskTool } from './task.js';
|
|
36
|
+
import { createTodoWriteTool } from './todo-write.js';
|
|
37
|
+
const TOOL_CREATORS = {
|
|
38
|
+
[TOOL_NAMES.READ]: createReadTool,
|
|
39
|
+
[TOOL_NAMES.WRITE]: createWriteTool,
|
|
40
|
+
[TOOL_NAMES.EDIT]: createEditTool,
|
|
41
|
+
[TOOL_NAMES.GLOB]: createGlobTool,
|
|
42
|
+
[TOOL_NAMES.GREP]: createGrepTool,
|
|
43
|
+
[TOOL_NAMES.BASH]: createBashTool,
|
|
44
|
+
[TOOL_NAMES.BASH_OUTPUT]: createBashOutputTool,
|
|
45
|
+
[TOOL_NAMES.KILL_BASH]: createKillBashTool,
|
|
46
|
+
[TOOL_NAMES.TASK]: createTaskTool,
|
|
47
|
+
[TOOL_NAMES.TODO_WRITE]: createTodoWriteTool,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Creates an array of built-in tools based on configuration.
|
|
51
|
+
* You must explicitly specify which tools you need using the `tools` property.
|
|
52
|
+
* Tool names are strongly typed with autocomplete support.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { createBuiltInTools } from 'concevent-ai-agent-sdk';
|
|
57
|
+
*
|
|
58
|
+
* // Specify exactly which tools you need
|
|
59
|
+
* const { tools, cleanup } = createBuiltInTools({
|
|
60
|
+
* workingDirectory: '/project',
|
|
61
|
+
* tools: ['Read', 'Write', 'Glob'],
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* // For shell tools
|
|
65
|
+
* const { tools: shellTools } = createBuiltInTools({
|
|
66
|
+
* workingDirectory: '/project',
|
|
67
|
+
* tools: ['Bash'],
|
|
68
|
+
* defaultTimeout: 60000,
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* // Don't forget to cleanup when done
|
|
72
|
+
* process.on('exit', () => cleanup());
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export function createBuiltInTools(config) {
|
|
76
|
+
const requestedTools = config.tools;
|
|
77
|
+
if (!requestedTools || requestedTools.length === 0) {
|
|
78
|
+
throw new Error('You must specify which tools to include using the `tools` property. ' +
|
|
79
|
+
`Available tools: ${Object.keys(TOOL_CREATORS).join(', ')}`);
|
|
80
|
+
}
|
|
81
|
+
// Validate that Task tool has agentFactory if requested
|
|
82
|
+
if (requestedTools.includes(TOOL_NAMES.TASK) && !config.agentFactory) {
|
|
83
|
+
throw new Error('The Task tool requires an agentFactory to be provided in the configuration.');
|
|
84
|
+
}
|
|
85
|
+
// Create process manager for shell tools
|
|
86
|
+
const processManager = createProcessManagerWithInternal();
|
|
87
|
+
// Create tools
|
|
88
|
+
const tools = [];
|
|
89
|
+
const unknownTools = [];
|
|
90
|
+
for (const name of requestedTools) {
|
|
91
|
+
const creator = TOOL_CREATORS[name];
|
|
92
|
+
if (creator) {
|
|
93
|
+
tools.push(creator(config, processManager));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
unknownTools.push(name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (unknownTools.length > 0) {
|
|
100
|
+
throw new Error(`Unknown tool(s): ${unknownTools.join(', ')}. ` +
|
|
101
|
+
`Available tools: ${Object.keys(TOOL_CREATORS).join(', ')}`);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
tools,
|
|
105
|
+
processManager,
|
|
106
|
+
cleanup: () => processManager.cleanup(),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates a single built-in tool by name.
|
|
111
|
+
* Tool names are strongly typed with autocomplete support.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import { createBuiltInTool } from 'concevent-ai-agent-sdk';
|
|
116
|
+
*
|
|
117
|
+
* const readTool = createBuiltInTool('Read', {
|
|
118
|
+
* workingDirectory: '/project'
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function createBuiltInTool(name, config = {}, processManager) {
|
|
123
|
+
const creator = TOOL_CREATORS[name];
|
|
124
|
+
if (!creator) {
|
|
125
|
+
throw new Error(`Unknown built-in tool: ${name}. Available tools: ${Object.keys(TOOL_CREATORS).join(', ')}`);
|
|
126
|
+
}
|
|
127
|
+
return creator(config, processManager);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Gets the names of all available built-in tools.
|
|
131
|
+
*/
|
|
132
|
+
export function getBuiltInToolNames() {
|
|
133
|
+
return Object.keys(TOOL_CREATORS);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Checks if a tool name is a built-in tool.
|
|
137
|
+
*/
|
|
138
|
+
export function isBuiltInTool(name) {
|
|
139
|
+
return name in TOOL_CREATORS;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,OA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M,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAEpC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,0BAA0B,IAAI,sBAAsB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC5F,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,IAAI,aAAa,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from '../types/index.js';
|
|
3
|
+
import type { ToolConfig, ProcessManager } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Schema for the KillBash tool parameters
|
|
6
|
+
*/
|
|
7
|
+
export declare const killBashSchema: z.ZodObject<{
|
|
8
|
+
process_id: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
process_id: string;
|
|
11
|
+
}, {
|
|
12
|
+
process_id: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type KillBashParams = z.infer<typeof killBashSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates the KillBash tool for terminating background processes
|
|
17
|
+
*/
|
|
18
|
+
export declare function createKillBashTool(_config?: ToolConfig, processManager?: ProcessManager): ToolDefinition;
|
|
19
|
+
//# sourceMappingURL=kill-bash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-bash.d.ts","sourceRoot":"","sources":["../../src/tools/kill-bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;EAEzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,UAAe,EACxB,cAAc,CAAC,EAAE,cAAc,GAC9B,cAAc,CA4ChB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
/**
|
|
4
|
+
* Schema for the KillBash tool parameters
|
|
5
|
+
*/
|
|
6
|
+
export const killBashSchema = z.object({
|
|
7
|
+
process_id: z.string().describe('The ID of the background process to terminate.'),
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Creates the KillBash tool for terminating background processes
|
|
11
|
+
*/
|
|
12
|
+
export function createKillBashTool(_config = {}, processManager) {
|
|
13
|
+
return {
|
|
14
|
+
declaration: {
|
|
15
|
+
name: 'KillBash',
|
|
16
|
+
description: `Terminates a running background bash process.
|
|
17
|
+
First sends SIGTERM for graceful shutdown, then SIGKILL if needed.
|
|
18
|
+
|
|
19
|
+
The process will be removed from the process list after termination.`,
|
|
20
|
+
parametersJsonSchema: zodToJsonSchema(killBashSchema),
|
|
21
|
+
},
|
|
22
|
+
executor: async (args) => {
|
|
23
|
+
const params = killBashSchema.parse(args);
|
|
24
|
+
if (!processManager) {
|
|
25
|
+
throw new Error('ProcessManager not available. Background processes are not enabled.');
|
|
26
|
+
}
|
|
27
|
+
const process = processManager.get(params.process_id);
|
|
28
|
+
if (!process) {
|
|
29
|
+
throw new Error(`Process not found: ${params.process_id}. The process may have already been terminated or the ID is invalid.`);
|
|
30
|
+
}
|
|
31
|
+
const wasRunning = process.running;
|
|
32
|
+
const killed = await processManager.kill(params.process_id);
|
|
33
|
+
if (!killed) {
|
|
34
|
+
throw new Error(`Failed to terminate process ${params.process_id}`);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
process_id: params.process_id,
|
|
38
|
+
command: process.command,
|
|
39
|
+
was_running: wasRunning,
|
|
40
|
+
success: true,
|
|
41
|
+
message: wasRunning
|
|
42
|
+
? `Successfully terminated running process ${params.process_id}`
|
|
43
|
+
: `Process ${params.process_id} was already completed, removed from list`,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
parallel: false, // Killing processes should be sequential to avoid race conditions
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=kill-bash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-bash.js","sourceRoot":"","sources":["../../src/tools/kill-bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;CAClF,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAsB,EAAE,EACxB,cAA+B;IAE/B,OAAO;QACL,WAAW,EAAE;YACX,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE;;;qEAGkD;YAC/D,oBAAoB,EAAE,eAAe,CAAC,cAAc,CAAC;SACtD;QACD,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAE1C,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;YACzF,CAAC;YAED,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAEtD,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CACb,sBAAsB,MAAM,CAAC,UAAU,sEAAsE,CAC9G,CAAC;YACJ,CAAC;YAED,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;YACnC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAE5D,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;YACtE,CAAC;YAED,OAAO;gBACL,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,WAAW,EAAE,UAAU;gBACvB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,UAAU;oBACjB,CAAC,CAAC,2CAA2C,MAAM,CAAC,UAAU,EAAE;oBAChE,CAAC,CAAC,WAAW,MAAM,CAAC,UAAU,2CAA2C;aAC5E,CAAC;QACJ,CAAC;QACD,QAAQ,EAAE,KAAK,EAAE,kEAAkE;KACpF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from '../types/index.js';
|
|
3
|
+
import type { ToolConfig } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Schema for the Read tool parameters
|
|
6
|
+
*/
|
|
7
|
+
export declare const readSchema: z.ZodObject<{
|
|
8
|
+
file_path: z.ZodString;
|
|
9
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
file_path: string;
|
|
13
|
+
offset?: number | undefined;
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
file_path: string;
|
|
17
|
+
offset?: number | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export type ReadParams = z.infer<typeof readSchema>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates the Read tool for reading file contents
|
|
23
|
+
*/
|
|
24
|
+
export declare function createReadTool(config?: ToolConfig): ToolDefinition;
|
|
25
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;EAcrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,UAAe,GAAG,cAAc,CAyFtE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
4
|
+
import { resolvePath, isPathAllowed, isPathSafe } from './utils/path.js';
|
|
5
|
+
/**
|
|
6
|
+
* Schema for the Read tool parameters
|
|
7
|
+
*/
|
|
8
|
+
export const readSchema = z.object({
|
|
9
|
+
file_path: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe('The path to the file to read. Can be absolute or relative to working directory.'),
|
|
12
|
+
offset: z
|
|
13
|
+
.number()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('Line number to start reading from (1-based). If not provided, starts from the beginning.'),
|
|
16
|
+
limit: z
|
|
17
|
+
.number()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Maximum number of lines to read. If not provided, reads the entire file.'),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Creates the Read tool for reading file contents
|
|
23
|
+
*/
|
|
24
|
+
export function createReadTool(config = {}) {
|
|
25
|
+
const workingDirectory = config.workingDirectory || process.cwd();
|
|
26
|
+
return {
|
|
27
|
+
declaration: {
|
|
28
|
+
name: 'Read',
|
|
29
|
+
description: `Reads the contents of a file. Returns the file content with line numbers.
|
|
30
|
+
If offset and limit are provided, reads only the specified range of lines.
|
|
31
|
+
Line numbers in output are 1-based and formatted as "LINE_NUMBER|LINE_CONTENT".`,
|
|
32
|
+
parametersJsonSchema: zodToJsonSchema(readSchema),
|
|
33
|
+
},
|
|
34
|
+
executor: async (args) => {
|
|
35
|
+
const params = readSchema.parse(args);
|
|
36
|
+
const resolvedPath = resolvePath(params.file_path, workingDirectory);
|
|
37
|
+
// Security checks
|
|
38
|
+
if (!isPathSafe(params.file_path, workingDirectory)) {
|
|
39
|
+
throw new Error(`Path traversal detected: ${params.file_path}`);
|
|
40
|
+
}
|
|
41
|
+
if (!isPathAllowed(resolvedPath, config.allowedPaths)) {
|
|
42
|
+
throw new Error(`Access denied: ${params.file_path} is outside allowed paths`);
|
|
43
|
+
}
|
|
44
|
+
// Check if file exists
|
|
45
|
+
try {
|
|
46
|
+
const stat = await fs.stat(resolvedPath);
|
|
47
|
+
if (!stat.isFile()) {
|
|
48
|
+
throw new Error(`Not a file: ${params.file_path}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error.code === 'ENOENT') {
|
|
53
|
+
throw new Error(`File not found: ${params.file_path}`);
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
// Read file contents
|
|
58
|
+
const content = await fs.readFile(resolvedPath, 'utf-8');
|
|
59
|
+
// Handle empty files
|
|
60
|
+
if (content.length === 0) {
|
|
61
|
+
return {
|
|
62
|
+
file_path: params.file_path,
|
|
63
|
+
content: '',
|
|
64
|
+
message: 'File is empty.',
|
|
65
|
+
total_lines: 0,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const lines = content.split('\n');
|
|
69
|
+
const totalLines = lines.length;
|
|
70
|
+
// Apply offset and limit
|
|
71
|
+
const startLine = params.offset ? Math.max(1, params.offset) : 1;
|
|
72
|
+
const endLine = params.limit
|
|
73
|
+
? Math.min(totalLines, startLine + params.limit - 1)
|
|
74
|
+
: totalLines;
|
|
75
|
+
// Format lines with line numbers (1-based, right-aligned to 6 chars)
|
|
76
|
+
const outputLines = [];
|
|
77
|
+
for (let i = startLine - 1; i < endLine; i++) {
|
|
78
|
+
const lineNum = (i + 1).toString().padStart(6, ' ');
|
|
79
|
+
outputLines.push(`${lineNum}|${lines[i]}`);
|
|
80
|
+
}
|
|
81
|
+
const result = {
|
|
82
|
+
file_path: params.file_path,
|
|
83
|
+
content: outputLines.join('\n'),
|
|
84
|
+
total_lines: totalLines,
|
|
85
|
+
lines_shown: {
|
|
86
|
+
start: startLine,
|
|
87
|
+
end: endLine,
|
|
88
|
+
count: endLine - startLine + 1,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
// Add note if not showing all lines
|
|
92
|
+
if (startLine > 1 || endLine < totalLines) {
|
|
93
|
+
return {
|
|
94
|
+
...result,
|
|
95
|
+
note: `Showing lines ${startLine}-${endLine} of ${totalLines} total lines.`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
},
|
|
100
|
+
parallel: true, // Reading is safe to do in parallel
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/tools/read.ts"],"names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+
import type { ToolConfig } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Schema for the Task tool parameters
|
|
6
|
+
*/
|
|
7
|
+
export declare const taskSchema: z.ZodObject<{
|
|
8
|
+
description: z.ZodString;
|
|
9
|
+
prompt: z.ZodString;
|
|
10
|
+
allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
description: string;
|
|
13
|
+
prompt: string;
|
|
14
|
+
allowed_tools?: string[] | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
description: string;
|
|
17
|
+
prompt: string;
|
|
18
|
+
allowed_tools?: string[] | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export type TaskParams = z.infer<typeof taskSchema>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates the Task tool for launching sub-agents
|
|
23
|
+
*/
|
|
24
|
+
export declare function createTaskTool(config?: ToolConfig): ToolDefinition;
|
|
25
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;EASrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,UAAe,GAAG,cAAc,CA2DtE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
/**
|
|
4
|
+
* Schema for the Task tool parameters
|
|
5
|
+
*/
|
|
6
|
+
export const taskSchema = z.object({
|
|
7
|
+
description: z.string().describe('A clear description of what this sub-task should accomplish.'),
|
|
8
|
+
prompt: z.string().describe('The prompt/instructions for the sub-agent to execute.'),
|
|
9
|
+
allowed_tools: z
|
|
10
|
+
.array(z.string())
|
|
11
|
+
.optional()
|
|
12
|
+
.describe('List of tool names the sub-agent is allowed to use. If not specified, the sub-agent may use all available tools.'),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Creates the Task tool for launching sub-agents
|
|
16
|
+
*/
|
|
17
|
+
export function createTaskTool(config = {}) {
|
|
18
|
+
return {
|
|
19
|
+
declaration: {
|
|
20
|
+
name: 'Task',
|
|
21
|
+
description: `Launches a new sub-agent to handle a specific task.
|
|
22
|
+
The sub-agent operates independently and returns its result when complete.
|
|
23
|
+
|
|
24
|
+
Use this to:
|
|
25
|
+
- Break down complex tasks into smaller, focused sub-tasks
|
|
26
|
+
- Delegate specialized work to agents with specific tool access
|
|
27
|
+
- Run tasks that require different tool permissions
|
|
28
|
+
|
|
29
|
+
The sub-agent inherits the current context but operates in isolation.`,
|
|
30
|
+
parametersJsonSchema: zodToJsonSchema(taskSchema),
|
|
31
|
+
},
|
|
32
|
+
executor: async (args, context) => {
|
|
33
|
+
const params = taskSchema.parse(args);
|
|
34
|
+
if (!config.agentFactory) {
|
|
35
|
+
throw new Error('Task tool is not available: No agent factory configured. ' +
|
|
36
|
+
'To use the Task tool, provide an agentFactory in the BuiltInToolsConfig.');
|
|
37
|
+
}
|
|
38
|
+
// Check if aborted before starting
|
|
39
|
+
if (context.abortSignal?.aborted) {
|
|
40
|
+
throw new Error('Task cancelled: operation was aborted');
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const result = await config.agentFactory({
|
|
44
|
+
description: params.description,
|
|
45
|
+
prompt: params.prompt,
|
|
46
|
+
allowedTools: params.allowed_tools,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
success: true,
|
|
50
|
+
description: params.description,
|
|
51
|
+
result: result.message,
|
|
52
|
+
message: 'Sub-task completed successfully',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
// Re-throw abort errors
|
|
57
|
+
if (error.name === 'AbortError' || error.message.includes('abort')) {
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
success: false,
|
|
62
|
+
description: params.description,
|
|
63
|
+
error: error.message,
|
|
64
|
+
message: `Sub-task failed: ${error.message}`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
parallel: false, // Sub-agents should run sequentially
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8DAA8D,CAAC;IAChG,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uDAAuD,CAAC;IACpF,aAAa,EAAE,CAAC;SACb,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CACP,kHAAkH,CACnH;CACJ,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,SAAqB,EAAE;IACpD,OAAO;QACL,WAAW,EAAE;YACX,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE;;;;;;;;sEAQmD;YAChE,oBAAoB,EAAE,eAAe,CAAC,UAAU,C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@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from '../types/index.js';
|
|
3
|
+
import type { ToolConfig } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Schema for the TodoWrite tool parameters
|
|
6
|
+
*/
|
|
7
|
+
export declare const todoWriteSchema: z.ZodObject<{
|
|
8
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
content: z.ZodString;
|
|
11
|
+
status: z.ZodEnum<["pending", "in_progress", "completed", "cancelled"]>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
status: "pending" | "in_progress" | "completed" | "cancelled";
|
|
14
|
+
id: string;
|
|
15
|
+
content: string;
|
|
16
|
+
}, {
|
|
17
|
+
status: "pending" | "in_progress" | "completed" | "cancelled";
|
|
18
|
+
id: string;
|
|
19
|
+
content: string;
|
|
20
|
+
}>, "many">;
|
|
21
|
+
merge: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
todos: {
|
|
24
|
+
status: "pending" | "in_progress" | "completed" | "cancelled";
|
|
25
|
+
id: string;
|
|
26
|
+
content: string;
|
|
27
|
+
}[];
|
|
28
|
+
merge: boolean;
|
|
29
|
+
}, {
|
|
30
|
+
todos: {
|
|
31
|
+
status: "pending" | "in_progress" | "completed" | "cancelled";
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
}[];
|
|
35
|
+
merge?: boolean | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export type TodoWriteParams = z.infer<typeof todoWriteSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates the TodoWrite tool for managing todo items
|
|
40
|
+
*/
|
|
41
|
+
export declare function createTodoWriteTool(config?: ToolConfig): ToolDefinition;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a TodoRead tool for reading current todos (bonus utility)
|
|
44
|
+
*/
|
|
45
|
+
export declare function createTodoReadTool(config?: ToolConfig): ToolDefinition;
|
|
46
|
+
//# sourceMappingURL=todo-write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-write.d.ts","sourceRoot":"","sources":["../../src/tools/todo-write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAqC,MAAM,YAAY,CAAC;AAahF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAuC9D;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,UAAe,GAAG,cAAc,CA+D3E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,UAAe,GAAG,cAAc,CAmC1E"}
|