cmdr-agent 2.2.0 → 2.4.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/package.json +1 -1
- package/dist/src/cli/commands.js +1 -1
- package/dist/src/cli/commands.js.map +1 -1
- package/dist/src/cli/ink/App.d.ts +2 -0
- package/dist/src/cli/ink/App.d.ts.map +1 -1
- package/dist/src/cli/ink/App.js +56 -7
- package/dist/src/cli/ink/App.js.map +1 -1
- package/dist/src/cli/repl.d.ts.map +1 -1
- package/dist/src/cli/repl.js +91 -1
- package/dist/src/cli/repl.js.map +1 -1
- package/dist/src/config/mcp-config.d.ts +41 -0
- package/dist/src/config/mcp-config.d.ts.map +1 -0
- package/dist/src/config/mcp-config.js +55 -0
- package/dist/src/config/mcp-config.js.map +1 -0
- package/dist/src/config/mcp-registry.d.ts +45 -0
- package/dist/src/config/mcp-registry.d.ts.map +1 -0
- package/dist/src/config/mcp-registry.js +156 -0
- package/dist/src/config/mcp-registry.js.map +1 -0
- package/dist/src/config/schema.d.ts +8 -8
- package/dist/src/core/agent-runner.d.ts +4 -0
- package/dist/src/core/agent-runner.d.ts.map +1 -1
- package/dist/src/core/agent-runner.js +60 -1
- package/dist/src/core/agent-runner.js.map +1 -1
- package/dist/src/core/agent.d.ts +4 -0
- package/dist/src/core/agent.d.ts.map +1 -1
- package/dist/src/core/agent.js +6 -0
- package/dist/src/core/agent.js.map +1 -1
- package/dist/src/core/graph-context.d.ts +83 -0
- package/dist/src/core/graph-context.d.ts.map +1 -0
- package/dist/src/core/graph-context.js +370 -0
- package/dist/src/core/graph-context.js.map +1 -0
- package/dist/src/core/hooks.d.ts +61 -0
- package/dist/src/core/hooks.d.ts.map +1 -0
- package/dist/src/core/hooks.js +140 -0
- package/dist/src/core/hooks.js.map +1 -0
- package/dist/src/core/intent.d.ts.map +1 -1
- package/dist/src/core/intent.js +3 -0
- package/dist/src/core/intent.js.map +1 -1
- package/dist/src/core/permissions.d.ts +43 -0
- package/dist/src/core/permissions.d.ts.map +1 -1
- package/dist/src/core/permissions.js +108 -0
- package/dist/src/core/permissions.js.map +1 -1
- package/dist/src/core/presets.d.ts.map +1 -1
- package/dist/src/core/presets.js +6 -2
- package/dist/src/core/presets.js.map +1 -1
- package/dist/src/core/types.d.ts +7 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/tools/built-in/bash.d.ts +1 -1
- package/dist/src/tools/built-in/cron-tools.d.ts +19 -0
- package/dist/src/tools/built-in/cron-tools.d.ts.map +1 -0
- package/dist/src/tools/built-in/cron-tools.js +86 -0
- package/dist/src/tools/built-in/cron-tools.js.map +1 -0
- package/dist/src/tools/built-in/graph-tools.d.ts +31 -0
- package/dist/src/tools/built-in/graph-tools.d.ts.map +1 -0
- package/dist/src/tools/built-in/graph-tools.js +103 -0
- package/dist/src/tools/built-in/graph-tools.js.map +1 -0
- package/dist/src/tools/built-in/index.d.ts +8 -1
- package/dist/src/tools/built-in/index.d.ts.map +1 -1
- package/dist/src/tools/built-in/index.js +15 -2
- package/dist/src/tools/built-in/index.js.map +1 -1
- package/dist/src/tools/built-in/mcp-resource-tools.d.ts +16 -0
- package/dist/src/tools/built-in/mcp-resource-tools.d.ts.map +1 -0
- package/dist/src/tools/built-in/mcp-resource-tools.js +73 -0
- package/dist/src/tools/built-in/mcp-resource-tools.js.map +1 -0
- package/dist/src/tools/built-in/plan-tools.d.ts +13 -0
- package/dist/src/tools/built-in/plan-tools.d.ts.map +1 -0
- package/dist/src/tools/built-in/plan-tools.js +42 -0
- package/dist/src/tools/built-in/plan-tools.js.map +1 -0
- package/dist/src/tools/built-in/task-tools.d.ts +22 -0
- package/dist/src/tools/built-in/task-tools.d.ts.map +1 -0
- package/dist/src/tools/built-in/task-tools.js +113 -0
- package/dist/src/tools/built-in/task-tools.js.map +1 -0
- package/dist/src/tools/built-in/todo-tool.d.ts +21 -0
- package/dist/src/tools/built-in/todo-tool.d.ts.map +1 -0
- package/dist/src/tools/built-in/todo-tool.js +52 -0
- package/dist/src/tools/built-in/todo-tool.js.map +1 -0
- package/dist/src/tools/built-in/web-fetch.d.ts +1 -1
- package/dist/src/tools/built-in/web-search.d.ts +9 -0
- package/dist/src/tools/built-in/web-search.d.ts.map +1 -0
- package/dist/src/tools/built-in/web-search.js +89 -0
- package/dist/src/tools/built-in/web-search.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph tools — curated wrappers around code-review-graph MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* Three tools exposed to the LLM:
|
|
5
|
+
* - graph_impact: blast radius analysis
|
|
6
|
+
* - graph_query: dependency queries (callers, callees, imports, tests)
|
|
7
|
+
* - graph_review: risk-scored review context
|
|
8
|
+
*
|
|
9
|
+
* These are for deep analysis mid-reasoning. Initial grounding is handled
|
|
10
|
+
* by GraphContextProvider's context injection — no duplication.
|
|
11
|
+
*
|
|
12
|
+
* All three are read-only and added to SAFE_PARALLEL_TOOLS.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { defineTool } from '../registry.js';
|
|
16
|
+
// Module-level reference — set during startup
|
|
17
|
+
let _mcpClient = null;
|
|
18
|
+
let _graphAvailable = false;
|
|
19
|
+
let _projectRoot = '';
|
|
20
|
+
export function setGraphToolsClient(client, projectRoot) {
|
|
21
|
+
_mcpClient = client;
|
|
22
|
+
_projectRoot = projectRoot;
|
|
23
|
+
_graphAvailable = true;
|
|
24
|
+
}
|
|
25
|
+
export function setGraphToolsAvailable(available) {
|
|
26
|
+
_graphAvailable = available;
|
|
27
|
+
}
|
|
28
|
+
async function callCrg(toolName, input) {
|
|
29
|
+
if (!_graphAvailable || !_mcpClient) {
|
|
30
|
+
return {
|
|
31
|
+
data: 'Code review graph is not available. Install it with: pip install code-review-graph\nThen restart cmdr. Falling back to grep/file_read for code exploration.',
|
|
32
|
+
isError: true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return _mcpClient.callTool('crg', toolName, input);
|
|
36
|
+
}
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// graph_impact — blast radius analysis
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
export const graphImpactTool = defineTool({
|
|
41
|
+
name: 'graph_impact',
|
|
42
|
+
description: `Analyze the blast radius of changed files using the code knowledge graph. Shows which functions, classes, and files are impacted by changes. Use this for understanding the scope of modifications before or after editing code. Returns impacted files, affected nodes, and dependency chains.`,
|
|
43
|
+
inputSchema: z.object({
|
|
44
|
+
changed_files: z.array(z.string()).optional().describe('File paths to analyze. Auto-detects from git diff if omitted.'),
|
|
45
|
+
max_depth: z.number().optional().describe('BFS traversal depth in dependency graph. Default: 2.'),
|
|
46
|
+
base: z.string().optional().describe('Git ref for change detection. Default: HEAD~1.'),
|
|
47
|
+
}),
|
|
48
|
+
async execute(input, _context) {
|
|
49
|
+
const params = {
|
|
50
|
+
repo_root: _projectRoot,
|
|
51
|
+
max_depth: input.max_depth ?? 2,
|
|
52
|
+
base: input.base ?? 'HEAD~1',
|
|
53
|
+
};
|
|
54
|
+
if (input.changed_files)
|
|
55
|
+
params.changed_files = input.changed_files;
|
|
56
|
+
return callCrg('get_impact_radius_tool', params);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// graph_query — dependency queries
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
export const graphQueryTool = defineTool({
|
|
63
|
+
name: 'graph_query',
|
|
64
|
+
description: `Query the code knowledge graph for structural relationships. Patterns: callers_of (find who calls a function), callees_of (find what a function calls), imports_of (what a file imports), importers_of (who imports a file), children_of (nodes in a file/class), tests_for (tests for a target), inheritors_of (subclasses), file_summary (all nodes in a file).`,
|
|
65
|
+
inputSchema: z.object({
|
|
66
|
+
pattern: z.enum([
|
|
67
|
+
'callers_of', 'callees_of', 'imports_of', 'importers_of',
|
|
68
|
+
'children_of', 'tests_for', 'inheritors_of', 'file_summary',
|
|
69
|
+
]).describe('Query pattern to run.'),
|
|
70
|
+
target: z.string().describe('Node name, qualified name, or file path to query.'),
|
|
71
|
+
}),
|
|
72
|
+
async execute(input, _context) {
|
|
73
|
+
return callCrg('query_graph_tool', {
|
|
74
|
+
pattern: input.pattern,
|
|
75
|
+
target: input.target,
|
|
76
|
+
repo_root: _projectRoot,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// graph_review — risk-scored review context
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
export const graphReviewTool = defineTool({
|
|
84
|
+
name: 'graph_review',
|
|
85
|
+
description: `Generate a risk-scored code review using the knowledge graph. Maps git diffs to affected functions, execution flows, communities, and test coverage gaps. Returns prioritized review items with risk levels. Use this for comprehensive code reviews instead of manually reading all changed files.`,
|
|
86
|
+
inputSchema: z.object({
|
|
87
|
+
base: z.string().optional().describe('Git ref to diff against. Default: HEAD~1.'),
|
|
88
|
+
changed_files: z.array(z.string()).optional().describe('Files to review. Auto-detected from git diff if omitted.'),
|
|
89
|
+
include_source: z.boolean().optional().describe('Include source code snippets. Default: false.'),
|
|
90
|
+
}),
|
|
91
|
+
async execute(input, _context) {
|
|
92
|
+
const params = {
|
|
93
|
+
base: input.base ?? 'HEAD~1',
|
|
94
|
+
repo_root: _projectRoot,
|
|
95
|
+
include_source: input.include_source ?? false,
|
|
96
|
+
max_depth: 2,
|
|
97
|
+
};
|
|
98
|
+
if (input.changed_files)
|
|
99
|
+
params.changed_files = input.changed_files;
|
|
100
|
+
return callCrg('detect_changes_tool', params);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=graph-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-tools.js","sourceRoot":"","sources":["../../../../src/tools/built-in/graph-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG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SAAqS;IAClT,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;QACjF,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;QAClH,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;KACjG,CAAC;IACF,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,QAAwB;QAC3C,MAAM,MAAM,GAA4B;YACtC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,QAAQ;YAC5B,SAAS,EAAE,YAAY;YACvB,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,KAAK;YAC7C,SAAS,EAAE,CAAC;SACb,CAAA;QACD,IAAI,KAAK,CAAC,aAAa;YAAE,MAAM,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAA;QACnE,OAAO,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -15,11 +15,18 @@ import { gitCommitTool, gitBranchTool } from './git-commit.js';
|
|
|
15
15
|
import { gitWorktreeTool } from './git-worktree.js';
|
|
16
16
|
import { thinkTool } from './think.js';
|
|
17
17
|
import { webFetchTool } from './web-fetch.js';
|
|
18
|
+
import { webSearchTool } from './web-search.js';
|
|
18
19
|
import { askUserTool } from './ask-user.js';
|
|
19
20
|
import { memoryReadTool, memoryWriteTool } from './memory.js';
|
|
20
21
|
import { lspDiagnosticsTool } from './diagnostics.js';
|
|
21
22
|
import { notebookReadTool, notebookEditTool, notebookRunTool } from './notebook.js';
|
|
22
|
-
|
|
23
|
+
import { todoWriteTool } from './todo-tool.js';
|
|
24
|
+
import { taskCreateTool, taskListTool, taskGetTool, taskStopTool } from './task-tools.js';
|
|
25
|
+
import { cronCreateTool, cronListTool, cronDeleteTool } from './cron-tools.js';
|
|
26
|
+
import { enterPlanModeTool, exitPlanModeTool } from './plan-tools.js';
|
|
27
|
+
import { mcpListResourcesTool, mcpReadResourceTool } from './mcp-resource-tools.js';
|
|
28
|
+
import { graphImpactTool, graphQueryTool, graphReviewTool } from './graph-tools.js';
|
|
29
|
+
export { bashTool, fileReadTool, fileWriteTool, fileEditTool, grepTool, globTool, gitDiffTool, gitLogTool, gitCommitTool, gitBranchTool, gitWorktreeTool, lspDiagnosticsTool, notebookReadTool, notebookEditTool, notebookRunTool, thinkTool, webFetchTool, webSearchTool, askUserTool, memoryReadTool, memoryWriteTool, todoWriteTool, taskCreateTool, taskListTool, taskGetTool, taskStopTool, cronCreateTool, cronListTool, cronDeleteTool, enterPlanModeTool, exitPlanModeTool, mcpListResourcesTool, mcpReadResourceTool, graphImpactTool, graphQueryTool, graphReviewTool, };
|
|
23
30
|
export declare const BUILT_IN_TOOLS: ToolDefinition<any>[];
|
|
24
31
|
export declare function registerBuiltInTools(registry: ToolRegistry): void;
|
|
25
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/built-in/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OA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AQ,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EACzE,eAAe,EAAE,kBAAkB,EACnC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EACnD,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EACpF,aAAa,EACb,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EACvD,cAAc,EAAE,YAAY,EAAE,cAAc,EAC5C,iBAAiB,EAAE,gBAAgB,EACnC,oBAAoB,EAAE,mBAAmB,EACzC,eAAe,EAAE,cAAc,EAAE,eAAe,GACjD,CAAA;AAGD,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,EAY/C,CAAA;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAMjE"}
|
|
@@ -13,18 +13,31 @@ import { gitCommitTool, gitBranchTool } from './git-commit.js';
|
|
|
13
13
|
import { gitWorktreeTool } from './git-worktree.js';
|
|
14
14
|
import { thinkTool } from './think.js';
|
|
15
15
|
import { webFetchTool } from './web-fetch.js';
|
|
16
|
+
import { webSearchTool } from './web-search.js';
|
|
16
17
|
import { askUserTool } from './ask-user.js';
|
|
17
18
|
import { memoryReadTool, memoryWriteTool } from './memory.js';
|
|
18
19
|
import { lspDiagnosticsTool } from './diagnostics.js';
|
|
19
20
|
import { notebookReadTool, notebookEditTool, notebookRunTool } from './notebook.js';
|
|
20
|
-
|
|
21
|
+
import { todoWriteTool } from './todo-tool.js';
|
|
22
|
+
import { taskCreateTool, taskListTool, taskGetTool, taskStopTool } from './task-tools.js';
|
|
23
|
+
import { cronCreateTool, cronListTool, cronDeleteTool } from './cron-tools.js';
|
|
24
|
+
import { enterPlanModeTool, exitPlanModeTool } from './plan-tools.js';
|
|
25
|
+
import { mcpListResourcesTool, mcpReadResourceTool } from './mcp-resource-tools.js';
|
|
26
|
+
import { graphImpactTool, graphQueryTool, graphReviewTool } from './graph-tools.js';
|
|
27
|
+
export { bashTool, fileReadTool, fileWriteTool, fileEditTool, grepTool, globTool, gitDiffTool, gitLogTool, gitCommitTool, gitBranchTool, gitWorktreeTool, lspDiagnosticsTool, notebookReadTool, notebookEditTool, notebookRunTool, thinkTool, webFetchTool, webSearchTool, askUserTool, memoryReadTool, memoryWriteTool, todoWriteTool, taskCreateTool, taskListTool, taskGetTool, taskStopTool, cronCreateTool, cronListTool, cronDeleteTool, enterPlanModeTool, exitPlanModeTool, mcpListResourcesTool, mcpReadResourceTool, graphImpactTool, graphQueryTool, graphReviewTool, };
|
|
21
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
29
|
export const BUILT_IN_TOOLS = [
|
|
23
30
|
bashTool, fileReadTool, fileWriteTool, fileEditTool,
|
|
24
31
|
grepTool, globTool, gitDiffTool, gitLogTool, gitCommitTool, gitBranchTool,
|
|
25
32
|
gitWorktreeTool, lspDiagnosticsTool,
|
|
26
33
|
notebookReadTool, notebookEditTool, notebookRunTool,
|
|
27
|
-
thinkTool, webFetchTool, askUserTool, memoryReadTool, memoryWriteTool,
|
|
34
|
+
thinkTool, webFetchTool, webSearchTool, askUserTool, memoryReadTool, memoryWriteTool,
|
|
35
|
+
todoWriteTool,
|
|
36
|
+
taskCreateTool, taskListTool, taskGetTool, taskStopTool,
|
|
37
|
+
cronCreateTool, cronListTool, cronDeleteTool,
|
|
38
|
+
enterPlanModeTool, exitPlanModeTool,
|
|
39
|
+
mcpListResourcesTool, mcpReadResourceTool,
|
|
40
|
+
graphImpactTool, graphQueryTool, graphReviewTool,
|
|
28
41
|
];
|
|
29
42
|
export function registerBuiltInTools(registry) {
|
|
30
43
|
for (const tool of BUILT_IN_TOOLS) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tools/built-in/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,W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AAC,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP resource tools — list and read resources from connected MCP servers.
|
|
3
|
+
*
|
|
4
|
+
* MCP servers can expose resources (files, database schemas, API docs, etc.)
|
|
5
|
+
* in addition to tools. These tools let the LLM discover and read them.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpClient } from '../../plugins/mcp-client.js';
|
|
8
|
+
export declare function setMcpClient(client: McpClient): void;
|
|
9
|
+
export declare const mcpListResourcesTool: import("../registry.js").ToolDefinition<{
|
|
10
|
+
server?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const mcpReadResourceTool: import("../registry.js").ToolDefinition<{
|
|
13
|
+
server: string;
|
|
14
|
+
uri: string;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=mcp-resource-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-resource-tools.d.ts","sourceRoot":"","sources":["../../../../src/tools/built-in/mcp-resource-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAI5D,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAEpD;AAED,eAAO,MAAM,oBAAoB;;EAkC/B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;EAgC9B,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP resource tools — list and read resources from connected MCP servers.
|
|
3
|
+
*
|
|
4
|
+
* MCP servers can expose resources (files, database schemas, API docs, etc.)
|
|
5
|
+
* in addition to tools. These tools let the LLM discover and read them.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { defineTool } from '../registry.js';
|
|
9
|
+
let mcpClientRef = null;
|
|
10
|
+
export function setMcpClient(client) {
|
|
11
|
+
mcpClientRef = client;
|
|
12
|
+
}
|
|
13
|
+
export const mcpListResourcesTool = defineTool({
|
|
14
|
+
name: 'mcp_list_resources',
|
|
15
|
+
description: 'List available resources from connected MCP servers. Resources are additional context like files, database schemas, or documentation that MCP servers can provide.',
|
|
16
|
+
inputSchema: z.object({
|
|
17
|
+
server: z.string().optional().describe('Optional: filter to a specific MCP server name'),
|
|
18
|
+
}),
|
|
19
|
+
execute: async (input) => {
|
|
20
|
+
if (!mcpClientRef) {
|
|
21
|
+
return { data: 'No MCP client available', isError: true };
|
|
22
|
+
}
|
|
23
|
+
const connections = mcpClientRef.listConnections();
|
|
24
|
+
if (connections.length === 0) {
|
|
25
|
+
return { data: 'No MCP servers connected. Use /mcp to manage connections.' };
|
|
26
|
+
}
|
|
27
|
+
const filtered = input.server
|
|
28
|
+
? connections.filter(c => c.name === input.server)
|
|
29
|
+
: connections;
|
|
30
|
+
if (filtered.length === 0) {
|
|
31
|
+
return { data: `MCP server "${input.server}" not found. Connected: ${connections.map(c => c.name).join(', ')}`, isError: true };
|
|
32
|
+
}
|
|
33
|
+
// Note: Resource listing requires the MCP server to support resources/list.
|
|
34
|
+
// This is a best-effort — many servers only support tools.
|
|
35
|
+
const lines = filtered.map(c => `${c.name} (${c.transport}) — ${c.tools} tools${c.connected ? '' : ' [disconnected]'}`);
|
|
36
|
+
return {
|
|
37
|
+
data: `Connected MCP servers:\n${lines.join('\n')}\n\nNote: Use mcp_read_resource with a specific server and resource URI to read content.`,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
export const mcpReadResourceTool = defineTool({
|
|
42
|
+
name: 'mcp_read_resource',
|
|
43
|
+
description: 'Read a specific resource from an MCP server by URI. The resource URI format depends on the server (e.g. "file:///path", "db://schema/table").',
|
|
44
|
+
inputSchema: z.object({
|
|
45
|
+
server: z.string().describe('The MCP server name'),
|
|
46
|
+
uri: z.string().describe('The resource URI to read'),
|
|
47
|
+
}),
|
|
48
|
+
execute: async (input) => {
|
|
49
|
+
if (!mcpClientRef) {
|
|
50
|
+
return { data: 'No MCP client available', isError: true };
|
|
51
|
+
}
|
|
52
|
+
// Validate URI format
|
|
53
|
+
try {
|
|
54
|
+
new URL(input.uri);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Allow relative URIs too — some MCP servers use simple paths
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
// Use the MCP client's callTool to send a resources/read request
|
|
61
|
+
// This piggybacks on the existing transport infrastructure
|
|
62
|
+
const result = await mcpClientRef.callTool(input.server, '__resources_read__', {
|
|
63
|
+
uri: input.uri,
|
|
64
|
+
});
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
69
|
+
return { data: `Failed to read resource: ${msg}`, isError: true };
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=mcp-resource-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-resource-tools.js","sourceRoot":"","sources":["../../../../src/tools/built-in/mcp-resource-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG3C,IAAI,YAAY,GAAqB,IAAI,CAAA;AAEzC,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC5C,YAAY,GAAG,MAAM,CAAA;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC7C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oKAAoK;IACjL,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gD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
|
4
|
+
* When in plan mode, the LLM should describe its approach before executing.
|
|
5
|
+
* These tools let the LLM switch modes programmatically.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isPlanMode(): boolean;
|
|
8
|
+
export declare function setPlanMode(active: boolean): void;
|
|
9
|
+
export declare const enterPlanModeTool: import("../registry.js").ToolDefinition<{
|
|
10
|
+
reason?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const exitPlanModeTool: import("../registry.js").ToolDefinition<{}>;
|
|
13
|
+
//# sourceMappingURL=plan-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-tools.d.ts","sourceRoot":"","sources":["../../../../src/tools/built-in/plan-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED,eAAO,MAAM,iBAAiB;;EAa5B,CAAA;AAEF,eAAO,MAAM,gBAAgB,6CAU3B,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan mode tools — allow the LLM to self-manage planning vs execution mode.
|
|
3
|
+
*
|
|
4
|
+
* When in plan mode, the LLM should describe its approach before executing.
|
|
5
|
+
* These tools let the LLM switch modes programmatically.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { defineTool } from '../registry.js';
|
|
9
|
+
// Global plan mode state — can also be set by /plan command
|
|
10
|
+
let planModeActive = false;
|
|
11
|
+
export function isPlanMode() {
|
|
12
|
+
return planModeActive;
|
|
13
|
+
}
|
|
14
|
+
export function setPlanMode(active) {
|
|
15
|
+
planModeActive = active;
|
|
16
|
+
}
|
|
17
|
+
export const enterPlanModeTool = defineTool({
|
|
18
|
+
name: 'enter_plan_mode',
|
|
19
|
+
description: 'Switch to plan mode. In plan mode, describe your approach and reasoning before executing any tools. Use this when the task is complex and would benefit from planning first.',
|
|
20
|
+
inputSchema: z.object({
|
|
21
|
+
reason: z.string().optional().describe('Why you are entering plan mode'),
|
|
22
|
+
}),
|
|
23
|
+
execute: async (input) => {
|
|
24
|
+
planModeActive = true;
|
|
25
|
+
const reason = input.reason ? ` Reason: ${input.reason}` : '';
|
|
26
|
+
return {
|
|
27
|
+
data: `Plan mode activated.${reason}\n\nYou are now in plan mode. Describe your approach step-by-step before executing. Use exit_plan_mode when ready to execute.`,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
export const exitPlanModeTool = defineTool({
|
|
32
|
+
name: 'exit_plan_mode',
|
|
33
|
+
description: 'Exit plan mode and return to execution mode. Use this after you have laid out your plan and are ready to start implementing.',
|
|
34
|
+
inputSchema: z.object({}),
|
|
35
|
+
execute: async () => {
|
|
36
|
+
planModeActive = false;
|
|
37
|
+
return {
|
|
38
|
+
data: 'Plan mode deactivated. You are now in execution mode. Proceed with implementing your plan.',
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=plan-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-tools.js","sourceRoot":"","sources":["../../../../src/tools/built-in/plan-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,4DAA4D;AAC5D,IAAI,cAAc,GAAG,KAAK,CAAA;AAE1B,MAAM,UAAU,UAAU;IACxB,OAAO,cAAc,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAe;IACzC,cAAc,GAAG,MAAM,CAAA;AACzB,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,8KAA8K;IAC3L,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;KACzE,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,cAAc,GAAG,IAAI,CAAA;QACrB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAC7D,OAAO;YACL,IAAI,EAAE,uBAAuB,MAAM,+HAA+H;SACnK,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;IACzC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,8HAA8H;IAC3I,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,cAAc,GAAG,KAAK,CAAA;QACtB,OAAO;YACL,IAAI,EAAE,4FAA4F;SACnG,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task management tools — LLM-driven wrappers around TaskScheduler.
|
|
3
|
+
*
|
|
4
|
+
* Provides task_create, task_list, task_get, task_stop for the LLM to
|
|
5
|
+
* schedule and manage background tasks.
|
|
6
|
+
*/
|
|
7
|
+
import type { TaskScheduler } from '../../scheduling/task-scheduler.js';
|
|
8
|
+
export declare function setTaskScheduler(ts: TaskScheduler): void;
|
|
9
|
+
export declare const taskCreateTool: import("../registry.js").ToolDefinition<{
|
|
10
|
+
command: string;
|
|
11
|
+
name: string;
|
|
12
|
+
intervalMs?: number | undefined;
|
|
13
|
+
delayMs?: number | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const taskListTool: import("../registry.js").ToolDefinition<{}>;
|
|
16
|
+
export declare const taskGetTool: import("../registry.js").ToolDefinition<{
|
|
17
|
+
id: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const taskStopTool: import("../registry.js").ToolDefinition<{
|
|
20
|
+
id: string;
|
|
21
|
+
}>;
|
|
22
|
+
//# sourceMappingURL=task-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-tools.d.ts","sourceRoot":"","sources":["../../../../src/tools/built-in/task-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAKvE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,CAExD;AAED,eAAO,MAAM,cAAc;;;;;EA6BzB,CAAA;AAEF,eAAO,MAAM,YAAY,6CA4BvB,CAAA;AAEF,eAAO,MAAM,WAAW;;EA2BtB,CAAA;AAEF,eAAO,MAAM,YAAY;;EAkBvB,CAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task management tools — LLM-driven wrappers around TaskScheduler.
|
|
3
|
+
*
|
|
4
|
+
* Provides task_create, task_list, task_get, task_stop for the LLM to
|
|
5
|
+
* schedule and manage background tasks.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { defineTool } from '../registry.js';
|
|
9
|
+
// TaskScheduler reference is set during REPL startup
|
|
10
|
+
let scheduler = null;
|
|
11
|
+
export function setTaskScheduler(ts) {
|
|
12
|
+
scheduler = ts;
|
|
13
|
+
}
|
|
14
|
+
export const taskCreateTool = defineTool({
|
|
15
|
+
name: 'task_create',
|
|
16
|
+
description: 'Create a background scheduled task. Supports one-shot (delayed) and recurring (interval) tasks. The task runs a shell command.',
|
|
17
|
+
inputSchema: z.object({
|
|
18
|
+
name: z.string().describe('Human-readable name for the task'),
|
|
19
|
+
command: z.string().describe('Shell command to execute'),
|
|
20
|
+
intervalMs: z.number().optional().describe('Run every N milliseconds (recurring). Omit for one-shot.'),
|
|
21
|
+
delayMs: z.number().optional().describe('Delay before first/only run (default: 0 for immediate)'),
|
|
22
|
+
}),
|
|
23
|
+
execute: async (input) => {
|
|
24
|
+
if (!scheduler) {
|
|
25
|
+
return { data: 'TaskScheduler is not initialized', isError: true };
|
|
26
|
+
}
|
|
27
|
+
const { execSync } = await import('node:child_process');
|
|
28
|
+
const handler = async () => {
|
|
29
|
+
execSync(input.command, { timeout: 30000, stdio: 'pipe' });
|
|
30
|
+
};
|
|
31
|
+
let id;
|
|
32
|
+
if (input.intervalMs) {
|
|
33
|
+
id = scheduler.scheduleInterval(input.name, input.intervalMs, handler);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
id = scheduler.scheduleOnce(input.name, input.delayMs ?? 0, handler);
|
|
37
|
+
}
|
|
38
|
+
const type = input.intervalMs ? `recurring (every ${input.intervalMs}ms)` : `one-shot (delay ${input.delayMs ?? 0}ms)`;
|
|
39
|
+
return { data: `Task created: ${input.name} (${type})\nID: ${id}` };
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
export const taskListTool = defineTool({
|
|
43
|
+
name: 'task_list',
|
|
44
|
+
description: 'List all scheduled background tasks with their status, run count, and timing.',
|
|
45
|
+
inputSchema: z.object({}),
|
|
46
|
+
execute: async () => {
|
|
47
|
+
if (!scheduler) {
|
|
48
|
+
return { data: 'TaskScheduler is not initialized', isError: true };
|
|
49
|
+
}
|
|
50
|
+
const tasks = scheduler.list();
|
|
51
|
+
if (tasks.length === 0) {
|
|
52
|
+
return { data: 'No scheduled tasks.' };
|
|
53
|
+
}
|
|
54
|
+
const lines = tasks.map(t => {
|
|
55
|
+
const parts = [
|
|
56
|
+
` ${t.name} [${t.status}]`,
|
|
57
|
+
` ID: ${t.id}`,
|
|
58
|
+
` Runs: ${t.runCount}`,
|
|
59
|
+
];
|
|
60
|
+
if (t.lastRun)
|
|
61
|
+
parts.push(` Last: ${t.lastRun.toISOString()}`);
|
|
62
|
+
if (t.nextRun)
|
|
63
|
+
parts.push(` Next: ${t.nextRun.toISOString()}`);
|
|
64
|
+
if (t.error)
|
|
65
|
+
parts.push(` Error: ${t.error}`);
|
|
66
|
+
return parts.join('\n');
|
|
67
|
+
});
|
|
68
|
+
return { data: `Scheduled tasks (${tasks.length} total, ${scheduler.activeCount} active):\n\n${lines.join('\n\n')}` };
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
export const taskGetTool = defineTool({
|
|
72
|
+
name: 'task_get',
|
|
73
|
+
description: 'Get details of a specific scheduled task by ID.',
|
|
74
|
+
inputSchema: z.object({
|
|
75
|
+
id: z.string().describe('The task ID returned by task_create'),
|
|
76
|
+
}),
|
|
77
|
+
execute: async (input) => {
|
|
78
|
+
if (!scheduler) {
|
|
79
|
+
return { data: 'TaskScheduler is not initialized', isError: true };
|
|
80
|
+
}
|
|
81
|
+
const task = scheduler.get(input.id);
|
|
82
|
+
if (!task) {
|
|
83
|
+
return { data: `Task not found: ${input.id}`, isError: true };
|
|
84
|
+
}
|
|
85
|
+
const info = [
|
|
86
|
+
`Name: ${task.name}`,
|
|
87
|
+
`Status: ${task.status}`,
|
|
88
|
+
`Runs: ${task.runCount}`,
|
|
89
|
+
task.lastRun ? `Last run: ${task.lastRun.toISOString()}` : null,
|
|
90
|
+
task.nextRun ? `Next run: ${task.nextRun.toISOString()}` : null,
|
|
91
|
+
task.error ? `Error: ${task.error}` : null,
|
|
92
|
+
].filter(Boolean).join('\n');
|
|
93
|
+
return { data: info };
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
export const taskStopTool = defineTool({
|
|
97
|
+
name: 'task_stop',
|
|
98
|
+
description: 'Stop/cancel a scheduled task by ID.',
|
|
99
|
+
inputSchema: z.object({
|
|
100
|
+
id: z.string().describe('The task ID to cancel'),
|
|
101
|
+
}),
|
|
102
|
+
execute: async (input) => {
|
|
103
|
+
if (!scheduler) {
|
|
104
|
+
return { data: 'TaskScheduler is not initialized', isError: true };
|
|
105
|
+
}
|
|
106
|
+
const success = scheduler.cancel(input.id);
|
|
107
|
+
if (!success) {
|
|
108
|
+
return { data: `Task not found: ${input.id}`, isError: true };
|
|
109
|
+
}
|
|
110
|
+
return { data: `Task ${input.id} cancelled.` };
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=task-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-tools.js","sourceRoot":"","sources":["../../../../src/tools/built-in/task-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG3C,qDAAqD;AACrD,IAAI,SAAS,GAAyB,IAAI,CAAA;AAE1C,MAAM,UAAU,gBAAgB,CAAC,EAAiB;IAChD,SAAS,GAAG,EAAE,CAAA;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACvC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,gIAAgI;IAC7I,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;QAC7D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QACxD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;QACtG,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;KAClG,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,EAAE,IAAI,EAAE,kCAAkC,EAAE,OAAO,EAAE,IAAI,EA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KAAK,EAAE,EAAE;QACvB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,EAAE,IAAI,EAAE,kCAAkC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;QACpE,CAAC;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,IAAI,EAAE,mBAAmB,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;QAC/D,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,QAAQ,KAAK,CAAC,EAAE,aAAa,EAAE,CAAA;IAChD,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* todo_write — session-scoped task checklist for tracking progress.
|
|
3
|
+
*
|
|
4
|
+
* The LLM can create, update, and manage a checklist of tasks
|
|
5
|
+
* within the current session, similar to Claude Code's TodoWrite tool.
|
|
6
|
+
*/
|
|
7
|
+
interface TodoItem {
|
|
8
|
+
id: number;
|
|
9
|
+
title: string;
|
|
10
|
+
status: 'not-started' | 'in-progress' | 'completed';
|
|
11
|
+
}
|
|
12
|
+
export declare function getSessionTodos(): readonly TodoItem[];
|
|
13
|
+
export declare const todoWriteTool: import("../registry.js").ToolDefinition<{
|
|
14
|
+
todos: {
|
|
15
|
+
status: "completed" | "not-started" | "in-progress";
|
|
16
|
+
title: string;
|
|
17
|
+
id?: number | undefined;
|
|
18
|
+
}[];
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=todo-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-tool.d.ts","sourceRoot":"","sources":["../../../../src/tools/built-in/todo-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,aAAa,GAAG,aAAa,GAAG,WAAW,CAAA;CACpD;AAMD,wBAAgB,eAAe,IAAI,SAAS,QAAQ,EAAE,CAErD;AAED,eAAO,MAAM,aAAa;;;;;;EAuCxB,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* todo_write — session-scoped task checklist for tracking progress.
|
|
3
|
+
*
|
|
4
|
+
* The LLM can create, update, and manage a checklist of tasks
|
|
5
|
+
* within the current session, similar to Claude Code's TodoWrite tool.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { defineTool } from '../registry.js';
|
|
9
|
+
// Session-scoped todo list (shared across all tool invocations)
|
|
10
|
+
const sessionTodos = [];
|
|
11
|
+
let nextId = 1;
|
|
12
|
+
export function getSessionTodos() {
|
|
13
|
+
return sessionTodos;
|
|
14
|
+
}
|
|
15
|
+
export const todoWriteTool = defineTool({
|
|
16
|
+
name: 'todo_write',
|
|
17
|
+
description: 'Manage a session-scoped task checklist. Use to track progress on multi-step tasks. Provide the complete array of all todo items (both existing and new) each time.',
|
|
18
|
+
inputSchema: z.object({
|
|
19
|
+
todos: z.array(z.object({
|
|
20
|
+
id: z.number().optional().describe('Existing todo ID (omit for new items)'),
|
|
21
|
+
title: z.string().describe('Short description of the task'),
|
|
22
|
+
status: z.enum(['not-started', 'in-progress', 'completed']).describe('Current status'),
|
|
23
|
+
})).describe('Complete list of all todo items'),
|
|
24
|
+
}),
|
|
25
|
+
execute: async (input) => {
|
|
26
|
+
// Replace the entire todo list with the provided items
|
|
27
|
+
sessionTodos.length = 0;
|
|
28
|
+
for (const item of input.todos) {
|
|
29
|
+
sessionTodos.push({
|
|
30
|
+
id: item.id ?? nextId++,
|
|
31
|
+
title: item.title,
|
|
32
|
+
status: item.status,
|
|
33
|
+
});
|
|
34
|
+
// Keep nextId ahead of any provided IDs
|
|
35
|
+
if (item.id && item.id >= nextId) {
|
|
36
|
+
nextId = item.id + 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const total = sessionTodos.length;
|
|
40
|
+
const completed = sessionTodos.filter(t => t.status === 'completed').length;
|
|
41
|
+
const inProgress = sessionTodos.filter(t => t.status === 'in-progress').length;
|
|
42
|
+
const notStarted = sessionTodos.filter(t => t.status === 'not-started').length;
|
|
43
|
+
const lines = sessionTodos.map(t => {
|
|
44
|
+
const icon = t.status === 'completed' ? '✓' : t.status === 'in-progress' ? '▶' : '○';
|
|
45
|
+
return ` ${icon} [${t.id}] ${t.title} (${t.status})`;
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
data: `Todo list updated (${completed}/${total} done, ${inProgress} in-progress, ${notStarted} not-started):\n${lines.join('\n')}`,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=todo-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-tool.js","sourceRoot":"","sources":["../../../../src/tools/built-in/todo-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAQ3C,gEAAgE;AAChE,MAAM,YAAY,GAAe,EAAE,CAAA;AACnC,IAAI,MAAM,GAAG,CAAC,CAAA;AAEd,MAAM,UAAU,eAAe;IAC7B,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;IACtC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,oKAAoK;IACjL,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;YACtB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ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9E,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACjC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;YACpF,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,MAAM,GAAG,CAAA;QACvD,CAAC,CAAC,CAAA;QAEF,OAAO;YACL,IAAI,EAAE,sBAAsB,SAAS,IAAI,KAAK,UAAU,UAAU,iBAAiB,UAAU,mBAAmB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SACnI,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const webFetchTool: import("../registry.js").ToolDefinition<{
|
|
5
5
|
url: string;
|
|
6
|
-
method?: "GET" | "POST" | undefined;
|
|
7
6
|
headers?: Record<string, string> | undefined;
|
|
7
|
+
method?: "POST" | "GET" | undefined;
|
|
8
8
|
body?: string | undefined;
|
|
9
9
|
maxBytes?: number | undefined;
|
|
10
10
|
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* web_search — search the web using DuckDuckGo HTML scraping (no API key required).
|
|
3
|
+
* Falls back to Brave Search API if BRAVE_SEARCH_API_KEY is set.
|
|
4
|
+
*/
|
|
5
|
+
export declare const webSearchTool: import("../registry.js").ToolDefinition<{
|
|
6
|
+
query: string;
|
|
7
|
+
maxResults?: number | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=web-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../../../src/tools/built-in/web-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4EH,eAAO,MAAM,aAAa;;;EA8BxB,CAAA"}
|