@codingame/monaco-vscode-chat-service-override 37.0.0 → 37.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/index.js +11 -0
- package/package.json +5 -5
- package/vscode/src/vs/platform/agentHost/browser/agentHostProtocolClient.js +1 -1
- package/vscode/src/vs/platform/agentHost/common/agentHostCustomizationConfig.d.ts +74 -0
- package/vscode/src/vs/platform/agentHost/common/agentHostCustomizationConfig.js +90 -0
- package/vscode/src/vs/platform/agentHost/common/agentHostSlashCommand.d.ts +8 -0
- package/vscode/src/vs/platform/agentHost/common/agentHostSlashCommand.js +16 -0
- package/vscode/src/vs/platform/agentHost/common/agentHostStarter.config.contribution.js +53 -53
- package/vscode/src/vs/platform/agentHost/common/agentHostWorkingDirectories.d.ts +16 -0
- package/vscode/src/vs/platform/agentHost/common/agentHostWorkingDirectories.js +14 -0
- package/vscode/src/vs/platform/agentHost/common/agentMerge.js +7 -7
- package/vscode/src/vs/platform/agentHost/common/agentModelByokMeta.d.ts +24 -0
- package/vscode/src/vs/platform/agentHost/common/agentModelByokMeta.js +13 -0
- package/vscode/src/vs/platform/agentHost/common/agentModelNotices.d.ts +22 -0
- package/vscode/src/vs/platform/agentHost/common/agentModelNotices.js +21 -0
- package/vscode/src/vs/platform/agentHost/common/agentModelPricing.d.ts +114 -0
- package/vscode/src/vs/platform/agentHost/common/agentModelPricing.js +56 -0
- package/vscode/src/vs/platform/agentHost/common/changesetUri.js +15 -1
- package/vscode/src/vs/platform/agentHost/common/copilotConfigSlashCommands.d.ts +73 -0
- package/vscode/src/vs/platform/agentHost/common/copilotConfigSlashCommands.js +141 -0
- package/vscode/src/vs/platform/agentHost/common/meta/agentCompletionAttachmentMeta.js +42 -1
- package/vscode/src/vs/platform/agentHost/common/meta/agentCustomizationMeta.d.ts +27 -0
- package/vscode/src/vs/platform/agentHost/common/meta/agentCustomizationMeta.js +14 -0
- package/vscode/src/vs/platform/agentHost/common/meta/agentEphemeralSessionMeta.d.ts +14 -0
- package/vscode/src/vs/platform/agentHost/common/meta/agentEphemeralSessionMeta.js +11 -0
- package/vscode/src/vs/platform/agentHost/common/sandboxConfigSchema.js +13 -13
- package/vscode/src/vs/platform/agentHost/common/state/agentSubscription.js +1 -1
- package/vscode/src/vs/platform/agentHost/common/state/sessionActions.js +4 -1
- package/vscode/src/vs/platform/agentHost/common/toolSearchConstants.d.ts +4 -0
- package/vscode/src/vs/platform/agentHost/common/toolSearchConstants.js +6 -0
- package/vscode/src/vs/platform/networkFilter/common/networkFilterService.js +1 -1
- package/vscode/src/vs/workbench/browser/chatChangesPill.js +2 -2
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoice.contribution.js +28 -28
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceSessionsPicker.js +2 -2
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.js +18 -18
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidgetBinding.js +3 -3
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/confirmationComponent.js +3 -3
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/feedbackDialog.js +6 -6
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/headerComponent.js +11 -11
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/onboardingComponent.js +11 -11
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/sessionListComponent.js +9 -9
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/statusRowsComponent.js +5 -5
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/voiceBarComponent.js +2 -2
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscripts.contribution.js +13 -13
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscriptsView.js +7 -7
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.js +28 -28
- package/vscode/src/vs/workbench/contrib/agentsVoice/common/voiceTranscriptStore.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatResponseAccessibleView.js +18 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityActions.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +93 -93
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAgentRecommendationActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFindActions.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatLanguageModelActions.js +13 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatNewActions.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatOpenAgentDebugPanelAction.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatPluginActions.js +14 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatPromptNavigationActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQueueActions.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +18 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/createPluginAction.js +32 -32
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/exportAgentHostDebugLogsAction.js +9 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/openAgentHostStateFileAction.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginCommands.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginEditor/agentPluginEditor.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginEditor/agentPluginEditorInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginRepositoryService.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginsView.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationContentExpander.d.ts +34 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationContentExpander.js +229 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationItemProvider.d.ts +57 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationItemProvider.js +460 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHost.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHost.contribution.js +92 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostAllowSignedOutWhenUsableContribution.d.ts +23 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostAllowSignedOutWhenUsableContribution.js +46 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostAuth.d.ts +142 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostAuth.js +746 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.d.ts +77 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.js +474 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostConfigEditor.d.ts +169 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostConfigEditor.js +261 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCopilotCliSettingsContribution.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCopilotCliSettingsContribution.js +90 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostDownloadProgress.d.ts +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostDownloadProgress.js +73 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostExistingSessionHarnessPickerEnablement.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostExistingSessionHarnessPickerEnablement.js +61 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.d.ts +112 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.js +192 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostPermissionUiContribution.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostPromptCacheNotification.d.ts +21 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostPromptCacheNotification.js +137 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostResponseFileChanges.js +301 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostRootConfigForwarder.d.ts +84 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostRootConfigForwarder.js +96 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.d.ts +884 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.js +5868 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionInputPills.js +19 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListContribution.d.ts +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListContribution.js +129 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.d.ts +42 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListController.js +221 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListStore.d.ts +125 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListStore.js +345 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionWorkingDirectorySynchronizer.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSettings.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSettings.contribution.js +68 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSettingsFileSystemProvider.d.ts +62 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSettingsFileSystemProvider.js +163 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSignedOutModelsNotification.d.ts +54 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSignedOutModelsNotification.js +219 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSubagentProgress.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSubagentProgress.js +50 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostTerminalContribution.d.ts +42 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostTerminalContribution.js +132 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentSessionSettings.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentSessionSettings.contribution.js +85 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentSessionSettingsFileSystemProvider.d.ts +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentSessionSettingsFileSystemProvider.js +161 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/applyAgentHostSubmitConfig.d.ts +18 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/applyAgentHostSubmitConfig.js +13 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/copilotConfigSlashSubmitHandler.d.ts +28 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/copilotConfigSlashSubmitHandler.js +71 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/openSessionLinkOpener.contribution.d.ts +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/openSessionLinkOpener.contribution.js +205 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.js +50 -50
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjection.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionsExperiments.contribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentTitleBarStatusWidget.js +22 -22
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccess.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccessActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/externalSessionsFilterMenu.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/sessionSummaryHover.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessionsConfiguration.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationIcons.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidget.js +126 -126
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagement.contribution.js +44 -44
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.js +137 -137
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditorInput.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationPresentation.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWelcomePagePromptLaunchers.js +37 -37
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationCardList.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationCreatorService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigrationAccessibility.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigrationCategories.js +145 -145
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigrationDashboard.js +29 -29
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationMigrationServiceImpl.js +9 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/embeddedAgentPluginDetail.js +40 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/embeddedExtensionToolsDetail.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/embeddedMcpServerDetail.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/galleryItemRenderer.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/mcpListWidget.js +75 -75
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/pluginListWidget.js +115 -115
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/promptsServiceCustomizationItemProvider.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/toolsListWidget.js +50 -50
- package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentResolveService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.shared.contribution.js +344 -344
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/agentHostChatDebugProvider.js +37 -37
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/agentHostLogSources.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatCustomizationDiscoveryRenderer.js +32 -32
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugCacheExplorerView.js +124 -124
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugCacheInsights.js +72 -72
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugDetailPanel.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEditorInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEnablement.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEventDetailRenderer.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEventList.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugFilters.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugFlowChartView.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugFlowGraph.js +22 -22
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugHomeView.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugHookContentRenderer.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugLogsView.js +24 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugMessageContentRenderer.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugModelTurnContentRenderer.js +23 -23
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugOverviewView.js +35 -35
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugToolCallContentRenderer.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugWireLogView.js +40 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +14 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingExplanationModelManager.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingExplanationWidget.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatImageCarouselService.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPills.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagement.contribution.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditorInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.js +63 -63
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +30 -30
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPetAchievements.contribution.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPetAchievementsEditor.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPetAchievementsEditorInput.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPetAchievementsWidget.js +35 -35
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPromoNotification.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuotaNotification.js +25 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/chatRepoInfo.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.js +19 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupController.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupGrowthSession.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupProviders.js +26 -26
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupRunner.js +16 -16
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommands.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusDashboard.js +62 -62
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusEntry.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatTipCatalog.js +19 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/chatTipService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWindowNotifier.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/claudePluginRecommendations.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/contextContrib/chatContext.contribution.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/defaultModelContribution.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/enablementStatusWidget.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/planReviewFeedback/planReviewFeedbackEditorOverlay.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/pluginGitCommandService.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/pluginInstallService.js +27 -27
- package/vscode/src/vs/workbench/contrib/chat/browser/pluginSources.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/pluginUrlHandler.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/chatModeActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/hookActions.js +27 -27
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/hookUtils.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionOverlay.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolSetsCodeLensProvider.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptUrlHandler.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/runPromptAction.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveAsPromptFileActions.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/skillActions.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptTimeline/promptTimeline.contribution.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/promptTimeline/promptTimelineCard.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptTimeline/promptTimelineGutterRail.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptTimeline/promptTimelineModel.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptTimeline/promptTimelineRulerRail.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/promptTimeline/promptTimelineStickyHeader.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptsDebugContribution.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/sessionChatPillOptions.js +18 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/sessionPullRequestPill.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/clientToolSetsContribution.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsConfirmationService.js +39 -39
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.js +25 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/renameTool.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/usagesTool.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/utilityModelContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceInputMode/voiceInputMode.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentOpenChat.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatFind/chatFindAccessibilityHelp.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatQueuePickerActionItem.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/agentHostInputCompletions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputEditorContrib.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputEditorHover.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditor.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewTitleControl.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatSessionStore.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/common/plugins/agentPluginServiceImpl.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/chatPromptFilesContribution.js +18 -18
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptCodeActions.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderAutocompletion.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHovers.js +12 -12
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.js +154 -154
- package/vscode/src/vs/workbench/contrib/chat/common/sessionChatPills.js +9 -9
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
- package/vscode/src/vs/workbench/contrib/imageCarousel/browser/imageCarousel.contribution.js +10 -10
- package/vscode/src/vs/workbench/contrib/imageCarousel/browser/imageCarouselEditor.js +10 -10
- package/vscode/src/vs/workbench/contrib/imageCarousel/browser/imageCarouselEditorInput.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +15 -15
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDefaultModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatEditReviewSession.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpPromptArgumentPick.js +14 -14
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chat/notebookChatUtils.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +10 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +1 -1
- package/vscode/src/vs/workbench/contrib/remoteCodingAgents/browser/remoteCodingAgents.contribution.js +7 -7
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.js +10 -10
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibilityHelp.js +16 -16
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.js +20 -20
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.js +6 -6
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/npmScriptAutoApprover.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAutoApproveAnalyzer.js +12 -12
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineFileWriteAnalyzer.js +2 -2
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalLastCommandTool.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalSelectionTool.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/killTerminalTool.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalConfirmationTool.js +4 -4
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.js +73 -73
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sendToTerminalTool.js +10 -10
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/createAndRunTaskTool.js +14 -14
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/getTaskOutputTool.js +7 -7
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/runTaskTool.js +14 -14
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/taskHelpers.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.js +4 -4
- package/vscode/src/vs/workbench/services/agentEditorComments/browser/agentEditorCommentsOverlayWidget.js +3 -3
- package/vscode/src/vs/platform/agentHost/common/state/legacyProtocolCompatibility.d.ts +0 -30
- package/vscode/src/vs/platform/agentHost/common/state/legacyProtocolCompatibility.js +0 -87
- package/vscode/src/vs/workbench/services/accounts/browser/defaultAccount.d.ts +0 -205
- package/vscode/src/vs/workbench/services/accounts/browser/defaultAccount.js +0 -1580
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
|
|
2
|
+
import { fetchAuthorizationServerMetadata } from '@codingame/monaco-vscode-api/vscode/vs/base/common/oauth';
|
|
3
|
+
import { SequencerByKey } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
4
|
+
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
5
|
+
import { match } from '@codingame/monaco-vscode-api/vscode/vs/base/common/glob';
|
|
6
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
7
|
+
import { readAgentModelByokIdentifier } from '../../../../../../platform/agentHost/common/agentModelByokMeta.js';
|
|
8
|
+
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
9
|
+
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
10
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
11
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
12
|
+
import { IAuthenticationMcpAccessService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationMcpAccessService.service';
|
|
13
|
+
import { IAuthenticationMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationMcpService.service';
|
|
14
|
+
import { IAuthenticationMcpUsageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationMcpUsageService.service';
|
|
15
|
+
import { getDynamicAuthenticationProviderId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication';
|
|
16
|
+
import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
17
|
+
import { IDynamicAuthenticationProviderStorageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/dynamicAuthenticationProviderStorage.service';
|
|
18
|
+
import { CHAT_SETUP_ACTION_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
19
|
+
|
|
20
|
+
function agentHostMcpServerId(authority, serverName, resourceUrl) {
|
|
21
|
+
return `agent-host-mcp:${authority}/${encodeURIComponent(serverName)}/${encodeURIComponent(resourceUrl)}`;
|
|
22
|
+
}
|
|
23
|
+
function modelRequiresAgentAuthentication(agent, model, allowSignedOutWhenUsable = false) {
|
|
24
|
+
if (!agent?.protectedResources?.length) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const requiresAuthentication = ( agent.protectedResources.some(resource => resource.required !== false));
|
|
28
|
+
if (!allowSignedOutWhenUsable || !( agent.models.some(candidate => readAgentModelByokIdentifier(candidate) !== undefined))) {
|
|
29
|
+
return requiresAuthentication;
|
|
30
|
+
}
|
|
31
|
+
if (!model) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
const selectedModel = agent.models.find(candidate => candidate.id === model.id);
|
|
35
|
+
return !selectedModel || readAgentModelByokIdentifier(selectedModel) === undefined;
|
|
36
|
+
}
|
|
37
|
+
class AgentHostAuthTokenCache {
|
|
38
|
+
constructor() {
|
|
39
|
+
this._completedTokens = ( new Map());
|
|
40
|
+
this._pendingAuthentications = ( new Map());
|
|
41
|
+
this._keyGenerations = ( new Map());
|
|
42
|
+
this._globalGeneration = 0;
|
|
43
|
+
}
|
|
44
|
+
async authenticate(resource, scopes, token, authenticate) {
|
|
45
|
+
const key = this._key(resource, scopes);
|
|
46
|
+
const globalGeneration = this._globalGeneration;
|
|
47
|
+
const keyGeneration = this._keyGenerations.get(key) ?? 0;
|
|
48
|
+
const pending = this._pendingAuthentications.get(key);
|
|
49
|
+
if (pending) {
|
|
50
|
+
if (pending.token === token) {
|
|
51
|
+
await pending.promise;
|
|
52
|
+
if (!this._isCurrentGeneration(key, globalGeneration, keyGeneration)) {
|
|
53
|
+
throw ( new CancellationError());
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
await pending.promise;
|
|
59
|
+
} catch {}
|
|
60
|
+
if (!this._isCurrentGeneration(key, globalGeneration, keyGeneration)) {
|
|
61
|
+
throw ( new CancellationError());
|
|
62
|
+
}
|
|
63
|
+
return this.authenticate(resource, scopes, token, authenticate);
|
|
64
|
+
}
|
|
65
|
+
if (this._completedTokens.get(key) === token) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const promise = (async () => {
|
|
69
|
+
await authenticate();
|
|
70
|
+
if (!this._isCurrentGeneration(key, globalGeneration, keyGeneration)) {
|
|
71
|
+
throw ( new CancellationError());
|
|
72
|
+
}
|
|
73
|
+
this._completedTokens.set(key, token);
|
|
74
|
+
})();
|
|
75
|
+
this._pendingAuthentications.set(key, {
|
|
76
|
+
token,
|
|
77
|
+
promise
|
|
78
|
+
});
|
|
79
|
+
try {
|
|
80
|
+
await promise;
|
|
81
|
+
return true;
|
|
82
|
+
} finally {
|
|
83
|
+
if (this._pendingAuthentications.get(key)?.promise === promise) {
|
|
84
|
+
this._pendingAuthentications.delete(key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
clear(resource, scopes) {
|
|
89
|
+
if (resource !== undefined) {
|
|
90
|
+
if (scopes !== undefined) {
|
|
91
|
+
const key = this._key(resource, scopes);
|
|
92
|
+
this._invalidateKey(key);
|
|
93
|
+
this._completedTokens.delete(key);
|
|
94
|
+
this._pendingAuthentications.delete(key);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const prefix = `${resource}\x00`;
|
|
98
|
+
const keys = ( new Set([...( this._completedTokens.keys()), ...( this._pendingAuthentications.keys()), ...( this._keyGenerations.keys())]));
|
|
99
|
+
for (const key of keys) {
|
|
100
|
+
if (key.startsWith(prefix)) {
|
|
101
|
+
this._invalidateKey(key);
|
|
102
|
+
this._completedTokens.delete(key);
|
|
103
|
+
this._pendingAuthentications.delete(key);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
this._globalGeneration++;
|
|
108
|
+
this._completedTokens.clear();
|
|
109
|
+
this._pendingAuthentications.clear();
|
|
110
|
+
this._keyGenerations.clear();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_invalidateKey(key) {
|
|
114
|
+
this._keyGenerations.set(key, (this._keyGenerations.get(key) ?? 0) + 1);
|
|
115
|
+
}
|
|
116
|
+
_isCurrentGeneration(key, globalGeneration, keyGeneration) {
|
|
117
|
+
return this._globalGeneration === globalGeneration && (this._keyGenerations.get(key) ?? 0) === keyGeneration;
|
|
118
|
+
}
|
|
119
|
+
_key(resource, scopes) {
|
|
120
|
+
return `${resource}\x00${scopes ? [...( new Set(scopes))].sort().join("\u0000") : ""}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function protectedResourceAuthenticationKey(resource) {
|
|
124
|
+
return JSON.stringify([resource.resource, [...( new Set(resource.scopes_supported ?? []))].sort(), resource.authorization_servers ?? []]);
|
|
125
|
+
}
|
|
126
|
+
class AgentHostAuthenticationRecovery {
|
|
127
|
+
constructor() {
|
|
128
|
+
this._resentTokens = ( new Map());
|
|
129
|
+
this._pendingRecoveries = ( new Map());
|
|
130
|
+
}
|
|
131
|
+
clear() {
|
|
132
|
+
this._resentTokens.clear();
|
|
133
|
+
this._pendingRecoveries.clear();
|
|
134
|
+
}
|
|
135
|
+
recover(accessor, resource, options) {
|
|
136
|
+
const key = protectedResourceAuthenticationKey(resource);
|
|
137
|
+
const pendingRecovery = this._pendingRecoveries.get(key);
|
|
138
|
+
if (pendingRecovery) {
|
|
139
|
+
return pendingRecovery;
|
|
140
|
+
}
|
|
141
|
+
const recovery = this._recover(accessor, key, resource, options).finally(() => {
|
|
142
|
+
if (this._pendingRecoveries.get(key) === recovery) {
|
|
143
|
+
this._pendingRecoveries.delete(key);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
this._pendingRecoveries.set(key, recovery);
|
|
147
|
+
return recovery;
|
|
148
|
+
}
|
|
149
|
+
async _recover(accessor, key, resource, options) {
|
|
150
|
+
throwIfAuthenticationStale(options);
|
|
151
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
152
|
+
const commandService = accessor.get(ICommandService);
|
|
153
|
+
const logService = accessor.get(ILogService);
|
|
154
|
+
const scopes = resource.scopes_supported ?? [];
|
|
155
|
+
const resolution = await resolveAuthenticationSessionForResource(( URI.parse(resource.resource)), resource.authorization_servers ?? [], scopes, authenticationService, logService, options.logPrefix);
|
|
156
|
+
throwIfAuthenticationStale(options);
|
|
157
|
+
if (resolution.kind !== "resolved") {
|
|
158
|
+
logAuthenticationSessionResolution(logService, options.logPrefix, resource.resource, resolution);
|
|
159
|
+
if (resolution.kind === "signedOut") {
|
|
160
|
+
this._resentTokens.delete(key);
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const session = resolution.session;
|
|
165
|
+
const previousToken = this._resentTokens.get(key);
|
|
166
|
+
if (previousToken !== undefined && previousToken === session.accessToken) {
|
|
167
|
+
options.authTokenCache?.clear(resource.resource, resource.scopes_supported);
|
|
168
|
+
throwIfAuthenticationStale(options);
|
|
169
|
+
const interactiveSession = await forceAuthenticationInteractively(authenticationService, commandService, logService, resource, options);
|
|
170
|
+
throwIfAuthenticationStale(options);
|
|
171
|
+
if (interactiveSession) {
|
|
172
|
+
this._resentTokens.set(key, interactiveSession.accessToken);
|
|
173
|
+
if (interactiveSession.accessToken === session.accessToken) {
|
|
174
|
+
logService.info(
|
|
175
|
+
`${options.logPrefix} Interactive authentication completed without a new token for ${resource.resource}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
options.authTokenCache?.clear(resource.resource, resource.scopes_supported);
|
|
182
|
+
if (await forwardAuthenticationToken(options, resource.resource, resource.scopes_supported ?? [], session)) {
|
|
183
|
+
this._resentTokens.set(key, session.accessToken);
|
|
184
|
+
logService.info(`${options.logPrefix} Authenticating for resource: ${resource.resource}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async function resolveSessionForResource(
|
|
189
|
+
resourceServer,
|
|
190
|
+
authorizationServers,
|
|
191
|
+
scopes,
|
|
192
|
+
authenticationService,
|
|
193
|
+
logService,
|
|
194
|
+
logPrefix
|
|
195
|
+
) {
|
|
196
|
+
const resolution = await resolveAuthenticationSessionForResource(
|
|
197
|
+
resourceServer,
|
|
198
|
+
authorizationServers,
|
|
199
|
+
scopes,
|
|
200
|
+
authenticationService,
|
|
201
|
+
logService,
|
|
202
|
+
logPrefix
|
|
203
|
+
);
|
|
204
|
+
return resolution.kind === "resolved" ? resolution.session : undefined;
|
|
205
|
+
}
|
|
206
|
+
async function resolveAuthenticationSessionForResource(
|
|
207
|
+
resourceServer,
|
|
208
|
+
authorizationServers,
|
|
209
|
+
scopes,
|
|
210
|
+
authenticationService,
|
|
211
|
+
logService,
|
|
212
|
+
logPrefix
|
|
213
|
+
) {
|
|
214
|
+
let hasUnavailableProvider = false;
|
|
215
|
+
for (const server of authorizationServers) {
|
|
216
|
+
const serverUri = ( URI.parse(server));
|
|
217
|
+
let providerId;
|
|
218
|
+
try {
|
|
219
|
+
providerId = await authenticationService.getOrActivateProviderIdForServer(serverUri, resourceServer);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
hasUnavailableProvider = true;
|
|
222
|
+
logService.trace(
|
|
223
|
+
`${logPrefix} Authentication provider is not ready for server: ${server}`,
|
|
224
|
+
error
|
|
225
|
+
);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (!providerId) {
|
|
229
|
+
const declaredProvider = authenticationService.declaredProviders.find(
|
|
230
|
+
provider => !authenticationService.isAuthenticationProviderRegistered(provider.id) && provider.authorizationServerGlobs?.some(glob => match(glob, ( serverUri.toString(true)), {
|
|
231
|
+
ignoreCase: true
|
|
232
|
+
}))
|
|
233
|
+
);
|
|
234
|
+
if (declaredProvider) {
|
|
235
|
+
hasUnavailableProvider = true;
|
|
236
|
+
logService.trace(
|
|
237
|
+
`${logPrefix} Authentication provider '${declaredProvider.id}' is not ready for server: ${server}`
|
|
238
|
+
);
|
|
239
|
+
} else {
|
|
240
|
+
logService.trace(`${logPrefix} No authentication provider resolved for server: ${server}`);
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
logService.trace(
|
|
245
|
+
`${logPrefix} Resolved auth provider '${providerId}' for server: ${server}`
|
|
246
|
+
);
|
|
247
|
+
let sessions;
|
|
248
|
+
try {
|
|
249
|
+
sessions = await authenticationService.getSessions(providerId, [...scopes], {
|
|
250
|
+
authorizationServer: serverUri
|
|
251
|
+
}, true);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
hasUnavailableProvider = true;
|
|
254
|
+
logService.trace(
|
|
255
|
+
`${logPrefix} Authentication provider '${providerId}' is not ready to resolve sessions for server: ${server}`,
|
|
256
|
+
error
|
|
257
|
+
);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const exactSession = sessions[0];
|
|
261
|
+
if (exactSession) {
|
|
262
|
+
return {
|
|
263
|
+
kind: "resolved",
|
|
264
|
+
session: exactSession
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
let allSessions;
|
|
268
|
+
try {
|
|
269
|
+
allSessions = await authenticationService.getSessions(providerId, undefined, {
|
|
270
|
+
authorizationServer: serverUri
|
|
271
|
+
}, true);
|
|
272
|
+
} catch (error) {
|
|
273
|
+
hasUnavailableProvider = true;
|
|
274
|
+
logService.trace(
|
|
275
|
+
`${logPrefix} Authentication provider '${providerId}' is not ready to resolve sessions for server: ${server}`,
|
|
276
|
+
error
|
|
277
|
+
);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const requestedSet = ( new Set(scopes));
|
|
281
|
+
let bestSession;
|
|
282
|
+
let bestExtraScopes = Infinity;
|
|
283
|
+
for (const session of allSessions) {
|
|
284
|
+
const sessionScopes = ( new Set(session.scopes));
|
|
285
|
+
let isSuperset = true;
|
|
286
|
+
for (const scope of requestedSet) {
|
|
287
|
+
if (!( sessionScopes.has(scope))) {
|
|
288
|
+
isSuperset = false;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (isSuperset) {
|
|
293
|
+
const extraScopes = sessionScopes.size - requestedSet.size;
|
|
294
|
+
if (extraScopes < bestExtraScopes) {
|
|
295
|
+
bestExtraScopes = extraScopes;
|
|
296
|
+
bestSession = session;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (bestSession) {
|
|
301
|
+
return {
|
|
302
|
+
kind: "resolved",
|
|
303
|
+
session: bestSession
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return hasUnavailableProvider ? {
|
|
308
|
+
kind: "unavailable"
|
|
309
|
+
} : {
|
|
310
|
+
kind: "signedOut"
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async function forwardAuthenticationToken(options, resource, scopes, session) {
|
|
314
|
+
throwIfAuthenticationStale(options);
|
|
315
|
+
const token = session?.accessToken ?? "";
|
|
316
|
+
const expiresAfter = session?.expiresAfter;
|
|
317
|
+
const request = {
|
|
318
|
+
resource,
|
|
319
|
+
scopes,
|
|
320
|
+
token,
|
|
321
|
+
...(expiresAfter !== undefined && Number.isInteger(expiresAfter) && expiresAfter > 0 ? {
|
|
322
|
+
expiresIn: Math.ceil(expiresAfter / 1000)
|
|
323
|
+
} : {})
|
|
324
|
+
};
|
|
325
|
+
if (options.authTokenCache) {
|
|
326
|
+
return options.authTokenCache.authenticate(resource, scopes ?? [], token, () => options.authenticate(request));
|
|
327
|
+
}
|
|
328
|
+
await options.authenticate(request);
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
function throwIfAuthenticationStale(options) {
|
|
332
|
+
if (options.isCurrent?.() === false) {
|
|
333
|
+
throw ( new CancellationError());
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async function authenticateProtectedResources(accessor, agents, options) {
|
|
337
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
338
|
+
const logService = accessor.get(ILogService);
|
|
339
|
+
for (const agent of agents) {
|
|
340
|
+
for (const resource of agent.protectedResources ?? []) {
|
|
341
|
+
await authenticateProtectedResourceWithServices(authenticationService, logService, resource, options);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
async function authenticateAgentProtectedResourcesWithToken(agents, token, options) {
|
|
346
|
+
for (const agent of agents) {
|
|
347
|
+
await authenticateProtectedResourcesWithToken(agent.protectedResources ?? [], token, options);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
async function authenticateProtectedResourcesWithToken(protectedResources, token, options) {
|
|
351
|
+
for (const resource of protectedResources) {
|
|
352
|
+
await forwardAuthenticationToken(options, resource.resource, resource.scopes_supported, {
|
|
353
|
+
accessToken: token
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
async function revokeAuthenticationForRemovedSessions(accessor, agents, providerId, removedSessions, options) {
|
|
358
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
359
|
+
const logService = accessor.get(ILogService);
|
|
360
|
+
const reconciledResources = ( new Set());
|
|
361
|
+
for (const agent of agents) {
|
|
362
|
+
for (const resource of agent.protectedResources ?? []) {
|
|
363
|
+
const scopes = resource.scopes_supported ?? [];
|
|
364
|
+
const key = protectedResourceAuthenticationKey(resource);
|
|
365
|
+
if (( reconciledResources.has(key))) {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (!removedSessionsCouldSatisfyResource(removedSessions, scopes)) {
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (!(await resourceMatchesAuthenticationProvider(authenticationService, resource, providerId, logService, options.logPrefix))) {
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
reconciledResources.add(key);
|
|
375
|
+
const resolution = await resolveSessionForProtectedResource(authenticationService, logService, resource, options);
|
|
376
|
+
throwIfAuthenticationStale(options);
|
|
377
|
+
if (resolution.kind === "unavailable") {
|
|
378
|
+
logAuthenticationSessionResolution(logService, options.logPrefix, resource.resource, resolution);
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (resolution.kind === "resolved") {
|
|
382
|
+
if (await forwardAuthenticationToken(options, resource.resource, scopes, resolution.session)) {
|
|
383
|
+
logService.info(
|
|
384
|
+
`${options.logPrefix} Authenticating for resource after session removal: ${resource.resource}`
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
options.authTokenCache?.clear(resource.resource, scopes);
|
|
390
|
+
if (await forwardAuthenticationToken(options, resource.resource, scopes, undefined)) {
|
|
391
|
+
logService.info(
|
|
392
|
+
`${options.logPrefix} Clearing authentication for resource after session removal: ${resource.resource}`
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function removedSessionsCouldSatisfyResource(removedSessions, scopes) {
|
|
399
|
+
return ( removedSessions.some(session => {
|
|
400
|
+
const granted = ( new Set(session.scopes));
|
|
401
|
+
return scopes.every(scope => ( granted.has(scope)));
|
|
402
|
+
}));
|
|
403
|
+
}
|
|
404
|
+
async function resourceMatchesAuthenticationProvider(authenticationService, resource, providerId, logService, logPrefix) {
|
|
405
|
+
for (const authorizationServer of resource.authorization_servers ?? []) {
|
|
406
|
+
try {
|
|
407
|
+
if ((await authenticationService.getOrActivateProviderIdForServer(( URI.parse(authorizationServer)), ( URI.parse(resource.resource)))) === providerId) {
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
} catch (error) {
|
|
411
|
+
logService.trace(
|
|
412
|
+
`${logPrefix} Unable to resolve authentication provider for session removal: ${authorizationServer}`,
|
|
413
|
+
error
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
async function authenticateProtectedResourceWithServices(authenticationService, logService, resource, options) {
|
|
420
|
+
throwIfAuthenticationStale(options);
|
|
421
|
+
const resolution = await resolveSessionForProtectedResource(authenticationService, logService, resource, options);
|
|
422
|
+
throwIfAuthenticationStale(options);
|
|
423
|
+
if (resolution.kind !== "resolved") {
|
|
424
|
+
logAuthenticationSessionResolution(logService, options.logPrefix, resource.resource, resolution);
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
const authenticated = await forwardAuthenticationToken(
|
|
428
|
+
options,
|
|
429
|
+
resource.resource,
|
|
430
|
+
resource.scopes_supported ?? [],
|
|
431
|
+
resolution.session
|
|
432
|
+
);
|
|
433
|
+
if (!authenticated) {
|
|
434
|
+
logService.trace(
|
|
435
|
+
`${options.logPrefix} Authentication state for ${resource.resource} unchanged; skipping authenticate RPC`
|
|
436
|
+
);
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
logService.info(`${options.logPrefix} Authenticating for resource: ${resource.resource}`);
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
async function resolveSessionForProtectedResource(authenticationService, logService, resource, options) {
|
|
443
|
+
return resolveAuthenticationSessionForResource(( URI.parse(resource.resource)), resource.authorization_servers ?? [], resource.scopes_supported ?? [], authenticationService, logService, options.logPrefix);
|
|
444
|
+
}
|
|
445
|
+
function logAuthenticationSessionResolution(logService, logPrefix, resource, resolution) {
|
|
446
|
+
if (resolution.kind === "unavailable") {
|
|
447
|
+
logService.info(
|
|
448
|
+
`${logPrefix} Authentication provider is not ready for resource: ${resource}; deferring authentication`
|
|
449
|
+
);
|
|
450
|
+
} else {
|
|
451
|
+
logService.info(`${logPrefix} No signed-in session resolved for resource: ${resource}`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
async function resolveAuthenticationInteractively(accessor, protectedResources, options) {
|
|
455
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
456
|
+
const commandService = accessor.get(ICommandService);
|
|
457
|
+
const logService = accessor.get(ILogService);
|
|
458
|
+
for (const resource of protectedResources) {
|
|
459
|
+
throwIfAuthenticationStale(options);
|
|
460
|
+
const resourceUri = ( URI.parse(resource.resource));
|
|
461
|
+
const scopes = resource.scopes_supported ?? [];
|
|
462
|
+
const existingSession = await resolveSessionForResource(
|
|
463
|
+
resourceUri,
|
|
464
|
+
resource.authorization_servers ?? [],
|
|
465
|
+
scopes,
|
|
466
|
+
authenticationService,
|
|
467
|
+
logService,
|
|
468
|
+
options.logPrefix
|
|
469
|
+
);
|
|
470
|
+
throwIfAuthenticationStale(options);
|
|
471
|
+
if (existingSession) {
|
|
472
|
+
await forwardAuthenticationToken(options, resource.resource, scopes, existingSession);
|
|
473
|
+
logService.info(
|
|
474
|
+
`${options.logPrefix} Interactive authentication succeeded for ${resource.resource}`
|
|
475
|
+
);
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
return (await forceAuthenticationInteractively(authenticationService, commandService, logService, resource, options)) !== undefined;
|
|
479
|
+
}
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
async function forceAuthenticationInteractively(authenticationService, commandService, logService, resource, options) {
|
|
483
|
+
throwIfAuthenticationStale(options);
|
|
484
|
+
const scopes = resource.scopes_supported ?? [];
|
|
485
|
+
const setupResult = await commandService.executeCommand(CHAT_SETUP_ACTION_ID, undefined, {
|
|
486
|
+
forceSignInDialog: true,
|
|
487
|
+
additionalScopes: scopes,
|
|
488
|
+
dialogTitle: ( localize(5986, "Sign in to use GitHub Copilot")),
|
|
489
|
+
disableChatViewReveal: true,
|
|
490
|
+
returnResult: true
|
|
491
|
+
});
|
|
492
|
+
throwIfAuthenticationStale(options);
|
|
493
|
+
if (setupResult?.success === undefined) {
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
if (!setupResult.success) {
|
|
497
|
+
throw setupResult.error ?? ( new Error(( localize(5987, "Failed to sign in to use GitHub Copilot."))));
|
|
498
|
+
}
|
|
499
|
+
const session = await resolveSessionForResource(( URI.parse(resource.resource)), resource.authorization_servers ?? [], scopes, authenticationService, logService, options.logPrefix);
|
|
500
|
+
throwIfAuthenticationStale(options);
|
|
501
|
+
if (!session) {
|
|
502
|
+
logService.info(
|
|
503
|
+
`${options.logPrefix} Interactive authentication did not provide a token for ${resource.resource}`
|
|
504
|
+
);
|
|
505
|
+
return undefined;
|
|
506
|
+
}
|
|
507
|
+
options.authTokenCache?.clear(resource.resource, scopes);
|
|
508
|
+
if (!(await forwardAuthenticationToken(options, resource.resource, scopes, session))) {
|
|
509
|
+
return undefined;
|
|
510
|
+
}
|
|
511
|
+
logService.info(
|
|
512
|
+
`${options.logPrefix} Interactive authentication completed for ${resource.resource}`
|
|
513
|
+
);
|
|
514
|
+
return session;
|
|
515
|
+
}
|
|
516
|
+
async function resolveMcpServerAuthentication(accessor, protectedResource, options) {
|
|
517
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
518
|
+
const authenticationMcpAccessService = accessor.get(IAuthenticationMcpAccessService);
|
|
519
|
+
const authenticationMcpService = accessor.get(IAuthenticationMcpService);
|
|
520
|
+
const authenticationMcpUsageService = accessor.get(IAuthenticationMcpUsageService);
|
|
521
|
+
const dynamicAuthenticationProviderStorageService = accessor.get(IDynamicAuthenticationProviderStorageService);
|
|
522
|
+
const logService = accessor.get(ILogService);
|
|
523
|
+
const agentHostMeta = options.agentHost ? {
|
|
524
|
+
authority: options.agentHost.authority,
|
|
525
|
+
label: accessor.get(ILabelService).getHostLabel(options.agentHost.scheme, options.agentHost.authority)
|
|
526
|
+
} : undefined;
|
|
527
|
+
const scopes = options.scopes.length > 0 || isGitHubMcpResource(protectedResource) ? options.scopes : protectedResource.scopes_supported ?? [];
|
|
528
|
+
const authenticationOperations = getMcpAuthenticationOperations(authenticationService);
|
|
529
|
+
for (const authorizationServer of protectedResource.authorization_servers ?? []) {
|
|
530
|
+
const authorizationServerUri = ( URI.parse(authorizationServer));
|
|
531
|
+
const providerOperationId = getDynamicAuthenticationProviderId(authorizationServerUri, protectedResource);
|
|
532
|
+
const authenticated = await authenticationOperations.queue(providerOperationId, async () => {
|
|
533
|
+
const providerId = await getOrCreateProviderForMcpResource(
|
|
534
|
+
authorizationServerUri,
|
|
535
|
+
protectedResource,
|
|
536
|
+
options.oauthClient,
|
|
537
|
+
authenticationService,
|
|
538
|
+
dynamicAuthenticationProviderStorageService,
|
|
539
|
+
logService,
|
|
540
|
+
options.logPrefix,
|
|
541
|
+
options.allowInteraction,
|
|
542
|
+
options.authorizationServerMetadataFetcher ?? fetchAuthorizationServerMetadata
|
|
543
|
+
);
|
|
544
|
+
if (!providerId) {
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
const oauthClientOptions = options.oauthClient ? {
|
|
548
|
+
clientId: options.oauthClient.clientId,
|
|
549
|
+
clientSecret: options.oauthClient.clientSecret
|
|
550
|
+
} : {};
|
|
551
|
+
const sessions = await authenticationService.getSessions(providerId, [...scopes], {
|
|
552
|
+
authorizationServer: authorizationServerUri,
|
|
553
|
+
resource: protectedResource.resource,
|
|
554
|
+
...oauthClientOptions,
|
|
555
|
+
silent: !options.allowInteraction
|
|
556
|
+
}, true);
|
|
557
|
+
const allowedSession = getAllowedMcpSession(
|
|
558
|
+
providerId,
|
|
559
|
+
sessions,
|
|
560
|
+
authenticationMcpAccessService,
|
|
561
|
+
authenticationMcpService,
|
|
562
|
+
options
|
|
563
|
+
);
|
|
564
|
+
if (allowedSession) {
|
|
565
|
+
await authenticateMcpSession(
|
|
566
|
+
providerId,
|
|
567
|
+
allowedSession,
|
|
568
|
+
scopes,
|
|
569
|
+
authenticationMcpAccessService,
|
|
570
|
+
authenticationMcpService,
|
|
571
|
+
authenticationMcpUsageService,
|
|
572
|
+
logService,
|
|
573
|
+
options,
|
|
574
|
+
false,
|
|
575
|
+
agentHostMeta
|
|
576
|
+
);
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
if (!options.allowInteraction) {
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
const provider = authenticationService.getProvider(providerId);
|
|
583
|
+
const session = sessions.length ? provider.supportsMultipleAccounts ? await authenticationMcpService.selectSession(
|
|
584
|
+
providerId,
|
|
585
|
+
options.mcpServerId,
|
|
586
|
+
options.mcpServerName,
|
|
587
|
+
[...scopes],
|
|
588
|
+
sessions
|
|
589
|
+
) : sessions[0] : await authenticationService.createSession(providerId, [...scopes], {
|
|
590
|
+
activateImmediate: true,
|
|
591
|
+
authorizationServer: authorizationServerUri,
|
|
592
|
+
resource: protectedResource.resource,
|
|
593
|
+
...oauthClientOptions
|
|
594
|
+
});
|
|
595
|
+
await authenticateMcpSession(
|
|
596
|
+
providerId,
|
|
597
|
+
session,
|
|
598
|
+
scopes,
|
|
599
|
+
authenticationMcpAccessService,
|
|
600
|
+
authenticationMcpService,
|
|
601
|
+
authenticationMcpUsageService,
|
|
602
|
+
logService,
|
|
603
|
+
options,
|
|
604
|
+
true,
|
|
605
|
+
agentHostMeta
|
|
606
|
+
);
|
|
607
|
+
return true;
|
|
608
|
+
});
|
|
609
|
+
if (authenticated) {
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
const mcpAuthenticationOperations = ( new WeakMap());
|
|
616
|
+
function getMcpAuthenticationOperations(authenticationService) {
|
|
617
|
+
let operations = mcpAuthenticationOperations.get(authenticationService);
|
|
618
|
+
if (!operations) {
|
|
619
|
+
operations = ( new SequencerByKey());
|
|
620
|
+
mcpAuthenticationOperations.set(authenticationService, operations);
|
|
621
|
+
}
|
|
622
|
+
return operations;
|
|
623
|
+
}
|
|
624
|
+
function isGitHubMcpResource(resource) {
|
|
625
|
+
return resource.resource_name === "GitHub MCP Server";
|
|
626
|
+
}
|
|
627
|
+
async function getOrCreateProviderForMcpResource(
|
|
628
|
+
authorizationServer,
|
|
629
|
+
protectedResource,
|
|
630
|
+
oauthClient,
|
|
631
|
+
authenticationService,
|
|
632
|
+
dynamicAuthenticationProviderStorageService,
|
|
633
|
+
logService,
|
|
634
|
+
logPrefix,
|
|
635
|
+
allowCreation,
|
|
636
|
+
authorizationServerMetadataFetcher
|
|
637
|
+
) {
|
|
638
|
+
const resourceUri = ( URI.parse(protectedResource.resource));
|
|
639
|
+
const dynamicProviderId = getDynamicAuthenticationProviderId(authorizationServer, protectedResource);
|
|
640
|
+
let clientId = oauthClient?.clientId;
|
|
641
|
+
let clientSecret = oauthClient?.clientSecret;
|
|
642
|
+
if (oauthClient) {
|
|
643
|
+
const isProviderActive = authenticationService.isDynamicAuthenticationProvider(dynamicProviderId);
|
|
644
|
+
const registeredClient = await dynamicAuthenticationProviderStorageService.getClientRegistration(dynamicProviderId);
|
|
645
|
+
const clientMatches = registeredClient?.clientId === oauthClient.clientId && registeredClient.clientSecret === oauthClient.clientSecret;
|
|
646
|
+
if (clientMatches) {
|
|
647
|
+
if (isProviderActive) {
|
|
648
|
+
return dynamicProviderId;
|
|
649
|
+
}
|
|
650
|
+
} else {
|
|
651
|
+
if (!allowCreation) {
|
|
652
|
+
return undefined;
|
|
653
|
+
}
|
|
654
|
+
if (isProviderActive) {
|
|
655
|
+
authenticationService.unregisterAuthenticationProvider(dynamicProviderId);
|
|
656
|
+
await dynamicAuthenticationProviderStorageService.removeDynamicProvider(dynamicProviderId);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
} else {
|
|
660
|
+
const existing = await authenticationService.getOrActivateProviderIdForServer(authorizationServer, resourceUri);
|
|
661
|
+
if (existing) {
|
|
662
|
+
return existing;
|
|
663
|
+
}
|
|
664
|
+
const registeredClient = await dynamicAuthenticationProviderStorageService.getClientRegistration(dynamicProviderId);
|
|
665
|
+
if (!registeredClient?.clientId && !allowCreation) {
|
|
666
|
+
return undefined;
|
|
667
|
+
}
|
|
668
|
+
clientId = registeredClient?.clientId;
|
|
669
|
+
clientSecret = registeredClient?.clientSecret;
|
|
670
|
+
}
|
|
671
|
+
try {
|
|
672
|
+
const {
|
|
673
|
+
metadata
|
|
674
|
+
} = await authorizationServerMetadataFetcher(( authorizationServer.toString(true)));
|
|
675
|
+
const provider = await authenticationService.createDynamicAuthenticationProvider(authorizationServer, metadata, protectedResource, clientId, clientSecret);
|
|
676
|
+
return provider?.id;
|
|
677
|
+
} catch (err) {
|
|
678
|
+
logService.warn(`${logPrefix} Failed to create MCP auth provider for ${( authorizationServer.toString(true))}`, err);
|
|
679
|
+
return undefined;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
function getAllowedMcpSession(
|
|
683
|
+
providerId,
|
|
684
|
+
sessions,
|
|
685
|
+
authenticationMcpAccessService,
|
|
686
|
+
authenticationMcpService,
|
|
687
|
+
options
|
|
688
|
+
) {
|
|
689
|
+
const accountNamePreference = authenticationMcpService.getAccountPreference(options.mcpServerId, providerId);
|
|
690
|
+
if (accountNamePreference) {
|
|
691
|
+
const preferred = sessions.find(session => session.account.label === accountNamePreference);
|
|
692
|
+
if (preferred && authenticationMcpAccessService.isAccessAllowedForUrl(
|
|
693
|
+
providerId,
|
|
694
|
+
preferred.account.label,
|
|
695
|
+
options.mcpServerId,
|
|
696
|
+
options.mcpServerUrl
|
|
697
|
+
)) {
|
|
698
|
+
return preferred;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
if (sessions.length === 1 && authenticationMcpAccessService.isAccessAllowedForUrl(
|
|
702
|
+
providerId,
|
|
703
|
+
sessions[0].account.label,
|
|
704
|
+
options.mcpServerId,
|
|
705
|
+
options.mcpServerUrl
|
|
706
|
+
)) {
|
|
707
|
+
return sessions[0];
|
|
708
|
+
}
|
|
709
|
+
return undefined;
|
|
710
|
+
}
|
|
711
|
+
async function authenticateMcpSession(
|
|
712
|
+
providerId,
|
|
713
|
+
session,
|
|
714
|
+
scopes,
|
|
715
|
+
authenticationMcpAccessService,
|
|
716
|
+
authenticationMcpService,
|
|
717
|
+
authenticationMcpUsageService,
|
|
718
|
+
logService,
|
|
719
|
+
options,
|
|
720
|
+
updateAccess,
|
|
721
|
+
agentHost
|
|
722
|
+
) {
|
|
723
|
+
await forwardAuthenticationToken(options, options.mcpServerUrl, scopes, session);
|
|
724
|
+
if (updateAccess) {
|
|
725
|
+
authenticationMcpAccessService.updateAllowedMcpServers(providerId, session.account.label, [{
|
|
726
|
+
id: options.mcpServerId,
|
|
727
|
+
name: options.mcpServerName,
|
|
728
|
+
allowed: true,
|
|
729
|
+
url: options.mcpServerUrl,
|
|
730
|
+
agentHost
|
|
731
|
+
}]);
|
|
732
|
+
authenticationMcpService.updateAccountPreference(options.mcpServerId, providerId, session.account);
|
|
733
|
+
}
|
|
734
|
+
authenticationMcpUsageService.addAccountUsage(
|
|
735
|
+
providerId,
|
|
736
|
+
session.account.label,
|
|
737
|
+
scopes,
|
|
738
|
+
options.mcpServerId,
|
|
739
|
+
options.mcpServerName
|
|
740
|
+
);
|
|
741
|
+
logService.info(
|
|
742
|
+
`${options.logPrefix} MCP authentication succeeded for ${options.mcpServerName}`
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
export { AgentHostAuthTokenCache, AgentHostAuthenticationRecovery, agentHostMcpServerId, authenticateAgentProtectedResourcesWithToken, authenticateProtectedResources, authenticateProtectedResourcesWithToken, modelRequiresAgentAuthentication, resolveAuthenticationInteractively, resolveMcpServerAuthentication, resolveSessionForResource, revokeAuthenticationForRemovedSessions };
|