@codingame/monaco-vscode-chat-service-override 38.0.7 → 38.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common.js +0 -53
- package/index.js +0 -3
- package/package.json +5 -5
- package/session.js +0 -3
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/missionControlAgentHostContribution.js +1 -1
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.shared.contribution.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHost.contribution.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostChatContribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewTitleControl.js +1 -1
- package/vscode/src/vs/platform/agentHost/browser/webPubSubRelayTransport.d.ts +0 -135
- package/vscode/src/vs/platform/agentHost/browser/webPubSubRelayTransport.js +0 -510
- package/vscode/src/vs/platform/agentHost/common/agentModelNotices.d.ts +0 -22
- package/vscode/src/vs/platform/agentHost/common/agentModelNotices.js +0 -21
- package/vscode/src/vs/platform/agentHost/common/cloudSandboxAgentHost.d.ts +0 -273
- package/vscode/src/vs/platform/agentHost/common/cloudSandboxAgentHost.js +0 -61
- package/vscode/src/vs/platform/agentHost/common/meta/agentModelMeta.d.ts +0 -7
- package/vscode/src/vs/platform/agentHost/common/meta/agentModelMeta.js +0 -17
- package/vscode/src/vs/platform/agentHost/common/meta/copilotd/cloudSandboxProjectMeta.d.ts +0 -12
- package/vscode/src/vs/platform/agentHost/common/meta/copilotd/cloudSandboxProjectMeta.js +0 -48
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelEnsembleMeta.d.ts +0 -8
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelEnsembleMeta.js +0 -11
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelPricing.d.ts +0 -114
- package/vscode/src/vs/platform/agentHost/common/meta/vscode/agentModelPricing.js +0 -141
- package/vscode/src/vs/platform/agentHost/common/taskEventReplay.d.ts +0 -48
- package/vscode/src/vs/platform/agentHost/common/taskEventReplay.js +0 -238
- package/vscode/src/vs/platform/agentHost/common/webPubSub/chunking.d.ts +0 -102
- package/vscode/src/vs/platform/agentHost/common/webPubSub/chunking.js +0 -260
- package/vscode/src/vs/platform/agentHost/common/webPubSub/framing.d.ts +0 -102
- package/vscode/src/vs/platform/agentHost/common/webPubSub/framing.js +0 -115
- package/vscode/src/vs/platform/agentHost/common/webPubSub/groups.d.ts +0 -46
- package/vscode/src/vs/platform/agentHost/common/webPubSub/groups.js +0 -92
- package/vscode/src/vs/sessions/contrib/chat/browser/newSession.d.ts +0 -9
- package/vscode/src/vs/sessions/contrib/chat/browser/voiceBridge.contribution.d.ts +0 -14
- package/vscode/src/vs/sessions/contrib/chat/browser/voiceBridge.contribution.js +0 -385
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.d.ts +0 -67
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.js +0 -695
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.d.ts +0 -4
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.js +0 -39
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.d.ts +0 -1
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.js +0 -59
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.d.ts +0 -1
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.js +0 -83
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.d.ts +0 -87
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.js +0 -176
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.d.ts +0 -422
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.js +0 -2444
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.d.ts +0 -91
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.js +0 -620
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.d.ts +0 -1
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.js +0 -5
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.d.ts +0 -46
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.js +0 -321
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.d.ts +0 -104
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.js +0 -345
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoice.contribution.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoice.contribution.js +0 -611
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceSessionsPicker.d.ts +0 -20
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceSessionsPicker.js +0 -85
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.d.ts +0 -200
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidget.js +0 -981
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidgetBinding.d.ts +0 -24
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWidgetBinding.js +0 -206
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWindowService.d.ts +0 -65
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/agentsVoiceWindowService.js +0 -368
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/confirmationComponent.d.ts +0 -10
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/confirmationComponent.js +0 -57
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/feedbackDialog.d.ts +0 -33
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/feedbackDialog.js +0 -98
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/headerComponent.d.ts +0 -32
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/headerComponent.js +0 -186
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/onboardingComponent.d.ts +0 -12
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/onboardingComponent.js +0 -116
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/sessionListComponent.d.ts +0 -32
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/sessionListComponent.js +0 -226
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/statusRowsComponent.d.ts +0 -18
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/statusRowsComponent.js +0 -138
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/tokens.d.ts +0 -32
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/tokens.js +0 -29
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/transcriptComponent.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/transcriptComponent.js +0 -108
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/voiceBarComponent.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/components/voiceBarComponent.js +0 -63
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/media/voiceModeOnboarding.css +0 -252
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscripts.contribution.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscripts.contribution.js +0 -178
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscriptsView.d.ts +0 -47
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/transcriptsView/voiceTranscriptsView.js +0 -322
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.d.ts +0 -146
- package/vscode/src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.js +0 -890
- package/vscode/src/vs/workbench/contrib/agentsVoice/common/voiceTranscriptStore.d.ts +0 -132
- package/vscode/src/vs/workbench/contrib/agentsVoice/common/voiceTranscriptStore.js +0 -237
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.d.ts +0 -120
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.js +0 -234
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.d.ts +0 -36
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.js +0 -164
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/repositoryPicker.d.ts +0 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/repositoryPicker.js +0 -122
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupMicrosoftProbe.d.ts +0 -82
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupMicrosoftProbe.js +0 -213
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxAgentHostService.d.ts +0 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxAgentHostService.js +0 -561
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxApiService.d.ts +0 -133
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxApiService.js +0 -1176
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxConnectionCustomization.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxConnectionCustomization.js +0 -76
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxCredentialRefresh.d.ts +0 -54
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxCredentialRefresh.js +0 -220
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxHistoryCache.d.ts +0 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxHistoryCache.js +0 -184
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxLegacySessionPreparation.d.ts +0 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxLegacySessionPreparation.js +0 -165
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxModels.d.ts +0 -43
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxModels.js +0 -162
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxReadOnlySessionHandler.d.ts +0 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxReadOnlySessionHandler.js +0 -129
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.d.ts +0 -166
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.js +0 -838
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionHandler.d.ts +0 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionHandler.js +0 -604
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.d.ts +0 -289
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.js +0 -497
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlCredentialSealing.d.ts +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlCredentialSealing.js +0 -41
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentService.d.ts +0 -73
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlEnvironmentService.js +0 -398
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlSharingService.d.ts +0 -45
- package/vscode/src/vs/workbench/contrib/chat/browser/remoteAgentHost/missionControlSharingService.js +0 -296
- package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/voiceCodeTranscriptionClient.d.ts +0 -63
- package/vscode/src/vs/workbench/contrib/chat/browser/speechToText/voiceCodeTranscriptionClient.js +0 -361
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/ttsPlaybackService.d.ts +0 -34
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/ttsPlaybackService.js +0 -198
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/voiceClientService.d.ts +0 -131
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceClient/voiceClientService.js +0 -871
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceInputMode/voiceInputMode.d.ts +0 -66
- package/vscode/src/vs/workbench/contrib/chat/browser/voiceInputMode/voiceInputMode.js +0 -297
- package/vscode/src/vs/workbench/contrib/chat/common/voicePlaybackService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/voicePlaybackService.js +0 -118
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const NUMBER_KEYS = [
|
|
4
|
-
'multiplierNumeric',
|
|
5
|
-
'inputCost',
|
|
6
|
-
'cacheCost',
|
|
7
|
-
'cacheWriteCost',
|
|
8
|
-
'outputCost',
|
|
9
|
-
'longContextInputCost',
|
|
10
|
-
'longContextCacheCost',
|
|
11
|
-
'longContextCacheWriteCost',
|
|
12
|
-
'longContextOutputCost',
|
|
13
|
-
'discountPercent',
|
|
14
|
-
];
|
|
15
|
-
function readAgentModelPricingMeta(model) {
|
|
16
|
-
const meta = model._meta;
|
|
17
|
-
if (!meta) {
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
const result = {};
|
|
21
|
-
for (const key of NUMBER_KEYS) {
|
|
22
|
-
const value = meta[key];
|
|
23
|
-
if (typeof value === 'number') {
|
|
24
|
-
result[key] = value;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (typeof meta.priceCategory === 'string') {
|
|
28
|
-
result.priceCategory = meta.priceCategory;
|
|
29
|
-
}
|
|
30
|
-
if (typeof meta.category === 'string') {
|
|
31
|
-
result.category = meta.category;
|
|
32
|
-
}
|
|
33
|
-
const rawPromo = meta.promo;
|
|
34
|
-
if (rawPromo && typeof rawPromo === 'object' && !Array.isArray(rawPromo)) {
|
|
35
|
-
const p = rawPromo;
|
|
36
|
-
if (typeof p.id === 'string' && typeof p.discountPercent === 'number' && typeof p.message === 'string') {
|
|
37
|
-
result.promo = {
|
|
38
|
-
id: p.id,
|
|
39
|
-
discountPercent: p.discountPercent,
|
|
40
|
-
message: p.message,
|
|
41
|
-
...(typeof p.endsAt === 'string' ? { endsAt: p.endsAt } : {}),
|
|
42
|
-
...(typeof p.showBanner === 'boolean' ? { showBanner: p.showBanner } : {}),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
function createAgentModelPricingMeta(pricing) {
|
|
49
|
-
const entries = Object.entries(pricing).filter(([, value]) => value !== undefined);
|
|
50
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
51
|
-
}
|
|
52
|
-
function normalizeCAPIBilling(raw) {
|
|
53
|
-
if (!raw || typeof raw !== 'object') {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
const billing = raw;
|
|
57
|
-
const multiplier = typeof billing.multiplier === 'number' ? billing.multiplier : undefined;
|
|
58
|
-
const priceCategory = typeof billing.priceCategory === 'string' ? billing.priceCategory
|
|
59
|
-
: typeof billing.price_category === 'string' ? billing.price_category
|
|
60
|
-
: undefined;
|
|
61
|
-
const discountPercent = typeof billing.discountPercent === 'number' ? billing.discountPercent
|
|
62
|
-
: typeof billing.discount_percent === 'number' ? billing.discount_percent
|
|
63
|
-
: undefined;
|
|
64
|
-
const rawTokenPrices = (billing.tokenPrices ?? billing.token_prices);
|
|
65
|
-
let tokenPrices = undefined;
|
|
66
|
-
if (rawTokenPrices && typeof rawTokenPrices === 'object') {
|
|
67
|
-
const defaultTier = rawTokenPrices.default;
|
|
68
|
-
const hasDefault = defaultTier && typeof defaultTier === 'object';
|
|
69
|
-
const batchSize = asNumber(rawTokenPrices.batchSize) ?? asNumber(rawTokenPrices.batch_size) ?? 1_000_000;
|
|
70
|
-
const scale = batchSize > 0 ? 1_000_000 / batchSize : 1;
|
|
71
|
-
const price = (...values) => {
|
|
72
|
-
const value = values.map(asNumber).find(candidate => candidate !== undefined);
|
|
73
|
-
return value === undefined ? undefined : value * scale;
|
|
74
|
-
};
|
|
75
|
-
const inputPrice = price(rawTokenPrices.inputPrice, hasDefault ? defaultTier.input_price : undefined);
|
|
76
|
-
const cachePrice = price(rawTokenPrices.cacheReadPrice, rawTokenPrices.cachePrice, hasDefault ? defaultTier.cache_read_price : undefined, hasDefault ? defaultTier.cache_price : undefined);
|
|
77
|
-
const cacheWritePrice = price(rawTokenPrices.cacheWritePrice, hasDefault ? defaultTier.cache_write_price : undefined);
|
|
78
|
-
const outputPrice = price(rawTokenPrices.outputPrice, hasDefault ? defaultTier.output_price : undefined);
|
|
79
|
-
const contextMax = asNumber(rawTokenPrices.maxPromptTokens) ?? asNumber(rawTokenPrices.contextMax) ?? asNumber(hasDefault ? defaultTier.max_prompt_tokens : undefined) ?? asNumber(hasDefault ? defaultTier.context_max : undefined);
|
|
80
|
-
const rawLong = (rawTokenPrices.longContext ?? rawTokenPrices.long_context);
|
|
81
|
-
let longContext;
|
|
82
|
-
if (rawLong && typeof rawLong === 'object') {
|
|
83
|
-
longContext = {
|
|
84
|
-
inputPrice: price(rawLong.inputPrice, rawLong.input_price),
|
|
85
|
-
cachePrice: price(rawLong.cacheReadPrice, rawLong.cachePrice, rawLong.cache_read_price, rawLong.cache_price),
|
|
86
|
-
cacheWritePrice: price(rawLong.cacheWritePrice, rawLong.cache_write_price),
|
|
87
|
-
outputPrice: price(rawLong.outputPrice, rawLong.output_price),
|
|
88
|
-
contextMax: asNumber(rawLong.maxPromptTokens) ?? asNumber(rawLong.contextMax) ?? asNumber(rawLong.max_prompt_tokens) ?? asNumber(rawLong.context_max),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
tokenPrices = { inputPrice, cachePrice, cacheWritePrice, outputPrice, contextMax, longContext };
|
|
92
|
-
}
|
|
93
|
-
return { multiplier, priceCategory, discountPercent, promo: normalizePromo(billing), tokenPrices };
|
|
94
|
-
}
|
|
95
|
-
function asNumber(v) {
|
|
96
|
-
return typeof v === 'number' ? v : undefined;
|
|
97
|
-
}
|
|
98
|
-
function normalizePromo(billing) {
|
|
99
|
-
const raw = billing.promo;
|
|
100
|
-
if (!raw || typeof raw !== 'object') {
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
const id = typeof raw.id === 'string' ? raw.id : undefined;
|
|
104
|
-
const discountPercent = asNumber(raw.discountPercent) ?? asNumber(raw.discount_percent);
|
|
105
|
-
const endsAt = typeof raw.endsAt === 'string' ? raw.endsAt
|
|
106
|
-
: typeof raw.ends_at === 'string' ? raw.ends_at
|
|
107
|
-
: undefined;
|
|
108
|
-
const message = typeof raw.message === 'string' ? raw.message : undefined;
|
|
109
|
-
const showBanner = typeof raw.showBanner === 'boolean' ? raw.showBanner
|
|
110
|
-
: typeof raw.show_banner === 'boolean' ? raw.show_banner
|
|
111
|
-
: undefined;
|
|
112
|
-
if (id && typeof discountPercent === 'number' && message) {
|
|
113
|
-
return { id, discountPercent, message, ...(endsAt ? { endsAt } : {}), ...(showBanner !== undefined ? { showBanner } : {}) };
|
|
114
|
-
}
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
function createPricingMetaFromBilling(billing, priceCategory, category) {
|
|
118
|
-
const tokenPrices = billing?.tokenPrices;
|
|
119
|
-
const longContext = tokenPrices?.longContext;
|
|
120
|
-
const showLongContext = longContext !== undefined && ((longContext.inputPrice !== undefined && longContext.inputPrice !== tokenPrices?.inputPrice) ||
|
|
121
|
-
(longContext.outputPrice !== undefined && longContext.outputPrice !== tokenPrices?.outputPrice) ||
|
|
122
|
-
(longContext.cachePrice !== undefined && longContext.cachePrice !== tokenPrices?.cachePrice) ||
|
|
123
|
-
(longContext.cacheWritePrice !== undefined && longContext.cacheWritePrice !== tokenPrices?.cacheWritePrice));
|
|
124
|
-
return createAgentModelPricingMeta({
|
|
125
|
-
multiplierNumeric: typeof billing?.multiplier === 'number' ? billing.multiplier : undefined,
|
|
126
|
-
inputCost: tokenPrices?.inputPrice,
|
|
127
|
-
cacheCost: tokenPrices?.cachePrice,
|
|
128
|
-
cacheWriteCost: tokenPrices?.cacheWritePrice,
|
|
129
|
-
outputCost: tokenPrices?.outputPrice,
|
|
130
|
-
longContextInputCost: showLongContext ? (longContext.inputPrice ?? tokenPrices?.inputPrice) : undefined,
|
|
131
|
-
longContextCacheCost: showLongContext ? (longContext.cachePrice ?? tokenPrices?.cachePrice) : undefined,
|
|
132
|
-
longContextCacheWriteCost: showLongContext ? (longContext.cacheWritePrice ?? tokenPrices?.cacheWritePrice) : undefined,
|
|
133
|
-
longContextOutputCost: showLongContext ? (longContext.outputPrice ?? tokenPrices?.outputPrice) : undefined,
|
|
134
|
-
priceCategory: priceCategory ?? (typeof billing?.priceCategory === 'string' ? billing.priceCategory : undefined),
|
|
135
|
-
category,
|
|
136
|
-
discountPercent: typeof billing?.discountPercent === 'number' ? billing.discountPercent : undefined,
|
|
137
|
-
promo: billing?.promo,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export { createAgentModelPricingMeta, createPricingMetaFromBilling, normalizeCAPIBilling, readAgentModelPricingMeta };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ChatState } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-chat/state";
|
|
2
|
-
import { SessionState } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-session/state";
|
|
3
|
-
/** A persisted history that could not be decoded. Distinct from a transport/HTTP failure. */
|
|
4
|
-
export declare class TaskEventReplayError extends Error {
|
|
5
|
-
constructor(message: string);
|
|
6
|
-
}
|
|
7
|
-
/** The replayed state of a single session found in a task's persisted history. */
|
|
8
|
-
export interface IReplayedSession {
|
|
9
|
-
/** Session channel URI (`ahp-session:/<uuid>`). */
|
|
10
|
-
readonly session: string;
|
|
11
|
-
/** Folded session-channel state. */
|
|
12
|
-
readonly state: SessionState;
|
|
13
|
-
/** Folded chat-channel state, keyed by chat channel URI. */
|
|
14
|
-
readonly chats: ReadonlyMap<string, ChatState>;
|
|
15
|
-
/**
|
|
16
|
-
* The host-announced default chat, or a sole recorded chat consistent with all recorded catalogue evidence.
|
|
17
|
-
* History without either retains the legacy `<session>/chat` fallback.
|
|
18
|
-
*/
|
|
19
|
-
readonly defaultChat: string;
|
|
20
|
-
/** Timestamp of the last persisted event, ISO 8601. */
|
|
21
|
-
readonly modifiedAt: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Outcome of replaying a task's persisted AHP history.
|
|
25
|
-
*
|
|
26
|
-
* {@link truncated} MUST be surfaced rather than presented as a complete transcript: a partial
|
|
27
|
-
* tail means the recorded conversation stops short of what actually happened.
|
|
28
|
-
*/
|
|
29
|
-
export interface IReplayedTaskHistory {
|
|
30
|
-
/** Every session the task's history covers. A task may own more than one. */
|
|
31
|
-
readonly sessions: readonly IReplayedSession[];
|
|
32
|
-
/** Whether the recorded history ends mid-action, so the tail is missing. */
|
|
33
|
-
readonly truncated: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Replay Mission Control's persisted AHP frames for a task.
|
|
37
|
-
*
|
|
38
|
-
* Returns `undefined` when the task has no AHP history at all (a cloud task that never ran on a
|
|
39
|
-
* sandbox), which is not an error.
|
|
40
|
-
*/
|
|
41
|
-
export declare function replayTaskAhpEvents(events: readonly unknown[]): IReplayedTaskHistory | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Decode the `events` array of a Mission Control `GET /agents/tasks/<id>/events` response.
|
|
44
|
-
*
|
|
45
|
-
* The `total` cross-check guards against a silently short page being folded into a transcript
|
|
46
|
-
* that looks whole.
|
|
47
|
-
*/
|
|
48
|
-
export declare function parseTaskEventsResponse(body: unknown): readonly unknown[];
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
|
|
3
|
-
import { Reassembler } from './webPubSub/chunking.js';
|
|
4
|
-
import { ActionType } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/common/actions';
|
|
5
|
-
import { chatReducer } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-chat/reducer';
|
|
6
|
-
import { ChatOriginKind } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-chat/state';
|
|
7
|
-
import { sessionReducer } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-session/reducer';
|
|
8
|
-
import { SessionLifecycle, SessionStatus } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/channels-session/state';
|
|
9
|
-
|
|
10
|
-
const MAX_RESTART_EPOCH_INITIAL_SEQUENCE = 1;
|
|
11
|
-
class TaskEventReplayError extends Error {
|
|
12
|
-
constructor(message) {
|
|
13
|
-
super(message);
|
|
14
|
-
this.name = "TaskEventReplayError";
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function isRecord(value) {
|
|
18
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
-
}
|
|
20
|
-
function requireNonEmptyString(value, field, eventIndex) {
|
|
21
|
-
if (typeof value !== "string" || !value.trim()) {
|
|
22
|
-
throw ( new TaskEventReplayError(`Task AHP event ${eventIndex} has an invalid ${field}.`));
|
|
23
|
-
}
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
function requireNonNegativeInteger(value, field, eventIndex) {
|
|
27
|
-
if (!Number.isInteger(value) || value < 0) {
|
|
28
|
-
throw ( new TaskEventReplayError(`Task AHP event ${eventIndex} has an invalid ${field}.`));
|
|
29
|
-
}
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
function parseActionEnvelope(value, eventIndex) {
|
|
33
|
-
if (!isRecord(value)) {
|
|
34
|
-
throw ( new TaskEventReplayError(`Task AHP event ${eventIndex} did not contain an ActionEnvelope object.`));
|
|
35
|
-
}
|
|
36
|
-
requireNonEmptyString(value["channel"], "payload.data.channel", eventIndex);
|
|
37
|
-
requireNonNegativeInteger(value["serverSeq"], "payload.data.serverSeq", eventIndex);
|
|
38
|
-
const action = value["action"];
|
|
39
|
-
if (!isRecord(action)) {
|
|
40
|
-
throw ( new TaskEventReplayError(`Task AHP event ${eventIndex} has an invalid payload.data.action.`));
|
|
41
|
-
}
|
|
42
|
-
requireNonEmptyString(action["type"], "payload.data.action.type", eventIndex);
|
|
43
|
-
const rejectionReason = value["rejectionReason"];
|
|
44
|
-
if (rejectionReason !== undefined && rejectionReason !== null) {
|
|
45
|
-
requireNonEmptyString(rejectionReason, "payload.data.rejectionReason", eventIndex);
|
|
46
|
-
}
|
|
47
|
-
return value;
|
|
48
|
-
}
|
|
49
|
-
function sessionChannelFor(sessionId) {
|
|
50
|
-
return sessionId.startsWith("ahp-session:/") ? sessionId : `ahp-session:/${sessionId}`;
|
|
51
|
-
}
|
|
52
|
-
function seedSessionState() {
|
|
53
|
-
return {
|
|
54
|
-
provider: "",
|
|
55
|
-
title: "",
|
|
56
|
-
status: SessionStatus.Idle,
|
|
57
|
-
lifecycle: SessionLifecycle.Ready,
|
|
58
|
-
activeClients: [],
|
|
59
|
-
chats: []
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function seedChatState(chatChannel, modifiedAt) {
|
|
63
|
-
return {
|
|
64
|
-
resource: chatChannel,
|
|
65
|
-
title: "",
|
|
66
|
-
status: SessionStatus.Idle,
|
|
67
|
-
modifiedAt,
|
|
68
|
-
turns: []
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function decodeEvents(events) {
|
|
72
|
-
const sessions = ( new Map());
|
|
73
|
-
for (const [eventIndex, value] of events.entries()) {
|
|
74
|
-
if (!isRecord(value)) {
|
|
75
|
-
throw ( new TaskEventReplayError(`Task AHP event ${eventIndex} must be an object.`));
|
|
76
|
-
}
|
|
77
|
-
if (value["ns"] !== "ahp") {
|
|
78
|
-
throw ( new TaskEventReplayError(`Task AHP event ${eventIndex} has an invalid ns.`));
|
|
79
|
-
}
|
|
80
|
-
const session = sessionChannelFor(requireNonEmptyString(value["session_id"], "session_id", eventIndex));
|
|
81
|
-
const seq = requireNonNegativeInteger(value["seq"], "seq", eventIndex);
|
|
82
|
-
const at = requireNonEmptyString(value["at"], "at", eventIndex);
|
|
83
|
-
let entry = sessions.get(session);
|
|
84
|
-
if (!entry) {
|
|
85
|
-
entry = {
|
|
86
|
-
envelopes: [],
|
|
87
|
-
eventsBySeq: ( new Map()),
|
|
88
|
-
modifiedAt: at,
|
|
89
|
-
nextSeq: seq,
|
|
90
|
-
reassembler: ( new Reassembler()),
|
|
91
|
-
abandonedChunkGroup: false
|
|
92
|
-
};
|
|
93
|
-
sessions.set(session, entry);
|
|
94
|
-
}
|
|
95
|
-
if (equals(entry.eventsBySeq.get(seq), value)) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const startsRestartEpoch = seq !== entry.nextSeq && seq < entry.nextSeq && seq <= MAX_RESTART_EPOCH_INITIAL_SEQUENCE;
|
|
99
|
-
if (seq !== entry.nextSeq && !startsRestartEpoch) {
|
|
100
|
-
throw ( new TaskEventReplayError(
|
|
101
|
-
`Task AHP event ${eventIndex} for session '${session}' has sequence ${seq}; expected ${entry.nextSeq}.`
|
|
102
|
-
));
|
|
103
|
-
}
|
|
104
|
-
if (startsRestartEpoch) {
|
|
105
|
-
entry.abandonedChunkGroup ||= entry.reassembler.inFlightGroupCount > 0;
|
|
106
|
-
entry.eventsBySeq.clear();
|
|
107
|
-
entry.nextSeq = seq;
|
|
108
|
-
entry.reassembler = ( new Reassembler());
|
|
109
|
-
}
|
|
110
|
-
entry.eventsBySeq.set(seq, value);
|
|
111
|
-
entry.modifiedAt = at;
|
|
112
|
-
entry.nextSeq += 1;
|
|
113
|
-
let reassembled;
|
|
114
|
-
try {
|
|
115
|
-
reassembled = entry.reassembler.ingest(value["payload"]);
|
|
116
|
-
} catch (error) {
|
|
117
|
-
const message = error instanceof Error ? error.message : "unknown chunking failure";
|
|
118
|
-
throw ( new TaskEventReplayError(
|
|
119
|
-
`Task AHP event ${eventIndex} for session '${session}' could not be reassembled: ${message}`
|
|
120
|
-
));
|
|
121
|
-
}
|
|
122
|
-
if (reassembled === null) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
const envelope = parseActionEnvelope(reassembled, eventIndex);
|
|
126
|
-
if (!envelope.rejectionReason) {
|
|
127
|
-
entry.envelopes.push(envelope);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return sessions;
|
|
131
|
-
}
|
|
132
|
-
function foldSession(session, entry) {
|
|
133
|
-
let state = seedSessionState();
|
|
134
|
-
const chats = ( new Map());
|
|
135
|
-
const mentioned = ( new Set());
|
|
136
|
-
const removed = ( new Set());
|
|
137
|
-
for (const envelope of entry.envelopes) {
|
|
138
|
-
const channel = envelope.channel;
|
|
139
|
-
const action = envelope.action;
|
|
140
|
-
if (action.type.startsWith("session/") && channel === session) {
|
|
141
|
-
const sessionAction = action;
|
|
142
|
-
switch (sessionAction.type) {
|
|
143
|
-
case ActionType.SessionChatAdded:
|
|
144
|
-
removed.delete(sessionAction.summary.resource);
|
|
145
|
-
break;
|
|
146
|
-
case ActionType.SessionChatUpdated:
|
|
147
|
-
mentioned.add(sessionAction.chat);
|
|
148
|
-
break;
|
|
149
|
-
case ActionType.SessionChatsReordered:
|
|
150
|
-
for (const chat of sessionAction.chats) {
|
|
151
|
-
mentioned.add(chat);
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
case ActionType.SessionChatRemoved:
|
|
155
|
-
mentioned.delete(sessionAction.chat);
|
|
156
|
-
removed.add(sessionAction.chat);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
state = sessionReducer(state, sessionAction);
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
if (action.type.startsWith("chat/")) {
|
|
163
|
-
const current = chats.get(channel) ?? seedChatState(channel, entry.modifiedAt);
|
|
164
|
-
chats.set(channel, chatReducer(current, action));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const catalogue = ( new Map(state.chats.map(chat => [chat.resource, chat])));
|
|
168
|
-
const isPeer = chat => {
|
|
169
|
-
const origin = catalogue.get(chat)?.origin;
|
|
170
|
-
return !!origin && origin.kind !== ChatOriginKind.User;
|
|
171
|
-
};
|
|
172
|
-
const candidates = [...( chats.keys())].filter(chat => !( removed.has(chat)) && !isPeer(chat));
|
|
173
|
-
const [candidate] = candidates;
|
|
174
|
-
const reachesCandidateCache = ( new Map());
|
|
175
|
-
const reachesCandidate = chat => {
|
|
176
|
-
const visited = ( new Set());
|
|
177
|
-
let current = chat;
|
|
178
|
-
while (current !== candidate && !( reachesCandidateCache.has(current))) {
|
|
179
|
-
if (( visited.has(current)) || ( removed.has(current))) {
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
visited.add(current);
|
|
183
|
-
const origin = catalogue.get(current)?.origin;
|
|
184
|
-
if (origin?.kind !== ChatOriginKind.Tool && origin?.kind !== ChatOriginKind.Fork && origin?.kind !== ChatOriginKind.SideChat) {
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
current = origin.chat;
|
|
188
|
-
}
|
|
189
|
-
const result = current === candidate || reachesCandidateCache.get(current) === true;
|
|
190
|
-
for (const resource of visited) {
|
|
191
|
-
reachesCandidateCache.set(resource, result);
|
|
192
|
-
}
|
|
193
|
-
return result;
|
|
194
|
-
};
|
|
195
|
-
const unambiguousChat = candidates.length === 1 && state.chats.every(chat => reachesCandidate(chat.resource)) && [...mentioned].every(reachesCandidate) ? candidate : undefined;
|
|
196
|
-
const defaultChat = state.defaultChat || unambiguousChat || `${session}/chat`;
|
|
197
|
-
if (!( chats.has(defaultChat))) {
|
|
198
|
-
chats.set(defaultChat, seedChatState(defaultChat, entry.modifiedAt));
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
session,
|
|
202
|
-
state,
|
|
203
|
-
chats,
|
|
204
|
-
defaultChat,
|
|
205
|
-
modifiedAt: entry.modifiedAt
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function replayTaskAhpEvents(events) {
|
|
209
|
-
const decoded = decodeEvents(events);
|
|
210
|
-
if (decoded.size === 0) {
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
const sessions = [];
|
|
214
|
-
let truncated = false;
|
|
215
|
-
for (const [session, entry] of decoded) {
|
|
216
|
-
sessions.push(foldSession(session, entry));
|
|
217
|
-
truncated ||= entry.abandonedChunkGroup || entry.reassembler.inFlightGroupCount > 0;
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
sessions,
|
|
221
|
-
truncated
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function parseTaskEventsResponse(body) {
|
|
225
|
-
if (!isRecord(body) || !Array.isArray(body["events"])) {
|
|
226
|
-
throw ( new TaskEventReplayError("Task AHP history response is malformed."));
|
|
227
|
-
}
|
|
228
|
-
const total = body["total"];
|
|
229
|
-
if (!Number.isInteger(total) || total < 0) {
|
|
230
|
-
throw ( new TaskEventReplayError("Task AHP history response has an invalid total."));
|
|
231
|
-
}
|
|
232
|
-
if (total !== body["events"].length) {
|
|
233
|
-
throw ( new TaskEventReplayError("Task AHP history response has an inconsistent total."));
|
|
234
|
-
}
|
|
235
|
-
return body["events"];
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export { TaskEventReplayError, parseTaskEventsResponse, replayTaskAhpEvents };
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `ChunkEnvelope` wire shape (snake_case field names per spec).
|
|
3
|
-
*
|
|
4
|
-
* `data` for the `"message"` variant is the complete inner application payload.
|
|
5
|
-
* `bytes` for the `"chunk"` variant is a base64-encoded byte slice (RFC 4648
|
|
6
|
-
* standard, with padding) of the serialised inner payload.
|
|
7
|
-
*/
|
|
8
|
-
export type ChunkEnvelope = {
|
|
9
|
-
readonly kind: "message";
|
|
10
|
-
readonly data: unknown;
|
|
11
|
-
readonly generation?: number;
|
|
12
|
-
} | {
|
|
13
|
-
readonly kind: "chunk";
|
|
14
|
-
readonly group_id: string;
|
|
15
|
-
readonly seq: number;
|
|
16
|
-
readonly total: number;
|
|
17
|
-
readonly bytes: string;
|
|
18
|
-
readonly generation?: number;
|
|
19
|
-
};
|
|
20
|
-
/** Default per-segment ceiling (serialised `ChunkEnvelope` bytes). */
|
|
21
|
-
export declare const DEFAULT_MAX_CHUNK_BYTES: number;
|
|
22
|
-
/** Default reassembly timeout in milliseconds. */
|
|
23
|
-
export declare const DEFAULT_REASSEMBLY_TIMEOUT_MS = 30000;
|
|
24
|
-
/** Recommended per-buffer ceiling (decoded payload bytes). */
|
|
25
|
-
export declare const DEFAULT_MAX_REASSEMBLY_BYTES: number;
|
|
26
|
-
/** Recommended aggregate ceiling across all incomplete reassembly groups. */
|
|
27
|
-
export declare const DEFAULT_MAX_REASSEMBLY_TOTAL_BYTES: number;
|
|
28
|
-
/** Recommended cap on the number of concurrent in-flight reassembly groups. */
|
|
29
|
-
export declare const DEFAULT_MAX_CONCURRENT_GROUPS = 64;
|
|
30
|
-
/** Defensive cap on the `total` field of an individual chunked group. */
|
|
31
|
-
export declare const DEFAULT_MAX_SEGMENTS_PER_GROUP = 4096;
|
|
32
|
-
/**
|
|
33
|
-
* Error thrown by {@link Reassembler} on a contract violation and by
|
|
34
|
-
* {@link chunk} on caller-side failures.
|
|
35
|
-
*/
|
|
36
|
-
export declare class ChunkingError extends Error {
|
|
37
|
-
constructor(message: string);
|
|
38
|
-
}
|
|
39
|
-
/** Options accepted by {@link chunk}. */
|
|
40
|
-
export interface ChunkOptions {
|
|
41
|
-
/** Per-segment ceiling in serialised-bytes. Defaults to {@link DEFAULT_MAX_CHUNK_BYTES}. */
|
|
42
|
-
readonly maxChunkBytes?: number;
|
|
43
|
-
/** UUID factory invoked once per chunked publish to mint a `group_id`. */
|
|
44
|
-
readonly newGroupId?: () => string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Split an application payload into one or more {@link ChunkEnvelope}s.
|
|
48
|
-
*
|
|
49
|
-
* If the serialised single-frame envelope fits inside the ceiling, returns a
|
|
50
|
-
* one-element array containing the `kind: "message"` envelope. Otherwise mints
|
|
51
|
-
* a `group_id` and returns `total = ceil(len(B) / R)` `kind: "chunk"`
|
|
52
|
-
* envelopes. The raw-byte budget is derived from the actual group id and the
|
|
53
|
-
* widest permitted sequence fields so every serialized envelope fits.
|
|
54
|
-
*/
|
|
55
|
-
export declare function chunk(payload: unknown, options?: ChunkOptions): ChunkEnvelope[];
|
|
56
|
-
/** Options accepted by {@link Reassembler}. */
|
|
57
|
-
export interface ReassemblerOptions {
|
|
58
|
-
/** Drop partial buffers older than this many milliseconds. */
|
|
59
|
-
readonly timeoutMs?: number;
|
|
60
|
-
/** Maximum total decoded bytes a single in-flight group may accumulate. */
|
|
61
|
-
readonly maxBufferBytes?: number;
|
|
62
|
-
/** Maximum decoded bytes retained across every in-flight group. */
|
|
63
|
-
readonly maxTotalBufferBytes?: number;
|
|
64
|
-
/** Maximum number of concurrent in-flight groups. */
|
|
65
|
-
readonly maxConcurrentGroups?: number;
|
|
66
|
-
/** Maximum `total` value the reassembler will accept on any chunked envelope. */
|
|
67
|
-
readonly maxSegmentsPerGroup?: number;
|
|
68
|
-
/** Clock source. Defaults to {@link Date.now}. */
|
|
69
|
-
readonly now?: () => number;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Stateful reassembler. One instance per Web PubSub subscriber connection.
|
|
73
|
-
*
|
|
74
|
-
* On `kind: "message"` {@link Reassembler.ingest} returns the inner payload
|
|
75
|
-
* immediately. On `kind: "chunk"` it returns `null` while waiting for sibling
|
|
76
|
-
* segments and the reassembled inner payload once the final segment arrives.
|
|
77
|
-
* All contract violations throw {@link ChunkingError}.
|
|
78
|
-
*/
|
|
79
|
-
export declare class Reassembler {
|
|
80
|
-
private readonly buffers;
|
|
81
|
-
private readonly timeoutMs;
|
|
82
|
-
private readonly maxBufferBytes;
|
|
83
|
-
private readonly maxTotalBufferBytes;
|
|
84
|
-
private readonly maxConcurrentGroups;
|
|
85
|
-
private readonly maxSegmentsPerGroup;
|
|
86
|
-
private readonly now;
|
|
87
|
-
private accumulatedBytes;
|
|
88
|
-
constructor(options?: ReassemblerOptions);
|
|
89
|
-
/**
|
|
90
|
-
* Process one inbound envelope. Returns the inner payload when reassembly
|
|
91
|
-
* completes (or immediately, for a `kind: "message"` envelope), `null` while
|
|
92
|
-
* waiting for sibling chunks.
|
|
93
|
-
*/
|
|
94
|
-
ingest(envelope: ChunkEnvelope): unknown;
|
|
95
|
-
/** Drop any buffer older than the configured timeout, returning dropped `group_id`s. */
|
|
96
|
-
sweepExpired(): string[];
|
|
97
|
-
/** Number of in-flight reassembly buffers. Exposed for diagnostics + tests. */
|
|
98
|
-
get inFlightGroupCount(): number;
|
|
99
|
-
/** Decoded bytes currently retained across all incomplete groups. */
|
|
100
|
-
get inFlightBytes(): number;
|
|
101
|
-
private dropBuffer;
|
|
102
|
-
}
|