centaurus-cli 3.0.1 → 3.1.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/dist/ai/types.js +0 -1
- package/dist/ai/types.js.map +1 -1
- package/dist/cli-adapter.js +5047 -5158
- package/dist/cli-adapter.js.map +1 -1
- package/dist/commands/CommandParser.js +372 -315
- package/dist/commands/CommandParser.js.map +1 -1
- package/dist/config/build-config.js +11 -42
- package/dist/config/build-config.js.map +1 -1
- package/dist/config/defaultConfig.js +94 -82
- package/dist/config/defaultConfig.js.map +1 -1
- package/dist/config/manager.js +144 -160
- package/dist/config/manager.js.map +1 -1
- package/dist/config/mcp-config-manager.js +411 -364
- package/dist/config/mcp-config-manager.js.map +1 -1
- package/dist/config/models.js +118 -185
- package/dist/config/models.js.map +1 -1
- package/dist/config/slash-commands.js +186 -184
- package/dist/config/slash-commands.js.map +1 -1
- package/dist/config/types.js +33 -26
- package/dist/config/types.js.map +1 -1
- package/dist/context/command-detector.js +63 -67
- package/dist/context/command-detector.js.map +1 -1
- package/dist/context/context-manager.js +533 -518
- package/dist/context/context-manager.js.map +1 -1
- package/dist/context/handlers/docker-handler.js +518 -576
- package/dist/context/handlers/docker-handler.js.map +1 -1
- package/dist/context/handlers/ssh-handler.js +1050 -1109
- package/dist/context/handlers/ssh-handler.js.map +1 -1
- package/dist/context/handlers/wsl-handler.js +558 -630
- package/dist/context/handlers/wsl-handler.js.map +1 -1
- package/dist/context/index.js +42 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/subshell-handler.js +0 -4
- package/dist/context/subshell-handler.js.map +1 -1
- package/dist/context/types.js +20 -31
- package/dist/context/types.js.map +1 -1
- package/dist/hooks/useConnectivity.js +13 -10
- package/dist/hooks/useConnectivity.js.map +1 -1
- package/dist/hooks/useTerminalDimensions.js +67 -79
- package/dist/hooks/useTerminalDimensions.js.map +1 -1
- package/dist/index.js +228 -251
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcp-command-handler.js +297 -260
- package/dist/mcp/mcp-command-handler.js.map +1 -1
- package/dist/mcp/mcp-server-manager.js +139 -155
- package/dist/mcp/mcp-server-manager.js.map +1 -1
- package/dist/mcp/mcp-tool-wrapper.js +74 -94
- package/dist/mcp/mcp-tool-wrapper.js.map +1 -1
- package/dist/services/ai-autocomplete-agent.js +169 -181
- package/dist/services/ai-autocomplete-agent.js.map +1 -1
- package/dist/services/ai-context-injector.js +180 -93
- package/dist/services/ai-context-injector.js.map +1 -1
- package/dist/services/ai-service-client.js +513 -456
- package/dist/services/ai-service-client.js.map +1 -1
- package/dist/services/api-client.js +443 -441
- package/dist/services/api-client.js.map +1 -1
- package/dist/services/auth-handler.js +162 -198
- package/dist/services/auth-handler.js.map +1 -1
- package/dist/services/background-task-manager.js +258 -282
- package/dist/services/background-task-manager.js.map +1 -1
- package/dist/services/checkpoint-manager.js +1526 -1512
- package/dist/services/checkpoint-manager.js.map +1 -1
- package/dist/services/clipboard-service.js +151 -200
- package/dist/services/clipboard-service.js.map +1 -1
- package/dist/services/connectivity-manager.js +63 -65
- package/dist/services/connectivity-manager.js.map +1 -1
- package/dist/services/conversation-manager.js +118 -121
- package/dist/services/conversation-manager.js.map +1 -1
- package/dist/services/environment-context-injector.js +160 -187
- package/dist/services/environment-context-injector.js.map +1 -1
- package/dist/services/fast-context-agent.js +203 -243
- package/dist/services/fast-context-agent.js.map +1 -1
- package/dist/services/input-detection-agent.js +190 -202
- package/dist/services/input-detection-agent.js.map +1 -1
- package/dist/services/input-requirement-detector.js +155 -189
- package/dist/services/input-requirement-detector.js.map +1 -1
- package/dist/services/local-chat-storage.js +342 -365
- package/dist/services/local-chat-storage.js.map +1 -1
- package/dist/services/monitored-shell-manager.js +225 -233
- package/dist/services/monitored-shell-manager.js.map +1 -1
- package/dist/services/ollama-service.js +293 -310
- package/dist/services/ollama-service.js.map +1 -1
- package/dist/services/rules-storage.js +142 -0
- package/dist/services/rules-storage.js.map +1 -0
- package/dist/services/session-quota-manager.js +219 -235
- package/dist/services/session-quota-manager.js.map +1 -1
- package/dist/services/shell-input-agent.js +299 -334
- package/dist/services/shell-input-agent.js.map +1 -1
- package/dist/services/sub-agent-manager.js +459 -501
- package/dist/services/sub-agent-manager.js.map +1 -1
- package/dist/services/warpify-detector.js +133 -183
- package/dist/services/warpify-detector.js.map +1 -1
- package/dist/services/workflow-storage.js +202 -217
- package/dist/services/workflow-storage.js.map +1 -1
- package/dist/test-ssh-handler.js +148 -193
- package/dist/test-ssh-handler.js.map +1 -1
- package/dist/tools/add-mcp.js +161 -0
- package/dist/tools/add-mcp.js.map +1 -0
- package/dist/tools/background-command.js +240 -273
- package/dist/tools/background-command.js.map +1 -1
- package/dist/tools/command.js +447 -440
- package/dist/tools/command.js.map +1 -1
- package/dist/tools/create-image.js +172 -202
- package/dist/tools/create-image.js.map +1 -1
- package/dist/tools/enter-remote-session.js +169 -215
- package/dist/tools/enter-remote-session.js.map +1 -1
- package/dist/tools/fast-context.js +60 -67
- package/dist/tools/fast-context.js.map +1 -1
- package/dist/tools/file-ops.js +601 -572
- package/dist/tools/file-ops.js.map +1 -1
- package/dist/tools/find-files.js +262 -303
- package/dist/tools/find-files.js.map +1 -1
- package/dist/tools/get-diff.js +423 -406
- package/dist/tools/get-diff.js.map +1 -1
- package/dist/tools/grep-search.js +966 -948
- package/dist/tools/grep-search.js.map +1 -1
- package/dist/tools/inspect-symbol.js +308 -323
- package/dist/tools/inspect-symbol.js.map +1 -1
- package/dist/tools/plan-mode.js +459 -503
- package/dist/tools/plan-mode.js.map +1 -1
- package/dist/tools/read-binary-file.js +160 -190
- package/dist/tools/read-binary-file.js.map +1 -1
- package/dist/tools/registry.js +100 -84
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/reproduce_issue.js +170 -151
- package/dist/tools/reproduce_issue.js.map +1 -1
- package/dist/tools/sub-agent.js +223 -228
- package/dist/tools/sub-agent.js.map +1 -1
- package/dist/tools/task-complete.js +28 -27
- package/dist/tools/task-complete.js.map +1 -1
- package/dist/tools/types.js +0 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/validation.js +96 -118
- package/dist/tools/validation.js.map +1 -1
- package/dist/tools/web-search.js +194 -194
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools/workflow-tool.js +77 -82
- package/dist/tools/workflow-tool.js.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/rule.js +1 -0
- package/dist/types/rule.js.map +1 -0
- package/dist/types/workflow.js +0 -7
- package/dist/types/workflow.js.map +1 -1
- package/dist/ui/components/AgentTimer.js +24 -25
- package/dist/ui/components/AgentTimer.js.map +1 -1
- package/dist/ui/components/App.js +3266 -3263
- package/dist/ui/components/App.js.map +1 -1
- package/dist/ui/components/AuthScreen.js +22 -34
- package/dist/ui/components/AuthScreen.js.map +1 -1
- package/dist/ui/components/AuthWelcomeScreen.js +30 -24
- package/dist/ui/components/AuthWelcomeScreen.js.map +1 -1
- package/dist/ui/components/Breadcrumbs.js +53 -82
- package/dist/ui/components/Breadcrumbs.js.map +1 -1
- package/dist/ui/components/CircularSelectInput.js +59 -67
- package/dist/ui/components/CircularSelectInput.js.map +1 -1
- package/dist/ui/components/ClipboardFileAutocomplete.js +78 -39
- package/dist/ui/components/ClipboardFileAutocomplete.js.map +1 -1
- package/dist/ui/components/CodeBlock.js +24 -42
- package/dist/ui/components/CodeBlock.js.map +1 -1
- package/dist/ui/components/ConfigViewer.js +18 -25
- package/dist/ui/components/ConfigViewer.js.map +1 -1
- package/dist/ui/components/ConfirmPrompt.js +49 -71
- package/dist/ui/components/ConfirmPrompt.js.map +1 -1
- package/dist/ui/components/ConnectionStatusMessage.js +32 -83
- package/dist/ui/components/ConnectionStatusMessage.js.map +1 -1
- package/dist/ui/components/ContextWindowIndicator.js +34 -49
- package/dist/ui/components/ContextWindowIndicator.js.map +1 -1
- package/dist/ui/components/DetailedPlanReviewScreen.js +104 -106
- package/dist/ui/components/DetailedPlanReviewScreen.js.map +1 -1
- package/dist/ui/components/DiffViewer.js +68 -121
- package/dist/ui/components/DiffViewer.js.map +1 -1
- package/dist/ui/components/ErrorBoundary.js +40 -48
- package/dist/ui/components/ErrorBoundary.js.map +1 -1
- package/dist/ui/components/FileCreationPreview.js +29 -60
- package/dist/ui/components/FileCreationPreview.js.map +1 -1
- package/dist/ui/components/FileOperation.js +34 -29
- package/dist/ui/components/FileOperation.js.map +1 -1
- package/dist/ui/components/FileTagAutocomplete.js +55 -25
- package/dist/ui/components/FileTagAutocomplete.js.map +1 -1
- package/dist/ui/components/FontRecommendation.js.map +1 -1
- package/dist/ui/components/GitDiffBreadcrumb.js +29 -0
- package/dist/ui/components/GitDiffBreadcrumb.js.map +1 -0
- package/dist/ui/components/InputBox.js +1620 -2150
- package/dist/ui/components/InputBox.js.map +1 -1
- package/dist/ui/components/InteractiveShell.js +234 -352
- package/dist/ui/components/InteractiveShell.js.map +1 -1
- package/dist/ui/components/KeyboardHelp.js +34 -35
- package/dist/ui/components/KeyboardHelp.js.map +1 -1
- package/dist/ui/components/LoadingIndicator.js +22 -25
- package/dist/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/ui/components/MCPAddScreen.js +40 -51
- package/dist/ui/components/MCPAddScreen.js.map +1 -1
- package/dist/ui/components/MCPListScreen.js +40 -48
- package/dist/ui/components/MCPListScreen.js.map +1 -1
- package/dist/ui/components/MCPServerListScreen.js +49 -56
- package/dist/ui/components/MCPServerListScreen.js.map +1 -1
- package/dist/ui/components/MarkdownRenderer.js +69 -96
- package/dist/ui/components/MarkdownRenderer.js.map +1 -1
- package/dist/ui/components/MessageBox.js +66 -48
- package/dist/ui/components/MessageBox.js.map +1 -1
- package/dist/ui/components/MessageDisplay.js +150 -142
- package/dist/ui/components/MessageDisplay.js.map +1 -1
- package/dist/ui/components/MonitorModeAIPanel.js +46 -65
- package/dist/ui/components/MonitorModeAIPanel.js.map +1 -1
- package/dist/ui/components/MultiLineInput.js +243 -277
- package/dist/ui/components/MultiLineInput.js.map +1 -1
- package/dist/ui/components/PasswordPrompt.js +37 -18
- package/dist/ui/components/PasswordPrompt.js.map +1 -1
- package/dist/ui/components/PlanAcceptedMessage.js +27 -38
- package/dist/ui/components/PlanAcceptedMessage.js.map +1 -1
- package/dist/ui/components/PlanReviewScreen.js +46 -50
- package/dist/ui/components/PlanReviewScreen.js.map +1 -1
- package/dist/ui/components/RulesEditorScreen.js +81 -0
- package/dist/ui/components/RulesEditorScreen.js.map +1 -0
- package/dist/ui/components/SelectPrompt.js +19 -8
- package/dist/ui/components/SelectPrompt.js.map +1 -1
- package/dist/ui/components/ShimmerText.js +44 -0
- package/dist/ui/components/ShimmerText.js.map +1 -0
- package/dist/ui/components/SlashCommandAutocomplete.js +49 -22
- package/dist/ui/components/SlashCommandAutocomplete.js.map +1 -1
- package/dist/ui/components/StatusBar.js +56 -87
- package/dist/ui/components/StatusBar.js.map +1 -1
- package/dist/ui/components/StreamingMessageDisplay.js +116 -99
- package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
- package/dist/ui/components/TaskCompletedMessage.js +28 -23
- package/dist/ui/components/TaskCompletedMessage.js.map +1 -1
- package/dist/ui/components/TaskProgressIndicator.js +44 -70
- package/dist/ui/components/TaskProgressIndicator.js.map +1 -1
- package/dist/ui/components/ThinkingDisplay.js +44 -41
- package/dist/ui/components/ThinkingDisplay.js.map +1 -1
- package/dist/ui/components/ToolExecutionMessage.js +772 -1326
- package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
- package/dist/ui/components/ToolExecutionStatus.js +53 -84
- package/dist/ui/components/ToolExecutionStatus.js.map +1 -1
- package/dist/ui/components/ToolResult.js +22 -15
- package/dist/ui/components/ToolResult.js.map +1 -1
- package/dist/ui/components/VersionUpdatePrompt.js +88 -120
- package/dist/ui/components/VersionUpdatePrompt.js.map +1 -1
- package/dist/ui/components/WelcomeBanner.js +176 -26
- package/dist/ui/components/WelcomeBanner.js.map +1 -1
- package/dist/ui/components/WorkflowCreatorScreen.js +94 -161
- package/dist/ui/components/WorkflowCreatorScreen.js.map +1 -1
- package/dist/utils/ansi-encoder.js +30 -61
- package/dist/utils/ansi-encoder.js.map +1 -1
- package/dist/utils/chat-formatter.js +327 -305
- package/dist/utils/chat-formatter.js.map +1 -1
- package/dist/utils/command-history.js +152 -174
- package/dist/utils/command-history.js.map +1 -1
- package/dist/utils/context-sanitizer.js +49 -112
- package/dist/utils/context-sanitizer.js.map +1 -1
- package/dist/utils/conversation-logger.js +292 -324
- package/dist/utils/conversation-logger.js.map +1 -1
- package/dist/utils/custom-commands-manager.js +126 -131
- package/dist/utils/custom-commands-manager.js.map +1 -1
- package/dist/utils/editor-utils.js +732 -837
- package/dist/utils/editor-utils.js.map +1 -1
- package/dist/utils/file.js +174 -213
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/git-stats.js +169 -0
- package/dist/utils/git-stats.js.map +1 -0
- package/dist/utils/input-classifier.js +960 -482
- package/dist/utils/input-classifier.js.map +1 -1
- package/dist/utils/logger.js +48 -73
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/markdown-parser.js +277 -310
- package/dist/utils/markdown-parser.js.map +1 -1
- package/dist/utils/rule-reference-resolver.js +54 -0
- package/dist/utils/rule-reference-resolver.js.map +1 -0
- package/dist/utils/shell.js +144 -156
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/state.js +23 -22
- package/dist/utils/state.js.map +1 -1
- package/dist/utils/syntax-checker.js +279 -327
- package/dist/utils/syntax-checker.js.map +1 -1
- package/dist/utils/terminal-output.js +199 -302
- package/dist/utils/terminal-output.js.map +1 -1
- package/dist/utils/text-clipboard.js +47 -70
- package/dist/utils/text-clipboard.js.map +1 -1
- package/dist/utils/unicode-sanitizer.js +134 -197
- package/dist/utils/unicode-sanitizer.js.map +1 -1
- package/dist/utils/version-checker.js +46 -56
- package/dist/utils/version-checker.js.map +1 -1
- package/package.json +6 -4
- package/dist/ai/types.d.ts +0 -20
- package/dist/ai/types.d.ts.map +0 -1
- package/dist/cli-adapter.d.ts +0 -514
- package/dist/cli-adapter.d.ts.map +0 -1
- package/dist/commands/CommandParser.d.ts +0 -27
- package/dist/commands/CommandParser.d.ts.map +0 -1
- package/dist/config/build-config.d.ts +0 -42
- package/dist/config/build-config.d.ts.map +0 -1
- package/dist/config/defaultConfig.d.ts +0 -79
- package/dist/config/defaultConfig.d.ts.map +0 -1
- package/dist/config/manager.d.ts +0 -62
- package/dist/config/manager.d.ts.map +0 -1
- package/dist/config/mcp-config-manager.d.ts +0 -79
- package/dist/config/mcp-config-manager.d.ts.map +0 -1
- package/dist/config/models.d.ts +0 -83
- package/dist/config/models.d.ts.map +0 -1
- package/dist/config/slash-commands.d.ts +0 -23
- package/dist/config/slash-commands.d.ts.map +0 -1
- package/dist/config/types.d.ts +0 -35
- package/dist/config/types.d.ts.map +0 -1
- package/dist/context/command-detector.d.ts +0 -50
- package/dist/context/command-detector.d.ts.map +0 -1
- package/dist/context/context-manager.d.ts +0 -157
- package/dist/context/context-manager.d.ts.map +0 -1
- package/dist/context/handlers/docker-handler.d.ts +0 -130
- package/dist/context/handlers/docker-handler.d.ts.map +0 -1
- package/dist/context/handlers/ssh-handler.d.ts +0 -201
- package/dist/context/handlers/ssh-handler.d.ts.map +0 -1
- package/dist/context/handlers/wsl-handler.d.ts +0 -146
- package/dist/context/handlers/wsl-handler.d.ts.map +0 -1
- package/dist/context/index.d.ts +0 -8
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/subshell-handler.d.ts +0 -165
- package/dist/context/subshell-handler.d.ts.map +0 -1
- package/dist/context/types.d.ts +0 -70
- package/dist/context/types.d.ts.map +0 -1
- package/dist/hooks/useConnectivity.d.ts +0 -2
- package/dist/hooks/useConnectivity.d.ts.map +0 -1
- package/dist/hooks/useTerminalDimensions.d.ts +0 -41
- package/dist/hooks/useTerminalDimensions.d.ts.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/mcp/mcp-command-handler.d.ts +0 -47
- package/dist/mcp/mcp-command-handler.d.ts.map +0 -1
- package/dist/mcp/mcp-server-manager.d.ts +0 -30
- package/dist/mcp/mcp-server-manager.d.ts.map +0 -1
- package/dist/mcp/mcp-tool-wrapper.d.ts +0 -12
- package/dist/mcp/mcp-tool-wrapper.d.ts.map +0 -1
- package/dist/services/ai-autocomplete-agent.d.ts +0 -39
- package/dist/services/ai-autocomplete-agent.d.ts.map +0 -1
- package/dist/services/ai-context-injector.d.ts +0 -41
- package/dist/services/ai-context-injector.d.ts.map +0 -1
- package/dist/services/ai-service-client.d.ts +0 -128
- package/dist/services/ai-service-client.d.ts.map +0 -1
- package/dist/services/api-client.d.ts +0 -353
- package/dist/services/api-client.d.ts.map +0 -1
- package/dist/services/auth-handler.d.ts +0 -30
- package/dist/services/auth-handler.d.ts.map +0 -1
- package/dist/services/background-task-manager.d.ts +0 -114
- package/dist/services/background-task-manager.d.ts.map +0 -1
- package/dist/services/checkpoint-manager.d.ts +0 -204
- package/dist/services/checkpoint-manager.d.ts.map +0 -1
- package/dist/services/clipboard-service.d.ts +0 -37
- package/dist/services/clipboard-service.d.ts.map +0 -1
- package/dist/services/connectivity-manager.d.ts +0 -18
- package/dist/services/connectivity-manager.d.ts.map +0 -1
- package/dist/services/conversation-manager.d.ts +0 -73
- package/dist/services/conversation-manager.d.ts.map +0 -1
- package/dist/services/environment-context-injector.d.ts +0 -69
- package/dist/services/environment-context-injector.d.ts.map +0 -1
- package/dist/services/fast-context-agent.d.ts +0 -12
- package/dist/services/fast-context-agent.d.ts.map +0 -1
- package/dist/services/input-detection-agent.d.ts +0 -40
- package/dist/services/input-detection-agent.d.ts.map +0 -1
- package/dist/services/input-requirement-detector.d.ts +0 -28
- package/dist/services/input-requirement-detector.d.ts.map +0 -1
- package/dist/services/local-chat-storage.d.ts +0 -182
- package/dist/services/local-chat-storage.d.ts.map +0 -1
- package/dist/services/monitored-shell-manager.d.ts +0 -120
- package/dist/services/monitored-shell-manager.d.ts.map +0 -1
- package/dist/services/ollama-service.d.ts +0 -197
- package/dist/services/ollama-service.d.ts.map +0 -1
- package/dist/services/session-quota-manager.d.ts +0 -101
- package/dist/services/session-quota-manager.d.ts.map +0 -1
- package/dist/services/shell-input-agent.d.ts +0 -89
- package/dist/services/shell-input-agent.d.ts.map +0 -1
- package/dist/services/sub-agent-manager.d.ts +0 -140
- package/dist/services/sub-agent-manager.d.ts.map +0 -1
- package/dist/services/warpify-detector.d.ts +0 -43
- package/dist/services/warpify-detector.d.ts.map +0 -1
- package/dist/services/workflow-storage.d.ts +0 -72
- package/dist/services/workflow-storage.d.ts.map +0 -1
- package/dist/test-ssh-handler.d.ts +0 -8
- package/dist/test-ssh-handler.d.ts.map +0 -1
- package/dist/tools/background-command.d.ts +0 -11
- package/dist/tools/background-command.d.ts.map +0 -1
- package/dist/tools/command.d.ts +0 -3
- package/dist/tools/command.d.ts.map +0 -1
- package/dist/tools/create-image.d.ts +0 -10
- package/dist/tools/create-image.d.ts.map +0 -1
- package/dist/tools/enter-remote-session.d.ts +0 -48
- package/dist/tools/enter-remote-session.d.ts.map +0 -1
- package/dist/tools/fast-context.d.ts +0 -3
- package/dist/tools/fast-context.d.ts.map +0 -1
- package/dist/tools/file-ops.d.ts +0 -7
- package/dist/tools/file-ops.d.ts.map +0 -1
- package/dist/tools/find-files.d.ts +0 -49
- package/dist/tools/find-files.d.ts.map +0 -1
- package/dist/tools/get-diff.d.ts +0 -14
- package/dist/tools/get-diff.d.ts.map +0 -1
- package/dist/tools/grep-search.d.ts +0 -155
- package/dist/tools/grep-search.d.ts.map +0 -1
- package/dist/tools/inspect-symbol.d.ts +0 -32
- package/dist/tools/inspect-symbol.d.ts.map +0 -1
- package/dist/tools/plan-mode.d.ts +0 -140
- package/dist/tools/plan-mode.d.ts.map +0 -1
- package/dist/tools/read-binary-file.d.ts +0 -10
- package/dist/tools/read-binary-file.d.ts.map +0 -1
- package/dist/tools/registry.d.ts +0 -31
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/reproduce_issue.d.ts +0 -2
- package/dist/tools/reproduce_issue.d.ts.map +0 -1
- package/dist/tools/sub-agent.d.ts +0 -9
- package/dist/tools/sub-agent.d.ts.map +0 -1
- package/dist/tools/task-complete.d.ts +0 -3
- package/dist/tools/task-complete.d.ts.map +0 -1
- package/dist/tools/types.d.ts +0 -40
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/validation.d.ts +0 -47
- package/dist/tools/validation.d.ts.map +0 -1
- package/dist/tools/web-search.d.ts +0 -24
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/workflow-tool.d.ts +0 -11
- package/dist/tools/workflow-tool.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -123
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/workflow.d.ts +0 -110
- package/dist/types/workflow.d.ts.map +0 -1
- package/dist/ui/components/AgentTimer.d.ts +0 -7
- package/dist/ui/components/AgentTimer.d.ts.map +0 -1
- package/dist/ui/components/App.d.ts +0 -197
- package/dist/ui/components/App.d.ts.map +0 -1
- package/dist/ui/components/AuthScreen.d.ts +0 -8
- package/dist/ui/components/AuthScreen.d.ts.map +0 -1
- package/dist/ui/components/AuthWelcomeScreen.d.ts +0 -8
- package/dist/ui/components/AuthWelcomeScreen.d.ts.map +0 -1
- package/dist/ui/components/Breadcrumbs.d.ts +0 -13
- package/dist/ui/components/Breadcrumbs.d.ts.map +0 -1
- package/dist/ui/components/CircularSelectInput.d.ts +0 -24
- package/dist/ui/components/CircularSelectInput.d.ts.map +0 -1
- package/dist/ui/components/ClipboardFileAutocomplete.d.ts +0 -10
- package/dist/ui/components/ClipboardFileAutocomplete.d.ts.map +0 -1
- package/dist/ui/components/CodeBlock.d.ts +0 -9
- package/dist/ui/components/CodeBlock.d.ts.map +0 -1
- package/dist/ui/components/ConfigViewer.d.ts +0 -11
- package/dist/ui/components/ConfigViewer.d.ts.map +0 -1
- package/dist/ui/components/ConfirmPrompt.d.ts +0 -13
- package/dist/ui/components/ConfirmPrompt.d.ts.map +0 -1
- package/dist/ui/components/ConnectionStatusMessage.d.ts +0 -17
- package/dist/ui/components/ConnectionStatusMessage.d.ts.map +0 -1
- package/dist/ui/components/ContextWindowIndicator.d.ts +0 -8
- package/dist/ui/components/ContextWindowIndicator.d.ts.map +0 -1
- package/dist/ui/components/DetailedPlanReviewScreen.d.ts +0 -17
- package/dist/ui/components/DetailedPlanReviewScreen.d.ts.map +0 -1
- package/dist/ui/components/DiffViewer.d.ts +0 -9
- package/dist/ui/components/DiffViewer.d.ts.map +0 -1
- package/dist/ui/components/ErrorBoundary.d.ts +0 -17
- package/dist/ui/components/ErrorBoundary.d.ts.map +0 -1
- package/dist/ui/components/FileCreationPreview.d.ts +0 -8
- package/dist/ui/components/FileCreationPreview.d.ts.map +0 -1
- package/dist/ui/components/FileOperation.d.ts +0 -10
- package/dist/ui/components/FileOperation.d.ts.map +0 -1
- package/dist/ui/components/FileTagAutocomplete.d.ts +0 -11
- package/dist/ui/components/FileTagAutocomplete.d.ts.map +0 -1
- package/dist/ui/components/FontRecommendation.d.ts +0 -1
- package/dist/ui/components/FontRecommendation.d.ts.map +0 -1
- package/dist/ui/components/InputBox.d.ts +0 -42
- package/dist/ui/components/InputBox.d.ts.map +0 -1
- package/dist/ui/components/InteractiveShell.d.ts +0 -30
- package/dist/ui/components/InteractiveShell.d.ts.map +0 -1
- package/dist/ui/components/KeyboardHelp.d.ts +0 -7
- package/dist/ui/components/KeyboardHelp.d.ts.map +0 -1
- package/dist/ui/components/LoadingIndicator.d.ts +0 -3
- package/dist/ui/components/LoadingIndicator.d.ts.map +0 -1
- package/dist/ui/components/MCPAddScreen.d.ts +0 -13
- package/dist/ui/components/MCPAddScreen.d.ts.map +0 -1
- package/dist/ui/components/MCPListScreen.d.ts +0 -17
- package/dist/ui/components/MCPListScreen.d.ts.map +0 -1
- package/dist/ui/components/MCPServerListScreen.d.ts +0 -16
- package/dist/ui/components/MCPServerListScreen.d.ts.map +0 -1
- package/dist/ui/components/MarkdownRenderer.d.ts +0 -8
- package/dist/ui/components/MarkdownRenderer.d.ts.map +0 -1
- package/dist/ui/components/MessageBox.d.ts +0 -10
- package/dist/ui/components/MessageBox.d.ts.map +0 -1
- package/dist/ui/components/MessageDisplay.d.ts +0 -14
- package/dist/ui/components/MessageDisplay.d.ts.map +0 -1
- package/dist/ui/components/MonitorModeAIPanel.d.ts +0 -23
- package/dist/ui/components/MonitorModeAIPanel.d.ts.map +0 -1
- package/dist/ui/components/MultiLineInput.d.ts +0 -13
- package/dist/ui/components/MultiLineInput.d.ts.map +0 -1
- package/dist/ui/components/PasswordPrompt.d.ts +0 -9
- package/dist/ui/components/PasswordPrompt.d.ts.map +0 -1
- package/dist/ui/components/PlanAcceptedMessage.d.ts +0 -20
- package/dist/ui/components/PlanAcceptedMessage.d.ts.map +0 -1
- package/dist/ui/components/PlanReviewScreen.d.ts +0 -14
- package/dist/ui/components/PlanReviewScreen.d.ts.map +0 -1
- package/dist/ui/components/SelectPrompt.d.ts +0 -12
- package/dist/ui/components/SelectPrompt.d.ts.map +0 -1
- package/dist/ui/components/SlashCommandAutocomplete.d.ts +0 -13
- package/dist/ui/components/SlashCommandAutocomplete.d.ts.map +0 -1
- package/dist/ui/components/StatusBar.d.ts +0 -14
- package/dist/ui/components/StatusBar.d.ts.map +0 -1
- package/dist/ui/components/StreamingMessageDisplay.d.ts +0 -15
- package/dist/ui/components/StreamingMessageDisplay.d.ts.map +0 -1
- package/dist/ui/components/TaskCompletedMessage.d.ts +0 -14
- package/dist/ui/components/TaskCompletedMessage.d.ts.map +0 -1
- package/dist/ui/components/TaskProgressIndicator.d.ts +0 -18
- package/dist/ui/components/TaskProgressIndicator.d.ts.map +0 -1
- package/dist/ui/components/ThinkingDisplay.d.ts +0 -15
- package/dist/ui/components/ThinkingDisplay.d.ts.map +0 -1
- package/dist/ui/components/ToolExecutionMessage.d.ts +0 -8
- package/dist/ui/components/ToolExecutionMessage.d.ts.map +0 -1
- package/dist/ui/components/ToolExecutionStatus.d.ts +0 -10
- package/dist/ui/components/ToolExecutionStatus.d.ts.map +0 -1
- package/dist/ui/components/ToolResult.d.ts +0 -10
- package/dist/ui/components/ToolResult.d.ts.map +0 -1
- package/dist/ui/components/VersionUpdatePrompt.d.ts +0 -9
- package/dist/ui/components/VersionUpdatePrompt.d.ts.map +0 -1
- package/dist/ui/components/WelcomeBanner.d.ts +0 -3
- package/dist/ui/components/WelcomeBanner.d.ts.map +0 -1
- package/dist/ui/components/WorkflowCreatorScreen.d.ts +0 -25
- package/dist/ui/components/WorkflowCreatorScreen.d.ts.map +0 -1
- package/dist/utils/ansi-encoder.d.ts +0 -7
- package/dist/utils/ansi-encoder.d.ts.map +0 -1
- package/dist/utils/chat-formatter.d.ts +0 -12
- package/dist/utils/chat-formatter.d.ts.map +0 -1
- package/dist/utils/command-history.d.ts +0 -24
- package/dist/utils/command-history.d.ts.map +0 -1
- package/dist/utils/context-sanitizer.d.ts +0 -50
- package/dist/utils/context-sanitizer.d.ts.map +0 -1
- package/dist/utils/conversation-logger.d.ts +0 -142
- package/dist/utils/conversation-logger.d.ts.map +0 -1
- package/dist/utils/custom-commands-manager.d.ts +0 -59
- package/dist/utils/custom-commands-manager.d.ts.map +0 -1
- package/dist/utils/editor-utils.d.ts +0 -101
- package/dist/utils/editor-utils.d.ts.map +0 -1
- package/dist/utils/file.d.ts +0 -61
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/input-classifier.d.ts +0 -25
- package/dist/utils/input-classifier.d.ts.map +0 -1
- package/dist/utils/logger.d.ts +0 -17
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/markdown-parser.d.ts +0 -60
- package/dist/utils/markdown-parser.d.ts.map +0 -1
- package/dist/utils/shell.d.ts +0 -47
- package/dist/utils/shell.d.ts.map +0 -1
- package/dist/utils/state.d.ts +0 -13
- package/dist/utils/state.d.ts.map +0 -1
- package/dist/utils/syntax-checker.d.ts +0 -24
- package/dist/utils/syntax-checker.d.ts.map +0 -1
- package/dist/utils/terminal-output.d.ts +0 -25
- package/dist/utils/terminal-output.d.ts.map +0 -1
- package/dist/utils/text-clipboard.d.ts +0 -12
- package/dist/utils/text-clipboard.d.ts.map +0 -1
- package/dist/utils/unicode-sanitizer.d.ts +0 -44
- package/dist/utils/unicode-sanitizer.d.ts.map +0 -1
- package/dist/utils/version-checker.d.ts +0 -14
- package/dist/utils/version-checker.d.ts.map +0 -1
package/dist/tools/command.js
CHANGED
|
@@ -1,462 +1,469 @@
|
|
|
1
|
-
import * as shellUtils from
|
|
2
|
-
import * as fs from
|
|
3
|
-
import * as path from
|
|
4
|
-
import { runWSLCommand, runDockerCommand, runSSHCommand } from
|
|
5
|
-
// Helper to process shell input with escape sequences and special keys
|
|
1
|
+
import * as shellUtils from "../utils/shell.js";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { runWSLCommand, runDockerCommand, runSSHCommand } from "../utils/editor-utils.js";
|
|
6
5
|
function processShellInput(input) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
6
|
+
let processed = input.replace(/\\n/g, "\r").replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\b/g, "\b").replace(/\\x1B/g, "\x1B");
|
|
7
|
+
const keyMap = {
|
|
8
|
+
"[UP]": "\x1B[A",
|
|
9
|
+
"[DOWN]": "\x1B[B",
|
|
10
|
+
"[RIGHT]": "\x1B[C",
|
|
11
|
+
"[LEFT]": "\x1B[D",
|
|
12
|
+
"[ENTER]": "\r",
|
|
13
|
+
// Enter key sends CR
|
|
14
|
+
"[TAB]": " ",
|
|
15
|
+
"[ESC]": "\x1B",
|
|
16
|
+
"[BACKSPACE]": "\b",
|
|
17
|
+
"[CTRL+C]": "",
|
|
18
|
+
"[CTRL+D]": "",
|
|
19
|
+
"[CTRL+Z]": ""
|
|
20
|
+
};
|
|
21
|
+
for (const [key, code] of Object.entries(keyMap)) {
|
|
22
|
+
processed = processed.split(key).join(code);
|
|
23
|
+
}
|
|
24
|
+
return processed;
|
|
25
|
+
}
|
|
26
|
+
function resolveCommandWorkingDirectory(currentContext, contextCwd, commandCwd) {
|
|
27
|
+
if (currentContext.type === "local") {
|
|
28
|
+
return commandCwd ? path.resolve(contextCwd, commandCwd) : contextCwd;
|
|
29
|
+
}
|
|
30
|
+
const remoteBase = currentContext.metadata?.workingDirectory || contextCwd || "~";
|
|
31
|
+
if (!commandCwd) {
|
|
32
|
+
return remoteBase;
|
|
33
|
+
}
|
|
34
|
+
return path.posix.isAbsolute(commandCwd) ? commandCwd : path.posix.join(remoteBase, commandCwd);
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
**NEVER PROPOSE A cd COMMAND**.
|
|
39
|
-
If you have this tool, note that you DO have the ability to run commands directly on the USER's system.
|
|
40
|
-
Make sure to specify CommandLine exactly as it should be run in the shell.
|
|
41
|
-
Note that the user will have to approve the command before it is executed. The user may reject it if it is not to their liking.
|
|
42
|
-
The actual command will NOT execute until the user approves it. The user may not approve it immediately.
|
|
43
|
-
If the step is WAITING for user approval, it has NOT started running.
|
|
44
|
-
If the step returns a command id, it means that the command was sent to the background. You should use the command_status tool to monitor the output and status of the command.
|
|
36
|
+
const runCommandTool = {
|
|
37
|
+
schema: {
|
|
38
|
+
name: "execute_command",
|
|
39
|
+
description: `PROPOSE a command to run on behalf of the user. Operating System: windows. Shell: pwsh.
|
|
40
|
+
**NEVER PROPOSE A cd COMMAND**.
|
|
41
|
+
If you have this tool, note that you DO have the ability to run commands directly on the USER's system.
|
|
42
|
+
Make sure to specify CommandLine exactly as it should be run in the shell.
|
|
43
|
+
Note that the user will have to approve the command before it is executed. The user may reject it if it is not to their liking.
|
|
44
|
+
The actual command will NOT execute until the user approves it. The user may not approve it immediately.
|
|
45
|
+
If the step is WAITING for user approval, it has NOT started running.
|
|
46
|
+
If the step returns a command id, it means that the command was sent to the background. You should use the command_status tool to monitor the output and status of the command.
|
|
45
47
|
Commands will be run with PAGER=cat. You may want to limit the length of output for commands that usually rely on paging and may contain very long output (e.g. git log, use git log -n <N>).`,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
CommandLine: {
|
|
54
|
-
type: 'string',
|
|
55
|
-
description: 'The exact command line string to execute.',
|
|
56
|
-
},
|
|
57
|
-
Cwd: {
|
|
58
|
-
type: 'string',
|
|
59
|
-
description: 'The current working directory for the command',
|
|
60
|
-
},
|
|
61
|
-
SafeToAutoRun: {
|
|
62
|
-
type: 'boolean',
|
|
63
|
-
description: 'Set to true if you believe that this command is safe to run WITHOUT user approval. A command is unsafe if it may have some destructive side-effects. Example unsafe side-effects include: deleting files, mutating state, installing system dependencies, making external requests, etc. Set to true only if you are extremely confident it is safe. If you feel the command could be unsafe, never set this to true, EVEN if the USER asks you to. It is imperative that you never auto-run a potentially unsafe command.',
|
|
64
|
-
},
|
|
65
|
-
WaitMsBeforeAsync: {
|
|
66
|
-
type: 'integer',
|
|
67
|
-
description: 'This specifies the number of milliseconds to wait after starting the command before sending it to the background. If you want the command to complete execution synchronously, set this to a large enough value that you expect the command to complete in that time under ordinary circumstances. If you\'re starting an interactive or long-running command, set it to a large enough value that it would cause possible failure cases to execute synchronously (e.g. 500ms). Keep the value as small as possible, with a maximum of 10000ms.',
|
|
68
|
-
},
|
|
69
|
-
shell_input: {
|
|
70
|
-
type: 'string',
|
|
71
|
-
description: '[INTERNAL - DO NOT USE FROM MAIN AGENT] Input to send to a CURRENTLY RUNNING interactive shell. This parameter is used internally by the shell input sub-agent. When starting a command, do NOT set this parameter - just start the command and the user will provide input through the shell UI or agent control mode.',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
required: ['reason_text', 'CommandLine', 'Cwd', 'SafeToAutoRun', 'WaitMsBeforeAsync'],
|
|
48
|
+
parameters: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
reason_text: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: 'REQUIRED: A brief explanation of why you are executing this command and what you expect it to do. This will be shown to the user. Example: "Running npm install to install the project dependencies"'
|
|
75
54
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
55
|
+
CommandLine: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "The exact command line string to execute."
|
|
58
|
+
},
|
|
59
|
+
Cwd: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "The current working directory for the command"
|
|
62
|
+
},
|
|
63
|
+
SafeToAutoRun: {
|
|
64
|
+
type: "boolean",
|
|
65
|
+
description: "Set to true if you believe that this command is safe to run WITHOUT user approval. A command is unsafe if it may have some destructive side-effects. Example unsafe side-effects include: deleting files, mutating state, installing system dependencies, making external requests, etc. Set to true only if you are extremely confident it is safe. If you feel the command could be unsafe, never set this to true, EVEN if the USER asks you to. It is imperative that you never auto-run a potentially unsafe command."
|
|
66
|
+
},
|
|
67
|
+
WaitMsBeforeAsync: {
|
|
68
|
+
type: "integer",
|
|
69
|
+
description: "This specifies the number of milliseconds to wait after starting the command before sending it to the background. If you want the command to complete execution synchronously, set this to a large enough value that you expect the command to complete in that time under ordinary circumstances. If you're starting an interactive or long-running command, set it to a large enough value that it would cause possible failure cases to execute synchronously (e.g. 500ms). Keep the value as small as possible, with a maximum of 10000ms."
|
|
70
|
+
},
|
|
71
|
+
shell_input: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "[INTERNAL - DO NOT USE FROM MAIN AGENT] Input to send to a CURRENTLY RUNNING interactive shell. This parameter is used internally by the shell input sub-agent. When starting a command, do NOT set this parameter - just start the command and the user will provide input through the shell UI or agent control mode."
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
required: ["reason_text", "CommandLine", "Cwd", "SafeToAutoRun", "WaitMsBeforeAsync"]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
async execute(args, context) {
|
|
80
|
+
const { CommandLine, Cwd, shell_input } = args;
|
|
81
|
+
if (shell_input) {
|
|
82
|
+
if (context.cliAdapter) {
|
|
83
|
+
const interactiveProcess = context.cliAdapter.getCurrentInteractiveProcess();
|
|
84
|
+
if (!interactiveProcess) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Cannot use shell_input when no interactive shell is running. To run an interactive command:
|
|
87
|
+
1. First, run the command WITHOUT shell_input - just use CommandLine
|
|
88
|
+
2. The interactive shell will open and you can provide input there
|
|
89
|
+
3. Agent Control mode (if enabled) will automatically handle input prompts
|
|
90
|
+
|
|
91
|
+
Please retry: run the command first, then input will be handled automatically.`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const processedInput = processShellInput(shell_input);
|
|
95
|
+
interactiveProcess.write(processedInput);
|
|
96
|
+
const readableSent = processedInput.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\x1B/g, "^[").replace(/\u0003/g, "^C");
|
|
97
|
+
return `Sent input to active shell: ${readableSent}`;
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error("CLI adapter not available for shell input.");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const command = CommandLine;
|
|
103
|
+
const contextManager = context.contextManager;
|
|
104
|
+
const currentContext = contextManager.getCurrentContext();
|
|
105
|
+
const isChainedCommand = /&&|;/.test(command);
|
|
106
|
+
const cdMatch = !isChainedCommand && command.match(/^cd\s+(.+)$/);
|
|
107
|
+
if (cdMatch) {
|
|
108
|
+
if (currentContext.type === "local") {
|
|
109
|
+
const targetDir = cdMatch[1].trim();
|
|
110
|
+
const newCwd = path.resolve(Cwd || context.cwd, targetDir);
|
|
111
|
+
if (!fs.existsSync(newCwd)) {
|
|
112
|
+
throw new Error(`Directory not found: ${targetDir}
|
|
113
|
+
|
|
114
|
+
Action: Use 'list_directory' to verify the directory structure.`);
|
|
115
|
+
}
|
|
116
|
+
if (!fs.statSync(newCwd).isDirectory()) {
|
|
117
|
+
throw new Error(`Path is not a directory: ${targetDir}
|
|
118
|
+
|
|
119
|
+
Action: Verify the path points to a directory, not a file.`);
|
|
120
|
+
}
|
|
121
|
+
contextManager.updateWorkingDirectory(newCwd);
|
|
122
|
+
if (context.cliAdapter) {
|
|
123
|
+
context.cliAdapter.cwd = newCwd;
|
|
124
|
+
if (context.cliAdapter.onCwdChange) {
|
|
125
|
+
context.cliAdapter.onCwdChange(newCwd);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return `Changed directory to: ${newCwd}`;
|
|
129
|
+
} else {
|
|
130
|
+
const targetDir = cdMatch[1].trim();
|
|
131
|
+
const result = await contextManager.executeCommand(`cd ${targetDir}`);
|
|
132
|
+
if (result.exitCode === 0) {
|
|
133
|
+
if (currentContext.handler) {
|
|
134
|
+
const newCwd = await currentContext.handler.getCurrentWorkingDirectory();
|
|
135
|
+
if (newCwd) {
|
|
136
|
+
contextManager.updateWorkingDirectory(newCwd);
|
|
137
|
+
if (context.cliAdapter) {
|
|
138
|
+
context.cliAdapter.cwd = newCwd;
|
|
139
|
+
if (context.cliAdapter.onCwdChange) {
|
|
140
|
+
context.cliAdapter.onCwdChange(newCwd);
|
|
92
141
|
}
|
|
93
|
-
|
|
94
|
-
const processedInput = processShellInput(shell_input);
|
|
95
|
-
// Send the processed input
|
|
96
|
-
interactiveProcess.write(processedInput);
|
|
97
|
-
// Return readable confirmation (showing what was actually sent)
|
|
98
|
-
const readableSent = processedInput
|
|
99
|
-
.replace(/\n/g, '\\n')
|
|
100
|
-
.replace(/\r/g, '\\r')
|
|
101
|
-
.replace(/\x1B/g, '^[')
|
|
102
|
-
.replace(/\u0003/g, '^C');
|
|
103
|
-
return `Sent input to active shell: ${readableSent}`;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
throw new Error('CLI adapter not available for shell input.');
|
|
142
|
+
}
|
|
107
143
|
}
|
|
144
|
+
}
|
|
145
|
+
return `Changed directory to: ${contextManager.getCurrentContext().metadata.workingDirectory}`;
|
|
146
|
+
} else {
|
|
147
|
+
throw new Error(`${result.stderr || "Failed to change directory"}
|
|
148
|
+
|
|
149
|
+
Action: Verify the directory exists in the remote environment.`);
|
|
108
150
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const longRunningPatterns = [
|
|
154
|
+
/npm\s+run\s+dev/,
|
|
155
|
+
/npm\s+run\s+start/,
|
|
156
|
+
/npm\s+start/,
|
|
157
|
+
/yarn\s+dev/,
|
|
158
|
+
/yarn\s+start/,
|
|
159
|
+
/pnpm\s+dev/,
|
|
160
|
+
/pnpm\s+start/,
|
|
161
|
+
/python\s+-m\s+http\.server/,
|
|
162
|
+
/python3\s+-m\s+http\.server/,
|
|
163
|
+
/php\s+-S/,
|
|
164
|
+
/ruby\s+-run\s+-e\s+httpd/,
|
|
165
|
+
/serve\s+/,
|
|
166
|
+
/http-server/,
|
|
167
|
+
/webpack\s+--watch/,
|
|
168
|
+
/webpack-dev-server/,
|
|
169
|
+
/vite(?:\s+(?!build)|\s*$)/,
|
|
170
|
+
/next\s+dev/,
|
|
171
|
+
/gatsby\s+develop/,
|
|
172
|
+
/rails\s+server/,
|
|
173
|
+
/rails\s+s\b/,
|
|
174
|
+
/django\s+runserver/,
|
|
175
|
+
/manage\.py\s+runserver/,
|
|
176
|
+
/flask\s+run/,
|
|
177
|
+
/nodemon/,
|
|
178
|
+
/ng\s+serve/,
|
|
179
|
+
/ember\s+serve/,
|
|
180
|
+
/hugo\s+server/,
|
|
181
|
+
/jekyll\s+serve/,
|
|
182
|
+
/docker\s+run.*-d/,
|
|
183
|
+
/docker-compose\s+up/,
|
|
184
|
+
/tail\s+-f/,
|
|
185
|
+
/watch\s+/,
|
|
186
|
+
/less\s+/,
|
|
187
|
+
/more\s+/,
|
|
188
|
+
/vim\s+/,
|
|
189
|
+
/vi\s+/,
|
|
190
|
+
/nano\s+/,
|
|
191
|
+
/emacs\s+/
|
|
192
|
+
];
|
|
193
|
+
const isLongRunning = longRunningPatterns.some((pattern) => pattern.test(command));
|
|
194
|
+
if (isLongRunning) {
|
|
195
|
+
throw new Error(
|
|
196
|
+
`This command appears to be a long-running process (like a development server or file watcher). Long-running commands cannot be executed through execute_command as they would block execution.
|
|
197
|
+
|
|
198
|
+
USE THE background_command TOOL INSTEAD:
|
|
199
|
+
- action: "start" to run the command in the background
|
|
200
|
+
- action: "status" to check the output while it runs
|
|
201
|
+
- action: "kill" to terminate when done
|
|
202
|
+
|
|
203
|
+
Command that needs background execution: ${command}`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
const riskyPatterns = [/rm\s+-rf/, /del\s+\/s/, /format/, /dd\s+if=/];
|
|
207
|
+
const isRisky = riskyPatterns.some((pattern) => pattern.test(command));
|
|
208
|
+
const approved = await context.requireApproval(
|
|
209
|
+
`Execute command: ${command}${currentContext.type !== "local" ? ` (in ${currentContext.type} environment)` : ""}`,
|
|
210
|
+
isRisky,
|
|
211
|
+
void 0,
|
|
212
|
+
"execute_command",
|
|
213
|
+
{ command }
|
|
214
|
+
);
|
|
215
|
+
if (typeof approved === "object" && "feedback" in approved) {
|
|
216
|
+
throw new Error(`USER_FEEDBACK: ${approved.feedback}`);
|
|
217
|
+
}
|
|
218
|
+
if (!approved) {
|
|
219
|
+
throw new Error("Operation cancelled by user.");
|
|
220
|
+
}
|
|
221
|
+
const executionCwd = resolveCommandWorkingDirectory(currentContext, context.cwd, Cwd);
|
|
222
|
+
if (currentContext.type === "local") {
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
let output = "";
|
|
225
|
+
let exitCode;
|
|
226
|
+
const interactiveProcess = shellUtils.executeCommandInteractive(
|
|
227
|
+
command,
|
|
228
|
+
executionCwd,
|
|
229
|
+
(data) => {
|
|
230
|
+
output += data;
|
|
231
|
+
if (context.onStreamingOutput) {
|
|
232
|
+
context.onStreamingOutput(data, "stdout");
|
|
136
233
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// Get the actual new working directory from the handler
|
|
143
|
-
if (currentContext.handler) {
|
|
144
|
-
const newCwd = await currentContext.handler.getCurrentWorkingDirectory();
|
|
145
|
-
if (newCwd) {
|
|
146
|
-
contextManager.updateWorkingDirectory(newCwd);
|
|
147
|
-
// Update CLI adapter CWD and notify UI
|
|
148
|
-
if (context.cliAdapter) {
|
|
149
|
-
context.cliAdapter.cwd = newCwd;
|
|
150
|
-
if (context.cliAdapter.onCwdChange) {
|
|
151
|
-
context.cliAdapter.onCwdChange(newCwd);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return `Changed directory to: ${contextManager.getCurrentContext().metadata.workingDirectory}`;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
throw new Error(`${result.stderr || 'Failed to change directory'}\n\nAction: Verify the directory exists in the remote environment.`);
|
|
160
|
-
}
|
|
234
|
+
},
|
|
235
|
+
(code) => {
|
|
236
|
+
exitCode = code;
|
|
237
|
+
if (context.cliAdapter) {
|
|
238
|
+
context.cliAdapter.setCurrentInteractiveProcess(void 0);
|
|
161
239
|
}
|
|
240
|
+
if (code === 0) {
|
|
241
|
+
resolve(output || "Command executed successfully");
|
|
242
|
+
} else {
|
|
243
|
+
const errorOutput = output + `
|
|
244
|
+
Exit Code: ${code}`;
|
|
245
|
+
reject(new Error(`${errorOutput || `Command failed with exit code ${code}`}
|
|
246
|
+
|
|
247
|
+
Possible reasons:
|
|
248
|
+
1. The command is invalid or not installed.
|
|
249
|
+
2. The arguments are incorrect.
|
|
250
|
+
3. The command requires user input (interactive mode).`));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
if (context.cliAdapter) {
|
|
255
|
+
context.cliAdapter.setCurrentInteractiveProcess(interactiveProcess);
|
|
162
256
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
`- action: "kill" to terminate when done\n\n` +
|
|
212
|
-
`Command that needs background execution: ${command}`);
|
|
213
|
-
}
|
|
214
|
-
// Check for risky commands
|
|
215
|
-
const riskyPatterns = [/rm\s+-rf/, /del\s+\/s/, /format/, /dd\s+if=/];
|
|
216
|
-
const isRisky = riskyPatterns.some((pattern) => pattern.test(command));
|
|
217
|
-
const approved = await context.requireApproval(`Execute command: ${command}${currentContext.type !== 'local' ? ` (in ${currentContext.type} environment)` : ''}`, isRisky, undefined, 'execute_command', { command });
|
|
218
|
-
// Check for feedback object (user rejected with feedback)
|
|
219
|
-
if (typeof approved === 'object' && 'feedback' in approved) {
|
|
220
|
-
throw new Error(`USER_FEEDBACK: ${approved.feedback}`);
|
|
257
|
+
});
|
|
258
|
+
} else if (currentContext.type === "wsl") {
|
|
259
|
+
const remoteCwd = executionCwd;
|
|
260
|
+
const distribution = currentContext.metadata?.distroName || "Ubuntu";
|
|
261
|
+
return new Promise((resolve, reject) => {
|
|
262
|
+
let output = "";
|
|
263
|
+
const constrainedCols = Math.max(40, (process.stdout.columns || 80) - 4);
|
|
264
|
+
const constrainedRows = Math.min(process.stdout.rows || 24, 50);
|
|
265
|
+
const wslPty = runWSLCommand(
|
|
266
|
+
distribution,
|
|
267
|
+
command,
|
|
268
|
+
remoteCwd,
|
|
269
|
+
(data) => {
|
|
270
|
+
output += data;
|
|
271
|
+
if (context.onStreamingOutput) {
|
|
272
|
+
context.onStreamingOutput(data, "stdout");
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
(exitCode) => {
|
|
276
|
+
if (context.cliAdapter) {
|
|
277
|
+
context.cliAdapter.setCurrentInteractiveProcess(void 0);
|
|
278
|
+
}
|
|
279
|
+
if (exitCode !== 0) {
|
|
280
|
+
reject(new Error(`${output || `Command failed with exit code ${exitCode}`}
|
|
281
|
+
|
|
282
|
+
Possible reasons:
|
|
283
|
+
1. The command is invalid or not installed.
|
|
284
|
+
2. The arguments are incorrect.`));
|
|
285
|
+
} else {
|
|
286
|
+
resolve(output || "Command executed successfully");
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
constrainedCols,
|
|
290
|
+
constrainedRows
|
|
291
|
+
);
|
|
292
|
+
if (context.cliAdapter) {
|
|
293
|
+
context.cliAdapter.setCurrentInteractiveProcess({
|
|
294
|
+
process: null,
|
|
295
|
+
write: (data) => wslPty.write(data),
|
|
296
|
+
kill: () => wslPty.kill(),
|
|
297
|
+
signal: (sig) => {
|
|
298
|
+
if (sig === "SIGINT") {
|
|
299
|
+
wslPty.write("");
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
resize: (cols, rows) => wslPty.resize(cols, rows),
|
|
303
|
+
isPty: true
|
|
304
|
+
});
|
|
221
305
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
306
|
+
});
|
|
307
|
+
} else if (currentContext.type === "docker") {
|
|
308
|
+
const parentContext = contextManager.getParentContext();
|
|
309
|
+
const remoteCwd = executionCwd;
|
|
310
|
+
const containerId = currentContext.metadata?.containerId || "";
|
|
311
|
+
const constrainedCols = Math.max(40, (process.stdout.columns || 80) - 4);
|
|
312
|
+
const constrainedRows = Math.min(process.stdout.rows || 24, 50);
|
|
313
|
+
if (parentContext && parentContext.type === "ssh") {
|
|
314
|
+
const sshClient = parentContext.handler?.client;
|
|
315
|
+
if (!sshClient) {
|
|
316
|
+
throw new Error("SSH client not available for nested Docker session");
|
|
225
317
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
318
|
+
const escapedCommand = command.replace(/"/g, '\\"');
|
|
319
|
+
const dockerCommand = `docker exec -w "${remoteCwd}" ${containerId} sh -c "${escapedCommand}"`;
|
|
320
|
+
return new Promise((resolve, reject) => {
|
|
321
|
+
let output = "";
|
|
322
|
+
const sshPty = runSSHCommand(
|
|
323
|
+
sshClient,
|
|
324
|
+
dockerCommand,
|
|
325
|
+
parentContext.metadata.workingDirectory || "~",
|
|
326
|
+
(data) => {
|
|
327
|
+
output += data;
|
|
328
|
+
if (context.onStreamingOutput) {
|
|
329
|
+
context.onStreamingOutput(data, "stdout");
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
(exitCode) => {
|
|
333
|
+
if (context.cliAdapter) {
|
|
334
|
+
context.cliAdapter.setCurrentInteractiveProcess(void 0);
|
|
335
|
+
}
|
|
336
|
+
if (exitCode !== 0) {
|
|
337
|
+
reject(new Error(`${output || `Command failed with exit code ${exitCode}`}
|
|
338
|
+
|
|
339
|
+
Possible reasons:
|
|
340
|
+
1. The command is invalid or not installed in the container.
|
|
341
|
+
2. The arguments are incorrect.
|
|
342
|
+
3. The Docker container may not be running.`));
|
|
343
|
+
} else {
|
|
344
|
+
resolve(output || "Command executed successfully");
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
constrainedCols,
|
|
348
|
+
constrainedRows
|
|
349
|
+
);
|
|
350
|
+
if (context.cliAdapter) {
|
|
351
|
+
context.cliAdapter.setCurrentInteractiveProcess({
|
|
352
|
+
process: null,
|
|
353
|
+
write: (data) => sshPty.write(data),
|
|
354
|
+
kill: () => sshPty.kill(),
|
|
355
|
+
signal: (sig) => {
|
|
356
|
+
if (sig === "SIGINT") {
|
|
357
|
+
sshPty.write("");
|
|
262
358
|
}
|
|
359
|
+
},
|
|
360
|
+
resize: (cols, rows) => sshPty.resize(cols, rows),
|
|
361
|
+
isPty: true
|
|
263
362
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
signal: (sig) => {
|
|
305
|
-
if (sig === 'SIGINT') {
|
|
306
|
-
wslPty.write('\x03'); // Ctrl+C
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
resize: (cols, rows) => wslPty.resize(cols, rows),
|
|
310
|
-
isPty: true
|
|
311
|
-
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
} else {
|
|
366
|
+
return new Promise((resolve, reject) => {
|
|
367
|
+
let output = "";
|
|
368
|
+
const dockerPty = runDockerCommand(
|
|
369
|
+
containerId,
|
|
370
|
+
command,
|
|
371
|
+
remoteCwd,
|
|
372
|
+
(data) => {
|
|
373
|
+
output += data;
|
|
374
|
+
if (context.onStreamingOutput) {
|
|
375
|
+
context.onStreamingOutput(data, "stdout");
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
(exitCode) => {
|
|
379
|
+
if (context.cliAdapter) {
|
|
380
|
+
context.cliAdapter.setCurrentInteractiveProcess(void 0);
|
|
381
|
+
}
|
|
382
|
+
if (exitCode !== 0) {
|
|
383
|
+
reject(new Error(`${output || `Command failed with exit code ${exitCode}`}
|
|
384
|
+
|
|
385
|
+
Possible reasons:
|
|
386
|
+
1. The command is invalid or not installed.
|
|
387
|
+
2. The arguments are incorrect.`));
|
|
388
|
+
} else {
|
|
389
|
+
resolve(output || "Command executed successfully");
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
constrainedCols,
|
|
393
|
+
constrainedRows
|
|
394
|
+
);
|
|
395
|
+
if (context.cliAdapter) {
|
|
396
|
+
context.cliAdapter.setCurrentInteractiveProcess({
|
|
397
|
+
process: null,
|
|
398
|
+
write: (data) => dockerPty.write(data),
|
|
399
|
+
kill: () => dockerPty.kill(),
|
|
400
|
+
signal: (sig) => {
|
|
401
|
+
if (sig === "SIGINT") {
|
|
402
|
+
dockerPty.write("");
|
|
312
403
|
}
|
|
404
|
+
},
|
|
405
|
+
resize: (cols, rows) => dockerPty.resize(cols, rows),
|
|
406
|
+
isPty: true
|
|
313
407
|
});
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return new Promise((resolve, reject) => {
|
|
336
|
-
let output = '';
|
|
337
|
-
const sshPty = runSSHCommand(sshClient, dockerCommand, parentContext.metadata.workingDirectory || '~', (data) => {
|
|
338
|
-
// Stream output to UI
|
|
339
|
-
output += data;
|
|
340
|
-
if (context.onStreamingOutput) {
|
|
341
|
-
context.onStreamingOutput(data, 'stdout');
|
|
342
|
-
}
|
|
343
|
-
}, (exitCode) => {
|
|
344
|
-
// Clear the interactive process
|
|
345
|
-
if (context.cliAdapter) {
|
|
346
|
-
context.cliAdapter.setCurrentInteractiveProcess(undefined);
|
|
347
|
-
}
|
|
348
|
-
if (exitCode !== 0) {
|
|
349
|
-
reject(new Error(`${output || `Command failed with exit code ${exitCode}`}\n\nPossible reasons:\n1. The command is invalid or not installed in the container.\n2. The arguments are incorrect.\n3. The Docker container may not be running.`));
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
resolve(output || 'Command executed successfully');
|
|
353
|
-
}
|
|
354
|
-
}, constrainedCols, constrainedRows);
|
|
355
|
-
// Set up interactive process for stdin
|
|
356
|
-
if (context.cliAdapter) {
|
|
357
|
-
context.cliAdapter.setCurrentInteractiveProcess({
|
|
358
|
-
process: null,
|
|
359
|
-
write: (data) => sshPty.write(data),
|
|
360
|
-
kill: () => sshPty.kill(),
|
|
361
|
-
signal: (sig) => {
|
|
362
|
-
if (sig === 'SIGINT') {
|
|
363
|
-
sshPty.write('\x03'); // Ctrl+C
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
resize: (cols, rows) => sshPty.resize(cols, rows),
|
|
367
|
-
isPty: true
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
});
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
} else if (currentContext.type === "ssh") {
|
|
412
|
+
const remoteCwd = executionCwd;
|
|
413
|
+
const sshClient = currentContext.handler?.client;
|
|
414
|
+
if (!sshClient) {
|
|
415
|
+
throw new Error("SSH client not available");
|
|
416
|
+
}
|
|
417
|
+
return new Promise((resolve, reject) => {
|
|
418
|
+
let output = "";
|
|
419
|
+
const constrainedCols = Math.max(40, (process.stdout.columns || 80) - 4);
|
|
420
|
+
const constrainedRows = Math.min(process.stdout.rows || 24, 50);
|
|
421
|
+
const sshPty = runSSHCommand(
|
|
422
|
+
sshClient,
|
|
423
|
+
command,
|
|
424
|
+
remoteCwd,
|
|
425
|
+
(data) => {
|
|
426
|
+
output += data;
|
|
427
|
+
if (context.onStreamingOutput) {
|
|
428
|
+
context.onStreamingOutput(data, "stdout");
|
|
371
429
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const dockerPty = runDockerCommand(containerId, command, remoteCwd, (data) => {
|
|
377
|
-
// Stream output to UI
|
|
378
|
-
output += data;
|
|
379
|
-
if (context.onStreamingOutput) {
|
|
380
|
-
context.onStreamingOutput(data, 'stdout');
|
|
381
|
-
}
|
|
382
|
-
}, (exitCode) => {
|
|
383
|
-
// Clear the interactive process
|
|
384
|
-
if (context.cliAdapter) {
|
|
385
|
-
context.cliAdapter.setCurrentInteractiveProcess(undefined);
|
|
386
|
-
}
|
|
387
|
-
if (exitCode !== 0) {
|
|
388
|
-
reject(new Error(`${output || `Command failed with exit code ${exitCode}`}\n\nPossible reasons:\n1. The command is invalid or not installed.\n2. The arguments are incorrect.`));
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
resolve(output || 'Command executed successfully');
|
|
392
|
-
}
|
|
393
|
-
}, constrainedCols, constrainedRows);
|
|
394
|
-
// Set up interactive process for stdin
|
|
395
|
-
if (context.cliAdapter) {
|
|
396
|
-
context.cliAdapter.setCurrentInteractiveProcess({
|
|
397
|
-
process: null,
|
|
398
|
-
write: (data) => dockerPty.write(data),
|
|
399
|
-
kill: () => dockerPty.kill(),
|
|
400
|
-
signal: (sig) => {
|
|
401
|
-
if (sig === 'SIGINT') {
|
|
402
|
-
dockerPty.write('\x03'); // Ctrl+C
|
|
403
|
-
}
|
|
404
|
-
},
|
|
405
|
-
resize: (cols, rows) => dockerPty.resize(cols, rows),
|
|
406
|
-
isPty: true
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
});
|
|
430
|
+
},
|
|
431
|
+
(exitCode) => {
|
|
432
|
+
if (context.cliAdapter) {
|
|
433
|
+
context.cliAdapter.setCurrentInteractiveProcess(void 0);
|
|
410
434
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
435
|
+
if (exitCode !== 0) {
|
|
436
|
+
reject(new Error(`${output || `Command failed with exit code ${exitCode}`}
|
|
437
|
+
|
|
438
|
+
Possible reasons:
|
|
439
|
+
1. The command is invalid or not installed.
|
|
440
|
+
2. The arguments are incorrect.`));
|
|
441
|
+
} else {
|
|
442
|
+
resolve(output || "Command executed successfully");
|
|
419
443
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
reject(new Error(`${output || `Command failed with exit code ${exitCode}`}\n\nPossible reasons:\n1. The command is invalid or not installed.\n2. The arguments are incorrect.`));
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
resolve(output || 'Command executed successfully');
|
|
441
|
-
}
|
|
442
|
-
}, constrainedCols, constrainedRows);
|
|
443
|
-
// Set up interactive process for stdin
|
|
444
|
-
if (context.cliAdapter) {
|
|
445
|
-
context.cliAdapter.setCurrentInteractiveProcess({
|
|
446
|
-
process: null,
|
|
447
|
-
write: (data) => sshPty.write(data),
|
|
448
|
-
kill: () => sshPty.kill(),
|
|
449
|
-
signal: (sig) => {
|
|
450
|
-
if (sig === 'SIGINT') {
|
|
451
|
-
sshPty.write('\x03'); // Ctrl+C
|
|
452
|
-
}
|
|
453
|
-
},
|
|
454
|
-
resize: (cols, rows) => sshPty.resize(cols, rows),
|
|
455
|
-
isPty: true
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
});
|
|
444
|
+
},
|
|
445
|
+
constrainedCols,
|
|
446
|
+
constrainedRows
|
|
447
|
+
);
|
|
448
|
+
if (context.cliAdapter) {
|
|
449
|
+
context.cliAdapter.setCurrentInteractiveProcess({
|
|
450
|
+
process: null,
|
|
451
|
+
write: (data) => sshPty.write(data),
|
|
452
|
+
kill: () => sshPty.kill(),
|
|
453
|
+
signal: (sig) => {
|
|
454
|
+
if (sig === "SIGINT") {
|
|
455
|
+
sshPty.write("");
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
resize: (cols, rows) => sshPty.resize(cols, rows),
|
|
459
|
+
isPty: true
|
|
460
|
+
});
|
|
459
461
|
}
|
|
460
|
-
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
export {
|
|
467
|
+
runCommandTool
|
|
461
468
|
};
|
|
462
469
|
//# sourceMappingURL=command.js.map
|