cmdr-agent 2.1.2 → 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/dist/bin/cmdr.js +4 -0
- package/dist/bin/cmdr.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/cli/args.d.ts +4 -0
- package/dist/src/cli/args.d.ts.map +1 -1
- package/dist/src/cli/args.js +15 -0
- package/dist/src/cli/args.js.map +1 -1
- package/dist/src/cli/commands.js +21 -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 +71 -7
- package/dist/src/cli/ink/App.js.map +1 -1
- package/dist/src/cli/repl.d.ts +4 -0
- package/dist/src/cli/repl.d.ts.map +1 -1
- package/dist/src/cli/repl.js +83 -20
- package/dist/src/cli/repl.js.map +1 -1
- 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 +5 -0
- package/dist/src/core/agent-runner.d.ts.map +1 -1
- package/dist/src/core/agent-runner.js +34 -2
- package/dist/src/core/agent-runner.js.map +1 -1
- package/dist/src/core/agent.d.ts +2 -1
- package/dist/src/core/agent.d.ts.map +1 -1
- package/dist/src/core/agent.js +5 -1
- package/dist/src/core/agent.js.map +1 -1
- package/dist/src/core/content-replacement.d.ts +44 -0
- package/dist/src/core/content-replacement.d.ts.map +1 -0
- package/dist/src/core/content-replacement.js +67 -0
- package/dist/src/core/content-replacement.js.map +1 -0
- package/dist/src/core/event-bus.d.ts +129 -0
- package/dist/src/core/event-bus.d.ts.map +1 -0
- package/dist/src/core/event-bus.js +103 -0
- package/dist/src/core/event-bus.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/orchestrator.d.ts +17 -1
- package/dist/src/core/orchestrator.d.ts.map +1 -1
- package/dist/src/core/orchestrator.js +95 -1
- package/dist/src/core/orchestrator.js.map +1 -1
- package/dist/src/core/permissions.d.ts +74 -3
- package/dist/src/core/permissions.d.ts.map +1 -1
- package/dist/src/core/permissions.js +230 -11
- 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 +1 -0
- package/dist/src/core/presets.js.map +1 -1
- package/dist/src/core/types.d.ts +22 -1
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/llm/anthropic.d.ts +27 -0
- package/dist/src/llm/anthropic.d.ts.map +1 -0
- package/dist/src/llm/anthropic.js +269 -0
- package/dist/src/llm/anthropic.js.map +1 -0
- package/dist/src/llm/ollama.d.ts.map +1 -1
- package/dist/src/llm/ollama.js +16 -4
- package/dist/src/llm/ollama.js.map +1 -1
- package/dist/src/llm/openai.d.ts +25 -0
- package/dist/src/llm/openai.d.ts.map +1 -0
- package/dist/src/llm/openai.js +299 -0
- package/dist/src/llm/openai.js.map +1 -0
- package/dist/src/llm/provider-factory.d.ts +35 -0
- package/dist/src/llm/provider-factory.d.ts.map +1 -0
- package/dist/src/llm/provider-factory.js +73 -0
- package/dist/src/llm/provider-factory.js.map +1 -0
- package/dist/src/memory/consolidation.d.ts +37 -0
- package/dist/src/memory/consolidation.d.ts.map +1 -0
- package/dist/src/memory/consolidation.js +148 -0
- package/dist/src/memory/consolidation.js.map +1 -0
- package/dist/src/memory/memory-manager.d.ts +39 -0
- package/dist/src/memory/memory-manager.d.ts.map +1 -0
- package/dist/src/memory/memory-manager.js +96 -0
- package/dist/src/memory/memory-manager.js.map +1 -0
- package/dist/src/plugins/mcp-client.d.ts +14 -5
- package/dist/src/plugins/mcp-client.d.ts.map +1 -1
- package/dist/src/plugins/mcp-client.js +197 -43
- package/dist/src/plugins/mcp-client.js.map +1 -1
- package/dist/src/scheduling/task-scheduler.d.ts +51 -0
- package/dist/src/scheduling/task-scheduler.d.ts.map +1 -0
- package/dist/src/scheduling/task-scheduler.js +127 -0
- package/dist/src/scheduling/task-scheduler.js.map +1 -0
- package/dist/src/session/prompt-builder.d.ts +6 -0
- package/dist/src/session/prompt-builder.d.ts.map +1 -1
- package/dist/src/session/prompt-builder.js +21 -2
- package/dist/src/session/prompt-builder.js.map +1 -1
- package/dist/src/session/prompt-cache.d.ts +33 -0
- package/dist/src/session/prompt-cache.d.ts.map +1 -0
- package/dist/src/session/prompt-cache.js +54 -0
- package/dist/src/session/prompt-cache.js.map +1 -0
- 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/diagnostics.d.ts +12 -0
- package/dist/src/tools/built-in/diagnostics.d.ts.map +1 -0
- package/dist/src/tools/built-in/diagnostics.js +119 -0
- package/dist/src/tools/built-in/diagnostics.js.map +1 -0
- package/dist/src/tools/built-in/git-worktree.d.ts +13 -0
- package/dist/src/tools/built-in/git-worktree.d.ts.map +1 -0
- package/dist/src/tools/built-in/git-worktree.js +75 -0
- package/dist/src/tools/built-in/git-worktree.js.map +1 -0
- package/dist/src/tools/built-in/index.d.ts +11 -1
- package/dist/src/tools/built-in/index.d.ts.map +1 -1
- package/dist/src/tools/built-in/index.js +19 -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/memory.d.ts +15 -0
- package/dist/src/tools/built-in/memory.d.ts.map +1 -0
- package/dist/src/tools/built-in/memory.js +58 -0
- package/dist/src/tools/built-in/memory.js.map +1 -0
- package/dist/src/tools/built-in/notebook.d.ts +22 -0
- package/dist/src/tools/built-in/notebook.d.ts.map +1 -0
- package/dist/src/tools/built-in/notebook.js +207 -0
- package/dist/src/tools/built-in/notebook.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-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,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;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EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;KACjD,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,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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AC,MAAM,CAAA;QAC9E,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,MAAM,CAAA;QAE9E,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"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
import { z } from 'zod';
|
|
6
|
+
import { defineTool } from '../registry.js';
|
|
7
|
+
async function searchDuckDuckGo(query, maxResults) {
|
|
8
|
+
const encoded = encodeURIComponent(query);
|
|
9
|
+
const url = `https://html.duckduckgo.com/html/?q=${encoded}`;
|
|
10
|
+
const response = await fetch(url, {
|
|
11
|
+
headers: {
|
|
12
|
+
'User-Agent': 'Mozilla/5.0 (compatible; cmdr-agent/1.0)',
|
|
13
|
+
},
|
|
14
|
+
signal: AbortSignal.timeout(15000),
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`DuckDuckGo returned ${response.status}`);
|
|
18
|
+
}
|
|
19
|
+
const html = await response.text();
|
|
20
|
+
const results = [];
|
|
21
|
+
// Parse result entries from DuckDuckGo HTML
|
|
22
|
+
const resultPattern = /<a[^>]+class="result__a"[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>[\s\S]*?<a[^>]+class="result__snippet"[^>]*>([\s\S]*?)<\/a>/g;
|
|
23
|
+
let match;
|
|
24
|
+
while ((match = resultPattern.exec(html)) !== null && results.length < maxResults) {
|
|
25
|
+
const rawUrl = match[1];
|
|
26
|
+
const title = match[2].replace(/<[^>]*>/g, '').trim();
|
|
27
|
+
const snippet = match[3].replace(/<[^>]*>/g, '').trim();
|
|
28
|
+
// DuckDuckGo wraps URLs in a redirect — extract the actual URL
|
|
29
|
+
let finalUrl = rawUrl;
|
|
30
|
+
try {
|
|
31
|
+
const parsed = new URL(rawUrl, 'https://duckduckgo.com');
|
|
32
|
+
const uddg = parsed.searchParams.get('uddg');
|
|
33
|
+
if (uddg)
|
|
34
|
+
finalUrl = decodeURIComponent(uddg);
|
|
35
|
+
}
|
|
36
|
+
catch { /* use raw */ }
|
|
37
|
+
if (title && finalUrl) {
|
|
38
|
+
results.push({ title, url: finalUrl, snippet });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return results;
|
|
42
|
+
}
|
|
43
|
+
async function searchBrave(query, maxResults, apiKey) {
|
|
44
|
+
const encoded = encodeURIComponent(query);
|
|
45
|
+
const response = await fetch(`https://api.search.brave.com/res/v1/web/search?q=${encoded}&count=${maxResults}`, {
|
|
46
|
+
headers: {
|
|
47
|
+
'Accept': 'application/json',
|
|
48
|
+
'Accept-Encoding': 'gzip',
|
|
49
|
+
'X-Subscription-Token': apiKey,
|
|
50
|
+
},
|
|
51
|
+
signal: AbortSignal.timeout(15000),
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new Error(`Brave Search returned ${response.status}`);
|
|
55
|
+
}
|
|
56
|
+
const data = await response.json();
|
|
57
|
+
return (data.web?.results ?? []).slice(0, maxResults).map(r => ({
|
|
58
|
+
title: r.title,
|
|
59
|
+
url: r.url,
|
|
60
|
+
snippet: r.description,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
export const webSearchTool = defineTool({
|
|
64
|
+
name: 'web_search',
|
|
65
|
+
description: 'Search the web for information. Returns titles, URLs, and snippets of top results. Use this when you need current information not in your training data.',
|
|
66
|
+
inputSchema: z.object({
|
|
67
|
+
query: z.string().describe('The search query'),
|
|
68
|
+
maxResults: z.number().min(1).max(20).default(5).describe('Maximum number of results to return (default: 5)'),
|
|
69
|
+
}),
|
|
70
|
+
execute: async (input) => {
|
|
71
|
+
const braveKey = process.env.BRAVE_SEARCH_API_KEY;
|
|
72
|
+
const maxResults = input.maxResults ?? 5;
|
|
73
|
+
try {
|
|
74
|
+
const results = braveKey
|
|
75
|
+
? await searchBrave(input.query, maxResults, braveKey)
|
|
76
|
+
: await searchDuckDuckGo(input.query, maxResults);
|
|
77
|
+
if (results.length === 0) {
|
|
78
|
+
return { data: `No results found for: "${input.query}"` };
|
|
79
|
+
}
|
|
80
|
+
const formatted = results.map((r, i) => `${i + 1}. ${r.title}\n ${r.url}\n ${r.snippet}`).join('\n\n');
|
|
81
|
+
return { data: `Search results for "${input.query}":\n\n${formatted}` };
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
85
|
+
return { data: `Search failed: ${msg}`, isError: true };
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=web-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../../../src/tools/built-in/web-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAQ3C,KAAK,UAAU,gBAAgB,CAAC,KAAa,EAAE,UAAkB;IAC/D,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;IACzC,MAAM,GAAG,GAAG,uCAAuC,OAAO,EAAE,CAAA;IAE5D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,OAAO,EAAE;YACP,YAAY,EAAE,0CAA0C;SACzD;QACD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;KACnC,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAC3D,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAClC,MAAM,OAAO,GAAmB,EAAE,CAAA;IAElC,4CAA4C;IAC5C,MAAM,aAAa,GAAG,8HAA8H,CAAA;IACpJ,IAAI,KAA6B,CAAA;IACjC,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,K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