@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.
Files changed (144) hide show
  1. package/common.js +0 -53
  2. package/index.js +0 -3
  3. package/package.json +5 -5
  4. package/session.js +0 -3
  5. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/missionControlAgentHostContribution.js +1 -1
  6. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostActions.js +1 -1
  7. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.js +1 -1
  8. package/vscode/src/vs/workbench/contrib/chat/browser/chat.shared.contribution.js +6 -6
  9. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.d.ts +1 -1
  10. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.js +1 -1
  11. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.d.ts +1 -1
  12. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.js +2 -2
  13. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentActions.js +1 -1
  14. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHost.contribution.js +7 -7
  15. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostChatContribution.js +4 -4
  16. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewTitleControl.js +1 -1
  17. package/vscode/src/vs/platform/agentHost/browser/webPubSubRelayTransport.d.ts +0 -135
  18. package/vscode/src/vs/platform/agentHost/browser/webPubSubRelayTransport.js +0 -510
  19. package/vscode/src/vs/platform/agentHost/common/agentModelNotices.d.ts +0 -22
  20. package/vscode/src/vs/platform/agentHost/common/agentModelNotices.js +0 -21
  21. package/vscode/src/vs/platform/agentHost/common/cloudSandboxAgentHost.d.ts +0 -273
  22. package/vscode/src/vs/platform/agentHost/common/cloudSandboxAgentHost.js +0 -61
  23. package/vscode/src/vs/platform/agentHost/common/meta/agentModelMeta.d.ts +0 -7
  24. package/vscode/src/vs/platform/agentHost/common/meta/agentModelMeta.js +0 -17
  25. package/vscode/src/vs/platform/agentHost/common/meta/copilotd/cloudSandboxProjectMeta.d.ts +0 -12
  26. package/vscode/src/vs/platform/agentHost/common/meta/copilotd/cloudSandboxProjectMeta.js +0 -48
  27. package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelEnsembleMeta.d.ts +0 -8
  28. package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelEnsembleMeta.js +0 -11
  29. package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelPricing.d.ts +0 -114
  30. package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelPricing.js +0 -141
  31. package/vscode/src/vs/platform/agentHost/common/taskEventReplay.d.ts +0 -48
  32. package/vscode/src/vs/platform/agentHost/common/taskEventReplay.js +0 -238
  33. package/vscode/src/vs/platform/agentHost/common/webPubSub/chunking.d.ts +0 -102
  34. package/vscode/src/vs/platform/agentHost/common/webPubSub/chunking.js +0 -260
  35. package/vscode/src/vs/platform/agentHost/common/webPubSub/framing.d.ts +0 -102
  36. package/vscode/src/vs/platform/agentHost/common/webPubSub/framing.js +0 -115
  37. package/vscode/src/vs/platform/agentHost/common/webPubSub/groups.d.ts +0 -46
  38. package/vscode/src/vs/platform/agentHost/common/webPubSub/groups.js +0 -92
  39. package/vscode/src/vs/sessions/contrib/chat/browser/newSession.d.ts +0 -9
  40. package/vscode/src/vs/sessions/contrib/chat/browser/voiceBridge.contribution.d.ts +0 -14
  41. package/vscode/src/vs/sessions/contrib/chat/browser/voiceBridge.contribution.js +0 -385
  42. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.d.ts +0 -67
  43. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.js +0 -695
  44. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.d.ts +0 -4
  45. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.js +0 -39
  46. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.d.ts +0 -1
  47. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.js +0 -59
  48. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.d.ts +0 -1
  49. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.js +0 -83
  50. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.d.ts +0 -87
  51. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.js +0 -176
  52. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.d.ts +0 -422
  53. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.js +0 -2444
  54. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.d.ts +0 -91
  55. package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.js +0 -620
  56. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.d.ts +0 -1
  57. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.js +0 -5
  58. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.d.ts +0 -46
  59. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.js +0 -321
  60. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.d.ts +0 -104
  61. package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.js +0 -345
  62. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoice.contribution.d.ts +0 -2
  63. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoice.contribution.js +0 -611
  64. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceSessionsPicker.d.ts +0 -20
  65. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceSessionsPicker.js +0 -85
  66. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.d.ts +0 -200
  67. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.js +0 -981
  68. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidgetBinding.d.ts +0 -24
  69. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidgetBinding.js +0 -206
  70. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWindowService.d.ts +0 -65
  71. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWindowService.js +0 -368
  72. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/confirmationComponent.d.ts +0 -10
  73. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/confirmationComponent.js +0 -57
  74. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/feedbackDialog.d.ts +0 -33
  75. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/feedbackDialog.js +0 -98
  76. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/headerComponent.d.ts +0 -32
  77. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/headerComponent.js +0 -186
  78. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/onboardingComponent.d.ts +0 -12
  79. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/onboardingComponent.js +0 -116
  80. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/sessionListComponent.d.ts +0 -32
  81. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/sessionListComponent.js +0 -226
  82. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/statusRowsComponent.d.ts +0 -18
  83. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/statusRowsComponent.js +0 -138
  84. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/tokens.d.ts +0 -32
  85. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/tokens.js +0 -29
  86. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/transcriptComponent.d.ts +0 -13
  87. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/transcriptComponent.js +0 -108
  88. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/voiceBarComponent.d.ts +0 -13
  89. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/voiceBarComponent.js +0 -63
  90. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/media/voiceModeOnboarding.css +0 -252
  91. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscripts.contribution.d.ts +0 -1
  92. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscripts.contribution.js +0 -178
  93. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscriptsView.d.ts +0 -47
  94. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscriptsView.js +0 -322
  95. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.d.ts +0 -146
  96. package/vscode/src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.js +0 -890
  97. package/vscode/src/vs/workbench/contrib/agentsVoice/common/voiceTranscriptStore.d.ts +0 -132
  98. package/vscode/src/vs/workbench/contrib/agentsVoice/common/voiceTranscriptStore.js +0 -237
  99. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.d.ts +0 -120
  100. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.js +0 -234
  101. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.d.ts +0 -36
  102. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.js +0 -164
  103. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/repositoryPicker.d.ts +0 -21
  104. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/repositoryPicker.js +0 -122
  105. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupMicrosoftProbe.d.ts +0 -82
  106. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupMicrosoftProbe.js +0 -213
  107. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxAgentHostService.d.ts +0 -40
  108. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxAgentHostService.js +0 -561
  109. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxApiService.d.ts +0 -133
  110. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxApiService.js +0 -1176
  111. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxConnectionCustomization.d.ts +0 -17
  112. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxConnectionCustomization.js +0 -76
  113. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxCredentialRefresh.d.ts +0 -54
  114. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxCredentialRefresh.js +0 -220
  115. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxHistoryCache.d.ts +0 -21
  116. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxHistoryCache.js +0 -184
  117. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxLegacySessionPreparation.d.ts +0 -8
  118. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxLegacySessionPreparation.js +0 -165
  119. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxModels.d.ts +0 -43
  120. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxModels.js +0 -162
  121. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxReadOnlySessionHandler.d.ts +0 -40
  122. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxReadOnlySessionHandler.js +0 -129
  123. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.d.ts +0 -166
  124. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.js +0 -838
  125. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionHandler.d.ts +0 -40
  126. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionHandler.js +0 -604
  127. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.d.ts +0 -289
  128. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.js +0 -497
  129. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlCredentialSealing.d.ts +0 -6
  130. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlCredentialSealing.js +0 -41
  131. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentService.d.ts +0 -73
  132. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentService.js +0 -398
  133. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlSharingService.d.ts +0 -45
  134. package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlSharingService.js +0 -296
  135. package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/voiceCodeTranscriptionClient.d.ts +0 -63
  136. package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/voiceCodeTranscriptionClient.js +0 -361
  137. package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/ttsPlaybackService.d.ts +0 -34
  138. package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/ttsPlaybackService.js +0 -198
  139. package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/voiceClientService.d.ts +0 -131
  140. package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/voiceClientService.js +0 -871
  141. package/vscode/src/vs/workbench/contrib/chat/browser/voiceInputMode/voiceInputMode.d.ts +0 -66
  142. package/vscode/src/vs/workbench/contrib/chat/browser/voiceInputMode/voiceInputMode.js +0 -297
  143. package/vscode/src/vs/workbench/contrib/chat/common/voicePlaybackService.d.ts +0 -31
  144. package/vscode/src/vs/workbench/contrib/chat/common/voicePlaybackService.js +0 -118
@@ -1,838 +0,0 @@
1
-
2
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { raceCancellation, raceCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
4
- import { CancellationTokenSource, CancellationToken, cancelOnDispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
5
- import { CancellationError, isCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
6
- import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
7
- import { Disposable, DisposableMap, toDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
8
- import { isObject } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
9
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
10
- import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
11
- import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
12
- import { CloudSandboxEnabledSettingId, CloudSandboxAuthenticationRequiredError, cloudSandboxAddress, CLOUD_SANDBOX_AGENT_PROVIDER, CLOUD_SANDBOX_SESSION_SCHEME, CloudSandboxAutoConnectOnOpenSettingId, isCloudSandboxEnabled } from '../../../../../platform/agentHost/common/cloudSandboxAgentHost.js';
13
- import { ICloudSandboxAgentHostService, ICloudSandboxApiService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/cloudSandboxAgentHost.service';
14
- import { AgentSession } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agent';
15
- import { IAgentHostService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentService.service';
16
- import { agentHostAuthority, AGENT_HOST_SCHEME } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostUri';
17
- import { findRemoteAgentHostSessionTypeAuthority, remoteAgentHostSessionTypeId } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostSessionType';
18
- import { getEntryAddress, RemoteAgentHostEntryType, RemoteAgentHostsEnabledSettingId, RemoteAgentHostConnectionStatus } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/remoteAgentHostService';
19
- import { IRemoteAgentHostService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/remoteAgentHostService.service';
20
- import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
21
- import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
22
- import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
23
- import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
24
- import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
25
- import { IWorkspaceTrustManagementService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspaceTrust.service';
26
- import { ChatSessionsExtensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService';
27
- import { IChatSessionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService.service';
28
- import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service';
29
- import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
30
- import { CloudSandboxSessionHandler } from './cloudSandboxSessionHandler.js';
31
- import { IRemoteAgentHostConnectionCustomizationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostConnectionCustomization.service';
32
- import { isCloudSandboxConnectionAddress, createCloudSandboxConnectionCustomization } from './cloudSandboxConnectionCustomization.js';
33
- import { sealMissionControlMcpCredential } from './missionControlCredentialSealing.js';
34
- import { withSessionInitiator } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/meta/agentSessionInitiatorMeta';
35
-
36
- const LOG_PREFIX = "[CloudSandboxAgentHost]";
37
- const DISCOVERY_STALE_AFTER_MS = 60_000;
38
- const FULL_DISCOVERY_INTERVAL_MS = 15 * 60_000;
39
- const MAX_DISCOVERY_RETRY_INTERVAL_MS = 5 * 60_000;
40
- const INVENTORY_STORAGE_PREFIX = "sessions.cloudSandbox.inventory.";
41
- function isDiscoveredSandboxSession(value) {
42
- const candidate = value;
43
- return isObject(candidate) && typeof candidate.environmentId === "string" && candidate.environmentId.length > 0 && typeof candidate.sessionId === "string" && candidate.sessionId.length > 0 && typeof candidate.taskId === "string" && candidate.taskId.length > 0 && typeof candidate.name === "string" && (candidate.eventType === undefined || typeof candidate.eventType === "string") && (candidate.repoName === undefined || typeof candidate.repoName === "string") && (candidate.hasRepository === undefined || typeof candidate.hasRepository === "boolean") && (candidate.updatedAt === undefined || typeof candidate.updatedAt === "string") && (candidate.isArchived === undefined || typeof candidate.isArchived === "boolean");
44
- }
45
- function discoveredSessionProject(repoName) {
46
- if (!repoName) {
47
- return undefined;
48
- }
49
- return {
50
- uri: ( URI.parse(`https://github.com/${repoName}`)),
51
- displayName: repoName
52
- };
53
- }
54
- let CloudSandboxSessionContribution = class CloudSandboxSessionContribution extends Disposable {
55
- constructor(
56
- _cloudSandboxService,
57
- _apiService,
58
- _remoteAgentHostService,
59
- _connectionCustomizations,
60
- _configurationService,
61
- _instantiationService,
62
- _chatSessionsService,
63
- _logService,
64
- _chatEntitlementService,
65
- _hostService,
66
- _storageService,
67
- _workspaceTrustManagementService,
68
- _localAgentHostService
69
- ) {
70
- super();
71
- this._cloudSandboxService = _cloudSandboxService;
72
- this._apiService = _apiService;
73
- this._remoteAgentHostService = _remoteAgentHostService;
74
- this._connectionCustomizations = _connectionCustomizations;
75
- this._configurationService = _configurationService;
76
- this._instantiationService = _instantiationService;
77
- this._chatSessionsService = _chatSessionsService;
78
- this._logService = _logService;
79
- this._chatEntitlementService = _chatEntitlementService;
80
- this._hostService = _hostService;
81
- this._storageService = _storageService;
82
- this._workspaceTrustManagementService = _workspaceTrustManagementService;
83
- this._localAgentHostService = _localAgentHostService;
84
- this._providerInstances = ( new Map());
85
- this._providerStores = this._register(( new DisposableMap()));
86
- this._persistedInventory = ( new Map());
87
- this._environments = ( new Map());
88
- this._pendingConnects = ( new Map());
89
- this._provisioning = ( new Set());
90
- this._historyHandlers = this._register(( new DisposableMap()));
91
- this._enabledCts = ( new CancellationTokenSource());
92
- this._discoveryIncremental = false;
93
- this._discoveryRetryInterval = DISCOVERY_STALE_AFTER_MS;
94
- this._deletedTaskIds = ( new Set());
95
- this._register(
96
- this._connectionCustomizations.register(isCloudSandboxConnectionAddress, address => {
97
- const connection = this._remoteAgentHostService.configuredEntries.find(entry => getEntryAddress(entry) === address)?.connection;
98
- const userLocal = connection?.type === RemoteAgentHostEntryType.CloudSandbox && connection.environmentKind === "user-local";
99
- const customization = createCloudSandboxConnectionCustomization(address, this._cloudSandboxService, userLocal, async request => {
100
- if (!userLocal) {
101
- throw ( new Error("User-local MC sealing requires a user-local connection."));
102
- }
103
- const environment = await this._apiService.getEnvironment(connection.environmentId, CancellationToken.None);
104
- const client = this._remoteAgentHostService.getConnection(address);
105
- const root = client?.rootState.value;
106
- if (environment.id !== connection.environmentId || !client || !root || root instanceof Error) {
107
- throw ( new Error("Mission Control environment or host is unavailable for sealing."));
108
- }
109
- const initialization = client.initializeResult.get();
110
- const result = await sealMissionControlMcpCredential(
111
- request,
112
- environment.encryption_keys,
113
- root,
114
- initialization?._meta,
115
- sealingRequest => {
116
- if (!this._localAgentHostService.sealMissionControlCredential) {
117
- throw ( new Error("Trusted local credential sealing is unavailable."));
118
- }
119
- return this._localAgentHostService.sealMissionControlCredential(sealingRequest);
120
- }
121
- );
122
- if (this._remoteAgentHostService.getConnection(address) !== client || client.initializeResult.get() !== initialization) {
123
- throw ( new CancellationError());
124
- }
125
- return result;
126
- });
127
- return {
128
- ...customization,
129
- registerChatSessionContentProvider: (sessionType, provider) => this._registerLiveSessionProvider(sessionType, provider)
130
- };
131
- })
132
- );
133
- this._register(this._remoteAgentHostService.onDidChangeConnections(() => {
134
- this._wireConnections();
135
- this._updateConnectionStatuses();
136
- }));
137
- this._register(this._configurationService.onDidChangeConfiguration(e => {
138
- if (e.affectsConfiguration(CloudSandboxEnabledSettingId) || e.affectsConfiguration(RemoteAgentHostsEnabledSettingId)) {
139
- this._updateEnablement();
140
- }
141
- }));
142
- this._register(
143
- this._chatEntitlementService.onDidChangeSentiment(() => this._updateEnablement())
144
- );
145
- this._register(this._hostService.onDidChangeFocus(focused => {
146
- if (focused) {
147
- void this._refreshIfStale();
148
- }
149
- }));
150
- this._register(this._apiService.onDidChangeAccount(accountKey => {
151
- if (!this._isEnabled()) {
152
- return;
153
- }
154
- this._restoreAccount(accountKey);
155
- void this._discoverAndSeed(false, true);
156
- }));
157
- this._register(toDisposable(() => {
158
- this._enabledCts.cancel();
159
- this._enabledCts.dispose();
160
- for (const address of [...( this._environments.keys())]) {
161
- this._teardownEnvironment(address);
162
- }
163
- }));
164
- this._register(( Registry.as(ChatSessionsExtensions.AsyncActivation)).register({
165
- priority: 1,
166
- matchSessionType: sessionType => this._findAddressForSessionType(sessionType) !== undefined,
167
- getActivationToken: sessionType => {
168
- const address = this._findAddressForSessionType(sessionType);
169
- return (address ? this._providerStores.get(address)?.token : undefined) ?? CancellationToken.Cancelled;
170
- },
171
- waitForActivation: (_accessor, sessionType) => this._waitForActivation(sessionType)
172
- }));
173
- }
174
- async _refreshIfStale() {
175
- if (this._discoveryInFlight) {
176
- await (this._discoveryQueued ?? this._discoveryInFlight);
177
- return;
178
- }
179
- if (!this._hostService.hasFocus || (this._lastDiscoveryAttempt !== undefined && Date.now() - this._lastDiscoveryAttempt < this._discoveryRetryInterval)) {
180
- return;
181
- }
182
- await this._discoverAndSeed(true);
183
- }
184
- _discoverAndSeed(incremental = false, retry = false) {
185
- if (!this._isEnabled() || this._store.isDisposed) {
186
- return Promise.resolve();
187
- }
188
- if (this._discoveryInFlight) {
189
- if (!retry && this._discoveryToken === this._enabledCts.token && (incremental || !this._discoveryIncremental)) {
190
- return this._discoveryQueued ?? this._discoveryInFlight;
191
- }
192
- this._discoveryQueued ??= this._discoveryInFlight.then(() => {
193
- this._discoveryQueued = undefined;
194
- return this._discoverAndSeed();
195
- });
196
- return this._discoveryQueued;
197
- }
198
- this._lastDiscoveryAttempt = Date.now();
199
- this._discoveryIncremental = incremental && this._lastFullDiscovery !== undefined && this._lastDiscoveryAttempt - this._lastFullDiscovery < FULL_DISCOVERY_INTERVAL_MS;
200
- this._discoveryToken = this._enabledCts.token;
201
- this._discoveryInFlight = this._doDiscoverAndSeed(this._discoveryToken, this._discoveryIncremental).finally(() => {
202
- this._discoveryInFlight = undefined;
203
- this._discoveryToken = undefined;
204
- });
205
- return this._discoveryInFlight;
206
- }
207
- async _doDiscoverAndSeed(token, incremental) {
208
- let result;
209
- try {
210
- const accountKey = await this._apiService.getAccountKey();
211
- if (token.isCancellationRequested || !this._isEnabled()) {
212
- return;
213
- }
214
- if (this._restoreAccount(accountKey)) {
215
- token = this._enabledCts.token;
216
- this._discoveryToken = token;
217
- this._discoveryIncremental = incremental = false;
218
- this._lastDiscoveryAttempt = Date.now();
219
- }
220
- if (!accountKey) {
221
- throw ( new CloudSandboxAuthenticationRequiredError());
222
- }
223
- result = await this._apiService.listSessions(token, {
224
- incremental
225
- });
226
- } catch (error) {
227
- if (token.isCancellationRequested || isCancellationError(error) || !this._isEnabled()) {
228
- return;
229
- }
230
- result = {
231
- kind: "failed",
232
- reason: error instanceof Error ? error.message : String(error)
233
- };
234
- }
235
- if (token.isCancellationRequested || !this._isEnabled()) {
236
- return;
237
- }
238
- this._discoveryRetryInterval = result.kind === "failed" || result.kind === "partial" ? Math.min(this._discoveryRetryInterval * 2, MAX_DISCOVERY_RETRY_INTERVAL_MS) : DISCOVERY_STALE_AFTER_MS;
239
- if (result.kind === "failed") {
240
- this._logService.warn(`${LOG_PREFIX} Discovery failed: ${result.reason}`);
241
- return;
242
- }
243
- if (result.kind === "complete") {
244
- this._lastFullDiscovery = Date.now();
245
- }
246
- const present = ( new Set());
247
- const updatedTasks = ( new Set());
248
- for (const session of result.sessions) {
249
- if (!session.environmentId || !session.sessionId || ( this._deletedTaskIds.has(session.taskId))) {
250
- continue;
251
- }
252
- const address = cloudSandboxAddress(session.environmentId);
253
- present.add(address);
254
- updatedTasks.add(session.taskId);
255
- this._seedDiscoveredSession({
256
- ...session,
257
- isArchived: session.isArchived === true
258
- });
259
- }
260
- const removedTasks = ( new Set(result.kind === "complete" ? [] : result.removedTaskIds));
261
- for (const [address, environment] of this._environments) {
262
- if (( present.has(address)) || ( this._provisioning.has(address))) {
263
- continue;
264
- }
265
- if (result.kind !== "complete" && (!environment.taskId || (!( removedTasks.has(environment.taskId)) && !( updatedTasks.has(environment.taskId))))) {
266
- continue;
267
- }
268
- const connected = ( this._remoteAgentHostService.connections.some(
269
- c => c.address === address && RemoteAgentHostConnectionStatus.isConnected(c.status)
270
- ));
271
- if (!connected) {
272
- this._teardownEnvironment(address);
273
- }
274
- }
275
- this._persistInventory();
276
- this._logService.info(
277
- `${LOG_PREFIX} Seeded ${present.size} discovered sandbox environment(s)${result.kind === "partial" ? " (partial scan; kept existing entries)" : ""}.`
278
- );
279
- }
280
- _seedDiscoveredSession(session) {
281
- this._ensureProvider(session);
282
- const address = cloudSandboxAddress(session.environmentId);
283
- this._environments.set(address, session);
284
- const provider = this._providerInstances.get(address);
285
- provider?.setLabel?.(session.name);
286
- const parsed = session.updatedAt ? Date.parse(session.updatedAt) : Number.NaN;
287
- const modifiedTime = Number.isNaN(parsed) ? provider?.getSessionModifiedTime(session.sessionId) ?? Date.now() : parsed;
288
- const project = discoveredSessionProject(session.repoName);
289
- provider?.seedSessions([{
290
- session: AgentSession.uri(CLOUD_SANDBOX_SESSION_SCHEME, session.sessionId),
291
- provider: CLOUD_SANDBOX_AGENT_PROVIDER,
292
- ...(session.eventType ? {
293
- _meta: withSessionInitiator(undefined, {
294
- name: session.eventType
295
- })
296
- } : {}),
297
- startTime: modifiedTime,
298
- modifiedTime,
299
- summary: session.name,
300
- ...(session.status !== undefined ? {
301
- status: session.status
302
- } : {}),
303
- ...(project ? {
304
- project
305
- } : {})
306
- }], {
307
- updateExisting: true,
308
- workspaceless: session.hasRepository === undefined ? undefined : !session.hasRepository
309
- });
310
- if (session.isArchived !== undefined) {
311
- provider?.setSessionArchived(session.sessionId, session.isArchived);
312
- }
313
- }
314
- _restoreAccount(accountKey) {
315
- if (accountKey === this._accountKey) {
316
- return false;
317
- }
318
- this._teardownAll();
319
- this._accountKey = accountKey;
320
- if (accountKey) {
321
- const storageKey = INVENTORY_STORAGE_PREFIX + accountKey;
322
- const keys = ( this._storageService.keys(StorageScope.PROFILE, StorageTarget.MACHINE)).filter(key => key.startsWith(`${storageKey}.`));
323
- let restored = 0;
324
- for (const key of keys) {
325
- const sessions = this._readInventory(key);
326
- this._persistedInventory.set(key, JSON.stringify({
327
- version: 1,
328
- sessions
329
- }));
330
- for (const session of sessions) {
331
- this._seedDiscoveredSession(session);
332
- restored++;
333
- }
334
- }
335
- if (keys.length === 0 && this._storageService.get(storageKey, StorageScope.PROFILE) !== undefined) {
336
- for (const session of this._readInventory(storageKey)) {
337
- this._seedDiscoveredSession(session);
338
- restored++;
339
- }
340
- this._persistInventory();
341
- }
342
- if (restored) {
343
- this._logService.info(`${LOG_PREFIX} Restored ${restored} cached sandbox environment(s).`);
344
- }
345
- }
346
- return true;
347
- }
348
- _readInventory(storageKey) {
349
- let cached;
350
- try {
351
- cached = this._storageService.getObject(storageKey, StorageScope.PROFILE);
352
- } catch (error) {
353
- this._logService.warn(`${LOG_PREFIX} Reading cached sandbox inventory failed.`, error);
354
- return [];
355
- }
356
- if (cached !== undefined) {
357
- if (isObject(cached) && cached.version === 1 && Array.isArray(cached.sessions) && cached.sessions.every(isDiscoveredSandboxSession)) {
358
- return cached.sessions;
359
- }
360
- this._logService.warn(`${LOG_PREFIX} Ignoring invalid cached sandbox inventory.`);
361
- }
362
- return [];
363
- }
364
- _persistInventory() {
365
- if (!this._accountKey) {
366
- return;
367
- }
368
- const storageKey = INVENTORY_STORAGE_PREFIX + this._accountKey;
369
- const inventory = ( new Map());
370
- const entries = [];
371
- for (const environment of ( this._environments.values())) {
372
- if (environment.sessionId && environment.taskId) {
373
- const session = {
374
- environmentId: environment.environmentId,
375
- sessionId: environment.sessionId,
376
- taskId: environment.taskId,
377
- eventType: environment.eventType,
378
- name: environment.name,
379
- repoName: environment.repoName,
380
- hasRepository: environment.hasRepository,
381
- updatedAt: environment.updatedAt,
382
- ...(environment.isArchived !== undefined ? {
383
- isArchived: environment.isArchived
384
- } : {})
385
- };
386
- const key = `${storageKey}.${JSON.stringify([session.environmentId, session.sessionId])}`;
387
- const value = JSON.stringify({
388
- version: 1,
389
- sessions: [session]
390
- });
391
- inventory.set(key, value);
392
- if (this._persistedInventory.get(key) !== value) {
393
- entries.push({
394
- key,
395
- value,
396
- scope: StorageScope.PROFILE,
397
- target: StorageTarget.MACHINE
398
- });
399
- }
400
- }
401
- }
402
- for (const key of ( this._persistedInventory.keys())) {
403
- if (!( inventory.has(key))) {
404
- entries.push({
405
- key,
406
- value: undefined,
407
- scope: StorageScope.PROFILE,
408
- target: StorageTarget.MACHINE
409
- });
410
- }
411
- }
412
- if (this._storageService.get(storageKey, StorageScope.PROFILE) !== undefined) {
413
- entries.push({
414
- key: storageKey,
415
- value: undefined,
416
- scope: StorageScope.PROFILE,
417
- target: StorageTarget.MACHINE
418
- });
419
- }
420
- this._persistedInventory = inventory;
421
- this._storageService.storeAll(entries, false);
422
- }
423
- _ownsSandboxSession(address, rawId) {
424
- const environment = this._environments.get(address);
425
- return !!environment?.taskId && environment.sessionId === rawId;
426
- }
427
- async _renameSandboxSession(address, rawId, title) {
428
- const environment = this._environments.get(address);
429
- if (!environment?.taskId || environment.sessionId !== rawId) {
430
- throw ( new Error(( localize(13267, "Mission Control sandbox session not found."))));
431
- }
432
- const store = ( new DisposableStore());
433
- const source = store.add(( new CancellationTokenSource(this._enabledCts.token)));
434
- try {
435
- await this._apiService.renameTask(environment.taskId, title, source.token);
436
- if (source.token.isCancellationRequested) {
437
- throw ( new CancellationError());
438
- }
439
- } finally {
440
- store.dispose();
441
- }
442
- const current = this._environments.get(address);
443
- if (current?.taskId !== environment.taskId || current.sessionId !== rawId) {
444
- throw ( new CancellationError());
445
- }
446
- this._environments.set(address, {
447
- ...current,
448
- name: title
449
- });
450
- this._persistInventory();
451
- }
452
- async _setSandboxSessionArchived(address, rawId, archived, token = CancellationToken.None) {
453
- const environment = this._environments.get(address);
454
- if (!environment?.taskId || environment.sessionId !== rawId) {
455
- throw ( new Error(( localize(13268, "Mission Control sandbox session not found."))));
456
- }
457
- if (token.isCancellationRequested) {
458
- throw ( new CancellationError());
459
- }
460
- const store = ( new DisposableStore());
461
- const source = store.add(( new CancellationTokenSource(this._enabledCts.token)));
462
- store.add(token.onCancellationRequested(() => source.cancel()));
463
- try {
464
- await this._apiService.setTaskArchived(environment.taskId, archived, source.token);
465
- if (source.token.isCancellationRequested) {
466
- throw ( new CancellationError());
467
- }
468
- } finally {
469
- store.dispose();
470
- }
471
- const current = this._environments.get(address);
472
- if (current?.taskId !== environment.taskId || current.sessionId !== rawId) {
473
- throw ( new CancellationError());
474
- }
475
- this._environments.set(address, {
476
- ...current,
477
- isArchived: archived
478
- });
479
- this._persistInventory();
480
- }
481
- async _deleteSandboxSession(address, sessionIds, removeSession, token = CancellationToken.None) {
482
- const environment = this._environments.get(address);
483
- if (!environment?.taskId || !environment.sessionId || ( sessionIds.some(id => id !== environment.sessionId))) {
484
- throw ( new Error(( localize(13269, "Mission Control sandbox session not found."))));
485
- }
486
- if (sessionIds.length === 0) {
487
- return;
488
- }
489
- if (token.isCancellationRequested) {
490
- throw ( new CancellationError());
491
- }
492
- const store = ( new DisposableStore());
493
- const source = store.add(( new CancellationTokenSource(this._enabledCts.token)));
494
- store.add(token.onCancellationRequested(() => source.cancel()));
495
- try {
496
- await this._apiService.deleteTask(environment.taskId, source.token);
497
- if (source.token.isCancellationRequested) {
498
- throw ( new CancellationError());
499
- }
500
- } finally {
501
- store.dispose();
502
- }
503
- this._deletedTaskIds.add(environment.taskId);
504
- removeSession(environment.sessionId);
505
- this._teardownEnvironment(address);
506
- this._persistInventory();
507
- }
508
- async _disconnectEnvironment(address) {
509
- this._cancelPendingConnect(address);
510
- try {
511
- await this._cloudSandboxService.disconnect(address);
512
- } catch (error) {
513
- this._logService.warn(
514
- `${LOG_PREFIX} Failed to disconnect ${address}: ${error instanceof Error ? error.message : String(error)}`
515
- );
516
- } finally {
517
- if (!( this._pendingConnects.has(address))) {
518
- this._settleFailedConnect(address);
519
- }
520
- }
521
- }
522
- _cancelPendingConnect(address) {
523
- const pending = this._pendingConnects.get(address);
524
- this._pendingConnects.delete(address);
525
- pending?.source.dispose(true);
526
- }
527
- _teardownEnvironment(address) {
528
- const taskId = this._environments.get(address)?.taskId;
529
- if (taskId) {
530
- this._apiService.clearSessionHistory(taskId);
531
- }
532
- this._environments.delete(address);
533
- this._cancelPendingConnect(address);
534
- this._providerStores.deleteAndDispose(address);
535
- this._clearSessionHandlers(address);
536
- void this._disconnectEnvironment(address);
537
- }
538
- _teardownAll() {
539
- this._apiService.clearSessionHistory();
540
- this._enabledCts.cancel();
541
- this._enabledCts.dispose();
542
- this._enabledCts = ( new CancellationTokenSource());
543
- this._lastDiscoveryAttempt = undefined;
544
- this._lastFullDiscovery = undefined;
545
- this._discoveryRetryInterval = DISCOVERY_STALE_AFTER_MS;
546
- this._accountKey = undefined;
547
- this._deletedTaskIds.clear();
548
- this._persistedInventory.clear();
549
- for (const address of [...( this._environments.keys())]) {
550
- this._teardownEnvironment(address);
551
- }
552
- }
553
- _authoritiesByAddress() {
554
- const byAuthority = ( new Map());
555
- for (const address of ( this._environments.keys())) {
556
- byAuthority.set(agentHostAuthority(address), address);
557
- }
558
- return byAuthority;
559
- }
560
- _findAddressForSessionType(sessionType) {
561
- const byAuthority = this._authoritiesByAddress();
562
- const authority = findRemoteAgentHostSessionTypeAuthority(sessionType, ( byAuthority.keys()));
563
- return authority ? byAuthority.get(authority) : undefined;
564
- }
565
- get supportsBackgroundConnection() {
566
- return false;
567
- }
568
- async _waitForActivation(sessionType) {
569
- const address = this._findAddressForSessionType(sessionType);
570
- const env = address ? this._environments.get(address) : undefined;
571
- const provider = address ? this._providerInstances.get(address) : undefined;
572
- if (!address || !env || !provider) {
573
- return false;
574
- }
575
- const token = this._providerStores.get(address)?.token ?? CancellationToken.Cancelled;
576
- const isCurrentActivation = () => {
577
- const current = !token.isCancellationRequested && this._isEnabled() && ( this._environments.has(address)) && this._providerInstances.get(address) === provider;
578
- if (!current) {
579
- this._logService.trace(`${LOG_PREFIX} Abandoning activation for ${address} after teardown.`);
580
- }
581
- return current;
582
- };
583
- if (env.taskId) {
584
- const activated = this._activateHistory(sessionType, address, env);
585
- if (activated) {
586
- void this._connectOnOpen(sessionType, address, env, token, isCurrentActivation).catch(error => {
587
- if (!isCancellationError(error)) {
588
- this._logService.warn(`${LOG_PREFIX} Background activation failed for ${address}`, error);
589
- }
590
- });
591
- }
592
- return activated && isCurrentActivation() && this._chatSessionsService.getContentProviderSchemes().includes(sessionType);
593
- }
594
- return this._connectOnOpen(sessionType, address, env, token, isCurrentActivation);
595
- }
596
- async _connectOnOpen(sessionType, address, env, token, isCurrentActivation) {
597
- const shouldConnect = this.supportsBackgroundConnection ? this._configurationService.getValue(CloudSandboxAutoConnectOnOpenSettingId) === true : !env.taskId || ( this._pendingConnects.has(address)) || (await this._isEnvironmentOnline(env, token));
598
- if (!isCurrentActivation()) {
599
- return false;
600
- }
601
- if (!shouldConnect && !( this._pendingConnects.has(address))) {
602
- this._logService.info(
603
- `${LOG_PREFIX} Not connecting automatically to ${address}; serving history and leaving the connect to the user.`
604
- );
605
- return !!env.taskId;
606
- }
607
- const connecting = this.connect({
608
- environmentId: env.environmentId,
609
- sessionId: env.sessionId,
610
- name: env.name
611
- }).then(() => undefined, error => {
612
- this._logService.warn(
613
- `${LOG_PREFIX} connect-on-open failed for ${address}: ${error instanceof Error ? error.message : String(error)}`
614
- );
615
- return error ?? ( new Error("connect failed"));
616
- });
617
- const connectError = await connecting;
618
- if (!isCurrentActivation()) {
619
- return false;
620
- }
621
- if (connectError !== undefined) {
622
- return !!env.taskId;
623
- }
624
- if (env.taskId) {
625
- return true;
626
- }
627
- const authority = agentHostAuthority(address);
628
- while (isCurrentActivation()) {
629
- const connection = this._remoteAgentHostService.getConnection(address);
630
- if (!connection) {
631
- return false;
632
- }
633
- const rootState = connection.rootState.value;
634
- if (rootState instanceof Error) {
635
- return false;
636
- }
637
- if (rootState) {
638
- return ( rootState.agents.some(
639
- agent => remoteAgentHostSessionTypeId(authority, agent.provider) === sessionType
640
- ));
641
- }
642
- const changed = Event.toPromise(connection.rootState.onDidChange);
643
- try {
644
- await raceCancellation(changed, token);
645
- } finally {
646
- changed.cancel();
647
- }
648
- }
649
- return false;
650
- }
651
- async _isEnvironmentOnline(env, token) {
652
- try {
653
- const record = await this._apiService.getEnvironment(env.environmentId, token);
654
- return record.status === "online";
655
- } catch (error) {
656
- this._logService.trace(
657
- `${LOG_PREFIX} Could not read the state of ${env.environmentId}; treating it as not online: ${error instanceof Error ? error.message : String(error)}`
658
- );
659
- return false;
660
- }
661
- }
662
- _activateHistory(sessionType, address, env) {
663
- if (( this._historyHandlers.has(sessionType))) {
664
- return true;
665
- }
666
- if (this._chatSessionsService.getContentProviderSchemes().includes(sessionType)) {
667
- this._logService.trace(
668
- `${LOG_PREFIX} ${sessionType} already has a content provider; leaving it to serve the session.`
669
- );
670
- return true;
671
- }
672
- if (!env.taskId) {
673
- this._logService.warn(`${LOG_PREFIX} No task id for ${address}; cannot serve history read-only.`);
674
- return false;
675
- }
676
- const store = ( new DisposableStore());
677
- const handler = store.add(this._instantiationService.createInstance(CloudSandboxSessionHandler, {
678
- taskId: env.taskId,
679
- agentId: sessionType,
680
- connectionAuthority: agentHostAuthority(address),
681
- connectionStatus: this._providerInstances.get(address).connectionStatus
682
- }));
683
- store.add(
684
- this._chatSessionsService.registerChatSessionContentProvider(sessionType, handler)
685
- );
686
- this._historyHandlers.set(sessionType, {
687
- handler,
688
- dispose: () => store.dispose()
689
- });
690
- this._logService.info(`${LOG_PREFIX} Serving ${sessionType} from Mission Control history.`);
691
- return true;
692
- }
693
- _registerLiveSessionProvider(sessionType, provider) {
694
- const entry = this._historyHandlers.get(sessionType);
695
- if (!entry) {
696
- return undefined;
697
- }
698
- entry.handler.setLiveProvider(provider);
699
- return toDisposable(() => {
700
- if (this._historyHandlers.get(sessionType) === entry) {
701
- this._historyHandlers.deleteAndDispose(sessionType);
702
- }
703
- });
704
- }
705
- _clearSessionHandlers(address) {
706
- const authority = agentHostAuthority(address);
707
- for (const sessionType of [...( this._historyHandlers.keys())]) {
708
- if (findRemoteAgentHostSessionTypeAuthority(sessionType, [authority]) === authority) {
709
- this._historyHandlers.deleteAndDispose(sessionType);
710
- }
711
- }
712
- }
713
- async connect(options) {
714
- if (!this._isEnabled()) {
715
- throw ( new Error("Copilot cloud sandbox connections are not enabled."));
716
- }
717
- const address = cloudSandboxAddress(options.environmentId);
718
- this._ensureProvider({
719
- environmentId: options.environmentId,
720
- sessionId: options.sessionId,
721
- name: options.name
722
- });
723
- const pending = this._pendingConnects.get(address);
724
- if (pending) {
725
- return pending.promise;
726
- }
727
- const source = ( new CancellationTokenSource(this._enabledCts.token));
728
- const token = source.token;
729
- const attempt = (async () => {
730
- this._providerInstances.get(address)?.setConnectionStatus(RemoteAgentHostConnectionStatus.connecting);
731
- const result = await raceCancellationError(this._cloudSandboxService.connect(options, token), token);
732
- if (token.isCancellationRequested || !this._isEnabled()) {
733
- throw ( new CancellationError());
734
- }
735
- for (const [sessionType, entry] of this._historyHandlers) {
736
- if (this._findAddressForSessionType(sessionType) === address) {
737
- entry.handler.retryLiveSessions();
738
- }
739
- }
740
- return result;
741
- })();
742
- this._pendingConnects.set(address, {
743
- source,
744
- promise: attempt
745
- });
746
- try {
747
- return await attempt;
748
- } catch (error) {
749
- if (this._pendingConnects.get(address)?.source === source) {
750
- this._settleFailedConnect(address);
751
- }
752
- throw error;
753
- } finally {
754
- if (this._pendingConnects.get(address)?.source === source) {
755
- this._pendingConnects.delete(address);
756
- }
757
- source.dispose();
758
- }
759
- }
760
- _settleFailedConnect(address) {
761
- const provider = this._providerInstances.get(address);
762
- if (!provider) {
763
- return;
764
- }
765
- const connectionInfo = this._remoteAgentHostService.connections.find(c => c.address === address);
766
- if (connectionInfo) {
767
- provider.setConnectionStatus(connectionInfo.status);
768
- } else if (!RemoteAgentHostConnectionStatus.isIncompatible(provider.connectionStatus.get())) {
769
- provider.setConnectionStatus(RemoteAgentHostConnectionStatus.disconnected);
770
- }
771
- }
772
- _isEnabled() {
773
- return !this._store.isDisposed && isCloudSandboxEnabled(this._configurationService) && !this._chatEntitlementService.sentiment.hidden;
774
- }
775
- _updateEnablement() {
776
- this._updateRegistration();
777
- if (!this._isEnabled()) {
778
- this._teardownAll();
779
- }
780
- }
781
- _ensureProvider(env) {
782
- const address = cloudSandboxAddress(env.environmentId);
783
- const known = this._environments.get(address);
784
- this._environments.set(address, {
785
- ...known,
786
- ...env,
787
- taskId: env.taskId ?? known?.taskId,
788
- eventType: env.eventType ?? known?.eventType,
789
- repoName: env.repoName ?? known?.repoName,
790
- hasRepository: env.hasRepository ?? known?.hasRepository,
791
- updatedAt: env.updatedAt ?? known?.updatedAt
792
- });
793
- if (( this._providerStores.has(address))) {
794
- return;
795
- }
796
- const store = ( new DisposableStore());
797
- const token = cancelOnDispose(store);
798
- this._providerStores.set(address, {
799
- token,
800
- dispose: () => store.dispose()
801
- });
802
- store.add(
803
- this._workspaceTrustManagementService.registerTrustedAuthority(AGENT_HOST_SCHEME, agentHostAuthority(address))
804
- );
805
- const provider = this._createProvider(env, store);
806
- this._providerInstances.set(address, provider);
807
- store.add(toDisposable(() => this._providerInstances.delete(address)));
808
- this._logService.info(`${LOG_PREFIX} Registered sessions provider for ${address}`);
809
- }
810
- _wireConnections() {
811
- for (const [address, provider] of this._providerInstances) {
812
- const connectionInfo = this._remoteAgentHostService.connections.find(
813
- c => c.address === address && RemoteAgentHostConnectionStatus.isConnected(c.status)
814
- );
815
- if (connectionInfo) {
816
- const connection = this._remoteAgentHostService.getConnection(address);
817
- if (connection) {
818
- provider.setConnection(connection, connectionInfo.defaultDirectory);
819
- }
820
- }
821
- }
822
- }
823
- _updateConnectionStatuses() {
824
- for (const [address, provider] of this._providerInstances) {
825
- const connectionInfo = this._remoteAgentHostService.connections.find(c => c.address === address);
826
- if (connectionInfo) {
827
- provider.setConnectionStatus(connectionInfo.status);
828
- } else if (( this._pendingConnects.has(address))) {
829
- continue;
830
- } else if (!RemoteAgentHostConnectionStatus.isIncompatible(provider.connectionStatus.get())) {
831
- provider.setConnectionStatus(RemoteAgentHostConnectionStatus.disconnected);
832
- }
833
- }
834
- }
835
- };
836
- CloudSandboxSessionContribution = ( __decorate([( __param(0, ICloudSandboxAgentHostService)), ( __param(1, ICloudSandboxApiService)), ( __param(2, IRemoteAgentHostService)), ( __param(3, IRemoteAgentHostConnectionCustomizationService)), ( __param(4, IConfigurationService)), ( __param(5, IInstantiationService)), ( __param(6, IChatSessionsService)), ( __param(7, ILogService)), ( __param(8, IChatEntitlementService)), ( __param(9, IHostService)), ( __param(10, IStorageService)), ( __param(11, IWorkspaceTrustManagementService)), ( __param(12, IAgentHostService))], CloudSandboxSessionContribution));
837
-
838
- export { CloudSandboxSessionContribution, discoveredSessionProject };