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
|
@@ -1,541 +1,499 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import { aiServiceClient } from './ai-service-client.js';
|
|
9
|
-
import { apiClient } from './api-client.js';
|
|
10
|
-
import { sessionQuotaManager } from './session-quota-manager.js';
|
|
11
|
-
import { logError } from '../utils/logger.js';
|
|
12
|
-
import { quickLog } from '../utils/conversation-logger.js';
|
|
13
|
-
import { ContextManager } from '../context/context-manager.js';
|
|
14
|
-
// ==================== Constants ====================
|
|
1
|
+
import { randomUUID } from "crypto";
|
|
2
|
+
import { aiServiceClient } from "./ai-service-client.js";
|
|
3
|
+
import { apiClient } from "./api-client.js";
|
|
4
|
+
import { sessionQuotaManager } from "./session-quota-manager.js";
|
|
5
|
+
import { logError } from "../utils/logger.js";
|
|
6
|
+
import { quickLog } from "../utils/conversation-logger.js";
|
|
7
|
+
import { ContextManager } from "../context/context-manager.js";
|
|
15
8
|
const MAX_CONCURRENT_SUBAGENTS = 5;
|
|
16
|
-
const SUBAGENT_TIMEOUT_MS = 10 * 60 *
|
|
9
|
+
const SUBAGENT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
17
10
|
const MAX_TURNS_PER_SUBAGENT = 50;
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const COMPLEX_MODEL = 'gemini-3-pro-preview';
|
|
11
|
+
const SIMPLE_MODEL = "gemini-3-flash-preview";
|
|
12
|
+
const COMPLEX_MODEL = "gemini-3.1-pro-preview";
|
|
21
13
|
const COMPLEXITY_THRESHOLD = 5;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
const SUBAGENT_SYSTEM_PROMPT = `You are a sub-agent spawned by a main AI agent to complete a specific task.
|
|
15
|
+
|
|
16
|
+
IMPORTANT RULES:
|
|
17
|
+
1. You have full access to file system tools (read, write, edit, list, grep, find)
|
|
18
|
+
2. You have access to command execution tools
|
|
19
|
+
3. Focus ONLY on the task assigned to you
|
|
20
|
+
4. Always provide reason_text for every tool call to explain what you're doing
|
|
21
|
+
5. Call task_complete when you've finished the assigned task
|
|
22
|
+
6. Be efficient - don't explore unnecessarily, stick to the task
|
|
23
|
+
7. If you encounter errors, try to resolve them or report clearly what went wrong
|
|
24
|
+
|
|
25
|
+
CONTEXT FROM MAIN AGENT:
|
|
26
|
+
Working Directory: {WORKING_DIRECTORY}
|
|
27
|
+
|
|
28
|
+
{CONTEXT}
|
|
29
|
+
|
|
30
|
+
YOUR TASK:
|
|
31
|
+
{PROMPT}
|
|
32
|
+
|
|
42
33
|
Complete this task efficiently and call task_complete when done.`;
|
|
43
|
-
// ==================== SubAgentManager Class ====================
|
|
44
34
|
class SubAgentManagerClass {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
subAgents = /* @__PURE__ */ new Map();
|
|
36
|
+
toolRegistry;
|
|
37
|
+
onSubAgentCountChange;
|
|
38
|
+
onToolExecutionUpdate;
|
|
39
|
+
/**
|
|
40
|
+
* Initialize the manager with a tool registry
|
|
41
|
+
*/
|
|
42
|
+
initialize(toolRegistry) {
|
|
43
|
+
this.toolRegistry = toolRegistry;
|
|
44
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [SubAgentManager] Initialized with tool registry
|
|
45
|
+
`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Set callback for sub-agent count changes
|
|
49
|
+
*/
|
|
50
|
+
setOnSubAgentCountChange(callback) {
|
|
51
|
+
this.onSubAgentCountChange = callback;
|
|
52
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [SubAgentManager] setOnSubAgentCountChange callback registered
|
|
53
|
+
`);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Set callback for tool execution updates (for logging)
|
|
57
|
+
*/
|
|
58
|
+
setOnToolExecutionUpdate(callback) {
|
|
59
|
+
this.onToolExecutionUpdate = callback;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Notify listeners about sub-agent count change
|
|
63
|
+
*/
|
|
64
|
+
notifyCountChange() {
|
|
65
|
+
const runningAgents = this.getRunningSubAgents();
|
|
66
|
+
const runningCount = runningAgents.length;
|
|
67
|
+
const details = runningAgents.map((a) => `${a.id}:${a.status}`).join(", ");
|
|
68
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [SubAgentManager] notifyCountChange called, runningCount=${runningCount}, agents=[${details}]
|
|
69
|
+
`);
|
|
70
|
+
if (this.onSubAgentCountChange) {
|
|
71
|
+
this.onSubAgentCountChange(runningCount);
|
|
55
72
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Select model based on complexity
|
|
76
|
+
*/
|
|
77
|
+
selectModel(complexity) {
|
|
78
|
+
return complexity <= COMPLEXITY_THRESHOLD ? SIMPLE_MODEL : COMPLEX_MODEL;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generate system prompt for sub-agent
|
|
82
|
+
*/
|
|
83
|
+
generateSystemPrompt(config) {
|
|
84
|
+
return SUBAGENT_SYSTEM_PROMPT.replace("{WORKING_DIRECTORY}", config.workingDirectory).replace("{CONTEXT}", config.context || "No additional context provided.").replace("{PROMPT}", config.prompt);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Spawn a new sub-agent
|
|
88
|
+
*/
|
|
89
|
+
async spawnSubAgent(config) {
|
|
90
|
+
if (this.getRunningSubAgents().length >= MAX_CONCURRENT_SUBAGENTS) {
|
|
91
|
+
return {
|
|
92
|
+
success: false,
|
|
93
|
+
error: `Maximum ${MAX_CONCURRENT_SUBAGENTS} concurrent sub-agents allowed. Wait for existing sub-agents to complete.`
|
|
94
|
+
};
|
|
62
95
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
96
|
+
if (!this.toolRegistry) {
|
|
97
|
+
return {
|
|
98
|
+
success: false,
|
|
99
|
+
error: "SubAgentManager not initialized. Tool registry is missing."
|
|
100
|
+
};
|
|
68
101
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const runningCount = runningAgents.length;
|
|
75
|
-
const details = runningAgents.map(a => `${a.id}:${a.status}`).join(', ');
|
|
76
|
-
quickLog(`[${new Date().toISOString()}] [SubAgentManager] notifyCountChange called, runningCount=${runningCount}, agents=[${details}]\n`);
|
|
77
|
-
if (this.onSubAgentCountChange) {
|
|
78
|
-
this.onSubAgentCountChange(runningCount);
|
|
79
|
-
// quickLog(`Callback invoked`) // Removed redundant log or kept if preferred
|
|
80
|
-
}
|
|
102
|
+
if (!apiClient.isAuthenticated()) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
error: "Authentication required for sub-agents."
|
|
106
|
+
};
|
|
81
107
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
if (!sessionQuotaManager.canSendMessage()) {
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
error: "Session quota exhausted. Cannot spawn sub-agent."
|
|
112
|
+
};
|
|
87
113
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
const agentId = `subagent-${randomUUID().substring(0, 8)}`;
|
|
115
|
+
const model = this.selectModel(config.complexity);
|
|
116
|
+
const subAgent = {
|
|
117
|
+
id: agentId,
|
|
118
|
+
status: "pending",
|
|
119
|
+
prompt: config.prompt,
|
|
120
|
+
context: config.context,
|
|
121
|
+
workingDirectory: config.workingDirectory,
|
|
122
|
+
complexity: config.complexity,
|
|
123
|
+
model,
|
|
124
|
+
startTime: /* @__PURE__ */ new Date(),
|
|
125
|
+
conversationHistory: [],
|
|
126
|
+
turnCount: 0,
|
|
127
|
+
fileOperations: [],
|
|
128
|
+
toolHistory: [],
|
|
129
|
+
isRead: false,
|
|
130
|
+
abortController: new AbortController()
|
|
131
|
+
};
|
|
132
|
+
this.subAgents.set(agentId, subAgent);
|
|
133
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [SubAgentManager] Sub-agent ${agentId} added to map, calling notifyCountChange\\n`);
|
|
134
|
+
this.notifyCountChange();
|
|
135
|
+
this.runSubAgentLoop(agentId, config).catch((error) => {
|
|
136
|
+
logError(`Sub-agent ${agentId} failed:`, error);
|
|
137
|
+
const agent = this.subAgents.get(agentId);
|
|
138
|
+
if (agent && agent.status === "running") {
|
|
139
|
+
agent.status = "failed";
|
|
140
|
+
agent.error = error.message || String(error);
|
|
141
|
+
agent.endTime = /* @__PURE__ */ new Date();
|
|
142
|
+
this.notifyCountChange();
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return { success: true, agentId };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Run the sub-agent's agent loop
|
|
149
|
+
*/
|
|
150
|
+
async runSubAgentLoop(agentId, config) {
|
|
151
|
+
const subAgent = this.subAgents.get(agentId);
|
|
152
|
+
if (!subAgent) {
|
|
153
|
+
throw new Error(`Sub-agent ${agentId} not found`);
|
|
96
154
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
155
|
+
subAgent.status = "running";
|
|
156
|
+
this.notifyCountChange();
|
|
157
|
+
const timeoutId = setTimeout(() => {
|
|
158
|
+
const agent = this.subAgents.get(agentId);
|
|
159
|
+
if (agent && agent.status === "running") {
|
|
160
|
+
agent.status = "failed";
|
|
161
|
+
agent.error = "Sub-agent timed out after 10 minutes";
|
|
162
|
+
agent.endTime = /* @__PURE__ */ new Date();
|
|
163
|
+
agent.abortController?.abort();
|
|
164
|
+
this.notifyCountChange();
|
|
165
|
+
}
|
|
166
|
+
}, SUBAGENT_TIMEOUT_MS);
|
|
167
|
+
try {
|
|
168
|
+
const systemPrompt = this.generateSystemPrompt(config);
|
|
169
|
+
subAgent.conversationHistory.push({
|
|
170
|
+
role: "user",
|
|
171
|
+
content: systemPrompt
|
|
172
|
+
});
|
|
173
|
+
const tools = this.toolRegistry.getSchemas();
|
|
174
|
+
const effectiveContextManager = config.parentContextManager || new ContextManager(config.workingDirectory, process.platform);
|
|
175
|
+
const context = {
|
|
176
|
+
cwd: config.workingDirectory,
|
|
177
|
+
contextManager: effectiveContextManager,
|
|
178
|
+
requireApproval: async () => true,
|
|
179
|
+
// Auto-approve for sub-agents (autonomous)
|
|
180
|
+
onStreamingOutput: () => {
|
|
121
181
|
}
|
|
122
|
-
//
|
|
182
|
+
// No streaming output for sub-agents (yet)
|
|
183
|
+
};
|
|
184
|
+
const currentCtx = effectiveContextManager.getCurrentContext();
|
|
185
|
+
const isRemote = currentCtx && currentCtx.type !== "local";
|
|
186
|
+
let envOs;
|
|
187
|
+
let envShell;
|
|
188
|
+
let envHomeDir;
|
|
189
|
+
let envPlatform;
|
|
190
|
+
if (isRemote && currentCtx.metadata) {
|
|
191
|
+
const remoteOs = currentCtx.metadata.os;
|
|
192
|
+
envOs = remoteOs || "linux";
|
|
193
|
+
envPlatform = envOs === "windows" ? "win32" : "linux";
|
|
194
|
+
envShell = currentCtx.metadata.shell || "bash";
|
|
195
|
+
envHomeDir = currentCtx.metadata.homeDirectory || `/home/${currentCtx.metadata.username || "user"}`;
|
|
196
|
+
} else {
|
|
197
|
+
envOs = process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : "linux";
|
|
198
|
+
envPlatform = process.platform;
|
|
199
|
+
envShell = process.env.SHELL || "cmd.exe";
|
|
200
|
+
envHomeDir = process.env.USERPROFILE || process.env.HOME || "";
|
|
201
|
+
}
|
|
202
|
+
while (subAgent.turnCount < MAX_TURNS_PER_SUBAGENT && subAgent.status === "running") {
|
|
203
|
+
subAgent.turnCount++;
|
|
204
|
+
sessionQuotaManager.incrementMessageCount();
|
|
123
205
|
if (!sessionQuotaManager.canSendMessage()) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
206
|
+
subAgent.status = "failed";
|
|
207
|
+
subAgent.error = "Session quota exhausted during sub-agent execution";
|
|
208
|
+
break;
|
|
128
209
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const model = this.selectModel(config.complexity);
|
|
132
|
-
const subAgent = {
|
|
133
|
-
id: agentId,
|
|
134
|
-
status: 'pending',
|
|
135
|
-
prompt: config.prompt,
|
|
136
|
-
context: config.context,
|
|
137
|
-
workingDirectory: config.workingDirectory,
|
|
138
|
-
complexity: config.complexity,
|
|
139
|
-
model,
|
|
140
|
-
startTime: new Date(),
|
|
141
|
-
conversationHistory: [],
|
|
142
|
-
turnCount: 0,
|
|
143
|
-
fileOperations: [],
|
|
144
|
-
toolHistory: [],
|
|
145
|
-
isRead: false,
|
|
146
|
-
abortController: new AbortController(),
|
|
147
|
-
};
|
|
148
|
-
this.subAgents.set(agentId, subAgent);
|
|
149
|
-
quickLog(`[${new Date().toISOString()}] [SubAgentManager] Sub-agent ${agentId} added to map, calling notifyCountChange\\n`);
|
|
150
|
-
this.notifyCountChange();
|
|
151
|
-
// Start the sub-agent loop in background (don't await)
|
|
152
|
-
this.runSubAgentLoop(agentId, config).catch(error => {
|
|
153
|
-
logError(`Sub-agent ${agentId} failed:`, error);
|
|
154
|
-
const agent = this.subAgents.get(agentId);
|
|
155
|
-
if (agent && agent.status === 'running') {
|
|
156
|
-
agent.status = 'failed';
|
|
157
|
-
agent.error = error.message || String(error);
|
|
158
|
-
agent.endTime = new Date();
|
|
159
|
-
this.notifyCountChange();
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
return { success: true, agentId };
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Run the sub-agent's agent loop
|
|
166
|
-
*/
|
|
167
|
-
async runSubAgentLoop(agentId, config) {
|
|
168
|
-
const subAgent = this.subAgents.get(agentId);
|
|
169
|
-
if (!subAgent) {
|
|
170
|
-
throw new Error(`Sub-agent ${agentId} not found`);
|
|
171
|
-
}
|
|
172
|
-
subAgent.status = 'running';
|
|
173
|
-
this.notifyCountChange();
|
|
174
|
-
// Set up timeout
|
|
175
|
-
const timeoutId = setTimeout(() => {
|
|
176
|
-
const agent = this.subAgents.get(agentId);
|
|
177
|
-
if (agent && agent.status === 'running') {
|
|
178
|
-
agent.status = 'failed';
|
|
179
|
-
agent.error = 'Sub-agent timed out after 10 minutes';
|
|
180
|
-
agent.endTime = new Date();
|
|
181
|
-
agent.abortController?.abort();
|
|
182
|
-
this.notifyCountChange();
|
|
183
|
-
}
|
|
184
|
-
}, SUBAGENT_TIMEOUT_MS);
|
|
210
|
+
let assistantMessage = "";
|
|
211
|
+
let toolCalls = [];
|
|
185
212
|
try {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
subAgent.conversationHistory
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const context = {
|
|
198
|
-
cwd: config.workingDirectory,
|
|
199
|
-
contextManager: effectiveContextManager,
|
|
200
|
-
requireApproval: async () => true, // Auto-approve for sub-agents (autonomous)
|
|
201
|
-
onStreamingOutput: () => { }, // No streaming output for sub-agents (yet)
|
|
202
|
-
};
|
|
203
|
-
// Detect environment from the effective context manager's current state
|
|
204
|
-
// This ensures the AI model knows the correct OS/shell when in a remote session
|
|
205
|
-
const currentCtx = effectiveContextManager.getCurrentContext();
|
|
206
|
-
const isRemote = currentCtx && currentCtx.type !== 'local';
|
|
207
|
-
let envOs;
|
|
208
|
-
let envShell;
|
|
209
|
-
let envHomeDir;
|
|
210
|
-
let envPlatform;
|
|
211
|
-
if (isRemote && currentCtx.metadata) {
|
|
212
|
-
// Use remote session's OS/shell info
|
|
213
|
-
const remoteOs = currentCtx.metadata.os;
|
|
214
|
-
envOs = remoteOs || 'linux'; // Most remote sessions are Linux
|
|
215
|
-
envPlatform = envOs === 'windows' ? 'win32' : 'linux';
|
|
216
|
-
envShell = currentCtx.metadata.shell || 'bash';
|
|
217
|
-
envHomeDir = currentCtx.metadata.homeDirectory || `/home/${currentCtx.metadata.username || 'user'}`;
|
|
213
|
+
for await (const chunk of aiServiceClient.streamChat(
|
|
214
|
+
subAgent.model,
|
|
215
|
+
subAgent.conversationHistory,
|
|
216
|
+
tools,
|
|
217
|
+
{ cwd: config.workingDirectory, platform: envPlatform, shell: envShell, os: envOs, homeDir: envHomeDir },
|
|
218
|
+
void 0,
|
|
219
|
+
void 0,
|
|
220
|
+
subAgent.abortController?.signal
|
|
221
|
+
)) {
|
|
222
|
+
if (chunk.type === "error") {
|
|
223
|
+
throw new Error(chunk.message);
|
|
218
224
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
envOs = process.platform === 'win32' ? 'windows' : process.platform === 'darwin' ? 'macos' : 'linux';
|
|
222
|
-
envPlatform = process.platform;
|
|
223
|
-
envShell = process.env.SHELL || 'cmd.exe';
|
|
224
|
-
envHomeDir = process.env.USERPROFILE || process.env.HOME || '';
|
|
225
|
+
if (chunk.type === "text") {
|
|
226
|
+
assistantMessage += chunk.content;
|
|
225
227
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// Check quota
|
|
230
|
-
sessionQuotaManager.incrementMessageCount();
|
|
231
|
-
if (!sessionQuotaManager.canSendMessage()) {
|
|
232
|
-
subAgent.status = 'failed';
|
|
233
|
-
subAgent.error = 'Session quota exhausted during sub-agent execution';
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
let assistantMessage = '';
|
|
237
|
-
let toolCalls = [];
|
|
238
|
-
// Stream AI response
|
|
228
|
+
if (chunk.type === "tool_call") {
|
|
229
|
+
const toolCall = chunk.toolCall;
|
|
230
|
+
if (toolCall.arguments && typeof toolCall.arguments === "string") {
|
|
239
231
|
try {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
throw new Error(chunk.message);
|
|
243
|
-
}
|
|
244
|
-
if (chunk.type === 'text') {
|
|
245
|
-
assistantMessage += chunk.content;
|
|
246
|
-
}
|
|
247
|
-
if (chunk.type === 'tool_call') {
|
|
248
|
-
const toolCall = chunk.toolCall;
|
|
249
|
-
// Parse string arguments if needed
|
|
250
|
-
if (toolCall.arguments && typeof toolCall.arguments === 'string') {
|
|
251
|
-
try {
|
|
252
|
-
toolCall.arguments = JSON.parse(toolCall.arguments);
|
|
253
|
-
}
|
|
254
|
-
catch (e) {
|
|
255
|
-
// Ignore parsing error
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
toolCalls.push(toolCall);
|
|
259
|
-
}
|
|
260
|
-
if (chunk.type === 'done') {
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
catch (error) {
|
|
266
|
-
if (error.name === 'AbortError') {
|
|
267
|
-
// Sub-agent was terminated
|
|
268
|
-
subAgent.status = 'terminated';
|
|
269
|
-
subAgent.endTime = new Date();
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
throw error;
|
|
273
|
-
}
|
|
274
|
-
// Add assistant message to history
|
|
275
|
-
if (toolCalls.length > 0 || assistantMessage) {
|
|
276
|
-
const assistantMsg = {
|
|
277
|
-
role: 'assistant',
|
|
278
|
-
content: assistantMessage,
|
|
279
|
-
};
|
|
280
|
-
if (toolCalls.length > 0) {
|
|
281
|
-
assistantMsg.tool_calls = toolCalls;
|
|
282
|
-
}
|
|
283
|
-
subAgent.conversationHistory.push(assistantMsg);
|
|
284
|
-
}
|
|
285
|
-
// Execute tool calls
|
|
286
|
-
if (toolCalls.length === 0) {
|
|
287
|
-
// No tool calls and no task_complete - something went wrong
|
|
288
|
-
subAgent.status = 'completed';
|
|
289
|
-
subAgent.result = assistantMessage || 'Sub-agent completed without explicit task_complete';
|
|
290
|
-
subAgent.endTime = new Date();
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
for (const toolCall of toolCalls) {
|
|
294
|
-
// Check for task_complete
|
|
295
|
-
if (toolCall.name === 'task_complete') {
|
|
296
|
-
subAgent.status = 'completed';
|
|
297
|
-
subAgent.result = assistantMessage || 'Task completed successfully';
|
|
298
|
-
subAgent.endTime = new Date();
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
// Track the tool execution
|
|
302
|
-
const reasonText = toolCall.arguments?.reason_text;
|
|
303
|
-
const toolExecution = {
|
|
304
|
-
toolName: toolCall.name,
|
|
305
|
-
arguments: toolCall.arguments,
|
|
306
|
-
reasonText,
|
|
307
|
-
result: '',
|
|
308
|
-
success: false,
|
|
309
|
-
timestamp: new Date(),
|
|
310
|
-
};
|
|
311
|
-
try {
|
|
312
|
-
quickLog(`[SubAgent ${subAgent.id}] Executing tool: ${toolCall.name}`);
|
|
313
|
-
// Execute the tool
|
|
314
|
-
const result = await this.toolRegistry.execute(toolCall.name, toolCall.arguments, context);
|
|
315
|
-
quickLog(`[SubAgent ${subAgent.id}] Tool ${toolCall.name} execution result: ${JSON.stringify(result)}`);
|
|
316
|
-
toolExecution.success = result.success;
|
|
317
|
-
toolExecution.result = result.result;
|
|
318
|
-
// Track file operations
|
|
319
|
-
this.trackFileOperation(subAgent, toolCall, result);
|
|
320
|
-
// Add tool result to history
|
|
321
|
-
subAgent.conversationHistory.push({
|
|
322
|
-
role: 'tool',
|
|
323
|
-
tool_call_id: toolCall.id,
|
|
324
|
-
content: result.success ? result.result : `Error: ${result.error}`,
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
toolExecution.success = false;
|
|
329
|
-
toolExecution.result = `Error: ${error.message}`;
|
|
330
|
-
subAgent.conversationHistory.push({
|
|
331
|
-
role: 'tool',
|
|
332
|
-
tool_call_id: toolCall.id,
|
|
333
|
-
content: `Error: ${error.message}`,
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
subAgent.toolHistory.push(toolExecution);
|
|
337
|
-
}
|
|
338
|
-
// Check if task was completed
|
|
339
|
-
if (subAgent.status === 'completed') {
|
|
340
|
-
break;
|
|
232
|
+
toolCall.arguments = JSON.parse(toolCall.arguments);
|
|
233
|
+
} catch (e) {
|
|
341
234
|
}
|
|
235
|
+
}
|
|
236
|
+
toolCalls.push(toolCall);
|
|
342
237
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
subAgent.status = 'failed';
|
|
346
|
-
subAgent.error = `Sub-agent exceeded maximum ${MAX_TURNS_PER_SUBAGENT} turns`;
|
|
347
|
-
subAgent.endTime = new Date();
|
|
238
|
+
if (chunk.type === "done") {
|
|
239
|
+
break;
|
|
348
240
|
}
|
|
241
|
+
}
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if (error.name === "AbortError") {
|
|
244
|
+
subAgent.status = "terminated";
|
|
245
|
+
subAgent.endTime = /* @__PURE__ */ new Date();
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
throw error;
|
|
349
249
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
250
|
+
if (toolCalls.length > 0 || assistantMessage) {
|
|
251
|
+
const assistantMsg = {
|
|
252
|
+
role: "assistant",
|
|
253
|
+
content: assistantMessage
|
|
254
|
+
};
|
|
255
|
+
if (toolCalls.length > 0) {
|
|
256
|
+
assistantMsg.tool_calls = toolCalls;
|
|
257
|
+
}
|
|
258
|
+
subAgent.conversationHistory.push(assistantMsg);
|
|
353
259
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
trackFileOperation(subAgent, toolCall, result) {
|
|
360
|
-
const { name, arguments: args } = toolCall;
|
|
361
|
-
if (name === 'write_to_file') {
|
|
362
|
-
subAgent.fileOperations.push({
|
|
363
|
-
type: 'create',
|
|
364
|
-
path: args.TargetFile || args.target_path || args.file_path || 'unknown_file',
|
|
365
|
-
newContent: args.content,
|
|
366
|
-
reasonText: args.reason_text,
|
|
367
|
-
timestamp: new Date(),
|
|
368
|
-
});
|
|
260
|
+
if (toolCalls.length === 0) {
|
|
261
|
+
subAgent.status = "completed";
|
|
262
|
+
subAgent.result = assistantMessage || "Sub-agent completed without explicit task_complete";
|
|
263
|
+
subAgent.endTime = /* @__PURE__ */ new Date();
|
|
264
|
+
break;
|
|
369
265
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
266
|
+
for (const toolCall of toolCalls) {
|
|
267
|
+
if (toolCall.name === "task_complete") {
|
|
268
|
+
subAgent.status = "completed";
|
|
269
|
+
subAgent.result = assistantMessage || "Task completed successfully";
|
|
270
|
+
subAgent.endTime = /* @__PURE__ */ new Date();
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
const reasonText = toolCall.arguments?.reason_text;
|
|
274
|
+
const toolExecution = {
|
|
275
|
+
toolName: toolCall.name,
|
|
276
|
+
arguments: toolCall.arguments,
|
|
277
|
+
reasonText,
|
|
278
|
+
result: "",
|
|
279
|
+
success: false,
|
|
280
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
281
|
+
};
|
|
282
|
+
try {
|
|
283
|
+
quickLog(`[SubAgent ${subAgent.id}] Executing tool: ${toolCall.name}`);
|
|
284
|
+
const result = await this.toolRegistry.execute(toolCall.name, toolCall.arguments, context);
|
|
285
|
+
quickLog(`[SubAgent ${subAgent.id}] Tool ${toolCall.name} execution result: ${JSON.stringify(result)}`);
|
|
286
|
+
toolExecution.success = result.success;
|
|
287
|
+
toolExecution.result = result.result;
|
|
288
|
+
this.trackFileOperation(subAgent, toolCall, result);
|
|
289
|
+
subAgent.conversationHistory.push({
|
|
290
|
+
role: "tool",
|
|
291
|
+
tool_call_id: toolCall.id,
|
|
292
|
+
content: result.success ? result.result : `Error: ${result.error}`
|
|
377
293
|
});
|
|
294
|
+
} catch (error) {
|
|
295
|
+
toolExecution.success = false;
|
|
296
|
+
toolExecution.result = `Error: ${error.message}`;
|
|
297
|
+
subAgent.conversationHistory.push({
|
|
298
|
+
role: "tool",
|
|
299
|
+
tool_call_id: toolCall.id,
|
|
300
|
+
content: `Error: ${error.message}`
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
subAgent.toolHistory.push(toolExecution);
|
|
304
|
+
}
|
|
305
|
+
if (subAgent.status === "completed") {
|
|
306
|
+
break;
|
|
378
307
|
}
|
|
379
|
-
|
|
308
|
+
}
|
|
309
|
+
if (subAgent.turnCount >= MAX_TURNS_PER_SUBAGENT && subAgent.status === "running") {
|
|
310
|
+
subAgent.status = "failed";
|
|
311
|
+
subAgent.error = `Sub-agent exceeded maximum ${MAX_TURNS_PER_SUBAGENT} turns`;
|
|
312
|
+
subAgent.endTime = /* @__PURE__ */ new Date();
|
|
313
|
+
}
|
|
314
|
+
} finally {
|
|
315
|
+
clearTimeout(timeoutId);
|
|
316
|
+
this.notifyCountChange();
|
|
380
317
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
318
|
+
quickLog(`[${(/* @__PURE__ */ new Date()).toISOString()}] [SubAgent] ${agentId} finished with status: ${subAgent.status}
|
|
319
|
+
`);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Track file operations made by sub-agent
|
|
323
|
+
*/
|
|
324
|
+
trackFileOperation(subAgent, toolCall, result) {
|
|
325
|
+
const { name, arguments: args } = toolCall;
|
|
326
|
+
if (name === "write_to_file") {
|
|
327
|
+
subAgent.fileOperations.push({
|
|
328
|
+
type: "create",
|
|
329
|
+
path: args.TargetFile || args.target_path || args.file_path || "unknown_file",
|
|
330
|
+
newContent: args.content,
|
|
331
|
+
reasonText: args.reason_text,
|
|
332
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
333
|
+
});
|
|
334
|
+
} else if (name === "edit_file" || name === "multi_edit_file") {
|
|
335
|
+
subAgent.fileOperations.push({
|
|
336
|
+
type: "edit",
|
|
337
|
+
path: args.file_path || args.target_path || "unknown_file",
|
|
338
|
+
diff: result.success ? result.result : void 0,
|
|
339
|
+
reasonText: args.reason_text,
|
|
340
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
341
|
+
});
|
|
386
342
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Get a sub-agent by ID
|
|
346
|
+
*/
|
|
347
|
+
getSubAgent(agentId) {
|
|
348
|
+
return this.subAgents.get(agentId);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Get all sub-agents
|
|
352
|
+
*/
|
|
353
|
+
getAllSubAgents() {
|
|
354
|
+
return Array.from(this.subAgents.values());
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Get running sub-agents
|
|
358
|
+
*/
|
|
359
|
+
getRunningSubAgents() {
|
|
360
|
+
return this.getAllSubAgents().filter((a) => a.status === "running" || a.status === "pending");
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Get completed but unread sub-agents
|
|
364
|
+
*/
|
|
365
|
+
getCompletedUnreadSubAgents() {
|
|
366
|
+
return this.getAllSubAgents().filter(
|
|
367
|
+
(a) => (a.status === "completed" || a.status === "failed" || a.status === "terminated") && !a.isRead
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Terminate a sub-agent
|
|
372
|
+
*/
|
|
373
|
+
terminateSubAgent(agentId) {
|
|
374
|
+
const subAgent = this.subAgents.get(agentId);
|
|
375
|
+
if (!subAgent) {
|
|
376
|
+
return { success: false, error: `Sub-agent ${agentId} not found` };
|
|
392
377
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
*/
|
|
396
|
-
getRunningSubAgents() {
|
|
397
|
-
return this.getAllSubAgents().filter(a => a.status === 'running' || a.status === 'pending');
|
|
378
|
+
if (subAgent.status !== "running" && subAgent.status !== "pending") {
|
|
379
|
+
return { success: false, error: `Sub-agent ${agentId} is not running (status: ${subAgent.status})` };
|
|
398
380
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
381
|
+
subAgent.abortController?.abort();
|
|
382
|
+
subAgent.status = "terminated";
|
|
383
|
+
subAgent.endTime = /* @__PURE__ */ new Date();
|
|
384
|
+
this.notifyCountChange();
|
|
385
|
+
return { success: true };
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Get formatted diff output for a sub-agent
|
|
389
|
+
*/
|
|
390
|
+
getSubAgentDiff(agentId) {
|
|
391
|
+
const subAgent = this.subAgents.get(agentId);
|
|
392
|
+
if (!subAgent) {
|
|
393
|
+
return `Sub-agent ${agentId} not found`;
|
|
405
394
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
subAgent.abortController?.abort();
|
|
418
|
-
subAgent.status = 'terminated';
|
|
419
|
-
subAgent.endTime = new Date();
|
|
420
|
-
this.notifyCountChange();
|
|
421
|
-
return { success: true };
|
|
395
|
+
const lines = [];
|
|
396
|
+
lines.push(`## Sub-Agent Results: ${agentId}`);
|
|
397
|
+
lines.push(`**Status:** ${subAgent.status}`);
|
|
398
|
+
lines.push(`**Model:** ${subAgent.model}`);
|
|
399
|
+
lines.push(`**Duration:** ${this.formatDuration(subAgent.startTime, subAgent.endTime)}`);
|
|
400
|
+
lines.push(`**Turns:** ${subAgent.turnCount}`);
|
|
401
|
+
lines.push("");
|
|
402
|
+
if (subAgent.result) {
|
|
403
|
+
lines.push(`**Result:** ${subAgent.result}`);
|
|
404
|
+
lines.push("");
|
|
422
405
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
lines.push(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
lines.push(`**Duration:** ${this.formatDuration(subAgent.startTime, subAgent.endTime)}`);
|
|
436
|
-
lines.push(`**Turns:** ${subAgent.turnCount}`);
|
|
437
|
-
lines.push('');
|
|
438
|
-
if (subAgent.result) {
|
|
439
|
-
lines.push(`**Result:** ${subAgent.result}`);
|
|
440
|
-
lines.push('');
|
|
441
|
-
}
|
|
442
|
-
if (subAgent.error) {
|
|
443
|
-
lines.push(`**Error:** ${subAgent.error}`);
|
|
444
|
-
lines.push('');
|
|
445
|
-
}
|
|
446
|
-
// File operations
|
|
447
|
-
if (subAgent.fileOperations.length > 0) {
|
|
448
|
-
lines.push('### File Operations');
|
|
449
|
-
lines.push('');
|
|
450
|
-
for (const op of subAgent.fileOperations) {
|
|
451
|
-
const typeIcon = op.type === 'create' ? '📝' : op.type === 'edit' ? '✏️' : '🗑️';
|
|
452
|
-
lines.push(`${typeIcon} **${op.type.toUpperCase()}**: \`${op.path}\``);
|
|
453
|
-
if (op.reasonText) {
|
|
454
|
-
lines.push(` *Reason:* ${op.reasonText}`);
|
|
455
|
-
}
|
|
456
|
-
if (op.diff) {
|
|
457
|
-
lines.push('```diff');
|
|
458
|
-
lines.push(op.diff);
|
|
459
|
-
lines.push('```');
|
|
460
|
-
}
|
|
461
|
-
else if (op.newContent && op.type === 'create') {
|
|
462
|
-
// For new files, show a summary
|
|
463
|
-
const lineCount = op.newContent.split('\n').length;
|
|
464
|
-
lines.push(` *Created file with ${lineCount} lines*`);
|
|
465
|
-
}
|
|
466
|
-
lines.push('');
|
|
467
|
-
}
|
|
406
|
+
if (subAgent.error) {
|
|
407
|
+
lines.push(`**Error:** ${subAgent.error}`);
|
|
408
|
+
lines.push("");
|
|
409
|
+
}
|
|
410
|
+
if (subAgent.fileOperations.length > 0) {
|
|
411
|
+
lines.push("### File Operations");
|
|
412
|
+
lines.push("");
|
|
413
|
+
for (const op of subAgent.fileOperations) {
|
|
414
|
+
const typeIcon = op.type === "create" ? "\u{1F4DD}" : op.type === "edit" ? "\u270F\uFE0F" : "\u{1F5D1}\uFE0F";
|
|
415
|
+
lines.push(`${typeIcon} **${op.type.toUpperCase()}**: \`${op.path}\``);
|
|
416
|
+
if (op.reasonText) {
|
|
417
|
+
lines.push(` *Reason:* ${op.reasonText}`);
|
|
468
418
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
for (const [tool, count] of toolCounts) {
|
|
478
|
-
lines.push(`- ${tool}: ${count} call(s)`);
|
|
479
|
-
}
|
|
480
|
-
lines.push('');
|
|
419
|
+
if (op.diff) {
|
|
420
|
+
lines.push("```diff");
|
|
421
|
+
lines.push(op.diff);
|
|
422
|
+
lines.push("```");
|
|
423
|
+
} else if (op.newContent && op.type === "create") {
|
|
424
|
+
const lineCount = op.newContent.split("\n").length;
|
|
425
|
+
lines.push(` *Created file with ${lineCount} lines*`);
|
|
481
426
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
const structuredData = {
|
|
485
|
-
agentId: subAgent.id,
|
|
486
|
-
status: subAgent.status,
|
|
487
|
-
model: subAgent.model,
|
|
488
|
-
duration: this.formatDuration(subAgent.startTime, subAgent.endTime),
|
|
489
|
-
turnCount: subAgent.turnCount,
|
|
490
|
-
fileOperations: subAgent.fileOperations.map(op => ({
|
|
491
|
-
type: op.type,
|
|
492
|
-
path: op.path
|
|
493
|
-
})),
|
|
494
|
-
result: subAgent.result,
|
|
495
|
-
error: subAgent.error
|
|
496
|
-
};
|
|
497
|
-
// Return JSON string containing both checkable text (for AI) and structured data (for UI)
|
|
498
|
-
// Wrapped in a format that looks like text but can be parsed as JSON if needed by UI
|
|
499
|
-
// Actually, let's just return a JSON object string. The AI can read JSON.
|
|
500
|
-
return JSON.stringify({
|
|
501
|
-
report: markdownReport,
|
|
502
|
-
data: structuredData
|
|
503
|
-
}, null, 2);
|
|
427
|
+
lines.push("");
|
|
428
|
+
}
|
|
504
429
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
430
|
+
if (subAgent.toolHistory.length > 0) {
|
|
431
|
+
lines.push("### Tool Execution Summary");
|
|
432
|
+
lines.push("");
|
|
433
|
+
const toolCounts = /* @__PURE__ */ new Map();
|
|
434
|
+
for (const exec of subAgent.toolHistory) {
|
|
435
|
+
toolCounts.set(exec.toolName, (toolCounts.get(exec.toolName) || 0) + 1);
|
|
436
|
+
}
|
|
437
|
+
for (const [tool, count] of toolCounts) {
|
|
438
|
+
lines.push(`- ${tool}: ${count} call(s)`);
|
|
439
|
+
}
|
|
440
|
+
lines.push("");
|
|
513
441
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
442
|
+
const markdownReport = lines.join("\n");
|
|
443
|
+
const structuredData = {
|
|
444
|
+
agentId: subAgent.id,
|
|
445
|
+
status: subAgent.status,
|
|
446
|
+
model: subAgent.model,
|
|
447
|
+
duration: this.formatDuration(subAgent.startTime, subAgent.endTime),
|
|
448
|
+
turnCount: subAgent.turnCount,
|
|
449
|
+
fileOperations: subAgent.fileOperations.map((op) => ({
|
|
450
|
+
type: op.type,
|
|
451
|
+
path: op.path
|
|
452
|
+
})),
|
|
453
|
+
result: subAgent.result,
|
|
454
|
+
error: subAgent.error
|
|
455
|
+
};
|
|
456
|
+
return JSON.stringify({
|
|
457
|
+
report: markdownReport,
|
|
458
|
+
data: structuredData
|
|
459
|
+
}, null, 2);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Mark sub-agent results as read
|
|
463
|
+
*/
|
|
464
|
+
markSubAgentRead(agentId) {
|
|
465
|
+
const subAgent = this.subAgents.get(agentId);
|
|
466
|
+
if (subAgent) {
|
|
467
|
+
subAgent.isRead = true;
|
|
526
468
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Format duration between two dates
|
|
472
|
+
*/
|
|
473
|
+
formatDuration(start, end) {
|
|
474
|
+
const endTime = end || /* @__PURE__ */ new Date();
|
|
475
|
+
const durationMs = endTime.getTime() - start.getTime();
|
|
476
|
+
const seconds = Math.floor(durationMs / 1e3);
|
|
477
|
+
const minutes = Math.floor(seconds / 60);
|
|
478
|
+
if (minutes > 0) {
|
|
479
|
+
return `${minutes}m ${seconds % 60}s`;
|
|
480
|
+
}
|
|
481
|
+
return `${seconds}s`;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Clean up old completed sub-agents (call periodically)
|
|
485
|
+
*/
|
|
486
|
+
cleanup() {
|
|
487
|
+
const oneHourAgo = new Date(Date.now() - 60 * 60 * 1e3);
|
|
488
|
+
for (const [id, agent] of this.subAgents) {
|
|
489
|
+
if (agent.endTime && agent.endTime < oneHourAgo && agent.isRead) {
|
|
490
|
+
this.subAgents.delete(id);
|
|
491
|
+
}
|
|
537
492
|
}
|
|
493
|
+
}
|
|
538
494
|
}
|
|
539
|
-
|
|
540
|
-
export
|
|
495
|
+
const SubAgentManager = new SubAgentManagerClass();
|
|
496
|
+
export {
|
|
497
|
+
SubAgentManager
|
|
498
|
+
};
|
|
541
499
|
//# sourceMappingURL=sub-agent-manager.js.map
|