@codingame/monaco-vscode-chat-service-override 38.0.7 → 38.1.1

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,361 +0,0 @@
1
-
2
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { DeferredPromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
4
- import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
5
- import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
6
- import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
7
- import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
8
- import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
9
- import { getTranscriptionWebSocketUrl, addWebSocketAuthToken } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/voiceClient/voiceEndpoint';
10
-
11
- const PING_INTERVAL_MS = 25000;
12
- const PONG_TIMEOUT_MS = 10000;
13
- const CONNECT_TIMEOUT_MS = 8000;
14
- const SESSION_INIT_TIMEOUT_MS = 4000;
15
- let VoiceCodeTranscriptionClient = class VoiceCodeTranscriptionClient extends Disposable {
16
- get isConnected() {
17
- return this._socket?.readyState === WebSocket.OPEN;
18
- }
19
- constructor(_configurationService, _productService, _logService) {
20
- super();
21
- this._configurationService = _configurationService;
22
- this._productService = _productService;
23
- this._logService = _logService;
24
- this._onTranscription = this._register(( new Emitter()));
25
- this.onTranscription = this._onTranscription.event;
26
- this._onError = this._register(( new Emitter()));
27
- this.onError = this._onError.event;
28
- this._onDidClose = this._register(( new Emitter()));
29
- this.onDidClose = this._onDidClose.event;
30
- this._intentionalClose = false;
31
- this._activeTurns = ( new Set());
32
- this._lastRevisionByTurn = ( new Map());
33
- }
34
- async connect(window, authToken) {
35
- this.disconnect();
36
- const baseUrl = getTranscriptionWebSocketUrl(this._configurationService, this._productService);
37
- if (!baseUrl) {
38
- throw ( new Error("No transcription WebSocket URL is configured"));
39
- }
40
- this._intentionalClose = false;
41
- this._window = window;
42
- const socket = new window.WebSocket(addWebSocketAuthToken(baseUrl, authToken));
43
- this._socket = socket;
44
- const opened = this._connectDeferred = ( new DeferredPromise());
45
- this._connectTimeout = setTimeout(() => {
46
- if (this._socket === socket && !opened.isSettled) {
47
- opened.error(( new Error("Timed out connecting to the transcription service")));
48
- socket.close(4000, "connect timeout");
49
- }
50
- }, CONNECT_TIMEOUT_MS);
51
- socket.onopen = () => {
52
- if (this._socket === socket) {
53
- this._clearConnectTimeout();
54
- this._startPing();
55
- opened.complete();
56
- }
57
- };
58
- socket.onmessage = event => {
59
- if (this._socket === socket) {
60
- this._handleMessage(event);
61
- }
62
- };
63
- socket.onerror = () => {
64
- if (this._socket !== socket) {
65
- return;
66
- }
67
- this._clearConnectTimeout();
68
- if (!opened.isSettled) {
69
- opened.error(( new Error("Transcription WebSocket connection failed")));
70
- return;
71
- }
72
- this._reportError("Transcription WebSocket error", undefined, undefined, true);
73
- };
74
- socket.onclose = event => {
75
- if (this._socket !== socket) {
76
- return;
77
- }
78
- this._socket = undefined;
79
- this._clearConnectTimeout();
80
- this._clearSessionInitTimeout();
81
- this._stopPing();
82
- const detail = `Transcription connection closed (${event.code})${event.reason ? `: ${event.reason}` : ""}`;
83
- this._sessionInit?.error(( new Error(detail)));
84
- this._sessionInit = undefined;
85
- if (!opened.isSettled) {
86
- opened.error(( new Error(detail)));
87
- }
88
- if (!this._intentionalClose) {
89
- this._onDidClose.fire(event.code);
90
- this._reportError(detail, undefined, undefined, true);
91
- }
92
- };
93
- try {
94
- await opened.p;
95
- } finally {
96
- if (this._connectDeferred === opened) {
97
- this._connectDeferred = undefined;
98
- }
99
- }
100
- }
101
- async startSession() {
102
- this._assertConnected();
103
- if (this._sessionInit) {
104
- throw ( new Error("Transcription session initialization is already in progress"));
105
- }
106
- this._sessionInit = ( new DeferredPromise());
107
- this._sessionInitTimeout = setTimeout(() => {
108
- if (this._sessionInit) {
109
- this._sessionInit.error(( new Error("Timed out initializing the transcription session")));
110
- this._sessionInit = undefined;
111
- this._socket?.close(4000, "session initialization timeout");
112
- }
113
- }, SESSION_INIT_TIMEOUT_MS);
114
- this._send({
115
- type: "start_session"
116
- });
117
- try {
118
- await this._sessionInit.p;
119
- } finally {
120
- this._clearSessionInitTimeout();
121
- }
122
- }
123
- sendPttStart(turnId) {
124
- this._assertTurnId(turnId);
125
- if (( this._activeTurns.has(turnId))) {
126
- throw ( new Error("Transcription turn is already active"));
127
- }
128
- this._activeTurns.add(turnId);
129
- this._lastRevisionByTurn.set(turnId, 0);
130
- this._send({
131
- type: "ptt_start",
132
- turn_id: turnId
133
- });
134
- }
135
- sendPttAudioChunk(turnId, audio) {
136
- this._assertTurnId(turnId);
137
- this._assertActiveTurn(turnId);
138
- if (!audio) {
139
- throw ( new Error("Transcription audio must be non-empty"));
140
- }
141
- this._send({
142
- type: "ptt_audio_chunk",
143
- turn_id: turnId,
144
- audio
145
- });
146
- }
147
- sendPttEnd(turnId) {
148
- this._assertTurnId(turnId);
149
- this._assertActiveTurn(turnId);
150
- this._send({
151
- type: "ptt_end",
152
- turn_id: turnId
153
- });
154
- this._activeTurns.delete(turnId);
155
- }
156
- disconnect() {
157
- this._intentionalClose = true;
158
- this._stopPing();
159
- this._clearConnectTimeout();
160
- this._clearSessionInitTimeout();
161
- this._connectDeferred?.cancel();
162
- this._connectDeferred = undefined;
163
- this._sessionInit?.cancel();
164
- this._sessionInit = undefined;
165
- const socket = this._socket;
166
- this._socket = undefined;
167
- this._window = undefined;
168
- this._activeTurns.clear();
169
- this._lastRevisionByTurn.clear();
170
- if (socket && socket.readyState < WebSocket.CLOSING) {
171
- socket.close();
172
- }
173
- }
174
- dispose() {
175
- this.disconnect();
176
- super.dispose();
177
- }
178
- _handleMessage(event) {
179
- const message = parseMessage(event.data);
180
- if (!message) {
181
- this._logService.warn("[chat-stt] ignored malformed transcription frame");
182
- return;
183
- }
184
- switch (message.type) {
185
- case "pong":
186
- this._clearPongTimeout();
187
- return;
188
- case "session_init":
189
- if (typeof message.session_id !== "string" || !message.session_id) {
190
- this._logService.warn("[chat-stt] ignored malformed session_init frame");
191
- return;
192
- }
193
- this._sessionInit?.complete();
194
- this._sessionInit = undefined;
195
- this._clearSessionInitTimeout();
196
- return;
197
- case "transcription":
198
- this._handleTranscription(message);
199
- return;
200
- case "error":
201
- this._handleError(message);
202
- return;
203
- default:
204
- this._logService.warn(`[chat-stt] ignored unsupported transcription frame type ${message.type}`);
205
- }
206
- }
207
- _handleTranscription(message) {
208
- const transcription = parseTranscription(message);
209
- if (!transcription) {
210
- this._logService.warn("[chat-stt] ignored malformed transcription metadata");
211
- return;
212
- }
213
- const {
214
- turnId,
215
- revision
216
- } = transcription;
217
- const lastRevision = this._lastRevisionByTurn.get(turnId);
218
- if (lastRevision === undefined || revision <= lastRevision) {
219
- return;
220
- }
221
- this._lastRevisionByTurn.set(turnId, revision);
222
- this._onTranscription.fire(transcription);
223
- }
224
- _handleError(message) {
225
- if (typeof message.detail !== "string" || !message.detail) {
226
- this._logService.warn("[chat-stt] ignored malformed transcription error frame");
227
- return;
228
- }
229
- this._reportError(
230
- message.detail,
231
- optionalNonEmptyString(message.code),
232
- optionalNonEmptyString(message.turn_id),
233
- optionalBoolean(message.terminal)
234
- );
235
- }
236
- _reportError(detail, code, turnId, terminal) {
237
- this._onError.fire({
238
- detail,
239
- ...(code !== undefined ? {
240
- code
241
- } : {}),
242
- ...(turnId !== undefined ? {
243
- turnId
244
- } : {}),
245
- ...(terminal !== undefined ? {
246
- terminal
247
- } : {})
248
- });
249
- }
250
- _send(message) {
251
- this._assertConnected();
252
- this._socket.send(JSON.stringify(message));
253
- }
254
- _assertConnected() {
255
- if (!this.isConnected) {
256
- throw ( new Error("Transcription WebSocket is not connected"));
257
- }
258
- }
259
- _assertTurnId(turnId) {
260
- if (!turnId) {
261
- throw ( new Error("Transcription turn ID must be non-empty"));
262
- }
263
- }
264
- _assertActiveTurn(turnId) {
265
- if (!( this._activeTurns.has(turnId))) {
266
- throw ( new Error("Transcription turn is not active"));
267
- }
268
- }
269
- _startPing() {
270
- this._stopPing();
271
- if (!this._window) {
272
- return;
273
- }
274
- this._pingTimer = this._window.setInterval(() => {
275
- if (!this.isConnected) {
276
- return;
277
- }
278
- this._send({
279
- type: "ping"
280
- });
281
- this._clearPongTimeout();
282
- this._pongTimer = setTimeout(() => this._socket?.close(4000, "pong timeout"), PONG_TIMEOUT_MS);
283
- }, PING_INTERVAL_MS);
284
- }
285
- _stopPing() {
286
- if (this._pingTimer !== undefined) {
287
- this._window?.clearInterval(this._pingTimer);
288
- this._pingTimer = undefined;
289
- }
290
- this._clearPongTimeout();
291
- }
292
- _clearPongTimeout() {
293
- if (this._pongTimer !== undefined) {
294
- clearTimeout(this._pongTimer);
295
- this._pongTimer = undefined;
296
- }
297
- }
298
- _clearConnectTimeout() {
299
- if (this._connectTimeout !== undefined) {
300
- clearTimeout(this._connectTimeout);
301
- this._connectTimeout = undefined;
302
- }
303
- }
304
- _clearSessionInitTimeout() {
305
- if (this._sessionInitTimeout !== undefined) {
306
- clearTimeout(this._sessionInitTimeout);
307
- this._sessionInitTimeout = undefined;
308
- }
309
- }
310
- };
311
- VoiceCodeTranscriptionClient = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IProductService)), ( __param(2, ILogService))], VoiceCodeTranscriptionClient));
312
- function parseMessage(data) {
313
- if (typeof data !== "string") {
314
- return undefined;
315
- }
316
- try {
317
- const value = JSON.parse(data);
318
- if (!value || typeof value !== "object" || Array.isArray(value)) {
319
- return undefined;
320
- }
321
- const message = value;
322
- return typeof message.type === "string" && message.type ? message : undefined;
323
- } catch {
324
- return undefined;
325
- }
326
- }
327
- function parseTranscription(message) {
328
- const turnId = optionalNonEmptyString(message.turn_id);
329
- if (turnId === undefined || typeof message.text !== "string") {
330
- return undefined;
331
- }
332
- const status = transcriptionStatus(message.status);
333
- const revision = positiveSafeInteger(message.revision);
334
- if (status === undefined || revision === undefined || !isOptionalString(message.committed)) {
335
- return undefined;
336
- }
337
- return {
338
- turnId,
339
- text: message.text,
340
- status,
341
- revision,
342
- committed: message.committed ?? ""
343
- };
344
- }
345
- function transcriptionStatus(value) {
346
- return value === "partial" || value === "final" ? value : undefined;
347
- }
348
- function positiveSafeInteger(value) {
349
- return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : undefined;
350
- }
351
- function isOptionalString(value) {
352
- return value === undefined || typeof value === "string";
353
- }
354
- function optionalNonEmptyString(value) {
355
- return typeof value === "string" && value ? value : undefined;
356
- }
357
- function optionalBoolean(value) {
358
- return typeof value === "boolean" ? value : undefined;
359
- }
360
-
361
- export { VoiceCodeTranscriptionClient };
@@ -1,34 +0,0 @@
1
- import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
- import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
3
- import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
4
- import { ITtsPlaybackService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/voiceClient/ttsPlaybackService.service";
5
- export declare class TtsPlaybackService extends Disposable implements ITtsPlaybackService {
6
- private readonly logService;
7
- readonly _serviceBrand: undefined;
8
- constructor(logService: ILogService);
9
- private _window;
10
- private _playbackCtx;
11
- private _playbackTurn;
12
- private _playbackGen;
13
- private _analyserNode;
14
- private _isPlaying;
15
- private _lastPlayedSamples;
16
- private readonly _onPlaybackStarted;
17
- readonly onPlaybackStarted: Event<void>;
18
- private readonly _onPlaybackStopped;
19
- readonly onPlaybackStopped: Event<void>;
20
- get isPlaying(): boolean;
21
- get analyserNode(): AnalyserNode | undefined;
22
- getLastPlayedSamples(): Float32Array | null;
23
- ensureContext(window: Window & typeof globalThis): AudioContext;
24
- playAudioChunk(audio: string, isFinal: boolean, window: Window & typeof globalThis): void;
25
- stopPlayback(): void;
26
- /** Close the AudioContext entirely (for full teardown). */
27
- closeContext(): void;
28
- private _ensurePlayTurn;
29
- private _writeToPlayBuffer;
30
- private _startPlayback;
31
- private _schedulePlayStop;
32
- private _captureSamples;
33
- dispose(): void;
34
- }
@@ -1,198 +0,0 @@
1
-
2
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
- import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
5
- import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
6
- import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
7
- import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
8
-
9
- const PLAYBACK_SAMPLE_RATE = 24000;
10
- const MAX_PLAYBACK_SAMPLES = PLAYBACK_SAMPLE_RATE * 180;
11
- let TtsPlaybackService = class TtsPlaybackService extends Disposable {
12
- constructor(logService) {
13
- super();
14
- this.logService = logService;
15
- this._playbackTurn = null;
16
- this._playbackGen = 0;
17
- this._isPlaying = false;
18
- this._lastPlayedSamples = null;
19
- this._onPlaybackStarted = this._register(( new Emitter()));
20
- this.onPlaybackStarted = this._onPlaybackStarted.event;
21
- this._onPlaybackStopped = this._register(( new Emitter()));
22
- this.onPlaybackStopped = this._onPlaybackStopped.event;
23
- }
24
- get isPlaying() {
25
- return this._isPlaying;
26
- }
27
- get analyserNode() {
28
- return this._analyserNode;
29
- }
30
- getLastPlayedSamples() {
31
- return this._lastPlayedSamples;
32
- }
33
- ensureContext(window) {
34
- this._window = window;
35
- if (!this._playbackCtx) {
36
- this._playbackCtx = new window.AudioContext({
37
- sampleRate: PLAYBACK_SAMPLE_RATE
38
- });
39
- }
40
- if (this._playbackCtx.state === "suspended") {
41
- this._playbackCtx.resume().catch(() => {});
42
- }
43
- return this._playbackCtx;
44
- }
45
- playAudioChunk(audio, isFinal, window) {
46
- this._window = window;
47
- if (!audio && isFinal) {
48
- const turn = this._ensurePlayTurn(window);
49
- turn.writeChain = turn.writeChain.then(() => this._schedulePlayStop());
50
- return;
51
- }
52
- if (!audio) {
53
- return;
54
- }
55
- const turn = this._ensurePlayTurn(window);
56
- const gen = this._playbackGen;
57
- const binary = window.atob(audio);
58
- const bytes = ( new Uint8Array(binary.length));
59
- for (let i = 0; i < binary.length; i++) {
60
- bytes[i] = binary.charCodeAt(i);
61
- }
62
- const arrayBuf = bytes.buffer;
63
- turn.writeChain = turn.writeChain.then(async () => {
64
- if (gen !== this._playbackGen) {
65
- return;
66
- }
67
- try {
68
- const ctx = this.ensureContext(this._window);
69
- const decoded = await ctx.decodeAudioData(arrayBuf);
70
- if (gen !== this._playbackGen) {
71
- return;
72
- }
73
- this._writeToPlayBuffer(decoded);
74
- if (!this._playbackTurn?.started) {
75
- this._startPlayback();
76
- }
77
- } catch (err) {
78
- this.logService.error("[voice] TTS decode error", err);
79
- }
80
- });
81
- if (isFinal) {
82
- turn.writeChain = turn.writeChain.then(() => this._schedulePlayStop());
83
- }
84
- }
85
- stopPlayback() {
86
- this._playbackGen++;
87
- if (this._playbackTurn) {
88
- this._captureSamples(this._playbackTurn);
89
- }
90
- try {
91
- this._playbackTurn?.sourceNode?.stop();
92
- } catch {}
93
- this._playbackTurn = null;
94
- this._analyserNode = undefined;
95
- if (this._isPlaying) {
96
- this._isPlaying = false;
97
- this._onPlaybackStopped.fire();
98
- }
99
- }
100
- closeContext() {
101
- this.stopPlayback();
102
- if (this._playbackCtx) {
103
- this._playbackCtx.close();
104
- this._playbackCtx = undefined;
105
- }
106
- }
107
- _ensurePlayTurn(window) {
108
- const ctx = this.ensureContext(window);
109
- if (this._playbackTurn) {
110
- return this._playbackTurn;
111
- }
112
- const turn = {
113
- buffer: ctx.createBuffer(1, MAX_PLAYBACK_SAMPLES, PLAYBACK_SAMPLE_RATE),
114
- sourceNode: null,
115
- writeOffset: 0,
116
- startCtxTime: 0,
117
- started: false,
118
- writeChain: Promise.resolve()
119
- };
120
- this._playbackTurn = turn;
121
- return turn;
122
- }
123
- _writeToPlayBuffer(decoded) {
124
- if (!this._playbackTurn) {
125
- return;
126
- }
127
- const src = decoded.getChannelData(0);
128
- const dst = this._playbackTurn.buffer.getChannelData(0);
129
- const toWrite = Math.min(src.length, MAX_PLAYBACK_SAMPLES - this._playbackTurn.writeOffset);
130
- for (let i = 0; i < toWrite; i++) {
131
- dst[this._playbackTurn.writeOffset + i] = src[i];
132
- }
133
- this._playbackTurn.writeOffset += toWrite;
134
- }
135
- _startPlayback() {
136
- const ctx = this._playbackCtx;
137
- const turn = this._playbackTurn;
138
- if (!ctx || !turn || turn.started) {
139
- return;
140
- }
141
- turn.started = true;
142
- const node = ctx.createBufferSource();
143
- node.buffer = turn.buffer;
144
- turn.sourceNode = node;
145
- const analyser = ctx.createAnalyser();
146
- analyser.fftSize = 256;
147
- node.connect(analyser);
148
- analyser.connect(ctx.destination);
149
- this._analyserNode = analyser;
150
- turn.startCtxTime = ctx.currentTime;
151
- node.start(0);
152
- if (!this._isPlaying) {
153
- this._isPlaying = true;
154
- this._onPlaybackStarted.fire();
155
- }
156
- }
157
- _schedulePlayStop() {
158
- const ctx = this._playbackCtx;
159
- const turn = this._playbackTurn;
160
- if (!ctx || !turn) {
161
- return;
162
- }
163
- if (!turn.started) {
164
- this._startPlayback();
165
- }
166
- const node = turn.sourceNode;
167
- if (!node) {
168
- return;
169
- }
170
- const stopAt = turn.startCtxTime + turn.writeOffset / PLAYBACK_SAMPLE_RATE;
171
- const endedTurn = turn;
172
- node.stop(Math.max(stopAt, ctx.currentTime));
173
- node.onended = () => {
174
- if (this._playbackTurn !== endedTurn) {
175
- return;
176
- }
177
- this._captureSamples(endedTurn);
178
- this._playbackTurn = null;
179
- this._analyserNode = undefined;
180
- if (this._isPlaying) {
181
- this._isPlaying = false;
182
- this._onPlaybackStopped.fire();
183
- }
184
- };
185
- }
186
- _captureSamples(turn) {
187
- if (turn.writeOffset > 0) {
188
- this._lastPlayedSamples = turn.buffer.getChannelData(0).slice(0, turn.writeOffset);
189
- }
190
- }
191
- dispose() {
192
- this.closeContext();
193
- super.dispose();
194
- }
195
- };
196
- TtsPlaybackService = ( __decorate([( __param(0, ILogService))], TtsPlaybackService));
197
-
198
- export { TtsPlaybackService };