centaurus-cli 3.0.0 → 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 -5037
- 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 +1513 -973
- 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 +605 -537
- 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 -400
- 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 -3249
- 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 -511
- 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 -167
- 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
|
@@ -1,213 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- "
|
|
24
|
-
- "
|
|
25
|
-
- "Password: " (password prompt)
|
|
26
|
-
- "Press any key to continue..."
|
|
27
|
-
- "[sudo] password for user:"
|
|
28
|
-
- "Select option [1/2/3]:"
|
|
29
|
-
|
|
30
|
-
Examples of NOT waiting (answer NO):
|
|
31
|
-
- "Installing packages..." (still processing)
|
|
32
|
-
- "Building project..." (active work)
|
|
33
|
-
- "Downloading file 50%..." (progress indicator)
|
|
34
|
-
- Empty shell prompt like "PS C:\\>" or "user@host:~$"
|
|
1
|
+
import { aiServiceClient } from "./ai-service-client.js";
|
|
2
|
+
import { quickLog } from "../utils/conversation-logger.js";
|
|
3
|
+
import { ShellInputAgent } from "./shell-input-agent.js";
|
|
4
|
+
import { extractPromptContext } from "./input-requirement-detector.js";
|
|
5
|
+
const MODEL = "gemini-2.0-flash-lite";
|
|
6
|
+
const POLLING_INTERVAL_MS = 500;
|
|
7
|
+
const MAX_OUTPUT_CHARS = 2e3;
|
|
8
|
+
const DETECTION_SYSTEM_PROMPT = `You are a shell input detector. Your ONLY job is to determine if a running command is WAITING for user input.
|
|
9
|
+
|
|
10
|
+
Answer ONLY with "YES" or "NO" - no other text.
|
|
11
|
+
|
|
12
|
+
Examples of WAITING for input (answer YES):
|
|
13
|
+
- "Enter your name: " (ends with colon, expecting text)
|
|
14
|
+
- "Continue? (y/n)" (yes/no question)
|
|
15
|
+
- "Password: " (password prompt)
|
|
16
|
+
- "Press any key to continue..."
|
|
17
|
+
- "[sudo] password for user:"
|
|
18
|
+
- "Select option [1/2/3]:"
|
|
19
|
+
|
|
20
|
+
Examples of NOT waiting (answer NO):
|
|
21
|
+
- "Installing packages..." (still processing)
|
|
22
|
+
- "Building project..." (active work)
|
|
23
|
+
- "Downloading file 50%..." (progress indicator)
|
|
24
|
+
- Empty shell prompt like "PS C:\\>" or "user@host:~$"
|
|
35
25
|
- Just finished printing output (no prompt visible)`;
|
|
36
|
-
// ==================== InputDetectionAgent Class ====================
|
|
37
26
|
class InputDetectionAgentClass {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ShellInputAgent.handleInputPrompt(shellId, currentOutput, promptContext, inputType, 'high' // AI detection = high confidence
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (!isWaiting) {
|
|
108
|
-
session.lastDetectionResult = false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
if (error.name !== 'AbortError') {
|
|
113
|
-
quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Detection error: ${error.message}\n`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}, POLLING_INTERVAL_MS);
|
|
117
|
-
this.sessions.set(shellId, session);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Update the shell output for a session
|
|
121
|
-
* This should be called from App.tsx whenever shellState.output changes
|
|
122
|
-
*/
|
|
123
|
-
updateOutput(shellId, output) {
|
|
124
|
-
const session = this.sessions.get(shellId);
|
|
125
|
-
if (session) {
|
|
126
|
-
// Only update if content actually changed
|
|
127
|
-
if (output.length !== session.currentOutput.length || output !== session.currentOutput) {
|
|
128
|
-
session.currentOutput = output;
|
|
129
|
-
session.lastOutputTimestamp = Date.now(); // Reset stability timer
|
|
130
|
-
}
|
|
27
|
+
sessions = /* @__PURE__ */ new Map();
|
|
28
|
+
/**
|
|
29
|
+
* Start polling for a shell session
|
|
30
|
+
* Call updateOutput() to push new shell output to this session
|
|
31
|
+
*/
|
|
32
|
+
startPolling(shellId, initialOutput, command, cwd) {
|
|
33
|
+
this.stopPolling(shellId);
|
|
34
|
+
const abortController = new AbortController();
|
|
35
|
+
const session = {
|
|
36
|
+
shellId,
|
|
37
|
+
intervalId: null,
|
|
38
|
+
currentOutput: initialOutput,
|
|
39
|
+
lastOutputLength: 0,
|
|
40
|
+
lastDetectionResult: false,
|
|
41
|
+
lastTriggerOutputLength: 0,
|
|
42
|
+
isPolling: true,
|
|
43
|
+
abortController,
|
|
44
|
+
lastOutputTimestamp: Date.now(),
|
|
45
|
+
lastProcessedLength: 0
|
|
46
|
+
};
|
|
47
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [InputDetectionAgent] Starting polling for ${shellId}
|
|
48
|
+
`);
|
|
49
|
+
session.intervalId = setInterval(async () => {
|
|
50
|
+
if (!session.isPolling || abortController.signal.aborted) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const currentOutput = session.currentOutput;
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
const timeSinceLastUpdate = now - session.lastOutputTimestamp;
|
|
56
|
+
if (timeSinceLastUpdate < 2e3) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (currentOutput.length === session.lastProcessedLength) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
session.lastProcessedLength = currentOutput.length;
|
|
63
|
+
session.lastOutputLength = currentOutput.length;
|
|
64
|
+
if (session.lastDetectionResult && currentOutput.length > session.lastTriggerOutputLength + 10) {
|
|
65
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [InputDetectionAgent] Resetting detection (output grew from ${session.lastTriggerOutputLength} to ${currentOutput.length})
|
|
66
|
+
`);
|
|
67
|
+
session.lastDetectionResult = false;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const isWaiting = await this.detectInputRequired(currentOutput, abortController.signal);
|
|
71
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [InputDetectionAgent] Detection result: ${isWaiting ? "YES" : "NO"} (stable for ${timeSinceLastUpdate}ms)
|
|
72
|
+
`);
|
|
73
|
+
if (isWaiting && !session.lastDetectionResult) {
|
|
74
|
+
session.lastDetectionResult = true;
|
|
75
|
+
session.lastTriggerOutputLength = currentOutput.length;
|
|
76
|
+
const promptContext = extractPromptContext(currentOutput);
|
|
77
|
+
const inputType = "text input";
|
|
78
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [InputDetectionAgent] Triggering ShellInputAgent for ${shellId}
|
|
79
|
+
`);
|
|
80
|
+
if (ShellInputAgent.isSessionActive(shellId)) {
|
|
81
|
+
ShellInputAgent.handleInputPrompt(
|
|
82
|
+
shellId,
|
|
83
|
+
currentOutput,
|
|
84
|
+
promptContext,
|
|
85
|
+
inputType,
|
|
86
|
+
"high"
|
|
87
|
+
// AI detection = high confidence
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
} else if (!isWaiting) {
|
|
91
|
+
session.lastDetectionResult = false;
|
|
131
92
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
stopPolling(shellId) {
|
|
137
|
-
const session = this.sessions.get(shellId);
|
|
138
|
-
if (session) {
|
|
139
|
-
quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Stopping polling for ${shellId}\n`);
|
|
140
|
-
session.isPolling = false;
|
|
141
|
-
session.abortController.abort();
|
|
142
|
-
if (session.intervalId) {
|
|
143
|
-
clearInterval(session.intervalId);
|
|
144
|
-
}
|
|
145
|
-
this.sessions.delete(shellId);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error.name !== "AbortError") {
|
|
95
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [InputDetectionAgent] Detection error: ${error.message}
|
|
96
|
+
`);
|
|
146
97
|
}
|
|
98
|
+
}
|
|
99
|
+
}, POLLING_INTERVAL_MS);
|
|
100
|
+
this.sessions.set(shellId, session);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Update the shell output for a session
|
|
104
|
+
* This should be called from App.tsx whenever shellState.output changes
|
|
105
|
+
*/
|
|
106
|
+
updateOutput(shellId, output) {
|
|
107
|
+
const session = this.sessions.get(shellId);
|
|
108
|
+
if (session) {
|
|
109
|
+
if (output.length !== session.currentOutput.length || output !== session.currentOutput) {
|
|
110
|
+
session.currentOutput = output;
|
|
111
|
+
session.lastOutputTimestamp = Date.now();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Stop polling for a shell session
|
|
117
|
+
*/
|
|
118
|
+
stopPolling(shellId) {
|
|
119
|
+
const session = this.sessions.get(shellId);
|
|
120
|
+
if (session) {
|
|
121
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [InputDetectionAgent] Stopping polling for ${shellId}
|
|
122
|
+
`);
|
|
123
|
+
session.isPolling = false;
|
|
124
|
+
session.abortController.abort();
|
|
125
|
+
if (session.intervalId) {
|
|
126
|
+
clearInterval(session.intervalId);
|
|
127
|
+
}
|
|
128
|
+
this.sessions.delete(shellId);
|
|
147
129
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Core detection function - calls AI to determine if waiting for input
|
|
133
|
+
*/
|
|
134
|
+
async detectInputRequired(shellOutput, signal) {
|
|
135
|
+
const truncatedOutput = shellOutput.length > MAX_OUTPUT_CHARS ? "..." + shellOutput.slice(-MAX_OUTPUT_CHARS) : shellOutput;
|
|
136
|
+
const userPrompt = `SHELL OUTPUT:
|
|
137
|
+
${truncatedOutput}
|
|
138
|
+
|
|
139
|
+
Is this shell WAITING for user input? Answer YES or NO only.`;
|
|
140
|
+
const messages = [
|
|
141
|
+
{ role: "user", content: DETECTION_SYSTEM_PROMPT + "\n\n" + userPrompt }
|
|
142
|
+
];
|
|
143
|
+
let responseText = "";
|
|
144
|
+
try {
|
|
145
|
+
for await (const chunk of aiServiceClient.streamChat(
|
|
146
|
+
MODEL,
|
|
147
|
+
messages,
|
|
148
|
+
[],
|
|
149
|
+
// No tools needed - just text response
|
|
150
|
+
{
|
|
151
|
+
cwd: ".",
|
|
152
|
+
platform: process.platform,
|
|
153
|
+
shell: "cmd.exe",
|
|
154
|
+
os: "windows",
|
|
155
|
+
homeDir: ""
|
|
156
|
+
},
|
|
157
|
+
void 0,
|
|
158
|
+
void 0,
|
|
159
|
+
signal
|
|
160
|
+
)) {
|
|
161
|
+
if (signal.aborted) {
|
|
162
|
+
throw new Error("AbortError");
|
|
183
163
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const abortError = new Error('AbortError');
|
|
187
|
-
abortError.name = 'AbortError';
|
|
188
|
-
throw abortError;
|
|
189
|
-
}
|
|
190
|
-
throw error;
|
|
164
|
+
if (chunk.type === "text") {
|
|
165
|
+
responseText += chunk.content;
|
|
191
166
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return isYes;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Check if polling is active for a shell
|
|
198
|
-
*/
|
|
199
|
-
isPolling(shellId) {
|
|
200
|
-
return this.sessions.has(shellId) && this.sessions.get(shellId).isPolling;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Stop all polling sessions
|
|
204
|
-
*/
|
|
205
|
-
stopAll() {
|
|
206
|
-
for (const shellId of this.sessions.keys()) {
|
|
207
|
-
this.stopPolling(shellId);
|
|
167
|
+
if (responseText.length >= 3) {
|
|
168
|
+
break;
|
|
208
169
|
}
|
|
170
|
+
}
|
|
171
|
+
} catch (error) {
|
|
172
|
+
if (error.message === "AbortError" || error.name === "AbortError") {
|
|
173
|
+
const abortError = new Error("AbortError");
|
|
174
|
+
abortError.name = "AbortError";
|
|
175
|
+
throw abortError;
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
const isYes = responseText.toUpperCase().includes("YES");
|
|
180
|
+
return isYes;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Check if polling is active for a shell
|
|
184
|
+
*/
|
|
185
|
+
isPolling(shellId) {
|
|
186
|
+
return this.sessions.has(shellId) && this.sessions.get(shellId).isPolling;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Stop all polling sessions
|
|
190
|
+
*/
|
|
191
|
+
stopAll() {
|
|
192
|
+
for (const shellId of this.sessions.keys()) {
|
|
193
|
+
this.stopPolling(shellId);
|
|
209
194
|
}
|
|
195
|
+
}
|
|
210
196
|
}
|
|
211
|
-
|
|
212
|
-
export
|
|
197
|
+
const InputDetectionAgent = new InputDetectionAgentClass();
|
|
198
|
+
export {
|
|
199
|
+
InputDetectionAgent
|
|
200
|
+
};
|
|
213
201
|
//# sourceMappingURL=input-detection-agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-detection-agent.js","sourceRoot":"","sources":["../../src/services/input-detection-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAwB,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,sDAAsD;AAEtD,MAAM,KAAK,GAAG,uBAAuB,CAAC,CAAE,uCAAuC;AAC/E,MAAM,mBAAmB,GAAG,GAAG,CAAC,CAAS,iCAAiC;AAC1E,MAAM,gBAAgB,GAAG,IAAI,CAAC,CAAW,6CAA6C;AAiBtF,oEAAoE;AAEpE,MAAM,uBAA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-agent.ts"],"sourcesContent":["/**\r\n * Input Detection Agent Service\r\n * \r\n * A lightweight AI agent using gemini-2.0-flash-lite that detects when a shell\r\n * is waiting for user input. Polls shell output and returns YES/NO.\r\n * \r\n * When input is detected, triggers the ShellInputAgent to provide the actual input.\r\n */\r\n\r\nimport { aiServiceClient, Message as AIMessage } from './ai-service-client.js';\r\nimport { quickLog } from '../utils/conversation-logger.js';\r\nimport { ShellInputAgent } from './shell-input-agent.js';\r\nimport { extractPromptContext } from './input-requirement-detector.js';\r\n\r\n// ==================== Constants ====================\r\n\r\nconst MODEL = 'gemini-2.0-flash-lite'; // Fast, cheap model for classification\r\nconst POLLING_INTERVAL_MS = 500; // How often to poll when enabled\r\nconst MAX_OUTPUT_CHARS = 2000; // How much shell output to include in prompt\r\n\r\n// ==================== Types ====================\r\n\r\ninterface DetectionSession {\r\n shellId: string;\r\n intervalId: NodeJS.Timeout | null;\r\n currentOutput: string; // Current shell output (updated externally)\r\n lastOutputLength: number; // Track output changes\r\n lastDetectionResult: boolean; // Prevent duplicate triggers\r\n lastTriggerOutputLength: number; // Output length when we last triggered\r\n isPolling: boolean;\r\n abortController: AbortController;\r\n lastOutputTimestamp: number; // Timestamp of the last output update\r\n lastProcessedLength: number; // Length of output effectively processed by AI\r\n}\r\n\r\n// ==================== Detection System Prompt ====================\r\n\r\nconst DETECTION_SYSTEM_PROMPT = `You are a shell input detector. Your ONLY job is to determine if a running command is WAITING for user input.\r\n\r\nAnswer ONLY with \"YES\" or \"NO\" - no other text.\r\n\r\nExamples of WAITING for input (answer YES):\r\n- \"Enter your name: \" (ends with colon, expecting text)\r\n- \"Continue? (y/n)\" (yes/no question)\r\n- \"Password: \" (password prompt)\r\n- \"Press any key to continue...\"\r\n- \"[sudo] password for user:\"\r\n- \"Select option [1/2/3]:\"\r\n\r\nExamples of NOT waiting (answer NO):\r\n- \"Installing packages...\" (still processing)\r\n- \"Building project...\" (active work)\r\n- \"Downloading file 50%...\" (progress indicator)\r\n- Empty shell prompt like \"PS C:\\\\>\" or \"user@host:~$\"\r\n- Just finished printing output (no prompt visible)`;\r\n\r\n// ==================== InputDetectionAgent Class ====================\r\n\r\nclass InputDetectionAgentClass {\r\n private sessions: Map<string, DetectionSession> = new Map();\r\n\r\n /**\r\n * Start polling for a shell session\r\n * Call updateOutput() to push new shell output to this session\r\n */\r\n startPolling(\r\n shellId: string,\r\n initialOutput: string,\r\n command: string,\r\n cwd: string\r\n ): void {\r\n // Stop any existing polling for this shell\r\n this.stopPolling(shellId);\r\n\r\n const abortController = new AbortController();\r\n\r\n const session: DetectionSession = {\r\n shellId,\r\n intervalId: null,\r\n currentOutput: initialOutput,\r\n lastOutputLength: 0,\r\n lastDetectionResult: false,\r\n lastTriggerOutputLength: 0,\r\n isPolling: true,\r\n abortController,\r\n lastOutputTimestamp: Date.now(),\r\n lastProcessedLength: 0\r\n };\r\n\r\n quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Starting polling for ${shellId}\\n`);\r\n\r\n // Start the polling loop - checks session.currentOutput which is updated externally\r\n session.intervalId = setInterval(async () => {\r\n if (!session.isPolling || abortController.signal.aborted) {\r\n return;\r\n }\r\n\r\n const currentOutput = session.currentOutput;\r\n const now = Date.now();\r\n const timeSinceLastUpdate = now - session.lastOutputTimestamp;\r\n\r\n // CORE LOGIC: Debounce\r\n // 1. Check if output is stable (hasn't changed for 2 seconds)\r\n // 2. Check if we haven't already processed this exact output content (length check)\r\n\r\n if (timeSinceLastUpdate < 2000) {\r\n // Output is still changing (or just changed), wait for stability\r\n return;\r\n }\r\n\r\n if (currentOutput.length === session.lastProcessedLength) {\r\n // We already checked this exact output state, don't spam the AI\r\n return;\r\n }\r\n\r\n // Update processed length immediately to prevent re-entry while async runs\r\n session.lastProcessedLength = currentOutput.length;\r\n session.lastOutputLength = currentOutput.length;\r\n\r\n // If we previously triggered AND new output has arrived since then,\r\n // reset the detection flag so we can trigger again on the next prompt\r\n if (session.lastDetectionResult && currentOutput.length > session.lastTriggerOutputLength + 10) {\r\n // New output appeared after our last trigger - the ShellInputAgent likely responded\r\n // Reset so we can detect the next prompt\r\n quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Resetting detection (output grew from ${session.lastTriggerOutputLength} to ${currentOutput.length})\\n`);\r\n session.lastDetectionResult = false;\r\n }\r\n\r\n try {\r\n const isWaiting = await this.detectInputRequired(currentOutput, abortController.signal);\r\n\r\n quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Detection result: ${isWaiting ? 'YES' : 'NO'} (stable for ${timeSinceLastUpdate}ms)\\n`);\r\n\r\n // Only trigger if newly detected (prevent duplicate triggers within same prompt)\r\n if (isWaiting && !session.lastDetectionResult) {\r\n session.lastDetectionResult = true;\r\n session.lastTriggerOutputLength = currentOutput.length; // Record when we triggered\r\n\r\n // Extract context for ShellInputAgent\r\n const promptContext = extractPromptContext(currentOutput);\r\n const inputType = 'text input'; // AI-detected, generic type\r\n\r\n quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Triggering ShellInputAgent for ${shellId}\\n`);\r\n\r\n // Trigger the input agent\r\n if (ShellInputAgent.isSessionActive(shellId)) {\r\n ShellInputAgent.handleInputPrompt(\r\n shellId,\r\n currentOutput,\r\n promptContext,\r\n inputType,\r\n 'high' // AI detection = high confidence\r\n );\r\n }\r\n } else if (!isWaiting) {\r\n session.lastDetectionResult = false;\r\n }\r\n } catch (error: any) {\r\n if (error.name !== 'AbortError') {\r\n quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Detection error: ${error.message}\\n`);\r\n }\r\n }\r\n }, POLLING_INTERVAL_MS);\r\n\r\n this.sessions.set(shellId, session);\r\n }\r\n\r\n /**\r\n * Update the shell output for a session\r\n * This should be called from App.tsx whenever shellState.output changes\r\n */\r\n updateOutput(shellId: string, output: string): void {\r\n const session = this.sessions.get(shellId);\r\n if (session) {\r\n // Only update if content actually changed\r\n if (output.length !== session.currentOutput.length || output !== session.currentOutput) {\r\n session.currentOutput = output;\r\n session.lastOutputTimestamp = Date.now(); // Reset stability timer\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stop polling for a shell session\r\n */\r\n stopPolling(shellId: string): void {\r\n const session = this.sessions.get(shellId);\r\n if (session) {\r\n quickLog(`[${new Date().toISOString()}] [InputDetectionAgent] Stopping polling for ${shellId}\\n`);\r\n\r\n session.isPolling = false;\r\n session.abortController.abort();\r\n\r\n if (session.intervalId) {\r\n clearInterval(session.intervalId);\r\n }\r\n\r\n this.sessions.delete(shellId);\r\n }\r\n }\r\n\r\n /**\r\n * Core detection function - calls AI to determine if waiting for input\r\n */\r\n private async detectInputRequired(shellOutput: string, signal: AbortSignal): Promise<boolean> {\r\n // Truncate output to last N characters\r\n const truncatedOutput = shellOutput.length > MAX_OUTPUT_CHARS\r\n ? '...' + shellOutput.slice(-MAX_OUTPUT_CHARS)\r\n : shellOutput;\r\n\r\n const userPrompt = `SHELL OUTPUT:\\n${truncatedOutput}\\n\\nIs this shell WAITING for user input? Answer YES or NO only.`;\r\n\r\n // Build messages with system prompt embedded in first user message\r\n const messages: AIMessage[] = [\r\n { role: 'user', content: DETECTION_SYSTEM_PROMPT + '\\n\\n' + userPrompt }\r\n ];\r\n\r\n // Stream AI response and collect text\r\n let responseText = '';\r\n\r\n try {\r\n for await (const chunk of aiServiceClient.streamChat(\r\n MODEL,\r\n messages,\r\n [], // No tools needed - just text response\r\n {\r\n cwd: '.',\r\n platform: process.platform,\r\n shell: 'cmd.exe',\r\n os: 'windows',\r\n homeDir: ''\r\n },\r\n undefined,\r\n undefined,\r\n signal\r\n )) {\r\n if (signal.aborted) {\r\n throw new Error('AbortError');\r\n }\r\n\r\n if (chunk.type === 'text') {\r\n responseText += chunk.content;\r\n }\r\n\r\n // Early exit if we have enough to determine YES/NO\r\n if (responseText.length >= 3) {\r\n break;\r\n }\r\n }\r\n } catch (error: any) {\r\n if (error.message === 'AbortError' || error.name === 'AbortError') {\r\n const abortError = new Error('AbortError');\r\n abortError.name = 'AbortError';\r\n throw abortError;\r\n }\r\n throw error;\r\n }\r\n\r\n // Parse response - look for YES or NO\r\n const isYes = responseText.toUpperCase().includes('YES');\r\n\r\n return isYes;\r\n }\r\n\r\n /**\r\n * Check if polling is active for a shell\r\n */\r\n isPolling(shellId: string): boolean {\r\n return this.sessions.has(shellId) && this.sessions.get(shellId)!.isPolling;\r\n }\r\n\r\n /**\r\n * Stop all polling sessions\r\n */\r\n stopAll(): void {\r\n for (const shellId of this.sessions.keys()) {\r\n this.stopPolling(shellId);\r\n }\r\n }\r\n}\r\n\r\n// Export singleton\r\nexport const InputDetectionAgent = new InputDetectionAgentClass();\r\n"],"mappings":"AASA,SAAS,uBAA6C;AACtD,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AAIrC,MAAM,QAAQ;AACd,MAAM,sBAAsB;AAC5B,MAAM,mBAAmB;AAmBzB,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBhC,MAAM,yBAAyB;AAAA,EACnB,WAA0C,oBAAI,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1D,aACI,SACA,eACA,SACA,KACI;AAEJ,SAAK,YAAY,OAAO;AAExB,UAAM,kBAAkB,IAAI,gBAAgB;AAE5C,UAAM,UAA4B;AAAA,MAC9B;AAAA,MACA,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,kBAAkB;AAAA,MAClB,qBAAqB;AAAA,MACrB,yBAAyB;AAAA,MACzB,WAAW;AAAA,MACX;AAAA,MACA,qBAAqB,KAAK,IAAI;AAAA,MAC9B,qBAAqB;AAAA,IACzB;AAEA,aAAS,KAAI,oBAAI,KAAK,GAAE,YAAY,CAAC,gDAAgD,OAAO;AAAA,CAAI;AAGhG,YAAQ,aAAa,YAAY,YAAY;AACzC,UAAI,CAAC,QAAQ,aAAa,gBAAgB,OAAO,SAAS;AACtD;AAAA,MACJ;AAEA,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