@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,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChromiumBrowserManager - Robust browser binary discovery for Playwright
|
|
3
|
+
* Handles finding Chromium/Chrome binaries across different environments
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, statSync, readdirSync } from 'fs';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
/**
|
|
8
|
+
* ChromiumBinaryLocator - Robust chromium binary discovery
|
|
9
|
+
* Searches multiple locations with priority order and validation
|
|
10
|
+
*/
|
|
11
|
+
class ChromiumBinaryLocator {
|
|
12
|
+
cachedPath = undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Find chromium binary with comprehensive search
|
|
15
|
+
*/
|
|
16
|
+
findBinary() {
|
|
17
|
+
// 1. Environment variable (highest priority - user override)
|
|
18
|
+
if (process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH) {
|
|
19
|
+
if (this.isExecutable(process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH)) {
|
|
20
|
+
console.log(`[ChromiumManager] Using PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH: ${process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH}`);
|
|
21
|
+
return process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
|
|
22
|
+
}
|
|
23
|
+
console.warn(`[ChromiumManager] PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH set but not executable: ${process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH}`);
|
|
24
|
+
}
|
|
25
|
+
if (process.env.CHROMIUM_BIN) {
|
|
26
|
+
if (this.isExecutable(process.env.CHROMIUM_BIN)) {
|
|
27
|
+
console.log(`[ChromiumManager] Using CHROMIUM_BIN: ${process.env.CHROMIUM_BIN}`);
|
|
28
|
+
return process.env.CHROMIUM_BIN;
|
|
29
|
+
}
|
|
30
|
+
console.warn(`[ChromiumManager] CHROMIUM_BIN set but not executable: ${process.env.CHROMIUM_BIN}`);
|
|
31
|
+
}
|
|
32
|
+
// 2. Nix store - search for chromium directories
|
|
33
|
+
try {
|
|
34
|
+
const nixStorePath = '/nix/store';
|
|
35
|
+
if (existsSync(nixStorePath)) {
|
|
36
|
+
const chromiumPath = this.findChromiumInNixStore(nixStorePath);
|
|
37
|
+
if (chromiumPath) {
|
|
38
|
+
console.log(`[ChromiumManager] Found chromium (nix store): ${chromiumPath}`);
|
|
39
|
+
return chromiumPath;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.warn(`[ChromiumManager] Error searching nix store:`, error);
|
|
45
|
+
}
|
|
46
|
+
// 3. Nix profile locations (common on Replit, NixOS)
|
|
47
|
+
const homeDir = process.env.HOME;
|
|
48
|
+
if (homeDir) {
|
|
49
|
+
const nixPaths = [
|
|
50
|
+
join(homeDir, '.nix-profile/bin/chromium'),
|
|
51
|
+
join(homeDir, '.nix-profile/bin/chromium-browser'),
|
|
52
|
+
join(homeDir, '.local/state/nix/profiles/profile/bin/chromium'),
|
|
53
|
+
];
|
|
54
|
+
for (const path of nixPaths) {
|
|
55
|
+
if (this.isExecutable(path)) {
|
|
56
|
+
console.log(`[ChromiumManager] Found chromium (nix profile): ${path}`);
|
|
57
|
+
return path;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// 4. System-wide nix locations
|
|
62
|
+
const systemNixPaths = [
|
|
63
|
+
'/nix/var/nix/profiles/default/bin/chromium',
|
|
64
|
+
'/run/current-system/sw/bin/chromium',
|
|
65
|
+
];
|
|
66
|
+
for (const path of systemNixPaths) {
|
|
67
|
+
if (this.isExecutable(path)) {
|
|
68
|
+
console.log(`[ChromiumManager] Found chromium (system nix): ${path}`);
|
|
69
|
+
return path;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// 5. Standard Chrome/Chromium system paths
|
|
73
|
+
const systemPaths = [
|
|
74
|
+
'/usr/bin/chromium',
|
|
75
|
+
'/usr/bin/chromium-browser',
|
|
76
|
+
'/usr/bin/google-chrome',
|
|
77
|
+
'/usr/bin/google-chrome-stable',
|
|
78
|
+
'/usr/local/bin/chromium',
|
|
79
|
+
'/opt/google/chrome/chrome',
|
|
80
|
+
'/opt/chromium.org/chromium/chromium',
|
|
81
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', // macOS
|
|
82
|
+
'/Applications/Chromium.app/Contents/MacOS/Chromium', // macOS
|
|
83
|
+
];
|
|
84
|
+
for (const path of systemPaths) {
|
|
85
|
+
if (this.isExecutable(path)) {
|
|
86
|
+
console.log(`[ChromiumManager] Found chromium (system): ${path}`);
|
|
87
|
+
return path;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// 6. Check Playwright's cache (where browsers get installed)
|
|
91
|
+
try {
|
|
92
|
+
const playwrightCachePath = this.findPlaywrightCachedChromium();
|
|
93
|
+
if (playwrightCachePath) {
|
|
94
|
+
console.log(`[ChromiumManager] Found chromium (playwright cache): ${playwrightCachePath}`);
|
|
95
|
+
return playwrightCachePath;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.warn(`[ChromiumManager] Error searching playwright cache:`, error);
|
|
100
|
+
}
|
|
101
|
+
// 7. Return null if nothing found (don't fallback to 'chromium' - be explicit)
|
|
102
|
+
console.warn(`[ChromiumManager] No chromium binary found. Set PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH environment variable or install chromium.`);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Search nix store for chromium binaries
|
|
107
|
+
*/
|
|
108
|
+
findChromiumInNixStore(nixStorePath) {
|
|
109
|
+
try {
|
|
110
|
+
const entries = readdirSync(nixStorePath);
|
|
111
|
+
// Look for chromium directories (sorted by name to get latest version)
|
|
112
|
+
const chromiumDirs = entries
|
|
113
|
+
.filter(name => name.startsWith('chromium-') || name.includes('chromium'))
|
|
114
|
+
.sort()
|
|
115
|
+
.reverse(); // Get latest version first
|
|
116
|
+
for (const dir of chromiumDirs) {
|
|
117
|
+
const chromiumBin = join(nixStorePath, dir, 'bin/chromium');
|
|
118
|
+
if (this.isExecutable(chromiumBin)) {
|
|
119
|
+
return chromiumBin;
|
|
120
|
+
}
|
|
121
|
+
// Also check for chrome-sandbox and chrome binaries
|
|
122
|
+
const chromeBin = join(nixStorePath, dir, 'bin/chrome');
|
|
123
|
+
if (this.isExecutable(chromeBin)) {
|
|
124
|
+
return chromeBin;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
// Directory read error - not a problem, continue searching
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Find chromium in Playwright's cache directory
|
|
135
|
+
*/
|
|
136
|
+
findPlaywrightCachedChromium() {
|
|
137
|
+
const homeDir = process.env.HOME;
|
|
138
|
+
if (!homeDir)
|
|
139
|
+
return null;
|
|
140
|
+
const playwrightPaths = [
|
|
141
|
+
join(homeDir, '.cache/ms-playwright'),
|
|
142
|
+
join(homeDir, 'Library/Caches/ms-playwright'), // macOS
|
|
143
|
+
join(homeDir, 'AppData/Local/ms-playwright'), // Windows
|
|
144
|
+
];
|
|
145
|
+
for (const cachePath of playwrightPaths) {
|
|
146
|
+
if (!existsSync(cachePath))
|
|
147
|
+
continue;
|
|
148
|
+
try {
|
|
149
|
+
const entries = readdirSync(cachePath);
|
|
150
|
+
const chromiumDirs = entries
|
|
151
|
+
.filter(name => name.startsWith('chromium-'))
|
|
152
|
+
.sort()
|
|
153
|
+
.reverse();
|
|
154
|
+
for (const dir of chromiumDirs) {
|
|
155
|
+
// Linux/Windows
|
|
156
|
+
let chromiumBin = join(cachePath, dir, 'chrome-linux/chrome');
|
|
157
|
+
if (this.isExecutable(chromiumBin)) {
|
|
158
|
+
return chromiumBin;
|
|
159
|
+
}
|
|
160
|
+
// macOS
|
|
161
|
+
chromiumBin = join(cachePath, dir, 'chrome-mac/Chromium.app/Contents/MacOS/Chromium');
|
|
162
|
+
if (this.isExecutable(chromiumBin)) {
|
|
163
|
+
return chromiumBin;
|
|
164
|
+
}
|
|
165
|
+
// Windows
|
|
166
|
+
chromiumBin = join(cachePath, dir, 'chrome-win/chrome.exe');
|
|
167
|
+
if (this.isExecutable(chromiumBin)) {
|
|
168
|
+
return chromiumBin;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
// Continue searching
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Check if path is an executable file
|
|
180
|
+
*/
|
|
181
|
+
isExecutable(path) {
|
|
182
|
+
try {
|
|
183
|
+
if (!existsSync(path))
|
|
184
|
+
return false;
|
|
185
|
+
const stats = statSync(path);
|
|
186
|
+
// Check if file and has execute permission
|
|
187
|
+
return stats.isFile() && !!(stats.mode & 0o111);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get chromium binary path (cached)
|
|
195
|
+
*/
|
|
196
|
+
getBinary() {
|
|
197
|
+
if (this.cachedPath === undefined) {
|
|
198
|
+
this.cachedPath = this.findBinary();
|
|
199
|
+
}
|
|
200
|
+
return this.cachedPath;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Clear cached path (for testing)
|
|
204
|
+
*/
|
|
205
|
+
clearCache() {
|
|
206
|
+
this.cachedPath = undefined;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get browser configuration for Playwright
|
|
210
|
+
*/
|
|
211
|
+
getPlaywrightConfig() {
|
|
212
|
+
const binary = this.getBinary();
|
|
213
|
+
if (!binary) {
|
|
214
|
+
throw new Error('Chromium binary not found. Please install chromium or set PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH environment variable.');
|
|
215
|
+
}
|
|
216
|
+
return { executablePath: binary };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Singleton instance
|
|
220
|
+
const locator = new ChromiumBinaryLocator();
|
|
221
|
+
/**
|
|
222
|
+
* Get chromium binary path
|
|
223
|
+
*/
|
|
224
|
+
export function getChromiumBinary() {
|
|
225
|
+
return locator.getBinary();
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get Playwright browser launch configuration
|
|
229
|
+
*/
|
|
230
|
+
export function getPlaywrightConfig() {
|
|
231
|
+
return locator.getPlaywrightConfig();
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Clear cached chromium path (for testing)
|
|
235
|
+
*/
|
|
236
|
+
export function clearChromiumCache() {
|
|
237
|
+
locator.clearCache();
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Export the locator class for advanced usage
|
|
241
|
+
*/
|
|
242
|
+
export { ChromiumBinaryLocator };
|
|
243
|
+
//# sourceMappingURL=ChromiumBrowserManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,mBAAmB;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,qHAAqH,CACtH,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,OAAO,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,OAAO,CAAC,mBAAmB,EAAE,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common file operations and path handling for tool executors
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
/**
|
|
8
|
+
* Check if a path is within a root directory
|
|
9
|
+
*
|
|
10
|
+
* @param filePath Path to check
|
|
11
|
+
* @param rootDir Root directory
|
|
12
|
+
* @returns true if path is within root, false otherwise
|
|
13
|
+
*/
|
|
14
|
+
export declare function isWithinRoot(filePath: string, rootDir: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Make a path relative to a directory
|
|
17
|
+
*
|
|
18
|
+
* @param filePath Absolute path
|
|
19
|
+
* @param baseDir Base directory
|
|
20
|
+
* @returns Relative path
|
|
21
|
+
*/
|
|
22
|
+
export declare function makeRelative(filePath: string, baseDir: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Shorten a path for display
|
|
25
|
+
*
|
|
26
|
+
* @param filePath Path to shorten
|
|
27
|
+
* @param maxLength Maximum length (default: 60)
|
|
28
|
+
* @returns Shortened path
|
|
29
|
+
*/
|
|
30
|
+
export declare function shortenPath(filePath: string, maxLength?: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Read file content with line range support
|
|
33
|
+
*
|
|
34
|
+
* @param filePath Path to file
|
|
35
|
+
* @param offset Line offset (0-based)
|
|
36
|
+
* @param limit Number of lines to read
|
|
37
|
+
* @returns File content
|
|
38
|
+
*/
|
|
39
|
+
export declare function readFileContent(filePath: string, offset?: number, limit?: number): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Get file statistics
|
|
42
|
+
*
|
|
43
|
+
* @param filePath Path to file
|
|
44
|
+
* @returns File stats
|
|
45
|
+
*/
|
|
46
|
+
export declare function getFileStats(filePath: string): Promise<fs.Stats>;
|
|
47
|
+
/**
|
|
48
|
+
* Check if file exists
|
|
49
|
+
*
|
|
50
|
+
* @param filePath Path to file
|
|
51
|
+
* @returns true if exists, false otherwise
|
|
52
|
+
*/
|
|
53
|
+
export declare function fileExists(filePath: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a file path with smart fallback for common model mistakes.
|
|
56
|
+
*
|
|
57
|
+
* When a model passes a relative path that doesn't exist after resolution
|
|
58
|
+
* against the working directory, this tries stripping leading segments that
|
|
59
|
+
* duplicate the working directory name. For example, if workingDirectory is
|
|
60
|
+
* `/home/user/my-project` and the model passes `my-project/src/index.ts`,
|
|
61
|
+
* the naive resolution produces `/home/user/my-project/my-project/src/index.ts`
|
|
62
|
+
* (doesn't exist). The fallback strips the `my-project/` prefix and retries,
|
|
63
|
+
* yielding the correct `/home/user/my-project/src/index.ts`.
|
|
64
|
+
*
|
|
65
|
+
* Only returns a fallback if it (a) exists on disk and (b) passes the
|
|
66
|
+
* security check (within workingDirectory). Otherwise returns the original
|
|
67
|
+
* resolved path so the caller can produce the normal error.
|
|
68
|
+
*
|
|
69
|
+
* @param rawPath The path exactly as the model provided it
|
|
70
|
+
* @param workingDirectory The project root / security boundary
|
|
71
|
+
* @returns The resolved absolute path (fallback-corrected when possible)
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveFilePath(rawPath: string, workingDirectory: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Format file size for display
|
|
76
|
+
*
|
|
77
|
+
* @param bytes File size in bytes
|
|
78
|
+
* @returns Formatted string (e.g., "1.5 KB")
|
|
79
|
+
*/
|
|
80
|
+
export declare function formatFileSize(bytes: number): string;
|
|
81
|
+
//# sourceMappingURL=FileUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUtils.d.ts","sourceRoot":"","sources":["../../src/utils/FileUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAIvE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,CAY5E;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAiCjF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKpD"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common file operations and path handling for tool executors
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
/**
|
|
9
|
+
* Check if a path is within a root directory
|
|
10
|
+
*
|
|
11
|
+
* @param filePath Path to check
|
|
12
|
+
* @param rootDir Root directory
|
|
13
|
+
* @returns true if path is within root, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export function isWithinRoot(filePath, rootDir) {
|
|
16
|
+
const resolved = path.resolve(filePath);
|
|
17
|
+
const root = path.resolve(rootDir);
|
|
18
|
+
return resolved.startsWith(root);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Make a path relative to a directory
|
|
22
|
+
*
|
|
23
|
+
* @param filePath Absolute path
|
|
24
|
+
* @param baseDir Base directory
|
|
25
|
+
* @returns Relative path
|
|
26
|
+
*/
|
|
27
|
+
export function makeRelative(filePath, baseDir) {
|
|
28
|
+
return path.relative(baseDir, filePath);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Shorten a path for display
|
|
32
|
+
*
|
|
33
|
+
* @param filePath Path to shorten
|
|
34
|
+
* @param maxLength Maximum length (default: 60)
|
|
35
|
+
* @returns Shortened path
|
|
36
|
+
*/
|
|
37
|
+
export function shortenPath(filePath, maxLength = 60) {
|
|
38
|
+
if (filePath.length <= maxLength) {
|
|
39
|
+
return filePath;
|
|
40
|
+
}
|
|
41
|
+
const parts = filePath.split(path.sep);
|
|
42
|
+
if (parts.length <= 2) {
|
|
43
|
+
return filePath;
|
|
44
|
+
}
|
|
45
|
+
// Keep first and last parts, abbreviate middle
|
|
46
|
+
return `${parts[0]}${path.sep}...${path.sep}${parts[parts.length - 1]}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read file content with line range support
|
|
50
|
+
*
|
|
51
|
+
* @param filePath Path to file
|
|
52
|
+
* @param offset Line offset (0-based)
|
|
53
|
+
* @param limit Number of lines to read
|
|
54
|
+
* @returns File content
|
|
55
|
+
*/
|
|
56
|
+
export async function readFileContent(filePath, offset, limit) {
|
|
57
|
+
const content = await fs.promises.readFile(filePath, 'utf-8');
|
|
58
|
+
// Return full content if no offset/limit
|
|
59
|
+
if (offset === undefined && limit === undefined) {
|
|
60
|
+
return content;
|
|
61
|
+
}
|
|
62
|
+
// Split into lines
|
|
63
|
+
const lines = content.split('\n');
|
|
64
|
+
// Apply offset and limit
|
|
65
|
+
const startLine = offset || 0;
|
|
66
|
+
const endLine = limit ? startLine + limit : lines.length;
|
|
67
|
+
return lines.slice(startLine, endLine).join('\n');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get file statistics
|
|
71
|
+
*
|
|
72
|
+
* @param filePath Path to file
|
|
73
|
+
* @returns File stats
|
|
74
|
+
*/
|
|
75
|
+
export async function getFileStats(filePath) {
|
|
76
|
+
return fs.promises.stat(filePath);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check if file exists
|
|
80
|
+
*
|
|
81
|
+
* @param filePath Path to file
|
|
82
|
+
* @returns true if exists, false otherwise
|
|
83
|
+
*/
|
|
84
|
+
export function fileExists(filePath) {
|
|
85
|
+
return fs.existsSync(filePath);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolve a file path with smart fallback for common model mistakes.
|
|
89
|
+
*
|
|
90
|
+
* When a model passes a relative path that doesn't exist after resolution
|
|
91
|
+
* against the working directory, this tries stripping leading segments that
|
|
92
|
+
* duplicate the working directory name. For example, if workingDirectory is
|
|
93
|
+
* `/home/user/my-project` and the model passes `my-project/src/index.ts`,
|
|
94
|
+
* the naive resolution produces `/home/user/my-project/my-project/src/index.ts`
|
|
95
|
+
* (doesn't exist). The fallback strips the `my-project/` prefix and retries,
|
|
96
|
+
* yielding the correct `/home/user/my-project/src/index.ts`.
|
|
97
|
+
*
|
|
98
|
+
* Only returns a fallback if it (a) exists on disk and (b) passes the
|
|
99
|
+
* security check (within workingDirectory). Otherwise returns the original
|
|
100
|
+
* resolved path so the caller can produce the normal error.
|
|
101
|
+
*
|
|
102
|
+
* @param rawPath The path exactly as the model provided it
|
|
103
|
+
* @param workingDirectory The project root / security boundary
|
|
104
|
+
* @returns The resolved absolute path (fallback-corrected when possible)
|
|
105
|
+
*/
|
|
106
|
+
export function resolveFilePath(rawPath, workingDirectory) {
|
|
107
|
+
// Normalize double slashes
|
|
108
|
+
let filePath = rawPath.replace(/\/+/g, '/');
|
|
109
|
+
// Already absolute — nothing to resolve
|
|
110
|
+
if (path.isAbsolute(filePath)) {
|
|
111
|
+
return filePath;
|
|
112
|
+
}
|
|
113
|
+
// Standard resolution against working directory
|
|
114
|
+
const resolved = path.resolve(workingDirectory, filePath);
|
|
115
|
+
// If it exists, great — use it
|
|
116
|
+
if (fs.existsSync(resolved)) {
|
|
117
|
+
return resolved;
|
|
118
|
+
}
|
|
119
|
+
// --- Smart fallback: strip leading segments that match the workingDirectory basename ---
|
|
120
|
+
// Handles: "nexus-cortex/packages/core/..." when workingDirectory already IS nexus-cortex
|
|
121
|
+
const dirName = path.basename(workingDirectory);
|
|
122
|
+
const segments = filePath.split('/');
|
|
123
|
+
if (segments[0] === dirName && segments.length > 1) {
|
|
124
|
+
const stripped = segments.slice(1).join('/');
|
|
125
|
+
const fallback = path.resolve(workingDirectory, stripped);
|
|
126
|
+
if (fs.existsSync(fallback) && isWithinRoot(fallback, workingDirectory)) {
|
|
127
|
+
return fallback;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Return original resolution (caller will produce the appropriate error)
|
|
131
|
+
return resolved;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Format file size for display
|
|
135
|
+
*
|
|
136
|
+
* @param bytes File size in bytes
|
|
137
|
+
* @returns Formatted string (e.g., "1.5 KB")
|
|
138
|
+
*/
|
|
139
|
+
export function formatFileSize(bytes) {
|
|
140
|
+
if (bytes < 1024)
|
|
141
|
+
return `${bytes} B`;
|
|
142
|
+
if (bytes < 1024 * 1024)
|
|
143
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
144
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
145
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
146
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=FileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUtils.js","sourceRoot":"","sources":["../../src/utils/FileUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,OAAe;IAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,OAAe;IAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,YAAoB,EAAE;IAClE,IAAI,QAAQ,CAAC,MAAM,IAAI,S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IACzE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClF,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitPolicy — single source of truth for git/PR access control + safe subprocess wiring.
|
|
3
|
+
*
|
|
4
|
+
* Used by PRAgentTool, WorkspaceManagerTool, and the server's /v1/pr/* routes so that
|
|
5
|
+
* repo/action allow-listing, input validation, and token handling are consistent and
|
|
6
|
+
* defined in exactly one place.
|
|
7
|
+
*
|
|
8
|
+
* Security posture:
|
|
9
|
+
* - Validation (repo/branch/prNumber regexes) is ALWAYS enforced — there is no opt-out.
|
|
10
|
+
* Combined with execFile (no shell), this closes the shell/argument-injection class.
|
|
11
|
+
* - The repo/action allow-list is opt-in defense-in-depth. Unset GIT_ALLOWED_REPOS means
|
|
12
|
+
* "allow all" so existing single-user setups keep working after an upgrade;
|
|
13
|
+
* multi-tenant/shared deployments set it to restrict. (No startup warning — the
|
|
14
|
+
* trade-off is documented in .env.example so the TUI/CLI don't print noise on launch.)
|
|
15
|
+
* - The auth token is exposed to gh/git ONLY through the subprocess environment
|
|
16
|
+
* (GH_TOKEN / GITHUB_TOKEN). It is never interpolated into argv or a clone URL.
|
|
17
|
+
*
|
|
18
|
+
* Env vars (see SettingsSchema.ts / .env.example):
|
|
19
|
+
* - GIT_ALLOWED_REPOS comma list of owner/repo, supports `owner/*` and `*`. Default `*`.
|
|
20
|
+
* - GIT_ALLOWED_ACTIONS comma list of actions. Default: all actions allowed.
|
|
21
|
+
* - GIT_AUTH_TOKEN token for gh/git, injected into the subprocess env only.
|
|
22
|
+
* - GIT_HOST GitHub (Enterprise) host, default `github.com`.
|
|
23
|
+
*/
|
|
24
|
+
export type GitAction = 'review' | 'list' | 'create' | 'post-review' | 'clone' | 'worktree' | 'diff' | 'cleanup' | 'status';
|
|
25
|
+
export declare const ALL_GIT_ACTIONS: GitAction[];
|
|
26
|
+
export interface GitPolicyConfig {
|
|
27
|
+
/** Raw GIT_ALLOWED_REPOS value (comma list of owner/repo, `owner/*`, or `*`). */
|
|
28
|
+
allowedRepos?: string;
|
|
29
|
+
/** Raw GIT_ALLOWED_ACTIONS value (comma list). Unset → all actions allowed. */
|
|
30
|
+
allowedActions?: string;
|
|
31
|
+
/** GIT_AUTH_TOKEN — injected into subprocess env as GH_TOKEN/GITHUB_TOKEN. */
|
|
32
|
+
token?: string;
|
|
33
|
+
/** GIT_HOST — GitHub Enterprise host. Default `github.com`. */
|
|
34
|
+
host?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare class GitPolicy {
|
|
37
|
+
/** Parsed allow-list patterns: `*`, `owner/*`, or exact `owner/repo`. */
|
|
38
|
+
private readonly repoPatterns;
|
|
39
|
+
/** Allowed actions, or null when all actions are permitted. */
|
|
40
|
+
private readonly actions;
|
|
41
|
+
readonly token?: string;
|
|
42
|
+
readonly host: string;
|
|
43
|
+
constructor(cfg?: GitPolicyConfig);
|
|
44
|
+
/** Build a policy from environment variables (defaults to process.env). */
|
|
45
|
+
static fromEnv(env?: NodeJS.ProcessEnv): GitPolicy;
|
|
46
|
+
/**
|
|
47
|
+
* Validate a repo string: format first (blocks injection), then the allow-list.
|
|
48
|
+
* Returns an error message, or null when the repo is acceptable.
|
|
49
|
+
*/
|
|
50
|
+
validateRepo(repo: unknown): string | null;
|
|
51
|
+
/** True if the (already format-valid) repo matches the allow-list. */
|
|
52
|
+
isRepoAllowed(repo: string): boolean;
|
|
53
|
+
/** Validate a branch / ref name. Returns an error message or null. */
|
|
54
|
+
validateBranch(name: unknown): string | null;
|
|
55
|
+
/** Validate a PR number (must be a positive integer). Returns an error message or null. */
|
|
56
|
+
validatePrNumber(n: unknown): string | null;
|
|
57
|
+
/** Coerce a validated PR number to an integer (call only after validatePrNumber passes). */
|
|
58
|
+
prNumber(n: unknown): number;
|
|
59
|
+
isActionAllowed(action: GitAction): boolean;
|
|
60
|
+
/** Returns an error message if the action is blocked, else null. */
|
|
61
|
+
assertAction(action: GitAction): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Subprocess environment with the auth token + host injected for gh/git.
|
|
64
|
+
* The token rides in env only — never on argv or in a URL.
|
|
65
|
+
*/
|
|
66
|
+
subprocessEnv(base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
67
|
+
/** HTTPS clone URL for an `owner/repo`, host-aware. No token embedded. */
|
|
68
|
+
cloneUrl(repo: string): string;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=GitPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitPolicy.d.ts","sourceRoot":"","sources":["../../src/utils/GitPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,aAAa,GACb,OAAO,GACP,UAAU,GACV,MAAM,GACN,SAAS,GACT,QAAQ,CAAC;AAEb,eAAO,MAAM,eAAe,EAAE,SAAS,EAUtC,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,YAAY,CAAC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