@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
|
@@ -1,1580 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { distinct } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
4
|
-
import { ThrottledDelayer, RunOnceScheduler, timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
5
|
-
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
6
|
-
import { getErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
7
|
-
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
8
|
-
import { Disposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
9
|
-
import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
10
|
-
import { isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
11
|
-
import { isUndefined, isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
12
|
-
import { localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
13
|
-
import { registerAction2, Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
14
|
-
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
15
|
-
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
16
|
-
import { RawContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
17
|
-
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
18
|
-
import { MANAGED_SETTINGS_UPDATE_REQUIRED_ERROR_CODE } from '@codingame/monaco-vscode-api/vscode/vs/platform/defaultAccount/common/defaultAccount';
|
|
19
|
-
import { IDefaultAccountService } from '@codingame/monaco-vscode-api/vscode/vs/platform/defaultAccount/common/defaultAccount.service';
|
|
20
|
-
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
21
|
-
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
22
|
-
import { resolveForceRemoteSettingsRefresh } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/copilotManagedSettings';
|
|
23
|
-
import { INativeManagedSettingsService, IFileManagedSettingsService } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/copilotManagedSettings.service';
|
|
24
|
-
import { MANAGED_SETTINGS_FRESHNESS_NOT_REQUIRED, ManagedSettingsFreshnessState, isManagedSettingsFreshnessBlocking, ManagedSettingsFreshnessFailure, isManagedSettingsFreshnessSatisfiedFor } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/managedSettingsFreshness';
|
|
25
|
-
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
26
|
-
import { asJson, isSuccess, isClientError, asText, readHeader, retryAfterFromHeaders } from '@codingame/monaco-vscode-api/vscode/vs/platform/request/common/request';
|
|
27
|
-
import { IRequestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/request/common/request.service';
|
|
28
|
-
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
29
|
-
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
30
|
-
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
31
|
-
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
32
|
-
import { IAuthenticationService, IAuthenticationExtensionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
33
|
-
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
34
|
-
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
35
|
-
import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
|
|
36
|
-
import { appendManagedSettingsClientIdentity, adaptManagedSettings, parseManagedSettingsCompatibilityError } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/accounts/browser/managedSettings';
|
|
37
|
-
|
|
38
|
-
const DEFAULT_ACCOUNT_SIGN_IN_COMMAND = "workbench.actions.accounts.signIn";
|
|
39
|
-
var DefaultAccountStatus;
|
|
40
|
-
(function(DefaultAccountStatus) {
|
|
41
|
-
DefaultAccountStatus["Uninitialized"] = "uninitialized";
|
|
42
|
-
DefaultAccountStatus["Unavailable"] = "unavailable";
|
|
43
|
-
DefaultAccountStatus["Available"] = "available";
|
|
44
|
-
})(DefaultAccountStatus || (DefaultAccountStatus = {}));
|
|
45
|
-
const CONTEXT_DEFAULT_ACCOUNT_STATE = ( new RawContextKey("defaultAccountStatus", DefaultAccountStatus.Uninitialized));
|
|
46
|
-
const CACHED_POLICY_DATA_KEY = "defaultAccount.cachedPolicyData";
|
|
47
|
-
const ACCOUNT_DATA_POLL_INTERVAL_MS = 60 * 60 * 1000;
|
|
48
|
-
const MANAGED_SETTINGS_REQUEST_TIMEOUT_MS = 5000;
|
|
49
|
-
function toDefaultAccountConfig(defaultChatAgent) {
|
|
50
|
-
return {
|
|
51
|
-
preferredExtensions: [defaultChatAgent.chatExtensionId, defaultChatAgent.extensionId],
|
|
52
|
-
authenticationProvider: {
|
|
53
|
-
default: {
|
|
54
|
-
id: defaultChatAgent.provider.default.id,
|
|
55
|
-
name: defaultChatAgent.provider.default.name
|
|
56
|
-
},
|
|
57
|
-
enterprise: {
|
|
58
|
-
id: defaultChatAgent.provider.enterprise.id,
|
|
59
|
-
name: defaultChatAgent.provider.enterprise.name
|
|
60
|
-
},
|
|
61
|
-
enterpriseProviderConfig: `${defaultChatAgent.completionsAdvancedSetting}.authProvider`,
|
|
62
|
-
enterpriseProviderUriSetting: defaultChatAgent.providerUriSetting,
|
|
63
|
-
scopes: defaultChatAgent.providerScopes
|
|
64
|
-
},
|
|
65
|
-
entitlementUrl: defaultChatAgent.entitlementUrl,
|
|
66
|
-
tokenEntitlementUrl: defaultChatAgent.tokenEntitlementUrl,
|
|
67
|
-
mcpRegistryDataUrl: defaultChatAgent.mcpRegistryDataUrl,
|
|
68
|
-
managedSettingsUrl: defaultChatAgent.managedSettingsUrl
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
let DefaultAccountProvider = class DefaultAccountProvider extends Disposable {
|
|
72
|
-
get defaultAccount() {
|
|
73
|
-
return this._defaultAccount?.defaultAccount ?? null;
|
|
74
|
-
}
|
|
75
|
-
get policyData() {
|
|
76
|
-
return this._policyData?.policyData ?? null;
|
|
77
|
-
}
|
|
78
|
-
get copilotTokenInfo() {
|
|
79
|
-
return this._copilotTokenInfo;
|
|
80
|
-
}
|
|
81
|
-
get managedSettingsFetchStatus() {
|
|
82
|
-
return this._managedSettingsFetchStatus;
|
|
83
|
-
}
|
|
84
|
-
get managedSettingsFetchedAt() {
|
|
85
|
-
return this._policyData?.managedSettingsFetchedAt ?? null;
|
|
86
|
-
}
|
|
87
|
-
get managedSettingsRawResponse() {
|
|
88
|
-
return this._managedSettingsRawResponse;
|
|
89
|
-
}
|
|
90
|
-
get managedSettingsCompatibilityError() {
|
|
91
|
-
return this._managedSettingsCompatibilityError;
|
|
92
|
-
}
|
|
93
|
-
get managedSettingsFreshness() {
|
|
94
|
-
return this._managedSettingsFreshness;
|
|
95
|
-
}
|
|
96
|
-
constructor(
|
|
97
|
-
defaultAccountConfig,
|
|
98
|
-
configurationService,
|
|
99
|
-
authenticationService,
|
|
100
|
-
authenticationExtensionsService,
|
|
101
|
-
telemetryService,
|
|
102
|
-
extensionService,
|
|
103
|
-
requestService,
|
|
104
|
-
logService,
|
|
105
|
-
environmentService,
|
|
106
|
-
productService,
|
|
107
|
-
contextKeyService,
|
|
108
|
-
storageService,
|
|
109
|
-
hostService,
|
|
110
|
-
commandService,
|
|
111
|
-
nativeManagedSettingsService,
|
|
112
|
-
fileManagedSettingsService
|
|
113
|
-
) {
|
|
114
|
-
super();
|
|
115
|
-
this.defaultAccountConfig = defaultAccountConfig;
|
|
116
|
-
this.configurationService = configurationService;
|
|
117
|
-
this.authenticationService = authenticationService;
|
|
118
|
-
this.authenticationExtensionsService = authenticationExtensionsService;
|
|
119
|
-
this.telemetryService = telemetryService;
|
|
120
|
-
this.extensionService = extensionService;
|
|
121
|
-
this.requestService = requestService;
|
|
122
|
-
this.logService = logService;
|
|
123
|
-
this.environmentService = environmentService;
|
|
124
|
-
this.productService = productService;
|
|
125
|
-
this.storageService = storageService;
|
|
126
|
-
this.hostService = hostService;
|
|
127
|
-
this.commandService = commandService;
|
|
128
|
-
this.nativeManagedSettingsService = nativeManagedSettingsService;
|
|
129
|
-
this.fileManagedSettingsService = fileManagedSettingsService;
|
|
130
|
-
this._defaultAccount = null;
|
|
131
|
-
this._policyData = null;
|
|
132
|
-
this._copilotTokenInfo = null;
|
|
133
|
-
this._managedSettingsFetchStatus = null;
|
|
134
|
-
this._managedSettingsRawResponse = null;
|
|
135
|
-
this._managedSettingsCompatibilityError = null;
|
|
136
|
-
this._managedSettingsFreshness = MANAGED_SETTINGS_FRESHNESS_NOT_REQUIRED;
|
|
137
|
-
this._onDidChangeDefaultAccount = this._register(( new Emitter()));
|
|
138
|
-
this.onDidChangeDefaultAccount = this._onDidChangeDefaultAccount.event;
|
|
139
|
-
this._onDidChangePolicyData = this._register(( new Emitter()));
|
|
140
|
-
this.onDidChangePolicyData = this._onDidChangePolicyData.event;
|
|
141
|
-
this._onDidChangeCopilotTokenInfo = this._register(( new Emitter()));
|
|
142
|
-
this.onDidChangeCopilotTokenInfo = this._onDidChangeCopilotTokenInfo.event;
|
|
143
|
-
this._onDidChangeManagedSettingsCompatibilityError = this._register(( new Emitter()));
|
|
144
|
-
this.onDidChangeManagedSettingsCompatibilityError = this._onDidChangeManagedSettingsCompatibilityError.event;
|
|
145
|
-
this._onDidChangeManagedSettingsFreshness = this._register(( new Emitter()));
|
|
146
|
-
this.onDidChangeManagedSettingsFreshness = this._onDidChangeManagedSettingsFreshness.event;
|
|
147
|
-
this.initialized = false;
|
|
148
|
-
this.updateThrottler = this._register(( new ThrottledDelayer(100)));
|
|
149
|
-
this.accountDataPollScheduler = this._register(( new RunOnceScheduler(() => this.refetchDefaultAccount(), ACCOUNT_DATA_POLL_INTERVAL_MS)));
|
|
150
|
-
this.failedManagedSettingsFreshness = ( new Map());
|
|
151
|
-
this._rateLimitBackoffUntil = 0;
|
|
152
|
-
this.accountStatusContext = CONTEXT_DEFAULT_ACCOUNT_STATE.bindTo(contextKeyService);
|
|
153
|
-
const cachedAccountData = this.getCachedAccountData();
|
|
154
|
-
this._policyData = cachedAccountData?.accountPolicyData ?? null;
|
|
155
|
-
this._copilotTokenInfo = cachedAccountData?.copilotTokenInfo ?? null;
|
|
156
|
-
this._managedSettingsCompatibilityError = cachedAccountData?.accountPolicyData.managedSettingsCompatibilityError ?? null;
|
|
157
|
-
this.updateManagedSettingsFreshnessRequirement(
|
|
158
|
-
this.nativeManagedSettingsService.managedSettings,
|
|
159
|
-
this.getCachedServerManagedSettings(this.getDefaultAccountAuthenticationProvider()),
|
|
160
|
-
this.fileManagedSettingsService.managedSettings
|
|
161
|
-
);
|
|
162
|
-
this._register(
|
|
163
|
-
this.nativeManagedSettingsService.onDidChangeManagedSettings(() => this.onManagedSettingsSourceChanged())
|
|
164
|
-
);
|
|
165
|
-
this._register(
|
|
166
|
-
this.fileManagedSettingsService.onDidChangeManagedSettings(() => this.onManagedSettingsSourceChanged())
|
|
167
|
-
);
|
|
168
|
-
this.initPromise = this.init().finally(() => {
|
|
169
|
-
this.telemetryService.publicLog2("defaultaccount:status", {
|
|
170
|
-
status: this.defaultAccount ? "available" : "unavailable",
|
|
171
|
-
initial: true
|
|
172
|
-
});
|
|
173
|
-
this.initialized = true;
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
getCachedAccountData() {
|
|
177
|
-
const cached = this.storageService.get(CACHED_POLICY_DATA_KEY, StorageScope.APPLICATION);
|
|
178
|
-
if (cached) {
|
|
179
|
-
try {
|
|
180
|
-
const parsed = JSON.parse(cached);
|
|
181
|
-
const {
|
|
182
|
-
accountId,
|
|
183
|
-
policyData,
|
|
184
|
-
tokenEntitlementsFetchedAt,
|
|
185
|
-
mcpRegistryDataFetchedAt,
|
|
186
|
-
copilotTokenInfo
|
|
187
|
-
} = parsed;
|
|
188
|
-
if (accountId && policyData) {
|
|
189
|
-
this.logService.debug(
|
|
190
|
-
"[DefaultAccount] Initializing with cached policy data (migrating old format)"
|
|
191
|
-
);
|
|
192
|
-
const result = {
|
|
193
|
-
accountPolicyData: {
|
|
194
|
-
accountId,
|
|
195
|
-
policyData,
|
|
196
|
-
tokenEntitlementsFetchedAt,
|
|
197
|
-
mcpRegistryDataFetchedAt
|
|
198
|
-
},
|
|
199
|
-
copilotTokenInfo
|
|
200
|
-
};
|
|
201
|
-
this.storageService.store(
|
|
202
|
-
CACHED_POLICY_DATA_KEY,
|
|
203
|
-
JSON.stringify(result),
|
|
204
|
-
StorageScope.APPLICATION,
|
|
205
|
-
StorageTarget.MACHINE
|
|
206
|
-
);
|
|
207
|
-
return result;
|
|
208
|
-
}
|
|
209
|
-
const {
|
|
210
|
-
accountPolicyData,
|
|
211
|
-
copilotTokenInfo: wrappedCopilotTokenInfo
|
|
212
|
-
} = parsed;
|
|
213
|
-
if (accountPolicyData?.accountId && accountPolicyData?.policyData) {
|
|
214
|
-
this.logService.debug("[DefaultAccount] Initializing with cached policy data");
|
|
215
|
-
return {
|
|
216
|
-
accountPolicyData,
|
|
217
|
-
copilotTokenInfo: wrappedCopilotTokenInfo
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
} catch (error) {
|
|
221
|
-
this.logService.error(
|
|
222
|
-
"[DefaultAccount] Failed to parse cached policy data",
|
|
223
|
-
getErrorMessage(error)
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
229
|
-
async init() {
|
|
230
|
-
if (isWeb && !this.environmentService.remoteAuthority && !this.environmentService.isSessionsWindow) {
|
|
231
|
-
this.logService.debug("[DefaultAccount] Running in web without remote, skipping initialization");
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
await this.whenDefaultAccountAuthenticationProviderAvailable();
|
|
235
|
-
this.logService.debug("[DefaultAccount] Starting initialization");
|
|
236
|
-
await this.doUpdateDefaultAccount();
|
|
237
|
-
this.logService.debug("[DefaultAccount] Initialization complete");
|
|
238
|
-
this._register(this.onDidChangeDefaultAccount(account => {
|
|
239
|
-
this.telemetryService.publicLog2("defaultaccount:status", {
|
|
240
|
-
status: account ? "available" : "unavailable",
|
|
241
|
-
initial: false
|
|
242
|
-
});
|
|
243
|
-
}));
|
|
244
|
-
this._register(this.authenticationService.onDidChangeSessions(e => {
|
|
245
|
-
const defaultAccountProvider = this.getDefaultAccountAuthenticationProvider();
|
|
246
|
-
if (e.providerId !== defaultAccountProvider.id) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
const added = e.event.added?.length ?? 0;
|
|
250
|
-
const removed = e.event.removed?.length ?? 0;
|
|
251
|
-
const changed = e.event.changed?.length ?? 0;
|
|
252
|
-
const currentSessionRemoved = this.defaultAccount !== null && (e.event.removed?.some(session => session.id === this.defaultAccount?.sessionId) ?? false);
|
|
253
|
-
const hasReplacementCandidates = added > 0 || changed > 0;
|
|
254
|
-
const clearDefaultAccount = currentSessionRemoved && !hasReplacementCandidates;
|
|
255
|
-
const message = `[DefaultAccount] Authentication sessions changed: added=${added}, removed=${removed}, changed=${changed}, currentSessionRemoved=${currentSessionRemoved}, hasReplacementCandidates=${hasReplacementCandidates}, decision=${clearDefaultAccount ? "clear" : "reconcile"}`;
|
|
256
|
-
if (currentSessionRemoved || (added > 0 && removed > 0)) {
|
|
257
|
-
this.logService.info(message);
|
|
258
|
-
} else {
|
|
259
|
-
this.logService.trace(message);
|
|
260
|
-
}
|
|
261
|
-
if (clearDefaultAccount) {
|
|
262
|
-
this.setDefaultAccount(null);
|
|
263
|
-
} else {
|
|
264
|
-
this.updateDefaultAccount();
|
|
265
|
-
}
|
|
266
|
-
}));
|
|
267
|
-
this._register(
|
|
268
|
-
this.authenticationExtensionsService.onDidChangeAccountPreference(async e => {
|
|
269
|
-
const defaultAccountProvider = this.getDefaultAccountAuthenticationProvider();
|
|
270
|
-
if (e.providerId !== defaultAccountProvider.id) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
this.logService.debug(
|
|
274
|
-
"[DefaultAccount] Account preference changed for default account provider, updating default account"
|
|
275
|
-
);
|
|
276
|
-
this.updateDefaultAccount();
|
|
277
|
-
})
|
|
278
|
-
);
|
|
279
|
-
this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => {
|
|
280
|
-
const defaultAccountProvider = this.getDefaultAccountAuthenticationProvider();
|
|
281
|
-
if (e.id !== defaultAccountProvider.id) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
this.logService.debug(
|
|
285
|
-
"[DefaultAccount] Default account provider registered, updating default account"
|
|
286
|
-
);
|
|
287
|
-
this.updateDefaultAccount();
|
|
288
|
-
}));
|
|
289
|
-
this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => {
|
|
290
|
-
const defaultAccountProvider = this.getDefaultAccountAuthenticationProvider();
|
|
291
|
-
if (e.id !== defaultAccountProvider.id) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
this.logService.debug(
|
|
295
|
-
"[DefaultAccount] Default account provider unregistered, updating default account"
|
|
296
|
-
);
|
|
297
|
-
this.updateDefaultAccount();
|
|
298
|
-
}));
|
|
299
|
-
this._register(this.hostService.onDidChangeFocus(focused => {
|
|
300
|
-
if (focused) {
|
|
301
|
-
this.refetchDefaultAccount();
|
|
302
|
-
}
|
|
303
|
-
}));
|
|
304
|
-
}
|
|
305
|
-
async whenDefaultAccountAuthenticationProviderAvailable() {
|
|
306
|
-
const provider = this.getDefaultAccountAuthenticationProvider();
|
|
307
|
-
this.logService.debug(
|
|
308
|
-
"[DefaultAccount] Waiting for default account authentication provider to be available."
|
|
309
|
-
);
|
|
310
|
-
const disposables = ( new DisposableStore());
|
|
311
|
-
try {
|
|
312
|
-
await ( new Promise(resolve => {
|
|
313
|
-
if (this.isAccountProviderAvailable(provider)) {
|
|
314
|
-
this.logService.debug(
|
|
315
|
-
"[DefaultAccount] Default account authentication provider is now available."
|
|
316
|
-
);
|
|
317
|
-
resolve();
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
disposables.add(Event.any(
|
|
321
|
-
this.authenticationService.onDidChangeDeclaredProviders,
|
|
322
|
-
this.authenticationService.onDidRegisterAuthenticationProvider
|
|
323
|
-
)(() => {
|
|
324
|
-
if (this.isAccountProviderAvailable(provider)) {
|
|
325
|
-
this.logService.debug(
|
|
326
|
-
"[DefaultAccount] Default account authentication provider is now available."
|
|
327
|
-
);
|
|
328
|
-
resolve();
|
|
329
|
-
}
|
|
330
|
-
}));
|
|
331
|
-
if (this.environmentService.remoteAuthority) {
|
|
332
|
-
void this.authenticationService.getSessions(provider.id, undefined, {}, true);
|
|
333
|
-
}
|
|
334
|
-
this.extensionService.whenInstalledExtensionsRegistered().then(() => {
|
|
335
|
-
disposables.dispose();
|
|
336
|
-
this.logService.debug("[DefaultAccount] Installed extensions registered.");
|
|
337
|
-
resolve();
|
|
338
|
-
}, error => {
|
|
339
|
-
this.logService.error(
|
|
340
|
-
"[DefaultAccount] Error while waiting for installed extensions to be registered",
|
|
341
|
-
getErrorMessage(error)
|
|
342
|
-
);
|
|
343
|
-
resolve();
|
|
344
|
-
});
|
|
345
|
-
}));
|
|
346
|
-
} finally {
|
|
347
|
-
disposables.dispose();
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
async refresh(options) {
|
|
351
|
-
if (!this.initialized) {
|
|
352
|
-
await this.initPromise;
|
|
353
|
-
return this.defaultAccount;
|
|
354
|
-
}
|
|
355
|
-
this.logService.debug("[DefaultAccount] Refreshing default account");
|
|
356
|
-
await this.updateDefaultAccount(options);
|
|
357
|
-
return this.defaultAccount;
|
|
358
|
-
}
|
|
359
|
-
async refetchDefaultAccount() {
|
|
360
|
-
if (this.accountDataPollScheduler.isScheduled()) {
|
|
361
|
-
this.accountDataPollScheduler.cancel();
|
|
362
|
-
}
|
|
363
|
-
if (!this.hostService.hasFocus || !this._defaultAccount) {
|
|
364
|
-
this.scheduleAccountDataPoll();
|
|
365
|
-
this.logService.debug(
|
|
366
|
-
"[DefaultAccount] Skipping refetching default account. Host is not focused or default account is not set"
|
|
367
|
-
);
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
this.logService.debug("[DefaultAccount] Refetching default account");
|
|
371
|
-
await this.updateDefaultAccount();
|
|
372
|
-
}
|
|
373
|
-
async updateDefaultAccount(options) {
|
|
374
|
-
await this.updateThrottler.trigger(() => this.doUpdateDefaultAccount(options));
|
|
375
|
-
}
|
|
376
|
-
async doUpdateDefaultAccount(options) {
|
|
377
|
-
const currentSessionId = this.defaultAccount?.sessionId;
|
|
378
|
-
try {
|
|
379
|
-
const defaultAccount = await this.fetchDefaultAccount(options);
|
|
380
|
-
if (currentSessionId && this.defaultAccount?.sessionId !== currentSessionId) {
|
|
381
|
-
this.logService.info(
|
|
382
|
-
"[DefaultAccount] Discarding default account update because the current session changed while the update was in progress"
|
|
383
|
-
);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
this.setDefaultAccount(defaultAccount);
|
|
387
|
-
this.scheduleAccountDataPoll();
|
|
388
|
-
} catch (error) {
|
|
389
|
-
this.logService.error(
|
|
390
|
-
"[DefaultAccount] Error while updating default account",
|
|
391
|
-
getErrorMessage(error)
|
|
392
|
-
);
|
|
393
|
-
this.blockPendingManagedSettingsFreshness();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
async fetchDefaultAccount(options) {
|
|
397
|
-
const defaultAccountProvider = this.getDefaultAccountAuthenticationProvider();
|
|
398
|
-
this.logService.debug("[DefaultAccount] Default account provider ID:", defaultAccountProvider.id);
|
|
399
|
-
const managedSettingsSources = await this.initializeManagedSettingsSources();
|
|
400
|
-
const refreshRequirement = resolveForceRemoteSettingsRefresh(
|
|
401
|
-
managedSettingsSources.nativeMdm,
|
|
402
|
-
this.getCachedServerManagedSettings(defaultAccountProvider),
|
|
403
|
-
managedSettingsSources.file
|
|
404
|
-
);
|
|
405
|
-
if (!refreshRequirement.effective) {
|
|
406
|
-
this.setManagedSettingsFreshness(MANAGED_SETTINGS_FRESHNESS_NOT_REQUIRED);
|
|
407
|
-
}
|
|
408
|
-
if (!this.isAccountProviderAvailable(defaultAccountProvider)) {
|
|
409
|
-
this.logService.info(
|
|
410
|
-
`[DefaultAccount] Authentication provider is not available.`,
|
|
411
|
-
defaultAccountProvider
|
|
412
|
-
);
|
|
413
|
-
this.blockManagedSettingsFreshnessWithoutToken(refreshRequirement);
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
return await this.getDefaultAccountForAuthenticationProvider(
|
|
417
|
-
defaultAccountProvider,
|
|
418
|
-
managedSettingsSources,
|
|
419
|
-
refreshRequirement,
|
|
420
|
-
options
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
isAccountProviderAvailable(accountProvider) {
|
|
424
|
-
return ( this.authenticationService.declaredProviders.some(p => p.id === accountProvider.id)) || this.authenticationService.isAuthenticationProviderRegistered(accountProvider.id);
|
|
425
|
-
}
|
|
426
|
-
setDefaultAccount(account) {
|
|
427
|
-
if (equals(this._defaultAccount, account)) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
this.logService.trace("[DefaultAccount] Updating default account:", account);
|
|
431
|
-
if (account) {
|
|
432
|
-
this._defaultAccount = account;
|
|
433
|
-
this.setCopilotTokenInfo(account.copilotTokenInfo);
|
|
434
|
-
this.setPolicyData(account.policyData);
|
|
435
|
-
this.setManagedSettingsCompatibilityError(account.policyData?.managedSettingsCompatibilityError ?? null);
|
|
436
|
-
this._onDidChangeDefaultAccount.fire(this._defaultAccount.defaultAccount);
|
|
437
|
-
this.accountStatusContext.set(DefaultAccountStatus.Available);
|
|
438
|
-
this.logService.debug("[DefaultAccount] Account status set to Available");
|
|
439
|
-
} else {
|
|
440
|
-
this._defaultAccount = null;
|
|
441
|
-
const refreshRequirement = resolveForceRemoteSettingsRefresh(
|
|
442
|
-
this.nativeManagedSettingsService.managedSettings,
|
|
443
|
-
this.getCachedServerManagedSettings(this.getDefaultAccountAuthenticationProvider()),
|
|
444
|
-
this.fileManagedSettingsService.managedSettings
|
|
445
|
-
);
|
|
446
|
-
this.blockManagedSettingsFreshnessWithoutToken(refreshRequirement);
|
|
447
|
-
const retainedPolicyData = this._managedSettingsFreshness.state !== ManagedSettingsFreshnessState.NotRequired && isManagedSettingsFreshnessBlocking(this._managedSettingsFreshness) && this._managedSettingsFreshness.source === "server" ? this._policyData : null;
|
|
448
|
-
this.setPolicyData(retainedPolicyData);
|
|
449
|
-
this.setManagedSettingsCompatibilityError(null);
|
|
450
|
-
this.setCopilotTokenInfo(null);
|
|
451
|
-
this._onDidChangeDefaultAccount.fire(null);
|
|
452
|
-
this.accountDataPollScheduler.cancel();
|
|
453
|
-
this.accountStatusContext.set(DefaultAccountStatus.Unavailable);
|
|
454
|
-
this.logService.debug("[DefaultAccount] Account status set to Unavailable");
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
setPolicyData(accountPolicyData) {
|
|
458
|
-
if (equals(this._policyData, accountPolicyData)) {
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
this._policyData = accountPolicyData;
|
|
462
|
-
this.cachePolicyData(accountPolicyData);
|
|
463
|
-
this._onDidChangePolicyData.fire(this._policyData?.policyData ?? null);
|
|
464
|
-
}
|
|
465
|
-
setManagedSettingsCompatibilityError(error) {
|
|
466
|
-
if (equals(this._managedSettingsCompatibilityError, error)) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
this._managedSettingsCompatibilityError = error;
|
|
470
|
-
this._onDidChangeManagedSettingsCompatibilityError.fire(error);
|
|
471
|
-
}
|
|
472
|
-
setManagedSettingsFreshness(freshness) {
|
|
473
|
-
if (equals(this._managedSettingsFreshness, freshness)) {
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
this._managedSettingsFreshness = freshness;
|
|
477
|
-
this._onDidChangeManagedSettingsFreshness.fire(freshness);
|
|
478
|
-
}
|
|
479
|
-
blockPendingManagedSettingsFreshness() {
|
|
480
|
-
if (this._managedSettingsFreshness.state === ManagedSettingsFreshnessState.Pending) {
|
|
481
|
-
this.setManagedSettingsFreshness({
|
|
482
|
-
...this._managedSettingsFreshness,
|
|
483
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
484
|
-
failure: ManagedSettingsFreshnessFailure.Network
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
updateManagedSettingsFreshnessRequirement(nativeMdm, server, file) {
|
|
489
|
-
const requirement = resolveForceRemoteSettingsRefresh(nativeMdm, server, file);
|
|
490
|
-
this.setManagedSettingsFreshness(requirement.effective ? {
|
|
491
|
-
state: ManagedSettingsFreshnessState.Pending,
|
|
492
|
-
source: requirement.source
|
|
493
|
-
} : MANAGED_SETTINGS_FRESHNESS_NOT_REQUIRED);
|
|
494
|
-
}
|
|
495
|
-
onManagedSettingsSourceChanged() {
|
|
496
|
-
if (this.initialized) {
|
|
497
|
-
void this.updateDefaultAccount();
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
async initializeManagedSettingsSources() {
|
|
501
|
-
let nativeMdm = this.nativeManagedSettingsService.managedSettings;
|
|
502
|
-
try {
|
|
503
|
-
nativeMdm = await this.nativeManagedSettingsService.initialize();
|
|
504
|
-
} catch (error) {
|
|
505
|
-
this.logService.warn(
|
|
506
|
-
"[DefaultAccount] Failed to initialize native managed settings before resolving forceRemoteSettingsRefresh; using available values",
|
|
507
|
-
getErrorMessage(error)
|
|
508
|
-
);
|
|
509
|
-
}
|
|
510
|
-
let file = this.fileManagedSettingsService.managedSettings;
|
|
511
|
-
try {
|
|
512
|
-
file = await this.fileManagedSettingsService.initialize();
|
|
513
|
-
} catch (error) {
|
|
514
|
-
this.logService.warn(
|
|
515
|
-
"[DefaultAccount] Failed to initialize file managed settings before resolving forceRemoteSettingsRefresh; using available values",
|
|
516
|
-
getErrorMessage(error)
|
|
517
|
-
);
|
|
518
|
-
}
|
|
519
|
-
return {
|
|
520
|
-
nativeMdm,
|
|
521
|
-
file
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
blockManagedSettingsFreshnessWithoutToken(requirement) {
|
|
525
|
-
if (requirement.effective) {
|
|
526
|
-
this.setManagedSettingsFreshness({
|
|
527
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
528
|
-
source: requirement.source,
|
|
529
|
-
failure: ManagedSettingsFreshnessFailure.NoToken
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
getCachedServerManagedSettings(authenticationProvider) {
|
|
534
|
-
return this.getScopedServerManagedSettings(
|
|
535
|
-
this._policyData ?? undefined,
|
|
536
|
-
authenticationProvider,
|
|
537
|
-
this._policyData?.accountId
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
getScopedServerManagedSettings(accountPolicyData, authenticationProvider, accountId) {
|
|
541
|
-
if (!accountPolicyData || accountPolicyData.accountId !== accountId) {
|
|
542
|
-
return undefined;
|
|
543
|
-
}
|
|
544
|
-
const scope = accountPolicyData.managedSettingsScope;
|
|
545
|
-
const managedSettingsUrl = this.getManagedSettingsUrl();
|
|
546
|
-
if (scope && (scope.accountId !== accountId || scope.authenticationProviderId !== authenticationProvider.id || (managedSettingsUrl ? scope.endpointOrigin !== this.createManagedSettingsFreshnessScope(scope.accountId, authenticationProvider.id, managedSettingsUrl).endpointOrigin : false))) {
|
|
547
|
-
return undefined;
|
|
548
|
-
}
|
|
549
|
-
return accountPolicyData.policyData.managedSettings;
|
|
550
|
-
}
|
|
551
|
-
setCopilotTokenInfo(copilotTokenInfo) {
|
|
552
|
-
if (equals(this._copilotTokenInfo, copilotTokenInfo)) {
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
this._copilotTokenInfo = copilotTokenInfo;
|
|
556
|
-
this._onDidChangeCopilotTokenInfo.fire(this._copilotTokenInfo);
|
|
557
|
-
}
|
|
558
|
-
cachePolicyData(accountPolicyData) {
|
|
559
|
-
if (accountPolicyData) {
|
|
560
|
-
this.logService.debug(
|
|
561
|
-
"[DefaultAccount] Caching policy data for account:",
|
|
562
|
-
accountPolicyData.accountId
|
|
563
|
-
);
|
|
564
|
-
const cachedAccountData = {
|
|
565
|
-
accountPolicyData,
|
|
566
|
-
copilotTokenInfo: this._copilotTokenInfo ?? undefined
|
|
567
|
-
};
|
|
568
|
-
this.storageService.store(
|
|
569
|
-
CACHED_POLICY_DATA_KEY,
|
|
570
|
-
JSON.stringify(cachedAccountData),
|
|
571
|
-
StorageScope.APPLICATION,
|
|
572
|
-
StorageTarget.MACHINE
|
|
573
|
-
);
|
|
574
|
-
} else {
|
|
575
|
-
this.logService.debug("[DefaultAccount] Removing cached policy data");
|
|
576
|
-
this.storageService.remove(CACHED_POLICY_DATA_KEY, StorageScope.APPLICATION);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
scheduleAccountDataPoll() {
|
|
580
|
-
if (!this._defaultAccount) {
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
this.accountDataPollScheduler.schedule(ACCOUNT_DATA_POLL_INTERVAL_MS);
|
|
584
|
-
}
|
|
585
|
-
extractFromToken(token) {
|
|
586
|
-
const result = ( new Map());
|
|
587
|
-
const firstPart = token?.split(":")[0];
|
|
588
|
-
const fields = firstPart?.split(";");
|
|
589
|
-
for (const field of fields) {
|
|
590
|
-
const [key, value] = field.split("=");
|
|
591
|
-
result.set(key, value);
|
|
592
|
-
}
|
|
593
|
-
this.logService.debug(
|
|
594
|
-
`[DefaultAccount] extractFromToken: ${JSON.stringify(Object.fromEntries(result))}`
|
|
595
|
-
);
|
|
596
|
-
return result;
|
|
597
|
-
}
|
|
598
|
-
async getDefaultAccountForAuthenticationProvider(
|
|
599
|
-
authenticationProvider,
|
|
600
|
-
managedSettingsSources,
|
|
601
|
-
refreshRequirement,
|
|
602
|
-
options
|
|
603
|
-
) {
|
|
604
|
-
try {
|
|
605
|
-
this.logService.debug(
|
|
606
|
-
"[DefaultAccount] Getting Default Account from authenticated sessions for provider:",
|
|
607
|
-
authenticationProvider.id
|
|
608
|
-
);
|
|
609
|
-
const sessions = await this.findMatchingProviderSession(
|
|
610
|
-
authenticationProvider.id,
|
|
611
|
-
this.defaultAccountConfig.authenticationProvider.scopes
|
|
612
|
-
);
|
|
613
|
-
if (!sessions?.length) {
|
|
614
|
-
this.logService.debug(
|
|
615
|
-
"[DefaultAccount] No matching session found for provider:",
|
|
616
|
-
authenticationProvider.id
|
|
617
|
-
);
|
|
618
|
-
this.blockManagedSettingsFreshnessWithoutToken(refreshRequirement);
|
|
619
|
-
return null;
|
|
620
|
-
}
|
|
621
|
-
return this.getDefaultAccountFromAuthenticatedSessions(authenticationProvider, sessions, options, managedSettingsSources);
|
|
622
|
-
} catch (error) {
|
|
623
|
-
this.logService.error(
|
|
624
|
-
"[DefaultAccount] Failed to get default account for provider:",
|
|
625
|
-
authenticationProvider.id,
|
|
626
|
-
getErrorMessage(error)
|
|
627
|
-
);
|
|
628
|
-
this.blockManagedSettingsFreshnessWithoutToken(refreshRequirement);
|
|
629
|
-
return null;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
async getDefaultAccountFromAuthenticatedSessions(authenticationProvider, sessions, options, managedSettingsSources) {
|
|
633
|
-
try {
|
|
634
|
-
const accountId = sessions[0].account.id;
|
|
635
|
-
const accountPolicyData = this._policyData?.accountId === accountId ? this._policyData : undefined;
|
|
636
|
-
const sources = managedSettingsSources ?? (await this.initializeManagedSettingsSources());
|
|
637
|
-
const requirement = resolveForceRemoteSettingsRefresh(
|
|
638
|
-
sources.nativeMdm,
|
|
639
|
-
this.getScopedServerManagedSettings(accountPolicyData, authenticationProvider, accountId),
|
|
640
|
-
sources.file
|
|
641
|
-
);
|
|
642
|
-
const managedSettingsUrl = this.getManagedSettingsUrl();
|
|
643
|
-
const scope = managedSettingsUrl ? this.createManagedSettingsFreshnessScope(accountId, authenticationProvider.id, managedSettingsUrl) : undefined;
|
|
644
|
-
if (!requirement.effective) {
|
|
645
|
-
this.setManagedSettingsFreshness(MANAGED_SETTINGS_FRESHNESS_NOT_REQUIRED);
|
|
646
|
-
} else if ((!scope || !isManagedSettingsFreshnessSatisfiedFor(this._managedSettingsFreshness, scope) || options?.forceRefresh) && this.canRequestManagedSettings(options, scope)) {
|
|
647
|
-
this.setManagedSettingsFreshness({
|
|
648
|
-
state: ManagedSettingsFreshnessState.Pending,
|
|
649
|
-
source: requirement.source,
|
|
650
|
-
scope
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
const entitlementsResult = await this.getEntitlements(sessions, accountPolicyData, options);
|
|
654
|
-
const entitlementsData = entitlementsResult?.data;
|
|
655
|
-
const entitlementsFetchedAt = entitlementsResult?.fetchedAt;
|
|
656
|
-
const [tokenEntitlementsResult, managedSettingsResult] = await Promise.all([
|
|
657
|
-
entitlementsData?.chat_enabled ? this.getTokenEntitlements(sessions, accountPolicyData, options) : undefined,
|
|
658
|
-
entitlementsData?.chat_enabled || requirement.effective ? this.getManagedSettings(
|
|
659
|
-
sessions,
|
|
660
|
-
accountPolicyData,
|
|
661
|
-
options,
|
|
662
|
-
authenticationProvider,
|
|
663
|
-
sources,
|
|
664
|
-
requirement
|
|
665
|
-
) : undefined
|
|
666
|
-
]);
|
|
667
|
-
const tokenEntitlementsFetchedAt = tokenEntitlementsResult?.fetchedAt;
|
|
668
|
-
const managedSettingsFetchedAt = managedSettingsResult?.fetchedAt;
|
|
669
|
-
const managedSettingsScope = managedSettingsResult?.scope ?? accountPolicyData?.managedSettingsScope;
|
|
670
|
-
const managedSettingsCompatibilityError = managedSettingsResult ? managedSettingsResult.compatibilityError : this._managedSettingsCompatibilityError;
|
|
671
|
-
let mcpRegistryDataFetchedAt;
|
|
672
|
-
let policyData = accountPolicyData?.policyData ? {
|
|
673
|
-
...accountPolicyData.policyData
|
|
674
|
-
} : undefined;
|
|
675
|
-
if (entitlementsData) {
|
|
676
|
-
policyData = policyData ?? {};
|
|
677
|
-
policyData.cloud_session_storage_enabled = entitlementsData.cloud_session_storage_enabled;
|
|
678
|
-
}
|
|
679
|
-
if (tokenEntitlementsResult?.data) {
|
|
680
|
-
const tokenEntitlementsData = tokenEntitlementsResult.data;
|
|
681
|
-
policyData = policyData ?? {};
|
|
682
|
-
policyData.chat_agent_enabled = tokenEntitlementsData.policyData.chat_agent_enabled;
|
|
683
|
-
policyData.chat_preview_features_enabled = tokenEntitlementsData.policyData.chat_preview_features_enabled;
|
|
684
|
-
policyData.mcp = tokenEntitlementsData.policyData.mcp;
|
|
685
|
-
if (policyData.mcp) {
|
|
686
|
-
const mcpRegistryResult = await this.getMcpRegistryProvider(sessions, accountPolicyData, options);
|
|
687
|
-
mcpRegistryDataFetchedAt = mcpRegistryResult?.fetchedAt;
|
|
688
|
-
policyData.mcpRegistryUrl = mcpRegistryResult?.data?.url;
|
|
689
|
-
policyData.mcpAccess = mcpRegistryResult?.data?.registry_access;
|
|
690
|
-
} else {
|
|
691
|
-
policyData.mcpRegistryUrl = undefined;
|
|
692
|
-
policyData.mcpAccess = undefined;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
if (managedSettingsResult?.data) {
|
|
696
|
-
policyData = {
|
|
697
|
-
...(policyData ?? {}),
|
|
698
|
-
...managedSettingsResult.data
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
const defaultAccount = {
|
|
702
|
-
authenticationProvider,
|
|
703
|
-
accountName: sessions[0].account.label,
|
|
704
|
-
sessionId: sessions[0].id,
|
|
705
|
-
enterprise: authenticationProvider.enterprise || sessions[0].account.label.includes("_"),
|
|
706
|
-
entitlementsData
|
|
707
|
-
};
|
|
708
|
-
this.logService.debug(
|
|
709
|
-
"[DefaultAccount] Successfully created default account for provider:",
|
|
710
|
-
authenticationProvider.id
|
|
711
|
-
);
|
|
712
|
-
const accountPolicyResult = policyData || entitlementsFetchedAt ? {
|
|
713
|
-
accountId,
|
|
714
|
-
policyData: policyData ?? {},
|
|
715
|
-
entitlementsFetchedAt,
|
|
716
|
-
tokenEntitlementsFetchedAt,
|
|
717
|
-
mcpRegistryDataFetchedAt,
|
|
718
|
-
managedSettingsFetchedAt,
|
|
719
|
-
managedSettingsScope,
|
|
720
|
-
managedSettingsCompatibilityError: managedSettingsCompatibilityError ?? undefined
|
|
721
|
-
} : null;
|
|
722
|
-
return {
|
|
723
|
-
defaultAccount,
|
|
724
|
-
accountId,
|
|
725
|
-
policyData: accountPolicyResult,
|
|
726
|
-
copilotTokenInfo: tokenEntitlementsResult?.data?.copilotTokenInfo ?? null
|
|
727
|
-
};
|
|
728
|
-
} catch (error) {
|
|
729
|
-
this.logService.error(
|
|
730
|
-
"[DefaultAccount] Failed to create default account for provider:",
|
|
731
|
-
authenticationProvider.id,
|
|
732
|
-
getErrorMessage(error)
|
|
733
|
-
);
|
|
734
|
-
this.blockPendingManagedSettingsFreshness();
|
|
735
|
-
return null;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
async findMatchingProviderSession(authProviderId, allScopes) {
|
|
739
|
-
const sessions = await this.getSessions(authProviderId);
|
|
740
|
-
const matchingSessions = sessions.filter(session => {
|
|
741
|
-
this.logService.debug("[DefaultAccount] Checking session with scopes", session.scopes);
|
|
742
|
-
return ( allScopes.some(scopes => this.scopesMatch(session.scopes, scopes)));
|
|
743
|
-
});
|
|
744
|
-
return matchingSessions.length > 0 ? matchingSessions : undefined;
|
|
745
|
-
}
|
|
746
|
-
async getSessions(authProviderId) {
|
|
747
|
-
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
748
|
-
try {
|
|
749
|
-
let preferredAccount;
|
|
750
|
-
let preferredAccountName;
|
|
751
|
-
for (const preferredExtension of this.defaultAccountConfig.preferredExtensions) {
|
|
752
|
-
preferredAccountName = this.authenticationExtensionsService.getAccountPreference(preferredExtension, authProviderId);
|
|
753
|
-
if (preferredAccountName) {
|
|
754
|
-
break;
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
for (const account of await this.authenticationService.getAccounts(authProviderId)) {
|
|
758
|
-
if (account.label === preferredAccountName) {
|
|
759
|
-
preferredAccount = account;
|
|
760
|
-
break;
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
return await this.authenticationService.getSessions(authProviderId, undefined, {
|
|
764
|
-
account: preferredAccount
|
|
765
|
-
}, true);
|
|
766
|
-
} catch (error) {
|
|
767
|
-
this.logService.warn(
|
|
768
|
-
`[DefaultAccount] Attempt ${attempt} to get sessions failed:`,
|
|
769
|
-
getErrorMessage(error)
|
|
770
|
-
);
|
|
771
|
-
if (attempt === 3) {
|
|
772
|
-
throw error;
|
|
773
|
-
}
|
|
774
|
-
await timeout(500);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
throw ( new Error("Unable to get sessions after multiple attempts"));
|
|
778
|
-
}
|
|
779
|
-
scopesMatch(scopes, expectedScopes) {
|
|
780
|
-
return expectedScopes.every(scope => scopes.includes(scope));
|
|
781
|
-
}
|
|
782
|
-
async getTokenEntitlements(sessions, accountPolicyData, options) {
|
|
783
|
-
if (!options?.forceRefresh && accountPolicyData?.tokenEntitlementsFetchedAt && !this.isDataStale(accountPolicyData.tokenEntitlementsFetchedAt)) {
|
|
784
|
-
this.logService.debug("[DefaultAccount] Using last fetched token entitlements data");
|
|
785
|
-
return {
|
|
786
|
-
data: {
|
|
787
|
-
policyData: accountPolicyData.policyData,
|
|
788
|
-
copilotTokenInfo: this._copilotTokenInfo ?? {}
|
|
789
|
-
},
|
|
790
|
-
fetchedAt: accountPolicyData.tokenEntitlementsFetchedAt
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
const data = await this.requestTokenEntitlements(sessions);
|
|
794
|
-
return {
|
|
795
|
-
data,
|
|
796
|
-
fetchedAt: Date.now()
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
async requestTokenEntitlements(sessions) {
|
|
800
|
-
const tokenEntitlementsUrl = this.getTokenEntitlementUrl();
|
|
801
|
-
if (!tokenEntitlementsUrl) {
|
|
802
|
-
this.logService.debug("[DefaultAccount] No token entitlements URL found");
|
|
803
|
-
return undefined;
|
|
804
|
-
}
|
|
805
|
-
this.logService.debug("[DefaultAccount] Fetching token entitlements from:", tokenEntitlementsUrl);
|
|
806
|
-
const response = await this.request(
|
|
807
|
-
tokenEntitlementsUrl,
|
|
808
|
-
"GET",
|
|
809
|
-
undefined,
|
|
810
|
-
sessions,
|
|
811
|
-
CancellationToken.None,
|
|
812
|
-
"defaultAccount.tokenEntitlements"
|
|
813
|
-
);
|
|
814
|
-
if (!response) {
|
|
815
|
-
return undefined;
|
|
816
|
-
}
|
|
817
|
-
if (response.res.statusCode && response.res.statusCode !== 200) {
|
|
818
|
-
this.logService.trace(
|
|
819
|
-
`[DefaultAccount] unexpected status code ${response.res.statusCode} while fetching token entitlements`
|
|
820
|
-
);
|
|
821
|
-
return undefined;
|
|
822
|
-
}
|
|
823
|
-
try {
|
|
824
|
-
const chatData = await asJson(response);
|
|
825
|
-
if (chatData) {
|
|
826
|
-
const tokenMap = this.extractFromToken(chatData.token);
|
|
827
|
-
return {
|
|
828
|
-
policyData: {
|
|
829
|
-
chat_preview_features_enabled: tokenMap.get("editor_preview_features") !== "0",
|
|
830
|
-
chat_agent_enabled: tokenMap.get("agent_mode") !== "0",
|
|
831
|
-
mcp: tokenMap.get("mcp") === "1"
|
|
832
|
-
},
|
|
833
|
-
copilotTokenInfo: {
|
|
834
|
-
sn: tokenMap.get("sn"),
|
|
835
|
-
fcv1: tokenMap.get("fcv1")
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
this.logService.error("Failed to fetch token entitlements", "No data returned");
|
|
840
|
-
} catch (error) {
|
|
841
|
-
this.logService.error("Failed to fetch token entitlements", getErrorMessage(error));
|
|
842
|
-
}
|
|
843
|
-
return undefined;
|
|
844
|
-
}
|
|
845
|
-
async getEntitlements(sessions, accountPolicyData, options) {
|
|
846
|
-
const accountId = sessions[0].account.id;
|
|
847
|
-
const existingData = this._defaultAccount?.accountId === accountId ? this._defaultAccount?.defaultAccount.entitlementsData : undefined;
|
|
848
|
-
if (!options?.forceRefresh && !options?.refreshEntitlements && existingData && accountPolicyData?.entitlementsFetchedAt && !this.isDataStale(accountPolicyData.entitlementsFetchedAt)) {
|
|
849
|
-
this.logService.debug("[DefaultAccount] Using last fetched entitlements data");
|
|
850
|
-
return {
|
|
851
|
-
data: existingData,
|
|
852
|
-
fetchedAt: accountPolicyData.entitlementsFetchedAt
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
const entitlementUrl = this.getEntitlementUrl();
|
|
856
|
-
if (!entitlementUrl) {
|
|
857
|
-
this.logService.debug("[DefaultAccount] No chat entitlements URL found");
|
|
858
|
-
return {
|
|
859
|
-
data: undefined,
|
|
860
|
-
fetchedAt: undefined
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
this.logService.debug("[DefaultAccount] Fetching entitlements from:", entitlementUrl);
|
|
864
|
-
const response = await this.request(
|
|
865
|
-
entitlementUrl,
|
|
866
|
-
"GET",
|
|
867
|
-
undefined,
|
|
868
|
-
sessions,
|
|
869
|
-
CancellationToken.None,
|
|
870
|
-
"defaultAccount.entitlements"
|
|
871
|
-
);
|
|
872
|
-
if (!response) {
|
|
873
|
-
return {
|
|
874
|
-
data: undefined,
|
|
875
|
-
fetchedAt: Date.now()
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
if (response.res.statusCode && response.res.statusCode !== 200) {
|
|
879
|
-
this.logService.trace(
|
|
880
|
-
`[DefaultAccount] unexpected status code ${response.res.statusCode} while fetching entitlements`
|
|
881
|
-
);
|
|
882
|
-
const data =
|
|
883
|
-
(
|
|
884
|
-
response.res.statusCode === 401 || response.res.statusCode === 404) ? null : undefined;
|
|
885
|
-
return {
|
|
886
|
-
data,
|
|
887
|
-
fetchedAt: Date.now()
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
try {
|
|
891
|
-
const data = await asJson(response);
|
|
892
|
-
if (data) {
|
|
893
|
-
return {
|
|
894
|
-
data,
|
|
895
|
-
fetchedAt: Date.now()
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
this.logService.error("[DefaultAccount] Failed to fetch entitlements", "No data returned");
|
|
899
|
-
} catch (error) {
|
|
900
|
-
this.logService.error("[DefaultAccount] Failed to fetch entitlements", getErrorMessage(error));
|
|
901
|
-
}
|
|
902
|
-
return {
|
|
903
|
-
data: undefined,
|
|
904
|
-
fetchedAt: Date.now()
|
|
905
|
-
};
|
|
906
|
-
}
|
|
907
|
-
async getMcpRegistryProvider(sessions, accountPolicyData, options) {
|
|
908
|
-
if (!options?.forceRefresh && accountPolicyData?.mcpRegistryDataFetchedAt && !this.isDataStale(accountPolicyData.mcpRegistryDataFetchedAt)) {
|
|
909
|
-
this.logService.debug("[DefaultAccount] Using last fetched MCP registry data");
|
|
910
|
-
const data = accountPolicyData.policyData.mcpRegistryUrl && accountPolicyData.policyData.mcpAccess ? {
|
|
911
|
-
url: accountPolicyData.policyData.mcpRegistryUrl,
|
|
912
|
-
registry_access: accountPolicyData.policyData.mcpAccess
|
|
913
|
-
} : null;
|
|
914
|
-
return {
|
|
915
|
-
data,
|
|
916
|
-
fetchedAt: accountPolicyData.mcpRegistryDataFetchedAt
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
const data = await this.requestMcpRegistryProvider(sessions);
|
|
920
|
-
return !isUndefined(data) ? {
|
|
921
|
-
data,
|
|
922
|
-
fetchedAt: Date.now()
|
|
923
|
-
} : undefined;
|
|
924
|
-
}
|
|
925
|
-
async requestMcpRegistryProvider(sessions) {
|
|
926
|
-
const mcpRegistryDataUrl = this.getMcpRegistryDataUrl();
|
|
927
|
-
if (!mcpRegistryDataUrl) {
|
|
928
|
-
this.logService.debug("[DefaultAccount] No MCP registry data URL found");
|
|
929
|
-
return null;
|
|
930
|
-
}
|
|
931
|
-
this.logService.debug("[DefaultAccount] Fetching MCP registry data from:", mcpRegistryDataUrl);
|
|
932
|
-
const response = await this.request(
|
|
933
|
-
mcpRegistryDataUrl,
|
|
934
|
-
"GET",
|
|
935
|
-
undefined,
|
|
936
|
-
sessions,
|
|
937
|
-
CancellationToken.None,
|
|
938
|
-
"defaultAccount.mcpRegistryProvider"
|
|
939
|
-
);
|
|
940
|
-
if (!response) {
|
|
941
|
-
return undefined;
|
|
942
|
-
}
|
|
943
|
-
if (!isSuccess(response)) {
|
|
944
|
-
if (isClientError(response)) {
|
|
945
|
-
this.logService.debug(
|
|
946
|
-
`[DefaultAccount] Received ${response.res.statusCode} for MCP registry data, treating as no registry available.`
|
|
947
|
-
);
|
|
948
|
-
return null;
|
|
949
|
-
}
|
|
950
|
-
this.logService.debug(
|
|
951
|
-
`[DefaultAccount] unexpected status code ${response.res.statusCode} while fetching MCP registry data`
|
|
952
|
-
);
|
|
953
|
-
return undefined;
|
|
954
|
-
}
|
|
955
|
-
try {
|
|
956
|
-
const data = await asJson(response);
|
|
957
|
-
if (data) {
|
|
958
|
-
this.logService.debug("Fetched MCP registry providers", data.mcp_registries);
|
|
959
|
-
return data.mcp_registries[0] ?? null;
|
|
960
|
-
}
|
|
961
|
-
this.logService.debug("No MCP registry providers content found in response");
|
|
962
|
-
return null;
|
|
963
|
-
} catch (error) {
|
|
964
|
-
this.logService.error("Failed to fetch MCP registry providers", getErrorMessage(error));
|
|
965
|
-
return undefined;
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
async getManagedSettings(
|
|
969
|
-
sessions,
|
|
970
|
-
accountPolicyData,
|
|
971
|
-
options,
|
|
972
|
-
authenticationProvider = this.getDefaultAccountAuthenticationProvider(),
|
|
973
|
-
managedSettingsSources,
|
|
974
|
-
refreshRequirement
|
|
975
|
-
) {
|
|
976
|
-
const accountId = sessions[0].account.id;
|
|
977
|
-
const sources = managedSettingsSources ?? (await this.initializeManagedSettingsSources());
|
|
978
|
-
const requirement = refreshRequirement ?? resolveForceRemoteSettingsRefresh(
|
|
979
|
-
sources.nativeMdm,
|
|
980
|
-
this.getScopedServerManagedSettings(accountPolicyData, authenticationProvider, accountId),
|
|
981
|
-
sources.file
|
|
982
|
-
);
|
|
983
|
-
const cachedManagedSettings = accountPolicyData?.managedSettingsFetchedAt !== undefined && !this.isDataStale(accountPolicyData.managedSettingsFetchedAt) ? {
|
|
984
|
-
data: {
|
|
985
|
-
managedSettings: accountPolicyData.policyData.managedSettings
|
|
986
|
-
},
|
|
987
|
-
fetchedAt: accountPolicyData.managedSettingsFetchedAt
|
|
988
|
-
} : undefined;
|
|
989
|
-
const managedSettingsUrl = this.getManagedSettingsUrl();
|
|
990
|
-
if (!managedSettingsUrl) {
|
|
991
|
-
this.logService.debug(
|
|
992
|
-
"[DefaultAccount] No managed settings URL configured; skipping enterprise policy fetch"
|
|
993
|
-
);
|
|
994
|
-
this._managedSettingsFetchStatus = "no-url";
|
|
995
|
-
if (requirement.effective) {
|
|
996
|
-
this.setManagedSettingsFreshness({
|
|
997
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
998
|
-
source: requirement.source,
|
|
999
|
-
failure: ManagedSettingsFreshnessFailure.NoUrl
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
const retained = requirement.effective ? {
|
|
1003
|
-
data: {
|
|
1004
|
-
managedSettings: accountPolicyData?.policyData.managedSettings
|
|
1005
|
-
},
|
|
1006
|
-
fetchedAt: accountPolicyData?.managedSettingsFetchedAt
|
|
1007
|
-
} : cachedManagedSettings;
|
|
1008
|
-
return {
|
|
1009
|
-
data: retained?.data,
|
|
1010
|
-
fetchedAt: retained?.fetchedAt,
|
|
1011
|
-
scope: accountPolicyData?.managedSettingsScope,
|
|
1012
|
-
compatibilityError: this._managedSettingsCompatibilityError
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
const scope = this.createManagedSettingsFreshnessScope(accountId, authenticationProvider.id, managedSettingsUrl);
|
|
1016
|
-
const cachedScope = accountPolicyData?.managedSettingsScope;
|
|
1017
|
-
const cacheScopeMatches = !cachedScope || this.getManagedSettingsScopeKey(cachedScope) === this.getManagedSettingsScopeKey(scope);
|
|
1018
|
-
const scopedManagedSettings = cacheScopeMatches ? accountPolicyData?.policyData.managedSettings : undefined;
|
|
1019
|
-
const scopedManagedSettingsFetchedAt = cacheScopeMatches ? accountPolicyData?.managedSettingsFetchedAt : undefined;
|
|
1020
|
-
const scopedCachedManagedSettings = cacheScopeMatches ? cachedManagedSettings : undefined;
|
|
1021
|
-
if (requirement.effective && !this.canRequestManagedSettings(options, scope)) {
|
|
1022
|
-
this.logService.debug(
|
|
1023
|
-
"[DefaultAccount] Skipping automatic managed settings retry after a prior failure"
|
|
1024
|
-
);
|
|
1025
|
-
const failedFreshness = this.failedManagedSettingsFreshness.get(this.getManagedSettingsScopeKey(scope));
|
|
1026
|
-
if (failedFreshness) {
|
|
1027
|
-
this.setManagedSettingsFreshness({
|
|
1028
|
-
...failedFreshness,
|
|
1029
|
-
source: requirement.source
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
return {
|
|
1033
|
-
data: {
|
|
1034
|
-
managedSettings: scopedManagedSettings
|
|
1035
|
-
},
|
|
1036
|
-
fetchedAt: scopedManagedSettingsFetchedAt,
|
|
1037
|
-
scope,
|
|
1038
|
-
compatibilityError: this._managedSettingsCompatibilityError
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
const freshnessSatisfied = requirement.effective && isManagedSettingsFreshnessSatisfiedFor(this._managedSettingsFreshness, scope);
|
|
1042
|
-
if (!options?.forceRefresh && !options?.retryManagedSettings && scopedCachedManagedSettings && (!requirement.effective || freshnessSatisfied) && !this._managedSettingsCompatibilityError) {
|
|
1043
|
-
this.logService.debug("[DefaultAccount] Using last fetched managed settings data");
|
|
1044
|
-
return {
|
|
1045
|
-
...scopedCachedManagedSettings,
|
|
1046
|
-
scope,
|
|
1047
|
-
compatibilityError: this._managedSettingsCompatibilityError
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
const lastAttemptAt = Date.now();
|
|
1051
|
-
if (requirement.effective) {
|
|
1052
|
-
this.setManagedSettingsFreshness({
|
|
1053
|
-
state: ManagedSettingsFreshnessState.Pending,
|
|
1054
|
-
source: requirement.source,
|
|
1055
|
-
scope,
|
|
1056
|
-
lastAttemptAt
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
const sharedBackoffActive = Date.now() < this._rateLimitBackoffUntil;
|
|
1060
|
-
const result = await this.requestManagedSettings(requirement.effective ? [sessions[0]] : sessions, managedSettingsUrl);
|
|
1061
|
-
if (requirement.effective && !sharedBackoffActive) {
|
|
1062
|
-
this.updateFailedManagedSettingsFreshness(scope, requirement.source, result, lastAttemptAt);
|
|
1063
|
-
}
|
|
1064
|
-
switch (result.kind) {
|
|
1065
|
-
case "success":
|
|
1066
|
-
{
|
|
1067
|
-
const fetchedAt = Date.now();
|
|
1068
|
-
this.resolveManagedSettingsFreshnessAfterSuccess(result.data.managedSettings, scope, lastAttemptAt, fetchedAt);
|
|
1069
|
-
return {
|
|
1070
|
-
data: result.data,
|
|
1071
|
-
fetchedAt,
|
|
1072
|
-
scope,
|
|
1073
|
-
compatibilityError: null
|
|
1074
|
-
};
|
|
1075
|
-
}
|
|
1076
|
-
case "noSettings":
|
|
1077
|
-
{
|
|
1078
|
-
const fetchedAt = Date.now();
|
|
1079
|
-
this.resolveManagedSettingsFreshnessAfterSuccess(undefined, scope, lastAttemptAt, fetchedAt);
|
|
1080
|
-
return {
|
|
1081
|
-
data: {
|
|
1082
|
-
managedSettings: undefined
|
|
1083
|
-
},
|
|
1084
|
-
fetchedAt,
|
|
1085
|
-
scope,
|
|
1086
|
-
compatibilityError: null
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
case "updateRequired":
|
|
1090
|
-
if (requirement.effective) {
|
|
1091
|
-
this.setManagedSettingsFreshness({
|
|
1092
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
1093
|
-
source: requirement.source,
|
|
1094
|
-
scope,
|
|
1095
|
-
lastAttemptAt,
|
|
1096
|
-
failure: ManagedSettingsFreshnessFailure.UpdateRequired
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
return {
|
|
1100
|
-
data: requirement.effective ? {
|
|
1101
|
-
managedSettings: scopedManagedSettings
|
|
1102
|
-
} : {
|
|
1103
|
-
managedSettings: undefined
|
|
1104
|
-
},
|
|
1105
|
-
fetchedAt: requirement.effective ? scopedManagedSettingsFetchedAt : Date.now(),
|
|
1106
|
-
scope,
|
|
1107
|
-
compatibilityError: result.error
|
|
1108
|
-
};
|
|
1109
|
-
case "network":
|
|
1110
|
-
case "rateLimited":
|
|
1111
|
-
case "httpError":
|
|
1112
|
-
case "malformed":
|
|
1113
|
-
{
|
|
1114
|
-
if (requirement.effective) {
|
|
1115
|
-
this.setManagedSettingsFreshness(
|
|
1116
|
-
this.toBlockedManagedSettingsFreshness(requirement.source, result, lastAttemptAt, scope)
|
|
1117
|
-
);
|
|
1118
|
-
return {
|
|
1119
|
-
data: {
|
|
1120
|
-
managedSettings: scopedManagedSettings
|
|
1121
|
-
},
|
|
1122
|
-
fetchedAt: scopedManagedSettingsFetchedAt,
|
|
1123
|
-
scope,
|
|
1124
|
-
compatibilityError: this._managedSettingsCompatibilityError
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
const retained = this._managedSettingsCompatibilityError ? undefined : scopedCachedManagedSettings;
|
|
1128
|
-
return {
|
|
1129
|
-
data: {
|
|
1130
|
-
managedSettings: retained?.data.managedSettings
|
|
1131
|
-
},
|
|
1132
|
-
fetchedAt: retained?.fetchedAt,
|
|
1133
|
-
scope,
|
|
1134
|
-
compatibilityError: this._managedSettingsCompatibilityError
|
|
1135
|
-
};
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
createManagedSettingsFreshnessScope(accountId, authenticationProviderId, managedSettingsUrl) {
|
|
1140
|
-
let endpointOrigin = managedSettingsUrl;
|
|
1141
|
-
try {
|
|
1142
|
-
endpointOrigin = ( new URL(managedSettingsUrl)).origin;
|
|
1143
|
-
} catch {}
|
|
1144
|
-
return {
|
|
1145
|
-
accountId,
|
|
1146
|
-
authenticationProviderId,
|
|
1147
|
-
endpointOrigin
|
|
1148
|
-
};
|
|
1149
|
-
}
|
|
1150
|
-
resolveManagedSettingsFreshnessAfterSuccess(server, scope, lastAttemptAt, satisfiedAt) {
|
|
1151
|
-
const freshRequirement = resolveForceRemoteSettingsRefresh(
|
|
1152
|
-
this.nativeManagedSettingsService.managedSettings,
|
|
1153
|
-
server,
|
|
1154
|
-
this.fileManagedSettingsService.managedSettings
|
|
1155
|
-
);
|
|
1156
|
-
this.setManagedSettingsFreshness(freshRequirement.effective ? {
|
|
1157
|
-
state: ManagedSettingsFreshnessState.Satisfied,
|
|
1158
|
-
source: freshRequirement.source,
|
|
1159
|
-
scope,
|
|
1160
|
-
lastAttemptAt,
|
|
1161
|
-
satisfiedAt
|
|
1162
|
-
} : MANAGED_SETTINGS_FRESHNESS_NOT_REQUIRED);
|
|
1163
|
-
}
|
|
1164
|
-
toBlockedManagedSettingsFreshness(source, result, lastAttemptAt, scope) {
|
|
1165
|
-
switch (result.kind) {
|
|
1166
|
-
case "network":
|
|
1167
|
-
return {
|
|
1168
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
1169
|
-
source,
|
|
1170
|
-
scope,
|
|
1171
|
-
lastAttemptAt,
|
|
1172
|
-
failure: ManagedSettingsFreshnessFailure.Network
|
|
1173
|
-
};
|
|
1174
|
-
case "rateLimited":
|
|
1175
|
-
return {
|
|
1176
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
1177
|
-
source,
|
|
1178
|
-
scope,
|
|
1179
|
-
lastAttemptAt,
|
|
1180
|
-
failure: ManagedSettingsFreshnessFailure.RateLimited
|
|
1181
|
-
};
|
|
1182
|
-
case "httpError":
|
|
1183
|
-
return {
|
|
1184
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
1185
|
-
source,
|
|
1186
|
-
scope,
|
|
1187
|
-
lastAttemptAt,
|
|
1188
|
-
failure: ManagedSettingsFreshnessFailure.HttpError,
|
|
1189
|
-
httpStatus: result.status
|
|
1190
|
-
};
|
|
1191
|
-
case "malformed":
|
|
1192
|
-
return {
|
|
1193
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
1194
|
-
source,
|
|
1195
|
-
scope,
|
|
1196
|
-
lastAttemptAt,
|
|
1197
|
-
failure: ManagedSettingsFreshnessFailure.Malformed
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
async requestManagedSettings(sessions, managedSettingsUrl) {
|
|
1202
|
-
const requestUrl = appendManagedSettingsClientIdentity(managedSettingsUrl, this.productService);
|
|
1203
|
-
this.logService.debug("[DefaultAccount] Fetching managed settings from:", requestUrl);
|
|
1204
|
-
const rateLimitBackoffActive = Date.now() < this._rateLimitBackoffUntil;
|
|
1205
|
-
const response = await this.request(
|
|
1206
|
-
requestUrl,
|
|
1207
|
-
"GET",
|
|
1208
|
-
undefined,
|
|
1209
|
-
sessions,
|
|
1210
|
-
CancellationToken.None,
|
|
1211
|
-
"defaultAccount.managedSettings",
|
|
1212
|
-
{
|
|
1213
|
-
requestTimeoutMs: MANAGED_SETTINGS_REQUEST_TIMEOUT_MS,
|
|
1214
|
-
retryNotFound: false
|
|
1215
|
-
}
|
|
1216
|
-
);
|
|
1217
|
-
if (!response) {
|
|
1218
|
-
this.logService.debug(
|
|
1219
|
-
"[DefaultAccount] Managed settings fetch returned no response (network error, all selected sessions rejected, or active rate-limit backoff); falling back to local-only policy"
|
|
1220
|
-
);
|
|
1221
|
-
this.reportManagedSettingsOutcome("no-response", rateLimitBackoffActive);
|
|
1222
|
-
return rateLimitBackoffActive ? {
|
|
1223
|
-
kind: "rateLimited"
|
|
1224
|
-
} : {
|
|
1225
|
-
kind: "network"
|
|
1226
|
-
};
|
|
1227
|
-
}
|
|
1228
|
-
const status = response.res.statusCode ?? 0;
|
|
1229
|
-
if (status === 404) {
|
|
1230
|
-
this.reportManagedSettingsOutcome(status, rateLimitBackoffActive);
|
|
1231
|
-
return {
|
|
1232
|
-
kind: "noSettings"
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
if (status === 466) {
|
|
1236
|
-
const error = await this.readManagedSettingsCompatibilityError(response);
|
|
1237
|
-
this.setManagedSettingsCompatibilityError(error);
|
|
1238
|
-
this.reportManagedSettingsOutcome(status, rateLimitBackoffActive);
|
|
1239
|
-
return {
|
|
1240
|
-
kind: "updateRequired",
|
|
1241
|
-
error
|
|
1242
|
-
};
|
|
1243
|
-
}
|
|
1244
|
-
if (this.isRateLimited(response)) {
|
|
1245
|
-
this.reportManagedSettingsOutcome(status, rateLimitBackoffActive);
|
|
1246
|
-
return {
|
|
1247
|
-
kind: "rateLimited"
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
if (!isSuccess(response)) {
|
|
1251
|
-
this.logService.warn(
|
|
1252
|
-
`[DefaultAccount] Managed settings fetch returned non-success status ${status}; falling back to local-only policy`
|
|
1253
|
-
);
|
|
1254
|
-
this.reportManagedSettingsOutcome(status, rateLimitBackoffActive);
|
|
1255
|
-
return {
|
|
1256
|
-
kind: "httpError",
|
|
1257
|
-
status
|
|
1258
|
-
};
|
|
1259
|
-
}
|
|
1260
|
-
try {
|
|
1261
|
-
const data = await asJson(response);
|
|
1262
|
-
this.logService.trace(
|
|
1263
|
-
"[DefaultAccount] Managed settings raw response:",
|
|
1264
|
-
JSON.stringify(data ?? null)
|
|
1265
|
-
);
|
|
1266
|
-
this._managedSettingsRawResponse = data ?? null;
|
|
1267
|
-
const adapted = adaptManagedSettings(data ?? {}, msg => this.logService.warn(msg));
|
|
1268
|
-
const managedSettingsCount = adapted.managedSettings ? ( Object.keys(adapted.managedSettings)).length : 0;
|
|
1269
|
-
if (managedSettingsCount === 0 && adapted.managedSettingsActive !== true) {
|
|
1270
|
-
this.logService.debug(
|
|
1271
|
-
"[DefaultAccount] Managed settings fetched (empty response — no enterprise policy file present)"
|
|
1272
|
-
);
|
|
1273
|
-
} else {
|
|
1274
|
-
this.logService.info("[DefaultAccount] Managed settings applied");
|
|
1275
|
-
this.logService.trace("[DefaultAccount] Managed settings payload:", JSON.stringify(adapted));
|
|
1276
|
-
}
|
|
1277
|
-
this.reportManagedSettingsOutcome("ok", rateLimitBackoffActive);
|
|
1278
|
-
return {
|
|
1279
|
-
kind: "success",
|
|
1280
|
-
data: adapted
|
|
1281
|
-
};
|
|
1282
|
-
} catch (error) {
|
|
1283
|
-
this.logService.error(
|
|
1284
|
-
"[DefaultAccount] Failed to parse managed settings response",
|
|
1285
|
-
getErrorMessage(error)
|
|
1286
|
-
);
|
|
1287
|
-
this.reportManagedSettingsOutcome("parse-error", rateLimitBackoffActive);
|
|
1288
|
-
return {
|
|
1289
|
-
kind: "malformed"
|
|
1290
|
-
};
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
canRequestManagedSettings(options, scope) {
|
|
1294
|
-
return options?.retryManagedSettings === true || scope === undefined || !( this.failedManagedSettingsFreshness.has(this.getManagedSettingsScopeKey(scope)));
|
|
1295
|
-
}
|
|
1296
|
-
updateFailedManagedSettingsFreshness(scope, source, result, lastAttemptAt) {
|
|
1297
|
-
const scopeKey = this.getManagedSettingsScopeKey(scope);
|
|
1298
|
-
switch (result.kind) {
|
|
1299
|
-
case "success":
|
|
1300
|
-
case "noSettings":
|
|
1301
|
-
this.failedManagedSettingsFreshness.delete(scopeKey);
|
|
1302
|
-
break;
|
|
1303
|
-
case "updateRequired":
|
|
1304
|
-
{
|
|
1305
|
-
this.failedManagedSettingsFreshness.set(scopeKey, {
|
|
1306
|
-
state: ManagedSettingsFreshnessState.Blocked,
|
|
1307
|
-
source,
|
|
1308
|
-
scope,
|
|
1309
|
-
lastAttemptAt,
|
|
1310
|
-
failure: ManagedSettingsFreshnessFailure.UpdateRequired
|
|
1311
|
-
});
|
|
1312
|
-
break;
|
|
1313
|
-
}
|
|
1314
|
-
case "network":
|
|
1315
|
-
case "rateLimited":
|
|
1316
|
-
case "httpError":
|
|
1317
|
-
case "malformed":
|
|
1318
|
-
{
|
|
1319
|
-
this.failedManagedSettingsFreshness.set(
|
|
1320
|
-
scopeKey,
|
|
1321
|
-
this.toBlockedManagedSettingsFreshness(source, result, lastAttemptAt, scope)
|
|
1322
|
-
);
|
|
1323
|
-
break;
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
getManagedSettingsScopeKey(scope) {
|
|
1328
|
-
return `${scope.authenticationProviderId}\n${scope.accountId}\n${scope.endpointOrigin}`;
|
|
1329
|
-
}
|
|
1330
|
-
async readManagedSettingsCompatibilityError(response) {
|
|
1331
|
-
try {
|
|
1332
|
-
const text = await asText(response);
|
|
1333
|
-
const body = text ? JSON.parse(text) : undefined;
|
|
1334
|
-
const parsed = parseManagedSettingsCompatibilityError(body);
|
|
1335
|
-
if (parsed) {
|
|
1336
|
-
return parsed;
|
|
1337
|
-
}
|
|
1338
|
-
this.logService.error(
|
|
1339
|
-
"[DefaultAccount] Managed settings compatibility response did not contain the expected error code"
|
|
1340
|
-
);
|
|
1341
|
-
} catch (error) {
|
|
1342
|
-
this.logService.error(
|
|
1343
|
-
"[DefaultAccount] Failed to parse managed settings compatibility response",
|
|
1344
|
-
getErrorMessage(error)
|
|
1345
|
-
);
|
|
1346
|
-
}
|
|
1347
|
-
return {
|
|
1348
|
-
errorCode: MANAGED_SETTINGS_UPDATE_REQUIRED_ERROR_CODE
|
|
1349
|
-
};
|
|
1350
|
-
}
|
|
1351
|
-
reportManagedSettingsOutcome(status, rateLimitBackoffActive) {
|
|
1352
|
-
this._managedSettingsFetchStatus = status;
|
|
1353
|
-
this.telemetryService.publicLog2("defaultaccount:managedSettings:fetch", {
|
|
1354
|
-
outcome: typeof status === "number" ? `status:${status}` : status,
|
|
1355
|
-
rateLimitBackoffActive
|
|
1356
|
-
});
|
|
1357
|
-
}
|
|
1358
|
-
isRateLimited(response) {
|
|
1359
|
-
const status = response.res.statusCode;
|
|
1360
|
-
if (status === 429) {
|
|
1361
|
-
return true;
|
|
1362
|
-
}
|
|
1363
|
-
if (status === 403 && readHeader(response.res.headers, "x-ratelimit-remaining") === "0") {
|
|
1364
|
-
return true;
|
|
1365
|
-
}
|
|
1366
|
-
if (!isSuccess(response) && readHeader(response.res.headers, "retry-after") !== undefined) {
|
|
1367
|
-
return true;
|
|
1368
|
-
}
|
|
1369
|
-
return false;
|
|
1370
|
-
}
|
|
1371
|
-
async request(url, type, body, sessions, token, callSite, options) {
|
|
1372
|
-
if (Date.now() < this._rateLimitBackoffUntil) {
|
|
1373
|
-
const remainingSec = Math.ceil((this._rateLimitBackoffUntil - Date.now()) / 1000);
|
|
1374
|
-
this.logService.debug(
|
|
1375
|
-
`[DefaultAccount] Skipping request to ${url} — rate-limit backoff active for ${remainingSec}s more`
|
|
1376
|
-
);
|
|
1377
|
-
return undefined;
|
|
1378
|
-
}
|
|
1379
|
-
let lastResponse;
|
|
1380
|
-
for (const session of sessions) {
|
|
1381
|
-
if (token.isCancellationRequested) {
|
|
1382
|
-
return lastResponse;
|
|
1383
|
-
}
|
|
1384
|
-
try {
|
|
1385
|
-
const response = await this.requestService.request({
|
|
1386
|
-
type,
|
|
1387
|
-
url,
|
|
1388
|
-
data: type === "POST" ? JSON.stringify(body) : undefined,
|
|
1389
|
-
disableCache: true,
|
|
1390
|
-
timeout: options?.requestTimeoutMs,
|
|
1391
|
-
headers: {
|
|
1392
|
-
"Authorization": `Bearer ${session.accessToken}`
|
|
1393
|
-
},
|
|
1394
|
-
callSite
|
|
1395
|
-
}, token);
|
|
1396
|
-
const status = response.res.statusCode;
|
|
1397
|
-
if (this.isRateLimited(response)) {
|
|
1398
|
-
const retryAfterSec = retryAfterFromHeaders(response.res.headers) ?? 60;
|
|
1399
|
-
this._rateLimitBackoffUntil = Date.now() + retryAfterSec * 1000;
|
|
1400
|
-
this.logService.warn(
|
|
1401
|
-
`[DefaultAccount] Rate limited by ${url} (status ${status}); backing off for ${retryAfterSec}s`
|
|
1402
|
-
);
|
|
1403
|
-
return response;
|
|
1404
|
-
}
|
|
1405
|
-
if (status === 401 || (status === 404 && options?.retryNotFound !== false)) {
|
|
1406
|
-
this.logService.debug(
|
|
1407
|
-
`[DefaultAccount] Received ${status} for URL ${url} with session ${session.id}, likely due to expired/revoked token or insufficient permissions.`,
|
|
1408
|
-
"Trying next session if available."
|
|
1409
|
-
);
|
|
1410
|
-
lastResponse = response;
|
|
1411
|
-
continue;
|
|
1412
|
-
}
|
|
1413
|
-
return response;
|
|
1414
|
-
} catch (error) {
|
|
1415
|
-
if (!token.isCancellationRequested) {
|
|
1416
|
-
this.logService.error(`[DefaultAccount] request: error ${error}`, url);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
if (!lastResponse) {
|
|
1421
|
-
this.logService.trace("[DefaultAccount]: No response received for request", url);
|
|
1422
|
-
return undefined;
|
|
1423
|
-
}
|
|
1424
|
-
return lastResponse;
|
|
1425
|
-
}
|
|
1426
|
-
isDataStale(fetchedAt) {
|
|
1427
|
-
return (Date.now() - fetchedAt) >= ACCOUNT_DATA_POLL_INTERVAL_MS;
|
|
1428
|
-
}
|
|
1429
|
-
getEntitlementUrl() {
|
|
1430
|
-
if (this.getDefaultAccountAuthenticationProvider().enterprise) {
|
|
1431
|
-
try {
|
|
1432
|
-
const enterpriseUrl = this.getEnterpriseUrl();
|
|
1433
|
-
if (!enterpriseUrl) {
|
|
1434
|
-
return undefined;
|
|
1435
|
-
}
|
|
1436
|
-
return `${enterpriseUrl.protocol}//api.${enterpriseUrl.hostname}${enterpriseUrl.port ? ":" + enterpriseUrl.port : ""}/copilot_internal/user`;
|
|
1437
|
-
} catch (error) {
|
|
1438
|
-
this.logService.error(error);
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
return this.defaultAccountConfig.entitlementUrl;
|
|
1442
|
-
}
|
|
1443
|
-
getTokenEntitlementUrl() {
|
|
1444
|
-
if (this.getDefaultAccountAuthenticationProvider().enterprise) {
|
|
1445
|
-
try {
|
|
1446
|
-
const enterpriseUrl = this.getEnterpriseUrl();
|
|
1447
|
-
if (!enterpriseUrl) {
|
|
1448
|
-
return undefined;
|
|
1449
|
-
}
|
|
1450
|
-
return `${enterpriseUrl.protocol}//api.${enterpriseUrl.hostname}${enterpriseUrl.port ? ":" + enterpriseUrl.port : ""}/copilot_internal/v2/token`;
|
|
1451
|
-
} catch (error) {
|
|
1452
|
-
this.logService.error(error);
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
return this.defaultAccountConfig.tokenEntitlementUrl;
|
|
1456
|
-
}
|
|
1457
|
-
getMcpRegistryDataUrl() {
|
|
1458
|
-
if (this.getDefaultAccountAuthenticationProvider().enterprise) {
|
|
1459
|
-
try {
|
|
1460
|
-
const enterpriseUrl = this.getEnterpriseUrl();
|
|
1461
|
-
if (!enterpriseUrl) {
|
|
1462
|
-
return undefined;
|
|
1463
|
-
}
|
|
1464
|
-
return `${enterpriseUrl.protocol}//api.${enterpriseUrl.hostname}${enterpriseUrl.port ? ":" + enterpriseUrl.port : ""}/copilot/mcp_registry`;
|
|
1465
|
-
} catch (error) {
|
|
1466
|
-
this.logService.error(error);
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
return this.defaultAccountConfig.mcpRegistryDataUrl;
|
|
1470
|
-
}
|
|
1471
|
-
getManagedSettingsUrl() {
|
|
1472
|
-
if (this.getDefaultAccountAuthenticationProvider().enterprise) {
|
|
1473
|
-
try {
|
|
1474
|
-
const enterpriseUrl = this.getEnterpriseUrl();
|
|
1475
|
-
if (!enterpriseUrl) {
|
|
1476
|
-
return undefined;
|
|
1477
|
-
}
|
|
1478
|
-
return `${enterpriseUrl.protocol}//api.${enterpriseUrl.hostname}${enterpriseUrl.port ? ":" + enterpriseUrl.port : ""}/copilot_internal/managed_settings`;
|
|
1479
|
-
} catch (error) {
|
|
1480
|
-
this.logService.error(error);
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
return this.defaultAccountConfig.managedSettingsUrl;
|
|
1484
|
-
}
|
|
1485
|
-
getDefaultAccountAuthenticationProvider() {
|
|
1486
|
-
if (this.configurationService.getValue(this.defaultAccountConfig.authenticationProvider.enterpriseProviderConfig) === this.defaultAccountConfig.authenticationProvider.enterprise.id) {
|
|
1487
|
-
return {
|
|
1488
|
-
...this.defaultAccountConfig.authenticationProvider.enterprise,
|
|
1489
|
-
enterprise: true
|
|
1490
|
-
};
|
|
1491
|
-
}
|
|
1492
|
-
return {
|
|
1493
|
-
...this.defaultAccountConfig.authenticationProvider.default,
|
|
1494
|
-
enterprise: false
|
|
1495
|
-
};
|
|
1496
|
-
}
|
|
1497
|
-
resolveGitHubUrl(path) {
|
|
1498
|
-
if (this.getDefaultAccountAuthenticationProvider().enterprise) {
|
|
1499
|
-
try {
|
|
1500
|
-
const enterpriseUrl = this.getEnterpriseUrl();
|
|
1501
|
-
if (enterpriseUrl) {
|
|
1502
|
-
return `${enterpriseUrl.protocol}//${enterpriseUrl.host}/${path}`;
|
|
1503
|
-
}
|
|
1504
|
-
} catch {}
|
|
1505
|
-
}
|
|
1506
|
-
return `https://github.com/${path}`;
|
|
1507
|
-
}
|
|
1508
|
-
getEnterpriseUrl() {
|
|
1509
|
-
const value = this.configurationService.getValue(
|
|
1510
|
-
this.defaultAccountConfig.authenticationProvider.enterpriseProviderUriSetting
|
|
1511
|
-
);
|
|
1512
|
-
if (!isString(value)) {
|
|
1513
|
-
return undefined;
|
|
1514
|
-
}
|
|
1515
|
-
return ( new URL(value));
|
|
1516
|
-
}
|
|
1517
|
-
async signIn(options) {
|
|
1518
|
-
const authProvider = this.getDefaultAccountAuthenticationProvider();
|
|
1519
|
-
if (!authProvider) {
|
|
1520
|
-
throw ( new Error("No default account provider configured"));
|
|
1521
|
-
}
|
|
1522
|
-
const {
|
|
1523
|
-
additionalScopes,
|
|
1524
|
-
...sessionOptions
|
|
1525
|
-
} = options ?? {};
|
|
1526
|
-
const defaultAccountScopes = this.defaultAccountConfig.authenticationProvider.scopes[0];
|
|
1527
|
-
const scopes = additionalScopes ? distinct([...defaultAccountScopes, ...additionalScopes]) : defaultAccountScopes;
|
|
1528
|
-
const session = await this.authenticationService.createSession(authProvider.id, scopes, sessionOptions);
|
|
1529
|
-
for (const preferredExtension of this.defaultAccountConfig.preferredExtensions) {
|
|
1530
|
-
this.authenticationExtensionsService.updateAccountPreference(preferredExtension, authProvider.id, session.account);
|
|
1531
|
-
}
|
|
1532
|
-
await this.updateDefaultAccount();
|
|
1533
|
-
return this.defaultAccount;
|
|
1534
|
-
}
|
|
1535
|
-
async signOut() {
|
|
1536
|
-
if (!this.defaultAccount) {
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
1539
|
-
await this.commandService.executeCommand("_signOutOfAccount", {
|
|
1540
|
-
providerId: this.defaultAccount.authenticationProvider.id,
|
|
1541
|
-
accountLabel: this.defaultAccount.accountName
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1545
|
-
DefaultAccountProvider = ( __decorate([( __param(1, IConfigurationService)), ( __param(2, IAuthenticationService)), ( __param(3, IAuthenticationExtensionsService)), ( __param(4, ITelemetryService)), ( __param(5, IExtensionService)), ( __param(6, IRequestService)), ( __param(7, ILogService)), ( __param(8, IWorkbenchEnvironmentService)), ( __param(9, IProductService)), ( __param(10, IContextKeyService)), ( __param(11, IStorageService)), ( __param(12, IHostService)), ( __param(13, ICommandService)), ( __param(14, INativeManagedSettingsService)), ( __param(15, IFileManagedSettingsService))], DefaultAccountProvider));
|
|
1546
|
-
let DefaultAccountProviderContribution = class DefaultAccountProviderContribution extends Disposable {
|
|
1547
|
-
static {
|
|
1548
|
-
this.ID = "workbench.contributions.defaultAccountProvider";
|
|
1549
|
-
}
|
|
1550
|
-
constructor(productService, instantiationService, defaultAccountService) {
|
|
1551
|
-
super();
|
|
1552
|
-
if (productService.defaultChatAgent) {
|
|
1553
|
-
const defaultAccountProvider = this._register(instantiationService.createInstance(
|
|
1554
|
-
DefaultAccountProvider,
|
|
1555
|
-
toDefaultAccountConfig(productService.defaultChatAgent)
|
|
1556
|
-
));
|
|
1557
|
-
defaultAccountService.setDefaultAccountProvider(defaultAccountProvider);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
};
|
|
1561
|
-
DefaultAccountProviderContribution = ( __decorate([( __param(0, IProductService)), ( __param(1, IInstantiationService)), ( __param(2, IDefaultAccountService))], DefaultAccountProviderContribution));
|
|
1562
|
-
registerAction2(class extends Action2 {
|
|
1563
|
-
constructor() {
|
|
1564
|
-
super({
|
|
1565
|
-
id: DEFAULT_ACCOUNT_SIGN_IN_COMMAND,
|
|
1566
|
-
title: ( localize2(18953, "Sign In"))
|
|
1567
|
-
});
|
|
1568
|
-
}
|
|
1569
|
-
async run(accessor) {
|
|
1570
|
-
const defaultAccountService = accessor.get(IDefaultAccountService);
|
|
1571
|
-
await defaultAccountService.signIn();
|
|
1572
|
-
}
|
|
1573
|
-
});
|
|
1574
|
-
registerWorkbenchContribution2(
|
|
1575
|
-
DefaultAccountProviderContribution.ID,
|
|
1576
|
-
DefaultAccountProviderContribution,
|
|
1577
|
-
WorkbenchPhase.BlockStartup
|
|
1578
|
-
);
|
|
1579
|
-
|
|
1580
|
-
export { CONTEXT_DEFAULT_ACCOUNT_STATE, DEFAULT_ACCOUNT_SIGN_IN_COMMAND, DefaultAccountProvider, DefaultAccountStatus };
|