@nexus-cortex/executors 4.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +13 -0
- package/dist/ExecutorRegistry.d.ts +89 -0
- package/dist/ExecutorRegistry.d.ts.map +1 -0
- package/dist/ExecutorRegistry.js +219 -0
- package/dist/ExecutorRegistry.js.map +1 -0
- package/dist/base/BaseTool.d.ts +108 -0
- package/dist/base/BaseTool.d.ts.map +1 -0
- package/dist/base/BaseTool.js +111 -0
- package/dist/base/BaseTool.js.map +1 -0
- package/dist/base/ToolRegistry.d.ts +141 -0
- package/dist/base/ToolRegistry.d.ts.map +1 -0
- package/dist/base/ToolRegistry.js +241 -0
- package/dist/base/ToolRegistry.js.map +1 -0
- package/dist/base/ToolResult.d.ts +63 -0
- package/dist/base/ToolResult.d.ts.map +1 -0
- package/dist/base/ToolResult.js +8 -0
- package/dist/base/ToolResult.js.map +1 -0
- package/dist/base/index.d.ts +10 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +8 -0
- package/dist/base/index.js.map +1 -0
- package/dist/implementations/addon/CreateArtifactTool.d.ts +221 -0
- package/dist/implementations/addon/CreateArtifactTool.d.ts.map +1 -0
- package/dist/implementations/addon/CreateArtifactTool.js +1042 -0
- package/dist/implementations/addon/CreateArtifactTool.js.map +1 -0
- package/dist/implementations/addon/FrameDiffCache.d.ts +166 -0
- package/dist/implementations/addon/FrameDiffCache.d.ts.map +1 -0
- package/dist/implementations/addon/FrameDiffCache.js +395 -0
- package/dist/implementations/addon/FrameDiffCache.js.map +1 -0
- package/dist/implementations/addon/H264StreamEncoder.d.ts +84 -0
- package/dist/implementations/addon/H264StreamEncoder.d.ts.map +1 -0
- package/dist/implementations/addon/H264StreamEncoder.js +203 -0
- package/dist/implementations/addon/H264StreamEncoder.js.map +1 -0
- package/dist/implementations/addon/HybridScreenshotManager.d.ts +197 -0
- package/dist/implementations/addon/HybridScreenshotManager.d.ts.map +1 -0
- package/dist/implementations/addon/HybridScreenshotManager.js +415 -0
- package/dist/implementations/addon/HybridScreenshotManager.js.map +1 -0
- package/dist/implementations/addon/InspectSandboxTool.d.ts +54 -0
- package/dist/implementations/addon/InspectSandboxTool.d.ts.map +1 -0
- package/dist/implementations/addon/InspectSandboxTool.js +226 -0
- package/dist/implementations/addon/InspectSandboxTool.js.map +1 -0
- package/dist/implementations/addon/InteractWithSandboxTool.d.ts +90 -0
- package/dist/implementations/addon/InteractWithSandboxTool.d.ts.map +1 -0
- package/dist/implementations/addon/InteractWithSandboxTool.js +367 -0
- package/dist/implementations/addon/InteractWithSandboxTool.js.map +1 -0
- package/dist/implementations/addon/KeyframeDetector.d.ts +140 -0
- package/dist/implementations/addon/KeyframeDetector.d.ts.map +1 -0
- package/dist/implementations/addon/KeyframeDetector.js +390 -0
- package/dist/implementations/addon/KeyframeDetector.js.map +1 -0
- package/dist/implementations/addon/ModifySandboxTool.d.ts +62 -0
- package/dist/implementations/addon/ModifySandboxTool.d.ts.map +1 -0
- package/dist/implementations/addon/ModifySandboxTool.js +266 -0
- package/dist/implementations/addon/ModifySandboxTool.js.map +1 -0
- package/dist/implementations/addon/ReactArtifactBuilder.d.ts +27 -0
- package/dist/implementations/addon/ReactArtifactBuilder.d.ts.map +1 -0
- package/dist/implementations/addon/ReactArtifactBuilder.js +198 -0
- package/dist/implementations/addon/ReactArtifactBuilder.js.map +1 -0
- package/dist/implementations/addon/SandboxEventBroadcaster.d.ts +143 -0
- package/dist/implementations/addon/SandboxEventBroadcaster.d.ts.map +1 -0
- package/dist/implementations/addon/SandboxEventBroadcaster.js +258 -0
- package/dist/implementations/addon/SandboxEventBroadcaster.js.map +1 -0
- package/dist/implementations/addon/SandboxIntrospectionTools.d.ts +77 -0
- package/dist/implementations/addon/SandboxIntrospectionTools.d.ts.map +1 -0
- package/dist/implementations/addon/SandboxIntrospectionTools.js +292 -0
- package/dist/implementations/addon/SandboxIntrospectionTools.js.map +1 -0
- package/dist/implementations/addon/SandboxViewServer.d.ts +127 -0
- package/dist/implementations/addon/SandboxViewServer.d.ts.map +1 -0
- package/dist/implementations/addon/SandboxViewServer.js +775 -0
- package/dist/implementations/addon/SandboxViewServer.js.map +1 -0
- package/dist/implementations/addon/ScreenStream.d.ts +149 -0
- package/dist/implementations/addon/ScreenStream.d.ts.map +1 -0
- package/dist/implementations/addon/ScreenStream.js +306 -0
- package/dist/implementations/addon/ScreenStream.js.map +1 -0
- package/dist/implementations/addon/StopSandboxTool.d.ts +61 -0
- package/dist/implementations/addon/StopSandboxTool.d.ts.map +1 -0
- package/dist/implementations/addon/StopSandboxTool.js +252 -0
- package/dist/implementations/addon/StopSandboxTool.js.map +1 -0
- package/dist/implementations/addon/TerminalSandbox.d.ts +111 -0
- package/dist/implementations/addon/TerminalSandbox.d.ts.map +1 -0
- package/dist/implementations/addon/TerminalSandbox.js +345 -0
- package/dist/implementations/addon/TerminalSandbox.js.map +1 -0
- package/dist/implementations/addon/VisualFeedbackBridge.d.ts +367 -0
- package/dist/implementations/addon/VisualFeedbackBridge.d.ts.map +1 -0
- package/dist/implementations/addon/VisualFeedbackBridge.js +888 -0
- package/dist/implementations/addon/VisualFeedbackBridge.js.map +1 -0
- package/dist/implementations/addon/WindowManager.d.ts +138 -0
- package/dist/implementations/addon/WindowManager.d.ts.map +1 -0
- package/dist/implementations/addon/WindowManager.js +276 -0
- package/dist/implementations/addon/WindowManager.js.map +1 -0
- package/dist/implementations/addon/index.d.ts +29 -0
- package/dist/implementations/addon/index.d.ts.map +1 -0
- package/dist/implementations/addon/index.js +29 -0
- package/dist/implementations/addon/index.js.map +1 -0
- package/dist/implementations/addon/injectables/reactIntrospection.d.ts +57 -0
- package/dist/implementations/addon/injectables/reactIntrospection.d.ts.map +1 -0
- package/dist/implementations/addon/injectables/reactIntrospection.js +480 -0
- package/dist/implementations/addon/injectables/reactIntrospection.js.map +1 -0
- package/dist/implementations/addon/terminal-client.html +253 -0
- package/dist/implementations/agent/PRAgentTool.d.ts +37 -0
- package/dist/implementations/agent/PRAgentTool.d.ts.map +1 -0
- package/dist/implementations/agent/PRAgentTool.js +257 -0
- package/dist/implementations/agent/PRAgentTool.js.map +1 -0
- package/dist/implementations/agent/TaskTool.d.ts +76 -0
- package/dist/implementations/agent/TaskTool.d.ts.map +1 -0
- package/dist/implementations/agent/TaskTool.js +424 -0
- package/dist/implementations/agent/TaskTool.js.map +1 -0
- package/dist/implementations/agent/index.d.ts +5 -0
- package/dist/implementations/agent/index.d.ts.map +1 -0
- package/dist/implementations/agent/index.js +3 -0
- package/dist/implementations/agent/index.js.map +1 -0
- package/dist/implementations/execution/BackgroundProcessRegistry.d.ts +68 -0
- package/dist/implementations/execution/BackgroundProcessRegistry.d.ts.map +1 -0
- package/dist/implementations/execution/BackgroundProcessRegistry.js +146 -0
- package/dist/implementations/execution/BackgroundProcessRegistry.js.map +1 -0
- package/dist/implementations/execution/BashOutputTool.d.ts +42 -0
- package/dist/implementations/execution/BashOutputTool.d.ts.map +1 -0
- package/dist/implementations/execution/BashOutputTool.js +168 -0
- package/dist/implementations/execution/BashOutputTool.js.map +1 -0
- package/dist/implementations/execution/CodeExecuteTool.d.ts +31 -0
- package/dist/implementations/execution/CodeExecuteTool.d.ts.map +1 -0
- package/dist/implementations/execution/CodeExecuteTool.js +127 -0
- package/dist/implementations/execution/CodeExecuteTool.js.map +1 -0
- package/dist/implementations/execution/KillShellTool.d.ts +37 -0
- package/dist/implementations/execution/KillShellTool.d.ts.map +1 -0
- package/dist/implementations/execution/KillShellTool.js +144 -0
- package/dist/implementations/execution/KillShellTool.js.map +1 -0
- package/dist/implementations/execution/SearchToolsTool.d.ts +32 -0
- package/dist/implementations/execution/SearchToolsTool.d.ts.map +1 -0
- package/dist/implementations/execution/SearchToolsTool.js +109 -0
- package/dist/implementations/execution/SearchToolsTool.js.map +1 -0
- package/dist/implementations/execution/ShellTool.d.ts +108 -0
- package/dist/implementations/execution/ShellTool.d.ts.map +1 -0
- package/dist/implementations/execution/ShellTool.js +546 -0
- package/dist/implementations/execution/ShellTool.js.map +1 -0
- package/dist/implementations/execution/WorkspaceManagerTool.d.ts +40 -0
- package/dist/implementations/execution/WorkspaceManagerTool.d.ts.map +1 -0
- package/dist/implementations/execution/WorkspaceManagerTool.js +370 -0
- package/dist/implementations/execution/WorkspaceManagerTool.js.map +1 -0
- package/dist/implementations/execution/index.d.ts +13 -0
- package/dist/implementations/execution/index.d.ts.map +1 -0
- package/dist/implementations/execution/index.js +13 -0
- package/dist/implementations/execution/index.js.map +1 -0
- package/dist/implementations/extensions/EndTurnTool.d.ts +62 -0
- package/dist/implementations/extensions/EndTurnTool.d.ts.map +1 -0
- package/dist/implementations/extensions/EndTurnTool.js +172 -0
- package/dist/implementations/extensions/EndTurnTool.js.map +1 -0
- package/dist/implementations/extensions/ResearchBacklogTool.d.ts +37 -0
- package/dist/implementations/extensions/ResearchBacklogTool.d.ts.map +1 -0
- package/dist/implementations/extensions/ResearchBacklogTool.js +102 -0
- package/dist/implementations/extensions/ResearchBacklogTool.js.map +1 -0
- package/dist/implementations/extensions/SkillTool.d.ts +108 -0
- package/dist/implementations/extensions/SkillTool.d.ts.map +1 -0
- package/dist/implementations/extensions/SkillTool.js +351 -0
- package/dist/implementations/extensions/SkillTool.js.map +1 -0
- package/dist/implementations/extensions/SlashCommandTool.d.ts +112 -0
- package/dist/implementations/extensions/SlashCommandTool.d.ts.map +1 -0
- package/dist/implementations/extensions/SlashCommandTool.js +315 -0
- package/dist/implementations/extensions/SlashCommandTool.js.map +1 -0
- package/dist/implementations/extensions/index.d.ts +14 -0
- package/dist/implementations/extensions/index.d.ts.map +1 -0
- package/dist/implementations/extensions/index.js +10 -0
- package/dist/implementations/extensions/index.js.map +1 -0
- package/dist/implementations/file/EditTool.d.ts +232 -0
- package/dist/implementations/file/EditTool.d.ts.map +1 -0
- package/dist/implementations/file/EditTool.js +707 -0
- package/dist/implementations/file/EditTool.js.map +1 -0
- package/dist/implementations/file/ReadFileTool.d.ts +49 -0
- package/dist/implementations/file/ReadFileTool.d.ts.map +1 -0
- package/dist/implementations/file/ReadFileTool.js +225 -0
- package/dist/implementations/file/ReadFileTool.js.map +1 -0
- package/dist/implementations/file/WriteBinaryTool.d.ts +21 -0
- package/dist/implementations/file/WriteBinaryTool.d.ts.map +1 -0
- package/dist/implementations/file/WriteBinaryTool.js +153 -0
- package/dist/implementations/file/WriteBinaryTool.js.map +1 -0
- package/dist/implementations/file/WriteFileTool.d.ts +41 -0
- package/dist/implementations/file/WriteFileTool.d.ts.map +1 -0
- package/dist/implementations/file/WriteFileTool.js +220 -0
- package/dist/implementations/file/WriteFileTool.js.map +1 -0
- package/dist/implementations/file/index.d.ts +8 -0
- package/dist/implementations/file/index.d.ts.map +1 -0
- package/dist/implementations/file/index.js +8 -0
- package/dist/implementations/file/index.js.map +1 -0
- package/dist/implementations/historical/GetConversationSegmentTool.d.ts +44 -0
- package/dist/implementations/historical/GetConversationSegmentTool.d.ts.map +1 -0
- package/dist/implementations/historical/GetConversationSegmentTool.js +220 -0
- package/dist/implementations/historical/GetConversationSegmentTool.js.map +1 -0
- package/dist/implementations/historical/ListCompactionBoundariesTool.d.ts +36 -0
- package/dist/implementations/historical/ListCompactionBoundariesTool.d.ts.map +1 -0
- package/dist/implementations/historical/ListCompactionBoundariesTool.js +174 -0
- package/dist/implementations/historical/ListCompactionBoundariesTool.js.map +1 -0
- package/dist/implementations/historical/ListSessionsTool.d.ts +38 -0
- package/dist/implementations/historical/ListSessionsTool.d.ts.map +1 -0
- package/dist/implementations/historical/ListSessionsTool.js +140 -0
- package/dist/implementations/historical/ListSessionsTool.js.map +1 -0
- package/dist/implementations/historical/LoadSessionTool.d.ts +39 -0
- package/dist/implementations/historical/LoadSessionTool.d.ts.map +1 -0
- package/dist/implementations/historical/LoadSessionTool.js +171 -0
- package/dist/implementations/historical/LoadSessionTool.js.map +1 -0
- package/dist/implementations/historical/RequestHistoricalContextTool.d.ts +46 -0
- package/dist/implementations/historical/RequestHistoricalContextTool.d.ts.map +1 -0
- package/dist/implementations/historical/RequestHistoricalContextTool.js +224 -0
- package/dist/implementations/historical/RequestHistoricalContextTool.js.map +1 -0
- package/dist/implementations/historical/SearchConversationHistoryTool.d.ts +51 -0
- package/dist/implementations/historical/SearchConversationHistoryTool.d.ts.map +1 -0
- package/dist/implementations/historical/SearchConversationHistoryTool.js +306 -0
- package/dist/implementations/historical/SearchConversationHistoryTool.js.map +1 -0
- package/dist/implementations/historical/index.d.ts +12 -0
- package/dist/implementations/historical/index.d.ts.map +1 -0
- package/dist/implementations/historical/index.js +12 -0
- package/dist/implementations/historical/index.js.map +1 -0
- package/dist/implementations/index.d.ts +16 -0
- package/dist/implementations/index.d.ts.map +1 -0
- package/dist/implementations/index.js +28 -0
- package/dist/implementations/index.js.map +1 -0
- package/dist/implementations/mcp/DiscoveredMcpTool.d.ts +58 -0
- package/dist/implementations/mcp/DiscoveredMcpTool.d.ts.map +1 -0
- package/dist/implementations/mcp/DiscoveredMcpTool.js +269 -0
- package/dist/implementations/mcp/DiscoveredMcpTool.js.map +1 -0
- package/dist/implementations/mcp/index.d.ts +9 -0
- package/dist/implementations/mcp/index.d.ts.map +1 -0
- package/dist/implementations/mcp/index.js +8 -0
- package/dist/implementations/mcp/index.js.map +1 -0
- package/dist/implementations/notebook/NotebookEditTool.d.ts +96 -0
- package/dist/implementations/notebook/NotebookEditTool.d.ts.map +1 -0
- package/dist/implementations/notebook/NotebookEditTool.js +390 -0
- package/dist/implementations/notebook/NotebookEditTool.js.map +1 -0
- package/dist/implementations/notebook/index.d.ts +7 -0
- package/dist/implementations/notebook/index.d.ts.map +1 -0
- package/dist/implementations/notebook/index.js +7 -0
- package/dist/implementations/notebook/index.js.map +1 -0
- package/dist/implementations/search/GlobTool.d.ts +73 -0
- package/dist/implementations/search/GlobTool.d.ts.map +1 -0
- package/dist/implementations/search/GlobTool.js +213 -0
- package/dist/implementations/search/GlobTool.js.map +1 -0
- package/dist/implementations/search/GrepTool.d.ts +102 -0
- package/dist/implementations/search/GrepTool.d.ts.map +1 -0
- package/dist/implementations/search/GrepTool.js +754 -0
- package/dist/implementations/search/GrepTool.js.map +1 -0
- package/dist/implementations/search/index.d.ts +6 -0
- package/dist/implementations/search/index.d.ts.map +1 -0
- package/dist/implementations/search/index.js +6 -0
- package/dist/implementations/search/index.js.map +1 -0
- package/dist/implementations/tmux/TmuxSessionTool.d.ts +82 -0
- package/dist/implementations/tmux/TmuxSessionTool.d.ts.map +1 -0
- package/dist/implementations/tmux/TmuxSessionTool.js +371 -0
- package/dist/implementations/tmux/TmuxSessionTool.js.map +1 -0
- package/dist/implementations/tmux/TmuxViewServer.d.ts +86 -0
- package/dist/implementations/tmux/TmuxViewServer.d.ts.map +1 -0
- package/dist/implementations/tmux/TmuxViewServer.js +480 -0
- package/dist/implementations/tmux/TmuxViewServer.js.map +1 -0
- package/dist/implementations/tmux/index.d.ts +6 -0
- package/dist/implementations/tmux/index.d.ts.map +1 -0
- package/dist/implementations/tmux/index.js +6 -0
- package/dist/implementations/tmux/index.js.map +1 -0
- package/dist/implementations/ui/AskUserQuestionTool.d.ts +77 -0
- package/dist/implementations/ui/AskUserQuestionTool.d.ts.map +1 -0
- package/dist/implementations/ui/AskUserQuestionTool.js +241 -0
- package/dist/implementations/ui/AskUserQuestionTool.js.map +1 -0
- package/dist/implementations/ui/ExitPlanModeTool.d.ts +44 -0
- package/dist/implementations/ui/ExitPlanModeTool.d.ts.map +1 -0
- package/dist/implementations/ui/ExitPlanModeTool.js +150 -0
- package/dist/implementations/ui/ExitPlanModeTool.js.map +1 -0
- package/dist/implementations/ui/TodoWriteTool.d.ts +59 -0
- package/dist/implementations/ui/TodoWriteTool.d.ts.map +1 -0
- package/dist/implementations/ui/TodoWriteTool.js +315 -0
- package/dist/implementations/ui/TodoWriteTool.js.map +1 -0
- package/dist/implementations/ui/index.d.ts +9 -0
- package/dist/implementations/ui/index.d.ts.map +1 -0
- package/dist/implementations/ui/index.js +9 -0
- package/dist/implementations/ui/index.js.map +1 -0
- package/dist/implementations/web/BrowseTool.d.ts +43 -0
- package/dist/implementations/web/BrowseTool.d.ts.map +1 -0
- package/dist/implementations/web/BrowseTool.js +181 -0
- package/dist/implementations/web/BrowseTool.js.map +1 -0
- package/dist/implementations/web/SandboxTransferTool.d.ts +30 -0
- package/dist/implementations/web/SandboxTransferTool.d.ts.map +1 -0
- package/dist/implementations/web/SandboxTransferTool.js +261 -0
- package/dist/implementations/web/SandboxTransferTool.js.map +1 -0
- package/dist/implementations/web/WebFetchTool.d.ts +93 -0
- package/dist/implementations/web/WebFetchTool.d.ts.map +1 -0
- package/dist/implementations/web/WebFetchTool.js +484 -0
- package/dist/implementations/web/WebFetchTool.js.map +1 -0
- package/dist/implementations/web/WebSearchTool.d.ts +53 -0
- package/dist/implementations/web/WebSearchTool.d.ts.map +1 -0
- package/dist/implementations/web/WebSearchTool.js +227 -0
- package/dist/implementations/web/WebSearchTool.js.map +1 -0
- package/dist/implementations/web/escalateDirective.d.ts +11 -0
- package/dist/implementations/web/escalateDirective.d.ts.map +1 -0
- package/dist/implementations/web/escalateDirective.js +20 -0
- package/dist/implementations/web/escalateDirective.js.map +1 -0
- package/dist/implementations/web/index.d.ts +10 -0
- package/dist/implementations/web/index.d.ts.map +1 -0
- package/dist/implementations/web/index.js +10 -0
- package/dist/implementations/web/index.js.map +1 -0
- package/dist/implementations/web/webBackends.d.ts +65 -0
- package/dist/implementations/web/webBackends.d.ts.map +1 -0
- package/dist/implementations/web/webBackends.js +430 -0
- package/dist/implementations/web/webBackends.js.map +1 -0
- package/dist/implementations/web/webFetchRequestInit.d.ts +9 -0
- package/dist/implementations/web/webFetchRequestInit.d.ts.map +1 -0
- package/dist/implementations/web/webFetchRequestInit.js +21 -0
- package/dist/implementations/web/webFetchRequestInit.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/ArtifactRegistry.d.ts +138 -0
- package/dist/utils/ArtifactRegistry.d.ts.map +1 -0
- package/dist/utils/ArtifactRegistry.js +259 -0
- package/dist/utils/ArtifactRegistry.js.map +1 -0
- package/dist/utils/ChromiumBrowserManager.d.ts +56 -0
- package/dist/utils/ChromiumBrowserManager.d.ts.map +1 -0
- package/dist/utils/ChromiumBrowserManager.js +243 -0
- package/dist/utils/ChromiumBrowserManager.js.map +1 -0
- package/dist/utils/FileUtils.d.ts +81 -0
- package/dist/utils/FileUtils.d.ts.map +1 -0
- package/dist/utils/FileUtils.js +148 -0
- package/dist/utils/FileUtils.js.map +1 -0
- package/dist/utils/GitPolicy.d.ts +70 -0
- package/dist/utils/GitPolicy.d.ts.map +1 -0
- package/dist/utils/GitPolicy.js +166 -0
- package/dist/utils/GitPolicy.js.map +1 -0
- package/dist/utils/GitUtils.d.ts +18 -0
- package/dist/utils/GitUtils.d.ts.map +1 -0
- package/dist/utils/GitUtils.js +62 -0
- package/dist/utils/GitUtils.js.map +1 -0
- package/dist/utils/SandboxRegistry.d.ts +110 -0
- package/dist/utils/SandboxRegistry.d.ts.map +1 -0
- package/dist/utils/SandboxRegistry.js +220 -0
- package/dist/utils/SandboxRegistry.js.map +1 -0
- package/dist/utils/SchemaValidator.d.ts +21 -0
- package/dist/utils/SchemaValidator.d.ts.map +1 -0
- package/dist/utils/SchemaValidator.js +67 -0
- package/dist/utils/SchemaValidator.js.map +1 -0
- package/dist/utils/SessionLock.d.ts +96 -0
- package/dist/utils/SessionLock.d.ts.map +1 -0
- package/dist/utils/SessionLock.js +276 -0
- package/dist/utils/SessionLock.js.map +1 -0
- package/dist/utils/SessionPersistence.d.ts +89 -0
- package/dist/utils/SessionPersistence.d.ts.map +1 -0
- package/dist/utils/SessionPersistence.js +244 -0
- package/dist/utils/SessionPersistence.js.map +1 -0
- package/dist/utils/TextUtils.d.ts +77 -0
- package/dist/utils/TextUtils.d.ts.map +1 -0
- package/dist/utils/TextUtils.js +112 -0
- package/dist/utils/TextUtils.js.map +1 -0
- package/dist/utils/TmuxCapture.d.ts +94 -0
- package/dist/utils/TmuxCapture.d.ts.map +1 -0
- package/dist/utils/TmuxCapture.js +131 -0
- package/dist/utils/TmuxCapture.js.map +1 -0
- package/dist/utils/TmuxManager.d.ts +65 -0
- package/dist/utils/TmuxManager.d.ts.map +1 -0
- package/dist/utils/TmuxManager.js +304 -0
- package/dist/utils/TmuxManager.js.map +1 -0
- package/dist/utils/autoResearchPlanGate.d.ts +10 -0
- package/dist/utils/autoResearchPlanGate.d.ts.map +1 -0
- package/dist/utils/autoResearchPlanGate.js +57 -0
- package/dist/utils/autoResearchPlanGate.js.map +1 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +13 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background Process Registry
|
|
3
|
+
*
|
|
4
|
+
* Simple in-memory registry to track background shell processes
|
|
5
|
+
* spawned by ShellTool. Used by BashOutput and KillShell tools.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
/**
|
|
9
|
+
* Singleton registry for background processes
|
|
10
|
+
*/
|
|
11
|
+
export class BackgroundProcessRegistry {
|
|
12
|
+
static instance;
|
|
13
|
+
processes = new Map();
|
|
14
|
+
emitter = new EventEmitter();
|
|
15
|
+
constructor() { }
|
|
16
|
+
static getInstance() {
|
|
17
|
+
if (!BackgroundProcessRegistry.instance) {
|
|
18
|
+
BackgroundProcessRegistry.instance = new BackgroundProcessRegistry();
|
|
19
|
+
}
|
|
20
|
+
return BackgroundProcessRegistry.instance;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Register a background process
|
|
24
|
+
*/
|
|
25
|
+
registerProcess(shellId, pid, command, process) {
|
|
26
|
+
const bgProcess = {
|
|
27
|
+
shellId,
|
|
28
|
+
pid,
|
|
29
|
+
command,
|
|
30
|
+
startTime: new Date(),
|
|
31
|
+
process,
|
|
32
|
+
output: [],
|
|
33
|
+
exitCode: null,
|
|
34
|
+
isRunning: true,
|
|
35
|
+
};
|
|
36
|
+
this.processes.set(shellId, bgProcess);
|
|
37
|
+
// Monitor process output if available
|
|
38
|
+
if (process && process.stdout) {
|
|
39
|
+
process.stdout.on('data', (data) => {
|
|
40
|
+
const lines = data.toString().split('\n').filter((l) => l.trim());
|
|
41
|
+
bgProcess.output.push(...lines);
|
|
42
|
+
this.emitter.emit('output', shellId, lines);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (process && process.stderr) {
|
|
46
|
+
process.stderr.on('data', (data) => {
|
|
47
|
+
const lines = data.toString().split('\n').filter((l) => l.trim());
|
|
48
|
+
bgProcess.output.push(...lines);
|
|
49
|
+
this.emitter.emit('output', shellId, lines);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Monitor process exit
|
|
53
|
+
if (process) {
|
|
54
|
+
process.on('exit', (code) => {
|
|
55
|
+
bgProcess.exitCode = code;
|
|
56
|
+
bgProcess.isRunning = false;
|
|
57
|
+
this.emitter.emit('exit', shellId, code);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get a background process by shell ID
|
|
63
|
+
*/
|
|
64
|
+
getProcess(shellId) {
|
|
65
|
+
return this.processes.get(shellId);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get all background processes
|
|
69
|
+
*/
|
|
70
|
+
getAllProcesses() {
|
|
71
|
+
return Array.from(this.processes.values());
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get output for a process
|
|
75
|
+
*/
|
|
76
|
+
getOutput(shellId, fromLine = 0) {
|
|
77
|
+
const process = this.processes.get(shellId);
|
|
78
|
+
if (!process) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return process.output.slice(fromLine);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Kill a background process
|
|
85
|
+
*/
|
|
86
|
+
killProcess(shellId) {
|
|
87
|
+
const process = this.processes.get(shellId);
|
|
88
|
+
if (!process) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (process.process && process.isRunning) {
|
|
92
|
+
try {
|
|
93
|
+
process.process.kill('SIGTERM');
|
|
94
|
+
process.isRunning = false;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// If no process handle, try to kill by PID directly using Node.js process API
|
|
102
|
+
if (process.isRunning && process.pid) {
|
|
103
|
+
try {
|
|
104
|
+
// Use Node.js global process.kill()
|
|
105
|
+
global.process.kill(process.pid, 'SIGTERM');
|
|
106
|
+
process.isRunning = false;
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Remove a process from the registry
|
|
117
|
+
*/
|
|
118
|
+
removeProcess(shellId) {
|
|
119
|
+
return this.processes.delete(shellId);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Clear all processes (for testing)
|
|
123
|
+
*/
|
|
124
|
+
clear() {
|
|
125
|
+
this.processes.clear();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Check if a process exists
|
|
129
|
+
*/
|
|
130
|
+
hasProcess(shellId) {
|
|
131
|
+
return this.processes.has(shellId);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get process count
|
|
135
|
+
*/
|
|
136
|
+
getProcessCount() {
|
|
137
|
+
return this.processes.size;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Subscribe to process events
|
|
141
|
+
*/
|
|
142
|
+
on(event, callback) {
|
|
143
|
+
this.emitter.on(event, callback);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=BackgroundProcessRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BackgroundProcessRegistry.js","sourceRoot":"","sources":["../../../src/implementations/execution/BackgroundProcessRegistry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAatC;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAC5B,MAAM,CAAC,QAAQ,CAA4B;IAC3C,SAAS,GAAmC,IAAI,GAAG,EAAE,CAAC;IACtD,OAAO,GAAiB,IAAI,YAAY,EAAE,CAAC;IAEnD,gBAAuB,CAAC;IAExB,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,yBAAyB,CAAC,QAAQ,EAAE,CAAC;YACxC,yBAAyB,CAAC,QAAQ,GAAG,IAAI,yBAAyB,EAAE,CAAC;QACvE,CAAC;QACD,OAAO,yBAAyB,CAAC,QAAQ,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,OAAe,EAAE,GAAW,EAAE,OAAe,EAAE,OAAsB;QACnF,MAAM,SAAS,GAAsB;YACnC,OAAO;YACP,GAAG;YACH,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO;YACP,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;SAChB,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEvC,sCAAsC;QACtC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAC9B,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;gBACzC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC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AAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,OAAe;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAe;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,EAAE,CAAC,KAAwB,EAAE,QAAkC;QAC7D,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BashOutput Tool Executor
|
|
3
|
+
*
|
|
4
|
+
* Retrieves output from background shell processes started by ShellTool.
|
|
5
|
+
* Uses BackgroundProcessRegistry to track and read process output.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Gemini CLI bash-output functionality
|
|
8
|
+
*/
|
|
9
|
+
import { BaseTool, type ToolResult } from '../../base/index.js';
|
|
10
|
+
import type { ExecutorConfig } from '../../base/ToolRegistry.js';
|
|
11
|
+
/**
|
|
12
|
+
* Parameters for the BashOutput tool
|
|
13
|
+
*/
|
|
14
|
+
export interface BashOutputToolParams {
|
|
15
|
+
/**
|
|
16
|
+
* The shell ID of the background process
|
|
17
|
+
*/
|
|
18
|
+
bash_id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional regex filter to show only matching lines
|
|
21
|
+
*/
|
|
22
|
+
filter?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* BashOutput Tool Executor
|
|
26
|
+
*
|
|
27
|
+
* Features:
|
|
28
|
+
* - Retrieves output from background shell processes
|
|
29
|
+
* - Optional regex filtering of output lines
|
|
30
|
+
* - Returns new output since last check
|
|
31
|
+
* - Shows process status (running/exited)
|
|
32
|
+
*/
|
|
33
|
+
export declare class BashOutputTool extends BaseTool<BashOutputToolParams, ToolResult> {
|
|
34
|
+
private config;
|
|
35
|
+
private registry;
|
|
36
|
+
private lastReadLine;
|
|
37
|
+
constructor(config: ExecutorConfig);
|
|
38
|
+
validateToolParams(params: BashOutputToolParams): string | null;
|
|
39
|
+
getDescription(params: BashOutputToolParams): string;
|
|
40
|
+
execute(params: BashOutputToolParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<ToolResult>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=BashOutputTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BashOutputTool.d.ts","sourceRoot":"","sources":["../../../src/implementations/execution/BashOutputTool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGjE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,QAAQ,CAAC,oBAAoB,EAAE,UAAU,CAAC;IAIhE,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,YAAY,CAAkC;gBAElC,MAAM,EAAE,cAAc;IAyB1C,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI;IAwB/D,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM;IAI9C,OAAO,CACX,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,WAAW,EACnB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC,UAAU,CAAC;CAiHvB"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BashOutput Tool Executor
|
|
3
|
+
*
|
|
4
|
+
* Retrieves output from background shell processes started by ShellTool.
|
|
5
|
+
* Uses BackgroundProcessRegistry to track and read process output.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Gemini CLI bash-output functionality
|
|
8
|
+
*/
|
|
9
|
+
import { BaseTool } from '../../base/index.js';
|
|
10
|
+
import { SchemaValidator } from '../../utils/SchemaValidator.js';
|
|
11
|
+
import { BackgroundProcessRegistry } from './BackgroundProcessRegistry.js';
|
|
12
|
+
/**
|
|
13
|
+
* BashOutput Tool Executor
|
|
14
|
+
*
|
|
15
|
+
* Features:
|
|
16
|
+
* - Retrieves output from background shell processes
|
|
17
|
+
* - Optional regex filtering of output lines
|
|
18
|
+
* - Returns new output since last check
|
|
19
|
+
* - Shows process status (running/exited)
|
|
20
|
+
*/
|
|
21
|
+
export class BashOutputTool extends BaseTool {
|
|
22
|
+
config;
|
|
23
|
+
registry;
|
|
24
|
+
lastReadLine = new Map();
|
|
25
|
+
constructor(config) {
|
|
26
|
+
super('BashOutput', 'BashOutput', `Retrieves output from a running or completed background bash shell. Returns stdout and stderr output along with shell status. Always returns only new output since the last check.`, {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
bash_id: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'The ID of the background shell to retrieve output from',
|
|
32
|
+
},
|
|
33
|
+
filter: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'Optional regular expression to filter the output lines. Only lines matching this regex will be included in the result.',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['bash_id'],
|
|
39
|
+
});
|
|
40
|
+
this.config = config;
|
|
41
|
+
this.registry = BackgroundProcessRegistry.getInstance();
|
|
42
|
+
}
|
|
43
|
+
validateToolParams(params) {
|
|
44
|
+
// Schema validation
|
|
45
|
+
const schemaError = SchemaValidator.validate(this.parameterSchema, params);
|
|
46
|
+
if (schemaError) {
|
|
47
|
+
return schemaError;
|
|
48
|
+
}
|
|
49
|
+
// Validate bash_id is not empty
|
|
50
|
+
if (!params.bash_id || !params.bash_id.trim()) {
|
|
51
|
+
return "The 'bash_id' parameter cannot be empty.";
|
|
52
|
+
}
|
|
53
|
+
// Validate filter regex if provided
|
|
54
|
+
if (params.filter) {
|
|
55
|
+
try {
|
|
56
|
+
new RegExp(params.filter);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return `Invalid filter regex: ${error.message}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
getDescription(params) {
|
|
65
|
+
return `Retrieving output from background shell: ${params.bash_id}`;
|
|
66
|
+
}
|
|
67
|
+
async execute(params, signal, updateOutput) {
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
try {
|
|
70
|
+
// Validate parameters
|
|
71
|
+
const validationError = this.validateToolParams(params);
|
|
72
|
+
if (validationError) {
|
|
73
|
+
return {
|
|
74
|
+
...this.createErrorResult(validationError),
|
|
75
|
+
metadata: {
|
|
76
|
+
executionTime: Date.now() - startTime,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Check if process exists
|
|
81
|
+
const process = this.registry.getProcess(params.bash_id);
|
|
82
|
+
if (!process) {
|
|
83
|
+
return {
|
|
84
|
+
...this.createErrorResult(`Background shell '${params.bash_id}' not found. It may have already exited and been removed from the registry.`),
|
|
85
|
+
metadata: {
|
|
86
|
+
executionTime: Date.now() - startTime,
|
|
87
|
+
bash_id: params.bash_id,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// Get last read line for this shell
|
|
92
|
+
const lastLine = this.lastReadLine.get(params.bash_id) || 0;
|
|
93
|
+
// Get new output since last check
|
|
94
|
+
let newOutput = this.registry.getOutput(params.bash_id, lastLine);
|
|
95
|
+
// Update last read line
|
|
96
|
+
this.lastReadLine.set(params.bash_id, process.output.length);
|
|
97
|
+
// Apply filter if provided
|
|
98
|
+
if (params.filter && newOutput.length > 0) {
|
|
99
|
+
try {
|
|
100
|
+
const regex = new RegExp(params.filter);
|
|
101
|
+
newOutput = newOutput.filter((line) => regex.test(line));
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// Should not happen due to validation, but handle gracefully
|
|
105
|
+
return {
|
|
106
|
+
...this.createErrorResult(`Filter regex error: ${error.message}`),
|
|
107
|
+
metadata: {
|
|
108
|
+
executionTime: Date.now() - startTime,
|
|
109
|
+
bash_id: params.bash_id,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Format output
|
|
115
|
+
const outputText = newOutput.length > 0 ? newOutput.join('\n') + '\n' : '(no new output)';
|
|
116
|
+
// Build status info
|
|
117
|
+
const statusLines = [];
|
|
118
|
+
statusLines.push(`Shell ID: ${params.bash_id}`);
|
|
119
|
+
statusLines.push(`PID: ${process.pid}`);
|
|
120
|
+
statusLines.push(`Status: ${process.isRunning ? 'Running' : 'Exited'}`);
|
|
121
|
+
if (process.exitCode !== null) {
|
|
122
|
+
statusLines.push(`Exit Code: ${process.exitCode}`);
|
|
123
|
+
}
|
|
124
|
+
statusLines.push(`Command: ${process.command}`);
|
|
125
|
+
statusLines.push(`Started: ${process.startTime.toISOString()}`);
|
|
126
|
+
statusLines.push(`New Lines: ${newOutput.length} (Total: ${process.output.length}, Last Read: ${lastLine})`);
|
|
127
|
+
if (params.filter) {
|
|
128
|
+
statusLines.push(`Filter: ${params.filter}`);
|
|
129
|
+
}
|
|
130
|
+
const fullOutput = `${statusLines.join('\n')}\n\n=== Output ===\n${outputText}`;
|
|
131
|
+
return {
|
|
132
|
+
...this.createSuccessResult(fullOutput),
|
|
133
|
+
metadata: {
|
|
134
|
+
executionTime: Date.now() - startTime,
|
|
135
|
+
bash_id: params.bash_id,
|
|
136
|
+
pid: process.pid,
|
|
137
|
+
isRunning: process.isRunning,
|
|
138
|
+
exitCode: process.exitCode,
|
|
139
|
+
newLinesCount: newOutput.length,
|
|
140
|
+
totalLinesCount: process.output.length,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
// Check for abort
|
|
146
|
+
if (signal.aborted) {
|
|
147
|
+
return {
|
|
148
|
+
...this.createErrorResult('Output retrieval was cancelled'),
|
|
149
|
+
metadata: {
|
|
150
|
+
executionTime: Date.now() - startTime,
|
|
151
|
+
bash_id: params.bash_id,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// Handle errors
|
|
156
|
+
const errorMessage = error.message || String(error);
|
|
157
|
+
return {
|
|
158
|
+
...this.createErrorResult(`Error retrieving shell output: ${errorMessage}`),
|
|
159
|
+
metadata: {
|
|
160
|
+
executionTime: Date.now() - startTime,
|
|
161
|
+
bash_id: params.bash_id,
|
|
162
|
+
error: errorMessage,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=BashOutputTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BashOutputTool.js","sourceRoot":"","sources":["../../../src/implementations/execution/BashOutputTool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAmB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAiB3E;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,QAA0C;IAIxD;IAHZ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AAO;gBACL,GAAG,IAAI,CAAC,iBAAiB,CAAC,kCAAkC,YAAY,EAAE,CAAC;gBAC3E,QAAQ,EAAE;oBACR,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;oBACrC,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,KAAK,EAAE,YAAY;iBACpB;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Execute Tool
|
|
3
|
+
*
|
|
4
|
+
* Executes JavaScript code in a Node.js child process with injected
|
|
5
|
+
* tool-calling globals. Enables non-PTC models to chain multiple tool
|
|
6
|
+
* calls in a single turn — only console.log() output enters context.
|
|
7
|
+
*
|
|
8
|
+
* Similar to Anthropic PTC but runs locally in Node.js instead of
|
|
9
|
+
* Anthropic's Python sandbox.
|
|
10
|
+
*/
|
|
11
|
+
import { BaseTool, type ToolResult } from '../../base/index.js';
|
|
12
|
+
export interface CodeExecuteParams {
|
|
13
|
+
/** JavaScript code to execute (top-level await supported via async wrapper) */
|
|
14
|
+
code: string;
|
|
15
|
+
/** Execution timeout in ms (default 5000, max 30000) */
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Code execution tool for token-efficient tool chaining.
|
|
20
|
+
*
|
|
21
|
+
* The agent writes JavaScript that can call tools via injected globals.
|
|
22
|
+
* Only console.log() output is captured and returned as the tool result.
|
|
23
|
+
*/
|
|
24
|
+
export declare class CodeExecuteTool extends BaseTool<CodeExecuteParams> {
|
|
25
|
+
constructor();
|
|
26
|
+
validateToolParams(params: CodeExecuteParams): string | null;
|
|
27
|
+
execute(params: CodeExecuteParams, signal: AbortSignal): Promise<ToolResult>;
|
|
28
|
+
private runNodeProcess;
|
|
29
|
+
shouldConfirmExecute(params: CodeExecuteParams): Promise<false | import('../../base/ToolResult.js').ToolCallConfirmationDetails>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=CodeExecuteTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeExecuteTool.d.ts","sourceRoot":"","sources":["../../../src/implementations/execution/CodeExecuteTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAYhE,MAAM,WAAW,iBAAiB;IAChC,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,QAAQ,CAAC,iBAAiB,CAAC;;IAuB9D,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI;IAStD,OAAO,CACX,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,CAAC;IA+BtB,OAAO,CAAC,cAAc;IAsDhB,oBAAoB,CACxB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,KAAK,GAAG,OAAO,0BAA0B,EAAE,2BAA2B,CAAC;CASnF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Execute Tool
|
|
3
|
+
*
|
|
4
|
+
* Executes JavaScript code in a Node.js child process with injected
|
|
5
|
+
* tool-calling globals. Enables non-PTC models to chain multiple tool
|
|
6
|
+
* calls in a single turn — only console.log() output enters context.
|
|
7
|
+
*
|
|
8
|
+
* Similar to Anthropic PTC but runs locally in Node.js instead of
|
|
9
|
+
* Anthropic's Python sandbox.
|
|
10
|
+
*/
|
|
11
|
+
import { spawn } from 'child_process';
|
|
12
|
+
import { BaseTool } from '../../base/index.js';
|
|
13
|
+
import { SchemaValidator } from '../../utils/SchemaValidator.js';
|
|
14
|
+
/** Maximum output length (30KB) */
|
|
15
|
+
const MAX_OUTPUT_LENGTH = 30_000;
|
|
16
|
+
/** Default execution timeout in ms */
|
|
17
|
+
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
18
|
+
/** Maximum allowed timeout */
|
|
19
|
+
const MAX_TIMEOUT_MS = 30_000;
|
|
20
|
+
/**
|
|
21
|
+
* Code execution tool for token-efficient tool chaining.
|
|
22
|
+
*
|
|
23
|
+
* The agent writes JavaScript that can call tools via injected globals.
|
|
24
|
+
* Only console.log() output is captured and returned as the tool result.
|
|
25
|
+
*/
|
|
26
|
+
export class CodeExecuteTool extends BaseTool {
|
|
27
|
+
constructor() {
|
|
28
|
+
super('CodeExecute', 'Code Execute', 'Execute JavaScript code for token-efficient tool chaining. Only console.log() output enters context.', {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
code: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'JavaScript code to execute. Top-level await supported. Use console.log() to output results.',
|
|
34
|
+
},
|
|
35
|
+
timeout: {
|
|
36
|
+
type: 'number',
|
|
37
|
+
description: 'Execution timeout in ms (default 5000, max 30000)',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ['code'],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
validateToolParams(params) {
|
|
44
|
+
const error = SchemaValidator.validate(this.parameterSchema, params);
|
|
45
|
+
if (error)
|
|
46
|
+
return error;
|
|
47
|
+
if (!params.code || typeof params.code !== 'string') {
|
|
48
|
+
return '"code" parameter is required and must be a string';
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
async execute(params, signal) {
|
|
53
|
+
if (signal.aborted) {
|
|
54
|
+
return { llmContent: 'Aborted', success: false, error: 'Aborted' };
|
|
55
|
+
}
|
|
56
|
+
const timeout = Math.min(Math.max(params.timeout ?? DEFAULT_TIMEOUT_MS, 100), MAX_TIMEOUT_MS);
|
|
57
|
+
// Wrap user code in async IIFE for top-level await
|
|
58
|
+
const wrappedCode = `
|
|
59
|
+
(async () => {
|
|
60
|
+
try {
|
|
61
|
+
${params.code}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error('Error:', e.message || e);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
`;
|
|
68
|
+
try {
|
|
69
|
+
const result = await this.runNodeProcess(wrappedCode, timeout, signal);
|
|
70
|
+
return { llmContent: result, success: true };
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
74
|
+
return { llmContent: `Error: ${msg}`, success: false, error: msg };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
runNodeProcess(code, timeout, signal) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const proc = spawn('node', ['-e', code], {
|
|
80
|
+
timeout,
|
|
81
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
82
|
+
env: { ...process.env, NODE_NO_WARNINGS: '1' },
|
|
83
|
+
});
|
|
84
|
+
let stdout = '';
|
|
85
|
+
let stderr = '';
|
|
86
|
+
proc.stdout.on('data', (chunk) => {
|
|
87
|
+
stdout += chunk.toString();
|
|
88
|
+
if (stdout.length > MAX_OUTPUT_LENGTH) {
|
|
89
|
+
proc.kill();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
proc.stderr.on('data', (chunk) => {
|
|
93
|
+
stderr += chunk.toString();
|
|
94
|
+
});
|
|
95
|
+
const onAbort = () => {
|
|
96
|
+
proc.kill();
|
|
97
|
+
reject(new Error('Aborted'));
|
|
98
|
+
};
|
|
99
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
100
|
+
proc.on('close', (exitCode) => {
|
|
101
|
+
signal.removeEventListener('abort', onAbort);
|
|
102
|
+
let output = stdout;
|
|
103
|
+
if (output.length > MAX_OUTPUT_LENGTH) {
|
|
104
|
+
output = output.slice(0, MAX_OUTPUT_LENGTH) + '\n[output truncated]';
|
|
105
|
+
}
|
|
106
|
+
if (exitCode !== 0 && stderr) {
|
|
107
|
+
output += (output ? '\n' : '') + stderr;
|
|
108
|
+
}
|
|
109
|
+
resolve(output || '(no output)');
|
|
110
|
+
});
|
|
111
|
+
proc.on('error', (err) => {
|
|
112
|
+
signal.removeEventListener('abort', onAbort);
|
|
113
|
+
reject(err);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async shouldConfirmExecute(params) {
|
|
118
|
+
// Always require user approval (graylist)
|
|
119
|
+
return {
|
|
120
|
+
description: `Execute code: ${params.code.slice(0, 100)}${params.code.length > 100 ? '...' : ''}`,
|
|
121
|
+
requiresConfirmation: true,
|
|
122
|
+
severity: 'warning',
|
|
123
|
+
context: 'Code execution requires user approval',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=CodeExecuteTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeExecuteTool.js","sourceRoot":"","sources":["../../../src/implementations/execution/CodeExecuteTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAmB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,mCAAmC;AACnC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,sCAAsC;AACtC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,8BAA8B;AAC9B,MAAM,cAAc,GAAG,MAAM,CAAC;AAS9B;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,QAA2B;IAC9D;QACE,KAAK,CACH,aAAa,EACb,cAAc,EACd,sGAAsG,EACtG;YACE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6FAA6F;iBAC3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@@
|
|
|
1
|
+
/**
|
|
2
|
+
* KillShell Tool Executor
|
|
3
|
+
*
|
|
4
|
+
* Terminates background shell processes started by ShellTool.
|
|
5
|
+
* Uses BackgroundProcessRegistry to track and kill processes.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Gemini CLI kill-shell functionality
|
|
8
|
+
*/
|
|
9
|
+
import { BaseTool, type ToolResult } from '../../base/index.js';
|
|
10
|
+
import type { ExecutorConfig } from '../../base/ToolRegistry.js';
|
|
11
|
+
/**
|
|
12
|
+
* Parameters for the KillShell tool
|
|
13
|
+
*/
|
|
14
|
+
export interface KillShellToolParams {
|
|
15
|
+
/**
|
|
16
|
+
* The shell ID of the background process to kill
|
|
17
|
+
*/
|
|
18
|
+
shell_id: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* KillShell Tool Executor
|
|
22
|
+
*
|
|
23
|
+
* Features:
|
|
24
|
+
* - Terminates background shell processes by shell ID
|
|
25
|
+
* - Sends SIGTERM signal to process
|
|
26
|
+
* - Returns success/failure status
|
|
27
|
+
* - Removes terminated process from registry
|
|
28
|
+
*/
|
|
29
|
+
export declare class KillShellTool extends BaseTool<KillShellToolParams, ToolResult> {
|
|
30
|
+
private config;
|
|
31
|
+
private registry;
|
|
32
|
+
constructor(config: ExecutorConfig);
|
|
33
|
+
validateToolParams(params: KillShellToolParams): string | null;
|
|
34
|
+
getDescription(params: KillShellToolParams): string;
|
|
35
|
+
execute(params: KillShellToolParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<ToolResult>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=KillShellTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KillShellTool.d.ts","sourceRoot":"","sources":["../../../src/implementations/execution/KillShellTool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGjE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,QAAQ,CAAC,mBAAmB,EAAE,UAAU,CAAC;IAG9D,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,QAAQ,CAA4B;gBAExB,MAAM,EAAE,cAAc;IAoB1C,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI;IAe9D,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM;IAI7C,OAAO,CACX,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,WAAW,EACnB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC,UAAU,CAAC;CAwGvB"}
|