@umsai/ums-code 0.1.4-v2 → 0.3.0-v2
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/package.json +11 -3
- package/dist/src/config/config.d.ts +6 -0
- package/dist/src/config/config.js +102 -11
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/settings.d.ts +5 -0
- package/dist/src/config/settings.js +15 -1
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +75 -17
- package/dist/src/config/settingsSchema.js +57 -17
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/config/webSearch.d.ts +35 -0
- package/dist/src/config/webSearch.js +87 -0
- package/dist/src/config/webSearch.js.map +1 -0
- package/dist/src/core/auth.d.ts +1 -1
- package/dist/src/core/auth.js +19 -3
- package/dist/src/core/auth.js.map +1 -1
- package/dist/src/core/initializer.js +13 -2
- package/dist/src/core/initializer.js.map +1 -1
- package/dist/src/core/theme.js +4 -1
- package/dist/src/core/theme.js.map +1 -1
- package/dist/src/gemini.d.ts +1 -1
- package/dist/src/gemini.js +53 -44
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.js +117 -0
- package/dist/src/gemini.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/i18n/index.d.ts +18 -0
- package/dist/src/i18n/index.js +184 -0
- package/dist/src/i18n/index.js.map +1 -0
- package/dist/src/i18n/locales/en.js +1129 -0
- package/dist/src/i18n/locales/zh.js +1052 -0
- package/dist/src/nonInteractive/control/ControlContext.d.ts +63 -0
- package/dist/src/nonInteractive/control/ControlContext.js +31 -0
- package/dist/src/nonInteractive/control/ControlContext.js.map +1 -0
- package/dist/src/nonInteractive/control/ControlDispatcher.d.ts +86 -0
- package/dist/src/nonInteractive/control/ControlDispatcher.js +238 -0
- package/dist/src/nonInteractive/control/ControlDispatcher.js.map +1 -0
- package/dist/src/nonInteractive/control/ControlDispatcher.test.d.ts +6 -0
- package/dist/src/nonInteractive/control/ControlDispatcher.test.js +549 -0
- package/dist/src/nonInteractive/control/ControlDispatcher.test.js.map +1 -0
- package/dist/src/nonInteractive/control/ControlService.d.ts +78 -0
- package/dist/src/nonInteractive/control/ControlService.js +154 -0
- package/dist/src/nonInteractive/control/ControlService.js.map +1 -0
- package/dist/src/nonInteractive/control/controllers/baseController.d.ts +50 -0
- package/dist/src/nonInteractive/control/controllers/baseController.js +102 -0
- package/dist/src/nonInteractive/control/controllers/baseController.js.map +1 -0
- package/dist/src/nonInteractive/control/controllers/hookController.d.ts +25 -0
- package/dist/src/nonInteractive/control/controllers/hookController.js +42 -0
- package/dist/src/nonInteractive/control/controllers/hookController.js.map +1 -0
- package/dist/src/nonInteractive/control/controllers/mcpController.d.ts +42 -0
- package/dist/src/nonInteractive/control/controllers/mcpController.js +205 -0
- package/dist/src/nonInteractive/control/controllers/mcpController.js.map +1 -0
- package/dist/src/nonInteractive/control/controllers/permissionController.d.ts +78 -0
- package/dist/src/nonInteractive/control/controllers/permissionController.js +358 -0
- package/dist/src/nonInteractive/control/controllers/permissionController.js.map +1 -0
- package/dist/src/nonInteractive/control/controllers/systemController.d.ts +56 -0
- package/dist/src/nonInteractive/control/controllers/systemController.js +166 -0
- package/dist/src/nonInteractive/control/controllers/systemController.js.map +1 -0
- package/dist/src/nonInteractive/control/types/serviceAPIs.d.ts +120 -0
- package/dist/src/nonInteractive/control/types/serviceAPIs.js +7 -0
- package/dist/src/nonInteractive/control/types/serviceAPIs.js.map +1 -0
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.d.ts +446 -0
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.js +891 -0
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.js.map +1 -0
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.test.d.ts +6 -0
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.test.js +1197 -0
- package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.test.js.map +1 -0
- package/dist/src/nonInteractive/io/JsonOutputAdapter.d.ts +29 -0
- package/dist/src/nonInteractive/io/JsonOutputAdapter.js +56 -0
- package/dist/src/nonInteractive/io/JsonOutputAdapter.js.map +1 -0
- package/dist/src/nonInteractive/io/JsonOutputAdapter.test.d.ts +6 -0
- package/dist/src/nonInteractive/io/JsonOutputAdapter.test.js +624 -0
- package/dist/src/nonInteractive/io/JsonOutputAdapter.test.js.map +1 -0
- package/dist/src/nonInteractive/io/StreamJsonInputReader.d.ts +16 -0
- package/dist/src/nonInteractive/io/StreamJsonInputReader.js +54 -0
- package/dist/src/nonInteractive/io/StreamJsonInputReader.js.map +1 -0
- package/dist/src/nonInteractive/io/StreamJsonInputReader.test.d.ts +6 -0
- package/dist/src/nonInteractive/io/StreamJsonInputReader.test.js +178 -0
- package/dist/src/nonInteractive/io/StreamJsonInputReader.test.js.map +1 -0
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.d.ts +69 -0
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.js +185 -0
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.js.map +1 -0
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.test.d.ts +6 -0
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.test.js +808 -0
- package/dist/src/nonInteractive/io/StreamJsonOutputAdapter.test.js.map +1 -0
- package/dist/src/nonInteractive/session.d.ts +23 -0
- package/dist/src/nonInteractive/session.js +549 -0
- package/dist/src/nonInteractive/session.js.map +1 -0
- package/dist/src/nonInteractive/session.test.d.ts +6 -0
- package/dist/src/nonInteractive/session.test.js +407 -0
- package/dist/src/nonInteractive/session.test.js.map +1 -0
- package/dist/src/nonInteractive/types.d.ts +344 -0
- package/dist/src/nonInteractive/types.js +78 -0
- package/dist/src/nonInteractive/types.js.map +1 -0
- package/dist/src/nonInteractiveCli.d.ts +21 -1
- package/dist/src/nonInteractiveCli.js +204 -57
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/nonInteractiveCliCommands.d.ts +19 -1
- package/dist/src/nonInteractiveCliCommands.js +69 -4
- package/dist/src/nonInteractiveCliCommands.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +2 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/FileCommandLoader.js +4 -1
- package/dist/src/services/FileCommandLoader.js.map +1 -1
- package/dist/src/ui/AppContainer.js +41 -38
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/auth/AuthDialog.d.ts +1 -13
- package/dist/src/ui/auth/AuthDialog.js +41 -111
- package/dist/src/ui/auth/AuthDialog.js.map +1 -1
- package/dist/src/ui/auth/AuthDialog.test.js +49 -19
- package/dist/src/ui/auth/AuthDialog.test.js.map +1 -1
- package/dist/src/ui/auth/AuthInProgress.js +2 -1
- package/dist/src/ui/auth/AuthInProgress.js.map +1 -1
- package/dist/src/ui/auth/useAuth.d.ts +9 -8
- package/dist/src/ui/auth/useAuth.js +135 -63
- package/dist/src/ui/auth/useAuth.js.map +1 -1
- package/dist/src/ui/commands/aboutCommand.js +7 -31
- package/dist/src/ui/commands/aboutCommand.js.map +1 -1
- package/dist/src/ui/commands/agentsCommand.js +10 -3
- package/dist/src/ui/commands/agentsCommand.js.map +1 -1
- package/dist/src/ui/commands/approvalModeCommand.js +8 -329
- package/dist/src/ui/commands/approvalModeCommand.js.map +1 -1
- package/dist/src/ui/commands/approvalModeCommand.test.js +19 -263
- package/dist/src/ui/commands/approvalModeCommand.test.js.map +1 -1
- package/dist/src/ui/commands/authCommand.js +4 -1
- package/dist/src/ui/commands/authCommand.js.map +1 -1
- package/dist/src/ui/commands/bugCommand.js +13 -47
- package/dist/src/ui/commands/bugCommand.js.map +1 -1
- package/dist/src/ui/commands/chatCommand.js +51 -25
- package/dist/src/ui/commands/chatCommand.js.map +1 -1
- package/dist/src/ui/commands/clearCommand.js +6 -3
- package/dist/src/ui/commands/clearCommand.js.map +1 -1
- package/dist/src/ui/commands/compressCommand.js +9 -4
- package/dist/src/ui/commands/compressCommand.js.map +1 -1
- package/dist/src/ui/commands/copyCommand.js +4 -1
- package/dist/src/ui/commands/copyCommand.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.js +30 -12
- package/dist/src/ui/commands/directoryCommand.js.map +1 -1
- package/dist/src/ui/commands/docsCommand.js +9 -3
- package/dist/src/ui/commands/docsCommand.js.map +1 -1
- package/dist/src/ui/commands/editorCommand.js +4 -1
- package/dist/src/ui/commands/editorCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.js +10 -3
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
- package/dist/src/ui/commands/helpCommand.js +4 -1
- package/dist/src/ui/commands/helpCommand.js.map +1 -1
- package/dist/src/ui/commands/ideCommand.js +23 -7
- package/dist/src/ui/commands/ideCommand.js.map +1 -1
- package/dist/src/ui/commands/initCommand.js +5 -3
- package/dist/src/ui/commands/initCommand.js.map +1 -1
- package/dist/src/ui/commands/languageCommand.d.ts +7 -0
- package/dist/src/ui/commands/languageCommand.js +386 -0
- package/dist/src/ui/commands/languageCommand.js.map +1 -0
- package/dist/src/ui/commands/mcpCommand.js +38 -18
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.js +54 -25
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/modelCommand.js +9 -4
- package/dist/src/ui/commands/modelCommand.js.map +1 -1
- package/dist/src/ui/commands/permissionsCommand.js +4 -1
- package/dist/src/ui/commands/permissionsCommand.js.map +1 -1
- package/dist/src/ui/commands/quitCommand.js +7 -2
- package/dist/src/ui/commands/quitCommand.js.map +1 -1
- package/dist/src/ui/commands/settingsCommand.js +4 -1
- package/dist/src/ui/commands/settingsCommand.js.map +1 -1
- package/dist/src/ui/commands/setupGithubCommand.js +4 -1
- package/dist/src/ui/commands/setupGithubCommand.js.map +1 -1
- package/dist/src/ui/commands/statsCommand.js +11 -4
- package/dist/src/ui/commands/statsCommand.js.map +1 -1
- package/dist/src/ui/commands/summaryCommand.js +15 -8
- package/dist/src/ui/commands/summaryCommand.js.map +1 -1
- package/dist/src/ui/commands/terminalSetupCommand.js +9 -3
- package/dist/src/ui/commands/terminalSetupCommand.js.map +1 -1
- package/dist/src/ui/commands/themeCommand.js +4 -1
- package/dist/src/ui/commands/themeCommand.js.map +1 -1
- package/dist/src/ui/commands/toolsCommand.js +5 -2
- package/dist/src/ui/commands/toolsCommand.js.map +1 -1
- package/dist/src/ui/commands/types.d.ts +1 -1
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/commands/vimCommand.js +4 -1
- package/dist/src/ui/commands/vimCommand.js.map +1 -1
- package/dist/src/ui/components/AboutBox.d.ts +2 -9
- package/dist/src/ui/components/AboutBox.js +6 -2
- package/dist/src/ui/components/AboutBox.js.map +1 -1
- package/dist/src/ui/components/ApprovalModeDialog.d.ts +21 -0
- package/dist/src/ui/components/ApprovalModeDialog.js +68 -0
- package/dist/src/ui/components/ApprovalModeDialog.js.map +1 -0
- package/dist/src/ui/components/AutoAcceptIndicator.js +7 -6
- package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -1
- package/dist/src/ui/components/Composer.js +4 -3
- package/dist/src/ui/components/Composer.js.map +1 -1
- package/dist/src/ui/components/ConfigInitDisplay.js +7 -3
- package/dist/src/ui/components/ConfigInitDisplay.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.js +33 -9
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/DialogManager.js +60 -13
- package/dist/src/ui/components/DialogManager.js.map +1 -1
- package/dist/src/ui/components/EditorSettingsDialog.js +8 -3
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
- package/dist/src/ui/components/Help.js +14 -4
- package/dist/src/ui/components/Help.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.test.js +17 -8
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +10 -136
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.js +6 -1
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.js +2 -1
- package/dist/src/ui/components/ModelDialog.js.map +1 -1
- package/dist/src/ui/components/ModelStatsDisplay.js +6 -5
- package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -1
- package/dist/src/ui/components/OpenAIKeyPrompt.d.ts +19 -1
- package/dist/src/ui/components/OpenAIKeyPrompt.js +38 -6
- package/dist/src/ui/components/OpenAIKeyPrompt.js.map +1 -1
- package/dist/src/ui/components/ProQuotaDialog.js +5 -4
- package/dist/src/ui/components/ProQuotaDialog.js.map +1 -1
- package/dist/src/ui/components/QuitConfirmationDialog.js +6 -5
- package/dist/src/ui/components/QuitConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/QwenOAuthProgress.d.ts +2 -2
- package/dist/src/ui/components/QwenOAuthProgress.js +14 -7
- package/dist/src/ui/components/QwenOAuthProgress.js.map +1 -1
- package/dist/src/ui/components/QwenOAuthProgress.test.js +1 -0
- package/dist/src/ui/components/QwenOAuthProgress.test.js.map +1 -1
- package/dist/src/ui/components/SessionSummaryDisplay.js +2 -1
- package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.d.ts +3 -1
- package/dist/src/ui/components/SettingsDialog.js +35 -12
- package/dist/src/ui/components/SettingsDialog.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +5 -4
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js +5 -4
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/StatsDisplay.js +5 -4
- package/dist/src/ui/components/StatsDisplay.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.js +5 -2
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/ToolStatsDisplay.js +3 -2
- package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -1
- package/dist/src/ui/components/WelcomeBackDialog.js +13 -4
- package/dist/src/ui/components/WelcomeBackDialog.js.map +1 -1
- package/dist/src/ui/components/messages/CompressionMessage.js +10 -6
- package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +40 -29
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.test.js +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.test.js.map +1 -1
- package/dist/src/ui/components/shared/ScopeSelector.js +3 -1
- package/dist/src/ui/components/shared/ScopeSelector.js.map +1 -1
- package/dist/src/ui/components/subagents/create/AgentCreationWizard.js +39 -26
- package/dist/src/ui/components/subagents/create/AgentCreationWizard.js.map +1 -1
- package/dist/src/ui/components/subagents/create/CreationSummary.js +20 -10
- package/dist/src/ui/components/subagents/create/CreationSummary.js.map +1 -1
- package/dist/src/ui/components/subagents/create/DescriptionInput.js +6 -3
- package/dist/src/ui/components/subagents/create/DescriptionInput.js.map +1 -1
- package/dist/src/ui/components/subagents/create/GenerationMethodSelector.js +7 -2
- package/dist/src/ui/components/subagents/create/GenerationMethodSelector.js.map +1 -1
- package/dist/src/ui/components/subagents/create/LocationSelector.js +7 -2
- package/dist/src/ui/components/subagents/create/LocationSelector.js.map +1 -1
- package/dist/src/ui/components/subagents/create/ToolSelector.js +8 -7
- package/dist/src/ui/components/subagents/create/ToolSelector.js.map +1 -1
- package/dist/src/ui/components/subagents/manage/ActionSelectionStep.js +29 -4
- package/dist/src/ui/components/subagents/manage/ActionSelectionStep.js.map +1 -1
- package/dist/src/ui/components/subagents/manage/AgentDeleteStep.js +6 -3
- package/dist/src/ui/components/subagents/manage/AgentDeleteStep.js.map +1 -1
- package/dist/src/ui/components/subagents/manage/AgentEditStep.js +14 -5
- package/dist/src/ui/components/subagents/manage/AgentEditStep.js.map +1 -1
- package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js +13 -6
- package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js.map +1 -1
- package/dist/src/ui/components/subagents/manage/AgentViewerStep.js +3 -2
- package/dist/src/ui/components/subagents/manage/AgentViewerStep.js.map +1 -1
- package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.js +14 -13
- package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.js.map +1 -1
- package/dist/src/ui/components/subagents/runtime/AgentExecutionDisplay.js +8 -8
- package/dist/src/ui/components/views/McpStatus.js +28 -15
- package/dist/src/ui/components/views/McpStatus.js.map +1 -1
- package/dist/src/ui/components/views/ToolsList.js +2 -1
- package/dist/src/ui/components/views/ToolsList.js.map +1 -1
- package/dist/src/ui/contexts/UIActionsContext.d.ts +5 -4
- package/dist/src/ui/contexts/UIActionsContext.js +1 -0
- package/dist/src/ui/contexts/UIActionsContext.js.map +1 -1
- package/dist/src/ui/contexts/UIStateContext.d.ts +5 -7
- package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
- package/dist/src/ui/editors/editorSettingsManager.js +1 -0
- package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.test.js +2 -0
- package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +1 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js +4 -7
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useApprovalModeCommand.d.ts +14 -0
- package/dist/src/ui/hooks/useApprovalModeCommand.js +33 -0
- package/dist/src/ui/hooks/useApprovalModeCommand.js.map +1 -0
- package/dist/src/ui/hooks/useAttentionNotifications.d.ts +14 -0
- package/dist/src/ui/hooks/useAttentionNotifications.js +41 -0
- package/dist/src/ui/hooks/useAttentionNotifications.js.map +1 -0
- package/dist/src/ui/hooks/useAttentionNotifications.test.d.ts +6 -0
- package/dist/src/ui/hooks/useAttentionNotifications.test.js +113 -0
- package/dist/src/ui/hooks/useAttentionNotifications.test.js.map +1 -0
- package/dist/src/ui/hooks/useCommandCompletion.d.ts +1 -4
- package/dist/src/ui/hooks/useCommandCompletion.js +1 -23
- package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useDialogClose.d.ts +6 -3
- package/dist/src/ui/hooks/useDialogClose.js +5 -0
- package/dist/src/ui/hooks/useDialogClose.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.js +6 -3
- package/dist/src/ui/hooks/useGitBranchName.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.test.js +39 -21
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -1
- package/dist/src/ui/hooks/useInitializationAuthError.d.ts +22 -0
- package/dist/src/ui/hooks/useInitializationAuthError.js +40 -0
- package/dist/src/ui/hooks/useInitializationAuthError.js.map +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.js +6 -4
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/useQwenAuth.d.ts +7 -12
- package/dist/src/ui/hooks/useQwenAuth.js +4 -8
- package/dist/src/ui/hooks/useQwenAuth.js.map +1 -1
- package/dist/src/ui/hooks/useQwenAuth.test.js +72 -98
- package/dist/src/ui/hooks/useQwenAuth.test.js.map +1 -1
- package/dist/src/ui/hooks/useThemeCommand.js +8 -3
- package/dist/src/ui/hooks/useThemeCommand.js.map +1 -1
- package/dist/src/ui/models/availableModels.js +7 -2
- package/dist/src/ui/models/availableModels.js.map +1 -1
- package/dist/src/ui/types.d.ts +32 -14
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/clipboardUtils.js +3 -3
- package/dist/src/ui/utils/clipboardUtils.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.d.ts +16 -0
- package/dist/src/ui/utils/commandUtils.js +16 -1
- package/dist/src/ui/utils/commandUtils.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.test.js +5 -2
- package/dist/src/ui/utils/commandUtils.test.js.map +1 -1
- package/dist/src/ui/utils/terminalSetup.js +45 -18
- package/dist/src/ui/utils/terminalSetup.js.map +1 -1
- package/dist/src/utils/attentionNotification.d.ts +20 -0
- package/dist/src/utils/attentionNotification.js +34 -0
- package/dist/src/utils/attentionNotification.js.map +1 -0
- package/dist/src/utils/attentionNotification.test.d.ts +6 -0
- package/dist/src/utils/attentionNotification.test.js +46 -0
- package/dist/src/utils/attentionNotification.test.js.map +1 -0
- package/dist/src/utils/dialogScopeUtils.d.ts +0 -4
- package/dist/src/utils/dialogScopeUtils.js +5 -2
- package/dist/src/utils/dialogScopeUtils.js.map +1 -1
- package/dist/src/utils/errors.d.ts +10 -2
- package/dist/src/utils/errors.js +14 -13
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.js +91 -54
- package/dist/src/utils/errors.test.js.map +1 -1
- package/dist/src/utils/nonInteractiveHelpers.d.ts +88 -0
- package/dist/src/utils/nonInteractiveHelpers.js +470 -0
- package/dist/src/utils/nonInteractiveHelpers.js.map +1 -0
- package/dist/src/utils/nonInteractiveHelpers.test.d.ts +6 -0
- package/dist/src/utils/nonInteractiveHelpers.test.js +945 -0
- package/dist/src/utils/nonInteractiveHelpers.test.js.map +1 -0
- package/dist/src/utils/sandbox.js +1 -1
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/settingsUtils.js +7 -1
- package/dist/src/utils/settingsUtils.js.map +1 -1
- package/dist/src/utils/systemInfo.d.ts +66 -0
- package/dist/src/utils/systemInfo.js +125 -0
- package/dist/src/utils/systemInfo.js.map +1 -0
- package/dist/src/utils/systemInfo.test.d.ts +6 -0
- package/dist/src/utils/systemInfo.test.js +259 -0
- package/dist/src/utils/systemInfo.test.js.map +1 -0
- package/dist/src/utils/systemInfoFields.d.ts +22 -0
- package/dist/src/utils/systemInfoFields.js +96 -0
- package/dist/src/utils/systemInfoFields.js.map +1 -0
- package/dist/src/utils/userStartupWarnings.js +9 -4
- package/dist/src/utils/userStartupWarnings.js.map +1 -1
- package/dist/src/validateNonInterActiveAuth.js +27 -6
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/src/zed-integration/acp.js +1 -2
- package/dist/src/zed-integration/acp.js.map +1 -1
- package/dist/src/zed-integration/schema.d.ts +506 -264
- package/dist/src/zed-integration/schema.js +13 -0
- package/dist/src/zed-integration/schema.js.map +1 -1
- package/dist/src/zed-integration/zedIntegration.js +376 -32
- package/dist/src/zed-integration/zedIntegration.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -4
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Qwen Team
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Permission Controller
|
|
8
|
+
*
|
|
9
|
+
* Handles permission-related control requests:
|
|
10
|
+
* - can_use_tool: Check if tool usage is allowed
|
|
11
|
+
* - set_permission_mode: Change permission mode at runtime
|
|
12
|
+
*
|
|
13
|
+
* Abstracts all permission logic from the session manager to keep it clean.
|
|
14
|
+
*/
|
|
15
|
+
import type { ToolCallRequestInfo } from '@umsai/ums-code-core';
|
|
16
|
+
import type { ControlRequestPayload, PermissionSuggestion } from '../../types.js';
|
|
17
|
+
import { BaseController } from './baseController.js';
|
|
18
|
+
export declare class PermissionController extends BaseController {
|
|
19
|
+
private pendingOutgoingRequests;
|
|
20
|
+
/**
|
|
21
|
+
* Handle permission control requests
|
|
22
|
+
*/
|
|
23
|
+
protected handleRequestPayload(payload: ControlRequestPayload, _signal: AbortSignal): Promise<Record<string, unknown>>;
|
|
24
|
+
/**
|
|
25
|
+
* Handle can_use_tool request
|
|
26
|
+
*
|
|
27
|
+
* Comprehensive permission evaluation based on:
|
|
28
|
+
* - Permission mode (approval level)
|
|
29
|
+
* - Tool registry validation
|
|
30
|
+
* - Error handling with safe defaults
|
|
31
|
+
*/
|
|
32
|
+
private handleCanUseTool;
|
|
33
|
+
/**
|
|
34
|
+
* Check permission mode for tool execution
|
|
35
|
+
*/
|
|
36
|
+
private checkPermissionMode;
|
|
37
|
+
/**
|
|
38
|
+
* Check if tool exists in registry
|
|
39
|
+
*/
|
|
40
|
+
private checkToolRegistry;
|
|
41
|
+
/**
|
|
42
|
+
* Handle set_permission_mode request
|
|
43
|
+
*
|
|
44
|
+
* Updates the permission mode in the context
|
|
45
|
+
*/
|
|
46
|
+
private handleSetPermissionMode;
|
|
47
|
+
/**
|
|
48
|
+
* Build permission suggestions for tool confirmation UI
|
|
49
|
+
*
|
|
50
|
+
* This method creates UI suggestions based on tool confirmation details,
|
|
51
|
+
* helping the host application present appropriate permission options.
|
|
52
|
+
*/
|
|
53
|
+
buildPermissionSuggestions(confirmationDetails: unknown): PermissionSuggestion[] | null;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a tool should be executed based on current permission settings
|
|
56
|
+
*
|
|
57
|
+
* This is a convenience method for direct tool execution checks without
|
|
58
|
+
* going through the control request flow.
|
|
59
|
+
*/
|
|
60
|
+
shouldAllowTool(toolRequest: ToolCallRequestInfo, confirmationDetails?: unknown): Promise<{
|
|
61
|
+
allowed: boolean;
|
|
62
|
+
message?: string;
|
|
63
|
+
updatedArgs?: Record<string, unknown>;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Get callback for monitoring tool calls and handling outgoing permission requests
|
|
67
|
+
* This is passed to executeToolCall to hook into CoreToolScheduler updates
|
|
68
|
+
*/
|
|
69
|
+
getToolCallUpdateCallback(): (toolCalls: unknown[]) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Handle outgoing permission request
|
|
72
|
+
*
|
|
73
|
+
* Behavior depends on input format:
|
|
74
|
+
* - stream-json mode: Send can_use_tool to SDK and await response
|
|
75
|
+
* - Other modes: Check local approval mode and decide immediately
|
|
76
|
+
*/
|
|
77
|
+
private handleOutgoingPermissionRequest;
|
|
78
|
+
}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Qwen Team
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { InputFormat, ToolConfirmationOutcome, } from '@umsai/ums-code-core';
|
|
7
|
+
import { BaseController } from './baseController.js';
|
|
8
|
+
export class PermissionController extends BaseController {
|
|
9
|
+
pendingOutgoingRequests = new Set();
|
|
10
|
+
/**
|
|
11
|
+
* Handle permission control requests
|
|
12
|
+
*/
|
|
13
|
+
async handleRequestPayload(payload, _signal) {
|
|
14
|
+
switch (payload.subtype) {
|
|
15
|
+
case 'can_use_tool':
|
|
16
|
+
return this.handleCanUseTool(payload);
|
|
17
|
+
case 'set_permission_mode':
|
|
18
|
+
return this.handleSetPermissionMode(payload);
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(`Unsupported request subtype in PermissionController`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Handle can_use_tool request
|
|
25
|
+
*
|
|
26
|
+
* Comprehensive permission evaluation based on:
|
|
27
|
+
* - Permission mode (approval level)
|
|
28
|
+
* - Tool registry validation
|
|
29
|
+
* - Error handling with safe defaults
|
|
30
|
+
*/
|
|
31
|
+
async handleCanUseTool(payload) {
|
|
32
|
+
const toolName = payload.tool_name;
|
|
33
|
+
if (!toolName ||
|
|
34
|
+
typeof toolName !== 'string' ||
|
|
35
|
+
toolName.trim().length === 0) {
|
|
36
|
+
return {
|
|
37
|
+
subtype: 'can_use_tool',
|
|
38
|
+
behavior: 'deny',
|
|
39
|
+
message: 'Missing or invalid tool_name in can_use_tool request',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
let behavior = 'allow';
|
|
43
|
+
let message;
|
|
44
|
+
try {
|
|
45
|
+
// Check permission mode first
|
|
46
|
+
const permissionResult = this.checkPermissionMode();
|
|
47
|
+
if (!permissionResult.allowed) {
|
|
48
|
+
behavior = 'deny';
|
|
49
|
+
message = permissionResult.message;
|
|
50
|
+
}
|
|
51
|
+
// Check tool registry if permission mode allows
|
|
52
|
+
if (behavior === 'allow') {
|
|
53
|
+
const registryResult = this.checkToolRegistry(toolName);
|
|
54
|
+
if (!registryResult.allowed) {
|
|
55
|
+
behavior = 'deny';
|
|
56
|
+
message = registryResult.message;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
behavior = 'deny';
|
|
62
|
+
message =
|
|
63
|
+
error instanceof Error
|
|
64
|
+
? `Failed to evaluate tool permission: ${error.message}`
|
|
65
|
+
: 'Failed to evaluate tool permission';
|
|
66
|
+
}
|
|
67
|
+
const response = {
|
|
68
|
+
subtype: 'can_use_tool',
|
|
69
|
+
behavior,
|
|
70
|
+
};
|
|
71
|
+
if (message) {
|
|
72
|
+
response['message'] = message;
|
|
73
|
+
}
|
|
74
|
+
return response;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check permission mode for tool execution
|
|
78
|
+
*/
|
|
79
|
+
checkPermissionMode() {
|
|
80
|
+
const mode = this.context.permissionMode;
|
|
81
|
+
// Map permission modes to approval logic (aligned with VALID_APPROVAL_MODE_VALUES)
|
|
82
|
+
switch (mode) {
|
|
83
|
+
case 'yolo': // Allow all tools
|
|
84
|
+
case 'auto-edit': // Auto-approve edit operations
|
|
85
|
+
case 'plan': // Auto-approve planning operations
|
|
86
|
+
return { allowed: true };
|
|
87
|
+
case 'default': // TODO: allow all tools for test
|
|
88
|
+
default:
|
|
89
|
+
return {
|
|
90
|
+
allowed: false,
|
|
91
|
+
message: 'Tool execution requires manual approval. Update permission mode or approve via host.',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if tool exists in registry
|
|
97
|
+
*/
|
|
98
|
+
checkToolRegistry(toolName) {
|
|
99
|
+
try {
|
|
100
|
+
// Access tool registry through config
|
|
101
|
+
const config = this.context.config;
|
|
102
|
+
const registryProvider = config;
|
|
103
|
+
if (typeof registryProvider.getToolRegistry === 'function') {
|
|
104
|
+
const registry = registryProvider.getToolRegistry();
|
|
105
|
+
if (registry &&
|
|
106
|
+
typeof registry.getTool === 'function' &&
|
|
107
|
+
!registry.getTool(toolName)) {
|
|
108
|
+
return {
|
|
109
|
+
allowed: false,
|
|
110
|
+
message: `Tool "${toolName}" is not registered.`,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { allowed: true };
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return {
|
|
118
|
+
allowed: false,
|
|
119
|
+
message: `Failed to check tool registry: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Handle set_permission_mode request
|
|
125
|
+
*
|
|
126
|
+
* Updates the permission mode in the context
|
|
127
|
+
*/
|
|
128
|
+
async handleSetPermissionMode(payload) {
|
|
129
|
+
const mode = payload.mode;
|
|
130
|
+
const validModes = [
|
|
131
|
+
'default',
|
|
132
|
+
'plan',
|
|
133
|
+
'auto-edit',
|
|
134
|
+
'yolo',
|
|
135
|
+
];
|
|
136
|
+
if (!validModes.includes(mode)) {
|
|
137
|
+
throw new Error(`Invalid permission mode: ${mode}. Valid values are: ${validModes.join(', ')}`);
|
|
138
|
+
}
|
|
139
|
+
this.context.permissionMode = mode;
|
|
140
|
+
if (this.context.debugMode) {
|
|
141
|
+
console.error(`[PermissionController] Permission mode updated to: ${mode}`);
|
|
142
|
+
}
|
|
143
|
+
return { status: 'updated', mode };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Build permission suggestions for tool confirmation UI
|
|
147
|
+
*
|
|
148
|
+
* This method creates UI suggestions based on tool confirmation details,
|
|
149
|
+
* helping the host application present appropriate permission options.
|
|
150
|
+
*/
|
|
151
|
+
buildPermissionSuggestions(confirmationDetails) {
|
|
152
|
+
if (!confirmationDetails ||
|
|
153
|
+
typeof confirmationDetails !== 'object' ||
|
|
154
|
+
!('type' in confirmationDetails)) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const details = confirmationDetails;
|
|
158
|
+
const type = String(details['type'] ?? '');
|
|
159
|
+
const title = typeof details['title'] === 'string' ? details['title'] : undefined;
|
|
160
|
+
// Ensure type matches ToolCallConfirmationDetails union
|
|
161
|
+
const confirmationType = type;
|
|
162
|
+
switch (confirmationType) {
|
|
163
|
+
case 'exec': // ToolExecuteConfirmationDetails
|
|
164
|
+
return [
|
|
165
|
+
{
|
|
166
|
+
type: 'allow',
|
|
167
|
+
label: 'Allow Command',
|
|
168
|
+
description: `Execute: ${details['command']}`,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
type: 'deny',
|
|
172
|
+
label: 'Deny',
|
|
173
|
+
description: 'Block this command execution',
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
case 'edit': // ToolEditConfirmationDetails
|
|
177
|
+
return [
|
|
178
|
+
{
|
|
179
|
+
type: 'allow',
|
|
180
|
+
label: 'Allow Edit',
|
|
181
|
+
description: `Edit file: ${details['fileName']}`,
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
type: 'deny',
|
|
185
|
+
label: 'Deny',
|
|
186
|
+
description: 'Block this file edit',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
type: 'modify',
|
|
190
|
+
label: 'Review Changes',
|
|
191
|
+
description: 'Review the proposed changes before applying',
|
|
192
|
+
},
|
|
193
|
+
];
|
|
194
|
+
case 'plan': // ToolPlanConfirmationDetails
|
|
195
|
+
return [
|
|
196
|
+
{
|
|
197
|
+
type: 'allow',
|
|
198
|
+
label: 'Approve Plan',
|
|
199
|
+
description: title || 'Execute the proposed plan',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
type: 'deny',
|
|
203
|
+
label: 'Reject Plan',
|
|
204
|
+
description: 'Do not execute this plan',
|
|
205
|
+
},
|
|
206
|
+
];
|
|
207
|
+
case 'mcp': // ToolMcpConfirmationDetails
|
|
208
|
+
return [
|
|
209
|
+
{
|
|
210
|
+
type: 'allow',
|
|
211
|
+
label: 'Allow MCP Call',
|
|
212
|
+
description: `${details['serverName']}: ${details['toolName']}`,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: 'deny',
|
|
216
|
+
label: 'Deny',
|
|
217
|
+
description: 'Block this MCP server call',
|
|
218
|
+
},
|
|
219
|
+
];
|
|
220
|
+
case 'info': // ToolInfoConfirmationDetails
|
|
221
|
+
return [
|
|
222
|
+
{
|
|
223
|
+
type: 'allow',
|
|
224
|
+
label: 'Allow Info Request',
|
|
225
|
+
description: title || 'Allow information request',
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
type: 'deny',
|
|
229
|
+
label: 'Deny',
|
|
230
|
+
description: 'Block this information request',
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
default:
|
|
234
|
+
// Fallback for unknown types
|
|
235
|
+
return [
|
|
236
|
+
{
|
|
237
|
+
type: 'allow',
|
|
238
|
+
label: 'Allow',
|
|
239
|
+
description: title || `Allow ${type} operation`,
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
type: 'deny',
|
|
243
|
+
label: 'Deny',
|
|
244
|
+
description: `Block ${type} operation`,
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Check if a tool should be executed based on current permission settings
|
|
251
|
+
*
|
|
252
|
+
* This is a convenience method for direct tool execution checks without
|
|
253
|
+
* going through the control request flow.
|
|
254
|
+
*/
|
|
255
|
+
async shouldAllowTool(toolRequest, confirmationDetails) {
|
|
256
|
+
// Check permission mode
|
|
257
|
+
const modeResult = this.checkPermissionMode();
|
|
258
|
+
if (!modeResult.allowed) {
|
|
259
|
+
return {
|
|
260
|
+
allowed: false,
|
|
261
|
+
message: modeResult.message,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
// Check tool registry
|
|
265
|
+
const registryResult = this.checkToolRegistry(toolRequest.name);
|
|
266
|
+
if (!registryResult.allowed) {
|
|
267
|
+
return {
|
|
268
|
+
allowed: false,
|
|
269
|
+
message: registryResult.message,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
// If we have confirmation details, we could potentially modify args
|
|
273
|
+
// This is a hook for future enhancement
|
|
274
|
+
if (confirmationDetails) {
|
|
275
|
+
// Future: handle argument modifications based on confirmation details
|
|
276
|
+
}
|
|
277
|
+
return { allowed: true };
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get callback for monitoring tool calls and handling outgoing permission requests
|
|
281
|
+
* This is passed to executeToolCall to hook into CoreToolScheduler updates
|
|
282
|
+
*/
|
|
283
|
+
getToolCallUpdateCallback() {
|
|
284
|
+
return (toolCalls) => {
|
|
285
|
+
for (const call of toolCalls) {
|
|
286
|
+
if (call &&
|
|
287
|
+
typeof call === 'object' &&
|
|
288
|
+
call.status === 'awaiting_approval') {
|
|
289
|
+
const awaiting = call;
|
|
290
|
+
if (typeof awaiting.confirmationDetails?.onConfirm === 'function' &&
|
|
291
|
+
!this.pendingOutgoingRequests.has(awaiting.request.callId)) {
|
|
292
|
+
this.pendingOutgoingRequests.add(awaiting.request.callId);
|
|
293
|
+
void this.handleOutgoingPermissionRequest(awaiting);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Handle outgoing permission request
|
|
301
|
+
*
|
|
302
|
+
* Behavior depends on input format:
|
|
303
|
+
* - stream-json mode: Send can_use_tool to SDK and await response
|
|
304
|
+
* - Other modes: Check local approval mode and decide immediately
|
|
305
|
+
*/
|
|
306
|
+
async handleOutgoingPermissionRequest(toolCall) {
|
|
307
|
+
try {
|
|
308
|
+
const inputFormat = this.context.config.getInputFormat?.();
|
|
309
|
+
const isStreamJsonMode = inputFormat === InputFormat.STREAM_JSON;
|
|
310
|
+
if (!isStreamJsonMode) {
|
|
311
|
+
// No SDK available - use local permission check
|
|
312
|
+
const modeCheck = this.checkPermissionMode();
|
|
313
|
+
const outcome = modeCheck.allowed
|
|
314
|
+
? ToolConfirmationOutcome.ProceedOnce
|
|
315
|
+
: ToolConfirmationOutcome.Cancel;
|
|
316
|
+
await toolCall.confirmationDetails.onConfirm(outcome);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
// Stream-json mode: ask SDK for permission
|
|
320
|
+
const permissionSuggestions = this.buildPermissionSuggestions(toolCall.confirmationDetails);
|
|
321
|
+
const response = await this.sendControlRequest({
|
|
322
|
+
subtype: 'can_use_tool',
|
|
323
|
+
tool_name: toolCall.request.name,
|
|
324
|
+
tool_use_id: toolCall.request.callId,
|
|
325
|
+
input: toolCall.request.args,
|
|
326
|
+
permission_suggestions: permissionSuggestions,
|
|
327
|
+
blocked_path: null,
|
|
328
|
+
}, 30000);
|
|
329
|
+
if (response.subtype !== 'success') {
|
|
330
|
+
await toolCall.confirmationDetails.onConfirm(ToolConfirmationOutcome.Cancel);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const payload = (response.response || {});
|
|
334
|
+
const behavior = String(payload['behavior'] || '').toLowerCase();
|
|
335
|
+
if (behavior === 'allow') {
|
|
336
|
+
// Handle updated input if provided
|
|
337
|
+
const updatedInput = payload['updatedInput'];
|
|
338
|
+
if (updatedInput && typeof updatedInput === 'object') {
|
|
339
|
+
toolCall.request.args = updatedInput;
|
|
340
|
+
}
|
|
341
|
+
await toolCall.confirmationDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
await toolCall.confirmationDetails.onConfirm(ToolConfirmationOutcome.Cancel);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
if (this.context.debugMode) {
|
|
349
|
+
console.error('[PermissionController] Outgoing permission failed:', error);
|
|
350
|
+
}
|
|
351
|
+
await toolCall.confirmationDetails.onConfirm(ToolConfirmationOutcome.Cancel);
|
|
352
|
+
}
|
|
353
|
+
finally {
|
|
354
|
+
this.pendingOutgoingRequests.delete(toolCall.request.callId);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=permissionController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissionController.js","sourceRoot":"","sources":["../../../../../src/nonInteractive/control/controllers/permissionController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,OAAO,EACL,WAAW,EACX,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAC9C,uBAAuB,GAAG,IAAI,GAAG,EAAU,CAAC;IAEpD;;OAEG;IACO,KAAK,CAAC,oBAAoB,CAClC,OAA8B,EAC9B,OAAoB;QAEpB,QAAQ,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAsC,CAAC,CAAC;YAEvE,KAAK,qBAAqB;gBACxB,OAAO,IAAI,CAAC,uBAAuB,CACjC,OAA6C,CAC9C,CAAC;YAEJ;gBACE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACK,KAAK,CAAC,gBAAgB,CAC5B,OAAoC;QAEpC,MAAM,QAAQ,GAAG,OAAO,CAAC,S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AM,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAC1C,uBAAuB,CAAC,MAAM,CAC/B,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Qwen Team
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* System Controller
|
|
8
|
+
*
|
|
9
|
+
* Handles system-level control requests:
|
|
10
|
+
* - initialize: Setup session and return system info
|
|
11
|
+
* - interrupt: Cancel current operations
|
|
12
|
+
* - set_model: Switch model (placeholder)
|
|
13
|
+
*/
|
|
14
|
+
import { BaseController } from './baseController.js';
|
|
15
|
+
import type { ControlRequestPayload } from '../../types.js';
|
|
16
|
+
export declare class SystemController extends BaseController {
|
|
17
|
+
/**
|
|
18
|
+
* Handle system control requests
|
|
19
|
+
*/
|
|
20
|
+
protected handleRequestPayload(payload: ControlRequestPayload, _signal: AbortSignal): Promise<Record<string, unknown>>;
|
|
21
|
+
/**
|
|
22
|
+
* Handle initialize request
|
|
23
|
+
*
|
|
24
|
+
* Registers SDK MCP servers and returns capabilities
|
|
25
|
+
*/
|
|
26
|
+
private handleInitialize;
|
|
27
|
+
/**
|
|
28
|
+
* Build control capabilities for initialize control response
|
|
29
|
+
*
|
|
30
|
+
* This method constructs the control capabilities object that indicates
|
|
31
|
+
* what control features are available. It is used exclusively in the
|
|
32
|
+
* initialize control response.
|
|
33
|
+
*/
|
|
34
|
+
buildControlCapabilities(): Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Handle interrupt request
|
|
37
|
+
*
|
|
38
|
+
* Triggers the interrupt callback to cancel current operations
|
|
39
|
+
*/
|
|
40
|
+
private handleInterrupt;
|
|
41
|
+
/**
|
|
42
|
+
* Handle set_model request
|
|
43
|
+
*
|
|
44
|
+
* Implements actual model switching with validation and error handling
|
|
45
|
+
*/
|
|
46
|
+
private handleSetModel;
|
|
47
|
+
/**
|
|
48
|
+
* Handle supported_commands request
|
|
49
|
+
*
|
|
50
|
+
* Returns list of supported control commands
|
|
51
|
+
*
|
|
52
|
+
* Note: This list should match the ControlRequestType enum in
|
|
53
|
+
* packages/sdk/typescript/src/types/controlRequests.ts
|
|
54
|
+
*/
|
|
55
|
+
private handleSupportedCommands;
|
|
56
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Qwen Team
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* System Controller
|
|
8
|
+
*
|
|
9
|
+
* Handles system-level control requests:
|
|
10
|
+
* - initialize: Setup session and return system info
|
|
11
|
+
* - interrupt: Cancel current operations
|
|
12
|
+
* - set_model: Switch model (placeholder)
|
|
13
|
+
*/
|
|
14
|
+
import { BaseController } from './baseController.js';
|
|
15
|
+
export class SystemController extends BaseController {
|
|
16
|
+
/**
|
|
17
|
+
* Handle system control requests
|
|
18
|
+
*/
|
|
19
|
+
async handleRequestPayload(payload, _signal) {
|
|
20
|
+
switch (payload.subtype) {
|
|
21
|
+
case 'initialize':
|
|
22
|
+
return this.handleInitialize(payload);
|
|
23
|
+
case 'interrupt':
|
|
24
|
+
return this.handleInterrupt();
|
|
25
|
+
case 'set_model':
|
|
26
|
+
return this.handleSetModel(payload);
|
|
27
|
+
case 'supported_commands':
|
|
28
|
+
return this.handleSupportedCommands();
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Unsupported request subtype in SystemController`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Handle initialize request
|
|
35
|
+
*
|
|
36
|
+
* Registers SDK MCP servers and returns capabilities
|
|
37
|
+
*/
|
|
38
|
+
async handleInitialize(payload) {
|
|
39
|
+
// Register SDK MCP servers if provided
|
|
40
|
+
if (payload.sdkMcpServers && Array.isArray(payload.sdkMcpServers)) {
|
|
41
|
+
for (const serverName of payload.sdkMcpServers) {
|
|
42
|
+
this.context.sdkMcpServers.add(serverName);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Build capabilities for response
|
|
46
|
+
const capabilities = this.buildControlCapabilities();
|
|
47
|
+
if (this.context.debugMode) {
|
|
48
|
+
console.error(`[SystemController] Initialized with ${this.context.sdkMcpServers.size} SDK MCP servers`);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
subtype: 'initialize',
|
|
52
|
+
capabilities,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build control capabilities for initialize control response
|
|
57
|
+
*
|
|
58
|
+
* This method constructs the control capabilities object that indicates
|
|
59
|
+
* what control features are available. It is used exclusively in the
|
|
60
|
+
* initialize control response.
|
|
61
|
+
*/
|
|
62
|
+
buildControlCapabilities() {
|
|
63
|
+
const capabilities = {
|
|
64
|
+
can_handle_can_use_tool: true,
|
|
65
|
+
can_handle_hook_callback: true,
|
|
66
|
+
can_set_permission_mode: typeof this.context.config.setApprovalMode === 'function',
|
|
67
|
+
can_set_model: typeof this.context.config.setModel === 'function',
|
|
68
|
+
};
|
|
69
|
+
// Check if MCP message handling is available
|
|
70
|
+
try {
|
|
71
|
+
const mcpProvider = this.context.config;
|
|
72
|
+
if (typeof mcpProvider.getMcpServers === 'function') {
|
|
73
|
+
const servers = mcpProvider.getMcpServers();
|
|
74
|
+
capabilities['can_handle_mcp_message'] = Boolean(servers && Object.keys(servers).length > 0);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
capabilities['can_handle_mcp_message'] = false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (this.context.debugMode) {
|
|
82
|
+
console.error('[SystemController] Failed to determine MCP capability:', error);
|
|
83
|
+
}
|
|
84
|
+
capabilities['can_handle_mcp_message'] = false;
|
|
85
|
+
}
|
|
86
|
+
return capabilities;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Handle interrupt request
|
|
90
|
+
*
|
|
91
|
+
* Triggers the interrupt callback to cancel current operations
|
|
92
|
+
*/
|
|
93
|
+
async handleInterrupt() {
|
|
94
|
+
// Trigger interrupt callback if available
|
|
95
|
+
if (this.context.onInterrupt) {
|
|
96
|
+
this.context.onInterrupt();
|
|
97
|
+
}
|
|
98
|
+
// Abort the main signal to cancel ongoing operations
|
|
99
|
+
if (this.context.abortSignal && !this.context.abortSignal.aborted) {
|
|
100
|
+
// Note: We can't directly abort the signal, but the onInterrupt callback should handle this
|
|
101
|
+
if (this.context.debugMode) {
|
|
102
|
+
console.error('[SystemController] Interrupt signal triggered');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (this.context.debugMode) {
|
|
106
|
+
console.error('[SystemController] Interrupt handled');
|
|
107
|
+
}
|
|
108
|
+
return { subtype: 'interrupt' };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Handle set_model request
|
|
112
|
+
*
|
|
113
|
+
* Implements actual model switching with validation and error handling
|
|
114
|
+
*/
|
|
115
|
+
async handleSetModel(payload) {
|
|
116
|
+
const model = payload.model;
|
|
117
|
+
// Validate model parameter
|
|
118
|
+
if (typeof model !== 'string' || model.trim() === '') {
|
|
119
|
+
throw new Error('Invalid model specified for set_model request');
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
// Attempt to set the model using config
|
|
123
|
+
await this.context.config.setModel(model);
|
|
124
|
+
if (this.context.debugMode) {
|
|
125
|
+
console.error(`[SystemController] Model switched to: ${model}`);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
subtype: 'set_model',
|
|
129
|
+
model,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to set model';
|
|
134
|
+
if (this.context.debugMode) {
|
|
135
|
+
console.error(`[SystemController] Failed to set model ${model}:`, error);
|
|
136
|
+
}
|
|
137
|
+
throw new Error(errorMessage);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Handle supported_commands request
|
|
142
|
+
*
|
|
143
|
+
* Returns list of supported control commands
|
|
144
|
+
*
|
|
145
|
+
* Note: This list should match the ControlRequestType enum in
|
|
146
|
+
* packages/sdk/typescript/src/types/controlRequests.ts
|
|
147
|
+
*/
|
|
148
|
+
async handleSupportedCommands() {
|
|
149
|
+
const commands = [
|
|
150
|
+
'initialize',
|
|
151
|
+
'interrupt',
|
|
152
|
+
'set_model',
|
|
153
|
+
'supported_commands',
|
|
154
|
+
'can_use_tool',
|
|
155
|
+
'set_permission_mode',
|
|
156
|
+
'mcp_message',
|
|
157
|
+
'mcp_server_status',
|
|
158
|
+
'hook_callback',
|
|
159
|
+
];
|
|
160
|
+
return {
|
|
161
|
+
subtype: 'supported_commands',
|
|
162
|
+
commands,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=systemController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemController.js","sourceRoot":"","sources":["../../../../../src/nonInteractive/control/controllers/systemController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAOrD,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAClD;;OAEG;IACO,KAAK,CAAC,oBAAoB,CAClC,OAA8B,EAC9B,OAAoB;QAEpB,QAAQ,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAsC,CAAC,CAAC;YAEvE,KAAK,WA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