@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.
- 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
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { encodeBase64, VSBuffer, decodeBase64 } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
3
|
-
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
4
|
-
|
|
5
|
-
const DEFAULT_MAX_CHUNK_BYTES = 900 * 1024;
|
|
6
|
-
const DEFAULT_REASSEMBLY_TIMEOUT_MS = 30_000;
|
|
7
|
-
const DEFAULT_MAX_REASSEMBLY_BYTES = 32 * 1024 * 1024;
|
|
8
|
-
const DEFAULT_MAX_REASSEMBLY_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
9
|
-
const DEFAULT_MAX_CONCURRENT_GROUPS = 64;
|
|
10
|
-
const DEFAULT_MAX_SEGMENTS_PER_GROUP = 4096;
|
|
11
|
-
class ChunkingError extends Error {
|
|
12
|
-
constructor(message) {
|
|
13
|
-
super(message);
|
|
14
|
-
this.name = "ChunkingError";
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const textEncoder = ( new TextEncoder());
|
|
18
|
-
const textDecoder = ( new TextDecoder("utf-8", {
|
|
19
|
-
fatal: true
|
|
20
|
-
}));
|
|
21
|
-
const CANONICAL_BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
22
|
-
function bytesToBase64(bytes) {
|
|
23
|
-
return encodeBase64(VSBuffer.wrap(bytes), true, false );
|
|
24
|
-
}
|
|
25
|
-
function base64ToBytes(b64) {
|
|
26
|
-
return decodeBase64(b64).buffer;
|
|
27
|
-
}
|
|
28
|
-
function chunk(payload, options = {}) {
|
|
29
|
-
const maxChunkBytes = options.maxChunkBytes ?? DEFAULT_MAX_CHUNK_BYTES;
|
|
30
|
-
if (maxChunkBytes <= 0 || !Number.isFinite(maxChunkBytes)) {
|
|
31
|
-
throw ( new ChunkingError(`maxChunkBytes must be a positive finite number, got ${maxChunkBytes}`));
|
|
32
|
-
}
|
|
33
|
-
let payloadSerialised;
|
|
34
|
-
try {
|
|
35
|
-
payloadSerialised = JSON.stringify(payload);
|
|
36
|
-
} catch (cause) {
|
|
37
|
-
throw ( new ChunkingError(`payload is not JSON-serialisable: ${cause.message}`));
|
|
38
|
-
}
|
|
39
|
-
if (payloadSerialised === undefined) {
|
|
40
|
-
throw ( new ChunkingError("payload is not JSON-serialisable"));
|
|
41
|
-
}
|
|
42
|
-
const rawBytes = textEncoder.encode(payloadSerialised);
|
|
43
|
-
if (rawBytes.byteLength > DEFAULT_MAX_REASSEMBLY_BYTES) {
|
|
44
|
-
throw ( new ChunkingError(
|
|
45
|
-
`serialized payload is ${rawBytes.byteLength} bytes, exceeds ${DEFAULT_MAX_REASSEMBLY_BYTES}-byte ceiling`
|
|
46
|
-
));
|
|
47
|
-
}
|
|
48
|
-
const singleSerialised = JSON.stringify({
|
|
49
|
-
kind: "message",
|
|
50
|
-
data: payload
|
|
51
|
-
});
|
|
52
|
-
if (textEncoder.encode(singleSerialised).byteLength <= maxChunkBytes) {
|
|
53
|
-
return [{
|
|
54
|
-
kind: "message",
|
|
55
|
-
data: payload
|
|
56
|
-
}];
|
|
57
|
-
}
|
|
58
|
-
const newGroupId = options.newGroupId ?? generateUuid;
|
|
59
|
-
const groupId = newGroupId();
|
|
60
|
-
if (typeof groupId !== "string" || groupId.length === 0) {
|
|
61
|
-
throw ( new ChunkingError("newGroupId() must return a non-empty string"));
|
|
62
|
-
}
|
|
63
|
-
const emptyEnvelope = {
|
|
64
|
-
kind: "chunk",
|
|
65
|
-
group_id: groupId,
|
|
66
|
-
seq: DEFAULT_MAX_SEGMENTS_PER_GROUP - 1,
|
|
67
|
-
total: DEFAULT_MAX_SEGMENTS_PER_GROUP,
|
|
68
|
-
bytes: ""
|
|
69
|
-
};
|
|
70
|
-
const overhead = textEncoder.encode(JSON.stringify(emptyEnvelope)).byteLength;
|
|
71
|
-
const encodedBudget = Math.floor((maxChunkBytes - overhead) / 4) * 4;
|
|
72
|
-
if (encodedBudget < 4) {
|
|
73
|
-
throw ( new ChunkingError(
|
|
74
|
-
`maxChunkBytes (${maxChunkBytes}) leaves no complete base64 quantum after ${overhead} bytes of envelope overhead`
|
|
75
|
-
));
|
|
76
|
-
}
|
|
77
|
-
const rawBudget = (encodedBudget / 4) * 3;
|
|
78
|
-
const total = Math.ceil(rawBytes.byteLength / rawBudget);
|
|
79
|
-
if (total > DEFAULT_MAX_SEGMENTS_PER_GROUP) {
|
|
80
|
-
throw ( new ChunkingError(
|
|
81
|
-
`payload requires ${total} chunks, exceeds ${DEFAULT_MAX_SEGMENTS_PER_GROUP}-chunk ceiling`
|
|
82
|
-
));
|
|
83
|
-
}
|
|
84
|
-
const out = ( new Array(total));
|
|
85
|
-
for (let i = 0; i < total; i++) {
|
|
86
|
-
const start = i * rawBudget;
|
|
87
|
-
const end = Math.min(start + rawBudget, rawBytes.byteLength);
|
|
88
|
-
const slice = rawBytes.subarray(start, end);
|
|
89
|
-
out[i] = {
|
|
90
|
-
kind: "chunk",
|
|
91
|
-
group_id: groupId,
|
|
92
|
-
seq: i,
|
|
93
|
-
total,
|
|
94
|
-
bytes: bytesToBase64(slice)
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return out;
|
|
98
|
-
}
|
|
99
|
-
class Reassembler {
|
|
100
|
-
constructor(options = {}) {
|
|
101
|
-
this.buffers = ( new Map());
|
|
102
|
-
this.accumulatedBytes = 0;
|
|
103
|
-
this.timeoutMs = options.timeoutMs ?? DEFAULT_REASSEMBLY_TIMEOUT_MS;
|
|
104
|
-
this.maxBufferBytes = options.maxBufferBytes ?? DEFAULT_MAX_REASSEMBLY_BYTES;
|
|
105
|
-
this.maxTotalBufferBytes = options.maxTotalBufferBytes ?? DEFAULT_MAX_REASSEMBLY_TOTAL_BYTES;
|
|
106
|
-
this.maxConcurrentGroups = options.maxConcurrentGroups ?? DEFAULT_MAX_CONCURRENT_GROUPS;
|
|
107
|
-
this.maxSegmentsPerGroup = options.maxSegmentsPerGroup ?? DEFAULT_MAX_SEGMENTS_PER_GROUP;
|
|
108
|
-
this.now = options.now ?? Date.now;
|
|
109
|
-
}
|
|
110
|
-
ingest(envelope) {
|
|
111
|
-
if (envelope === null || typeof envelope !== "object") {
|
|
112
|
-
throw ( new ChunkingError(`ChunkEnvelope must be an object, got ${typeof envelope}`));
|
|
113
|
-
}
|
|
114
|
-
if (envelope.kind === "message") {
|
|
115
|
-
if (envelope.data === undefined) {
|
|
116
|
-
throw ( new ChunkingError(`ChunkEnvelope kind:'message' is missing the required 'data' field`));
|
|
117
|
-
}
|
|
118
|
-
return envelope.data;
|
|
119
|
-
}
|
|
120
|
-
if (envelope.kind !== "chunk") {
|
|
121
|
-
throw ( new ChunkingError(`unknown ChunkEnvelope kind: ${String(envelope.kind)}`));
|
|
122
|
-
}
|
|
123
|
-
const {
|
|
124
|
-
group_id: groupId,
|
|
125
|
-
seq,
|
|
126
|
-
total,
|
|
127
|
-
bytes
|
|
128
|
-
} = envelope;
|
|
129
|
-
if (!Number.isInteger(total) || total < 1) {
|
|
130
|
-
throw ( new ChunkingError(`total must be a positive integer, got ${total}`));
|
|
131
|
-
}
|
|
132
|
-
if (total > this.maxSegmentsPerGroup) {
|
|
133
|
-
throw ( new ChunkingError(`total ${total} exceeds maxSegmentsPerGroup ${this.maxSegmentsPerGroup}`));
|
|
134
|
-
}
|
|
135
|
-
if (typeof groupId !== "string" || groupId.length === 0) {
|
|
136
|
-
throw ( new ChunkingError("group_id must be a non-empty string"));
|
|
137
|
-
}
|
|
138
|
-
if (typeof bytes !== "string") {
|
|
139
|
-
throw ( new ChunkingError("bytes must be a base64 string"));
|
|
140
|
-
}
|
|
141
|
-
let buffer = this.buffers.get(groupId);
|
|
142
|
-
if (buffer === undefined) {
|
|
143
|
-
if (this.buffers.size >= this.maxConcurrentGroups) {
|
|
144
|
-
throw ( new ChunkingError(
|
|
145
|
-
`refusing new group_id '${groupId}': ${this.buffers.size} concurrent groups already in flight`
|
|
146
|
-
));
|
|
147
|
-
}
|
|
148
|
-
buffer = {
|
|
149
|
-
generation: envelope.generation,
|
|
150
|
-
total,
|
|
151
|
-
received: 0,
|
|
152
|
-
segments: ( new Map()),
|
|
153
|
-
accumulatedBytes: 0,
|
|
154
|
-
startedAt: this.now()
|
|
155
|
-
};
|
|
156
|
-
this.buffers.set(groupId, buffer);
|
|
157
|
-
} else if (buffer.total !== total) {
|
|
158
|
-
this.dropBuffer(groupId);
|
|
159
|
-
throw ( new ChunkingError(
|
|
160
|
-
`total mismatch for group_id '${groupId}': existing ${buffer.total}, incoming ${total}`
|
|
161
|
-
));
|
|
162
|
-
} else if (buffer.generation !== envelope.generation) {
|
|
163
|
-
this.dropBuffer(groupId);
|
|
164
|
-
throw ( new ChunkingError(`generation mismatch for group_id '${groupId}'`));
|
|
165
|
-
}
|
|
166
|
-
if (!Number.isInteger(seq) || seq < 0 || seq >= total) {
|
|
167
|
-
this.dropBuffer(groupId);
|
|
168
|
-
throw ( new ChunkingError(`seq ${seq} out of range [0, ${total})`));
|
|
169
|
-
}
|
|
170
|
-
if (( buffer.segments.has(seq))) {
|
|
171
|
-
this.dropBuffer(groupId);
|
|
172
|
-
throw ( new ChunkingError(`duplicate seq ${seq} for group_id '${groupId}'`));
|
|
173
|
-
}
|
|
174
|
-
if (!CANONICAL_BASE64.test(bytes)) {
|
|
175
|
-
this.dropBuffer(groupId);
|
|
176
|
-
throw ( new ChunkingError(`base64 segment for group_id '${groupId}' is not canonical`));
|
|
177
|
-
}
|
|
178
|
-
let decoded;
|
|
179
|
-
try {
|
|
180
|
-
decoded = base64ToBytes(bytes);
|
|
181
|
-
} catch (cause) {
|
|
182
|
-
this.dropBuffer(groupId);
|
|
183
|
-
throw ( new ChunkingError(`base64 decode failed for group_id '${groupId}': ${cause.message}`));
|
|
184
|
-
}
|
|
185
|
-
if (buffer.accumulatedBytes + decoded.byteLength > this.maxBufferBytes) {
|
|
186
|
-
this.dropBuffer(groupId);
|
|
187
|
-
throw ( new ChunkingError(
|
|
188
|
-
`group_id '${groupId}' exceeded ${this.maxBufferBytes}-byte reassembly ceiling`
|
|
189
|
-
));
|
|
190
|
-
}
|
|
191
|
-
if (this.accumulatedBytes + decoded.byteLength > this.maxTotalBufferBytes) {
|
|
192
|
-
this.dropBuffer(groupId);
|
|
193
|
-
throw ( new ChunkingError(
|
|
194
|
-
`aggregate reassembly bytes would exceed ${this.maxTotalBufferBytes}-byte ceiling`
|
|
195
|
-
));
|
|
196
|
-
}
|
|
197
|
-
buffer.segments.set(seq, decoded);
|
|
198
|
-
buffer.received += 1;
|
|
199
|
-
buffer.accumulatedBytes += decoded.byteLength;
|
|
200
|
-
this.accumulatedBytes += decoded.byteLength;
|
|
201
|
-
if (buffer.received < buffer.total) {
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
const totalBytes = buffer.accumulatedBytes;
|
|
205
|
-
const merged = ( new Uint8Array(totalBytes));
|
|
206
|
-
let offset = 0;
|
|
207
|
-
for (let i = 0; i < buffer.total; i++) {
|
|
208
|
-
const slice = buffer.segments.get(i);
|
|
209
|
-
if (slice === undefined) {
|
|
210
|
-
this.dropBuffer(groupId);
|
|
211
|
-
throw ( new ChunkingError(`internal: segment ${i} missing despite received==total`));
|
|
212
|
-
}
|
|
213
|
-
merged.set(slice, offset);
|
|
214
|
-
offset += slice.byteLength;
|
|
215
|
-
}
|
|
216
|
-
this.dropBuffer(groupId);
|
|
217
|
-
let text;
|
|
218
|
-
try {
|
|
219
|
-
text = textDecoder.decode(merged);
|
|
220
|
-
} catch (cause) {
|
|
221
|
-
throw ( new ChunkingError(
|
|
222
|
-
`reassembled payload for group_id '${groupId}' is not valid UTF-8: ${cause.message}`
|
|
223
|
-
));
|
|
224
|
-
}
|
|
225
|
-
try {
|
|
226
|
-
return JSON.parse(text);
|
|
227
|
-
} catch (cause) {
|
|
228
|
-
throw ( new ChunkingError(
|
|
229
|
-
`reassembled payload for group_id '${groupId}' is not valid JSON: ${cause.message}`
|
|
230
|
-
));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
sweepExpired() {
|
|
234
|
-
const dropped = [];
|
|
235
|
-
const cutoff = this.now() - this.timeoutMs;
|
|
236
|
-
for (const [groupId, buffer] of this.buffers) {
|
|
237
|
-
if (buffer.startedAt <= cutoff) {
|
|
238
|
-
this.dropBuffer(groupId);
|
|
239
|
-
dropped.push(groupId);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return dropped;
|
|
243
|
-
}
|
|
244
|
-
get inFlightGroupCount() {
|
|
245
|
-
return this.buffers.size;
|
|
246
|
-
}
|
|
247
|
-
get inFlightBytes() {
|
|
248
|
-
return this.accumulatedBytes;
|
|
249
|
-
}
|
|
250
|
-
dropBuffer(groupId) {
|
|
251
|
-
const buffer = this.buffers.get(groupId);
|
|
252
|
-
if (buffer === undefined) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
this.accumulatedBytes -= buffer.accumulatedBytes;
|
|
256
|
-
this.buffers.delete(groupId);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export { ChunkingError, DEFAULT_MAX_CHUNK_BYTES, DEFAULT_MAX_CONCURRENT_GROUPS, DEFAULT_MAX_REASSEMBLY_BYTES, DEFAULT_MAX_REASSEMBLY_TOTAL_BYTES, DEFAULT_MAX_SEGMENTS_PER_GROUP, DEFAULT_REASSEMBLY_TIMEOUT_MS, Reassembler, chunk };
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { type ChunkEnvelope, type ChunkOptions, Reassembler } from "./chunking.js";
|
|
2
|
-
import { type ParseGroupNameOptions, type ParsedGroup } from "./groups.js";
|
|
3
|
-
/**
|
|
4
|
-
* The Web PubSub subprotocol used by every consumer of this transport. All
|
|
5
|
-
* framing is text-frame JSON.
|
|
6
|
-
*/
|
|
7
|
-
export declare const RELIABLE_JSON_SUBPROTOCOL = "json.reliable.webpubsub.azure.v1";
|
|
8
|
-
/**
|
|
9
|
-
* Web PubSub `sendToGroup` command on the outbound wire. `ackId` is a monotonic
|
|
10
|
-
* per-publisher counter scoped to the connection.
|
|
11
|
-
*/
|
|
12
|
-
export interface SendToGroupCommand {
|
|
13
|
-
readonly type: "sendToGroup";
|
|
14
|
-
readonly group: string;
|
|
15
|
-
readonly ackId: number;
|
|
16
|
-
readonly dataType: "json";
|
|
17
|
-
readonly noEcho: true;
|
|
18
|
-
readonly data: ChunkEnvelope;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Web PubSub group-message envelope on the inbound wire. The `from: 'group'`
|
|
22
|
-
* discriminant distinguishes group-fanout messages from service-level events.
|
|
23
|
-
*/
|
|
24
|
-
export interface GroupMessage {
|
|
25
|
-
readonly type: "message";
|
|
26
|
-
readonly from: "group";
|
|
27
|
-
readonly group: string;
|
|
28
|
-
readonly dataType: "json";
|
|
29
|
-
readonly data: ChunkEnvelope;
|
|
30
|
-
readonly fromUserId?: string;
|
|
31
|
-
readonly sequenceId?: number;
|
|
32
|
-
}
|
|
33
|
-
/** Options accepted by {@link buildPublish}. */
|
|
34
|
-
export interface BuildPublishOptions {
|
|
35
|
-
/** Target group name (must be a valid {@link parseGroupName} input). */
|
|
36
|
-
readonly group: string;
|
|
37
|
-
/** Source of monotonic `ackId` values for the publishing connection. */
|
|
38
|
-
readonly nextAckId: () => number;
|
|
39
|
-
/** Inner application payload. */
|
|
40
|
-
readonly payload: unknown;
|
|
41
|
-
/** Forwarded to {@link chunk}. */
|
|
42
|
-
readonly chunkOptions?: ChunkOptions;
|
|
43
|
-
/** Opaque host-side connection identity; absent for client-originated frames. */
|
|
44
|
-
readonly generation?: number;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Build the list of {@link SendToGroupCommand}s to publish for a single
|
|
48
|
-
* application payload. An oversized payload chunks into multiple envelopes,
|
|
49
|
-
* each carried by its own frame with its own `ackId`.
|
|
50
|
-
*/
|
|
51
|
-
export declare function buildPublish(options: BuildPublishOptions): SendToGroupCommand[];
|
|
52
|
-
/**
|
|
53
|
-
* Result of {@link parseInbound}.
|
|
54
|
-
*
|
|
55
|
-
* - `kind: 'payload'` — a complete inner application payload is ready.
|
|
56
|
-
* - `kind: 'pending'` — a chunk segment was accepted; reassembly continues.
|
|
57
|
-
* - `kind: 'ignored'` — the frame was not a group-fanout message.
|
|
58
|
-
*/
|
|
59
|
-
export type InboundResult = {
|
|
60
|
-
readonly kind: "payload";
|
|
61
|
-
readonly group: ParsedGroup;
|
|
62
|
-
readonly payload: unknown;
|
|
63
|
-
readonly generation?: number;
|
|
64
|
-
} | {
|
|
65
|
-
readonly kind: "batch";
|
|
66
|
-
readonly group: ParsedGroup;
|
|
67
|
-
readonly payloads: readonly unknown[];
|
|
68
|
-
readonly generation?: number;
|
|
69
|
-
} | {
|
|
70
|
-
readonly kind: "closed";
|
|
71
|
-
readonly group: ParsedGroup;
|
|
72
|
-
readonly generation?: number;
|
|
73
|
-
} | {
|
|
74
|
-
readonly kind: "capabilities";
|
|
75
|
-
readonly group: ParsedGroup;
|
|
76
|
-
readonly accepts: readonly string[];
|
|
77
|
-
} | {
|
|
78
|
-
readonly kind: "pending";
|
|
79
|
-
readonly group: ParsedGroup;
|
|
80
|
-
} | {
|
|
81
|
-
readonly kind: "ignored";
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Error thrown by {@link parseInbound} when a frame is definitely a
|
|
85
|
-
* group-fanout message but the receive envelope itself is malformed.
|
|
86
|
-
*/
|
|
87
|
-
export declare class FramingError extends Error {
|
|
88
|
-
constructor(message: string);
|
|
89
|
-
}
|
|
90
|
-
/** Options accepted by {@link parseInbound}. */
|
|
91
|
-
export interface ParseInboundOptions {
|
|
92
|
-
/** Reassembler instance for this subscriber connection. */
|
|
93
|
-
readonly reassembler: Reassembler;
|
|
94
|
-
/** Forwarded to {@link parseGroupName}. */
|
|
95
|
-
readonly groupValidation?: ParseGroupNameOptions;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Decode one inbound Web PubSub frame (already JSON-parsed) into a structured
|
|
99
|
-
* {@link InboundResult}. Non group-fanout frames are `kind: 'ignored'`;
|
|
100
|
-
* malformed group-fanout frames raise a {@link FramingError}.
|
|
101
|
-
*/
|
|
102
|
-
export declare function parseInbound(frame: unknown, options: ParseInboundOptions): InboundResult;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { chunk, DEFAULT_MAX_CHUNK_BYTES } from './chunking.js';
|
|
3
|
-
import { parseGroupName } from './groups.js';
|
|
4
|
-
|
|
5
|
-
const RELIABLE_JSON_SUBPROTOCOL = "json.reliable.webpubsub.azure.v1";
|
|
6
|
-
function buildPublish(options) {
|
|
7
|
-
if (options.generation !== undefined && (!Number.isSafeInteger(options.generation) || options.generation < 1)) {
|
|
8
|
-
throw ( new FramingError("Invalid host connection generation"));
|
|
9
|
-
}
|
|
10
|
-
const overhead = options.generation === undefined ? 0 : JSON.stringify({
|
|
11
|
-
generation: options.generation
|
|
12
|
-
}).length - 1;
|
|
13
|
-
const envelopes = chunk(options.payload, {
|
|
14
|
-
...options.chunkOptions,
|
|
15
|
-
maxChunkBytes: (options.chunkOptions?.maxChunkBytes ?? DEFAULT_MAX_CHUNK_BYTES) - overhead
|
|
16
|
-
});
|
|
17
|
-
return envelopes.map(envelope => ({
|
|
18
|
-
type: "sendToGroup",
|
|
19
|
-
group: options.group,
|
|
20
|
-
ackId: options.nextAckId(),
|
|
21
|
-
dataType: "json",
|
|
22
|
-
noEcho: true,
|
|
23
|
-
data: options.generation === undefined ? envelope : {
|
|
24
|
-
...envelope,
|
|
25
|
-
generation: options.generation
|
|
26
|
-
}
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
class FramingError extends Error {
|
|
30
|
-
constructor(message) {
|
|
31
|
-
super(message);
|
|
32
|
-
this.name = "FramingError";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function isObject(value) {
|
|
36
|
-
return typeof value === "object" && value !== null;
|
|
37
|
-
}
|
|
38
|
-
function parseInbound(frame, options) {
|
|
39
|
-
if (!isObject(frame)) {
|
|
40
|
-
return {
|
|
41
|
-
kind: "ignored"
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
if (frame["type"] !== "message" || frame["from"] !== "group") {
|
|
45
|
-
return {
|
|
46
|
-
kind: "ignored"
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (frame["dataType"] !== "json") {
|
|
50
|
-
throw ( new FramingError(
|
|
51
|
-
`group-fanout frame has unsupported dataType '${String(frame["dataType"])}'`
|
|
52
|
-
));
|
|
53
|
-
}
|
|
54
|
-
if (typeof frame["group"] !== "string") {
|
|
55
|
-
throw ( new FramingError(`group-fanout frame is missing a string 'group' field`));
|
|
56
|
-
}
|
|
57
|
-
if (!isObject(frame["data"])) {
|
|
58
|
-
throw ( new FramingError(`group-fanout frame is missing a 'data' ChunkEnvelope`));
|
|
59
|
-
}
|
|
60
|
-
const group = parseGroupName(frame["group"], options.groupValidation);
|
|
61
|
-
const fields = frame["data"];
|
|
62
|
-
const generation = fields["generation"];
|
|
63
|
-
if (generation !== undefined && (typeof generation !== "number" || !Number.isSafeInteger(generation) || generation < 1)) {
|
|
64
|
-
throw ( new FramingError("Invalid host connection generation"));
|
|
65
|
-
}
|
|
66
|
-
const identity = generation === undefined ? {} : {
|
|
67
|
-
generation
|
|
68
|
-
};
|
|
69
|
-
if (fields["kind"] === "closed") {
|
|
70
|
-
return {
|
|
71
|
-
kind: "closed",
|
|
72
|
-
group,
|
|
73
|
-
...identity
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
if (fields["kind"] === "capabilities") {
|
|
77
|
-
const accepts = fields["accepts"];
|
|
78
|
-
if (!Array.isArray(accepts) || !accepts.every(value => typeof value === "string") || accepts.length > 256) {
|
|
79
|
-
throw ( new FramingError("Invalid relay framing capabilities"));
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
kind: "capabilities",
|
|
83
|
-
group,
|
|
84
|
-
accepts
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (fields["kind"] === "batch") {
|
|
88
|
-
const items = fields["items"];
|
|
89
|
-
if (!Array.isArray(items) || items.length === 0 || items.length > 256 || ( new TextEncoder()).encode(JSON.stringify(fields)).byteLength > DEFAULT_MAX_CHUNK_BYTES) {
|
|
90
|
-
throw ( new FramingError("Invalid relay batch"));
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
kind: "batch",
|
|
94
|
-
group,
|
|
95
|
-
payloads: items,
|
|
96
|
-
...identity
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const envelope = fields;
|
|
100
|
-
const payload = options.reassembler.ingest(envelope);
|
|
101
|
-
if (payload === null) {
|
|
102
|
-
return {
|
|
103
|
-
kind: "pending",
|
|
104
|
-
group
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
kind: "payload",
|
|
109
|
-
group,
|
|
110
|
-
payload,
|
|
111
|
-
...identity
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { FramingError, RELIABLE_JSON_SUBPROTOCOL, buildPublish, parseInbound };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** Maximum length of a group name in UTF-8 bytes (operational-safety ceiling). */
|
|
2
|
-
export declare const MAX_GROUP_NAME_BYTES = 256;
|
|
3
|
-
/** Per-environment lane suffixes — the complete lane catalogue for env lanes. */
|
|
4
|
-
export type EnvLane = "root" | "events" | "lifecycle" | "control" | "ingest-ack";
|
|
5
|
-
/** Per-client lane discriminator. */
|
|
6
|
-
export type ClientLaneKind = "broadcast" | "to-host" | "to-client";
|
|
7
|
-
/** Structured result of {@link parseGroupName} for a per-client lane. */
|
|
8
|
-
export type ParsedClientLane = {
|
|
9
|
-
readonly scope: "client";
|
|
10
|
-
readonly lane: ClientLaneKind;
|
|
11
|
-
readonly cid: string;
|
|
12
|
-
};
|
|
13
|
-
/** Structured result of {@link parseGroupName} for a per-environment lane. */
|
|
14
|
-
export type ParsedEnvLane = {
|
|
15
|
-
readonly scope: "env";
|
|
16
|
-
readonly lane: EnvLane;
|
|
17
|
-
};
|
|
18
|
-
/** Parsed group name. Always carries `uid` and `eid`; `lane` discriminates scope. */
|
|
19
|
-
export type ParsedGroup = (ParsedClientLane | ParsedEnvLane) & {
|
|
20
|
-
readonly uid: string;
|
|
21
|
-
readonly eid: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Error thrown by {@link parseGroupName} when a name violates the grammar's
|
|
25
|
-
* validation rules or the {@link MAX_GROUP_NAME_BYTES} ceiling.
|
|
26
|
-
*/
|
|
27
|
-
export declare class GroupNameError extends Error {
|
|
28
|
-
constructor(message: string);
|
|
29
|
-
}
|
|
30
|
-
/** Options accepted by {@link parseGroupName}. */
|
|
31
|
-
export interface ParseGroupNameOptions {
|
|
32
|
-
/**
|
|
33
|
-
* If set, the parser rejects any group name whose `<uid>`, `<eid>`, or
|
|
34
|
-
* per-client `<cid>` segment does not match. Omit a field to skip that check.
|
|
35
|
-
*/
|
|
36
|
-
readonly expected?: {
|
|
37
|
-
readonly uid?: string;
|
|
38
|
-
readonly eid?: string;
|
|
39
|
-
readonly cid?: string;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Parse a group name into its structured components, throwing a
|
|
44
|
-
* {@link GroupNameError} on any rule violation.
|
|
45
|
-
*/
|
|
46
|
-
export declare function parseGroupName(name: string, options?: ParseGroupNameOptions): ParsedGroup;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const MAX_GROUP_NAME_BYTES = 256;
|
|
4
|
-
class GroupNameError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "GroupNameError";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
const encoder = ( new TextEncoder());
|
|
11
|
-
const OPAQUE_ID = /^[A-Za-z0-9_-]+$/;
|
|
12
|
-
function validateOpaqueId(name, value) {
|
|
13
|
-
if (value.length === 0) {
|
|
14
|
-
throw ( new GroupNameError(`${name} segment is empty`));
|
|
15
|
-
}
|
|
16
|
-
if (!OPAQUE_ID.test(value)) {
|
|
17
|
-
throw ( new GroupNameError(`${name} segment contains characters outside the opaque-id grammar`));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function parseGroupName(name, options = {}) {
|
|
21
|
-
const byteLength = encoder.encode(name).byteLength;
|
|
22
|
-
if (byteLength > MAX_GROUP_NAME_BYTES) {
|
|
23
|
-
throw ( new GroupNameError(
|
|
24
|
-
`group name is ${byteLength} bytes, exceeds ${MAX_GROUP_NAME_BYTES}-byte cap`
|
|
25
|
-
));
|
|
26
|
-
}
|
|
27
|
-
if (byteLength === 0) {
|
|
28
|
-
throw ( new GroupNameError("group name is empty"));
|
|
29
|
-
}
|
|
30
|
-
const segments = name.split(".");
|
|
31
|
-
if (segments.length < 5) {
|
|
32
|
-
throw ( new GroupNameError(`expected at least 5 segments, got ${segments.length}: ${name}`));
|
|
33
|
-
}
|
|
34
|
-
if (segments[0] !== "user") {
|
|
35
|
-
throw ( new GroupNameError(`expected first segment 'user', got '${segments[0]}'`));
|
|
36
|
-
}
|
|
37
|
-
const uid = segments[1] ?? "";
|
|
38
|
-
validateOpaqueId("uid", uid);
|
|
39
|
-
if (options.expected?.uid !== undefined && uid !== options.expected.uid) {
|
|
40
|
-
throw ( new GroupNameError(`uid '${uid}' does not match expected '${options.expected.uid}'`));
|
|
41
|
-
}
|
|
42
|
-
if (segments[2] !== "env") {
|
|
43
|
-
throw ( new GroupNameError(`expected third segment 'env', got '${segments[2]}'`));
|
|
44
|
-
}
|
|
45
|
-
const eid = segments[3] ?? "";
|
|
46
|
-
validateOpaqueId("eid", eid);
|
|
47
|
-
if (options.expected?.eid !== undefined && eid !== options.expected.eid) {
|
|
48
|
-
throw ( new GroupNameError(`eid '${eid}' does not match expected '${options.expected.eid}'`));
|
|
49
|
-
}
|
|
50
|
-
const lane = segments.slice(4);
|
|
51
|
-
if (lane[0] === "client") {
|
|
52
|
-
if (lane.length < 3) {
|
|
53
|
-
throw ( new GroupNameError(`client lane truncated: ${name}`));
|
|
54
|
-
}
|
|
55
|
-
const cid = lane[1] ?? "";
|
|
56
|
-
validateOpaqueId("cid", cid);
|
|
57
|
-
if (options.expected?.cid !== undefined && cid !== options.expected.cid) {
|
|
58
|
-
throw ( new GroupNameError(`cid '${cid}' does not match expected '${options.expected.cid}'`));
|
|
59
|
-
}
|
|
60
|
-
const direction = lane[2];
|
|
61
|
-
if (direction === "broadcast" || direction === "to-host" || direction === "to-client") {
|
|
62
|
-
if (lane.length !== 3) {
|
|
63
|
-
throw ( new GroupNameError(
|
|
64
|
-
`unexpected trailing segments after '${direction}': ${lane.slice(3).join(".")}`
|
|
65
|
-
));
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
scope: "client",
|
|
69
|
-
lane: direction,
|
|
70
|
-
uid,
|
|
71
|
-
eid,
|
|
72
|
-
cid
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
throw ( new GroupNameError(`unknown client direction '${direction}'`));
|
|
76
|
-
}
|
|
77
|
-
if (lane.length !== 1) {
|
|
78
|
-
throw ( new GroupNameError(`env lane must be a single segment, got ${lane.length}: ${lane.join(".")}`));
|
|
79
|
-
}
|
|
80
|
-
const envLane = lane[0];
|
|
81
|
-
if (envLane !== "root" && envLane !== "events" && envLane !== "lifecycle" && envLane !== "control" && envLane !== "ingest-ack") {
|
|
82
|
-
throw ( new GroupNameError(`unknown env lane '${envLane}'`));
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
scope: "env",
|
|
86
|
-
lane: envLane,
|
|
87
|
-
uid,
|
|
88
|
-
eid
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { GroupNameError, MAX_GROUP_NAME_BYTES, parseGroupName };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IChatSessionProviderOptionGroup, IChatSessionProviderOptionItem } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService";
|
|
2
|
-
export type NewSessionChangeType = "repoUri" | "isolationMode" | "branch" | "options" | "disabled" | "agent";
|
|
3
|
-
/**
|
|
4
|
-
* Represents a resolved option group with its current selected value.
|
|
5
|
-
*/
|
|
6
|
-
export interface ISessionOptionGroup {
|
|
7
|
-
readonly group: IChatSessionProviderOptionGroup;
|
|
8
|
-
readonly value: IChatSessionProviderOptionItem | undefined;
|
|
9
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
-
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
3
|
-
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
4
|
-
import { VoiceNewSessionPreparationResult } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/voiceClient/voiceSessionController";
|
|
5
|
-
import { IVoiceSessionController } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/voiceClient/voiceSessionController.service";
|
|
6
|
-
import { ISessionsService } from "@codingame/monaco-vscode-api/vscode/vs/sessions/services/sessions/browser/sessionsService.service";
|
|
7
|
-
import { ISessionsManagementService } from "@codingame/monaco-vscode-api/vscode/vs/sessions/services/sessions/common/sessionsManagement.service";
|
|
8
|
-
import { INewChatVoiceTargetService } from "@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/chat/browser/newChatVoice.service";
|
|
9
|
-
export declare function prepareNewVoiceSession(text: string, sessionsService: ISessionsService, sessionsManagementService: ISessionsManagementService, voiceSessionController: IVoiceSessionController, hasActiveComposer: () => boolean, beginVoiceTransition: () => IDisposable, logService: ILogService): Promise<VoiceNewSessionPreparationResult>;
|
|
10
|
-
/** Ends voice when a different welcome composer becomes active; routing in-session composers are exempt. */
|
|
11
|
-
export declare class SessionsVoiceNewComposerContribution extends Disposable implements IWorkbenchContribution {
|
|
12
|
-
static readonly ID = "sessions.voiceNewComposer";
|
|
13
|
-
constructor(voiceSessionController: IVoiceSessionController, newChatVoiceTargetService: INewChatVoiceTargetService);
|
|
14
|
-
}
|