@codingame/monaco-vscode-api 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/missing-services.js +46 -0
- package/package.json +8 -8
- package/services.js +3 -3
- package/vscode/src/vs/base/browser/ui/scrollbar/scrollableElement.js +7 -1
- package/vscode/src/vs/base/browser/ui/splitview/paneview.js +4 -1
- package/vscode/src/vs/base/common/errors.js +11 -1
- package/vscode/src/vs/base/common/htmlContent.js +4 -1
- package/vscode/src/vs/base/common/observableInternal/reactions/autorun.js +54 -1
- package/vscode/src/vs/platform/agentHost/common/agent.js +9 -1
- package/vscode/src/vs/platform/agentHost/common/agentHostEnablementService.js +8 -8
- package/vscode/src/vs/platform/agentHost/common/agentHostSchema.js +103 -103
- package/vscode/src/vs/platform/agentHost/common/agentService.js +20 -2
- package/vscode/src/vs/platform/agentHost/common/customizationEnablement.js +8 -1
- package/vscode/src/vs/platform/agentHost/common/meta/agentWorkspaceContinuationMeta.js +8 -0
- package/vscode/src/vs/platform/agentHost/common/state/legacyProtocolCompatibility.d.ts +30 -0
- package/vscode/src/vs/platform/agentHost/common/state/legacyProtocolCompatibility.js +95 -0
- package/vscode/src/vs/platform/agentHost/common/state/sessionProtocol.js +3 -1
- package/vscode/src/vs/platform/agentHost/common/state/sessionState.js +154 -4
- package/vscode/src/vs/platform/browserView/common/browserPermissions.js +14 -14
- package/vscode/src/vs/platform/configuration/common/configurationRegistry.js +12 -12
- package/vscode/src/vs/platform/contextkey/browser/contextKeyService.js +1 -1
- package/vscode/src/vs/platform/contextkey/common/contextkey.js +10 -10
- package/vscode/src/vs/platform/contextkey/common/contextkeys.js +10 -10
- package/vscode/src/vs/platform/contextkey/common/scanner.js +5 -5
- package/vscode/src/vs/platform/dialogs/common/dialogs.js +9 -9
- package/vscode/src/vs/platform/dnd/browser/dnd.js +1 -1
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +14 -14
- package/vscode/src/vs/platform/extensionManagement/common/extensionNls.js +1 -1
- package/vscode/src/vs/platform/extensionManagement/common/extensionsScannerService.js +7 -7
- package/vscode/src/vs/platform/extensions/common/extensionValidator.js +19 -19
- package/vscode/src/vs/platform/files/browser/htmlFileSystemProvider.js +2 -2
- package/vscode/src/vs/platform/files/common/files.js +6 -6
- package/vscode/src/vs/platform/github/common/githubPullRequestMutationService.d.ts +150 -0
- package/vscode/src/vs/platform/github/common/githubQueryService.d.ts +187 -0
- package/vscode/src/vs/platform/github/common/githubService.service.d.ts +18 -0
- package/vscode/src/vs/platform/github/common/githubService.service.js +6 -0
- package/vscode/src/vs/platform/history/browser/contextScopedHistoryWidget.js +1 -1
- package/vscode/src/vs/platform/hover/browser/hoverWidget.js +1 -1
- package/vscode/src/vs/platform/hover/browser/updatableHoverWidget.js +1 -1
- package/vscode/src/vs/platform/keybinding/common/abstractKeybindingService.js +5 -5
- package/vscode/src/vs/platform/languagePacks/common/languagePacks.js +1 -1
- package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +3 -3
- package/vscode/src/vs/platform/list/browser/listService.js +25 -25
- package/vscode/src/vs/platform/log/common/log.js +6 -6
- package/vscode/src/vs/platform/markers/common/markerService.js +2 -2
- package/vscode/src/vs/platform/markers/common/markers.js +6 -6
- package/vscode/src/vs/platform/mcp/common/mcpManagementService.js +1 -1
- package/vscode/src/vs/platform/meteredConnection/common/meteredConnection.config.contribution.js +5 -5
- package/vscode/src/vs/platform/notification/common/notification.js +3 -3
- package/vscode/src/vs/platform/product/common/product.js +1 -1
- package/vscode/src/vs/platform/quickinput/browser/quickInput.js +10 -10
- package/vscode/src/vs/platform/quickinput/browser/quickInputActions.js +5 -5
- package/vscode/src/vs/platform/quickinput/browser/quickInputController.js +6 -6
- package/vscode/src/vs/platform/quickinput/browser/quickInputList.js +1 -1
- package/vscode/src/vs/platform/quickinput/browser/quickInputUtils.js +1 -1
- package/vscode/src/vs/platform/quickinput/browser/quickPickPin.js +2 -2
- package/vscode/src/vs/platform/quickinput/browser/tree/quickInputTreeAccessibilityProvider.js +1 -1
- package/vscode/src/vs/platform/quickinput/browser/tree/quickTree.js +1 -1
- package/vscode/src/vs/platform/request/common/request.js +20 -20
- package/vscode/src/vs/platform/telemetry/common/telemetryUtils.js +1 -1
- package/vscode/src/vs/platform/terminal/common/terminalPlatformConfiguration.js +34 -34
- package/vscode/src/vs/platform/terminal/common/terminalProfiles.js +1 -1
- package/vscode/src/vs/platform/theme/common/colorUtils.js +2 -2
- package/vscode/src/vs/platform/theme/common/colors/baseColors.js +19 -19
- package/vscode/src/vs/platform/theme/common/colors/chartsColors.js +8 -8
- package/vscode/src/vs/platform/theme/common/colors/editorColors.js +95 -95
- package/vscode/src/vs/platform/theme/common/colors/inputColors.js +48 -48
- package/vscode/src/vs/platform/theme/common/colors/listColors.js +36 -36
- package/vscode/src/vs/platform/theme/common/colors/menuColors.js +7 -7
- package/vscode/src/vs/platform/theme/common/colors/minimapColors.js +11 -11
- package/vscode/src/vs/platform/theme/common/colors/miscColors.js +16 -16
- package/vscode/src/vs/platform/theme/common/colors/quickpickColors.js +10 -10
- package/vscode/src/vs/platform/theme/common/colors/searchColors.js +3 -3
- package/vscode/src/vs/platform/theme/common/iconRegistry.js +7 -7
- package/vscode/src/vs/platform/theme/common/sizes/baseSizes.js +37 -37
- package/vscode/src/vs/platform/theme/common/tokenClassificationRegistry.js +42 -42
- package/vscode/src/vs/platform/undoRedo/common/undoRedoService.js +20 -20
- package/vscode/src/vs/platform/userDataProfile/common/userDataProfile.js +1 -1
- package/vscode/src/vs/platform/userDataSync/common/abstractSynchronizer.js +2 -2
- package/vscode/src/vs/platform/userDataSync/common/keybindingsSync.js +2 -2
- package/vscode/src/vs/platform/userDataSync/common/settingsSync.js +1 -1
- package/vscode/src/vs/platform/userDataSync/common/userDataSync.js +5 -5
- package/vscode/src/vs/platform/userDataSync/common/userDataSyncMachines.js +1 -1
- package/vscode/src/vs/platform/workspace/common/workspace.js +1 -1
- package/vscode/src/vs/workbench/api/browser/statusBarExtensionPoint.js +12 -12
- package/vscode/src/vs/workbench/api/common/extHostAuthentication.js +5 -5
- package/vscode/src/vs/workbench/api/common/extHostDiagnostics.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostExtensionService.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostLanguageFeatures.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostLanguageModels.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostLogService.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostNotebook.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostStatusBar.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostTelemetry.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTerminalService.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTunnelService.js +2 -2
- package/vscode/src/vs/workbench/api/common/extHostWorkspace.js +1 -1
- package/vscode/src/vs/workbench/api/common/jsonValidationExtensionPoint.js +18 -18
- package/vscode/src/vs/workbench/browser/actions/developerActions.js +40 -40
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +132 -132
- package/vscode/src/vs/workbench/browser/actions/textInputActions.js +6 -6
- package/vscode/src/vs/workbench/browser/actions/windowActions.js +29 -29
- package/vscode/src/vs/workbench/browser/actions/workspaceActions.js +21 -21
- package/vscode/src/vs/workbench/browser/actions/workspaceCommands.js +4 -4
- package/vscode/src/vs/workbench/browser/editor.js +2 -2
- package/vscode/src/vs/workbench/browser/labels.js +4 -4
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +23 -23
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions.js +25 -25
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +4 -4
- package/vscode/src/vs/workbench/browser/parts/compositeBar.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/compositeBarActions.js +9 -9
- package/vscode/src/vs/workbench/browser/parts/compositePart.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialog.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/editor/binaryDiffEditor.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/binaryEditor.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/editor/breadcrumbs.js +38 -38
- package/vscode/src/vs/workbench/browser/parts/editor/breadcrumbsControl.js +14 -14
- package/vscode/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/diffEditorCommands.js +7 -7
- package/vscode/src/vs/workbench/browser/parts/editor/editorActions.js +136 -136
- package/vscode/src/vs/workbench/browser/parts/editor/editorCommands.js +25 -25
- package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/editorGroupView.js +8 -8
- package/vscode/src/vs/workbench/browser/parts/editor/editorGroupWatermark.js +12 -12
- package/vscode/src/vs/workbench/browser/parts/editor/editorHeaderControl.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/editor/editorPanes.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/editorPlaceholder.js +10 -10
- package/vscode/src/vs/workbench/browser/parts/editor/editorQuickAccess.js +5 -5
- package/vscode/src/vs/workbench/browser/parts/editor/editorStatus.js +66 -66
- package/vscode/src/vs/workbench/browser/parts/editor/editorTabsControl.js +5 -5
- package/vscode/src/vs/workbench/browser/parts/editor/editorTypePicker.js +6 -6
- package/vscode/src/vs/workbench/browser/parts/editor/modalEditorPart.js +5 -5
- package/vscode/src/vs/workbench/browser/parts/editor/multiEditorTabsControl.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/editor/sideBySideEditor.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/textCodeEditor.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/editor/textDiffEditor.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/editor/textEditor.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/globalCompositeBar.js +19 -19
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationAccessibleView.d.ts +10 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationAccessibleView.js +126 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsActions.js +22 -22
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsAlerts.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCenter.js +6 -6
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCommands.js +13 -13
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsList.js +6 -6
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js +13 -13
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsToasts.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsViewer.js +12 -5
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +4 -4
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/panel/panelActions.js +27 -27
- package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +3 -3
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarActions.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/titlebar/menubarControl.js +11 -11
- package/vscode/src/vs/workbench/browser/parts/titlebar/titlebarActions.js +15 -15
- package/vscode/src/vs/workbench/browser/parts/titlebar/windowTitle.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/views/checkbox.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/views/treeView.js +10 -10
- package/vscode/src/vs/workbench/browser/parts/views/viewFilter.js +4 -4
- package/vscode/src/vs/workbench/browser/parts/views/viewPane.js +5 -5
- package/vscode/src/vs/workbench/browser/parts/views/viewPaneContainer.js +6 -6
- package/vscode/src/vs/workbench/browser/quickaccess.js +1 -1
- package/vscode/src/vs/workbench/browser/window.js +14 -14
- package/vscode/src/vs/workbench/browser/workbench.contribution.js +232 -232
- package/vscode/src/vs/workbench/common/configuration.js +9 -9
- package/vscode/src/vs/workbench/common/contextkeys.js +86 -86
- package/vscode/src/vs/workbench/common/editor/diffEditorInput.js +1 -1
- package/vscode/src/vs/workbench/common/editor/sideBySideEditorInput.js +1 -1
- package/vscode/src/vs/workbench/common/editor/textEditorModel.js +1 -1
- package/vscode/src/vs/workbench/common/editor.js +4 -4
- package/vscode/src/vs/workbench/common/theme.js +208 -208
- package/vscode/src/vs/workbench/common/views.js +4 -4
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.js +168 -168
- package/vscode/src/vs/workbench/contrib/accessibility/browser/accessibleViewActions.js +12 -12
- package/vscode/src/vs/workbench/contrib/agentsVoice/common/agentsVoiceColors.js +2 -2
- package/vscode/src/vs/workbench/contrib/browserView/common/browserEditorInput.js +1 -1
- package/vscode/src/vs/workbench/contrib/browserView/common/browserView.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +65 -65
- package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginActions.js +78 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLegacyMigration.js +6 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsModel.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagement.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatScreenshotContext.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorContextKeys.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOutline.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessionDescription.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.js +45 -45
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetup.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/enablementActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/chatSpeechToTextService.js +19 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/dictationDownloadRing.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/dictationSession.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/micCaptureService.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditorInput.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/common/actions/chatContextKeys.js +108 -108
- package/vscode/src/vs/workbench/contrib/chat/common/attachments/chatVariableEntries.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/attachments/chatVariableEntries.js +81 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatImageExtraction.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatModes.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatService/chatService.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/customizationHarnessService.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/editing/chatEditingService.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +47 -31
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatModel.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatToolInvocation.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.js +13 -13
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/hookSchema.js +18 -18
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/hookTypes.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptFileAttributes.js +80 -80
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/promptTypes.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/tools/builtinTools/askQuestionsTool.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/common/tools/builtinTools/manageTodoListTool.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/common/tools/builtinTools/reviewPlanTool.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/tools/builtinTools/setArtifactRulesTool.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/tools/builtinTools/setArtifactsTool.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +22 -22
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsService.js +3 -3
- package/vscode/src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.js +11 -11
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/dictation/editorDictation.js +4 -4
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/diffEditorAccessibilityHelp.js +6 -6
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/diffEditorHelper.js +3 -3
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +10 -10
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.js +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/largeFileOptimizations.js +3 -3
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.js +6 -6
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/saveParticipants.js +4 -4
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.js +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleMultiCursorModifier.js +3 -3
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.js +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.js +12 -12
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.js +5 -5
- package/vscode/src/vs/workbench/contrib/codeEditor/common/languageConfigurationExtensionPoint.js +71 -71
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +7 -7
- package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +7 -7
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +2 -2
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +3 -3
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +3 -3
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +3 -3
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +3 -3
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +3 -3
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsAccessibility.js +12 -12
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +7 -7
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsModel.js +1 -1
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +9 -9
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +14 -14
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +16 -16
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +7 -7
- package/vscode/src/vs/workbench/contrib/comments/common/commentContextKeys.js +12 -12
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorDiffInput.js +3 -3
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInput.js +3 -3
- package/vscode/src/vs/workbench/contrib/debug/browser/baseDebugView.js +1 -1
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +29 -29
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +14 -14
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +75 -75
- package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/debug/browser/debugActionViewItems.js +9 -9
- package/vscode/src/vs/workbench/contrib/debug/browser/debugColors.js +12 -12
- package/vscode/src/vs/workbench/contrib/debug/browser/debugCommands.js +38 -38
- package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/debug/browser/debugHover.js +3 -3
- package/vscode/src/vs/workbench/contrib/debug/browser/debugIcons.js +57 -57
- package/vscode/src/vs/workbench/contrib/debug/browser/debugSessionPicker.js +3 -3
- package/vscode/src/vs/workbench/contrib/debug/browser/exceptionWidget.js +7 -7
- package/vscode/src/vs/workbench/contrib/debug/browser/linkDetector.js +2 -2
- package/vscode/src/vs/workbench/contrib/debug/browser/repl.js +18 -18
- package/vscode/src/vs/workbench/contrib/debug/browser/replViewer.js +5 -5
- package/vscode/src/vs/workbench/contrib/debug/browser/variablesView.js +9 -9
- package/vscode/src/vs/workbench/contrib/debug/common/abstractDebugAdapter.js +1 -1
- package/vscode/src/vs/workbench/contrib/debug/common/debug.js +65 -65
- package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +6 -6
- package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +1 -1
- package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/debug/common/loadedScriptsPicker.js +1 -1
- package/vscode/src/vs/workbench/contrib/debug/common/replModel.js +1 -1
- package/vscode/src/vs/workbench/contrib/dropOrPasteInto/browser/commands.js +2 -2
- package/vscode/src/vs/workbench/contrib/dropOrPasteInto/browser/configurationSchema.js +4 -4
- package/vscode/src/vs/workbench/contrib/extensions/browser/configBasedRecommendations.js +1 -1
- package/vscode/src/vs/workbench/contrib/extensions/browser/exeBasedRecommendations.js +1 -1
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionEditor.js +41 -41
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionEnablementWorkspaceTrustTransitionParticipant.js +1 -1
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionFeaturesTab.js +15 -15
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService.js +14 -14
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensions.contribution.js +158 -158
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.js +180 -180
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsActivationProgress.js +1 -1
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsCompletionItemsProvider.js +1 -1
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsDependencyChecker.js +5 -5
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsIcons.js +25 -25
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsQuickAccess.js +4 -4
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewer.js +7 -7
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.js +48 -48
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViews.js +5 -5
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWidgets.js +30 -30
- package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.js +77 -77
- package/vscode/src/vs/workbench/contrib/extensions/browser/fileBasedRecommendations.js +2 -2
- package/vscode/src/vs/workbench/contrib/extensions/browser/webRecommendations.js +1 -1
- package/vscode/src/vs/workbench/contrib/extensions/browser/workspaceRecommendations.js +2 -2
- package/vscode/src/vs/workbench/contrib/extensions/common/extensions.js +1 -1
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsFileTemplate.js +5 -5
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +3 -3
- package/vscode/src/vs/workbench/contrib/extensions/common/searchExtensionsTool.js +3 -3
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/configuration.js +4 -4
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpenerService.js +3 -3
- package/vscode/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +1 -1
- package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +8 -8
- package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +18 -18
- package/vscode/src/vs/workbench/contrib/files/browser/explorerViewlet.js +14 -14
- package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +39 -39
- package/vscode/src/vs/workbench/contrib/files/browser/fileActions.js +84 -84
- package/vscode/src/vs/workbench/contrib/files/browser/fileCommands._save.js +4 -4
- package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +2 -2
- package/vscode/src/vs/workbench/contrib/files/browser/fileConstants.js +6 -6
- package/vscode/src/vs/workbench/contrib/files/browser/fileImportExport.js +28 -28
- package/vscode/src/vs/workbench/contrib/files/browser/files.contribution._configuration.js +50 -50
- package/vscode/src/vs/workbench/contrib/files/browser/files.contribution._editorPane.js +2 -2
- package/vscode/src/vs/workbench/contrib/files/browser/views/emptyView.js +1 -1
- package/vscode/src/vs/workbench/contrib/files/browser/views/explorerView.js +7 -7
- package/vscode/src/vs/workbench/contrib/files/browser/views/explorerViewer.js +17 -17
- package/vscode/src/vs/workbench/contrib/files/browser/views/openEditorsView.js +9 -9
- package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +4 -4
- package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +1 -1
- package/vscode/src/vs/workbench/contrib/files/common/files.js +16 -16
- package/vscode/src/vs/workbench/contrib/folding/browser/folding.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js +20 -20
- package/vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js +4 -4
- package/vscode/src/vs/workbench/contrib/format/browser/formatModified.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlayHints/browser/inlayHintsAccessibilty.js +4 -4
- package/vscode/src/vs/workbench/contrib/inlineCompletions/browser/inlineCompletionLanguageStatusBarContribution.js +6 -6
- package/vscode/src/vs/workbench/contrib/list/browser/listResizeColumnAction.js +2 -2
- package/vscode/src/vs/workbench/contrib/list/browser/tableColumnResizeQuickPick.js +5 -5
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommandsAddConfiguration.js +70 -70
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServerActions.js +40 -40
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpConfiguration.js +45 -45
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServer.js +16 -16
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpTypes.js +4 -4
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +4 -4
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +23 -23
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +8 -8
- package/vscode/src/vs/workbench/contrib/meteredConnection/browser/meteredConnection.contribution.js +8 -8
- package/vscode/src/vs/workbench/contrib/meteredConnection/browser/meteredConnectionStatus.js +4 -4
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/icons.contribution.js +1 -1
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput.js +3 -3
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/scmMultiDiffSourceResolver.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +17 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOutputActions.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/coreActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/foldingController.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityProvider.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditor.js +13 -13
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +24 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookIcons.js +29 -29
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.js +7 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellExecutionIcon.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellOutput.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/foldedCellHint.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelQuickPickStrategy.js +14 -14
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookViewZones.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorInput.js +2 -2
- package/vscode/src/vs/workbench/contrib/preferences/browser/keybindingWidgets.js +3 -3
- package/vscode/src/vs/workbench/contrib/preferences/browser/preferencesIcons.js +13 -13
- package/vscode/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.js +10 -10
- package/vscode/src/vs/workbench/contrib/preferences/browser/settingsLayout.js +60 -60
- package/vscode/src/vs/workbench/contrib/preferences/common/preferences.js +3 -3
- package/vscode/src/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +21 -21
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +15 -15
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +17 -17
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +59 -59
- package/vscode/src/vs/workbench/contrib/scm/browser/scmHistory.js +11 -11
- package/vscode/src/vs/workbench/contrib/scm/browser/scmHistoryChatContext.js +6 -6
- package/vscode/src/vs/workbench/contrib/scm/common/quickDiff.js +51 -15
- package/vscode/src/vs/workbench/contrib/search/browser/anythingQuickAccess.js +9 -9
- package/vscode/src/vs/workbench/contrib/search/browser/patternInputWidget.js +4 -4
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsBase.js +1 -1
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTopBar.js +9 -9
- package/vscode/src/vs/workbench/contrib/search/browser/searchChatContext.js +5 -5
- package/vscode/src/vs/workbench/contrib/search/browser/searchFindInput.js +1 -1
- package/vscode/src/vs/workbench/contrib/search/browser/searchIcons.js +20 -20
- package/vscode/src/vs/workbench/contrib/search/browser/searchMessage.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/browser/searchResultsView.js +14 -14
- package/vscode/src/vs/workbench/contrib/search/browser/searchView.js +55 -55
- package/vscode/src/vs/workbench/contrib/search/browser/searchWidget.js +11 -11
- package/vscode/src/vs/workbench/contrib/search/browser/symbolsQuickAccess.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/common/search.js +1 -1
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.js +4 -4
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.js +5 -5
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetCompletionProvider.js +3 -3
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsFile.js +3 -3
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsService.js +9 -9
- package/vscode/src/vs/workbench/contrib/speech/common/speechService.js +29 -29
- package/vscode/src/vs/workbench/contrib/tasks/common/constants.js +1 -1
- package/vscode/src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.js +6 -6
- package/vscode/src/vs/workbench/contrib/tasks/common/taskService.js +6 -6
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +4 -4
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIcons.js +13 -13
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalMenus.js +42 -42
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationStyles.js +15 -15
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +10 -10
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalColorRegistry.js +23 -23
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalContextKey.js +17 -17
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalStrings.js +26 -26
- package/vscode/src/vs/workbench/contrib/terminalContrib/accessibility/common/terminalAccessibilityConfiguration.js +5 -5
- package/vscode/src/vs/workbench/contrib/terminalContrib/autoReplies/common/terminalAutoRepliesConfiguration.js +2 -2
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.js +77 -77
- package/vscode/src/vs/workbench/contrib/terminalContrib/commandGuide/common/terminalCommandGuideConfiguration.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/history/common/terminal.history.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/inlineHint/common/terminalInitialHintConfiguration.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/notification/common/terminalNotificationConfiguration.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/resizeDimensionsOverlay/common/terminalResizeDimensionsOverlayConfiguration.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/common/terminalStickyScrollConfiguration.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/suggest/common/terminalSuggestConfiguration.js +30 -30
- package/vscode/src/vs/workbench/contrib/terminalContrib/typeAhead/common/terminalTypeAheadConfiguration.js +5 -5
- package/vscode/src/vs/workbench/contrib/terminalContrib/zoom/common/terminal.zoom.js +2 -2
- package/vscode/src/vs/workbench/contrib/testing/common/constants.js +11 -11
- package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +2 -2
- package/vscode/src/vs/workbench/contrib/testing/common/testTypes.js +3 -3
- package/vscode/src/vs/workbench/contrib/url/browser/trustedDomains.js +6 -6
- package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindAccessibilityHelp.js +30 -30
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditor.js +1 -1
- package/vscode/src/vs/workbench/contrib/workspace/common/workspace.js +2 -2
- package/vscode/src/vs/workbench/services/accounts/browser/defaultAccount.d.ts +205 -0
- package/vscode/src/vs/workbench/services/accounts/browser/defaultAccount.js +1580 -0
- package/vscode/src/vs/workbench/services/agentHost/browser/codexAccountService.js +4 -4
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +11 -11
- package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +5 -5
- package/vscode/src/vs/workbench/services/chat/common/chatEntitlementService.js +16 -16
- package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverSchema.js +16 -16
- package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverUtils.js +1 -1
- package/vscode/src/vs/workbench/services/configurationResolver/common/variableResolver.js +16 -16
- package/vscode/src/vs/workbench/services/dataChannel/browser/dataChannelService.js +11 -11
- package/vscode/src/vs/workbench/services/editor/common/editorResolverService.js +4 -4
- package/vscode/src/vs/workbench/services/extensionManagement/common/extensionsIcons.js +3 -3
- package/vscode/src/vs/workbench/services/extensionRecommendations/common/workspaceExtensionsConfig.js +6 -6
- package/vscode/src/vs/workbench/services/extensions/browser/extensionUrlHandler.js +10 -10
- package/vscode/src/vs/workbench/services/extensions/common/extensionsRegistry.js +90 -90
- package/vscode/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.js +5 -5
- package/vscode/src/vs/workbench/services/language/common/languageService.js +24 -24
- package/vscode/src/vs/workbench/services/log/common/logConstants.js +1 -1
- package/vscode/src/vs/workbench/services/policies/common/accountPolicyService.js +1 -1
- package/vscode/src/vs/workbench/services/preferences/browser/keybindingsEditorInput.js +2 -2
- package/vscode/src/vs/workbench/services/preferences/browser/keybindingsEditorModel.js +7 -7
- package/vscode/src/vs/workbench/services/preferences/common/preferencesEditorInput.js +4 -4
- package/vscode/src/vs/workbench/services/preferences/common/preferencesModels.js +2 -2
- package/vscode/src/vs/workbench/services/preferences/common/preferencesValidation.js +30 -30
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +8 -8
- package/vscode/src/vs/workbench/services/remote/common/tunnelModel.js +6 -6
- package/vscode/src/vs/workbench/services/search/common/queryBuilder.js +1 -1
- package/vscode/src/vs/workbench/services/textMate/common/TMGrammars.js +9 -9
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModel.js +3 -3
- package/vscode/src/vs/workbench/services/themes/common/colorExtensionPoint.js +18 -18
- package/vscode/src/vs/workbench/services/themes/common/colorThemeData.js +8 -8
- package/vscode/src/vs/workbench/services/themes/common/iconExtensionPoint.js +13 -13
- package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +24 -24
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.js +3 -3
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfileIcons.js +1 -1
- package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.js +13 -13
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +16 -16
- package/vscode/src/vs/platform/agentHost/common/meta/agentFeedbackAnnotations.d.ts +0 -128
- package/vscode/src/vs/platform/agentHost/common/meta/agentToolCallMeta.d.ts +0 -81
- package/vscode/src/vs/workbench/contrib/welcomeOnboarding/common/onboardingTypes.d.ts +0 -81
- package/vscode/src/vs/workbench/contrib/welcomeOnboarding/common/onboardingTypes.js +0 -97
|
@@ -0,0 +1,1580 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
3
|
+
import { distinct } from '../../../../base/common/arrays.js';
|
|
4
|
+
import { ThrottledDelayer, RunOnceScheduler, timeout } from '../../../../base/common/async.js';
|
|
5
|
+
import { CancellationToken } from '../../../../base/common/cancellation.js';
|
|
6
|
+
import { getErrorMessage } from '../../../../base/common/errors.js';
|
|
7
|
+
import { Emitter, Event } from '../../../../base/common/event.js';
|
|
8
|
+
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
|
|
9
|
+
import { equals } from '../../../../base/common/objects.js';
|
|
10
|
+
import { isWeb } from '../../../../base/common/platform.js';
|
|
11
|
+
import { isUndefined, isString } from '../../../../base/common/types.js';
|
|
12
|
+
import { localize2 } from '../../../../nls.js';
|
|
13
|
+
import { registerAction2, Action2 } from '../../../../platform/actions/common/actions.js';
|
|
14
|
+
import { ICommandService } from '../../../../platform/commands/common/commands.service.js';
|
|
15
|
+
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.service.js';
|
|
16
|
+
import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
|
|
17
|
+
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.service.js';
|
|
18
|
+
import { MANAGED_SETTINGS_UPDATE_REQUIRED_ERROR_CODE } from '../../../../platform/defaultAccount/common/defaultAccount.js';
|
|
19
|
+
import { IDefaultAccountService } from '../../../../platform/defaultAccount/common/defaultAccount.service.js';
|
|
20
|
+
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
|
|
21
|
+
import { ILogService } from '../../../../platform/log/common/log.service.js';
|
|
22
|
+
import { resolveForceRemoteSettingsRefresh } from '../../../../platform/policy/common/copilotManagedSettings.js';
|
|
23
|
+
import { INativeManagedSettingsService, IFileManagedSettingsService } from '../../../../platform/policy/common/copilotManagedSettings.service.js';
|
|
24
|
+
import { MANAGED_SETTINGS_FRESHNESS_NOT_REQUIRED, ManagedSettingsFreshnessState, isManagedSettingsFreshnessBlocking, ManagedSettingsFreshnessFailure, isManagedSettingsFreshnessSatisfiedFor } from '../../../../platform/policy/common/managedSettingsFreshness.js';
|
|
25
|
+
import { IProductService } from '../../../../platform/product/common/productService.service.js';
|
|
26
|
+
import { asJson, isSuccess, isClientError, asText, readHeader, retryAfterFromHeaders } from '../../../../platform/request/common/request.js';
|
|
27
|
+
import { IRequestService } from '../../../../platform/request/common/request.service.js';
|
|
28
|
+
import { StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
|
|
29
|
+
import { IStorageService } from '../../../../platform/storage/common/storage.service.js';
|
|
30
|
+
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.service.js';
|
|
31
|
+
import { registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js';
|
|
32
|
+
import { IAuthenticationService, IAuthenticationExtensionsService } from '../../authentication/common/authentication.service.js';
|
|
33
|
+
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.service.js';
|
|
34
|
+
import { IExtensionService } from '../../extensions/common/extensions.service.js';
|
|
35
|
+
import { IHostService } from '../../host/browser/host.service.js';
|
|
36
|
+
import { appendManagedSettingsClientIdentity, adaptManagedSettings, parseManagedSettingsCompatibilityError } from './managedSettings.js';
|
|
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(19261, "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 };
|