indusagi 0.12.9 → 0.12.12

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.
Files changed (38) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/index.d.ts +2 -0
  3. package/dist/agent/index.d.ts.map +1 -1
  4. package/dist/agent/index.js +3 -0
  5. package/dist/agent/index.js.map +1 -1
  6. package/dist/agent/messages.d.ts +77 -0
  7. package/dist/agent/messages.d.ts.map +1 -0
  8. package/dist/agent/messages.js +116 -0
  9. package/dist/agent/messages.js.map +1 -0
  10. package/dist/agent/session-manager.d.ts +448 -0
  11. package/dist/agent/session-manager.d.ts.map +1 -0
  12. package/dist/agent/session-manager.js +1228 -0
  13. package/dist/agent/session-manager.js.map +1 -0
  14. package/dist/agent/tools/index.d.ts +32 -29
  15. package/dist/agent/tools/index.d.ts.map +1 -1
  16. package/dist/agent/tools/index.js +1 -1
  17. package/dist/agent/tools/index.js.map +1 -1
  18. package/dist/agent/tools/task-types.d.ts +74 -0
  19. package/dist/agent/tools/task-types.d.ts.map +1 -0
  20. package/dist/agent/tools/task-types.js +8 -0
  21. package/dist/agent/tools/task-types.js.map +1 -0
  22. package/dist/agent/tools/task.d.ts +66 -8
  23. package/dist/agent/tools/task.d.ts.map +1 -1
  24. package/dist/agent/tools/task.js +165 -17
  25. package/dist/agent/tools/task.js.map +1 -1
  26. package/dist/agent/tools/todo-store.d.ts +65 -12
  27. package/dist/agent/tools/todo-store.d.ts.map +1 -1
  28. package/dist/agent/tools/todo-store.js +115 -15
  29. package/dist/agent/tools/todo-store.js.map +1 -1
  30. package/dist/agent/tools/todo-types.d.ts +73 -0
  31. package/dist/agent/tools/todo-types.d.ts.map +1 -0
  32. package/dist/agent/tools/todo-types.js +8 -0
  33. package/dist/agent/tools/todo-types.js.map +1 -0
  34. package/dist/agent/tools/todo.d.ts +53 -6
  35. package/dist/agent/tools/todo.d.ts.map +1 -1
  36. package/dist/agent/tools/todo.js +62 -2
  37. package/dist/agent/tools/todo.js.map +1 -1
  38. package/package.json +1 -1
@@ -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 in the same subagent session as before.",
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: "Launch a subagent to handle complex or multi-step work autonomously. When using this tool, provide a clear description, a detailed prompt, and subagent_type. Use task_id to resume a previous task.",
117
+ description: descriptionBuilder(subagentStore),
16
118
  parameters: taskSchema,
17
- execute: async (_toolCallId, { description, prompt, subagent_type, task_id }) => {
18
- const id = task_id ?? `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
19
- const existing = taskSessions.get(id);
20
- const session = {
21
- description: description || existing?.description || "",
22
- prompt: prompt || existing?.prompt || "",
23
- subagentType: subagent_type || existing?.subagentType || "general",
24
- status: "completed",
25
- };
26
- taskSessions.set(id, session);
27
- const output = `Task(${id}): ${session.description}\n${session.prompt}\nStatus: ${session.status}`;
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: { description: session.description, prompt: session.prompt, subagentType: session.subagentType, taskId: id },
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":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IACpF,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IACxE,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,uDAAuD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AAO,CAAC,MAAM,IAAI,EAAE;gCACnC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,oBAAoB;gCAC3D,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,IAAI,qBAAqB;gCAC9D,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK;6BAC3B;yBACD,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC;gBACF,CAAC,CAAC,SAAS,CAAC;YAEb,mBAAmB;YACnB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC;gBACrC,WAAW;gBACX,MAAM;gBACN,YAAY,EAAE,aAAa;gBAC3B,MAAM,EAAE,OAAO;gBACf,MAAM;gBACN,QAAQ,EAAE,kBAAkB;aAC5B,CAAC,CAAC;YAEH,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;gBAChD,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
- * Simplified version for indusagi agent framework.
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
- constructor(initialTodos?: TodoItem[]);
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;;;GAGG;AAEH,eAAO,MAAM,aAAa,+DAAgE,CAAC;AAC3F,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,eAAe,oCAAqC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,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;AAMD,qBAAa,SAAS;IACrB,OAAO,CAAC,KAAK,CAAkB;gBAEnB,YAAY,CAAC,EAAE,QAAQ,EAAE;IAMrC,QAAQ,IAAI,QAAQ,EAAE;IAKtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI;IAKjC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE;IAK/B,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,EAAE;IAI9C,OAAO,CAAC,aAAa;CAGrB"}
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
- * Simplified version for indusagi agent framework.
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(initialTodos) {
39
+ constructor(initialTodosOrOptions, options) {
12
40
  this.todos = [];
13
- if (initialTodos) {
14
- this.todos = cloneTodos(initialTodos);
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.removeExpired();
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 q = query.toLowerCase();
27
- return this.getTodos().filter((t) => t.content.toLowerCase().includes(q));
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.getTodos().filter((t) => t.status === status);
91
+ return this.todos.filter((todo) => todo.status === status);
31
92
  }
32
- removeExpired(now = Date.now()) {
33
- this.todos = this.todos.filter((t) => t.expiresAt === undefined || t.expiresAt > now);
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;;;GAGG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC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AC;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, type TodoItem } from "./todo-store.js";
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
- export interface TodoToolDetails {
14
- todos: TodoItem[];
15
- incompleteCount: number;
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