@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,484 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebFetch Tool Executor
|
|
3
|
+
*
|
|
4
|
+
* Processes content from URLs embedded in a prompt using Gemini API's built-in urlContext tool.
|
|
5
|
+
* Includes fallback to local fetch + html-to-text for private IPs and failed requests.
|
|
6
|
+
*
|
|
7
|
+
* Based on Gemini CLI web-fetch.ts implementation
|
|
8
|
+
* Uses FREE Gemini API built-in tools with automatic fallback
|
|
9
|
+
*/
|
|
10
|
+
import { GoogleGenAI } from '@google/genai';
|
|
11
|
+
import { convert } from 'html-to-text';
|
|
12
|
+
import { BaseTool } from '../../base/index.js';
|
|
13
|
+
import { SchemaValidator } from '../../utils/SchemaValidator.js';
|
|
14
|
+
import { resolveProvider, anthropicFetch, xaiFetch, openaiFetch, } from './webBackends.js';
|
|
15
|
+
import { browseEscalationDirective } from './escalateDirective.js';
|
|
16
|
+
import { buildBrowserFetchInit } from './webFetchRequestInit.js';
|
|
17
|
+
// Selected web tools model — read at call time so /set updates apply live.
|
|
18
|
+
// Empty string means "no provider configured" → direct-fetch fallback.
|
|
19
|
+
const getWebToolsModel = () => process.env.WEB_TOOLS_MODEL?.trim() || '';
|
|
20
|
+
// Fetch configuration
|
|
21
|
+
const URL_FETCH_TIMEOUT_MS = 30000; // 30s — gov/county sites are often slow
|
|
22
|
+
const MAX_CONTENT_LENGTH = 100000; // 100,000 characters
|
|
23
|
+
/**
|
|
24
|
+
* WebFetch Tool Executor
|
|
25
|
+
*
|
|
26
|
+
* Features:
|
|
27
|
+
* - Uses Gemini API urlContext built-in tool (FREE)
|
|
28
|
+
* - Automatic grounding metadata with source attribution
|
|
29
|
+
* - UTF-8 byte-accurate citation insertion
|
|
30
|
+
* - Fallback to local fetch + html-to-text for:
|
|
31
|
+
* - Private IPs (localhost, 192.168.x.x, etc.)
|
|
32
|
+
* - Failed URL retrievals
|
|
33
|
+
* - GitHub blob URL → raw URL conversion
|
|
34
|
+
* - HTML to text conversion
|
|
35
|
+
*/
|
|
36
|
+
export class WebFetchTool extends BaseTool {
|
|
37
|
+
config;
|
|
38
|
+
genAI = null;
|
|
39
|
+
constructor(config) {
|
|
40
|
+
super('WebFetch', 'WebFetch', `Processes content from URL(s), including local and private network addresses (e.g., localhost), embedded in a prompt.
|
|
41
|
+
|
|
42
|
+
Include up to 20 URLs and instructions directly in the 'prompt' parameter. The tool fetches and processes the content, returning structured information with citations.`, {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
prompt: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: 'A comprehensive prompt that includes the URL(s) (up to 20) to fetch and specific instructions on how to process their content (e.g., "Summarize https://example.com/article and extract key points from https://another.com/data"). All URLs must be valid and complete, starting with "http://" or "https://".',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ['prompt'],
|
|
51
|
+
});
|
|
52
|
+
this.config = config;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Initialize Gemini API client
|
|
56
|
+
*/
|
|
57
|
+
getGeminiClient() {
|
|
58
|
+
if (!this.genAI) {
|
|
59
|
+
const apiKey = process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY;
|
|
60
|
+
if (!apiKey) {
|
|
61
|
+
throw new Error('Google API key not found. Please set GEMINI_API_KEY or GOOGLE_API_KEY environment variable.');
|
|
62
|
+
}
|
|
63
|
+
this.genAI = new GoogleGenAI({ apiKey });
|
|
64
|
+
}
|
|
65
|
+
return this.genAI;
|
|
66
|
+
}
|
|
67
|
+
validateToolParams(params) {
|
|
68
|
+
// Models frequently send { url: "...", prompt: "instructions" } instead of
|
|
69
|
+
// embedding the URL in the prompt string. Merge url into prompt so
|
|
70
|
+
// downstream parsing and provider dispatch see it.
|
|
71
|
+
const extra = params.url;
|
|
72
|
+
if (typeof extra === 'string' && extra.trim()) {
|
|
73
|
+
const trimmed = extra.trim();
|
|
74
|
+
if (!params.prompt.includes(trimmed)) {
|
|
75
|
+
params.prompt = `${trimmed} ${params.prompt}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Schema validation
|
|
79
|
+
const schemaError = SchemaValidator.validate(this.parameterSchema, params);
|
|
80
|
+
if (schemaError) {
|
|
81
|
+
return schemaError;
|
|
82
|
+
}
|
|
83
|
+
// Empty prompt check
|
|
84
|
+
if (!params.prompt || params.prompt.trim() === '') {
|
|
85
|
+
return "The 'prompt' parameter cannot be empty and must contain URL(s) and instructions.";
|
|
86
|
+
}
|
|
87
|
+
// Parse and validate URLs
|
|
88
|
+
const { validUrls, errors } = this.parsePrompt(params.prompt);
|
|
89
|
+
if (errors.length > 0) {
|
|
90
|
+
return `Error(s) in prompt URLs:\n- ${errors.join('\n- ')}`;
|
|
91
|
+
}
|
|
92
|
+
if (validUrls.length === 0) {
|
|
93
|
+
return "The 'prompt' must contain at least one valid URL (starting with http:// or https://).";
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
getDescription(params) {
|
|
98
|
+
const displayPrompt = params.prompt.length > 100 ? params.prompt.substring(0, 97) + '...' : params.prompt;
|
|
99
|
+
return `Processing URLs and instructions from prompt: "${displayPrompt}"`;
|
|
100
|
+
}
|
|
101
|
+
async execute(params, signal, updateOutput) {
|
|
102
|
+
const startTime = Date.now();
|
|
103
|
+
try {
|
|
104
|
+
// Validate parameters
|
|
105
|
+
const validationError = this.validateToolParams(params);
|
|
106
|
+
if (validationError) {
|
|
107
|
+
return {
|
|
108
|
+
...this.createErrorResult(validationError),
|
|
109
|
+
metadata: {
|
|
110
|
+
executionTime: Date.now() - startTime,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Parse URLs from prompt
|
|
115
|
+
const { validUrls: urls } = this.parsePrompt(params.prompt);
|
|
116
|
+
// Should not happen due to validation, but check anyway
|
|
117
|
+
if (urls.length === 0) {
|
|
118
|
+
return {
|
|
119
|
+
...this.createErrorResult('No valid URLs found in prompt'),
|
|
120
|
+
metadata: { executionTime: Date.now() - startTime },
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const url = urls[0]; // Primary URL (guaranteed by validation check above)
|
|
124
|
+
// Check for private IP - use direct-fetch fallback immediately (any provider's
|
|
125
|
+
// hosted web tool will refuse to fetch private IPs anyway).
|
|
126
|
+
if (this.isPrivateIp(url)) {
|
|
127
|
+
return await this.executeFallback(params, url, signal, startTime);
|
|
128
|
+
}
|
|
129
|
+
// Provider-native dispatch: Anthropic + XAI go through their server-side
|
|
130
|
+
// web tools. Google Gemini and the no-provider case fall through to the
|
|
131
|
+
// existing urlContext pipeline (with direct-fetch fallback).
|
|
132
|
+
const modelId = getWebToolsModel();
|
|
133
|
+
const provider = resolveProvider(modelId);
|
|
134
|
+
if (provider === 'anthropic' && process.env.ANTHROPIC_API_KEY) {
|
|
135
|
+
try {
|
|
136
|
+
const r = await anthropicFetch(params.prompt, modelId);
|
|
137
|
+
return this.formatBackendResult(r, urls, startTime);
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
console.warn(`[web-tools] anthropic fetch failed: ${err.message}`);
|
|
141
|
+
return await this.executeFallback(params, url, signal, startTime);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (provider === 'xai' && process.env.XAI_API_KEY) {
|
|
145
|
+
try {
|
|
146
|
+
const r = await xaiFetch(params.prompt, modelId);
|
|
147
|
+
return this.formatBackendResult(r, urls, startTime);
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
console.warn(`[web-tools] xai fetch failed: ${err.message}`);
|
|
151
|
+
return await this.executeFallback(params, url, signal, startTime);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (provider === 'openai' && process.env.OPENAI_API_KEY) {
|
|
155
|
+
try {
|
|
156
|
+
const r = await openaiFetch(params.prompt, modelId);
|
|
157
|
+
return this.formatBackendResult(r, urls, startTime);
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
console.warn(`[web-tools] openai fetch failed: ${err.message}`);
|
|
161
|
+
return await this.executeFallback(params, url, signal, startTime);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// No Gemini key + no other provider key → skip Gemini SDK call, go to fallback.
|
|
165
|
+
const hasGeminiKey = !!(process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY);
|
|
166
|
+
if (!hasGeminiKey) {
|
|
167
|
+
return await this.executeFallback(params, url, signal, startTime);
|
|
168
|
+
}
|
|
169
|
+
// Try primary execution with urlContext (Gemini)
|
|
170
|
+
return await this.executePrimary(params, urls, signal, startTime);
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
// Check for abort
|
|
174
|
+
if (signal.aborted) {
|
|
175
|
+
return {
|
|
176
|
+
...this.createErrorResult('Fetch operation was cancelled'),
|
|
177
|
+
metadata: {
|
|
178
|
+
executionTime: Date.now() - startTime,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
// Handle API errors - try fallback
|
|
183
|
+
const { validUrls: urls } = this.parsePrompt(params.prompt);
|
|
184
|
+
if (urls.length > 0 && urls[0]) {
|
|
185
|
+
try {
|
|
186
|
+
return await this.executeFallback(params, urls[0], signal, startTime);
|
|
187
|
+
}
|
|
188
|
+
catch (fallbackError) {
|
|
189
|
+
const errorMessage = fallbackError.message || String(fallbackError);
|
|
190
|
+
return {
|
|
191
|
+
...this.createErrorResult(`Error processing web content: ${errorMessage}\n\n` +
|
|
192
|
+
browseEscalationDirective(urls[0])),
|
|
193
|
+
metadata: {
|
|
194
|
+
executionTime: Date.now() - startTime,
|
|
195
|
+
error: errorMessage,
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const errorMessage = error.message || String(error);
|
|
201
|
+
const { validUrls: failedUrls } = this.parsePrompt(params.prompt);
|
|
202
|
+
return {
|
|
203
|
+
...this.createErrorResult(`Error processing web content: ${errorMessage}\n\n` +
|
|
204
|
+
browseEscalationDirective(failedUrls[0])),
|
|
205
|
+
metadata: {
|
|
206
|
+
executionTime: Date.now() - startTime,
|
|
207
|
+
error: errorMessage,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Format a provider-native backend result into the WebFetch tool result shape.
|
|
214
|
+
*/
|
|
215
|
+
formatBackendResult(r, urls, startTime) {
|
|
216
|
+
let body = r.text;
|
|
217
|
+
if (r.sources.length > 0) {
|
|
218
|
+
const list = r.sources
|
|
219
|
+
.map((s, i) => `[${i + 1}] ${s.title ?? 'Untitled'} (${s.url})`)
|
|
220
|
+
.join('\n');
|
|
221
|
+
body += `\n\nSources:\n${list}`;
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
...this.createSuccessResult(body),
|
|
225
|
+
sources: r.sources.map((s) => ({ web: { title: s.title, uri: s.url } })),
|
|
226
|
+
metadata: {
|
|
227
|
+
executionTime: Date.now() - startTime,
|
|
228
|
+
urls,
|
|
229
|
+
sourceCount: r.sources.length,
|
|
230
|
+
method: 'primary',
|
|
231
|
+
backend: r.backend,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Primary execution using Gemini API urlContext
|
|
237
|
+
*/
|
|
238
|
+
async executePrimary(params, urls, signal, startTime) {
|
|
239
|
+
// Get Gemini client
|
|
240
|
+
const genAI = this.getGeminiClient();
|
|
241
|
+
// Make request with urlContext tool enabled
|
|
242
|
+
const result = await genAI.models.generateContent({
|
|
243
|
+
model: getWebToolsModel(),
|
|
244
|
+
contents: params.prompt,
|
|
245
|
+
config: {
|
|
246
|
+
tools: [{ urlContext: {} }],
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
// Extract response and metadata
|
|
250
|
+
let responseText = result.text || '';
|
|
251
|
+
const candidate = result.candidates?.[0];
|
|
252
|
+
const urlContextMeta = candidate?.urlContextMetadata;
|
|
253
|
+
const groundingMetadata = candidate?.groundingMetadata;
|
|
254
|
+
const sources = groundingMetadata?.groundingChunks;
|
|
255
|
+
const groundingSupports = groundingMetadata?.groundingSupports;
|
|
256
|
+
// Check for processing errors
|
|
257
|
+
let processingError = false;
|
|
258
|
+
if (urlContextMeta?.urlMetadata && urlContextMeta.urlMetadata.length > 0) {
|
|
259
|
+
const allStatuses = urlContextMeta.urlMetadata.map((m) => m.urlRetrievalStatus);
|
|
260
|
+
if (allStatuses.every((s) => s !== 'URL_RETRIEVAL_STATUS_SUCCESS')) {
|
|
261
|
+
processingError = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else if (!responseText.trim() && !sources?.length) {
|
|
265
|
+
processingError = true;
|
|
266
|
+
}
|
|
267
|
+
if (!processingError && !responseText.trim() && (!sources || sources.length === 0)) {
|
|
268
|
+
processingError = true;
|
|
269
|
+
}
|
|
270
|
+
// Fallback if primary failed
|
|
271
|
+
if (processingError) {
|
|
272
|
+
return await this.executeFallback(params, urls[0], signal, startTime);
|
|
273
|
+
}
|
|
274
|
+
// Insert citations (UTF-8 byte-accurate)
|
|
275
|
+
if (groundingSupports && groundingSupports.length > 0) {
|
|
276
|
+
responseText = this.insertCitationsUTF8(responseText, groundingSupports);
|
|
277
|
+
}
|
|
278
|
+
// Append source list
|
|
279
|
+
if (sources && sources.length > 0) {
|
|
280
|
+
const sourceList = sources
|
|
281
|
+
.map((source, index) => {
|
|
282
|
+
const title = source.web?.title || 'Untitled';
|
|
283
|
+
const uri = source.web?.uri || 'Unknown URI';
|
|
284
|
+
return `[${index + 1}] ${title} (${uri})`;
|
|
285
|
+
})
|
|
286
|
+
.join('\n');
|
|
287
|
+
responseText += `\n\nSources:\n${sourceList}`;
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
...this.createSuccessResult(responseText),
|
|
291
|
+
sources,
|
|
292
|
+
metadata: {
|
|
293
|
+
executionTime: Date.now() - startTime,
|
|
294
|
+
urls,
|
|
295
|
+
sourceCount: sources?.length || 0,
|
|
296
|
+
method: 'primary',
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Fallback execution using local fetch + html-to-text
|
|
302
|
+
*/
|
|
303
|
+
async executeFallback(params, url, signal, startTime) {
|
|
304
|
+
// Convert GitHub blob URL to raw URL
|
|
305
|
+
if (url.includes('github.com') && url.includes('/blob/')) {
|
|
306
|
+
url = url.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/');
|
|
307
|
+
}
|
|
308
|
+
// Fetch with timeout
|
|
309
|
+
const controller = new AbortController();
|
|
310
|
+
const timeout = setTimeout(() => controller.abort(), URL_FETCH_TIMEOUT_MS);
|
|
311
|
+
try {
|
|
312
|
+
const response = await fetch(url, buildBrowserFetchInit(controller.signal));
|
|
313
|
+
clearTimeout(timeout);
|
|
314
|
+
if (!response.ok) {
|
|
315
|
+
throw new Error(`Request failed with status code ${response.status} ${response.statusText}`);
|
|
316
|
+
}
|
|
317
|
+
const rawContent = await response.text();
|
|
318
|
+
const contentType = response.headers.get('content-type') || '';
|
|
319
|
+
let textContent;
|
|
320
|
+
// Use html-to-text for HTML content
|
|
321
|
+
if (contentType.toLowerCase().includes('text/html') || contentType === '') {
|
|
322
|
+
textContent = convert(rawContent, {
|
|
323
|
+
wordwrap: false,
|
|
324
|
+
selectors: [
|
|
325
|
+
{ selector: 'a', options: { ignoreHref: true } },
|
|
326
|
+
{ selector: 'img', format: 'skip' },
|
|
327
|
+
],
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
// For other content types (text/plain, JSON, etc.), use raw text
|
|
332
|
+
textContent = rawContent;
|
|
333
|
+
}
|
|
334
|
+
// Truncate to max length
|
|
335
|
+
textContent = textContent.substring(0, MAX_CONTENT_LENGTH);
|
|
336
|
+
// Send to Gemini Flash for processing
|
|
337
|
+
const genAI = this.getGeminiClient();
|
|
338
|
+
const fallbackPrompt = `The user requested the following: "${params.prompt}".
|
|
339
|
+
|
|
340
|
+
I was unable to access the URL directly. Instead, I have fetched the raw content of the page. Please use the following content to answer the request. Do not attempt to access the URL again.
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
${textContent}
|
|
344
|
+
---
|
|
345
|
+
`;
|
|
346
|
+
const result = await genAI.models.generateContent({
|
|
347
|
+
model: getWebToolsModel(),
|
|
348
|
+
contents: fallbackPrompt,
|
|
349
|
+
});
|
|
350
|
+
const resultText = result.text || '';
|
|
351
|
+
return {
|
|
352
|
+
...this.createSuccessResult(resultText),
|
|
353
|
+
metadata: {
|
|
354
|
+
executionTime: Date.now() - startTime,
|
|
355
|
+
url,
|
|
356
|
+
fallback: true,
|
|
357
|
+
method: 'fallback',
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
clearTimeout(timeout);
|
|
363
|
+
throw new Error(`Error during fallback fetch for ${url}: ${error.message}`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Parse URLs from prompt text
|
|
368
|
+
*/
|
|
369
|
+
parsePrompt(text) {
|
|
370
|
+
const tokens = text.split(/\s+/);
|
|
371
|
+
const validUrls = [];
|
|
372
|
+
const errors = [];
|
|
373
|
+
for (const token of tokens) {
|
|
374
|
+
if (!token)
|
|
375
|
+
continue;
|
|
376
|
+
// Heuristic: check for :// in token
|
|
377
|
+
if (token.includes('://')) {
|
|
378
|
+
try {
|
|
379
|
+
const url = new URL(token);
|
|
380
|
+
// Allow only http/https
|
|
381
|
+
if (['http:', 'https:'].includes(url.protocol)) {
|
|
382
|
+
validUrls.push(url.href);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
errors.push(`Unsupported protocol in URL: "${token}". Only http and https are supported.`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
errors.push(`Malformed URL detected: "${token}".`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return { validUrls, errors };
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Check if URL points to a private IP address
|
|
397
|
+
*/
|
|
398
|
+
isPrivateIp(url) {
|
|
399
|
+
try {
|
|
400
|
+
const parsedUrl = new URL(url);
|
|
401
|
+
const hostname = parsedUrl.hostname;
|
|
402
|
+
// Check for localhost
|
|
403
|
+
if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1') {
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
// Check for private IP ranges
|
|
407
|
+
const ipv4Regex = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
408
|
+
const match = hostname.match(ipv4Regex);
|
|
409
|
+
if (match) {
|
|
410
|
+
const parts = match.slice(1).map(Number); // Extract octets
|
|
411
|
+
const [a, b, c, d] = parts;
|
|
412
|
+
// 10.0.0.0/8
|
|
413
|
+
if (a === 10)
|
|
414
|
+
return true;
|
|
415
|
+
// 172.16.0.0/12
|
|
416
|
+
if (a === 172 && b !== undefined && b >= 16 && b <= 31)
|
|
417
|
+
return true;
|
|
418
|
+
// 192.168.0.0/16
|
|
419
|
+
if (a === 192 && b === 168)
|
|
420
|
+
return true;
|
|
421
|
+
// 169.254.0.0/16 (link-local)
|
|
422
|
+
if (a === 169 && b === 254)
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
catch {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Insert citations at UTF-8 byte-accurate positions
|
|
433
|
+
*
|
|
434
|
+
* Gemini API returns byte positions (not character positions) for grounding metadata.
|
|
435
|
+
* This method handles multi-byte UTF-8 characters correctly.
|
|
436
|
+
*
|
|
437
|
+
* @param responseText The response text to insert citations into
|
|
438
|
+
* @param groundingSupports Array of grounding support items with byte positions
|
|
439
|
+
* @returns Text with citations inserted
|
|
440
|
+
*/
|
|
441
|
+
insertCitationsUTF8(responseText, groundingSupports) {
|
|
442
|
+
if (!groundingSupports || groundingSupports.length === 0) {
|
|
443
|
+
return responseText;
|
|
444
|
+
}
|
|
445
|
+
// Collect insertion points
|
|
446
|
+
const insertions = [];
|
|
447
|
+
for (const support of groundingSupports) {
|
|
448
|
+
if (support.segment && support.groundingChunkIndices) {
|
|
449
|
+
const citationMarker = support.groundingChunkIndices
|
|
450
|
+
.map((chunkIndex) => `[${chunkIndex + 1}]`)
|
|
451
|
+
.join('');
|
|
452
|
+
insertions.push({
|
|
453
|
+
index: support.segment.endIndex,
|
|
454
|
+
marker: citationMarker,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
// Sort in descending order to avoid index shifting
|
|
459
|
+
insertions.sort((a, b) => b.index - a.index);
|
|
460
|
+
// Use TextEncoder/TextDecoder for UTF-8 byte manipulation
|
|
461
|
+
const encoder = new TextEncoder();
|
|
462
|
+
const responseBytes = encoder.encode(responseText);
|
|
463
|
+
const parts = [];
|
|
464
|
+
let lastIndex = responseBytes.length;
|
|
465
|
+
for (const ins of insertions) {
|
|
466
|
+
const pos = Math.min(ins.index, lastIndex);
|
|
467
|
+
parts.unshift(responseBytes.subarray(pos, lastIndex)); // Content after marker
|
|
468
|
+
parts.unshift(encoder.encode(ins.marker)); // Marker
|
|
469
|
+
lastIndex = pos;
|
|
470
|
+
}
|
|
471
|
+
parts.unshift(responseBytes.subarray(0, lastIndex)); // Content before first marker
|
|
472
|
+
// Concatenate byte arrays
|
|
473
|
+
const totalLength = parts.reduce((sum, part) => sum + part.length, 0);
|
|
474
|
+
const finalBytes = new Uint8Array(totalLength);
|
|
475
|
+
let offset = 0;
|
|
476
|
+
for (const part of parts) {
|
|
477
|
+
finalBytes.set(part, offset);
|
|
478
|
+
offset += part.length;
|
|
479
|
+
}
|
|
480
|
+
// Decode back to string
|
|
481
|
+
return new TextDecoder().decode(finalBytes);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
//# sourceMappingURL=WebFetchTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebFetchTool.js","sourceRoot":"","sources":["../../../src/implementations/web/WebFetchTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAmB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EACL,eAAe,EACf,cAAc,EACd,QAAQ,EACR,WAAW,GAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,2EAA2E;AAC3E,uEAAuE;AACvE,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,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AAG,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAC3C,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,uBAAuB;YAC9E,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;YACpD,SAAS,GAAG,GAAG,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,8BAA8B;QAEnF,0BAA0B;QAC1B,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC7B,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QACxB,CAAC;QAED,wBAAwB;QACxB,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSearch Tool Executor — multi-provider.
|
|
3
|
+
*
|
|
4
|
+
* Backends (selected by WEB_TOOLS_MODEL env var):
|
|
5
|
+
* - Anthropic Claude → web_search_20250305 server tool
|
|
6
|
+
* - XAI Grok → Responses API web_search server tool
|
|
7
|
+
* - Google Gemini → googleSearch grounding (UTF-8 byte-accurate citations)
|
|
8
|
+
* - DuckDuckGo HTML → fallback when no provider key is available
|
|
9
|
+
*
|
|
10
|
+
* nexus-browser is intentionally not a backend here. It is exposed as a
|
|
11
|
+
* gated MCP server and reached only via the MCP transport.
|
|
12
|
+
*/
|
|
13
|
+
import { BaseTool, type ToolResult } from '../../base/index.js';
|
|
14
|
+
import type { ExecutorConfig } from '../../base/ToolRegistry.js';
|
|
15
|
+
interface GroundingChunkItem {
|
|
16
|
+
web?: {
|
|
17
|
+
uri?: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface WebSearchToolParams {
|
|
22
|
+
/** The search query to find information on the web */
|
|
23
|
+
query: string;
|
|
24
|
+
/**
|
|
25
|
+
* 'fast' (default) → provider-native search via runWebSearch.
|
|
26
|
+
* 'interactive' → dispatch a nexus-browser subagent to search and interact
|
|
27
|
+
* with results pages. Useful when provider-native search misses JS-rendered
|
|
28
|
+
* SPAs or behind-login content.
|
|
29
|
+
*/
|
|
30
|
+
mode?: 'fast' | 'interactive';
|
|
31
|
+
}
|
|
32
|
+
export interface WebSearchToolResult extends ToolResult {
|
|
33
|
+
sources?: GroundingChunkItem[];
|
|
34
|
+
}
|
|
35
|
+
export declare class WebSearchTool extends BaseTool<WebSearchToolParams, WebSearchToolResult> {
|
|
36
|
+
private config;
|
|
37
|
+
private genAI;
|
|
38
|
+
constructor(config: ExecutorConfig);
|
|
39
|
+
private getGeminiClient;
|
|
40
|
+
validateToolParams(params: WebSearchToolParams): string | null;
|
|
41
|
+
getDescription(params: WebSearchToolParams): string;
|
|
42
|
+
execute(params: WebSearchToolParams, signal: AbortSignal): Promise<WebSearchToolResult>;
|
|
43
|
+
private formatBackendOutput;
|
|
44
|
+
private runGeminiSearch;
|
|
45
|
+
/**
|
|
46
|
+
* Insert citations at UTF-8 byte-accurate positions. Gemini grounding
|
|
47
|
+
* metadata uses byte offsets (not character indices), so multi-byte UTF-8
|
|
48
|
+
* characters must be handled via TextEncoder/TextDecoder.
|
|
49
|
+
*/
|
|
50
|
+
private insertCitationsUTF8;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=WebSearchTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSearchTool.d.ts","sourceRoot":"","sources":["../../../src/implementations/web/WebSearchTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAQjE,UAAU,kBAAkB;IAC1B,GAAG,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAaD,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED,qBAAa,aAAc,SAAQ,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAGvE,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,KAAK,CAA4B;gBAErB,MAAM,EAAE,cAAc;IAkC1C,OAAO,CAAC,eAAe;IAavB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI;IAS9D,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM;IAI7C,OAAO,CACX,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,mBAAmB,CAAC;IAwE/B,OAAO,CAAC,mBAAmB;YAWb,eAAe;IAoE7B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CAuC5B"}
|