indusagi 0.12.8 → 0.12.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/agent/tools/index.d.ts +10 -7
- package/dist/agent/tools/index.d.ts.map +1 -1
- package/dist/agent/tools/index.js +1 -1
- package/dist/agent/tools/index.js.map +1 -1
- package/dist/agent/tools/task-types.d.ts +74 -0
- package/dist/agent/tools/task-types.d.ts.map +1 -0
- package/dist/agent/tools/task-types.js +8 -0
- package/dist/agent/tools/task-types.js.map +1 -0
- package/dist/agent/tools/task.d.ts +66 -8
- package/dist/agent/tools/task.d.ts.map +1 -1
- package/dist/agent/tools/task.js +165 -17
- package/dist/agent/tools/task.js.map +1 -1
- package/dist/agent/tools/todo-store.d.ts +65 -12
- package/dist/agent/tools/todo-store.d.ts.map +1 -1
- package/dist/agent/tools/todo-store.js +115 -15
- package/dist/agent/tools/todo-store.js.map +1 -1
- package/dist/agent/tools/todo-types.d.ts +73 -0
- package/dist/agent/tools/todo-types.d.ts.map +1 -0
- package/dist/agent/tools/todo-types.js +8 -0
- package/dist/agent/tools/todo-types.js.map +1 -0
- package/dist/agent/tools/todo.d.ts +53 -6
- package/dist/agent/tools/todo.d.ts.map +1 -1
- package/dist/agent/tools/todo.js +62 -2
- package/dist/agent/tools/todo.js.map +1 -1
- package/dist/agent/tools/websearch.d.ts +1 -1
- package/dist/agent/tools/websearch.d.ts.map +1 -1
- package/dist/agent/tools/websearch.js +49 -6
- package/dist/agent/tools/websearch.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,8 +9,9 @@ export { createGrepTool, grepTool, type GrepOperations, type GrepToolOptions, ty
|
|
|
9
9
|
export { createFindTool, findTool, type FindToolOptions, type FindToolDetails } from "./find.js";
|
|
10
10
|
export { createLsTool, lsTool, type LsOperations, type LsToolOptions, type LsToolDetails, } from "./ls.js";
|
|
11
11
|
export { createTaskTool, taskTool, type TaskToolOptions, type TaskToolDetails, } from "./task.js";
|
|
12
|
+
export type { TaskExecutor, TaskResult, TaskUpdate, SubagentDefinition, SubagentStore, } from "./task-types.js";
|
|
12
13
|
export { createTodoReadTool, createTodoWriteTool, todoReadTool, todoWriteTool, type TodoToolDetails, } from "./todo.js";
|
|
13
|
-
export { TodoStore, type TodoItem, type TodoPriority, type TodoStatus } from "./todo-store.js";
|
|
14
|
+
export { TodoStore, TODO_PRIORITIES, TODO_STATUSES, type TodoItem, type TodoPriority, type TodoStatus, type TodoStoreOptions, } from "./todo-store.js";
|
|
14
15
|
export { createWebSearchTool, webSearchTool, type WebSearchToolOptions, type WebSearchToolDetails, } from "./websearch.js";
|
|
15
16
|
export { createWebFetchTool, webFetchTool, type WebFetchToolOptions, type WebFetchToolDetails, } from "./webfetch.js";
|
|
16
17
|
export { computeEditDiff, generateDiffString } from "./edit-diff.js";
|
|
@@ -33,7 +34,8 @@ export declare const codingTools: (import("../types.js").AgentTool<import("@sinc
|
|
|
33
34
|
prompt: import("@sinclair/typebox").TString;
|
|
34
35
|
subagent_type: import("@sinclair/typebox").TString;
|
|
35
36
|
task_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
36
|
-
|
|
37
|
+
command: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
38
|
+
}>, import("./task-types.js").TaskToolDetails> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{}>, import("./todo-types.js").TodoToolDetails> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{
|
|
37
39
|
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
38
40
|
content: import("@sinclair/typebox").TString;
|
|
39
41
|
status: import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">;
|
|
@@ -41,7 +43,7 @@ export declare const codingTools: (import("../types.js").AgentTool<import("@sinc
|
|
|
41
43
|
}>>;
|
|
42
44
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
43
45
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">>;
|
|
44
|
-
}>, import("./todo.js").TodoToolDetails> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{
|
|
46
|
+
}>, import("./todo-types.js").TodoToolDetails> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{
|
|
45
47
|
url: import("@sinclair/typebox").TString;
|
|
46
48
|
format: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"text">, import("@sinclair/typebox").TLiteral<"markdown">, import("@sinclair/typebox").TLiteral<"html">]>>;
|
|
47
49
|
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -70,7 +72,7 @@ export declare const readOnlyTools: (import("../types.js").AgentTool<import("@si
|
|
|
70
72
|
path: import("@sinclair/typebox").TString;
|
|
71
73
|
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
72
74
|
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
73
|
-
}>, any> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{}>, import("./todo.js").TodoToolDetails> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{
|
|
75
|
+
}>, any> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{}>, import("./todo-types.js").TodoToolDetails> | import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{
|
|
74
76
|
url: import("@sinclair/typebox").TString;
|
|
75
77
|
format: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"text">, import("@sinclair/typebox").TLiteral<"markdown">, import("@sinclair/typebox").TLiteral<"html">]>>;
|
|
76
78
|
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -119,8 +121,9 @@ export declare const allTools: {
|
|
|
119
121
|
prompt: import("@sinclair/typebox").TString;
|
|
120
122
|
subagent_type: import("@sinclair/typebox").TString;
|
|
121
123
|
task_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
command: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
125
|
+
}>, import("./task-types.js").TaskToolDetails>;
|
|
126
|
+
readonly todoread: import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{}>, import("./todo-types.js").TodoToolDetails>;
|
|
124
127
|
readonly todowrite: import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{
|
|
125
128
|
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
126
129
|
content: import("@sinclair/typebox").TString;
|
|
@@ -129,7 +132,7 @@ export declare const allTools: {
|
|
|
129
132
|
}>>;
|
|
130
133
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
131
134
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">>;
|
|
132
|
-
}>, import("./todo.js").TodoToolDetails>;
|
|
135
|
+
}>, import("./todo-types.js").TodoToolDetails>;
|
|
133
136
|
readonly websearch: import("../types.js").AgentTool<import("@sinclair/typebox").TObject<{
|
|
134
137
|
query: import("@sinclair/typebox").TString;
|
|
135
138
|
numResults: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhE,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,E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AO,WAAW,EAAE,eAAe,CAAC;IAC3C,8BAA8B;IAC9B,EAAE,CAAC,EAAE,OAAO,SAAS,EAAE,aAAa,CAAC;IACrC,qCAAqC;IACrC,SAAS,CAAC,EAAE,OAAO,gBAAgB,EAAE,oBAAoB,CAAC;IAC1D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,eAAe,EAAE,mBAAmB,CAAC;CACvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,WAAW,CAGzF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,aAAa,CAG7F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,GACpB,OAAO,QAAQ,CAgBjB"}
|
|
@@ -27,7 +27,7 @@ export { createFindTool, findTool } from "./find.js";
|
|
|
27
27
|
export { createLsTool, lsTool, } from "./ls.js";
|
|
28
28
|
export { createTaskTool, taskTool, } from "./task.js";
|
|
29
29
|
export { createTodoReadTool, createTodoWriteTool, todoReadTool, todoWriteTool, } from "./todo.js";
|
|
30
|
-
export { TodoStore } from "./todo-store.js";
|
|
30
|
+
export { TodoStore, TODO_PRIORITIES, TODO_STATUSES, } from "./todo-store.js";
|
|
31
31
|
export { createWebSearchTool, webSearchTool, } from "./websearch.js";
|
|
32
32
|
export { createWebFetchTool, webFetchTool, } from "./webfetch.js";
|
|
33
33
|
// Re-export tool-specific utilities
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent/tools/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,sEAAsE;AACtE,+EAA+E;AAE/E,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,E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ACrD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAA6B;QACjE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,CAA8B;QACpE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,CAA8B;QACpE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAA6B;KACjE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Tool Types - Interfaces for extensible task execution
|
|
3
|
+
*
|
|
4
|
+
* These interfaces allow the task tool to be extended with custom executors.
|
|
5
|
+
* The coding-agent uses these to inject TaskSessionManager for actual subagent execution.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Task update callback - for streaming progress updates
|
|
9
|
+
*/
|
|
10
|
+
export interface TaskUpdate {
|
|
11
|
+
type: "chunk" | "complete" | "error";
|
|
12
|
+
content?: string;
|
|
13
|
+
details?: Partial<TaskToolDetails>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Task execution result
|
|
17
|
+
*/
|
|
18
|
+
export interface TaskResult {
|
|
19
|
+
output: string;
|
|
20
|
+
details: TaskToolDetails;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Task tool details - returned after task execution
|
|
24
|
+
*/
|
|
25
|
+
export interface TaskToolDetails {
|
|
26
|
+
taskId: string;
|
|
27
|
+
subagentType: string;
|
|
28
|
+
description: string;
|
|
29
|
+
result: string;
|
|
30
|
+
toolCalls: number;
|
|
31
|
+
durationMs: number;
|
|
32
|
+
model?: {
|
|
33
|
+
provider: string;
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Task executor interface - implement this to provide custom task execution
|
|
39
|
+
*
|
|
40
|
+
* The coding-agent implements this with TaskSessionManager that:
|
|
41
|
+
* - Creates actual subagent sessions
|
|
42
|
+
* - Runs the agent with the given prompt
|
|
43
|
+
* - Streams updates via onUpdate callback
|
|
44
|
+
* - Returns the final result
|
|
45
|
+
*/
|
|
46
|
+
export interface TaskExecutor {
|
|
47
|
+
/**
|
|
48
|
+
* Execute a task with the given parameters
|
|
49
|
+
*/
|
|
50
|
+
runTask(params: {
|
|
51
|
+
description: string;
|
|
52
|
+
prompt: string;
|
|
53
|
+
subagentType: string;
|
|
54
|
+
taskId?: string;
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
onUpdate?: (update: TaskUpdate) => void;
|
|
57
|
+
}): Promise<TaskResult>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Subagent definition - for describing available subagent types
|
|
61
|
+
*/
|
|
62
|
+
export interface SubagentDefinition {
|
|
63
|
+
name: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
mode?: string;
|
|
66
|
+
hidden?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Subagent store interface - for getting available subagents
|
|
70
|
+
*/
|
|
71
|
+
export interface SubagentStore {
|
|
72
|
+
list(): SubagentDefinition[];
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=task-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-types.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/task-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,eAAe,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;KACxC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,IAAI,IAAI,kBAAkB,EAAE,CAAC;CAC7B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Tool Types - Interfaces for extensible task execution
|
|
3
|
+
*
|
|
4
|
+
* These interfaces allow the task tool to be extended with custom executors.
|
|
5
|
+
* The coding-agent uses these to inject TaskSessionManager for actual subagent execution.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=task-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-types.js","sourceRoot":"","sources":["../../../src/agent/tools/task-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1,26 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Tool - Launch subagents for autonomous task execution
|
|
3
|
+
*
|
|
4
|
+
* @module agent/tools/task
|
|
5
|
+
* @description
|
|
6
|
+
* The task tool allows the agent to delegate complex or multi-step work to subagents.
|
|
7
|
+
* Subagents run autonomously and can use the full set of tools available to the main agent.
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* The task tool supports two modes:
|
|
12
|
+
* 1. **Simple mode** (default): Stores task info in memory, returns placeholder result
|
|
13
|
+
* 2. **Executor mode**: Uses injected TaskExecutor for actual subagent execution
|
|
14
|
+
*
|
|
15
|
+
* The coding-agent uses executor mode by providing a TaskExecutor that:
|
|
16
|
+
* - Creates real subagent sessions via TaskSessionManager
|
|
17
|
+
* - Runs the agent with the given prompt
|
|
18
|
+
* - Streams updates via onUpdate callback
|
|
19
|
+
* - Returns detailed results including tool calls, duration, model info
|
|
20
|
+
*
|
|
21
|
+
* ## Usage
|
|
22
|
+
*
|
|
23
|
+
* ### Simple mode (no executor)
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { createTaskTool } from "indusagi/agent";
|
|
26
|
+
* const taskTool = createTaskTool();
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* ### Executor mode (with custom execution)
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createTaskTool, type TaskExecutor } from "indusagi/agent";
|
|
32
|
+
*
|
|
33
|
+
* const executor: TaskExecutor = {
|
|
34
|
+
* async runTask(params) {
|
|
35
|
+
* // Custom implementation
|
|
36
|
+
* return { output: "result", details: { ... } };
|
|
37
|
+
* }
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* const taskTool = createTaskTool({ executor });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
1
43
|
import type { AgentTool } from "../types.js";
|
|
44
|
+
import type { TaskExecutor, TaskToolDetails, SubagentStore } from "./task-types.js";
|
|
45
|
+
export type { TaskExecutor, TaskResult, TaskToolDetails, TaskUpdate, SubagentStore } from "./task-types.js";
|
|
2
46
|
declare const taskSchema: import("@sinclair/typebox").TObject<{
|
|
3
47
|
description: import("@sinclair/typebox").TString;
|
|
4
48
|
prompt: import("@sinclair/typebox").TString;
|
|
5
49
|
subagent_type: import("@sinclair/typebox").TString;
|
|
6
50
|
task_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
51
|
+
command: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
52
|
}>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
subagentType: string;
|
|
12
|
-
taskId?: string;
|
|
13
|
-
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for creating the task tool
|
|
55
|
+
*/
|
|
14
56
|
export interface TaskToolOptions {
|
|
15
|
-
/**
|
|
57
|
+
/** Working directory for task execution */
|
|
16
58
|
cwd?: string;
|
|
59
|
+
/** Custom task executor (coding-agent provides this for real execution) */
|
|
60
|
+
executor?: TaskExecutor;
|
|
61
|
+
/** Subagent store for dynamic subagent type discovery */
|
|
62
|
+
subagentStore?: SubagentStore;
|
|
63
|
+
/** Build custom description with available subagents */
|
|
64
|
+
buildDescription?: (subagents: SubagentStore | undefined) => string;
|
|
17
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a task tool with optional custom executor
|
|
68
|
+
*
|
|
69
|
+
* @param options - Task tool options
|
|
70
|
+
* @param options.cwd - Working directory
|
|
71
|
+
* @param options.executor - Custom task executor for real execution
|
|
72
|
+
* @param options.subagentStore - Subagent store for dynamic type discovery
|
|
73
|
+
* @returns The task tool
|
|
74
|
+
*/
|
|
18
75
|
export declare function createTaskTool(options?: TaskToolOptions): AgentTool<typeof taskSchema, TaskToolDetails>;
|
|
76
|
+
/** Default task tool without executor (simple mode) */
|
|
19
77
|
export declare const taskTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
20
78
|
description: import("@sinclair/typebox").TString;
|
|
21
79
|
prompt: import("@sinclair/typebox").TString;
|
|
22
80
|
subagent_type: import("@sinclair/typebox").TString;
|
|
23
81
|
task_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
82
|
+
command: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
83
|
}>, TaskToolDetails>;
|
|
25
|
-
export {};
|
|
26
84
|
//# sourceMappingURL=task.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAA2B,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EACX,YAAY,EAEZ,eAAe,EAEf,aAAa,EACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE5G,QAAA,MAAM,UAAU;;;;;;EAWd,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,yDAAyD;IACzD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,KAAK,MAAM,CAAC;CACpE;AA6DD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC7B,OAAO,CAAC,EAAE,eAAe,GACvB,SAAS,CAAC,OAAO,UAAU,EAAE,eAAe,CAAC,CAsF/C;AAED,uDAAuD;AACvD,eAAO,MAAM,QAAQ;;;;;;oBAAmB,CAAC"}
|
package/dist/agent/tools/task.js
CHANGED
|
@@ -1,36 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Tool - Launch subagents for autonomous task execution
|
|
3
|
+
*
|
|
4
|
+
* @module agent/tools/task
|
|
5
|
+
* @description
|
|
6
|
+
* The task tool allows the agent to delegate complex or multi-step work to subagents.
|
|
7
|
+
* Subagents run autonomously and can use the full set of tools available to the main agent.
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* The task tool supports two modes:
|
|
12
|
+
* 1. **Simple mode** (default): Stores task info in memory, returns placeholder result
|
|
13
|
+
* 2. **Executor mode**: Uses injected TaskExecutor for actual subagent execution
|
|
14
|
+
*
|
|
15
|
+
* The coding-agent uses executor mode by providing a TaskExecutor that:
|
|
16
|
+
* - Creates real subagent sessions via TaskSessionManager
|
|
17
|
+
* - Runs the agent with the given prompt
|
|
18
|
+
* - Streams updates via onUpdate callback
|
|
19
|
+
* - Returns detailed results including tool calls, duration, model info
|
|
20
|
+
*
|
|
21
|
+
* ## Usage
|
|
22
|
+
*
|
|
23
|
+
* ### Simple mode (no executor)
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { createTaskTool } from "indusagi/agent";
|
|
26
|
+
* const taskTool = createTaskTool();
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* ### Executor mode (with custom execution)
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createTaskTool, type TaskExecutor } from "indusagi/agent";
|
|
32
|
+
*
|
|
33
|
+
* const executor: TaskExecutor = {
|
|
34
|
+
* async runTask(params) {
|
|
35
|
+
* // Custom implementation
|
|
36
|
+
* return { output: "result", details: { ... } };
|
|
37
|
+
* }
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* const taskTool = createTaskTool({ executor });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
1
43
|
import { Type } from "@sinclair/typebox";
|
|
2
44
|
const taskSchema = Type.Object({
|
|
3
|
-
description: Type.String({ description: "A short (3-5 words) description of task" }),
|
|
4
|
-
prompt: Type.String({ description: "The task for subagent to perform" }),
|
|
45
|
+
description: Type.String({ description: "A short (3-5 words) description of the task" }),
|
|
46
|
+
prompt: Type.String({ description: "The task for the subagent to perform" }),
|
|
5
47
|
subagent_type: Type.String({ description: "The type of specialized subagent to use for this task" }),
|
|
6
48
|
task_id: Type.Optional(Type.String({
|
|
7
|
-
description: "Only set to resume a previous task. The task will continue
|
|
49
|
+
description: "Only set to resume a previous task. The task will continue the same subagent session as before.",
|
|
8
50
|
})),
|
|
51
|
+
command: Type.Optional(Type.String({ description: "The command that triggered this task (optional)" })),
|
|
9
52
|
});
|
|
53
|
+
// Simple in-memory task sessions for basic mode
|
|
10
54
|
const taskSessions = new Map();
|
|
55
|
+
/**
|
|
56
|
+
* Build task description with available subagent types
|
|
57
|
+
*/
|
|
58
|
+
function buildDefaultDescription(subagentStore) {
|
|
59
|
+
const header = "Launch a subagent to handle complex or multi-step work autonomously.";
|
|
60
|
+
const instructions = "\n\nAvailable subagent types:\n- general: General-purpose subagent for multi-step tasks and research.\n- explore: Subagent specialized in codebase exploration and search.\n\nWhen using this tool, provide a clear description, a detailed prompt, and the subagent_type. Use task_id to resume a previous task.";
|
|
61
|
+
if (!subagentStore) {
|
|
62
|
+
return `${header}${instructions}`;
|
|
63
|
+
}
|
|
64
|
+
const subagents = subagentStore
|
|
65
|
+
.list()
|
|
66
|
+
.filter((agent) => agent.mode !== "primary" && agent.hidden !== true)
|
|
67
|
+
.map((agent) => `- ${agent.name}${agent.description ? `: ${agent.description}` : ""}`)
|
|
68
|
+
.join("\n");
|
|
69
|
+
return subagents
|
|
70
|
+
? `${header}\n\nAvailable subagent types:\n${subagents}\n\nWhen using this tool, provide a clear description, a detailed prompt, and the subagent_type. Use task_id to resume a previous task.`
|
|
71
|
+
: `${header}${instructions}`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Default simple executor for basic mode
|
|
75
|
+
*/
|
|
76
|
+
const defaultExecutor = {
|
|
77
|
+
async runTask({ description, prompt, subagentType, taskId }) {
|
|
78
|
+
const id = taskId ?? `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
79
|
+
const existing = taskSessions.get(id);
|
|
80
|
+
const session = {
|
|
81
|
+
description: description || existing?.description || "",
|
|
82
|
+
prompt: prompt || existing?.prompt || "",
|
|
83
|
+
subagentType: subagentType || existing?.subagentType || "general",
|
|
84
|
+
status: "completed",
|
|
85
|
+
};
|
|
86
|
+
taskSessions.set(id, session);
|
|
87
|
+
const output = `Task(${id}): ${session.description}\n${session.prompt}\nStatus: ${session.status}`;
|
|
88
|
+
return {
|
|
89
|
+
output,
|
|
90
|
+
details: {
|
|
91
|
+
taskId: id,
|
|
92
|
+
subagentType: session.subagentType,
|
|
93
|
+
description: session.description,
|
|
94
|
+
result: session.status,
|
|
95
|
+
toolCalls: 0,
|
|
96
|
+
durationMs: 0,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Create a task tool with optional custom executor
|
|
103
|
+
*
|
|
104
|
+
* @param options - Task tool options
|
|
105
|
+
* @param options.cwd - Working directory
|
|
106
|
+
* @param options.executor - Custom task executor for real execution
|
|
107
|
+
* @param options.subagentStore - Subagent store for dynamic type discovery
|
|
108
|
+
* @returns The task tool
|
|
109
|
+
*/
|
|
11
110
|
export function createTaskTool(options) {
|
|
111
|
+
const executor = options?.executor ?? defaultExecutor;
|
|
112
|
+
const subagentStore = options?.subagentStore;
|
|
113
|
+
const descriptionBuilder = options?.buildDescription ?? buildDefaultDescription;
|
|
12
114
|
return {
|
|
13
115
|
name: "task",
|
|
14
116
|
label: "task",
|
|
15
|
-
description:
|
|
117
|
+
description: descriptionBuilder(subagentStore),
|
|
16
118
|
parameters: taskSchema,
|
|
17
|
-
execute: async (_toolCallId, { description, prompt, subagent_type, task_id }) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
119
|
+
execute: async (_toolCallId, { description, prompt, subagent_type, task_id }, signal, onUpdate) => {
|
|
120
|
+
// Check if already aborted
|
|
121
|
+
if (signal?.aborted) {
|
|
122
|
+
throw new Error("Task aborted before execution");
|
|
123
|
+
}
|
|
124
|
+
// Track accumulated stats for streaming updates
|
|
125
|
+
let accumulatedToolCalls = 0;
|
|
126
|
+
let accumulatedDurationMs = 0;
|
|
127
|
+
// Convert onUpdate callback to TaskUpdate callback
|
|
128
|
+
const taskUpdateCallback = onUpdate
|
|
129
|
+
? (update) => {
|
|
130
|
+
// Update accumulated stats if provided
|
|
131
|
+
if (update.details) {
|
|
132
|
+
accumulatedToolCalls = update.details.toolCalls ?? accumulatedToolCalls;
|
|
133
|
+
accumulatedDurationMs = update.details.durationMs ?? accumulatedDurationMs;
|
|
134
|
+
}
|
|
135
|
+
if (update.type === "chunk" && update.content) {
|
|
136
|
+
onUpdate({
|
|
137
|
+
content: [{ type: "text", text: update.content }],
|
|
138
|
+
details: {
|
|
139
|
+
taskId: update.details?.taskId ?? task_id ?? "",
|
|
140
|
+
subagentType: update.details?.subagentType ?? subagent_type,
|
|
141
|
+
description: update.details?.description ?? description,
|
|
142
|
+
result: update.details?.result ?? "",
|
|
143
|
+
toolCalls: accumulatedToolCalls,
|
|
144
|
+
durationMs: accumulatedDurationMs,
|
|
145
|
+
model: update.details?.model,
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else if (update.type === "complete" && update.details && update.details.taskId) {
|
|
150
|
+
// Only call complete when we have all required fields
|
|
151
|
+
onUpdate({
|
|
152
|
+
content: [{ type: "text", text: "" }],
|
|
153
|
+
details: {
|
|
154
|
+
taskId: update.details.taskId,
|
|
155
|
+
subagentType: update.details.subagentType ?? subagent_type,
|
|
156
|
+
description: update.details.description ?? description,
|
|
157
|
+
result: update.details.result ?? "",
|
|
158
|
+
toolCalls: update.details.toolCalls ?? accumulatedToolCalls,
|
|
159
|
+
durationMs: update.details.durationMs ?? accumulatedDurationMs,
|
|
160
|
+
model: update.details.model,
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
: undefined;
|
|
166
|
+
// Execute the task
|
|
167
|
+
const result = await executor.runTask({
|
|
168
|
+
description,
|
|
169
|
+
prompt,
|
|
170
|
+
subagentType: subagent_type,
|
|
171
|
+
taskId: task_id,
|
|
172
|
+
signal,
|
|
173
|
+
onUpdate: taskUpdateCallback,
|
|
174
|
+
});
|
|
28
175
|
return {
|
|
29
|
-
content: [{ type: "text", text: output }],
|
|
30
|
-
details:
|
|
176
|
+
content: [{ type: "text", text: result.output }],
|
|
177
|
+
details: result.details,
|
|
31
178
|
};
|
|
32
179
|
},
|
|
33
180
|
};
|
|
34
181
|
}
|
|
182
|
+
/** Default task tool without executor (simple mode) */
|
|
35
183
|
export const taskTool = createTaskTool();
|
|
36
184
|
//# sourceMappingURL=task.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/agent/tools/task.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/agent/tools/task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAWzC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;IACxF,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,E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,OAAO,EAAE,MAAM,CAAC,OAAO;aACvB,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC"}
|
|
@@ -1,24 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Store - Persistent todo list management
|
|
3
|
+
*
|
|
4
|
+
* @module agent/tools/todo-store
|
|
5
|
+
* @description
|
|
6
|
+
* Manages a todo list with optional persistence callbacks.
|
|
7
|
+
* The coding-agent uses this to integrate with SessionManager for session persistence.
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* The TodoStore supports two modes:
|
|
12
|
+
* 1. **Simple mode** (default): Stores todos in memory only
|
|
13
|
+
* 2. **Persistent mode**: Uses callbacks to persist/load todos
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ### Simple mode
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const store = new TodoStore();
|
|
20
|
+
* store.setTodos([{ content: "Task", status: "pending", priority: "high" }]);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ### Persistent mode (coding-agent style)
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const store = new TodoStore({
|
|
26
|
+
* persist: (todos) => sessionManager.appendCustomEntry('todo', { todos }),
|
|
27
|
+
* load: () => loadFromSession(),
|
|
28
|
+
* rebuildFromBranch: () => rebuildFromSession(),
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import type { TodoItem, TodoStatus, TodoStoreOptions } from "./todo-types.js";
|
|
33
|
+
export type { TodoItem, TodoStatus, TodoPriority, TodoStoreOptions, TodoToolDetails } from "./todo-types.js";
|
|
34
|
+
declare const TODO_STATUSES: readonly ["pending", "in_progress", "completed", "cancelled"];
|
|
35
|
+
declare const TODO_PRIORITIES: readonly ["high", "medium", "low"];
|
|
1
36
|
/**
|
|
2
37
|
* Simple Todo Store for the todo tool.
|
|
3
|
-
*
|
|
38
|
+
* Supports optional persistence callbacks for session integration.
|
|
4
39
|
*/
|
|
5
|
-
export declare const TODO_STATUSES: readonly ["pending", "in_progress", "completed", "cancelled"];
|
|
6
|
-
export type TodoStatus = (typeof TODO_STATUSES)[number];
|
|
7
|
-
export declare const TODO_PRIORITIES: readonly ["high", "medium", "low"];
|
|
8
|
-
export type TodoPriority = (typeof TODO_PRIORITIES)[number];
|
|
9
|
-
export interface TodoItem {
|
|
10
|
-
content: string;
|
|
11
|
-
status: TodoStatus;
|
|
12
|
-
priority: TodoPriority;
|
|
13
|
-
expiresAt?: number;
|
|
14
|
-
}
|
|
15
40
|
export declare class TodoStore {
|
|
16
41
|
private todos;
|
|
17
|
-
|
|
42
|
+
private options?;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new TodoStore
|
|
45
|
+
* @param initialTodos - Optional initial todos (takes precedence over load callback)
|
|
46
|
+
* @param options - Optional persistence callbacks
|
|
47
|
+
*/
|
|
48
|
+
constructor(initialTodos?: TodoItem[], options?: TodoStoreOptions);
|
|
49
|
+
constructor(options?: TodoStoreOptions);
|
|
50
|
+
/**
|
|
51
|
+
* Get all todos (returns a copy)
|
|
52
|
+
*/
|
|
18
53
|
getTodos(): TodoItem[];
|
|
54
|
+
/**
|
|
55
|
+
* Set todos and persist
|
|
56
|
+
*/
|
|
19
57
|
setTodos(todos: TodoItem[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* Find todos matching a query
|
|
60
|
+
*/
|
|
20
61
|
find(query: string): TodoItem[];
|
|
62
|
+
/**
|
|
63
|
+
* Filter todos by status
|
|
64
|
+
*/
|
|
21
65
|
filterByStatus(status: TodoStatus): TodoItem[];
|
|
66
|
+
/**
|
|
67
|
+
* Rebuild todos from session branch
|
|
68
|
+
* Called when navigating the session tree
|
|
69
|
+
*/
|
|
70
|
+
rebuildFromBranch(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Remove expired todos
|
|
73
|
+
*/
|
|
22
74
|
private removeExpired;
|
|
23
75
|
}
|
|
76
|
+
export { TODO_STATUSES, TODO_PRIORITIES };
|
|
24
77
|
//# sourceMappingURL=todo-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo-store.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/todo-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"todo-store.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/todo-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE7G,QAAA,MAAM,aAAa,+DAAgE,CAAC;AACpF,QAAA,MAAM,eAAe,oCAAqC,CAAC;AAI3D;;;GAGG;AACH,qBAAa,SAAS;IACrB,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,OAAO,CAAC,CAAmB;IAEnC;;;;OAIG;gBACS,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB;gBACrD,OAAO,CAAC,EAAE,gBAAgB;IA0BtC;;OAEG;IACH,QAAQ,IAAI,QAAQ,EAAE;IAKtB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI;IAMjC;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE;IAK/B;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,EAAE;IAI9C;;;OAGG;IACH,iBAAiB,IAAI,IAAI;IAczB;;OAEG;IACH,OAAO,CAAC,aAAa;CAYrB;AAUD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,36 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Store - Persistent todo list management
|
|
3
|
+
*
|
|
4
|
+
* @module agent/tools/todo-store
|
|
5
|
+
* @description
|
|
6
|
+
* Manages a todo list with optional persistence callbacks.
|
|
7
|
+
* The coding-agent uses this to integrate with SessionManager for session persistence.
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* The TodoStore supports two modes:
|
|
12
|
+
* 1. **Simple mode** (default): Stores todos in memory only
|
|
13
|
+
* 2. **Persistent mode**: Uses callbacks to persist/load todos
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ### Simple mode
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const store = new TodoStore();
|
|
20
|
+
* store.setTodos([{ content: "Task", status: "pending", priority: "high" }]);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ### Persistent mode (coding-agent style)
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const store = new TodoStore({
|
|
26
|
+
* persist: (todos) => sessionManager.appendCustomEntry('todo', { todos }),
|
|
27
|
+
* load: () => loadFromSession(),
|
|
28
|
+
* rebuildFromBranch: () => rebuildFromSession(),
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
const TODO_STATUSES = ["pending", "in_progress", "completed", "cancelled"];
|
|
33
|
+
const TODO_PRIORITIES = ["high", "medium", "low"];
|
|
1
34
|
/**
|
|
2
35
|
* Simple Todo Store for the todo tool.
|
|
3
|
-
*
|
|
36
|
+
* Supports optional persistence callbacks for session integration.
|
|
4
37
|
*/
|
|
5
|
-
export const TODO_STATUSES = ["pending", "in_progress", "completed", "cancelled"];
|
|
6
|
-
export const TODO_PRIORITIES = ["high", "medium", "low"];
|
|
7
|
-
function cloneTodos(todos) {
|
|
8
|
-
return todos.map((todo) => ({ ...todo }));
|
|
9
|
-
}
|
|
10
38
|
export class TodoStore {
|
|
11
|
-
constructor(
|
|
39
|
+
constructor(initialTodosOrOptions, options) {
|
|
12
40
|
this.todos = [];
|
|
13
|
-
|
|
14
|
-
|
|
41
|
+
// Handle overloaded constructor
|
|
42
|
+
if (Array.isArray(initialTodosOrOptions)) {
|
|
43
|
+
this.todos = cloneTodos(initialTodosOrOptions);
|
|
44
|
+
this.options = options;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.options = initialTodosOrOptions;
|
|
48
|
+
// Load from persistence callback if available
|
|
49
|
+
if (this.options?.load) {
|
|
50
|
+
try {
|
|
51
|
+
const loaded = this.options.load();
|
|
52
|
+
if (Array.isArray(loaded)) {
|
|
53
|
+
this.todos = cloneTodos(loaded);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// Ignore load errors, start with empty
|
|
58
|
+
this.todos = [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
15
61
|
}
|
|
62
|
+
// Remove expired todos
|
|
63
|
+
this.removeExpired();
|
|
16
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Get all todos (returns a copy)
|
|
67
|
+
*/
|
|
17
68
|
getTodos() {
|
|
18
69
|
this.removeExpired();
|
|
19
70
|
return cloneTodos(this.todos);
|
|
20
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Set todos and persist
|
|
74
|
+
*/
|
|
21
75
|
setTodos(todos) {
|
|
22
76
|
this.todos = cloneTodos(todos);
|
|
23
|
-
this.
|
|
77
|
+
this.options?.persist?.(this.todos);
|
|
78
|
+
this.options?.onChange?.(this.todos);
|
|
24
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Find todos matching a query
|
|
82
|
+
*/
|
|
25
83
|
find(query) {
|
|
26
|
-
const
|
|
27
|
-
return this.
|
|
84
|
+
const lowerQuery = query.toLowerCase();
|
|
85
|
+
return this.todos.filter((todo) => todo.content.toLowerCase().includes(lowerQuery));
|
|
28
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Filter todos by status
|
|
89
|
+
*/
|
|
29
90
|
filterByStatus(status) {
|
|
30
|
-
return this.
|
|
91
|
+
return this.todos.filter((todo) => todo.status === status);
|
|
31
92
|
}
|
|
32
|
-
|
|
33
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Rebuild todos from session branch
|
|
95
|
+
* Called when navigating the session tree
|
|
96
|
+
*/
|
|
97
|
+
rebuildFromBranch() {
|
|
98
|
+
if (this.options?.rebuildFromBranch) {
|
|
99
|
+
try {
|
|
100
|
+
const rebuilt = this.options.rebuildFromBranch();
|
|
101
|
+
if (Array.isArray(rebuilt)) {
|
|
102
|
+
this.todos = cloneTodos(rebuilt);
|
|
103
|
+
this.options?.onChange?.(this.todos);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
// Ignore rebuild errors
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Remove expired todos
|
|
113
|
+
*/
|
|
114
|
+
removeExpired() {
|
|
115
|
+
const now = Date.now();
|
|
116
|
+
const before = this.todos.length;
|
|
117
|
+
this.todos = this.todos.filter((todo) => {
|
|
118
|
+
if (todo.expiresAt === undefined)
|
|
119
|
+
return true;
|
|
120
|
+
return todo.expiresAt > now;
|
|
121
|
+
});
|
|
122
|
+
// If any were removed, notify
|
|
123
|
+
if (this.todos.length !== before) {
|
|
124
|
+
this.options?.onChange?.(this.todos);
|
|
125
|
+
}
|
|
34
126
|
}
|
|
35
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Clone todos to prevent external mutation
|
|
130
|
+
*/
|
|
131
|
+
function cloneTodos(todos) {
|
|
132
|
+
return todos.map((todo) => ({ ...todo }));
|
|
133
|
+
}
|
|
134
|
+
// Export constants for external use
|
|
135
|
+
export { TODO_STATUSES, TODO_PRIORITIES };
|
|
36
136
|
//# sourceMappingURL=todo-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo-store.js","sourceRoot":"","sources":["../../../src/agent/tools/todo-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"todo-store.js","sourceRoot":"","sources":["../../../src/agent/tools/todo-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAMH,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AACpF,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAI3D;;;GAGG;AACH,MAAM,OAAO,SAAS;IAWrB,YAAY,qBAAqD,EAAE,OAA0B;QAVrF,UAAK,GAAe,EAAE,CAAC;QAW9B,gCAAgC;QAChC,IAAI,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAC1C,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;YAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,GAAG,qBAAqB,CAAC;YACrC,8CAA8C;YAC9C,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;gBACxB,IAAI,CAAC;oBACJ,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;oBACnC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;wBAC3B,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;oBACjC,CAAC;gBACF,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,uCAAuC;oBACvC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;gBACjB,CAAC;YACF,CAAC;QACF,CAAC;QAED,uBAAuB;QACvB,IAAI,CAAC,aAAa,EAA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YACF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,wBAAwB;YACzB,CAAC;QACF,CAAC;IACF,CAAC;IAED;;OAEG;IACK,aAAa;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACvC,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YAC9C,OAAO,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,8BAA8B;QAC9B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAClC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;CACD;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,KAAiB;IACpC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,oCAAoC;AACpC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Tool Types - Interfaces for extensible todo storage
|
|
3
|
+
*
|
|
4
|
+
* These interfaces allow the todo tool to be extended with custom persistence.
|
|
5
|
+
* The coding-agent uses these to integrate with SessionManager for session persistence.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Todo item status
|
|
9
|
+
*/
|
|
10
|
+
export type TodoStatus = "pending" | "in_progress" | "completed" | "cancelled";
|
|
11
|
+
/**
|
|
12
|
+
* Todo item priority
|
|
13
|
+
*/
|
|
14
|
+
export type TodoPriority = "high" | "medium" | "low";
|
|
15
|
+
/**
|
|
16
|
+
* Todo item structure
|
|
17
|
+
*/
|
|
18
|
+
export interface TodoItem {
|
|
19
|
+
content: string;
|
|
20
|
+
status: TodoStatus;
|
|
21
|
+
priority: TodoPriority;
|
|
22
|
+
expiresAt?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Todo tool details - returned after todo operations
|
|
26
|
+
*/
|
|
27
|
+
export interface TodoToolDetails {
|
|
28
|
+
todos: TodoItem[];
|
|
29
|
+
incompleteCount: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for TodoStore - allows custom persistence
|
|
33
|
+
*
|
|
34
|
+
* The coding-agent implements these to:
|
|
35
|
+
* - persist: Save todos to session entries
|
|
36
|
+
* - load: Load todos from session on startup
|
|
37
|
+
* - rebuildFromBranch: Restore todos when navigating session tree
|
|
38
|
+
*/
|
|
39
|
+
export interface TodoStoreOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Persist todos to storage
|
|
42
|
+
* Called whenever todos are updated
|
|
43
|
+
*/
|
|
44
|
+
persist?: (todos: TodoItem[]) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Load todos from storage
|
|
47
|
+
* Called on TodoStore construction
|
|
48
|
+
*/
|
|
49
|
+
load?: () => TodoItem[];
|
|
50
|
+
/**
|
|
51
|
+
* Rebuild todos from session branch
|
|
52
|
+
* Called when navigating the session tree
|
|
53
|
+
*/
|
|
54
|
+
rebuildFromBranch?: () => TodoItem[];
|
|
55
|
+
/**
|
|
56
|
+
* Callback when todos change
|
|
57
|
+
* Useful for triggering UI updates
|
|
58
|
+
*/
|
|
59
|
+
onChange?: (todos: TodoItem[]) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Session manager interface for type safety
|
|
63
|
+
* The coding-agent's SessionManager implements this
|
|
64
|
+
*/
|
|
65
|
+
export interface TodoSessionManager {
|
|
66
|
+
appendCustomEntry(type: string, data: unknown): void;
|
|
67
|
+
getBranch(): Array<{
|
|
68
|
+
type?: string;
|
|
69
|
+
customType?: string;
|
|
70
|
+
data?: unknown;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=todo-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-types.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/todo-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAEtC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,CAAC;IAExB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,QAAQ,EAAE,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrD,SAAS,IAAI,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC3E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Tool Types - Interfaces for extensible todo storage
|
|
3
|
+
*
|
|
4
|
+
* These interfaces allow the todo tool to be extended with custom persistence.
|
|
5
|
+
* The coding-agent uses these to integrate with SessionManager for session persistence.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=todo-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo-types.js","sourceRoot":"","sources":["../../../src/agent/tools/todo-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1,5 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Tools - Read and write todo lists
|
|
3
|
+
*
|
|
4
|
+
* @module agent/tools/todo
|
|
5
|
+
* @description
|
|
6
|
+
* Provides tools for managing todo lists. The todos are stored in a TodoStore
|
|
7
|
+
* which can optionally persist to external storage (e.g., session entries).
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* Two tools are provided:
|
|
12
|
+
* - `todoread`: Read the current todo list
|
|
13
|
+
* - `todowrite`: Update the todo list
|
|
14
|
+
*
|
|
15
|
+
* Both tools share the same TodoStore instance for consistency.
|
|
16
|
+
*
|
|
17
|
+
* ## Usage
|
|
18
|
+
*
|
|
19
|
+
* ### Simple mode
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { todoReadTool, todoWriteTool } from "indusagi/agent";
|
|
22
|
+
* // Uses default in-memory store
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ### With custom store (persistent mode)
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { createTodoReadTool, createTodoWriteTool, TodoStore } from "indusagi/agent";
|
|
28
|
+
*
|
|
29
|
+
* const store = new TodoStore({
|
|
30
|
+
* persist: (todos) => sessionManager.appendCustomEntry('todo', { todos }),
|
|
31
|
+
* load: () => loadFromSession(),
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const todoReadTool = createTodoReadTool(store);
|
|
35
|
+
* const todoWriteTool = createTodoWriteTool(store);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
1
38
|
import type { AgentTool } from "../types.js";
|
|
2
|
-
import { TodoStore
|
|
39
|
+
import { TodoStore } from "./todo-store.js";
|
|
40
|
+
import type { TodoToolDetails } from "./todo-types.js";
|
|
41
|
+
export type { TodoItem, TodoStatus, TodoPriority, TodoStoreOptions, TodoToolDetails } from "./todo-types.js";
|
|
42
|
+
export { TodoStore, TODO_PRIORITIES, TODO_STATUSES } from "./todo-store.js";
|
|
3
43
|
declare const TodoReadSchema: import("@sinclair/typebox").TObject<{}>;
|
|
4
44
|
declare const TodoWriteSchema: import("@sinclair/typebox").TObject<{
|
|
5
45
|
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
@@ -10,13 +50,21 @@ declare const TodoWriteSchema: import("@sinclair/typebox").TObject<{
|
|
|
10
50
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
11
51
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">>;
|
|
12
52
|
}>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Create a todo read tool
|
|
55
|
+
* @param store - The TodoStore to read from
|
|
56
|
+
* @returns The todoread tool
|
|
57
|
+
*/
|
|
17
58
|
export declare function createTodoReadTool(store: TodoStore): AgentTool<typeof TodoReadSchema, TodoToolDetails>;
|
|
59
|
+
/**
|
|
60
|
+
* Create a todo write tool
|
|
61
|
+
* @param store - The TodoStore to write to
|
|
62
|
+
* @returns The todowrite tool
|
|
63
|
+
*/
|
|
18
64
|
export declare function createTodoWriteTool(store: TodoStore): AgentTool<typeof TodoWriteSchema, TodoToolDetails>;
|
|
65
|
+
/** Default todo read tool using in-memory store */
|
|
19
66
|
export declare const todoReadTool: AgentTool<import("@sinclair/typebox").TObject<{}>, TodoToolDetails>;
|
|
67
|
+
/** Default todo write tool using in-memory store */
|
|
20
68
|
export declare const todoWriteTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
21
69
|
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
22
70
|
content: import("@sinclair/typebox").TString;
|
|
@@ -26,5 +74,4 @@ export declare const todoWriteTool: AgentTool<import("@sinclair/typebox").TObjec
|
|
|
26
74
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
27
75
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">>;
|
|
28
76
|
}>, TodoToolDetails>;
|
|
29
|
-
export {};
|
|
30
77
|
//# sourceMappingURL=todo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/todo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../../../src/agent/tools/todo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAkC,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG7E,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQ5E,QAAA,MAAM,cAAc,yCAAkB,CAAC;AACvC,QAAA,MAAM,eAAe;;;;;;;;EAQnB,CAAC;AAgBH;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,SAAS,GACd,SAAS,CAAC,OAAO,cAAc,EAAE,eAAe,CAAC,CAcnD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,SAAS,GACd,SAAS,CAAC,OAAO,eAAe,EAAE,eAAe,CAAC,CA0BpD;AAKD,mDAAmD;AACnD,eAAO,MAAM,YAAY,qEAAmC,CAAC;AAE7D,oDAAoD;AACpD,eAAO,MAAM,aAAa;;;;;;;;oBAAoC,CAAC"}
|
package/dist/agent/tools/todo.js
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Tools - Read and write todo lists
|
|
3
|
+
*
|
|
4
|
+
* @module agent/tools/todo
|
|
5
|
+
* @description
|
|
6
|
+
* Provides tools for managing todo lists. The todos are stored in a TodoStore
|
|
7
|
+
* which can optionally persist to external storage (e.g., session entries).
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* Two tools are provided:
|
|
12
|
+
* - `todoread`: Read the current todo list
|
|
13
|
+
* - `todowrite`: Update the todo list
|
|
14
|
+
*
|
|
15
|
+
* Both tools share the same TodoStore instance for consistency.
|
|
16
|
+
*
|
|
17
|
+
* ## Usage
|
|
18
|
+
*
|
|
19
|
+
* ### Simple mode
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { todoReadTool, todoWriteTool } from "indusagi/agent";
|
|
22
|
+
* // Uses default in-memory store
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ### With custom store (persistent mode)
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { createTodoReadTool, createTodoWriteTool, TodoStore } from "indusagi/agent";
|
|
28
|
+
*
|
|
29
|
+
* const store = new TodoStore({
|
|
30
|
+
* persist: (todos) => sessionManager.appendCustomEntry('todo', { todos }),
|
|
31
|
+
* load: () => loadFromSession(),
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const todoReadTool = createTodoReadTool(store);
|
|
35
|
+
* const todoWriteTool = createTodoWriteTool(store);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
1
38
|
import { StringEnum } from "../../ai/index.js";
|
|
2
39
|
import { Type } from "@sinclair/typebox";
|
|
3
40
|
import { TodoStore } from "./todo-store.js";
|
|
41
|
+
export { TodoStore, TODO_PRIORITIES, TODO_STATUSES } from "./todo-store.js";
|
|
4
42
|
const TodoItemSchema = Type.Object({
|
|
5
|
-
content: Type.String({ description: "Brief description of task" }),
|
|
43
|
+
content: Type.String({ description: "Brief description of the task" }),
|
|
6
44
|
status: StringEnum(["pending", "in_progress", "completed", "cancelled"]),
|
|
7
45
|
priority: StringEnum(["high", "medium", "low"]),
|
|
8
46
|
});
|
|
@@ -10,14 +48,27 @@ const TodoReadSchema = Type.Object({});
|
|
|
10
48
|
const TodoWriteSchema = Type.Object({
|
|
11
49
|
todos: Type.Array(TodoItemSchema, { description: "The updated todo list" }),
|
|
12
50
|
search: Type.Optional(Type.String({ description: "Optional query to filter todos after update" })),
|
|
13
|
-
status: Type.Optional(StringEnum(["pending", "in_progress", "completed", "cancelled"]
|
|
51
|
+
status: Type.Optional(StringEnum(["pending", "in_progress", "completed", "cancelled"], {
|
|
52
|
+
description: "Filter by status after update",
|
|
53
|
+
})),
|
|
14
54
|
});
|
|
55
|
+
/**
|
|
56
|
+
* Format todos as JSON string
|
|
57
|
+
*/
|
|
15
58
|
function formatTodos(todos) {
|
|
16
59
|
return JSON.stringify(todos, null, 2);
|
|
17
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Count incomplete (non-completed) todos
|
|
63
|
+
*/
|
|
18
64
|
function countIncomplete(todos) {
|
|
19
65
|
return todos.filter((todo) => todo.status !== "completed").length;
|
|
20
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Create a todo read tool
|
|
69
|
+
* @param store - The TodoStore to read from
|
|
70
|
+
* @returns The todoread tool
|
|
71
|
+
*/
|
|
21
72
|
export function createTodoReadTool(store) {
|
|
22
73
|
return {
|
|
23
74
|
name: "todoread",
|
|
@@ -33,6 +84,11 @@ export function createTodoReadTool(store) {
|
|
|
33
84
|
},
|
|
34
85
|
};
|
|
35
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a todo write tool
|
|
89
|
+
* @param store - The TodoStore to write to
|
|
90
|
+
* @returns The todowrite tool
|
|
91
|
+
*/
|
|
36
92
|
export function createTodoWriteTool(store) {
|
|
37
93
|
return {
|
|
38
94
|
name: "todowrite",
|
|
@@ -42,6 +98,7 @@ export function createTodoWriteTool(store) {
|
|
|
42
98
|
execute: async (_toolCallId, { todos, search, status }) => {
|
|
43
99
|
const typedTodos = todos;
|
|
44
100
|
store.setTodos(typedTodos);
|
|
101
|
+
// Get todos and apply filters
|
|
45
102
|
let selected = store.getTodos();
|
|
46
103
|
if (typeof search === "string" && search.trim()) {
|
|
47
104
|
selected = store.find(search.trim());
|
|
@@ -56,7 +113,10 @@ export function createTodoWriteTool(store) {
|
|
|
56
113
|
},
|
|
57
114
|
};
|
|
58
115
|
}
|
|
116
|
+
// Default store for simple mode
|
|
59
117
|
const defaultStore = new TodoStore();
|
|
118
|
+
/** Default todo read tool using in-memory store */
|
|
60
119
|
export const todoReadTool = createTodoReadTool(defaultStore);
|
|
120
|
+
/** Default todo write tool using in-memory store */
|
|
61
121
|
export const todoWriteTool = createTodoWriteTool(defaultStore);
|
|
62
122
|
//# sourceMappingURL=todo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../../../src/agent/tools/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search Tool
|
|
3
3
|
*
|
|
4
|
-
* Performs real-time web searches using
|
|
4
|
+
* Performs real-time web searches using DuckDuckGo API.
|
|
5
5
|
* Provides up-to-date information for current events and recent data.
|
|
6
6
|
*/
|
|
7
7
|
import { Type } from "@sinclair/typebox";
|
|
@@ -12,19 +12,62 @@ const webSearchSchema = Type.Object({
|
|
|
12
12
|
let windowStart = Date.now();
|
|
13
13
|
let requestCount = 0;
|
|
14
14
|
/**
|
|
15
|
-
* Default web search implementation
|
|
15
|
+
* Default web search implementation using DuckDuckGo
|
|
16
16
|
*/
|
|
17
17
|
async function defaultWebSearch(query, numResults, signal) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const count = Math.min(numResults ?? 8, 10);
|
|
19
|
+
try {
|
|
20
|
+
// Use DuckDuckGo Instant Answer API for web search
|
|
21
|
+
const searchUrl = `https://api.duckduckgo.com/?q=${encodeURIComponent(query)}&format=json&no_html=1&skip_disambig=1`;
|
|
22
|
+
const response = await fetch(searchUrl, {
|
|
23
|
+
signal,
|
|
24
|
+
headers: {
|
|
25
|
+
'Accept': 'application/json',
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new Error(`Search request failed: ${response.status}`);
|
|
30
|
+
}
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
// Build results from DuckDuckGo response
|
|
33
|
+
const results = [];
|
|
34
|
+
if (data.AbstractText) {
|
|
35
|
+
results.push(`**Summary:** ${data.AbstractText}`);
|
|
36
|
+
if (data.AbstractURL) {
|
|
37
|
+
results.push(`Source: ${data.AbstractURL}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (data.RelatedTopics && Array.isArray(data.RelatedTopics)) {
|
|
41
|
+
const topics = data.RelatedTopics
|
|
42
|
+
.filter((t) => t.Text && t.FirstURL)
|
|
43
|
+
.slice(0, count);
|
|
44
|
+
if (topics.length > 0) {
|
|
45
|
+
results.push(`\n**Related Results:**`);
|
|
46
|
+
for (const topic of topics) {
|
|
47
|
+
results.push(`- ${topic.Text}`);
|
|
48
|
+
results.push(` URL: ${topic.FirstURL}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (results.length === 0) {
|
|
53
|
+
return `No results found for: "${query}". Try a different search query.`;
|
|
54
|
+
}
|
|
55
|
+
return `Web search results for: "${query}"\n\n${results.join('\n')}`;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error.name === 'AbortError') {
|
|
59
|
+
throw new Error('Web search request timed out or was aborted');
|
|
60
|
+
}
|
|
61
|
+
// Fallback to basic search suggestion
|
|
62
|
+
return `Search query: "${query}"\n\nUnable to perform live search. Please try again or use a different query.`;
|
|
63
|
+
}
|
|
21
64
|
}
|
|
22
65
|
export function createWebSearchTool(options) {
|
|
23
66
|
const rateLimit = options?.rateLimitPerMinute ?? 60;
|
|
24
67
|
return {
|
|
25
68
|
name: "websearch",
|
|
26
69
|
label: "websearch",
|
|
27
|
-
description: "Search the web
|
|
70
|
+
description: "Search the web - performs real-time web searches and can scrape content from specific URLs. Provides up-to-date information for current events and recent data. Use this tool for accessing information beyond knowledge cutoff. The current year is 2026. You MUST use this year when searching for recent information or current events (e.g., search for 'AI news 2026', NOT 'AI news 2025').",
|
|
28
71
|
parameters: webSearchSchema,
|
|
29
72
|
execute: async (_toolCallId, { query, numResults }, signal) => {
|
|
30
73
|
// Check if already aborted
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websearch.js","sourceRoot":"","sources":["../../../src/agent/tools/websearch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;IACvD,UAAU,EAAE,IAAI,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