indusagi-coding-agent 0.1.25 → 0.1.27
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/CHANGELOG.md +87 -0
- package/dist/cli/file-processor.js +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +3 -3
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -3
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/task-session-manager.d.ts.map +1 -1
- package/dist/core/task-session-manager.js +1 -7
- package/dist/core/task-session-manager.js.map +1 -1
- package/dist/core/tools/bg-process.d.ts +1 -1
- package/dist/core/tools/index.d.ts +60 -59
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +89 -24
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/task.d.ts +21 -16
- package/dist/core/tools/task.d.ts.map +1 -1
- package/dist/core/tools/task.js +82 -43
- package/dist/core/tools/task.js.map +1 -1
- package/dist/core/tools/todo.d.ts +31 -20
- package/dist/core/tools/todo.d.ts.map +1 -1
- package/dist/core/tools/todo.js +67 -44
- package/dist/core/tools/todo.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -2
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/package.json +3 -3
- package/dist/core/todo-store.d.ts +0 -20
- package/dist/core/todo-store.d.ts.map +0 -1
- package/dist/core/todo-store.js +0 -55
- package/dist/core/todo-store.js.map +0 -1
- package/dist/core/tools/bash.d.ts +0 -428
- package/dist/core/tools/bash.d.ts.map +0 -1
- package/dist/core/tools/bash.js +0 -498
- package/dist/core/tools/bash.js.map +0 -1
- package/dist/core/tools/edit-diff.d.ts +0 -63
- package/dist/core/tools/edit-diff.d.ts.map +0 -1
- package/dist/core/tools/edit-diff.js +0 -243
- package/dist/core/tools/edit-diff.js.map +0 -1
- package/dist/core/tools/edit.d.ts +0 -315
- package/dist/core/tools/edit.d.ts.map +0 -1
- package/dist/core/tools/edit.js +0 -384
- package/dist/core/tools/edit.js.map +0 -1
- package/dist/core/tools/find.d.ts +0 -201
- package/dist/core/tools/find.d.ts.map +0 -1
- package/dist/core/tools/find.js +0 -342
- package/dist/core/tools/find.js.map +0 -1
- package/dist/core/tools/grep.d.ts +0 -323
- package/dist/core/tools/grep.d.ts.map +0 -1
- package/dist/core/tools/grep.js +0 -486
- package/dist/core/tools/grep.js.map +0 -1
- package/dist/core/tools/ls.d.ts +0 -44
- package/dist/core/tools/ls.d.ts.map +0 -1
- package/dist/core/tools/ls.js +0 -124
- package/dist/core/tools/ls.js.map +0 -1
- package/dist/core/tools/path-utils.d.ts +0 -8
- package/dist/core/tools/path-utils.d.ts.map +0 -1
- package/dist/core/tools/path-utils.js +0 -53
- package/dist/core/tools/path-utils.js.map +0 -1
- package/dist/core/tools/read.d.ts +0 -338
- package/dist/core/tools/read.d.ts.map +0 -1
- package/dist/core/tools/read.js +0 -397
- package/dist/core/tools/read.js.map +0 -1
- package/dist/core/tools/truncate.d.ts +0 -70
- package/dist/core/tools/truncate.d.ts.map +0 -1
- package/dist/core/tools/truncate.js +0 -205
- package/dist/core/tools/truncate.js.map +0 -1
- package/dist/core/tools/webfetch.d.ts +0 -174
- package/dist/core/tools/webfetch.d.ts.map +0 -1
- package/dist/core/tools/webfetch.js +0 -380
- package/dist/core/tools/webfetch.js.map +0 -1
- package/dist/core/tools/websearch.d.ts +0 -190
- package/dist/core/tools/websearch.d.ts.map +0 -1
- package/dist/core/tools/websearch.js +0 -267
- package/dist/core/tools/websearch.js.map +0 -1
- package/dist/core/tools/write.d.ts +0 -273
- package/dist/core/tools/write.d.ts.map +0 -1
- package/dist/core/tools/write.js +0 -288
- package/dist/core/tools/write.js.map +0 -1
package/dist/core/tools/index.js
CHANGED
|
@@ -1,28 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tools Module - Re-exports from indusagi package + local custom tools
|
|
3
|
+
*
|
|
4
|
+
* Most tools are now imported from the `indusagi` package to avoid duplication.
|
|
5
|
+
* Local tools kept for custom integrations:
|
|
6
|
+
* - todo.ts: Uses local TodoStore with session manager integration
|
|
7
|
+
* - task.ts: Has extensive dependencies on model registry, subagent store, etc.
|
|
8
|
+
* - bg-process.ts: Not available in indusagi
|
|
9
|
+
* - registry.ts: Custom tool metadata for this project
|
|
10
|
+
*/
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// RE-EXPORT FROM INDUSAGI PACKAGE
|
|
13
|
+
// ============================================================================
|
|
14
|
+
export {
|
|
15
|
+
// Read tool
|
|
16
|
+
createReadTool, readTool,
|
|
17
|
+
// Write tool
|
|
18
|
+
createWriteTool, writeTool,
|
|
19
|
+
// Edit tool
|
|
20
|
+
createEditTool, editTool,
|
|
21
|
+
// Bash tool
|
|
22
|
+
createBashTool, bashTool,
|
|
23
|
+
// Grep tool
|
|
24
|
+
createGrepTool, grepTool,
|
|
25
|
+
// Find tool
|
|
26
|
+
createFindTool, findTool,
|
|
27
|
+
// Ls tool
|
|
28
|
+
createLsTool, lsTool,
|
|
29
|
+
// WebFetch tool
|
|
30
|
+
createWebFetchTool, webFetchTool,
|
|
31
|
+
// WebSearch tool
|
|
32
|
+
createWebSearchTool, webSearchTool,
|
|
33
|
+
// Truncation utilities
|
|
34
|
+
DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail,
|
|
35
|
+
// Path utilities
|
|
36
|
+
expandPath, resolveReadPath, resolveToCwd,
|
|
37
|
+
// Edit diff utilities
|
|
38
|
+
computeEditDiff, generateDiffString,
|
|
39
|
+
// Tool registry from indusagi
|
|
40
|
+
ToolFactory, ToolRegistry as IndusagiToolRegistry, } from "indusagi/agent";
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// LOCAL CUSTOM TOOLS
|
|
43
|
+
// ============================================================================
|
|
44
|
+
export { createTodoReadTool, createTodoWriteTool, createSessionTodoStore, todoReadTool, todoWriteTool, TodoStore, } from "./todo.js";
|
|
9
45
|
export { createTaskTool, taskTool, } from "./task.js";
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import { bashTool,
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { createGrepTool,
|
|
19
|
-
import { createLsTool, lsTool } from "./ls.js";
|
|
20
|
-
import { createReadTool, readTool } from "./read.js";
|
|
46
|
+
export { createBgProcessTool } from "./bg-process.js";
|
|
47
|
+
import { TodoStore } from "./todo.js";
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// IMPORT TOOLS FOR DEFAULT EXPORTS
|
|
50
|
+
// ============================================================================
|
|
51
|
+
import { readTool, bashTool, editTool, writeTool } from "indusagi/agent";
|
|
52
|
+
import { grepTool, findTool, lsTool } from "indusagi/agent";
|
|
53
|
+
import { webFetchTool, webSearchTool } from "indusagi/agent";
|
|
54
|
+
import { createReadTool, createBashTool, createEditTool, createWriteTool, createGrepTool, createFindTool, createLsTool, createWebFetchTool, createWebSearchTool, } from "indusagi/agent";
|
|
21
55
|
import { createTodoReadTool, createTodoWriteTool, todoReadTool, todoWriteTool } from "./todo.js";
|
|
22
56
|
import { createTaskTool, taskTool } from "./task.js";
|
|
23
|
-
import { createWriteTool, writeTool } from "./write.js";
|
|
24
|
-
import { createWebFetchTool, webFetchTool } from "./webfetch.js";
|
|
25
|
-
import { createWebSearchTool, webSearchTool } from "./websearch.js";
|
|
26
57
|
// Default tools for full access mode (using process.cwd())
|
|
27
58
|
export const codingTools = [
|
|
28
59
|
readTool,
|
|
@@ -53,15 +84,20 @@ export const allTools = {
|
|
|
53
84
|
webfetch: webFetchTool,
|
|
54
85
|
websearch: webSearchTool,
|
|
55
86
|
};
|
|
87
|
+
// ============================================================================
|
|
88
|
+
// TOOL FACTORY FUNCTIONS
|
|
89
|
+
// ============================================================================
|
|
56
90
|
/**
|
|
57
91
|
* Create coding tools configured for a specific working directory.
|
|
92
|
+
* Note: hookRunner is not passed to indusagi's bash tool as they have incompatible interfaces.
|
|
93
|
+
* Shell environment hooks should be handled separately if needed.
|
|
58
94
|
*/
|
|
59
95
|
export function createCodingTools(cwd, options) {
|
|
60
96
|
const todoStore = options?.todoStore ?? new TodoStore();
|
|
61
97
|
const taskOptions = options?.task ? { ...options.task, cwd } : undefined;
|
|
62
98
|
return [
|
|
63
99
|
createReadTool(cwd, options?.read),
|
|
64
|
-
createBashTool(cwd,
|
|
100
|
+
createBashTool(cwd, options?.bash),
|
|
65
101
|
createEditTool(cwd),
|
|
66
102
|
createWriteTool(cwd),
|
|
67
103
|
createTaskTool(taskOptions),
|
|
@@ -87,13 +123,14 @@ export function createReadOnlyTools(cwd, options) {
|
|
|
87
123
|
/**
|
|
88
124
|
* Create all tools configured for a specific working directory.
|
|
89
125
|
* Extension tools are registered separately by the extension system.
|
|
126
|
+
* Note: hookRunner is not passed to indusagi's bash tool as they have incompatible interfaces.
|
|
90
127
|
*/
|
|
91
128
|
export function createAllTools(cwd, options) {
|
|
92
129
|
const todoStore = options?.todoStore ?? new TodoStore();
|
|
93
130
|
const taskOptions = options?.task ? { ...options.task, cwd } : undefined;
|
|
94
131
|
return {
|
|
95
132
|
read: createReadTool(cwd, options?.read),
|
|
96
|
-
bash: createBashTool(cwd,
|
|
133
|
+
bash: createBashTool(cwd, options?.bash),
|
|
97
134
|
edit: createEditTool(cwd),
|
|
98
135
|
write: createWriteTool(cwd),
|
|
99
136
|
grep: createGrepTool(cwd),
|
|
@@ -106,4 +143,32 @@ export function createAllTools(cwd, options) {
|
|
|
106
143
|
websearch: createWebSearchTool(),
|
|
107
144
|
};
|
|
108
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Built-in tools documentation
|
|
148
|
+
*
|
|
149
|
+
* CORE TOOLS (from indusagi package):
|
|
150
|
+
* - read: Read file contents (text files and images)
|
|
151
|
+
* - bash: Execute bash commands
|
|
152
|
+
* - edit: Make surgical edits to files
|
|
153
|
+
* - write: Create or overwrite files
|
|
154
|
+
* - grep: Search files with patterns
|
|
155
|
+
* - find: Find files by name or pattern
|
|
156
|
+
* - ls: List directory contents
|
|
157
|
+
* - webfetch: Fetch and transform content from URLs
|
|
158
|
+
* - websearch: Real-time web search using Exa AI API
|
|
159
|
+
*
|
|
160
|
+
* LOCAL TOOLS (custom integrations):
|
|
161
|
+
* - task: Delegate work to subagents (with model registry, subagent store integration)
|
|
162
|
+
* - todoread: Read todo list (with session manager integration)
|
|
163
|
+
* - todowrite: Update todo list (with session manager integration)
|
|
164
|
+
*
|
|
165
|
+
* EXTENSION TOOLS (via @indusagi/bg-process):
|
|
166
|
+
* - bg-process: Manage background processes
|
|
167
|
+
* - start: Run command in background
|
|
168
|
+
* - list: Show all managed processes
|
|
169
|
+
* - output: Get recent stdout/stderr
|
|
170
|
+
* - logs: Get log file paths
|
|
171
|
+
* - kill: Terminate a process
|
|
172
|
+
* - clear: Remove finished processes
|
|
173
|
+
*/
|
|
109
174
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAC/E,OAAO;AACN,YAAY;AACZ,cAAc,EACd,QAAQ;AAKR,aAAa;AACb,eAAe,EACf,SAAS;AAIT,YAAY;AACZ,cAAc,EACd,QAAQ;AAKR,YAAY;AACZ,cAAc,EACd,QAAQ;AAKR,YAAY;AACZ,cAAc,EACd,QAAQ;AAKR,YAAY;AACZ,cAAc,EACd,QAAQ;AAIR,UAAU;AACV,YAAY,EACZ,MAAM;AAKN,gBAAgB;AAChB,kBAAkB,EAClB,YAAY;AAIZ,iBAAiB;AACjB,mBAAmB,EACnB,aAAa;AAIb,uBAAuB;AACvB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY;AAEZ,iBAAiB;AACjB,UAAU,EACV,eAAe,EACf,YAAY;AAEZ,sBAAsB;AACtB,eAAe,EACf,kBAAkB;AAElB,8BAA8B;AAC9B,WAAW,EACX,YAAY,IAAI,oBAAoB,GAGpC,MAAM,gBAAgB,CAAC;AAYxB,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAC/E,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,SAAS,GAMT,MAAM,WAAW,CAAC;AAEnB,OAAO,EACN,cAAc,EACd,QAAQ,GAGR,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,mBAAmB,EAAoD,MAAM,iBAAiB,CAAC;AAOxG,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAKtC,+EAA+E;AAC/E,mCAAmC;AACnC,+EAA+E;AAC/E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAA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AAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC;QAC3B,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC;QACzB,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC;QACrB,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC;QACjC,QAAQ,EAAE,kBAAkB,CAAC,SAAS,CAAC;QACvC,SAAS,EAAE,mBAAmB,CAAC,SAAS,CAAC;QACzC,QAAQ,EAAE,kBAAkB,EAAE;QAC9B,SAAS,EAAE,mBAAmB,EAAE;KAChC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Tool - Uses indusagi's task tool with custom TaskSessionManager executor
|
|
3
|
+
*
|
|
4
|
+
* @module core/tools/task
|
|
5
|
+
* @description
|
|
6
|
+
* Wraps indusagi's createTaskTool with a custom TaskExecutor that uses
|
|
7
|
+
* TaskSessionManager for actual subagent execution.
|
|
8
|
+
*/
|
|
9
|
+
import { type TaskToolDetails } from "indusagi/agent";
|
|
1
10
|
import type { AgentTool } from "indusagi/agent";
|
|
2
11
|
import type { Model } from "indusagi/ai";
|
|
3
12
|
import type { ThinkingLevel } from "indusagi/agent";
|
|
@@ -5,15 +14,10 @@ import type { ModelRegistry } from "../model-registry.js";
|
|
|
5
14
|
import type { SettingsManager } from "../settings-manager.js";
|
|
6
15
|
import type { Skill } from "../skills.js";
|
|
7
16
|
import type { SubagentStore } from "../subagents.js";
|
|
8
|
-
import { type TaskToolDetails } from "../task-session-manager.js";
|
|
9
17
|
export type { TaskToolDetails };
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
subagent_type: import("@sinclair/typebox").TString;
|
|
14
|
-
task_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
15
|
-
command: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
16
|
-
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Task tool options - includes all dependencies for TaskSessionManager
|
|
20
|
+
*/
|
|
17
21
|
export interface TaskToolOptions {
|
|
18
22
|
cwd?: string;
|
|
19
23
|
settingsManager: SettingsManager;
|
|
@@ -27,12 +31,13 @@ export interface TaskToolOptions {
|
|
|
27
31
|
}>;
|
|
28
32
|
skills?: Skill[];
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Create task tool with custom executor using TaskSessionManager
|
|
36
|
+
*/
|
|
37
|
+
export declare function createTaskTool(options?: TaskToolOptions): AgentTool<any, TaskToolDetails>;
|
|
38
|
+
/**
|
|
39
|
+
* Default task tool - throws error if used without configuration
|
|
40
|
+
* This is intentionally not functional - must use createTaskTool with options
|
|
41
|
+
*/
|
|
42
|
+
export declare const taskTool: AgentTool<any, TaskToolDetails>;
|
|
38
43
|
//# sourceMappingURL=task.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA2B,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGN,KAAK,eAAe,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAA2B,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAsB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGzE,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,eAAe,CAAC;IACjC,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC9C,uBAAuB,EAAE,MAAM,aAAa,CAAC;IAC7C,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AA2ED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC,CAczF;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAAC,GAAG,EAAE,eAAe,CAQpD,CAAC"}
|
package/dist/core/tools/task.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Task Tool - Uses indusagi's task tool with custom TaskSessionManager executor
|
|
3
|
+
*
|
|
4
|
+
* @module core/tools/task
|
|
5
|
+
* @description
|
|
6
|
+
* Wraps indusagi's createTaskTool with a custom TaskExecutor that uses
|
|
7
|
+
* TaskSessionManager for actual subagent execution.
|
|
8
|
+
*/
|
|
9
|
+
import { createTaskTool as createIndusagiTaskTool, } from "indusagi/agent";
|
|
2
10
|
import { TaskSessionManager } from "../task-session-manager.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
subagent_type: Type.String({ description: "The type of specialized subagent to use for this task" }),
|
|
7
|
-
task_id: Type.Optional(Type.String({
|
|
8
|
-
description: "Only set to resume a previous task. The task will continue the same subagent session as before.",
|
|
9
|
-
})),
|
|
10
|
-
command: Type.Optional(Type.String({ description: "The command that triggered this task (optional)" })),
|
|
11
|
-
});
|
|
11
|
+
/**
|
|
12
|
+
* Build task description with available subagent types
|
|
13
|
+
*/
|
|
12
14
|
function buildTaskDescription(subagentStore) {
|
|
13
15
|
const header = "Launch a subagent to handle complex or multi-step work autonomously.";
|
|
14
|
-
const instructions = "
|
|
16
|
+
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.";
|
|
15
17
|
if (!subagentStore) {
|
|
16
|
-
return `${header}
|
|
18
|
+
return `${header}${instructions}`;
|
|
17
19
|
}
|
|
18
20
|
const subagents = subagentStore
|
|
19
21
|
.list()
|
|
@@ -21,45 +23,82 @@ function buildTaskDescription(subagentStore) {
|
|
|
21
23
|
.map((agent) => `- ${agent.name}${agent.description ? `: ${agent.description}` : ""}`)
|
|
22
24
|
.join("\n");
|
|
23
25
|
return subagents
|
|
24
|
-
? `${header}\n\nAvailable subagent types:\n${subagents}\n\
|
|
25
|
-
: `${header}
|
|
26
|
+
? `${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.`
|
|
27
|
+
: `${header}${instructions}`;
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
settingsManager: options.settingsManager,
|
|
32
|
-
modelRegistry: options.modelRegistry,
|
|
33
|
-
subagentStore: options.subagentStore,
|
|
34
|
-
getDefaultModel: options.getDefaultModel,
|
|
35
|
-
getDefaultThinkingLevel: options.getDefaultThinkingLevel,
|
|
36
|
-
contextFiles: options.contextFiles,
|
|
37
|
-
skills: options.skills,
|
|
38
|
-
})
|
|
39
|
-
: undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Create a task executor that uses TaskSessionManager
|
|
31
|
+
*/
|
|
32
|
+
function createTaskExecutor(options) {
|
|
40
33
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
async runTask(params) {
|
|
35
|
+
const manager = new TaskSessionManager({
|
|
36
|
+
cwd: options.cwd ?? process.cwd(),
|
|
37
|
+
settingsManager: options.settingsManager,
|
|
38
|
+
modelRegistry: options.modelRegistry,
|
|
39
|
+
subagentStore: options.subagentStore,
|
|
40
|
+
getDefaultModel: options.getDefaultModel,
|
|
41
|
+
getDefaultThinkingLevel: options.getDefaultThinkingLevel,
|
|
42
|
+
contextFiles: options.contextFiles,
|
|
43
|
+
skills: options.skills,
|
|
44
|
+
});
|
|
45
|
+
// Convert TaskUpdate callback to AgentToolUpdateCallback
|
|
46
|
+
const adaptedOnUpdate = params.onUpdate
|
|
47
|
+
? (partialResult) => {
|
|
48
|
+
// Extract text from content
|
|
49
|
+
const text = partialResult.content
|
|
50
|
+
.filter(c => c.type === "text" && c.text)
|
|
51
|
+
.map(c => c.text)
|
|
52
|
+
.join("");
|
|
53
|
+
params.onUpdate?.({
|
|
54
|
+
type: "chunk",
|
|
55
|
+
content: text,
|
|
56
|
+
details: partialResult.details,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
: undefined;
|
|
49
60
|
const result = await manager.runTask({
|
|
50
|
-
description,
|
|
51
|
-
prompt,
|
|
52
|
-
subagentType:
|
|
53
|
-
taskId:
|
|
54
|
-
signal,
|
|
55
|
-
onUpdate,
|
|
61
|
+
description: params.description,
|
|
62
|
+
prompt: params.prompt,
|
|
63
|
+
subagentType: params.subagentType,
|
|
64
|
+
taskId: params.taskId,
|
|
65
|
+
signal: params.signal,
|
|
66
|
+
onUpdate: adaptedOnUpdate, // Type cast to handle callback signature mismatch
|
|
56
67
|
});
|
|
57
68
|
return {
|
|
58
|
-
|
|
69
|
+
output: result.output,
|
|
59
70
|
details: result.details,
|
|
60
71
|
};
|
|
61
72
|
},
|
|
62
73
|
};
|
|
63
74
|
}
|
|
64
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Create task tool with custom executor using TaskSessionManager
|
|
77
|
+
*/
|
|
78
|
+
export function createTaskTool(options) {
|
|
79
|
+
if (!options) {
|
|
80
|
+
// Return a simple placeholder tool when no options provided
|
|
81
|
+
throw new Error("Task tool requires TaskToolOptions with settingsManager, modelRegistry, subagentStore, etc.");
|
|
82
|
+
}
|
|
83
|
+
const executor = createTaskExecutor(options);
|
|
84
|
+
return createIndusagiTaskTool({
|
|
85
|
+
cwd: options.cwd,
|
|
86
|
+
executor,
|
|
87
|
+
subagentStore: options.subagentStore, // Type cast to handle interface mismatch
|
|
88
|
+
buildDescription: (store) => buildTaskDescription(store),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Default task tool - throws error if used without configuration
|
|
93
|
+
* This is intentionally not functional - must use createTaskTool with options
|
|
94
|
+
*/
|
|
95
|
+
export const taskTool = {
|
|
96
|
+
name: "task",
|
|
97
|
+
label: "task",
|
|
98
|
+
description: "Launch a subagent to handle complex or multi-step work autonomously.",
|
|
99
|
+
parameters: {},
|
|
100
|
+
execute: async () => {
|
|
101
|
+
throw new Error("Task tool is not configured. Use createTaskTool() with TaskToolOptions.");
|
|
102
|
+
},
|
|
103
|
+
};
|
|
65
104
|
//# sourceMappingURL=task.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,cAAc,IAAI,sBAAsB,GAGxC,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAkBhE;;GAEG;AACH,SAAS,oBAAoB,CAAC,aAA6B;IAC1D,MAAM,MAAM,GAAG,sEAAsE,CAAC;IACtF,MAAM,YAAY,GACjB,mTAAmT,CAAC;IAErT,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,OAAO,GAAG,MAAM,GAAG,YAAY,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,SAAS,GAAG,aAAa;SAC7B,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,KAAyB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC;SACxF,GAAG,CAAC,CAAC,KAAyB,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SACzG,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO,SAAS;QACf,CAAC,CAAC,GAAG,MAAM,kCAAkC,SAAS,yIAAyI;QAC/L,CAAC,CAAC,GAAG,MAAM,GAAG,YAAY,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,OAAwB;IACnD,OAAO;QACN,KAAK,CAAC,OAAO,CAAC,MAAM;YACnB,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC;gBACtC,GAAG,EAAE,OAAO,CAAC,GAAG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AAO,EAAE,MAAM,CAAC,OAAO;aACvB,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAyB;IACvD,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,4DAA4D;QAC5D,MAAM,IAAI,KAAK,CAAC,6FAA6F,CAAC,CAAC;IAChH,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAE7C,OAAO,sBAAsB,CAAC;QAC7B,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,QAAQ;QACR,aAAa,EAAE,OAAO,CAAC,aAAoB,EAAE,yCAAyC;QACtF,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,KAAkC,CAAC;KACrF,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAoC;IACxD,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,sEAAsE;IACnF,UAAU,EAAE,EAAS;IACrB,OAAO,EAAE,KAAK,IAAI,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;IAC5F,CAAC;CACD,CAAC"}
|
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Todo Tools - Uses indusagi's todo tools with session persistence
|
|
3
|
+
*
|
|
4
|
+
* @module core/tools/todo
|
|
5
|
+
* @description
|
|
6
|
+
* Wraps indusagi's createTodoReadTool/createTodoWriteTool with a TodoStore
|
|
7
|
+
* that uses TodoStoreOptions for session persistence.
|
|
8
|
+
*/
|
|
9
|
+
import { createTodoReadTool as createIndusagiTodoReadTool, createTodoWriteTool as createIndusagiTodoWriteTool, TodoStore as IndusagiTodoStore, type TodoItem, type TodoPriority, type TodoStatus, type TodoToolDetails, type TodoStoreOptions } from "indusagi/agent";
|
|
10
|
+
import type { SessionManager } from "../session-manager.js";
|
|
11
|
+
/**
|
|
12
|
+
* Create a TodoStore with session persistence
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSessionTodoStore(sessionManager?: SessionManager): IndusagiTodoStore;
|
|
15
|
+
export type { TodoItem, TodoPriority, TodoStatus, TodoToolDetails, TodoStoreOptions };
|
|
16
|
+
export { IndusagiTodoStore as TodoStore };
|
|
17
|
+
/**
|
|
18
|
+
* Create todo read tool
|
|
19
|
+
*/
|
|
20
|
+
export declare function createTodoReadTool(store: IndusagiTodoStore): ReturnType<typeof createIndusagiTodoReadTool>;
|
|
21
|
+
/**
|
|
22
|
+
* Create todo write tool
|
|
23
|
+
*/
|
|
24
|
+
export declare function createTodoWriteTool(store: IndusagiTodoStore): ReturnType<typeof createIndusagiTodoWriteTool>;
|
|
25
|
+
/** Default todo read tool using in-memory store */
|
|
26
|
+
export declare const todoReadTool: import("indusagi/agent").AgentTool<import("@sinclair/typebox").TObject<{}>, TodoToolDetails>;
|
|
27
|
+
/** Default todo write tool using in-memory store */
|
|
28
|
+
export declare const todoWriteTool: import("indusagi/agent").AgentTool<import("@sinclair/typebox").TObject<{
|
|
5
29
|
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
6
30
|
content: import("@sinclair/typebox").TString;
|
|
7
|
-
status: import("@sinclair/typebox").TUnsafe<"
|
|
8
|
-
priority: import("@sinclair/typebox").TUnsafe<"low" | "medium" | "high">;
|
|
9
|
-
}>>;
|
|
10
|
-
}>;
|
|
11
|
-
export interface TodoToolDetails {
|
|
12
|
-
todos: TodoItem[];
|
|
13
|
-
incompleteCount: number;
|
|
14
|
-
}
|
|
15
|
-
export declare function createTodoReadTool(store: TodoStore): AgentTool<typeof TodoReadSchema, TodoToolDetails>;
|
|
16
|
-
export declare function createTodoWriteTool(store: TodoStore): AgentTool<typeof TodoWriteSchema, TodoToolDetails>;
|
|
17
|
-
export declare const todoReadTool: AgentTool<import("@sinclair/typebox").TObject<{}>, TodoToolDetails>;
|
|
18
|
-
export declare const todoWriteTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
19
|
-
todos: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
20
|
-
content: import("@sinclair/typebox").TString;
|
|
21
|
-
status: import("@sinclair/typebox").TUnsafe<"cancelled" | "pending" | "in_progress" | "completed">;
|
|
31
|
+
status: import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">;
|
|
22
32
|
priority: import("@sinclair/typebox").TUnsafe<"low" | "medium" | "high">;
|
|
23
33
|
}>>;
|
|
34
|
+
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
35
|
+
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<"in_progress" | "completed" | "cancelled" | "pending">>;
|
|
24
36
|
}>, TodoToolDetails>;
|
|
25
|
-
export {};
|
|
26
37
|
//# sourceMappingURL=todo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todo.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todo.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,kBAAkB,IAAI,0BAA0B,EAChD,mBAAmB,IAAI,2BAA2B,EAClD,SAAS,IAAI,iBAAiB,EAC9B,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAgCzF;AAGD,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAGtF,OAAO,EAAE,iBAAiB,IAAI,SAAS,EAAE,CAAC;AAE1C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAE1G;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAE5G;AAKD,mDAAmD;AACnD,eAAO,MAAM,YAAY,8FAAmC,CAAC;AAE7D,oDAAoD;AACpD,eAAO,MAAM,aAAa;;;;;;;;oBAAoC,CAAC"}
|
package/dist/core/tools/todo.js
CHANGED
|
@@ -1,52 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Todo Tools - Uses indusagi's todo tools with session persistence
|
|
3
|
+
*
|
|
4
|
+
* @module core/tools/todo
|
|
5
|
+
* @description
|
|
6
|
+
* Wraps indusagi's createTodoReadTool/createTodoWriteTool with a TodoStore
|
|
7
|
+
* that uses TodoStoreOptions for session persistence.
|
|
8
|
+
*/
|
|
9
|
+
import { createTodoReadTool as createIndusagiTodoReadTool, createTodoWriteTool as createIndusagiTodoWriteTool, TodoStore as IndusagiTodoStore, } from "indusagi/agent";
|
|
10
|
+
const TODO_CUSTOM_TYPE = "todo";
|
|
11
|
+
/**
|
|
12
|
+
* Create a TodoStore with session persistence
|
|
13
|
+
*/
|
|
14
|
+
export function createSessionTodoStore(sessionManager) {
|
|
15
|
+
return new IndusagiTodoStore({
|
|
16
|
+
persist: (todos) => {
|
|
17
|
+
sessionManager?.appendCustomEntry(TODO_CUSTOM_TYPE, { todos });
|
|
18
|
+
},
|
|
19
|
+
load: () => {
|
|
20
|
+
if (!sessionManager)
|
|
21
|
+
return [];
|
|
22
|
+
const entries = sessionManager.getBranch();
|
|
23
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
24
|
+
const entry = entries[i];
|
|
25
|
+
if (entry?.type !== "custom")
|
|
26
|
+
continue;
|
|
27
|
+
if (entry.customType !== TODO_CUSTOM_TYPE)
|
|
28
|
+
continue;
|
|
29
|
+
const data = entry.data;
|
|
30
|
+
if (!data || !Array.isArray(data.todos))
|
|
31
|
+
continue;
|
|
32
|
+
return data.todos;
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
},
|
|
36
|
+
rebuildFromBranch: () => {
|
|
37
|
+
if (!sessionManager)
|
|
38
|
+
return [];
|
|
39
|
+
const entries = sessionManager.getBranch();
|
|
40
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
41
|
+
const entry = entries[i];
|
|
42
|
+
if (entry?.type !== "custom")
|
|
43
|
+
continue;
|
|
44
|
+
if (entry.customType !== TODO_CUSTOM_TYPE)
|
|
45
|
+
continue;
|
|
46
|
+
const data = entry.data;
|
|
47
|
+
if (!data || !Array.isArray(data.todos))
|
|
48
|
+
continue;
|
|
49
|
+
return data.todos;
|
|
50
|
+
}
|
|
51
|
+
return [];
|
|
52
|
+
},
|
|
53
|
+
});
|
|
18
54
|
}
|
|
55
|
+
// Re-export TodoStore
|
|
56
|
+
export { IndusagiTodoStore as TodoStore };
|
|
57
|
+
/**
|
|
58
|
+
* Create todo read tool
|
|
59
|
+
*/
|
|
19
60
|
export function createTodoReadTool(store) {
|
|
20
|
-
return
|
|
21
|
-
name: "todoread",
|
|
22
|
-
label: "todoread",
|
|
23
|
-
description: "Read the current todo list. Returns items with content, status, and priority.",
|
|
24
|
-
parameters: TodoReadSchema,
|
|
25
|
-
execute: async () => {
|
|
26
|
-
const todos = store.getTodos();
|
|
27
|
-
return {
|
|
28
|
-
content: [{ type: "text", text: formatTodos(todos) }],
|
|
29
|
-
details: { todos, incompleteCount: countIncomplete(todos) },
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
};
|
|
61
|
+
return createIndusagiTodoReadTool(store);
|
|
33
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Create todo write tool
|
|
65
|
+
*/
|
|
34
66
|
export function createTodoWriteTool(store) {
|
|
35
|
-
return
|
|
36
|
-
name: "todowrite",
|
|
37
|
-
label: "todowrite",
|
|
38
|
-
description: "Update the todo list. Provide the full list each time with content, status, and priority fields.",
|
|
39
|
-
parameters: TodoWriteSchema,
|
|
40
|
-
execute: async (_toolCallId, { todos }) => {
|
|
41
|
-
store.setTodos(todos);
|
|
42
|
-
return {
|
|
43
|
-
content: [{ type: "text", text: formatTodos(todos) }],
|
|
44
|
-
details: { todos: store.getTodos(), incompleteCount: countIncomplete(todos) },
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
};
|
|
67
|
+
return createIndusagiTodoWriteTool(store);
|
|
48
68
|
}
|
|
49
|
-
|
|
69
|
+
// Default store for simple mode (no session persistence)
|
|
70
|
+
const defaultStore = new IndusagiTodoStore();
|
|
71
|
+
/** Default todo read tool using in-memory store */
|
|
50
72
|
export const todoReadTool = createTodoReadTool(defaultStore);
|
|
73
|
+
/** Default todo write tool using in-memory store */
|
|
51
74
|
export const todoWriteTool = createTodoWriteTool(defaultStore);
|
|
52
75
|
//# sourceMappingURL=todo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../../../src/core/tools/todo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../../../src/core/tools/todo.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,kBAAkB,IAAI,0BAA0B,EAChD,mBAAmB,IAAI,2BAA2B,EAClD,SAAS,IAAI,iBAAiB,GA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