@codingame/monaco-vscode-chat-service-override 38.0.7 → 38.1.2
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/common.js +0 -53
- package/index.js +0 -3
- package/package.json +5 -5
- package/session.js +0 -3
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/missionControlAgentHostContribution.js +1 -1
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.shared.contribution.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHost.contribution.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostChatContribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewTitleControl.js +1 -1
- package/vscode/src/vs/platform/agentHost/browser/webPubSubRelayTransport.d.ts +0 -135
- package/vscode/src/vs/platform/agentHost/browser/webPubSubRelayTransport.js +0 -510
- package/vscode/src/vs/platform/agentHost/common/agentModelNotices.d.ts +0 -22
- package/vscode/src/vs/platform/agentHost/common/agentModelNotices.js +0 -21
- package/vscode/src/vs/platform/agentHost/common/cloudSandboxAgentHost.d.ts +0 -273
- package/vscode/src/vs/platform/agentHost/common/cloudSandboxAgentHost.js +0 -61
- package/vscode/src/vs/platform/agentHost/common/meta/agentModelMeta.d.ts +0 -7
- package/vscode/src/vs/platform/agentHost/common/meta/agentModelMeta.js +0 -17
- package/vscode/src/vs/platform/agentHost/common/meta/copilotd/cloudSandboxProjectMeta.d.ts +0 -12
- package/vscode/src/vs/platform/agentHost/common/meta/copilotd/cloudSandboxProjectMeta.js +0 -48
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelEnsembleMeta.d.ts +0 -8
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelEnsembleMeta.js +0 -11
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelPricing.d.ts +0 -114
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelPricing.js +0 -141
- package/vscode/src/vs/platform/agentHost/common/taskEventReplay.d.ts +0 -48
- package/vscode/src/vs/platform/agentHost/common/taskEventReplay.js +0 -238
- package/vscode/src/vs/platform/agentHost/common/webPubSub/chunking.d.ts +0 -102
- package/vscode/src/vs/platform/agentHost/common/webPubSub/chunking.js +0 -260
- package/vscode/src/vs/platform/agentHost/common/webPubSub/framing.d.ts +0 -102
- package/vscode/src/vs/platform/agentHost/common/webPubSub/framing.js +0 -115
- package/vscode/src/vs/platform/agentHost/common/webPubSub/groups.d.ts +0 -46
- package/vscode/src/vs/platform/agentHost/common/webPubSub/groups.js +0 -92
- package/vscode/src/vs/sessions/contrib/chat/browser/newSession.d.ts +0 -9
- package/vscode/src/vs/sessions/contrib/chat/browser/voiceBridge.contribution.d.ts +0 -14
- package/vscode/src/vs/sessions/contrib/chat/browser/voiceBridge.contribution.js +0 -385
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.d.ts +0 -67
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.js +0 -695
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.d.ts +0 -4
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.js +0 -39
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.d.ts +0 -1
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.js +0 -59
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.d.ts +0 -1
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.js +0 -83
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.d.ts +0 -87
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.js +0 -176
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.d.ts +0 -422
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.js +0 -2444
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.d.ts +0 -91
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.js +0 -620
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.d.ts +0 -1
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.js +0 -5
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.d.ts +0 -46
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.js +0 -321
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.d.ts +0 -104
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.js +0 -345
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoice.contribution.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoice.contribution.js +0 -611
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceSessionsPicker.d.ts +0 -20
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceSessionsPicker.js +0 -85
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.d.ts +0 -200
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.js +0 -981
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidgetBinding.d.ts +0 -24
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidgetBinding.js +0 -206
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWindowService.d.ts +0 -65
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWindowService.js +0 -368
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/confirmationComponent.d.ts +0 -10
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/confirmationComponent.js +0 -57
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/feedbackDialog.d.ts +0 -33
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/feedbackDialog.js +0 -98
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/headerComponent.d.ts +0 -32
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/headerComponent.js +0 -186
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/onboardingComponent.d.ts +0 -12
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/onboardingComponent.js +0 -116
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/sessionListComponent.d.ts +0 -32
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/sessionListComponent.js +0 -226
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/statusRowsComponent.d.ts +0 -18
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/statusRowsComponent.js +0 -138
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/tokens.d.ts +0 -32
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/tokens.js +0 -29
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/transcriptComponent.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/transcriptComponent.js +0 -108
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/voiceBarComponent.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/voiceBarComponent.js +0 -63
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/media/voiceModeOnboarding.css +0 -252
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscripts.contribution.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscripts.contribution.js +0 -178
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscriptsView.d.ts +0 -47
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscriptsView.js +0 -322
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.d.ts +0 -146
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.js +0 -890
- package/vscode/src/vs/workbench/contrib/agentsVoice/common/voiceTranscriptStore.d.ts +0 -132
- package/vscode/src/vs/workbench/contrib/agentsVoice/common/voiceTranscriptStore.js +0 -237
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.d.ts +0 -120
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.js +0 -234
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.d.ts +0 -36
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.js +0 -164
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/repositoryPicker.d.ts +0 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/repositoryPicker.js +0 -122
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupMicrosoftProbe.d.ts +0 -82
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupMicrosoftProbe.js +0 -213
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxAgentHostService.d.ts +0 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxAgentHostService.js +0 -561
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxApiService.d.ts +0 -133
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxApiService.js +0 -1176
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxConnectionCustomization.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxConnectionCustomization.js +0 -76
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxCredentialRefresh.d.ts +0 -54
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxCredentialRefresh.js +0 -220
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxHistoryCache.d.ts +0 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxHistoryCache.js +0 -184
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxLegacySessionPreparation.d.ts +0 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxLegacySessionPreparation.js +0 -165
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxModels.d.ts +0 -43
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxModels.js +0 -162
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxReadOnlySessionHandler.d.ts +0 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxReadOnlySessionHandler.js +0 -129
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.d.ts +0 -166
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.js +0 -838
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionHandler.d.ts +0 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionHandler.js +0 -604
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.d.ts +0 -289
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.js +0 -497
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlCredentialSealing.d.ts +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlCredentialSealing.js +0 -41
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentService.d.ts +0 -73
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentService.js +0 -398
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlSharingService.d.ts +0 -45
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlSharingService.js +0 -296
- package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/voiceCodeTranscriptionClient.d.ts +0 -63
- package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/voiceCodeTranscriptionClient.js +0 -361
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/ttsPlaybackService.d.ts +0 -34
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/ttsPlaybackService.js +0 -198
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/voiceClientService.d.ts +0 -131
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/voiceClientService.js +0 -871
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceInputMode/voiceInputMode.d.ts +0 -66
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceInputMode/voiceInputMode.js +0 -297
- package/vscode/src/vs/workbench/contrib/chat/common/voicePlaybackService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/voicePlaybackService.js +0 -118
package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxAgentHostService.js
DELETED
|
@@ -1,561 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { CancellationError, isCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
4
|
-
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
5
|
-
import { Disposable, DisposableMap, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
-
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
7
|
-
import { isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
8
|
-
import { disposableTimeout, raceCancellationError, timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
9
|
-
import { StopWatch } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stopwatch';
|
|
10
|
-
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
11
|
-
import { NonReconnectableTransportError, AgentHostTransportFailureReason } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/sessionTransport';
|
|
12
|
-
import { AgentHostProtocolClient } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/browser/agentHostProtocolClient';
|
|
13
|
-
import { agentsWindowAgentHostClientInfo, editorWindowAgentHostClientInfo } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostClientInfo';
|
|
14
|
-
import { AgentHostClientConnectionKind } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostTelemetry';
|
|
15
|
-
import { traceConnectionOperation, formatConnectionDiagnosticError, getConnectionDiagnosticError } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/connectionDiagnostics';
|
|
16
|
-
import { WebPubSubRelayTransport } from '../../../../../platform/agentHost/browser/webPubSubRelayTransport.js';
|
|
17
|
-
import { AhpJsonlLogger } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/ahpJsonlLogger';
|
|
18
|
-
import { AgentHostAhpJsonlLoggingSettingId } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentService';
|
|
19
|
-
import { IAgentHostService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentService.service';
|
|
20
|
-
import { cloudSandboxAddress, buildWpsUrl, isCloudSandboxSealedToken, cloudSandboxEnvironmentId, CloudSandboxEnabledSettingId, CloudSandboxNetworkError } from '../../../../../platform/agentHost/common/cloudSandboxAgentHost.js';
|
|
21
|
-
import { ICloudSandboxApiService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/cloudSandboxAgentHost.service';
|
|
22
|
-
import { RemoteAgentHostEntryType, getEntryAddress, RemoteAgentHostsEnabledSettingId, RemoteAgentHostConnectionStatus } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/remoteAgentHostService';
|
|
23
|
-
import { IRemoteAgentHostService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/remoteAgentHostService.service';
|
|
24
|
-
import { DEFAULT_RECONNECT_POLICY } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/reconnectPolicy';
|
|
25
|
-
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
26
|
-
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
27
|
-
import { IPowerService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/power/common/powerService.service';
|
|
28
|
-
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
29
|
-
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
30
|
-
import { MAX_CONSECUTIVE_CREDENTIAL_REFRESH_FAILURES, MIN_CREDENTIAL_REFRESH_DELAY_MS, CloudSandboxCredentialRefreshState, CloudSandboxCredentialRefresher } from './cloudSandboxCredentialRefresh.js';
|
|
31
|
-
import { getCloudSandboxConnectionSurface } from './cloudSandboxTelemetry.js';
|
|
32
|
-
import { ICloudSandboxTelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.service';
|
|
33
|
-
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
34
|
-
import { GITHUB_COPILOT_PROTECTED_RESOURCE } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agent';
|
|
35
|
-
|
|
36
|
-
const LOG_PREFIX = "[CloudSandboxAgentHost]";
|
|
37
|
-
const CONNECTION_RETRY_DELAY_MS = 30_000;
|
|
38
|
-
const MIN_WAKING_RETRY_DELAY_MS = 1_000;
|
|
39
|
-
const MAX_SEALED_TOKEN_RETRIES = 12;
|
|
40
|
-
const SEALED_TOKEN_RETRY_DELAY_MS = 5_000;
|
|
41
|
-
const CONNECTION_TIMEOUT_MS = 10 * 60_000;
|
|
42
|
-
const SANDBOX_RECONNECT_POLICY = {
|
|
43
|
-
...DEFAULT_RECONNECT_POLICY,
|
|
44
|
-
maxElapsedTimeMs: MAX_CONSECUTIVE_CREDENTIAL_REFRESH_FAILURES * MIN_CREDENTIAL_REFRESH_DELAY_MS,
|
|
45
|
-
jitter: true
|
|
46
|
-
};
|
|
47
|
-
const USER_LOCAL_RECONNECT_POLICY = {
|
|
48
|
-
...SANDBOX_RECONNECT_POLICY,
|
|
49
|
-
maxElapsedTimeMs: 120_000
|
|
50
|
-
};
|
|
51
|
-
let CloudSandboxConnectionFactory = class CloudSandboxConnectionFactory extends Disposable {
|
|
52
|
-
constructor(
|
|
53
|
-
_instantiationService,
|
|
54
|
-
_configurationService,
|
|
55
|
-
_environmentService,
|
|
56
|
-
_telemetryService,
|
|
57
|
-
_powerService
|
|
58
|
-
) {
|
|
59
|
-
super();
|
|
60
|
-
this._instantiationService = _instantiationService;
|
|
61
|
-
this._configurationService = _configurationService;
|
|
62
|
-
this._environmentService = _environmentService;
|
|
63
|
-
this._telemetryService = _telemetryService;
|
|
64
|
-
this._powerService = _powerService;
|
|
65
|
-
this.kind = RemoteAgentHostEntryType.CloudSandbox;
|
|
66
|
-
this._stagedConnections = ( new Map());
|
|
67
|
-
this._pendingConnections = this._register(( new DisposableMap()));
|
|
68
|
-
this._connectionTelemetry = this._register(( new DisposableMap()));
|
|
69
|
-
this._entries = observableValue(this, []);
|
|
70
|
-
this.entries = this._entries;
|
|
71
|
-
this._surface = getCloudSandboxConnectionSurface(this._environmentService.isSessionsWindow, isWeb);
|
|
72
|
-
}
|
|
73
|
-
beginConnect(address, options) {
|
|
74
|
-
if (this._store.isDisposed || ( this._connectionTelemetry.has(address))) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
const telemetry = this._telemetryService.trackConnection("credentials", this._surface, options.connectionSource, options);
|
|
78
|
-
this._connectionTelemetry.set(address, telemetry);
|
|
79
|
-
return telemetry;
|
|
80
|
-
}
|
|
81
|
-
getTelemetry(address) {
|
|
82
|
-
return this._connectionTelemetry.get(address);
|
|
83
|
-
}
|
|
84
|
-
releaseTelemetry(address, telemetry) {
|
|
85
|
-
if (telemetry && this._connectionTelemetry.get(address) === telemetry) {
|
|
86
|
-
this._connectionTelemetry.deleteAndDispose(address);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
endConnectionTelemetry(address, cancelled) {
|
|
90
|
-
const telemetry = this._connectionTelemetry.get(address);
|
|
91
|
-
telemetry?.onConnectionStateChange(cancelled ? "disposed" : "failed");
|
|
92
|
-
this.releaseTelemetry(address, telemetry);
|
|
93
|
-
}
|
|
94
|
-
getConnectionObserver(entry) {
|
|
95
|
-
const address = getEntryAddress(entry);
|
|
96
|
-
const staged = this._stagedConnections.get(address);
|
|
97
|
-
let telemetry = this._connectionTelemetry.get(address);
|
|
98
|
-
if (!telemetry) {
|
|
99
|
-
telemetry = this._telemetryService.trackConnection("connection", this._surface, "existing", {
|
|
100
|
-
environmentKind: staged?.options.environmentKind
|
|
101
|
-
});
|
|
102
|
-
this._connectionTelemetry.set(address, telemetry);
|
|
103
|
-
}
|
|
104
|
-
const connectionTelemetry = telemetry;
|
|
105
|
-
return state => {
|
|
106
|
-
if (state === "connected" && staged) {
|
|
107
|
-
staged.reconnectRequiresRefresh = false;
|
|
108
|
-
}
|
|
109
|
-
connectionTelemetry.onConnectionStateChange(state);
|
|
110
|
-
if (state === "failed" || state === "disposed") {
|
|
111
|
-
this.releaseTelemetry(address, connectionTelemetry);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
stageConfiguration(options, clientToken) {
|
|
116
|
-
const address = cloudSandboxAddress(options.environmentId);
|
|
117
|
-
this._pendingConnections.deleteAndDispose(address);
|
|
118
|
-
const entry = {
|
|
119
|
-
name: options.name,
|
|
120
|
-
connection: {
|
|
121
|
-
type: RemoteAgentHostEntryType.CloudSandbox,
|
|
122
|
-
address,
|
|
123
|
-
environmentId: options.environmentId,
|
|
124
|
-
sessionId: options.sessionId,
|
|
125
|
-
...(options.environmentKind ? {
|
|
126
|
-
environmentKind: options.environmentKind
|
|
127
|
-
} : {})
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
this._stagedConnections.set(address, {
|
|
131
|
-
entry,
|
|
132
|
-
options,
|
|
133
|
-
creds: {
|
|
134
|
-
token: clientToken
|
|
135
|
-
},
|
|
136
|
-
clientId: clientToken.client_id,
|
|
137
|
-
refreshState: ( new CloudSandboxCredentialRefreshState()),
|
|
138
|
-
refresher: undefined,
|
|
139
|
-
reconnectRequiresRefresh: true,
|
|
140
|
-
lastAuthenticationToken: undefined
|
|
141
|
-
});
|
|
142
|
-
this._updateEntries();
|
|
143
|
-
return entry;
|
|
144
|
-
}
|
|
145
|
-
unstageConfiguration(address) {
|
|
146
|
-
this._pendingConnections.deleteAndDispose(address);
|
|
147
|
-
this._stagedConnections.delete(address);
|
|
148
|
-
this._updateEntries();
|
|
149
|
-
}
|
|
150
|
-
isCurrentConfiguration(entry) {
|
|
151
|
-
return this._stagedConnections.get(getEntryAddress(entry))?.entry === entry;
|
|
152
|
-
}
|
|
153
|
-
getSealedGitHubToken(environmentId) {
|
|
154
|
-
return this._stagedConnections.get(cloudSandboxAddress(environmentId))?.creds.token.encrypted_github_token;
|
|
155
|
-
}
|
|
156
|
-
async refreshSealedGitHubToken(environmentId) {
|
|
157
|
-
const address = cloudSandboxAddress(environmentId);
|
|
158
|
-
const staged = this._stagedConnections.get(address);
|
|
159
|
-
const refresher = staged?.refresher;
|
|
160
|
-
if (!staged || !refresher) {
|
|
161
|
-
throw ( new Error(`No active cloud sandbox credential refresher for ${address}.`));
|
|
162
|
-
}
|
|
163
|
-
const sealedToken = await refresher.refreshAuthenticationCredentials();
|
|
164
|
-
if (this._stagedConnections.get(address) !== staged || staged.refresher !== refresher) {
|
|
165
|
-
throw ( new CancellationError());
|
|
166
|
-
}
|
|
167
|
-
return sealedToken;
|
|
168
|
-
}
|
|
169
|
-
async createConnection(entry, _options) {
|
|
170
|
-
if (entry.connection.type !== RemoteAgentHostEntryType.CloudSandbox) {
|
|
171
|
-
throw ( new Error(
|
|
172
|
-
`Cloud sandbox factory cannot create a ${entry.connection.type} connection.`
|
|
173
|
-
));
|
|
174
|
-
}
|
|
175
|
-
const address = getEntryAddress(entry);
|
|
176
|
-
const staged = this._stagedConnections.get(address);
|
|
177
|
-
if (!staged) {
|
|
178
|
-
throw ( new Error(`No cloud sandbox connection is staged for ${address}.`));
|
|
179
|
-
}
|
|
180
|
-
const store = ( new DisposableStore());
|
|
181
|
-
this._pendingConnections.set(address, store);
|
|
182
|
-
try {
|
|
183
|
-
const telemetry = this._connectionTelemetry.get(address);
|
|
184
|
-
const diagnosticObserver = event => telemetry?.recordConnectionDiagnostic(event);
|
|
185
|
-
const refresher = store.add(
|
|
186
|
-
this._instantiationService.createInstance(CloudSandboxCredentialRefresher, address, {
|
|
187
|
-
environmentId: staged.options.environmentId,
|
|
188
|
-
sessionId: staged.options.sessionId,
|
|
189
|
-
onRequest: telemetry?.createRequestObserver()
|
|
190
|
-
}, staged.clientId, staged.creds, staged.refreshState)
|
|
191
|
-
);
|
|
192
|
-
staged.refresher = refresher;
|
|
193
|
-
store.add(toDisposable(() => {
|
|
194
|
-
if (staged.refresher === refresher) {
|
|
195
|
-
staged.refresher = undefined;
|
|
196
|
-
}
|
|
197
|
-
}));
|
|
198
|
-
const prepareCredentials = refreshConnection => traceConnectionOperation(diagnosticObserver, "credentials", async () => {
|
|
199
|
-
try {
|
|
200
|
-
if (refreshConnection) {
|
|
201
|
-
await refresher.refreshConnectionCredentials();
|
|
202
|
-
} else {
|
|
203
|
-
await refresher.ensureUnexpiredCredentials();
|
|
204
|
-
}
|
|
205
|
-
} catch (error) {
|
|
206
|
-
if (this._stagedConnections.get(address) !== staged || store.isDisposed) {
|
|
207
|
-
throw ( new CancellationError());
|
|
208
|
-
}
|
|
209
|
-
if (staged.refreshState.permanentFailure) {
|
|
210
|
-
this.unstageConfiguration(address);
|
|
211
|
-
throw ( new NonReconnectableTransportError(
|
|
212
|
-
"Mission Control refused connection recovery; reconnect after resolving environment availability or account authorization.",
|
|
213
|
-
staged.refreshState.permanentFailureStatus === 404 ? AgentHostTransportFailureReason.HostNotRunning : AgentHostTransportFailureReason.Unknown
|
|
214
|
-
));
|
|
215
|
-
}
|
|
216
|
-
throw error;
|
|
217
|
-
}
|
|
218
|
-
if (this._stagedConnections.get(address) !== staged || store.isDisposed) {
|
|
219
|
-
throw ( new CancellationError());
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
await prepareCredentials(false);
|
|
223
|
-
const ahpLoggingEnabled = !!this._configurationService.getValue(AgentHostAhpJsonlLoggingSettingId);
|
|
224
|
-
const transportFactory = () => this._instantiationService.createInstance(WebPubSubRelayTransport, {
|
|
225
|
-
clientConnectionKind: staged.options.environmentKind === "user-local" ? AgentHostClientConnectionKind.MissionControl : AgentHostClientConnectionKind.WebPubSub,
|
|
226
|
-
clientId: staged.clientId,
|
|
227
|
-
url: buildWpsUrl(staged.creds.token),
|
|
228
|
-
toHostGroup: staged.creds.token.groups.to_host,
|
|
229
|
-
joinGroups: [staged.creds.token.groups.broadcast, staged.creds.token.groups.to_client],
|
|
230
|
-
groupValidation: {
|
|
231
|
-
expected: {
|
|
232
|
-
cid: staged.creds.token.client_id
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
onDidReceiveFrame: () => telemetry?.recordReceivedFrame(),
|
|
236
|
-
ahpLogger: ahpLoggingEnabled ? this._instantiationService.createInstance(AhpJsonlLogger, {
|
|
237
|
-
logsHome: this._environmentService.logsHome,
|
|
238
|
-
logId: address,
|
|
239
|
-
connectionId: staged.clientId,
|
|
240
|
-
transport: "webpubsub"
|
|
241
|
-
}) : undefined
|
|
242
|
-
});
|
|
243
|
-
const client = this._instantiationService.createInstance(AgentHostProtocolClient, address, transportFactory, {
|
|
244
|
-
clientId: staged.clientId,
|
|
245
|
-
clientInfo: this._environmentService.isSessionsWindow ? agentsWindowAgentHostClientInfo : editorWindowAgentHostClientInfo,
|
|
246
|
-
reconnectPolicy: staged.options.environmentKind === "user-local" ? USER_LOCAL_RECONNECT_POLICY : SANDBOX_RECONNECT_POLICY,
|
|
247
|
-
onDidSuspend: this._powerService.onDidSuspend,
|
|
248
|
-
onDidResume: this._powerService.onDidResume,
|
|
249
|
-
prepareReconnect: async () => {
|
|
250
|
-
await prepareCredentials(
|
|
251
|
-
staged.reconnectRequiresRefresh || staged.options.environmentKind === "user-local"
|
|
252
|
-
);
|
|
253
|
-
staged.reconnectRequiresRefresh = true;
|
|
254
|
-
},
|
|
255
|
-
prepareAuthentication: async () => {
|
|
256
|
-
if (staged.lastAuthenticationToken && staged.lastAuthenticationToken === staged.creds.token.encrypted_github_token) {
|
|
257
|
-
await traceConnectionOperation(
|
|
258
|
-
diagnosticObserver,
|
|
259
|
-
"credentials",
|
|
260
|
-
() => refresher.refreshAuthenticationCredentials()
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
resolveInitialAuthentication: () => this._resolveInitialAuthentication(staged)
|
|
265
|
-
});
|
|
266
|
-
store.add(client.onDidConnectionDiagnostic(diagnosticObserver));
|
|
267
|
-
return {
|
|
268
|
-
connection: client,
|
|
269
|
-
transportDisposable: store,
|
|
270
|
-
reconnectManagedByClient: true
|
|
271
|
-
};
|
|
272
|
-
} catch (error) {
|
|
273
|
-
store.dispose();
|
|
274
|
-
throw error;
|
|
275
|
-
} finally {
|
|
276
|
-
if (this._pendingConnections.get(address) === store) {
|
|
277
|
-
this._pendingConnections.deleteAndLeak(address);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
async _resolveInitialAuthentication(staged) {
|
|
282
|
-
const address = getEntryAddress(staged.entry);
|
|
283
|
-
const sealedToken = staged.creds.token.encrypted_github_token;
|
|
284
|
-
if (!sealedToken) {
|
|
285
|
-
throw ( new Error(
|
|
286
|
-
`Mission Control returned no sealed token for ${address}; the session cannot make authenticated requests.`
|
|
287
|
-
));
|
|
288
|
-
}
|
|
289
|
-
if (!isCloudSandboxSealedToken(sealedToken)) {
|
|
290
|
-
throw ( new Error(
|
|
291
|
-
`Refusing to forward a non-sealed token to ${address}; Mission Control did not return a copilot-sealed envelope.`
|
|
292
|
-
));
|
|
293
|
-
}
|
|
294
|
-
staged.lastAuthenticationToken = sealedToken;
|
|
295
|
-
return {
|
|
296
|
-
resource: GITHUB_COPILOT_PROTECTED_RESOURCE.resource,
|
|
297
|
-
token: sealedToken
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
_updateEntries() {
|
|
301
|
-
this._entries.set([...( this._stagedConnections.values())].map(connection => connection.entry), undefined);
|
|
302
|
-
}
|
|
303
|
-
getUserLocalEnvironmentIds(account) {
|
|
304
|
-
return [...( this._stagedConnections.values())].filter(
|
|
305
|
-
connection => connection.options.environmentKind === "user-local" && connection.options.accountKey !== account
|
|
306
|
-
).map(connection => connection.options.environmentId);
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
CloudSandboxConnectionFactory = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, IConfigurationService)), ( __param(2, IWorkbenchEnvironmentService)), ( __param(3, ICloudSandboxTelemetryService)), ( __param(4, IPowerService))], CloudSandboxConnectionFactory));
|
|
310
|
-
let CloudSandboxAgentHostService = class CloudSandboxAgentHostService extends Disposable {
|
|
311
|
-
constructor(
|
|
312
|
-
_remoteAgentHostService,
|
|
313
|
-
_apiService,
|
|
314
|
-
_configurationService,
|
|
315
|
-
_instantiationService,
|
|
316
|
-
_logService,
|
|
317
|
-
_localAgentHostService
|
|
318
|
-
) {
|
|
319
|
-
super();
|
|
320
|
-
this._remoteAgentHostService = _remoteAgentHostService;
|
|
321
|
-
this._apiService = _apiService;
|
|
322
|
-
this._configurationService = _configurationService;
|
|
323
|
-
this._instantiationService = _instantiationService;
|
|
324
|
-
this._logService = _logService;
|
|
325
|
-
this._localAgentHostService = _localAgentHostService;
|
|
326
|
-
this._accountGeneration = 0;
|
|
327
|
-
this.sealedTokenRetryDelayMs = SEALED_TOKEN_RETRY_DELAY_MS;
|
|
328
|
-
this._connectionFactory = this._register(this._instantiationService.createInstance(CloudSandboxConnectionFactory));
|
|
329
|
-
this._register(
|
|
330
|
-
this._remoteAgentHostService.registerConnectionFactory(this._connectionFactory)
|
|
331
|
-
);
|
|
332
|
-
this._register(this._apiService.onDidChangeAccount(account => {
|
|
333
|
-
this._accountGeneration++;
|
|
334
|
-
for (const id of this._connectionFactory.getUserLocalEnvironmentIds(account)) {
|
|
335
|
-
void this.disconnect(id).catch(
|
|
336
|
-
error => this._logService.error("Failed to withdraw user-local MC connection", error)
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
}));
|
|
340
|
-
}
|
|
341
|
-
getSealedGitHubToken(environmentId) {
|
|
342
|
-
return this._connectionFactory.getSealedGitHubToken(environmentId);
|
|
343
|
-
}
|
|
344
|
-
refreshSealedGitHubToken(environmentId) {
|
|
345
|
-
return this._connectionFactory.refreshSealedGitHubToken(environmentId);
|
|
346
|
-
}
|
|
347
|
-
async disconnect(addressOrEnvironmentId) {
|
|
348
|
-
const address = cloudSandboxEnvironmentId(addressOrEnvironmentId) === undefined ? cloudSandboxAddress(addressOrEnvironmentId) : addressOrEnvironmentId;
|
|
349
|
-
this._connectionFactory.endConnectionTelemetry(address, true);
|
|
350
|
-
this._connectionFactory.unstageConfiguration(address);
|
|
351
|
-
await this._remoteAgentHostService.removeRemoteAgentHost(address);
|
|
352
|
-
}
|
|
353
|
-
async connect(options, token) {
|
|
354
|
-
if (options.environmentKind !== "user-local" && !this._configurationService.getValue(CloudSandboxEnabledSettingId)) {
|
|
355
|
-
throw ( new Error("Copilot cloud sandbox connections are not enabled."));
|
|
356
|
-
}
|
|
357
|
-
if (!this._configurationService.getValue(RemoteAgentHostsEnabledSettingId)) {
|
|
358
|
-
throw ( new Error("Remote agent host connections are not enabled."));
|
|
359
|
-
}
|
|
360
|
-
let userLocalAccount;
|
|
361
|
-
const accountGeneration = this._accountGeneration;
|
|
362
|
-
if (options.environmentKind === "user-local") {
|
|
363
|
-
if ((await this._localAgentHostService.getMissionControlEnvironmentId?.()) === options.environmentId) {
|
|
364
|
-
throw ( new Error(
|
|
365
|
-
"Use local IPC for this window's own Agent Host, not its Mission Control relay."
|
|
366
|
-
));
|
|
367
|
-
}
|
|
368
|
-
const account = await this._apiService.getAccountKey();
|
|
369
|
-
if (!account) {
|
|
370
|
-
throw ( new Error("User-local Mission Control connections require a signed-in account."));
|
|
371
|
-
}
|
|
372
|
-
userLocalAccount = account;
|
|
373
|
-
for (const id of this._connectionFactory.getUserLocalEnvironmentIds(account)) {
|
|
374
|
-
await this.disconnect(id);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
const address = cloudSandboxAddress(options.environmentId);
|
|
378
|
-
const existing = this._remoteAgentHostService.getConnection(address);
|
|
379
|
-
if (existing) {
|
|
380
|
-
this._logService.trace(`${LOG_PREFIX} Reusing existing connection for ${address}`);
|
|
381
|
-
return address;
|
|
382
|
-
}
|
|
383
|
-
const watch = StopWatch.create(false);
|
|
384
|
-
this._logService.info(
|
|
385
|
-
`${LOG_PREFIX} Connecting to sandbox environment ${options.environmentId}; sessionId=${options.sessionId ?? "none"}`
|
|
386
|
-
);
|
|
387
|
-
const telemetry = this._connectionFactory.beginConnect(address, options);
|
|
388
|
-
const operation = ( new DisposableStore());
|
|
389
|
-
const source = operation.add(( new CancellationTokenSource(token)));
|
|
390
|
-
let timedOut = false;
|
|
391
|
-
operation.add(disposableTimeout(() => {
|
|
392
|
-
timedOut = true;
|
|
393
|
-
telemetry?.onConnectionStateChange("failed");
|
|
394
|
-
source.cancel();
|
|
395
|
-
}, CONNECTION_TIMEOUT_MS));
|
|
396
|
-
operation.add(token.onCancellationRequested(() => {
|
|
397
|
-
telemetry?.completeConnect("cancelled");
|
|
398
|
-
this._connectionFactory.releaseTelemetry(address, telemetry);
|
|
399
|
-
}));
|
|
400
|
-
let establishing = false;
|
|
401
|
-
let clientId;
|
|
402
|
-
try {
|
|
403
|
-
const requestTelemetry = this._connectionFactory.getTelemetry(address);
|
|
404
|
-
const clientToken = await traceConnectionOperation(
|
|
405
|
-
event => requestTelemetry?.recordConnectionDiagnostic(event),
|
|
406
|
-
"credentials",
|
|
407
|
-
() => raceCancellationError(
|
|
408
|
-
this._mintWithWaking(options, source.token, requestTelemetry),
|
|
409
|
-
source.token
|
|
410
|
-
)
|
|
411
|
-
);
|
|
412
|
-
if (userLocalAccount !== undefined) {
|
|
413
|
-
const verifiedAccount = await this._apiService.getAccountKey();
|
|
414
|
-
if (accountGeneration !== this._accountGeneration || verifiedAccount !== userLocalAccount) {
|
|
415
|
-
throw ( new CancellationError());
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
establishing = true;
|
|
419
|
-
clientId = clientToken.client_id;
|
|
420
|
-
this._logService.info(
|
|
421
|
-
`${LOG_PREFIX} Credentials ready: environmentId=${options.environmentId} sessionId=${options.sessionId ?? "none"} clientId=${clientId} durationMs=${watch.elapsed()}`
|
|
422
|
-
);
|
|
423
|
-
requestTelemetry?.setConnectStage("connection");
|
|
424
|
-
const result = await this._establish(userLocalAccount === undefined ? options : {
|
|
425
|
-
...options,
|
|
426
|
-
accountKey: userLocalAccount
|
|
427
|
-
}, address, clientToken, source.token);
|
|
428
|
-
telemetry?.completeConnect(token.isCancellationRequested ? "cancelled" : "success");
|
|
429
|
-
return result;
|
|
430
|
-
} catch (error) {
|
|
431
|
-
const outcome = timedOut ? "timeout" : isCancellationError(error) || token.isCancellationRequested ? "cancelled" : "failed";
|
|
432
|
-
const message = `${LOG_PREFIX} Connection ${outcome}: environmentId=${options.environmentId} sessionId=${options.sessionId ?? "none"} clientId=${clientId ?? "none"} stage=${establishing ? "connection" : "credentials"} durationMs=${watch.elapsed()}`;
|
|
433
|
-
if (outcome === "cancelled") {
|
|
434
|
-
this._logService.debug(message);
|
|
435
|
-
} else {
|
|
436
|
-
this._logService.warn(
|
|
437
|
-
timedOut ? message : `${message}: ${formatConnectionDiagnosticError(getConnectionDiagnosticError(error))}`
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
telemetry?.completeConnect(
|
|
441
|
-
!timedOut && (isCancellationError(error) || token.isCancellationRequested) ? "cancelled" : "failure"
|
|
442
|
-
);
|
|
443
|
-
if (!establishing) {
|
|
444
|
-
this._connectionFactory.releaseTelemetry(address, telemetry);
|
|
445
|
-
}
|
|
446
|
-
throw timedOut ? ( new Error(( localize(
|
|
447
|
-
13247,
|
|
448
|
-
"Connecting to the sandbox timed out after {0} seconds.",
|
|
449
|
-
CONNECTION_TIMEOUT_MS / 1000
|
|
450
|
-
)))) : error;
|
|
451
|
-
} finally {
|
|
452
|
-
operation.dispose();
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
async _establish(options, address, clientToken, token) {
|
|
456
|
-
if (token.isCancellationRequested) {
|
|
457
|
-
throw ( new CancellationError());
|
|
458
|
-
}
|
|
459
|
-
const entry = this._connectionFactory.stageConfiguration(options, clientToken);
|
|
460
|
-
try {
|
|
461
|
-
if (token.isCancellationRequested) {
|
|
462
|
-
throw ( new CancellationError());
|
|
463
|
-
}
|
|
464
|
-
this._remoteAgentHostService.reconnect(address, true);
|
|
465
|
-
await raceCancellationError(this._remoteAgentHostService.waitForConnection(address), token);
|
|
466
|
-
this._logService.info(`${LOG_PREFIX} Protocol handshake completed with ${address}`);
|
|
467
|
-
return address;
|
|
468
|
-
} catch (error) {
|
|
469
|
-
const connectionStillLive = ( this._remoteAgentHostService.connections.some(
|
|
470
|
-
connection => connection.address === address && (RemoteAgentHostConnectionStatus.isConnected(connection.status) || RemoteAgentHostConnectionStatus.isReconnecting(connection.status))
|
|
471
|
-
));
|
|
472
|
-
if (this._connectionFactory.isCurrentConfiguration(entry) && (token.isCancellationRequested || !connectionStillLive)) {
|
|
473
|
-
this._connectionFactory.endConnectionTelemetry(address, isCancellationError(error) || token.isCancellationRequested);
|
|
474
|
-
this._connectionFactory.unstageConfiguration(address);
|
|
475
|
-
await this._remoteAgentHostService.removeRemoteAgentHost(address);
|
|
476
|
-
}
|
|
477
|
-
throw error;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
async _mintWithWaking(options, token, telemetry) {
|
|
481
|
-
for (let attempt = 1; ; attempt++) {
|
|
482
|
-
if (token.isCancellationRequested) {
|
|
483
|
-
throw ( new CancellationError());
|
|
484
|
-
}
|
|
485
|
-
let result;
|
|
486
|
-
try {
|
|
487
|
-
result = await this._apiService.connect({
|
|
488
|
-
environmentId: options.environmentId,
|
|
489
|
-
sessionId: options.sessionId,
|
|
490
|
-
onRequest: telemetry?.createRequestObserver()
|
|
491
|
-
}, token);
|
|
492
|
-
} catch (error) {
|
|
493
|
-
if (!(error instanceof CloudSandboxNetworkError) || token.isCancellationRequested) {
|
|
494
|
-
throw error;
|
|
495
|
-
}
|
|
496
|
-
this._logService.warn(
|
|
497
|
-
`${LOG_PREFIX} Connection request failed for environment ${options.environmentId}; retrying in ${CONNECTION_RETRY_DELAY_MS}ms: ${formatConnectionDiagnosticError(getConnectionDiagnosticError(error))}`
|
|
498
|
-
);
|
|
499
|
-
await timeout(CONNECTION_RETRY_DELAY_MS, token);
|
|
500
|
-
continue;
|
|
501
|
-
}
|
|
502
|
-
if (result.kind === "token") {
|
|
503
|
-
return await this._awaitSealedToken(options, result.token, token, telemetry);
|
|
504
|
-
}
|
|
505
|
-
const delayMs = this._wakingRetryDelay(result.waking.retryAfterSeconds);
|
|
506
|
-
this._logService.info(
|
|
507
|
-
`${LOG_PREFIX} Environment ${options.environmentId} waking; retrying in ${delayMs}ms (attempt ${attempt})`
|
|
508
|
-
);
|
|
509
|
-
await timeout(delayMs, token);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
_wakingRetryDelay(retryAfterSeconds, minimumDelayMs = MIN_WAKING_RETRY_DELAY_MS) {
|
|
513
|
-
const delay = Math.max(retryAfterSeconds * 1000, minimumDelayMs);
|
|
514
|
-
const jitterMs = Math.max(1, Math.floor(Math.random() * Math.min(1000, delay * 0.2)));
|
|
515
|
-
const withJitter = delay + jitterMs;
|
|
516
|
-
if (!Number.isFinite(withJitter)) {
|
|
517
|
-
throw ( new Error(( localize(13248, "The sandbox returned an invalid retry delay."))));
|
|
518
|
-
}
|
|
519
|
-
return Math.min(withJitter, CONNECTION_TIMEOUT_MS);
|
|
520
|
-
}
|
|
521
|
-
async _awaitSealedToken(options, minted, token, telemetry) {
|
|
522
|
-
let clientToken = minted;
|
|
523
|
-
let delayMs = this.sealedTokenRetryDelayMs;
|
|
524
|
-
for (let attempt = 0; attempt < MAX_SEALED_TOKEN_RETRIES && !isCloudSandboxSealedToken(clientToken.encrypted_github_token); attempt++) {
|
|
525
|
-
if (token.isCancellationRequested) {
|
|
526
|
-
throw ( new CancellationError());
|
|
527
|
-
}
|
|
528
|
-
this._logService.info(
|
|
529
|
-
`${LOG_PREFIX} Environment ${options.environmentId} has no sealed GitHub token yet; refreshing in ${delayMs}ms (attempt ${attempt + 1}/${MAX_SEALED_TOKEN_RETRIES})`
|
|
530
|
-
);
|
|
531
|
-
await timeout(delayMs, token);
|
|
532
|
-
let result;
|
|
533
|
-
try {
|
|
534
|
-
result = await this._apiService.reconnect({
|
|
535
|
-
environmentId: options.environmentId,
|
|
536
|
-
sessionId: options.sessionId,
|
|
537
|
-
onRequest: telemetry?.createRequestObserver()
|
|
538
|
-
}, minted.client_id, token);
|
|
539
|
-
} catch (err) {
|
|
540
|
-
if (isCancellationError(err) || token.isCancellationRequested) {
|
|
541
|
-
throw err;
|
|
542
|
-
}
|
|
543
|
-
this._logService.warn(
|
|
544
|
-
`${LOG_PREFIX} Credential refresh for ${options.environmentId} failed; continuing without a sealed token`,
|
|
545
|
-
err
|
|
546
|
-
);
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
if (result.kind !== "token") {
|
|
550
|
-
delayMs = this._wakingRetryDelay(result.waking.retryAfterSeconds, SEALED_TOKEN_RETRY_DELAY_MS);
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
clientToken = result.token;
|
|
554
|
-
delayMs = this.sealedTokenRetryDelayMs;
|
|
555
|
-
}
|
|
556
|
-
return clientToken;
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
CloudSandboxAgentHostService = ( __decorate([( __param(0, IRemoteAgentHostService)), ( __param(1, ICloudSandboxApiService)), ( __param(2, IConfigurationService)), ( __param(3, IInstantiationService)), ( __param(4, ILogService)), ( __param(5, IAgentHostService))], CloudSandboxAgentHostService));
|
|
560
|
-
|
|
561
|
-
export { CloudSandboxAgentHostService, MAX_SEALED_TOKEN_RETRIES };
|