openvibe 0.63.1 → 0.63.3
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 +92 -2
- package/README.md +39 -0
- package/README_CN.md +1 -1
- package/dist/cli/args.d.ts +3 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +22 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +5 -3
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/companion/executor/bash-executor.d.ts +30 -0
- package/dist/core/companion/executor/bash-executor.d.ts.map +1 -0
- package/dist/core/companion/executor/bash-executor.js +105 -0
- package/dist/core/companion/executor/bash-executor.js.map +1 -0
- package/dist/core/companion/executor/code-executor.d.ts +33 -0
- package/dist/core/companion/executor/code-executor.d.ts.map +1 -0
- package/dist/core/companion/executor/code-executor.js +144 -0
- package/dist/core/companion/executor/code-executor.js.map +1 -0
- package/dist/core/companion/executor/resource-monitor.d.ts +55 -0
- package/dist/core/companion/executor/resource-monitor.d.ts.map +1 -0
- package/dist/core/companion/executor/resource-monitor.js +141 -0
- package/dist/core/companion/executor/resource-monitor.js.map +1 -0
- package/dist/core/companion/http-server.d.ts +92 -0
- package/dist/core/companion/http-server.d.ts.map +1 -0
- package/dist/core/companion/http-server.js +229 -0
- package/dist/core/companion/http-server.js.map +1 -0
- package/dist/core/companion/index.d.ts +29 -0
- package/dist/core/companion/index.d.ts.map +1 -0
- package/dist/core/companion/index.js +48 -0
- package/dist/core/companion/index.js.map +1 -0
- package/dist/core/companion/scheduler/resource-scheduler.d.ts +82 -0
- package/dist/core/companion/scheduler/resource-scheduler.d.ts.map +1 -0
- package/dist/core/companion/scheduler/resource-scheduler.js +333 -0
- package/dist/core/companion/scheduler/resource-scheduler.js.map +1 -0
- package/dist/core/companion/scheduler/workers/base-worker.d.ts +87 -0
- package/dist/core/companion/scheduler/workers/base-worker.d.ts.map +1 -0
- package/dist/core/companion/scheduler/workers/base-worker.js +70 -0
- package/dist/core/companion/scheduler/workers/base-worker.js.map +1 -0
- package/dist/core/companion/scheduler/workers/cpu-worker.d.ts +12 -0
- package/dist/core/companion/scheduler/workers/cpu-worker.d.ts.map +1 -0
- package/dist/core/companion/scheduler/workers/cpu-worker.js +134 -0
- package/dist/core/companion/scheduler/workers/cpu-worker.js.map +1 -0
- package/dist/core/companion/scheduler/workers/gpu-worker.d.ts +16 -0
- package/dist/core/companion/scheduler/workers/gpu-worker.d.ts.map +1 -0
- package/dist/core/companion/scheduler/workers/gpu-worker.js +167 -0
- package/dist/core/companion/scheduler/workers/gpu-worker.js.map +1 -0
- package/dist/core/companion/scheduler/workers/index.d.ts +6 -0
- package/dist/core/companion/scheduler/workers/index.d.ts.map +1 -0
- package/dist/core/companion/scheduler/workers/index.js +6 -0
- package/dist/core/companion/scheduler/workers/index.js.map +1 -0
- package/dist/core/companion/scheduler/workers/io-worker.d.ts +17 -0
- package/dist/core/companion/scheduler/workers/io-worker.d.ts.map +1 -0
- package/dist/core/companion/scheduler/workers/io-worker.js +197 -0
- package/dist/core/companion/scheduler/workers/io-worker.js.map +1 -0
- package/dist/core/companion/scheduler/workers/network-worker.d.ts +13 -0
- package/dist/core/companion/scheduler/workers/network-worker.d.ts.map +1 -0
- package/dist/core/companion/scheduler/workers/network-worker.js +167 -0
- package/dist/core/companion/scheduler/workers/network-worker.js.map +1 -0
- package/dist/core/companion/security/security-manager.d.ts +50 -0
- package/dist/core/companion/security/security-manager.d.ts.map +1 -0
- package/dist/core/companion/security/security-manager.js +102 -0
- package/dist/core/companion/security/security-manager.js.map +1 -0
- package/dist/core/hybrid-cloud/extension.d.ts +8 -0
- package/dist/core/hybrid-cloud/extension.d.ts.map +1 -0
- package/dist/core/hybrid-cloud/extension.js +64 -0
- package/dist/core/hybrid-cloud/extension.js.map +1 -0
- package/dist/core/hybrid-cloud/index.d.ts +98 -0
- package/dist/core/hybrid-cloud/index.d.ts.map +1 -0
- package/dist/core/hybrid-cloud/index.js +211 -0
- package/dist/core/hybrid-cloud/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +6 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +13 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +35 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +7 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +46 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/todo-manager.d.ts +32 -0
- package/dist/core/todo-manager.d.ts.map +1 -0
- package/dist/core/todo-manager.js +117 -0
- package/dist/core/todo-manager.js.map +1 -0
- package/dist/core/tools/batch-write.d.ts +42 -0
- package/dist/core/tools/batch-write.d.ts.map +1 -0
- package/dist/core/tools/batch-write.js +267 -0
- package/dist/core/tools/batch-write.js.map +1 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +10 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/fast-executor.d.ts +6 -1
- package/dist/core/tools/fast-executor.d.ts.map +1 -1
- package/dist/core/tools/fast-executor.js +83 -4
- package/dist/core/tools/fast-executor.js.map +1 -1
- package/dist/core/tools/index.d.ts +141 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +30 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/todo.d.ts +47 -0
- package/dist/core/tools/todo.d.ts.map +1 -0
- package/dist/core/tools/todo.js +212 -0
- package/dist/core/tools/todo.js.map +1 -0
- package/dist/core/tools/unified.d.ts +121 -0
- package/dist/core/tools/unified.d.ts.map +1 -0
- package/dist/core/tools/unified.js +481 -0
- package/dist/core/tools/unified.js.map +1 -0
- package/dist/core/tools/write.d.ts +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +20 -5
- package/dist/core/tools/write.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +63 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +2 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +2 -0
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/todo-display.d.ts +9 -0
- package/dist/modes/interactive/components/todo-display.d.ts.map +1 -0
- package/dist/modes/interactive/components/todo-display.js +60 -0
- package/dist/modes/interactive/components/todo-display.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +8 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +151 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/plan-mode.d.ts +14 -0
- package/dist/modes/plan-mode.d.ts.map +1 -0
- package/dist/modes/plan-mode.js +107 -0
- package/dist/modes/plan-mode.js.map +1 -0
- package/dist/modes/spec-mode.d.ts +16 -0
- package/dist/modes/spec-mode.d.ts.map +1 -0
- package/dist/modes/spec-mode.js +186 -0
- package/dist/modes/spec-mode.js.map +1 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +7 -17
- package/dist/utils/version-check.js.map +1 -1
- package/docs/HYBRID_CLOUD_README.md +188 -0
- package/docs/hybrid-architecture-design.md +317 -0
- package/docs/todo.md +71 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-executor.js","sourceRoot":"","sources":["../../../src/core/tools/fast-executor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAoBxE,MAAM,UAAU,gBAAgB,CAC/B,KAAmC,EACnC,gBAAkC,EACjB;IACjB,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IAChF,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7B,EAAE,EAAE,EAAE,CAAC,EAAE;QACT,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,IAAI,EAAE,EAAE,CAAC,SAAS;QAClB,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC;KAC5C,CAAC,CAAC,CAAC;AAAA,CACJ;AACD,KAAK,UAAU,iBAAiB,CAC/B,QAAsB,EACtB,MAAoB,EACpB,QAAwD,EACzB;IAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,CAAC;QACJ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,IAAI,YAAY,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAA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AAM,UAAU,iBAAiB,GAA6E;IAC7G,OAAO,aAAa,CAAC,WAAW,EAAE,CAAC;AAAA,CACnC;AACD,MAAM,UAAU,mBAAmB,GAAS;IAC3C,aAAa,CAAC,KAAK,EAAE,CAAC;AAAA,CACtB","sourcesContent":["import type { AgentTool, AgentToolResult } from \"@boxiaolanya2008/pi-agent-core\";\nimport type { AssistantMessage, ToolResultMessage } from \"@boxiaolanya2008/pi-ai\";\nimport { globalMetrics, parallelExecute } from \"./parallel-executor.js\";\n\ninterface ToolCallInfo {\n\tid: string;\n\tname: string;\n\targs: Record<string, unknown>;\n\ttool: AgentTool<any> | undefined;\n}\ninterface ToolExecutionResult {\n\ttoolCallId: string;\n\ttoolName: string;\n\tresult: AgentToolResult<any>;\n\tisError: boolean;\n\tduration: number;\n}\ninterface ExecuteToolsOptions {\n\tparallel?: boolean;\n\tmaxConcurrency?: number;\n\tpriority?: number;\n}\nexport function extractToolCalls(\n\ttools: AgentTool<any>[] | undefined,\n\tassistantMessage: AssistantMessage,\n): ToolCallInfo[] {\n\tconst toolCalls = assistantMessage.content.filter((c) => c.type === \"toolCall\");\n\treturn toolCalls.map((tc) => ({\n\t\tid: tc.id,\n\t\tname: tc.name,\n\t\targs: tc.arguments,\n\t\ttool: tools?.find((t) => t.name === tc.name),\n\t}));\n}\nasync function executeSingleTool(\n\ttoolCall: ToolCallInfo,\n\tsignal?: AbortSignal,\n\tonUpdate?: (partialResult: AgentToolResult<any>) => void,\n): Promise<ToolExecutionResult> {\n\tconst startTime = Date.now();\n\ttry {\n\t\tif (!toolCall.tool) {\n\t\t\tthrow new Error(`Tool ${toolCall.name} not found`);\n\t\t}\n\t\tconst result = await toolCall.tool.execute(toolCall.id, toolCall.args, signal, onUpdate);\n\t\tconst duration = Date.now() - startTime;\n\t\tglobalMetrics.record(`tool:${toolCall.name}`, duration);\n\t\treturn {\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\tresult,\n\t\t\tisError: false,\n\t\t\tduration,\n\t\t};\n\t} catch (error) {\n\t\tconst duration = Date.now() - startTime;\n\t\tglobalMetrics.record(`tool:${toolCall.name}:error`, duration);\n\t\treturn {\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\tresult: {\n\t\t\t\tcontent: [{ type: \"text\", text: error instanceof Error ? error.message : String(error) }],\n\t\t\t\tdetails: {},\n\t\t\t},\n\t\t\tisError: true,\n\t\t\tduration,\n\t\t};\n\t}\n}\nexport async function executeToolsParallel(\n\ttools: AgentTool<any>[] | undefined,\n\tassistantMessage: AssistantMessage,\n\tsignal?: AbortSignal,\n\tonProgress?: (result: ToolExecutionResult) => void,\n\toptions: ExecuteToolsOptions = {},\n): Promise<ToolResultMessage[]> {\n\tconst { parallel = true, maxConcurrency = 8 } = options;\n\tconst toolCalls = extractToolCalls(tools, assistantMessage);\n\tif (toolCalls.length === 0) {\n\t\treturn [];\n\t}\n\tif (toolCalls.length === 1 || !parallel) {\n\t\tconst result = await executeSingleTool(toolCalls[0], signal);\n\t\tonProgress?.(result);\n\t\treturn [toToolResultMessage(result)];\n\t}\n\tconst results = await parallelExecute(toolCalls, (tc) => executeSingleTool(tc, signal), {\n\t\tconcurrency: maxConcurrency,\n\t});\n\tfor (const result of results) onProgress?.(result);\n\treturn results.map(toToolResultMessage);\n}\nfunction toToolResultMessage(result: ToolExecutionResult): ToolResultMessage {\n\treturn {\n\t\trole: \"toolResult\",\n\t\ttoolCallId: result.toolCallId,\n\t\ttoolName: result.toolName,\n\t\tcontent: result.result.content,\n\t\tdetails: result.result.details,\n\t\tisError: result.isError,\n\t\ttimestamp: Date.now(),\n\t};\n}\nexport function canParallelize(tools: ToolCallInfo[]): boolean {\n\treturn tools.length > 1;\n}\nexport function groupToolsByDependency(tools: ToolCallInfo[]): ToolCallInfo[][] {\n\treturn [tools];\n}\nexport function getExecutionStats(): Record<string, { avg: number; min: number; max: number; count: number }> {\n\treturn globalMetrics.getAllStats();\n}\nexport function resetExecutionStats(): void {\n\tglobalMetrics.reset();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fast-executor.js","sourceRoot":"","sources":["../../../src/core/tools/fast-executor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AA2BxE,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;AAExE,SAAS,eAAe,CAAC,EAAgB,EAAW;IACnD,OAAO,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAAA,CAC1C;AAED,SAAS,oBAAoB,CAAC,EAAgB,EAA4C;IACzF,MAAM,IAAI,GAAG,EAAE,CAAC,IAA+B,CAAC;IAChD,MAAM,IAAI,GAAI,IAAI,CAAC,IAAe,IAAK,IAAI,CAAC,SAAoB,IAAK,IAAI,CAAC,QAAmB,CAAC;IAC9F,MAAM,OAAO,GAAI,IAAI,CAAC,OAAkB,IAAK,IAAI,CAAC,OAAkB,CAAC;IAErE,IAAI,CAAC,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAA,CACzB;AAED,SAAS,iBAAiB,CAAC,SAAyB,EAAE,KAAmC,EAAkB;IAC1G,IAAI,SAAS,CAAC,MAAM,GAAG,qBAAqB,EAAE,CAAC;QAC9C,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,UAAU,GAAmB,EAAE,CAAC;IACtC,MAAM,UAAU,GAAmB,EAAE,CAAC;IAEtC,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC5B,IAAI,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;YACzB,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACr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CAAC,KAAqB,EAAW;IAC9D,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAAA,CACxB;AACD,MAAM,UAAU,sBAAsB,CAAC,KAAqB,EAAoB;IAC/E,OAAO,CAAC,KAAK,CAAC,CAAC;AAAA,CACf;AACD,MAAM,UAAU,iBAAiB,GAA6E;IAC7G,OAAO,aAAa,CAAC,WAAW,EAAE,CAAC;AAAA,CACnC;AACD,MAAM,UAAU,mBAAmB,GAAS;IAC3C,aAAa,CAAC,KAAK,EAAE,CAAC;AAAA,CACtB","sourcesContent":["import type { AgentTool, AgentToolResult } from \"@boxiaolanya2008/pi-agent-core\";\nimport type { AssistantMessage, ToolResultMessage } from \"@boxiaolanya2008/pi-ai\";\nimport { globalMetrics, parallelExecute } from \"./parallel-executor.js\";\n\ninterface ToolCallInfo {\n\tid: string;\n\tname: string;\n\targs: Record<string, unknown>;\n\ttool: AgentTool<any> | undefined;\n}\ninterface ToolExecutionResult {\n\ttoolCallId: string;\n\ttoolName: string;\n\tresult: AgentToolResult<any>;\n\tisError: boolean;\n\tduration: number;\n}\ninterface ExecuteToolsOptions {\n\tparallel?: boolean;\n\tmaxConcurrency?: number;\n\tpriority?: number;\n}\n\nexport interface ToolUpdateEvent {\n\ttoolCallId: string;\n\ttoolName: string;\n\tpartialResult: AgentToolResult<any>;\n}\n\nconst BATCH_WRITE_THRESHOLD = 2;\nconst WRITE_TOOL_NAMES = [\"write\", \"write_file\", \"create_file\", \"edit\"];\n\nfunction isWriteToolCall(tc: ToolCallInfo): boolean {\n\treturn WRITE_TOOL_NAMES.includes(tc.name);\n}\n\nfunction extractWriteFileData(tc: ToolCallInfo): { path: string; content: string } | null {\n\tconst args = tc.args as Record<string, unknown>;\n\tconst path = (args.path as string) || (args.file_path as string) || (args.filePath as string);\n\tconst content = (args.content as string) || (args.newText as string);\n\n\tif (!path || content === undefined) {\n\t\treturn null;\n\t}\n\n\treturn { path, content };\n}\n\nfunction optimizeToolCalls(toolCalls: ToolCallInfo[], tools: AgentTool<any>[] | undefined): ToolCallInfo[] {\n\tif (toolCalls.length < BATCH_WRITE_THRESHOLD) {\n\t\treturn toolCalls;\n\t}\n\n\tconst writeCalls: ToolCallInfo[] = [];\n\tconst otherCalls: ToolCallInfo[] = [];\n\n\tfor (const tc of toolCalls) {\n\t\tif (isWriteToolCall(tc)) {\n\t\t\twriteCalls.push(tc);\n\t\t} else {\n\t\t\totherCalls.push(tc);\n\t\t}\n\t}\n\n\tif (writeCalls.length < BATCH_WRITE_THRESHOLD) {\n\t\treturn toolCalls;\n\t}\n\n\tconst files: Array<{ path: string; content: string }> = [];\n\tconst writeCallIds: string[] = [];\n\n\tfor (const tc of writeCalls) {\n\t\tconst fileData = extractWriteFileData(tc);\n\t\tif (fileData) {\n\t\t\tfiles.push(fileData);\n\t\t\twriteCallIds.push(tc.id);\n\t\t} else {\n\t\t\totherCalls.push(tc);\n\t\t}\n\t}\n\n\tif (files.length < BATCH_WRITE_THRESHOLD) {\n\t\treturn toolCalls;\n\t}\n\n\tconst batchWriteTool = tools?.find((t) => t.name === \"batch_write\");\n\tif (!batchWriteTool) {\n\t\treturn toolCalls;\n\t}\n\n\tconst batchCall: ToolCallInfo = {\n\t\tid: `batch_${writeCallIds.join(\"_\")}`,\n\t\tname: \"batch_write\",\n\t\targs: {\n\t\t\toperation: \"batch_write\",\n\t\t\tfiles,\n\t\t\toptions: {\n\t\t\t\tatomic: true,\n\t\t\t\tbackup: true,\n\t\t\t\toverwrite: true,\n\t\t\t\tcreateDirs: true,\n\t\t\t},\n\t\t},\n\t\ttool: batchWriteTool,\n\t};\n\n\treturn [batchCall, ...otherCalls];\n}\n\nexport function extractToolCalls(\n\ttools: AgentTool<any>[] | undefined,\n\tassistantMessage: AssistantMessage,\n): ToolCallInfo[] {\n\tconst toolCalls = assistantMessage.content.filter((c) => c.type === \"toolCall\");\n\tconst rawCalls = toolCalls.map((tc) => ({\n\t\tid: tc.id,\n\t\tname: tc.name,\n\t\targs: tc.arguments,\n\t\ttool: tools?.find((t) => t.name === tc.name),\n\t}));\n\n\treturn optimizeToolCalls(rawCalls, tools);\n}\nasync function executeSingleTool(\n\ttoolCall: ToolCallInfo,\n\tsignal?: AbortSignal,\n\tonUpdate?: (partialResult: AgentToolResult<any>) => void,\n): Promise<ToolExecutionResult> {\n\tconst startTime = Date.now();\n\ttry {\n\t\tif (!toolCall.tool) {\n\t\t\tthrow new Error(`Tool ${toolCall.name} not found`);\n\t\t}\n\t\tconst result = await toolCall.tool.execute(toolCall.id, toolCall.args, signal, onUpdate);\n\t\tconst duration = Date.now() - startTime;\n\t\tglobalMetrics.record(`tool:${toolCall.name}`, duration);\n\t\treturn {\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\tresult,\n\t\t\tisError: false,\n\t\t\tduration,\n\t\t};\n\t} catch (error) {\n\t\tconst duration = Date.now() - startTime;\n\t\tglobalMetrics.record(`tool:${toolCall.name}:error`, duration);\n\t\treturn {\n\t\t\ttoolCallId: toolCall.id,\n\t\t\ttoolName: toolCall.name,\n\t\t\tresult: {\n\t\t\t\tcontent: [{ type: \"text\", text: error instanceof Error ? error.message : String(error) }],\n\t\t\t\tdetails: {},\n\t\t\t},\n\t\t\tisError: true,\n\t\t\tduration,\n\t\t};\n\t}\n}\nexport async function executeToolsParallel(\n\ttools: AgentTool<any>[] | undefined,\n\tassistantMessage: AssistantMessage,\n\tsignal?: AbortSignal,\n\tonProgress?: (result: ToolExecutionResult) => void,\n\toptions: ExecuteToolsOptions = {},\n\tonToolUpdate?: (event: ToolUpdateEvent) => void,\n): Promise<ToolResultMessage[]> {\n\tconst { parallel = true, maxConcurrency = 8 } = options;\n\tconst toolCalls = extractToolCalls(tools, assistantMessage);\n\tif (toolCalls.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst createOnUpdate = (toolCall: ToolCallInfo) => {\n\t\tif (!onToolUpdate) return undefined;\n\t\treturn (partialResult: AgentToolResult<any>) => {\n\t\t\tonToolUpdate({\n\t\t\t\ttoolCallId: toolCall.id,\n\t\t\t\ttoolName: toolCall.name,\n\t\t\t\tpartialResult,\n\t\t\t});\n\t\t};\n\t};\n\n\tif (toolCalls.length === 1 || !parallel) {\n\t\tconst result = await executeSingleTool(toolCalls[0], signal, createOnUpdate(toolCalls[0]));\n\t\tonProgress?.(result);\n\t\treturn [toToolResultMessage(result)];\n\t}\n\tconst results = await parallelExecute(toolCalls, (tc) => executeSingleTool(tc, signal, createOnUpdate(tc)), {\n\t\tconcurrency: maxConcurrency,\n\t});\n\tfor (const result of results) onProgress?.(result);\n\treturn results.map(toToolResultMessage);\n}\nfunction toToolResultMessage(result: ToolExecutionResult): ToolResultMessage {\n\treturn {\n\t\trole: \"toolResult\",\n\t\ttoolCallId: result.toolCallId,\n\t\ttoolName: result.toolName,\n\t\tcontent: result.result.content,\n\t\tdetails: result.result.details,\n\t\tisError: result.isError,\n\t\ttimestamp: Date.now(),\n\t};\n}\nexport function canParallelize(tools: ToolCallInfo[]): boolean {\n\treturn tools.length > 1;\n}\nexport function groupToolsByDependency(tools: ToolCallInfo[]): ToolCallInfo[][] {\n\treturn [tools];\n}\nexport function getExecutionStats(): Record<string, { avg: number; min: number; max: number; count: number }> {\n\treturn globalMetrics.getAllStats();\n}\nexport function resetExecutionStats(): void {\n\tglobalMetrics.reset();\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, bashTool, createBashTool, } from "./bash.js";
|
|
2
|
+
export { type BatchWriteFileResult, type BatchWriteInput, type BatchWriteResult, batchWriteTool, detectBatchWriteIntent, } from "./batch-write.js";
|
|
2
3
|
export { createEditTool, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, editTool, } from "./edit.js";
|
|
4
|
+
export type { ToolUpdateEvent } from "./fast-executor.js";
|
|
3
5
|
export { canParallelize, executeToolsParallel, extractToolCalls, getExecutionStats, resetExecutionStats, } from "./fast-executor.js";
|
|
4
6
|
export { createFindTool, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, findTool, } from "./find.js";
|
|
5
7
|
export { createGrepTool, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, grepTool, } from "./grep.js";
|
|
@@ -7,7 +9,9 @@ export { type AcceleratorConfig, acceleratedReadFile, acceleratedWriteFile, clea
|
|
|
7
9
|
export { createLsTool, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, lsTool, } from "./ls.js";
|
|
8
10
|
export { BatchProcessor, globalCache, globalMetrics, MemoryMappedCache, PerformanceMetrics, parallelExecute, } from "./parallel-executor.js";
|
|
9
11
|
export { createReadTool, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, readTool, } from "./read.js";
|
|
12
|
+
export { todoAddTool, todoCompleteTool, todoListTool, todoRemoveTool, todoSearchTool, todoTools, todoUncompleteTool, } from "./todo.js";
|
|
10
13
|
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, } from "./truncate.js";
|
|
14
|
+
export { createUnifiedTool, type UnifiedInput, type UnifiedResult, UnifiedSchema, unifiedTool } from "./unified.js";
|
|
11
15
|
export { createWriteTool, type WriteOperations, type WriteToolInput, type WriteToolOptions, writeTool, } from "./write.js";
|
|
12
16
|
import type { AgentTool } from "@boxiaolanya2008/pi-agent-core";
|
|
13
17
|
import { type BashToolOptions } from "./bash.js";
|
|
@@ -51,6 +55,140 @@ export declare const allTools: {
|
|
|
51
55
|
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
52
56
|
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
53
57
|
}>, any>;
|
|
58
|
+
batch_write: AgentTool<import("@sinclair/typebox").TObject<{
|
|
59
|
+
operation: import("@sinclair/typebox").TLiteral<"batch_write">;
|
|
60
|
+
files: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
61
|
+
path: import("@sinclair/typebox").TString;
|
|
62
|
+
content: import("@sinclair/typebox").TString;
|
|
63
|
+
}>>;
|
|
64
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
65
|
+
atomic: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
66
|
+
backup: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
67
|
+
overwrite: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
68
|
+
createDirs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
69
|
+
encoding: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
70
|
+
}>>;
|
|
71
|
+
}>, any>;
|
|
72
|
+
execute: AgentTool<import("@sinclair/typebox").TObject<{
|
|
73
|
+
operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
74
|
+
operation: import("@sinclair/typebox").TLiteral<"read">;
|
|
75
|
+
path: import("@sinclair/typebox").TString;
|
|
76
|
+
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
77
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
78
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
79
|
+
operation: import("@sinclair/typebox").TLiteral<"write">;
|
|
80
|
+
path: import("@sinclair/typebox").TString;
|
|
81
|
+
content: import("@sinclair/typebox").TString;
|
|
82
|
+
createDirs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
83
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
84
|
+
operation: import("@sinclair/typebox").TLiteral<"edit">;
|
|
85
|
+
path: import("@sinclair/typebox").TString;
|
|
86
|
+
oldText: import("@sinclair/typebox").TString;
|
|
87
|
+
newText: import("@sinclair/typebox").TString;
|
|
88
|
+
replaceAll: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
89
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
90
|
+
operation: import("@sinclair/typebox").TLiteral<"bash">;
|
|
91
|
+
command: import("@sinclair/typebox").TString;
|
|
92
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
93
|
+
cwd: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
94
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
95
|
+
operation: import("@sinclair/typebox").TLiteral<"grep">;
|
|
96
|
+
pattern: import("@sinclair/typebox").TString;
|
|
97
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
98
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
99
|
+
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
100
|
+
i: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
101
|
+
head_limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
102
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
103
|
+
operation: import("@sinclair/typebox").TLiteral<"find">;
|
|
104
|
+
pattern: import("@sinclair/typebox").TString;
|
|
105
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
106
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
107
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
108
|
+
operation: import("@sinclair/typebox").TLiteral<"ls">;
|
|
109
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
110
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
111
|
+
operation: import("@sinclair/typebox").TLiteral<"batch_write">;
|
|
112
|
+
files: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
113
|
+
path: import("@sinclair/typebox").TString;
|
|
114
|
+
content: import("@sinclair/typebox").TString;
|
|
115
|
+
}>>;
|
|
116
|
+
atomic: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
117
|
+
backup: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
118
|
+
}>]>>;
|
|
119
|
+
parallel: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
120
|
+
}>, any>;
|
|
121
|
+
todo_add: AgentTool<import("@sinclair/typebox").TObject<{
|
|
122
|
+
text: import("@sinclair/typebox").TString;
|
|
123
|
+
priority: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"low">, import("@sinclair/typebox").TLiteral<"medium">, import("@sinclair/typebox").TLiteral<"high">]>>;
|
|
124
|
+
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
125
|
+
}>, any>;
|
|
126
|
+
todo_complete: AgentTool<import("@sinclair/typebox").TObject<{
|
|
127
|
+
idOrText: import("@sinclair/typebox").TString;
|
|
128
|
+
}>, any>;
|
|
129
|
+
todo_uncomplete: AgentTool<import("@sinclair/typebox").TObject<{
|
|
130
|
+
idOrText: import("@sinclair/typebox").TString;
|
|
131
|
+
}>, any>;
|
|
132
|
+
todo_remove: AgentTool<import("@sinclair/typebox").TObject<{
|
|
133
|
+
idOrText: import("@sinclair/typebox").TString;
|
|
134
|
+
}>, any>;
|
|
135
|
+
todo_list: AgentTool<import("@sinclair/typebox").TObject<{
|
|
136
|
+
filter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"all">, import("@sinclair/typebox").TLiteral<"active">, import("@sinclair/typebox").TLiteral<"completed">]>>;
|
|
137
|
+
}>, any>;
|
|
138
|
+
todo_search: AgentTool<import("@sinclair/typebox").TObject<{
|
|
139
|
+
query: import("@sinclair/typebox").TString;
|
|
140
|
+
}>, any>;
|
|
141
|
+
};
|
|
142
|
+
export declare const unifiedTools: {
|
|
143
|
+
execute: AgentTool<import("@sinclair/typebox").TObject<{
|
|
144
|
+
operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
145
|
+
operation: import("@sinclair/typebox").TLiteral<"read">;
|
|
146
|
+
path: import("@sinclair/typebox").TString;
|
|
147
|
+
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
148
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
149
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
150
|
+
operation: import("@sinclair/typebox").TLiteral<"write">;
|
|
151
|
+
path: import("@sinclair/typebox").TString;
|
|
152
|
+
content: import("@sinclair/typebox").TString;
|
|
153
|
+
createDirs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
154
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
155
|
+
operation: import("@sinclair/typebox").TLiteral<"edit">;
|
|
156
|
+
path: import("@sinclair/typebox").TString;
|
|
157
|
+
oldText: import("@sinclair/typebox").TString;
|
|
158
|
+
newText: import("@sinclair/typebox").TString;
|
|
159
|
+
replaceAll: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
160
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
161
|
+
operation: import("@sinclair/typebox").TLiteral<"bash">;
|
|
162
|
+
command: import("@sinclair/typebox").TString;
|
|
163
|
+
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
164
|
+
cwd: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
165
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
166
|
+
operation: import("@sinclair/typebox").TLiteral<"grep">;
|
|
167
|
+
pattern: import("@sinclair/typebox").TString;
|
|
168
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
169
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
170
|
+
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
171
|
+
i: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
172
|
+
head_limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
173
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
174
|
+
operation: import("@sinclair/typebox").TLiteral<"find">;
|
|
175
|
+
pattern: import("@sinclair/typebox").TString;
|
|
176
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
177
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
178
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
179
|
+
operation: import("@sinclair/typebox").TLiteral<"ls">;
|
|
180
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
181
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
182
|
+
operation: import("@sinclair/typebox").TLiteral<"batch_write">;
|
|
183
|
+
files: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
184
|
+
path: import("@sinclair/typebox").TString;
|
|
185
|
+
content: import("@sinclair/typebox").TString;
|
|
186
|
+
}>>;
|
|
187
|
+
atomic: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
188
|
+
backup: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
189
|
+
}>]>>;
|
|
190
|
+
parallel: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
191
|
+
}>, any>;
|
|
54
192
|
};
|
|
55
193
|
export type ToolName = keyof typeof allTools;
|
|
56
194
|
export interface ToolsOptions {
|
|
@@ -60,4 +198,7 @@ export interface ToolsOptions {
|
|
|
60
198
|
export declare function createCodingTools(cwd: string, options?: ToolsOptions): Tool[];
|
|
61
199
|
export declare function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[];
|
|
62
200
|
export declare function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool>;
|
|
201
|
+
export declare function createUnifiedTools(cwd: string): {
|
|
202
|
+
execute: AgentTool<any>;
|
|
203
|
+
};
|
|
63
204
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,MAAM,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,SAAS,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,KAAK,eAAe,EAA4B,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,cAAc,EACd,sBAAsB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,eAAe,E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EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAkB1F;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;CAAE,CAI3E","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashTool,\n\tcreateBashTool,\n} from \"./bash.js\";\nexport {\n\ttype BatchWriteFileResult,\n\ttype BatchWriteInput,\n\ttype BatchWriteResult,\n\tbatchWriteTool,\n\tdetectBatchWriteIntent,\n} from \"./batch-write.js\";\nexport {\n\tcreateEditTool,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditTool,\n} from \"./edit.js\";\nexport type { ToolUpdateEvent } from \"./fast-executor.js\";\nexport {\n\tcanParallelize,\n\texecuteToolsParallel,\n\textractToolCalls,\n\tgetExecutionStats,\n\tresetExecutionStats,\n} from \"./fast-executor.js\";\nexport {\n\tcreateFindTool,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tfindTool,\n} from \"./find.js\";\nexport {\n\tcreateGrepTool,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\tgrepTool,\n} from \"./grep.js\";\nexport {\n\ttype AcceleratorConfig,\n\tacceleratedReadFile,\n\tacceleratedWriteFile,\n\tclearFileCache,\n\tconfigureAccelerator,\n\tgetAcceleratorResources,\n\tgetCacheStats,\n\tisAcceleratorEnabled,\n\tparallelGrep,\n\tparallelReadFiles,\n\tparallelReplace,\n\tparallelWriteFiles,\n} from \"./local-accelerator.js\";\nexport {\n\tcreateLsTool,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsTool,\n} from \"./ls.js\";\nexport {\n\tBatchProcessor,\n\tglobalCache,\n\tglobalMetrics,\n\tMemoryMappedCache,\n\tPerformanceMetrics,\n\tparallelExecute,\n} from \"./parallel-executor.js\";\nexport {\n\tcreateReadTool,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadTool,\n} from \"./read.js\";\nexport {\n\ttodoAddTool,\n\ttodoCompleteTool,\n\ttodoListTool,\n\ttodoRemoveTool,\n\ttodoSearchTool,\n\ttodoTools,\n\ttodoUncompleteTool,\n} from \"./todo.js\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.js\";\nexport { createUnifiedTool, type UnifiedInput, type UnifiedResult, UnifiedSchema, unifiedTool } from \"./unified.js\";\nexport {\n\tcreateWriteTool,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twriteTool,\n} from \"./write.js\";\n\nimport type { AgentTool } from \"@boxiaolanya2008/pi-agent-core\";\nimport { type BashToolOptions, bashTool, createBashTool } from \"./bash.js\";\nimport { batchWriteTool } from \"./batch-write.js\";\nimport { createEditTool, editTool } from \"./edit.js\";\nimport { createFindTool, findTool } from \"./find.js\";\nimport { createGrepTool, grepTool } from \"./grep.js\";\nimport { createLsTool, lsTool } from \"./ls.js\";\nimport { createReadTool, type ReadToolOptions, readTool } from \"./read.js\";\nimport {\n\ttodoAddTool,\n\ttodoCompleteTool,\n\ttodoListTool,\n\ttodoRemoveTool,\n\ttodoSearchTool,\n\ttodoUncompleteTool,\n} from \"./todo.js\";\nimport { createUnifiedTool, unifiedTool } from \"./unified.js\";\nimport { createWriteTool, writeTool } from \"./write.js\";\n\nexport type Tool = AgentTool<any>;\n\nexport const codingTools: Tool[] = [readTool, bashTool, editTool, writeTool];\nexport const readOnlyTools: Tool[] = [readTool, grepTool, findTool, lsTool];\n\nexport const allTools = {\n\tread: readTool,\n\tbash: bashTool,\n\tedit: editTool,\n\twrite: writeTool,\n\tgrep: grepTool,\n\tfind: findTool,\n\tls: lsTool,\n\tbatch_write: batchWriteTool,\n\texecute: unifiedTool,\n\ttodo_add: todoAddTool,\n\ttodo_complete: todoCompleteTool,\n\ttodo_uncomplete: todoUncompleteTool,\n\ttodo_remove: todoRemoveTool,\n\ttodo_list: todoListTool,\n\ttodo_search: todoSearchTool,\n};\n\nexport const unifiedTools = {\n\texecute: unifiedTool,\n};\n\nexport type ToolName = keyof typeof allTools;\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd),\n\t\tcreateWriteTool(cwd),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [createReadTool(cwd, options?.read), createGrepTool(cwd), createFindTool(cwd), createLsTool(cwd)];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd),\n\t\twrite: createWriteTool(cwd),\n\t\tgrep: createGrepTool(cwd),\n\t\tfind: createFindTool(cwd),\n\t\tls: createLsTool(cwd),\n\t\tbatch_write: batchWriteTool,\n\t\texecute: createUnifiedTool(cwd),\n\t\ttodo_add: todoAddTool,\n\t\ttodo_complete: todoCompleteTool,\n\t\ttodo_uncomplete: todoUncompleteTool,\n\t\ttodo_remove: todoRemoveTool,\n\t\ttodo_list: todoListTool,\n\t\ttodo_search: todoSearchTool,\n\t};\n}\n\nexport function createUnifiedTools(cwd: string): { execute: AgentTool<any> } {\n\treturn {\n\t\texecute: createUnifiedTool(cwd),\n\t};\n}\n"]}
|
package/dist/core/tools/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { bashTool, createBashTool, } from "./bash.js";
|
|
2
|
+
export { batchWriteTool, detectBatchWriteIntent, } from "./batch-write.js";
|
|
2
3
|
export { createEditTool, editTool, } from "./edit.js";
|
|
3
4
|
export { canParallelize, executeToolsParallel, extractToolCalls, getExecutionStats, resetExecutionStats, } from "./fast-executor.js";
|
|
4
5
|
export { createFindTool, findTool, } from "./find.js";
|
|
@@ -7,14 +8,19 @@ export { acceleratedReadFile, acceleratedWriteFile, clearFileCache, configureAcc
|
|
|
7
8
|
export { createLsTool, lsTool, } from "./ls.js";
|
|
8
9
|
export { BatchProcessor, globalCache, globalMetrics, MemoryMappedCache, PerformanceMetrics, parallelExecute, } from "./parallel-executor.js";
|
|
9
10
|
export { createReadTool, readTool, } from "./read.js";
|
|
11
|
+
export { todoAddTool, todoCompleteTool, todoListTool, todoRemoveTool, todoSearchTool, todoTools, todoUncompleteTool, } from "./todo.js";
|
|
10
12
|
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail, } from "./truncate.js";
|
|
13
|
+
export { createUnifiedTool, UnifiedSchema, unifiedTool } from "./unified.js";
|
|
11
14
|
export { createWriteTool, writeTool, } from "./write.js";
|
|
12
15
|
import { bashTool, createBashTool } from "./bash.js";
|
|
16
|
+
import { batchWriteTool } from "./batch-write.js";
|
|
13
17
|
import { createEditTool, editTool } from "./edit.js";
|
|
14
18
|
import { createFindTool, findTool } from "./find.js";
|
|
15
19
|
import { createGrepTool, grepTool } from "./grep.js";
|
|
16
20
|
import { createLsTool, lsTool } from "./ls.js";
|
|
17
21
|
import { createReadTool, readTool } from "./read.js";
|
|
22
|
+
import { todoAddTool, todoCompleteTool, todoListTool, todoRemoveTool, todoSearchTool, todoUncompleteTool, } from "./todo.js";
|
|
23
|
+
import { createUnifiedTool, unifiedTool } from "./unified.js";
|
|
18
24
|
import { createWriteTool, writeTool } from "./write.js";
|
|
19
25
|
export const codingTools = [readTool, bashTool, editTool, writeTool];
|
|
20
26
|
export const readOnlyTools = [readTool, grepTool, findTool, lsTool];
|
|
@@ -26,6 +32,17 @@ export const allTools = {
|
|
|
26
32
|
grep: grepTool,
|
|
27
33
|
find: findTool,
|
|
28
34
|
ls: lsTool,
|
|
35
|
+
batch_write: batchWriteTool,
|
|
36
|
+
execute: unifiedTool,
|
|
37
|
+
todo_add: todoAddTool,
|
|
38
|
+
todo_complete: todoCompleteTool,
|
|
39
|
+
todo_uncomplete: todoUncompleteTool,
|
|
40
|
+
todo_remove: todoRemoveTool,
|
|
41
|
+
todo_list: todoListTool,
|
|
42
|
+
todo_search: todoSearchTool,
|
|
43
|
+
};
|
|
44
|
+
export const unifiedTools = {
|
|
45
|
+
execute: unifiedTool,
|
|
29
46
|
};
|
|
30
47
|
export function createCodingTools(cwd, options) {
|
|
31
48
|
return [
|
|
@@ -47,6 +64,19 @@ export function createAllTools(cwd, options) {
|
|
|
47
64
|
grep: createGrepTool(cwd),
|
|
48
65
|
find: createFindTool(cwd),
|
|
49
66
|
ls: createLsTool(cwd),
|
|
67
|
+
batch_write: batchWriteTool,
|
|
68
|
+
execute: createUnifiedTool(cwd),
|
|
69
|
+
todo_add: todoAddTool,
|
|
70
|
+
todo_complete: todoCompleteTool,
|
|
71
|
+
todo_uncomplete: todoUncompleteTool,
|
|
72
|
+
todo_remove: todoRemoveTool,
|
|
73
|
+
todo_list: todoListTool,
|
|
74
|
+
todo_search: todoSearchTool,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function createUnifiedTools(cwd) {
|
|
78
|
+
return {
|
|
79
|
+
execute: createUnifiedTool(cwd),
|
|
50
80
|
};
|
|
51
81
|
}
|
|
52
82
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,QAAQ,EACR,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EAIN,cAAc,EACd,sBAAsB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;AAEnB,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EAEN,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,YAAY,EAKZ,MAAM,GACN,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,cAAc,EAKd,QAAQ,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,SAAS,EACT,kBAAkB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBA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G,CAAC;QACrB,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC;QAC/B,QAAQ,EAAE,WAAW;QACrB,aAAa,EAAE,gBAAgB;QAC/B,eAAe,EAAE,kBAAkB;QACnC,WAAW,EAAE,cAAc;QAC3B,SAAS,EAAE,YAAY;QACvB,WAAW,EAAE,cAAc;KAC3B,CAAC;AAAA,CACF;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAA+B;IAC5E,OAAO;QACN,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC;KAC/B,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashTool,\n\tcreateBashTool,\n} from \"./bash.js\";\nexport {\n\ttype BatchWriteFileResult,\n\ttype BatchWriteInput,\n\ttype BatchWriteResult,\n\tbatchWriteTool,\n\tdetectBatchWriteIntent,\n} from \"./batch-write.js\";\nexport {\n\tcreateEditTool,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditTool,\n} from \"./edit.js\";\nexport type { ToolUpdateEvent } from \"./fast-executor.js\";\nexport {\n\tcanParallelize,\n\texecuteToolsParallel,\n\textractToolCalls,\n\tgetExecutionStats,\n\tresetExecutionStats,\n} from \"./fast-executor.js\";\nexport {\n\tcreateFindTool,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tfindTool,\n} from \"./find.js\";\nexport {\n\tcreateGrepTool,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\tgrepTool,\n} from \"./grep.js\";\nexport {\n\ttype AcceleratorConfig,\n\tacceleratedReadFile,\n\tacceleratedWriteFile,\n\tclearFileCache,\n\tconfigureAccelerator,\n\tgetAcceleratorResources,\n\tgetCacheStats,\n\tisAcceleratorEnabled,\n\tparallelGrep,\n\tparallelReadFiles,\n\tparallelReplace,\n\tparallelWriteFiles,\n} from \"./local-accelerator.js\";\nexport {\n\tcreateLsTool,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsTool,\n} from \"./ls.js\";\nexport {\n\tBatchProcessor,\n\tglobalCache,\n\tglobalMetrics,\n\tMemoryMappedCache,\n\tPerformanceMetrics,\n\tparallelExecute,\n} from \"./parallel-executor.js\";\nexport {\n\tcreateReadTool,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadTool,\n} from \"./read.js\";\nexport {\n\ttodoAddTool,\n\ttodoCompleteTool,\n\ttodoListTool,\n\ttodoRemoveTool,\n\ttodoSearchTool,\n\ttodoTools,\n\ttodoUncompleteTool,\n} from \"./todo.js\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.js\";\nexport { createUnifiedTool, type UnifiedInput, type UnifiedResult, UnifiedSchema, unifiedTool } from \"./unified.js\";\nexport {\n\tcreateWriteTool,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twriteTool,\n} from \"./write.js\";\n\nimport type { AgentTool } from \"@boxiaolanya2008/pi-agent-core\";\nimport { type BashToolOptions, bashTool, createBashTool } from \"./bash.js\";\nimport { batchWriteTool } from \"./batch-write.js\";\nimport { createEditTool, editTool } from \"./edit.js\";\nimport { createFindTool, findTool } from \"./find.js\";\nimport { createGrepTool, grepTool } from \"./grep.js\";\nimport { createLsTool, lsTool } from \"./ls.js\";\nimport { createReadTool, type ReadToolOptions, readTool } from \"./read.js\";\nimport {\n\ttodoAddTool,\n\ttodoCompleteTool,\n\ttodoListTool,\n\ttodoRemoveTool,\n\ttodoSearchTool,\n\ttodoUncompleteTool,\n} from \"./todo.js\";\nimport { createUnifiedTool, unifiedTool } from \"./unified.js\";\nimport { createWriteTool, writeTool } from \"./write.js\";\n\nexport type Tool = AgentTool<any>;\n\nexport const codingTools: Tool[] = [readTool, bashTool, editTool, writeTool];\nexport const readOnlyTools: Tool[] = [readTool, grepTool, findTool, lsTool];\n\nexport const allTools = {\n\tread: readTool,\n\tbash: bashTool,\n\tedit: editTool,\n\twrite: writeTool,\n\tgrep: grepTool,\n\tfind: findTool,\n\tls: lsTool,\n\tbatch_write: batchWriteTool,\n\texecute: unifiedTool,\n\ttodo_add: todoAddTool,\n\ttodo_complete: todoCompleteTool,\n\ttodo_uncomplete: todoUncompleteTool,\n\ttodo_remove: todoRemoveTool,\n\ttodo_list: todoListTool,\n\ttodo_search: todoSearchTool,\n};\n\nexport const unifiedTools = {\n\texecute: unifiedTool,\n};\n\nexport type ToolName = keyof typeof allTools;\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd),\n\t\tcreateWriteTool(cwd),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [createReadTool(cwd, options?.read), createGrepTool(cwd), createFindTool(cwd), createLsTool(cwd)];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd),\n\t\twrite: createWriteTool(cwd),\n\t\tgrep: createGrepTool(cwd),\n\t\tfind: createFindTool(cwd),\n\t\tls: createLsTool(cwd),\n\t\tbatch_write: batchWriteTool,\n\t\texecute: createUnifiedTool(cwd),\n\t\ttodo_add: todoAddTool,\n\t\ttodo_complete: todoCompleteTool,\n\t\ttodo_uncomplete: todoUncompleteTool,\n\t\ttodo_remove: todoRemoveTool,\n\t\ttodo_list: todoListTool,\n\t\ttodo_search: todoSearchTool,\n\t};\n}\n\nexport function createUnifiedTools(cwd: string): { execute: AgentTool<any> } {\n\treturn {\n\t\texecute: createUnifiedTool(cwd),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AgentTool } from "@boxiaolanya2008/pi-agent-core";
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
|
+
declare const todoAddSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
text: import("@sinclair/typebox").TString;
|
|
5
|
+
priority: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"low">, import("@sinclair/typebox").TLiteral<"medium">, import("@sinclair/typebox").TLiteral<"high">]>>;
|
|
6
|
+
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
7
|
+
}>;
|
|
8
|
+
declare const todoCompleteSchema: import("@sinclair/typebox").TObject<{
|
|
9
|
+
idOrText: import("@sinclair/typebox").TString;
|
|
10
|
+
}>;
|
|
11
|
+
declare const todoUncompleteSchema: import("@sinclair/typebox").TObject<{
|
|
12
|
+
idOrText: import("@sinclair/typebox").TString;
|
|
13
|
+
}>;
|
|
14
|
+
declare const todoRemoveSchema: import("@sinclair/typebox").TObject<{
|
|
15
|
+
idOrText: import("@sinclair/typebox").TString;
|
|
16
|
+
}>;
|
|
17
|
+
declare const todoListSchema: import("@sinclair/typebox").TObject<{
|
|
18
|
+
filter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"all">, import("@sinclair/typebox").TLiteral<"active">, import("@sinclair/typebox").TLiteral<"completed">]>>;
|
|
19
|
+
}>;
|
|
20
|
+
declare const todoSearchSchema: import("@sinclair/typebox").TObject<{
|
|
21
|
+
query: import("@sinclair/typebox").TString;
|
|
22
|
+
}>;
|
|
23
|
+
export type TodoAddInput = Static<typeof todoAddSchema>;
|
|
24
|
+
export type TodoCompleteInput = Static<typeof todoCompleteSchema>;
|
|
25
|
+
export type TodoUncompleteInput = Static<typeof todoUncompleteSchema>;
|
|
26
|
+
export type TodoRemoveInput = Static<typeof todoRemoveSchema>;
|
|
27
|
+
export type TodoListInput = Static<typeof todoListSchema>;
|
|
28
|
+
export type TodoSearchInput = Static<typeof todoSearchSchema>;
|
|
29
|
+
export declare const todoAddTool: AgentTool<typeof todoAddSchema>;
|
|
30
|
+
export declare const todoCompleteTool: AgentTool<typeof todoCompleteSchema>;
|
|
31
|
+
export declare const todoUncompleteTool: AgentTool<typeof todoUncompleteSchema>;
|
|
32
|
+
export declare const todoRemoveTool: AgentTool<typeof todoRemoveSchema>;
|
|
33
|
+
export declare const todoListTool: AgentTool<typeof todoListSchema>;
|
|
34
|
+
export declare const todoSearchTool: AgentTool<typeof todoSearchSchema>;
|
|
35
|
+
export declare const todoTools: (AgentTool<import("@sinclair/typebox").TObject<{
|
|
36
|
+
text: import("@sinclair/typebox").TString;
|
|
37
|
+
priority: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"low">, import("@sinclair/typebox").TLiteral<"medium">, import("@sinclair/typebox").TLiteral<"high">]>>;
|
|
38
|
+
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
39
|
+
}>, any> | AgentTool<import("@sinclair/typebox").TObject<{
|
|
40
|
+
idOrText: import("@sinclair/typebox").TString;
|
|
41
|
+
}>, any> | AgentTool<import("@sinclair/typebox").TObject<{
|
|
42
|
+
filter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"all">, import("@sinclair/typebox").TLiteral<"active">, import("@sinclair/typebox").TLiteral<"completed">]>>;
|
|
43
|
+
}>, any> | AgentTool<import("@sinclair/typebox").TObject<{
|
|
44
|
+
query: import("@sinclair/typebox").TString;
|
|
45
|
+
}>, any>)[];
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=todo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../../../src/core/tools/todo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAWtD,QAAA,MAAM,aAAa;;;;EAQjB,CAAC;AAEH,QAAA,MAAM,kBAAkB;;EAItB,CAAC;AAEH,QAAA,MAAM,oBAAoB;;EAIxB,CAAC;AAEH,QAAA,MAAM,gBAAgB;;EAIpB,CAAC;AAEH,QAAA,MAAM,cAAc;;EAMlB,CAAC;AAEH,QAAA,MAAM,gBAAgB;;EAEpB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AACxD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAC1D,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAS9D,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,OAAO,aAAa,CAiBvD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAAS,CAAC,OAAO,kBAAkB,CA4BjE,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAAS,CAAC,OAAO,oBAAoB,CA4BrE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,OAAO,gBAAgB,CA4B7D,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,SAAS,CAAC,OAAO,cAAc,CA6BzD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,OAAO,gBAAgB,CA6B7D,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;WAOrB,CAAC","sourcesContent":["import type { AgentTool } from \"@boxiaolanya2008/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport {\n\taddTodo,\n\tcompleteTodo,\n\tlistTodos,\n\ttype loadTodos,\n\tremoveTodo,\n\tsearchTodos,\n\tuncompleteTodo,\n} from \"../todo-manager.js\";\n\nconst todoAddSchema = Type.Object({\n\ttext: Type.String({ description: \"The todo item text\" }),\n\tpriority: Type.Optional(\n\t\tType.Union([Type.Literal(\"low\"), Type.Literal(\"medium\"), Type.Literal(\"high\")], {\n\t\t\tdescription: \"Priority level (default: medium)\",\n\t\t}),\n\t),\n\ttags: Type.Optional(Type.Array(Type.String(), { description: \"Tags for categorization\" })),\n});\n\nconst todoCompleteSchema = Type.Object({\n\tidOrText: Type.String({\n\t\tdescription: \"The todo ID or exact text to mark as completed\",\n\t}),\n});\n\nconst todoUncompleteSchema = Type.Object({\n\tidOrText: Type.String({\n\t\tdescription: \"The todo ID or exact text to mark as not completed\",\n\t}),\n});\n\nconst todoRemoveSchema = Type.Object({\n\tidOrText: Type.String({\n\t\tdescription: \"The todo ID or exact text to remove\",\n\t}),\n});\n\nconst todoListSchema = Type.Object({\n\tfilter: Type.Optional(\n\t\tType.Union([Type.Literal(\"all\"), Type.Literal(\"active\"), Type.Literal(\"completed\")], {\n\t\t\tdescription: \"Filter option (default: all)\",\n\t\t}),\n\t),\n});\n\nconst todoSearchSchema = Type.Object({\n\tquery: Type.String({ description: \"Search query for todo text or tags\" }),\n});\n\nexport type TodoAddInput = Static<typeof todoAddSchema>;\nexport type TodoCompleteInput = Static<typeof todoCompleteSchema>;\nexport type TodoUncompleteInput = Static<typeof todoUncompleteSchema>;\nexport type TodoRemoveInput = Static<typeof todoRemoveSchema>;\nexport type TodoListInput = Static<typeof todoListSchema>;\nexport type TodoSearchInput = Static<typeof todoSearchSchema>;\n\nfunction formatTodoItem(item: ReturnType<typeof loadTodos>[\"items\"][0]): string {\n\tconst status = item.completed ? \"[x]\" : \"[ ]\";\n\tconst priority = item.priority === \"high\" ? \"!!!\" : item.priority === \"low\" ? \"!\" : \"!!\";\n\tconst tags = item.tags.length > 0 ? ` (${item.tags.join(\", \")})` : \"\";\n\treturn `${status} ${priority} ${item.text}${tags}`;\n}\n\nexport const todoAddTool: AgentTool<typeof todoAddSchema> = {\n\tname: \"todo_add\",\n\tlabel: \"todo_add\",\n\tdescription: \"Add a new todo item to the list. Use this to track tasks, reminders, or action items.\",\n\tparameters: todoAddSchema,\n\texecute: async (_id, { text, priority, tags }) => {\n\t\tconst item = addTodo(text, { priority, tags });\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Added todo: ${formatTodoItem(item)}`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { item },\n\t\t};\n\t},\n};\n\nexport const todoCompleteTool: AgentTool<typeof todoCompleteSchema> = {\n\tname: \"todo_complete\",\n\tlabel: \"todo_complete\",\n\tdescription: \"Mark a todo item as completed. Provide the todo ID or exact text.\",\n\tparameters: todoCompleteSchema,\n\texecute: async (_id, { idOrText }) => {\n\t\tconst item = completeTodo(idOrText);\n\t\tif (!item) {\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Could not find active todo matching \"${idOrText}\"`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: undefined,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Completed: ${formatTodoItem(item)}`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { item },\n\t\t};\n\t},\n};\n\nexport const todoUncompleteTool: AgentTool<typeof todoUncompleteSchema> = {\n\tname: \"todo_uncomplete\",\n\tlabel: \"todo_uncomplete\",\n\tdescription: \"Mark a completed todo item as not completed. Provide the todo ID or exact text.\",\n\tparameters: todoUncompleteSchema,\n\texecute: async (_id, { idOrText }) => {\n\t\tconst item = uncompleteTodo(idOrText);\n\t\tif (!item) {\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Could not find completed todo matching \"${idOrText}\"`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: undefined,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Reopened: ${formatTodoItem(item)}`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { item },\n\t\t};\n\t},\n};\n\nexport const todoRemoveTool: AgentTool<typeof todoRemoveSchema> = {\n\tname: \"todo_remove\",\n\tlabel: \"todo_remove\",\n\tdescription: \"Remove a todo item from the list. Provide the todo ID or exact text.\",\n\tparameters: todoRemoveSchema,\n\texecute: async (_id, { idOrText }) => {\n\t\tconst item = removeTodo(idOrText);\n\t\tif (!item) {\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Could not find todo matching \"${idOrText}\"`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: undefined,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Removed: ${formatTodoItem(item)}`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { item },\n\t\t};\n\t},\n};\n\nexport const todoListTool: AgentTool<typeof todoListSchema> = {\n\tname: \"todo_list\",\n\tlabel: \"todo_list\",\n\tdescription: \"List all todo items. Can filter by all, active (not completed), or completed.\",\n\tparameters: todoListSchema,\n\texecute: async (_id, { filter }) => {\n\t\tconst items = listTodos(filter);\n\t\tif (items.length === 0) {\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: \"No todo items found.\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: { items: [] },\n\t\t\t};\n\t\t}\n\t\tconst lines = items.map(formatTodoItem);\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: lines.join(\"\\n\"),\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { items },\n\t\t};\n\t},\n};\n\nexport const todoSearchTool: AgentTool<typeof todoSearchSchema> = {\n\tname: \"todo_search\",\n\tlabel: \"todo_search\",\n\tdescription: \"Search for todo items by text content or tags.\",\n\tparameters: todoSearchSchema,\n\texecute: async (_id, { query }) => {\n\t\tconst items = searchTodos(query);\n\t\tif (items.length === 0) {\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `No todos found matching \"${query}\".`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: { items: [] },\n\t\t\t};\n\t\t}\n\t\tconst lines = items.map(formatTodoItem);\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Found ${items.length} todo(s) matching \"${query}\":\\n${lines.join(\"\\n\")}`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { items },\n\t\t};\n\t},\n};\n\nexport const todoTools = [\n\ttodoAddTool,\n\ttodoCompleteTool,\n\ttodoUncompleteTool,\n\ttodoRemoveTool,\n\ttodoListTool,\n\ttodoSearchTool,\n];\n"]}
|