@compilr-dev/agents 0.1.0 → 0.2.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/agent.d.ts +168 -1
- package/dist/agent.js +268 -14
- package/dist/context/file-tracker.d.ts +156 -0
- package/dist/context/file-tracker.js +358 -0
- package/dist/context/file-tracking-hook.d.ts +29 -0
- package/dist/context/file-tracking-hook.js +103 -0
- package/dist/context/index.d.ts +5 -1
- package/dist/context/index.js +3 -0
- package/dist/context/manager.d.ts +69 -1
- package/dist/context/manager.js +304 -0
- package/dist/context/types.d.ts +95 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -3
- package/dist/messages/index.d.ts +13 -0
- package/dist/messages/index.js +51 -0
- package/dist/permissions/manager.js +6 -1
- package/dist/providers/gemini.js +1 -3
- package/dist/providers/mock.js +8 -0
- package/dist/providers/openai-compatible.js +1 -3
- package/dist/skills/index.js +691 -0
- package/dist/tools/builtin/index.d.ts +6 -1
- package/dist/tools/builtin/index.js +7 -0
- package/dist/tools/builtin/suggest.d.ts +57 -0
- package/dist/tools/builtin/suggest.js +99 -0
- package/dist/tools/builtin/task.js +13 -8
- package/dist/tools/builtin/tool-names.d.ts +44 -0
- package/dist/tools/builtin/tool-names.js +51 -0
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +5 -1
- package/dist/tools/registry.d.ts +4 -0
- package/dist/tools/registry.js +9 -0
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Built-in tools for common operations
|
|
3
3
|
*/
|
|
4
|
+
export { TOOL_NAMES, TOOL_SETS } from './tool-names.js';
|
|
5
|
+
export type { ToolName } from './tool-names.js';
|
|
4
6
|
export { readFileTool, createReadFileTool } from './read-file.js';
|
|
5
7
|
export type { ReadFileInput } from './read-file.js';
|
|
6
8
|
export { writeFileTool, createWriteFileTool } from './write-file.js';
|
|
@@ -25,6 +27,8 @@ export { createTaskTool, defaultAgentTypes } from './task.js';
|
|
|
25
27
|
export type { TaskInput, TaskResult, AgentTypeConfig, TaskToolOptions, ContextMode, ThoroughnessLevel, SubAgentEventInfo, } from './task.js';
|
|
26
28
|
export { webFetchTool, createWebFetchTool } from './web-fetch.js';
|
|
27
29
|
export type { WebFetchInput, WebFetchResult, WebFetchOptions } from './web-fetch.js';
|
|
30
|
+
export { suggestTool, createSuggestTool } from './suggest.js';
|
|
31
|
+
export type { SuggestInput, SuggestToolOptions } from './suggest.js';
|
|
28
32
|
export declare const builtinTools: {
|
|
29
33
|
readonly readFile: import("../types.js").Tool<import("./read-file.js").ReadFileInput>;
|
|
30
34
|
readonly writeFile: import("../types.js").Tool<import("./write-file.js").WriteFileInput>;
|
|
@@ -37,8 +41,9 @@ export declare const builtinTools: {
|
|
|
37
41
|
readonly todoWrite: import("../types.js").Tool<import("./todo.js").TodoWriteInput>;
|
|
38
42
|
readonly todoRead: import("../types.js").Tool<import("./todo.js").TodoReadInput>;
|
|
39
43
|
readonly webFetch: import("../types.js").Tool<import("./web-fetch.js").WebFetchInput>;
|
|
44
|
+
readonly suggest: import("../types.js").Tool<import("./suggest.js").SuggestInput>;
|
|
40
45
|
};
|
|
41
46
|
/**
|
|
42
47
|
* Array of all built-in tools
|
|
43
48
|
*/
|
|
44
|
-
export declare const allBuiltinTools: readonly [import("../types.js").Tool<import("./read-file.js").ReadFileInput>, import("../types.js").Tool<import("./write-file.js").WriteFileInput>, import("../types.js").Tool<import("./bash.js").BashInput>, import("../types.js").Tool<import("./bash-output.js").BashOutputInput>, import("../types.js").Tool<import("./kill-shell.js").KillShellInput>, import("../types.js").Tool<import("./grep.js").GrepInput>, import("../types.js").Tool<import("./glob.js").GlobInput>, import("../types.js").Tool<import("./edit.js").EditInput>, import("../types.js").Tool<import("./todo.js").TodoWriteInput>, import("../types.js").Tool<import("./todo.js").TodoReadInput>, import("../types.js").Tool<import("./web-fetch.js").WebFetchInput>];
|
|
49
|
+
export declare const allBuiltinTools: readonly [import("../types.js").Tool<import("./read-file.js").ReadFileInput>, import("../types.js").Tool<import("./write-file.js").WriteFileInput>, import("../types.js").Tool<import("./bash.js").BashInput>, import("../types.js").Tool<import("./bash-output.js").BashOutputInput>, import("../types.js").Tool<import("./kill-shell.js").KillShellInput>, import("../types.js").Tool<import("./grep.js").GrepInput>, import("../types.js").Tool<import("./glob.js").GlobInput>, import("../types.js").Tool<import("./edit.js").EditInput>, import("../types.js").Tool<import("./todo.js").TodoWriteInput>, import("../types.js").Tool<import("./todo.js").TodoReadInput>, import("../types.js").Tool<import("./web-fetch.js").WebFetchInput>, import("../types.js").Tool<import("./suggest.js").SuggestInput>];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Built-in tools for common operations
|
|
3
3
|
*/
|
|
4
|
+
// Tool names - single source of truth
|
|
5
|
+
export { TOOL_NAMES, TOOL_SETS } from './tool-names.js';
|
|
4
6
|
// Read file tool
|
|
5
7
|
export { readFileTool, createReadFileTool } from './read-file.js';
|
|
6
8
|
// Write file tool
|
|
@@ -25,6 +27,8 @@ export { todoWriteTool, todoReadTool, createTodoTools, TodoStore, resetDefaultTo
|
|
|
25
27
|
export { createTaskTool, defaultAgentTypes } from './task.js';
|
|
26
28
|
// WebFetch tool
|
|
27
29
|
export { webFetchTool, createWebFetchTool } from './web-fetch.js';
|
|
30
|
+
// Suggest tool (next action suggestions)
|
|
31
|
+
export { suggestTool, createSuggestTool } from './suggest.js';
|
|
28
32
|
/**
|
|
29
33
|
* Collection of all built-in tools for easy registration
|
|
30
34
|
*/
|
|
@@ -38,6 +42,7 @@ import { globTool } from './glob.js';
|
|
|
38
42
|
import { editTool } from './edit.js';
|
|
39
43
|
import { todoWriteTool, todoReadTool } from './todo.js';
|
|
40
44
|
import { webFetchTool } from './web-fetch.js';
|
|
45
|
+
import { suggestTool } from './suggest.js';
|
|
41
46
|
export const builtinTools = {
|
|
42
47
|
readFile: readFileTool,
|
|
43
48
|
writeFile: writeFileTool,
|
|
@@ -50,6 +55,7 @@ export const builtinTools = {
|
|
|
50
55
|
todoWrite: todoWriteTool,
|
|
51
56
|
todoRead: todoReadTool,
|
|
52
57
|
webFetch: webFetchTool,
|
|
58
|
+
suggest: suggestTool,
|
|
53
59
|
};
|
|
54
60
|
/**
|
|
55
61
|
* Array of all built-in tools
|
|
@@ -66,4 +72,5 @@ export const allBuiltinTools = [
|
|
|
66
72
|
todoWriteTool,
|
|
67
73
|
todoReadTool,
|
|
68
74
|
webFetchTool,
|
|
75
|
+
suggestTool,
|
|
69
76
|
];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggest Tool - Suggest next action to the user
|
|
3
|
+
*
|
|
4
|
+
* This tool allows the agent to suggest a logical next action for the user.
|
|
5
|
+
* The suggestion appears as "ghost text" in the CLI input prompt.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Silent tool (produces no visible output in conversation)
|
|
9
|
+
* - Emits 'suggest' event for CLI to handle
|
|
10
|
+
* - Only the last suggestion per response is kept
|
|
11
|
+
*/
|
|
12
|
+
import type { Tool } from '../types.js';
|
|
13
|
+
import type { AgentEvent } from '../../agent.js';
|
|
14
|
+
/**
|
|
15
|
+
* Input parameters for suggest tool
|
|
16
|
+
*/
|
|
17
|
+
export interface SuggestInput {
|
|
18
|
+
/**
|
|
19
|
+
* The suggested action or command for the user to take next
|
|
20
|
+
*/
|
|
21
|
+
action: string;
|
|
22
|
+
/**
|
|
23
|
+
* Brief explanation of why this action is suggested (optional)
|
|
24
|
+
*/
|
|
25
|
+
reason?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for creating the suggest tool
|
|
29
|
+
*/
|
|
30
|
+
export interface SuggestToolOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Callback to emit suggest event
|
|
33
|
+
* The CLI captures this to display the suggestion
|
|
34
|
+
*/
|
|
35
|
+
onSuggest?: (event: Extract<AgentEvent, {
|
|
36
|
+
type: 'suggest';
|
|
37
|
+
}>) => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Default suggest tool (no-op, for testing or when suggestions are disabled)
|
|
41
|
+
*/
|
|
42
|
+
export declare const suggestTool: Tool<SuggestInput>;
|
|
43
|
+
/**
|
|
44
|
+
* Create a suggest tool with event emission
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const suggestTool = createSuggestTool({
|
|
49
|
+
* onSuggest: (event) => {
|
|
50
|
+
* // Handle the suggestion (e.g., pass to CLI input prompt)
|
|
51
|
+
* console.log('Suggested action:', event.action);
|
|
52
|
+
* }
|
|
53
|
+
* });
|
|
54
|
+
* agent.registerTool(suggestTool);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createSuggestTool(options?: SuggestToolOptions): Tool<SuggestInput>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggest Tool - Suggest next action to the user
|
|
3
|
+
*
|
|
4
|
+
* This tool allows the agent to suggest a logical next action for the user.
|
|
5
|
+
* The suggestion appears as "ghost text" in the CLI input prompt.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Silent tool (produces no visible output in conversation)
|
|
9
|
+
* - Emits 'suggest' event for CLI to handle
|
|
10
|
+
* - Only the last suggestion per response is kept
|
|
11
|
+
*/
|
|
12
|
+
import { defineTool, createSuccessResult } from '../define.js';
|
|
13
|
+
/**
|
|
14
|
+
* Default suggest tool (no-op, for testing or when suggestions are disabled)
|
|
15
|
+
*/
|
|
16
|
+
export const suggestTool = defineTool({
|
|
17
|
+
name: 'suggest',
|
|
18
|
+
description: 'Suggest a next action for the user. The suggestion appears as ghost text in the input prompt. ' +
|
|
19
|
+
'Use this after completing a task to guide the user toward a logical next step. ' +
|
|
20
|
+
'Good suggestions are actionable, specific, and follow naturally from what you just did. ' +
|
|
21
|
+
'Examples: "run npm test to verify the fix", "review the changes in src/index.ts", ' +
|
|
22
|
+
'"commit the changes with git commit". Only suggest when there is a clear, helpful next step.',
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
action: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'The suggested action or command for the user to take next',
|
|
29
|
+
},
|
|
30
|
+
reason: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Brief explanation of why this action is suggested (optional)',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ['action'],
|
|
36
|
+
},
|
|
37
|
+
execute: (_input) => {
|
|
38
|
+
// Default implementation - silent, no-op
|
|
39
|
+
// Real implementation uses createSuggestTool with onSuggest callback
|
|
40
|
+
return Promise.resolve(createSuccessResult({
|
|
41
|
+
suggested: true,
|
|
42
|
+
message: 'Suggestion noted (no handler configured)',
|
|
43
|
+
}));
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Create a suggest tool with event emission
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const suggestTool = createSuggestTool({
|
|
52
|
+
* onSuggest: (event) => {
|
|
53
|
+
* // Handle the suggestion (e.g., pass to CLI input prompt)
|
|
54
|
+
* console.log('Suggested action:', event.action);
|
|
55
|
+
* }
|
|
56
|
+
* });
|
|
57
|
+
* agent.registerTool(suggestTool);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function createSuggestTool(options = {}) {
|
|
61
|
+
const { onSuggest } = options;
|
|
62
|
+
return defineTool({
|
|
63
|
+
name: 'suggest',
|
|
64
|
+
description: 'Suggest a next action for the user. The suggestion appears as ghost text in the input prompt. ' +
|
|
65
|
+
'Use this after completing a task to guide the user toward a logical next step. ' +
|
|
66
|
+
'Good suggestions are actionable, specific, and follow naturally from what you just did. ' +
|
|
67
|
+
'Examples: "run npm test to verify the fix", "review the changes in src/index.ts", ' +
|
|
68
|
+
'"commit the changes with git commit". Only suggest when there is a clear, helpful next step.',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
action: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: 'The suggested action or command for the user to take next',
|
|
75
|
+
},
|
|
76
|
+
reason: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'Brief explanation of why this action is suggested (optional)',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
required: ['action'],
|
|
82
|
+
},
|
|
83
|
+
execute: (input) => {
|
|
84
|
+
// Emit the suggest event if handler is configured
|
|
85
|
+
if (onSuggest) {
|
|
86
|
+
onSuggest({
|
|
87
|
+
type: 'suggest',
|
|
88
|
+
action: input.action,
|
|
89
|
+
reason: input.reason,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// Silent result - no visible output in conversation
|
|
93
|
+
return Promise.resolve(createSuccessResult({
|
|
94
|
+
suggested: true,
|
|
95
|
+
action: input.action,
|
|
96
|
+
}));
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - Extended built-in agent types
|
|
14
14
|
*/
|
|
15
15
|
import { defineTool, createSuccessResult, createErrorResult } from '../define.js';
|
|
16
|
+
import { TOOL_NAMES, TOOL_SETS } from './tool-names.js';
|
|
16
17
|
/**
|
|
17
18
|
* Map our context mode to agent's context mode
|
|
18
19
|
*/
|
|
@@ -123,6 +124,7 @@ export function createTaskTool(options) {
|
|
|
123
124
|
const agentConfig = agentTypes[subagent_type];
|
|
124
125
|
// Check concurrent limit
|
|
125
126
|
if (activeCount >= maxConcurrent) {
|
|
127
|
+
console.error(`[task-tool] BLOCKED: activeCount=${String(activeCount)}, maxConcurrent=${String(maxConcurrent)}`);
|
|
126
128
|
return createErrorResult(`Maximum concurrent sub-agents (${String(maxConcurrent)}) reached. ` +
|
|
127
129
|
`Wait for existing tasks to complete.`);
|
|
128
130
|
}
|
|
@@ -131,6 +133,7 @@ export function createTaskTool(options) {
|
|
|
131
133
|
onSpawn(subagent_type, description);
|
|
132
134
|
}
|
|
133
135
|
activeCount++;
|
|
136
|
+
console.error(`[task-tool] SPAWN: ${subagent_type}, activeCount=${String(activeCount)}`);
|
|
134
137
|
try {
|
|
135
138
|
// Note: Sub-agents currently use the parent's provider
|
|
136
139
|
// Future enhancement: support model switching via providerFactory
|
|
@@ -198,10 +201,12 @@ export function createTaskTool(options) {
|
|
|
198
201
|
return createSuccessResult(taskResult);
|
|
199
202
|
}
|
|
200
203
|
catch (error) {
|
|
204
|
+
console.error(`[task-tool] ERROR: ${subagent_type}, error=${error instanceof Error ? error.message : String(error)}`);
|
|
201
205
|
return createErrorResult(`Sub-agent failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
202
206
|
}
|
|
203
207
|
finally {
|
|
204
208
|
activeCount--;
|
|
209
|
+
console.error(`[task-tool] DONE: ${subagent_type}, activeCount=${String(activeCount)}`);
|
|
205
210
|
}
|
|
206
211
|
},
|
|
207
212
|
});
|
|
@@ -222,7 +227,7 @@ export const defaultAgentTypes = {
|
|
|
222
227
|
contextMode: 'inherit-summary',
|
|
223
228
|
supportsThoroughness: true,
|
|
224
229
|
toolInheritance: 'filter',
|
|
225
|
-
allowedTools: [
|
|
230
|
+
allowedTools: [...TOOL_SETS.READ_ONLY],
|
|
226
231
|
},
|
|
227
232
|
'code-review': {
|
|
228
233
|
description: 'Agent specialized for reviewing code changes. Use after writing ' +
|
|
@@ -238,7 +243,7 @@ export const defaultAgentTypes = {
|
|
|
238
243
|
contextMode: 'inherit-summary',
|
|
239
244
|
supportsThoroughness: false,
|
|
240
245
|
toolInheritance: 'filter',
|
|
241
|
-
allowedTools: [
|
|
246
|
+
allowedTools: [...TOOL_SETS.READ_ONLY],
|
|
242
247
|
},
|
|
243
248
|
general: {
|
|
244
249
|
description: 'General-purpose agent for complex multi-step tasks. Use when ' +
|
|
@@ -262,7 +267,7 @@ export const defaultAgentTypes = {
|
|
|
262
267
|
contextMode: 'inherit-summary',
|
|
263
268
|
supportsThoroughness: false,
|
|
264
269
|
toolInheritance: 'filter',
|
|
265
|
-
allowedTools: [
|
|
270
|
+
allowedTools: [...TOOL_SETS.READ_ONLY],
|
|
266
271
|
},
|
|
267
272
|
'test-runner': {
|
|
268
273
|
description: 'Agent for running and analyzing tests. Use to run test suites, ' +
|
|
@@ -278,7 +283,7 @@ export const defaultAgentTypes = {
|
|
|
278
283
|
contextMode: 'inherit-summary',
|
|
279
284
|
supportsThoroughness: true,
|
|
280
285
|
toolInheritance: 'filter',
|
|
281
|
-
allowedTools: [
|
|
286
|
+
allowedTools: [...TOOL_SETS.READ_ONLY_WITH_BASH],
|
|
282
287
|
},
|
|
283
288
|
'doc-lookup': {
|
|
284
289
|
description: 'Agent for searching documentation and APIs. Use to find ' +
|
|
@@ -294,7 +299,7 @@ export const defaultAgentTypes = {
|
|
|
294
299
|
contextMode: 'isolated',
|
|
295
300
|
supportsThoroughness: true,
|
|
296
301
|
toolInheritance: 'filter',
|
|
297
|
-
allowedTools: [
|
|
302
|
+
allowedTools: [...TOOL_SETS.READ_ONLY_WITH_WEB],
|
|
298
303
|
},
|
|
299
304
|
refactor: {
|
|
300
305
|
description: 'Agent for refactoring code safely. Use for renaming, extracting, ' +
|
|
@@ -310,8 +315,8 @@ export const defaultAgentTypes = {
|
|
|
310
315
|
contextMode: 'inherit-summary',
|
|
311
316
|
supportsThoroughness: false,
|
|
312
317
|
toolInheritance: 'filter',
|
|
313
|
-
allowedTools: [
|
|
314
|
-
deniedTools: [
|
|
318
|
+
allowedTools: [...TOOL_SETS.REFACTOR],
|
|
319
|
+
deniedTools: [TOOL_NAMES.BASH],
|
|
315
320
|
},
|
|
316
321
|
'security-audit': {
|
|
317
322
|
description: 'Agent for security auditing code. Use to scan for vulnerabilities, ' +
|
|
@@ -329,7 +334,7 @@ export const defaultAgentTypes = {
|
|
|
329
334
|
contextMode: 'isolated',
|
|
330
335
|
supportsThoroughness: true,
|
|
331
336
|
toolInheritance: 'filter',
|
|
332
|
-
allowedTools: [
|
|
337
|
+
allowedTools: [...TOOL_SETS.SECURITY_AUDIT],
|
|
333
338
|
},
|
|
334
339
|
debug: {
|
|
335
340
|
description: 'Agent for debugging issues. Use to investigate bugs, analyze ' +
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Names - Single Source of Truth
|
|
3
|
+
*
|
|
4
|
+
* All tool names are defined here to avoid hardcoding them in multiple places.
|
|
5
|
+
* Import these constants wherever you need to reference tool names.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Built-in tool names as constants
|
|
9
|
+
*/
|
|
10
|
+
export declare const TOOL_NAMES: {
|
|
11
|
+
readonly READ_FILE: "read_file";
|
|
12
|
+
readonly WRITE_FILE: "write_file";
|
|
13
|
+
readonly BASH: "bash";
|
|
14
|
+
readonly BASH_OUTPUT: "bash_output";
|
|
15
|
+
readonly KILL_SHELL: "kill_shell";
|
|
16
|
+
readonly GREP: "grep";
|
|
17
|
+
readonly GLOB: "glob";
|
|
18
|
+
readonly EDIT: "edit";
|
|
19
|
+
readonly TODO_WRITE: "todo_write";
|
|
20
|
+
readonly TODO_READ: "todo_read";
|
|
21
|
+
readonly WEB_FETCH: "web_fetch";
|
|
22
|
+
readonly TASK: "task";
|
|
23
|
+
readonly SUGGEST: "suggest";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Type for tool name values
|
|
27
|
+
*/
|
|
28
|
+
export type ToolName = (typeof TOOL_NAMES)[keyof typeof TOOL_NAMES];
|
|
29
|
+
/**
|
|
30
|
+
* Common tool sets for agent types
|
|
31
|
+
* Use these instead of hardcoding tool arrays
|
|
32
|
+
*/
|
|
33
|
+
export declare const TOOL_SETS: {
|
|
34
|
+
/** Read-only tools for exploration and code review */
|
|
35
|
+
readonly READ_ONLY: readonly ["glob", "grep", "read_file"];
|
|
36
|
+
/** Read-only tools plus bash for running commands */
|
|
37
|
+
readonly READ_ONLY_WITH_BASH: readonly ["bash", "glob", "grep", "read_file"];
|
|
38
|
+
/** Read-only tools plus web fetch for documentation lookup */
|
|
39
|
+
readonly READ_ONLY_WITH_WEB: readonly ["web_fetch", "glob", "grep", "read_file"];
|
|
40
|
+
/** Tools for refactoring (read + edit + write, no bash) */
|
|
41
|
+
readonly REFACTOR: readonly ["glob", "grep", "read_file", "edit", "write_file"];
|
|
42
|
+
/** Tools for security auditing (read + bash for dependency checks) */
|
|
43
|
+
readonly SECURITY_AUDIT: readonly ["glob", "grep", "read_file", "bash"];
|
|
44
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Names - Single Source of Truth
|
|
3
|
+
*
|
|
4
|
+
* All tool names are defined here to avoid hardcoding them in multiple places.
|
|
5
|
+
* Import these constants wherever you need to reference tool names.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Built-in tool names as constants
|
|
9
|
+
*/
|
|
10
|
+
export const TOOL_NAMES = {
|
|
11
|
+
READ_FILE: 'read_file',
|
|
12
|
+
WRITE_FILE: 'write_file',
|
|
13
|
+
BASH: 'bash',
|
|
14
|
+
BASH_OUTPUT: 'bash_output',
|
|
15
|
+
KILL_SHELL: 'kill_shell',
|
|
16
|
+
GREP: 'grep',
|
|
17
|
+
GLOB: 'glob',
|
|
18
|
+
EDIT: 'edit',
|
|
19
|
+
TODO_WRITE: 'todo_write',
|
|
20
|
+
TODO_READ: 'todo_read',
|
|
21
|
+
WEB_FETCH: 'web_fetch',
|
|
22
|
+
TASK: 'task',
|
|
23
|
+
SUGGEST: 'suggest',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Common tool sets for agent types
|
|
27
|
+
* Use these instead of hardcoding tool arrays
|
|
28
|
+
*/
|
|
29
|
+
export const TOOL_SETS = {
|
|
30
|
+
/** Read-only tools for exploration and code review */
|
|
31
|
+
READ_ONLY: [TOOL_NAMES.GLOB, TOOL_NAMES.GREP, TOOL_NAMES.READ_FILE],
|
|
32
|
+
/** Read-only tools plus bash for running commands */
|
|
33
|
+
READ_ONLY_WITH_BASH: [TOOL_NAMES.BASH, TOOL_NAMES.GLOB, TOOL_NAMES.GREP, TOOL_NAMES.READ_FILE],
|
|
34
|
+
/** Read-only tools plus web fetch for documentation lookup */
|
|
35
|
+
READ_ONLY_WITH_WEB: [
|
|
36
|
+
TOOL_NAMES.WEB_FETCH,
|
|
37
|
+
TOOL_NAMES.GLOB,
|
|
38
|
+
TOOL_NAMES.GREP,
|
|
39
|
+
TOOL_NAMES.READ_FILE,
|
|
40
|
+
],
|
|
41
|
+
/** Tools for refactoring (read + edit + write, no bash) */
|
|
42
|
+
REFACTOR: [
|
|
43
|
+
TOOL_NAMES.GLOB,
|
|
44
|
+
TOOL_NAMES.GREP,
|
|
45
|
+
TOOL_NAMES.READ_FILE,
|
|
46
|
+
TOOL_NAMES.EDIT,
|
|
47
|
+
TOOL_NAMES.WRITE_FILE,
|
|
48
|
+
],
|
|
49
|
+
/** Tools for security auditing (read + bash for dependency checks) */
|
|
50
|
+
SECURITY_AUDIT: [TOOL_NAMES.GLOB, TOOL_NAMES.GREP, TOOL_NAMES.READ_FILE, TOOL_NAMES.BASH],
|
|
51
|
+
};
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { defineTool, createSuccessResult, createErrorResult, wrapToolExecute } f
|
|
|
6
6
|
export type { DefineToolOptions } from './define.js';
|
|
7
7
|
export { DefaultToolRegistry, createToolRegistry } from './registry.js';
|
|
8
8
|
export type { ToolRegistryOptions } from './registry.js';
|
|
9
|
-
export { readFileTool, createReadFileTool, writeFileTool, createWriteFileTool, bashTool, createBashTool, execStream, detectFifoUsage, bashOutputTool, createBashOutputTool, killShellTool, createKillShellTool, ShellManager, getDefaultShellManager, setDefaultShellManager, grepTool, createGrepTool, globTool, createGlobTool, editTool, createEditTool, todoWriteTool, todoReadTool, createTodoTools, TodoStore, resetDefaultTodoStore, getDefaultTodoStore, createIsolatedTodoStore, cleanupTodoContextMessages, getTodoContextStats, webFetchTool, createWebFetchTool, createTaskTool, defaultAgentTypes, builtinTools, allBuiltinTools, } from './builtin/index.js';
|
|
10
|
-
export type { ReadFileInput, WriteFileInput, BashInput, BashResult, FifoDetectionResult, BashOutputInput, BashOutputResult, KillShellInput, KillShellResult, ShellStatus, BackgroundShell, ShellOutput, ShellManagerOptions, GrepInput, GlobInput, EditInput, TodoWriteInput, TodoReadInput, TodoItem, TodoStatus, TodoContextCleanupOptions, WebFetchInput, WebFetchResult, WebFetchOptions, TaskInput, TaskResult, AgentTypeConfig, TaskToolOptions, ContextMode, ThoroughnessLevel, SubAgentEventInfo, } from './builtin/index.js';
|
|
9
|
+
export { readFileTool, createReadFileTool, writeFileTool, createWriteFileTool, bashTool, createBashTool, execStream, detectFifoUsage, bashOutputTool, createBashOutputTool, killShellTool, createKillShellTool, ShellManager, getDefaultShellManager, setDefaultShellManager, grepTool, createGrepTool, globTool, createGlobTool, editTool, createEditTool, todoWriteTool, todoReadTool, createTodoTools, TodoStore, resetDefaultTodoStore, getDefaultTodoStore, createIsolatedTodoStore, cleanupTodoContextMessages, getTodoContextStats, webFetchTool, createWebFetchTool, createTaskTool, defaultAgentTypes, suggestTool, createSuggestTool, builtinTools, allBuiltinTools, TOOL_NAMES, TOOL_SETS, } from './builtin/index.js';
|
|
10
|
+
export type { ReadFileInput, WriteFileInput, BashInput, BashResult, FifoDetectionResult, BashOutputInput, BashOutputResult, KillShellInput, KillShellResult, ShellStatus, BackgroundShell, ShellOutput, ShellManagerOptions, GrepInput, GlobInput, EditInput, TodoWriteInput, TodoReadInput, TodoItem, TodoStatus, TodoContextCleanupOptions, WebFetchInput, WebFetchResult, WebFetchOptions, TaskInput, TaskResult, AgentTypeConfig, TaskToolOptions, ContextMode, ThoroughnessLevel, SubAgentEventInfo, SuggestInput, SuggestToolOptions, } from './builtin/index.js';
|
package/dist/tools/index.js
CHANGED
|
@@ -33,5 +33,9 @@ todoWriteTool, todoReadTool, createTodoTools, TodoStore, resetDefaultTodoStore,
|
|
|
33
33
|
webFetchTool, createWebFetchTool,
|
|
34
34
|
// Task (sub-agent spawning)
|
|
35
35
|
createTaskTool, defaultAgentTypes,
|
|
36
|
+
// Suggest (next action suggestions)
|
|
37
|
+
suggestTool, createSuggestTool,
|
|
36
38
|
// Collections
|
|
37
|
-
builtinTools, allBuiltinTools,
|
|
39
|
+
builtinTools, allBuiltinTools,
|
|
40
|
+
// Tool names - single source of truth
|
|
41
|
+
TOOL_NAMES, TOOL_SETS, } from './builtin/index.js';
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -72,6 +72,10 @@ export declare class DefaultToolRegistry implements IToolRegistry {
|
|
|
72
72
|
* Clear all registered tools
|
|
73
73
|
*/
|
|
74
74
|
clear(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Get the registry options (for inheritance by sub-agents)
|
|
77
|
+
*/
|
|
78
|
+
getOptions(): ToolRegistryOptions;
|
|
75
79
|
}
|
|
76
80
|
/**
|
|
77
81
|
* Create a new ToolRegistry with optional initial tools and options
|
package/dist/tools/registry.js
CHANGED
|
@@ -138,6 +138,15 @@ export class DefaultToolRegistry {
|
|
|
138
138
|
clear() {
|
|
139
139
|
this.tools.clear();
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Get the registry options (for inheritance by sub-agents)
|
|
143
|
+
*/
|
|
144
|
+
getOptions() {
|
|
145
|
+
return {
|
|
146
|
+
defaultTimeoutMs: this.defaultTimeoutMs,
|
|
147
|
+
toolTimeouts: { ...this.toolTimeouts },
|
|
148
|
+
};
|
|
149
|
+
}
|
|
141
150
|
}
|
|
142
151
|
/**
|
|
143
152
|
* Create a new ToolRegistry with optional initial tools and options
|