@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,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionPersistence - Manages tmux session metadata storage
|
|
3
|
+
* Stores session information in .cortex/tmux-sessions/metadata/
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
export class SessionPersistence {
|
|
8
|
+
metadataDir;
|
|
9
|
+
constructor(projectPath) {
|
|
10
|
+
const basePath = projectPath || process.cwd();
|
|
11
|
+
this.metadataDir = path.join(basePath, '.cortex', 'tmux-sessions', 'metadata');
|
|
12
|
+
this.ensureMetadataDir();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Ensure the metadata directory exists
|
|
16
|
+
*/
|
|
17
|
+
ensureMetadataDir() {
|
|
18
|
+
if (!fs.existsSync(this.metadataDir)) {
|
|
19
|
+
fs.mkdirSync(this.metadataDir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the file path for a session's metadata
|
|
24
|
+
*/
|
|
25
|
+
getMetadataPath(sessionId) {
|
|
26
|
+
return path.join(this.metadataDir, `${sessionId}.json`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Save session metadata to disk
|
|
30
|
+
* @param metadata Session metadata to save
|
|
31
|
+
*/
|
|
32
|
+
async saveSession(metadata) {
|
|
33
|
+
try {
|
|
34
|
+
const filePath = this.getMetadataPath(metadata.sessionId);
|
|
35
|
+
const data = JSON.stringify({
|
|
36
|
+
...metadata,
|
|
37
|
+
created: metadata.created.toISOString(),
|
|
38
|
+
lastUsed: metadata.lastUsed.toISOString()
|
|
39
|
+
}, null, 2);
|
|
40
|
+
fs.writeFileSync(filePath, data, 'utf-8');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new Error(`Failed to save session metadata: ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Load session metadata from disk
|
|
48
|
+
* @param sessionId Session identifier
|
|
49
|
+
* @returns Session metadata or null if not found
|
|
50
|
+
*/
|
|
51
|
+
async loadSession(sessionId) {
|
|
52
|
+
try {
|
|
53
|
+
const filePath = this.getMetadataPath(sessionId);
|
|
54
|
+
if (!fs.existsSync(filePath)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const data = fs.readFileSync(filePath, 'utf-8');
|
|
58
|
+
const parsed = JSON.parse(data);
|
|
59
|
+
return {
|
|
60
|
+
...parsed,
|
|
61
|
+
created: new Date(parsed.created),
|
|
62
|
+
lastUsed: new Date(parsed.lastUsed)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw new Error(`Failed to load session metadata: ${error.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Update lastUsed timestamp for a session
|
|
71
|
+
* @param sessionId Session identifier
|
|
72
|
+
*/
|
|
73
|
+
async touchSession(sessionId) {
|
|
74
|
+
const metadata = await this.loadSession(sessionId);
|
|
75
|
+
if (metadata) {
|
|
76
|
+
metadata.lastUsed = new Date();
|
|
77
|
+
await this.saveSession(metadata);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Delete session metadata from disk
|
|
82
|
+
* @param sessionId Session identifier
|
|
83
|
+
*/
|
|
84
|
+
async deleteSession(sessionId) {
|
|
85
|
+
try {
|
|
86
|
+
const filePath = this.getMetadataPath(sessionId);
|
|
87
|
+
if (fs.existsSync(filePath)) {
|
|
88
|
+
fs.unlinkSync(filePath);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Failed to delete session metadata: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* List all stored session metadata
|
|
97
|
+
* @returns Array of session metadata
|
|
98
|
+
*/
|
|
99
|
+
async listSessions() {
|
|
100
|
+
try {
|
|
101
|
+
if (!fs.existsSync(this.metadataDir)) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const files = fs.readdirSync(this.metadataDir);
|
|
105
|
+
const sessions = [];
|
|
106
|
+
for (const file of files) {
|
|
107
|
+
if (file.endsWith('.json')) {
|
|
108
|
+
const sessionId = file.replace('.json', '');
|
|
109
|
+
const metadata = await this.loadSession(sessionId);
|
|
110
|
+
if (metadata) {
|
|
111
|
+
sessions.push(metadata);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return sessions;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new Error(`Failed to list sessions: ${error.message}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Clean up metadata for sessions that no longer exist in tmux
|
|
123
|
+
* @param activeSessions Array of active session IDs from tmux
|
|
124
|
+
*/
|
|
125
|
+
async cleanupOrphaned(activeSessions) {
|
|
126
|
+
try {
|
|
127
|
+
const stored = await this.listSessions();
|
|
128
|
+
let cleaned = 0;
|
|
129
|
+
for (const metadata of stored) {
|
|
130
|
+
if (!activeSessions.includes(metadata.sessionId)) {
|
|
131
|
+
await this.deleteSession(metadata.sessionId);
|
|
132
|
+
cleaned++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return cleaned;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw new Error(`Failed to cleanup orphaned sessions: ${error.message}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Clean up sessions that haven't been used in a specified time period
|
|
143
|
+
* @param maxAgeMs Maximum age in milliseconds
|
|
144
|
+
*/
|
|
145
|
+
async cleanupStale(maxAgeMs) {
|
|
146
|
+
try {
|
|
147
|
+
const stored = await this.listSessions();
|
|
148
|
+
const now = Date.now();
|
|
149
|
+
let cleaned = 0;
|
|
150
|
+
for (const metadata of stored) {
|
|
151
|
+
const age = now - metadata.lastUsed.getTime();
|
|
152
|
+
if (age > maxAgeMs) {
|
|
153
|
+
await this.deleteSession(metadata.sessionId);
|
|
154
|
+
cleaned++;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return cleaned;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
throw new Error(`Failed to cleanup stale sessions: ${error.message}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get metadata directory path
|
|
165
|
+
*/
|
|
166
|
+
getMetadataDirectory() {
|
|
167
|
+
return this.metadataDir;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Recover sessions on startup
|
|
171
|
+
* Checks which persisted sessions still exist in tmux
|
|
172
|
+
* and cleans up metadata for sessions that no longer exist
|
|
173
|
+
*
|
|
174
|
+
* @param activeSessions Array of currently active tmux session IDs
|
|
175
|
+
* @returns Object with recovered and cleaned session counts
|
|
176
|
+
*/
|
|
177
|
+
async recoverSessions(activeSessions) {
|
|
178
|
+
const storedSessions = await this.listSessions();
|
|
179
|
+
let recovered = 0;
|
|
180
|
+
let cleaned = 0;
|
|
181
|
+
for (const metadata of storedSessions) {
|
|
182
|
+
if (activeSessions.includes(metadata.sessionId)) {
|
|
183
|
+
// Session still exists - recovered
|
|
184
|
+
recovered++;
|
|
185
|
+
// Update lastUsed to indicate recovery
|
|
186
|
+
metadata.lastUsed = new Date();
|
|
187
|
+
await this.saveSession(metadata);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// Session no longer exists - clean up metadata
|
|
191
|
+
await this.deleteSession(metadata.sessionId);
|
|
192
|
+
cleaned++;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
recovered,
|
|
197
|
+
cleaned,
|
|
198
|
+
total: storedSessions.length
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Auto-cleanup stale and orphaned sessions
|
|
203
|
+
* Should be called periodically (e.g., every hour)
|
|
204
|
+
*
|
|
205
|
+
* @param activeSessions Current active tmux sessions
|
|
206
|
+
* @param maxAgeHours Maximum age in hours before session is considered stale
|
|
207
|
+
* @returns Cleanup statistics
|
|
208
|
+
*/
|
|
209
|
+
async autoCleanup(activeSessions, maxAgeHours = 24) {
|
|
210
|
+
const maxAgeMs = maxAgeHours * 60 * 60 * 1000;
|
|
211
|
+
const orphanedCount = await this.cleanupOrphaned(activeSessions);
|
|
212
|
+
const staleCount = await this.cleanupStale(maxAgeMs);
|
|
213
|
+
return {
|
|
214
|
+
orphaned: orphanedCount,
|
|
215
|
+
stale: staleCount,
|
|
216
|
+
total: orphanedCount + staleCount
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get session statistics
|
|
221
|
+
*/
|
|
222
|
+
async getStats() {
|
|
223
|
+
const sessions = await this.listSessions();
|
|
224
|
+
if (sessions.length === 0) {
|
|
225
|
+
return {
|
|
226
|
+
totalSessions: 0,
|
|
227
|
+
oldestSession: null,
|
|
228
|
+
newestSession: null,
|
|
229
|
+
averageAge: 0
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
const now = Date.now();
|
|
233
|
+
const ages = sessions.map(s => now - s.created.getTime());
|
|
234
|
+
const averageAge = ages.reduce((sum, age) => sum + age, 0) / ages.length;
|
|
235
|
+
const sortedByCreated = sessions.sort((a, b) => a.created.getTime() - b.created.getTime());
|
|
236
|
+
return {
|
|
237
|
+
totalSessions: sessions.length,
|
|
238
|
+
oldestSession: sortedByCreated[0]?.created || new Date(),
|
|
239
|
+
newestSession: sortedByCreated[sortedByCreated.length - 1]?.created || new Date(),
|
|
240
|
+
averageAge: averageAge / (60 * 60 * 1000) // Convert to hours
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=SessionPersistence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionPersistence.js","sourceRoot":"","sources":["../../src/utils/SessionPersistence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM,OAAO,kBAAkB;IACrB,WAAW,CAAS;IAE5B,YAAY,WAAoB;QAC9B,MAAM,QAAQ,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAC/E,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACK,iBAAiB;QACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED;;OAEG;IACK,eA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O,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAE3F,OAAO;YACL,aAAa,EAAE,QAAQ,CAAC,MAAM;YAC9B,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,IAAI,IAAI,EAAE;YACxD,aAAa,EAAE,eAAe,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,IAAI,IAAI,IAAI,EAAE;YACjF,UAAU,EAAE,UAAU,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,mBAAmB;SAC9D,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Safe text manipulation utilities, especially for handling special characters
|
|
5
|
+
* in string replacements.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Performs a safe literal string replacement that correctly handles $ sequences.
|
|
9
|
+
*
|
|
10
|
+
* JavaScript's String.replace() treats $ specially in replacement strings:
|
|
11
|
+
* - $& = the matched substring
|
|
12
|
+
* - $` = portion before match
|
|
13
|
+
* - $' = portion after match
|
|
14
|
+
* - $1, $2, etc. = capture groups
|
|
15
|
+
* - $$ = literal $
|
|
16
|
+
*
|
|
17
|
+
* This function ensures $ characters in the replacement string are treated literally.
|
|
18
|
+
*
|
|
19
|
+
* @param content The string to search in
|
|
20
|
+
* @param oldString The exact string to find (literal, not regex)
|
|
21
|
+
* @param newString The exact string to replace with (literal, $ are escaped)
|
|
22
|
+
* @returns The content with replacements made
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Without safe replacement:
|
|
26
|
+
* "foo".replace("foo", "$100") // Returns "0" ($ is special)
|
|
27
|
+
*
|
|
28
|
+
* // With safe replacement:
|
|
29
|
+
* safeLiteralReplace("foo", "foo", "$100") // Returns "$100" ($ is literal)
|
|
30
|
+
*/
|
|
31
|
+
export declare function safeLiteralReplace(content: string, oldString: string, newString: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Counts occurrences of a literal string in content.
|
|
34
|
+
*
|
|
35
|
+
* @param content The string to search in
|
|
36
|
+
* @param searchString The exact string to count
|
|
37
|
+
* @returns The number of non-overlapping occurrences
|
|
38
|
+
*/
|
|
39
|
+
export declare function countOccurrences(content: string, searchString: string): number;
|
|
40
|
+
/**
|
|
41
|
+
* Escapes special regex characters in a string to make it safe for use in a RegExp.
|
|
42
|
+
*
|
|
43
|
+
* @param str The string to escape
|
|
44
|
+
* @returns The escaped string safe for use in new RegExp()
|
|
45
|
+
*/
|
|
46
|
+
export declare function escapeRegex(str: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Normalizes line endings to LF (\n).
|
|
49
|
+
*
|
|
50
|
+
* @param content The content with potentially mixed line endings
|
|
51
|
+
* @returns The content with normalized LF line endings
|
|
52
|
+
*/
|
|
53
|
+
export declare function normalizeLineEndings(content: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Truncates text to a maximum length, adding ellipsis if needed.
|
|
56
|
+
*
|
|
57
|
+
* @param text The text to truncate
|
|
58
|
+
* @param maxLength Maximum length (default: 100)
|
|
59
|
+
* @param ellipsis The ellipsis to add (default: '...')
|
|
60
|
+
* @returns The truncated text
|
|
61
|
+
*/
|
|
62
|
+
export declare function truncate(text: string, maxLength?: number, ellipsis?: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the first line of text.
|
|
65
|
+
*
|
|
66
|
+
* @param text The multi-line text
|
|
67
|
+
* @returns The first line
|
|
68
|
+
*/
|
|
69
|
+
export declare function getFirstLine(text: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Strips ANSI escape codes from text.
|
|
72
|
+
*
|
|
73
|
+
* @param text The text with ANSI codes
|
|
74
|
+
* @returns The text without ANSI codes
|
|
75
|
+
*/
|
|
76
|
+
export declare function stripAnsi(text: string): string;
|
|
77
|
+
//# sourceMappingURL=TextUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextUtils.d.ts","sourceRoot":"","sources":["../../src/utils/TextUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAWR;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAc9E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,MAAY,EACvB,QAAQ,GAAE,MAAc,GACvB,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM9C"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Safe text manipulation utilities, especially for handling special characters
|
|
5
|
+
* in string replacements.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Performs a safe literal string replacement that correctly handles $ sequences.
|
|
9
|
+
*
|
|
10
|
+
* JavaScript's String.replace() treats $ specially in replacement strings:
|
|
11
|
+
* - $& = the matched substring
|
|
12
|
+
* - $` = portion before match
|
|
13
|
+
* - $' = portion after match
|
|
14
|
+
* - $1, $2, etc. = capture groups
|
|
15
|
+
* - $$ = literal $
|
|
16
|
+
*
|
|
17
|
+
* This function ensures $ characters in the replacement string are treated literally.
|
|
18
|
+
*
|
|
19
|
+
* @param content The string to search in
|
|
20
|
+
* @param oldString The exact string to find (literal, not regex)
|
|
21
|
+
* @param newString The exact string to replace with (literal, $ are escaped)
|
|
22
|
+
* @returns The content with replacements made
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Without safe replacement:
|
|
26
|
+
* "foo".replace("foo", "$100") // Returns "0" ($ is special)
|
|
27
|
+
*
|
|
28
|
+
* // With safe replacement:
|
|
29
|
+
* safeLiteralReplace("foo", "foo", "$100") // Returns "$100" ($ is literal)
|
|
30
|
+
*/
|
|
31
|
+
export function safeLiteralReplace(content, oldString, newString) {
|
|
32
|
+
// replaceAll() is safe for literal strings (doesn't use regex)
|
|
33
|
+
// But we still need to escape $ in the replacement string
|
|
34
|
+
// because replaceAll treats $ specially in replacement patterns
|
|
35
|
+
// Escape all $ characters by doubling them
|
|
36
|
+
// This ensures $100 becomes $$100 which replaceAll interprets as literal $100
|
|
37
|
+
const safeNewString = newString.replace(/\$/g, '$$$$');
|
|
38
|
+
// Use replaceAll for literal string replacement
|
|
39
|
+
return content.replaceAll(oldString, safeNewString);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Counts occurrences of a literal string in content.
|
|
43
|
+
*
|
|
44
|
+
* @param content The string to search in
|
|
45
|
+
* @param searchString The exact string to count
|
|
46
|
+
* @returns The number of non-overlapping occurrences
|
|
47
|
+
*/
|
|
48
|
+
export function countOccurrences(content, searchString) {
|
|
49
|
+
if (searchString === '') {
|
|
50
|
+
return 0; // Empty string has no meaningful occurrences
|
|
51
|
+
}
|
|
52
|
+
let count = 0;
|
|
53
|
+
let position = 0;
|
|
54
|
+
while ((position = content.indexOf(searchString, position)) !== -1) {
|
|
55
|
+
count++;
|
|
56
|
+
position += searchString.length; // Move past this occurrence
|
|
57
|
+
}
|
|
58
|
+
return count;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Escapes special regex characters in a string to make it safe for use in a RegExp.
|
|
62
|
+
*
|
|
63
|
+
* @param str The string to escape
|
|
64
|
+
* @returns The escaped string safe for use in new RegExp()
|
|
65
|
+
*/
|
|
66
|
+
export function escapeRegex(str) {
|
|
67
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Normalizes line endings to LF (\n).
|
|
71
|
+
*
|
|
72
|
+
* @param content The content with potentially mixed line endings
|
|
73
|
+
* @returns The content with normalized LF line endings
|
|
74
|
+
*/
|
|
75
|
+
export function normalizeLineEndings(content) {
|
|
76
|
+
return content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Truncates text to a maximum length, adding ellipsis if needed.
|
|
80
|
+
*
|
|
81
|
+
* @param text The text to truncate
|
|
82
|
+
* @param maxLength Maximum length (default: 100)
|
|
83
|
+
* @param ellipsis The ellipsis to add (default: '...')
|
|
84
|
+
* @returns The truncated text
|
|
85
|
+
*/
|
|
86
|
+
export function truncate(text, maxLength = 100, ellipsis = '...') {
|
|
87
|
+
if (text.length <= maxLength) {
|
|
88
|
+
return text;
|
|
89
|
+
}
|
|
90
|
+
return text.substring(0, maxLength - ellipsis.length) + ellipsis;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Gets the first line of text.
|
|
94
|
+
*
|
|
95
|
+
* @param text The multi-line text
|
|
96
|
+
* @returns The first line
|
|
97
|
+
*/
|
|
98
|
+
export function getFirstLine(text) {
|
|
99
|
+
const lines = text.split('\n');
|
|
100
|
+
return lines[0] || '';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Strips ANSI escape codes from text.
|
|
104
|
+
*
|
|
105
|
+
* @param text The text with ANSI codes
|
|
106
|
+
* @returns The text without ANSI codes
|
|
107
|
+
*/
|
|
108
|
+
export function stripAnsi(text) {
|
|
109
|
+
// eslint-disable-next-line no-control-regex
|
|
110
|
+
return text.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=TextUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextUtils.js","sourceRoot":"","sources":["../../src/utils/TextUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAe,EACf,SAAiB,EACjB,SAAiB;IAEjB,+DAA+D;IAC/D,0DAA0D;IAC1D,gEAAgE;IAEhE,2CAA2C;IAC3C,8EAA8E;IAC9E,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEvD,gDAAgD;IAChD,OAAO,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,YAAoB;IACpE,IAAI,YAAY,KAAK,EAAE,EAAE,CAAC;QACxB,OAAO,CAAC,CAAC,CAAC,6CAA6C;IACzD,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACnE,KAAK,EAAE,CAAC;QACR,QAAQ,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,4BAA4B;IAC/D,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,YAAoB,GAAG,EACvB,WAAmB,KAAK;IAExB,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,4CAA4C;IAC5C,OAAO,IAAI,CAAC,OAAO,CACjB,6EAA6E,EAC7E,EAAE,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TmuxCapture - Visual screenshot capture for tmux sessions
|
|
3
|
+
*
|
|
4
|
+
* Leverages existing WindowManager and TerminalSandbox infrastructure
|
|
5
|
+
* to capture visual screenshots of tmux sessions.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Visual PNG screenshots of tmux sessions
|
|
9
|
+
* - Uses Playwright via TerminalSandbox
|
|
10
|
+
* - Minimal overhead (reuses existing browser instance)
|
|
11
|
+
* - Automatic cleanup
|
|
12
|
+
*/
|
|
13
|
+
export interface CaptureOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Screenshot format
|
|
16
|
+
*/
|
|
17
|
+
format?: 'png' | 'jpeg';
|
|
18
|
+
/**
|
|
19
|
+
* JPEG quality (0-100, only for JPEG format)
|
|
20
|
+
*/
|
|
21
|
+
quality?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Terminal dimensions (defaults to 80x24)
|
|
24
|
+
*/
|
|
25
|
+
dimensions?: {
|
|
26
|
+
cols: number;
|
|
27
|
+
rows: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Wait time in ms before capturing (allow rendering)
|
|
31
|
+
*/
|
|
32
|
+
waitTime?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface CaptureResult {
|
|
35
|
+
/**
|
|
36
|
+
* Screenshot buffer (PNG or JPEG)
|
|
37
|
+
*/
|
|
38
|
+
screenshot: Buffer;
|
|
39
|
+
/**
|
|
40
|
+
* Screenshot as base64 string
|
|
41
|
+
*/
|
|
42
|
+
base64: string;
|
|
43
|
+
/**
|
|
44
|
+
* Format of the screenshot
|
|
45
|
+
*/
|
|
46
|
+
format: 'png' | 'jpeg';
|
|
47
|
+
/**
|
|
48
|
+
* Timestamp of capture
|
|
49
|
+
*/
|
|
50
|
+
timestamp: number;
|
|
51
|
+
/**
|
|
52
|
+
* Session ID that was captured
|
|
53
|
+
*/
|
|
54
|
+
sessionId: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* TmuxCapture - Visual screenshot capture for tmux sessions
|
|
58
|
+
*
|
|
59
|
+
* Strategy:
|
|
60
|
+
* 1. Use WindowManager to create a terminal window
|
|
61
|
+
* 2. Attach to the tmux session in that terminal
|
|
62
|
+
* 3. Take a screenshot using Playwright
|
|
63
|
+
* 4. Clean up the window
|
|
64
|
+
*/
|
|
65
|
+
export declare class TmuxCapture {
|
|
66
|
+
private static windowManager;
|
|
67
|
+
private static initPromise;
|
|
68
|
+
/**
|
|
69
|
+
* Initialize WindowManager (singleton pattern)
|
|
70
|
+
*/
|
|
71
|
+
private static ensureWindowManager;
|
|
72
|
+
/**
|
|
73
|
+
* Capture visual screenshot of a tmux session
|
|
74
|
+
*
|
|
75
|
+
* @param sessionId Tmux session ID
|
|
76
|
+
* @param options Capture options
|
|
77
|
+
* @returns Screenshot and metadata
|
|
78
|
+
*/
|
|
79
|
+
static captureSession(sessionId: string, options?: CaptureOptions): Promise<CaptureResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Capture screenshot and save to file
|
|
82
|
+
*
|
|
83
|
+
* @param sessionId Tmux session ID
|
|
84
|
+
* @param filepath Path to save screenshot
|
|
85
|
+
* @param options Capture options
|
|
86
|
+
*/
|
|
87
|
+
static captureToFile(sessionId: string, filepath: string, options?: CaptureOptions): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Cleanup and shutdown WindowManager
|
|
90
|
+
* Call this when done with all captures
|
|
91
|
+
*/
|
|
92
|
+
static cleanup(): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=TmuxCapture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TmuxCapture.d.ts","sourceRoot":"","sources":["../../src/utils/TmuxCapture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAExB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IAEvB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,aAAa,CAA8B;IAC1D,OAAO,CAAC,MAAM,CAAC,WAAW,CAA8B;IAExD;;OAEG;mBACkB,mBAAmB;IAgBxC;;;;;;OAMG;WACiB,cAAc,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC;IAoEzB;;;;;;OAMG;WACiB,aAAa,CAC/B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC;IAMhB;;;OAGG;WACiB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7C"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TmuxCapture - Visual screenshot capture for tmux sessions
|
|
3
|
+
*
|
|
4
|
+
* Leverages existing WindowManager and TerminalSandbox infrastructure
|
|
5
|
+
* to capture visual screenshots of tmux sessions.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Visual PNG screenshots of tmux sessions
|
|
9
|
+
* - Uses Playwright via TerminalSandbox
|
|
10
|
+
* - Minimal overhead (reuses existing browser instance)
|
|
11
|
+
* - Automatic cleanup
|
|
12
|
+
*/
|
|
13
|
+
import { WindowManager } from '../implementations/addon/WindowManager.js';
|
|
14
|
+
import { TmuxManager } from './TmuxManager.js';
|
|
15
|
+
/**
|
|
16
|
+
* TmuxCapture - Visual screenshot capture for tmux sessions
|
|
17
|
+
*
|
|
18
|
+
* Strategy:
|
|
19
|
+
* 1. Use WindowManager to create a terminal window
|
|
20
|
+
* 2. Attach to the tmux session in that terminal
|
|
21
|
+
* 3. Take a screenshot using Playwright
|
|
22
|
+
* 4. Clean up the window
|
|
23
|
+
*/
|
|
24
|
+
export class TmuxCapture {
|
|
25
|
+
static windowManager = null;
|
|
26
|
+
static initPromise = null;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize WindowManager (singleton pattern)
|
|
29
|
+
*/
|
|
30
|
+
static async ensureWindowManager() {
|
|
31
|
+
if (TmuxCapture.windowManager) {
|
|
32
|
+
return TmuxCapture.windowManager;
|
|
33
|
+
}
|
|
34
|
+
if (!TmuxCapture.initPromise) {
|
|
35
|
+
TmuxCapture.initPromise = (async () => {
|
|
36
|
+
TmuxCapture.windowManager = new WindowManager();
|
|
37
|
+
await TmuxCapture.windowManager.initialize();
|
|
38
|
+
})();
|
|
39
|
+
}
|
|
40
|
+
await TmuxCapture.initPromise;
|
|
41
|
+
return TmuxCapture.windowManager;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Capture visual screenshot of a tmux session
|
|
45
|
+
*
|
|
46
|
+
* @param sessionId Tmux session ID
|
|
47
|
+
* @param options Capture options
|
|
48
|
+
* @returns Screenshot and metadata
|
|
49
|
+
*/
|
|
50
|
+
static async captureSession(sessionId, options = {}) {
|
|
51
|
+
const tmux = TmuxManager.getInstance();
|
|
52
|
+
// Verify tmux is available
|
|
53
|
+
if (!(await tmux.isAvailable())) {
|
|
54
|
+
throw new Error('tmux is not installed');
|
|
55
|
+
}
|
|
56
|
+
// Verify session exists
|
|
57
|
+
if (!(await tmux.sessionExists(sessionId))) {
|
|
58
|
+
throw new Error(`Tmux session '${sessionId}' does not exist`);
|
|
59
|
+
}
|
|
60
|
+
// Get or create WindowManager
|
|
61
|
+
const windowManager = await TmuxCapture.ensureWindowManager();
|
|
62
|
+
// Create temporary window ID
|
|
63
|
+
const windowId = `tmux-capture-${sessionId}-${Date.now()}`;
|
|
64
|
+
try {
|
|
65
|
+
// Create terminal window that attaches to tmux session
|
|
66
|
+
const windowConfig = {
|
|
67
|
+
type: 'terminal',
|
|
68
|
+
id: windowId,
|
|
69
|
+
shell: `tmux attach-session -t ${sessionId}`,
|
|
70
|
+
position: {
|
|
71
|
+
x: 0,
|
|
72
|
+
y: 0,
|
|
73
|
+
width: (options.dimensions?.cols || 80) * 10, // Approximate pixels
|
|
74
|
+
height: (options.dimensions?.rows || 24) * 20
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
await windowManager.createWindow(windowConfig);
|
|
78
|
+
// Wait for rendering
|
|
79
|
+
const waitTime = options.waitTime || 1000;
|
|
80
|
+
await new Promise(resolve => setTimeout(resolve, waitTime));
|
|
81
|
+
// Capture screenshot
|
|
82
|
+
const screenshot = await windowManager.captureWindow(windowId);
|
|
83
|
+
// Clean up window
|
|
84
|
+
await windowManager.closeWindow(windowId);
|
|
85
|
+
// Prepare result
|
|
86
|
+
const format = options.format || 'png';
|
|
87
|
+
const base64 = screenshot.toString('base64');
|
|
88
|
+
return {
|
|
89
|
+
screenshot,
|
|
90
|
+
base64,
|
|
91
|
+
format,
|
|
92
|
+
timestamp: Date.now(),
|
|
93
|
+
sessionId
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// Attempt cleanup on error
|
|
98
|
+
try {
|
|
99
|
+
await windowManager.closeWindow(windowId);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Ignore cleanup errors
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`Failed to capture tmux session: ${error.message}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Capture screenshot and save to file
|
|
109
|
+
*
|
|
110
|
+
* @param sessionId Tmux session ID
|
|
111
|
+
* @param filepath Path to save screenshot
|
|
112
|
+
* @param options Capture options
|
|
113
|
+
*/
|
|
114
|
+
static async captureToFile(sessionId, filepath, options = {}) {
|
|
115
|
+
const fs = await import('fs/promises');
|
|
116
|
+
const result = await TmuxCapture.captureSession(sessionId, options);
|
|
117
|
+
await fs.writeFile(filepath, result.screenshot);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Cleanup and shutdown WindowManager
|
|
121
|
+
* Call this when done with all captures
|
|
122
|
+
*/
|
|
123
|
+
static async cleanup() {
|
|
124
|
+
if (TmuxCapture.windowManager) {
|
|
125
|
+
await TmuxCapture.windowManager.close();
|
|
126
|
+
TmuxCapture.windowManager = null;
|
|
127
|
+
TmuxCapture.initPromise = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=TmuxCapture.js.map
|