maka-agent 0.2.0-dev.23.20260906 → 0.2.0-dev.24.20260907
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/dist/acp/maka-acp-agent.js +2 -1
- package/dist/acp/session-configuration.js +143 -0
- package/dist/acp/session-registry.js +90 -4
- package/dist/cli-core.js +2 -0
- package/dist/pi-transcript.js +5 -12
- package/dist/pi-tui-runner.js +74 -4
- package/dist/runtime-host-cli-context.js +167 -78
- package/dist/runtime-host-cli-installation.js +8 -2
- package/dist/runtime-host-cli.js +31 -1
- package/dist/runtime-host-handoff-surface.js +81 -0
- package/dist/runtime-host-installed-update-bootstrap.js +13 -0
- package/dist/runtime-host-installed-update-coordinator.js +33 -0
- package/dist/runtime-host-lifecycle-transaction.js +9 -1
- package/dist/runtime-host-local-handoff.js +37 -4
- package/dist/runtime-host-local-managed-activation.js +84 -0
- package/dist/runtime-host-local-source-retirement.js +18 -2
- package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
- package/dist/runtime-host-operator-retirement.js +50 -0
- package/dist/runtime-host-service-manager.js +3 -0
- package/dist/runtime-host-session-driver.js +4 -25
- package/dist/runtime-host-session-update.js +62 -0
- package/dist/runtime-host-tui-command.js +38 -73
- package/dist/runtime-host-tui-context.js +1 -0
- package/dist/runtime-host-tui-owner.js +226 -0
- package/dist/tui-copy-catalog.js +140 -3
- package/dist/tui-host-owner-copy.js +24 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
- package/node_modules/@maka/core/dist/model-failure.js +40 -0
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -4
- package/node_modules/@maka/core/dist/model-metadata.js +3 -3
- package/node_modules/@maka/core/dist/model-web-search.js +5 -4
- package/node_modules/@maka/core/dist/provider-registry.js +45 -4
- package/node_modules/@maka/core/dist/record-schema.js +9 -2
- package/node_modules/@maka/core/dist/runtime-boundary.js +31 -11
- package/node_modules/@maka/core/dist/runtime-event.js +37 -6
- package/node_modules/@maka/core/dist/runtime-handoff.js +98 -0
- package/node_modules/@maka/core/dist/runtime-invocation.js +1 -1
- package/node_modules/@maka/core/dist/runtime-logical-execution.js +112 -0
- package/node_modules/@maka/core/dist/session.js +54 -52
- package/node_modules/@maka/core/dist/slash-command-catalog.js +2 -0
- package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
- package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
- package/node_modules/@maka/core/package.json +4 -0
- package/node_modules/@maka/mcp/dist/index.js +131 -1
- package/node_modules/@maka/runtime/dist/agent-run.js +272 -105
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +13 -5
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +127 -133
- package/node_modules/@maka/runtime/dist/context-budget.js +14 -9
- package/node_modules/@maka/runtime/dist/conversation-copy.js +5 -4
- package/node_modules/@maka/runtime/dist/goal-continuation.js +36 -4
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +18 -9
- package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +30 -22
- package/node_modules/@maka/runtime/dist/history-compaction.js +29 -4
- package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +106 -0
- package/node_modules/@maka/runtime/dist/message-authority.js +9 -0
- package/node_modules/@maka/runtime/dist/model-adapter.js +19 -98
- package/node_modules/@maka/runtime/dist/model-factory.js +19 -81
- package/node_modules/@maka/runtime/dist/model-fetcher.js +7 -0
- package/node_modules/@maka/runtime/dist/model-runtime.js +85 -111
- package/node_modules/@maka/runtime/dist/native-web-search-tool.js +2 -1
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +2 -2
- package/node_modules/@maka/runtime/dist/opencode-session-header.js +4 -2
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +84 -123
- package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +68 -108
- package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +82 -54
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +117 -159
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +150 -112
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +160 -79
- package/node_modules/@maka/runtime/dist/runtime-read-model.js +30 -89
- package/node_modules/@maka/runtime/dist/runtime-resume.js +80 -4
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +5 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +171 -288
- package/node_modules/@maka/runtime/dist/session-projection-helpers.js +0 -27
- package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +3 -4
- package/node_modules/@maka/runtime/dist/test-connection.js +16 -16
- package/node_modules/@maka/runtime/dist/tool-result-archive-encoding.js +38 -0
- package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -61
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +35 -0
- package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +9 -1
- package/node_modules/@maka/runtime-host/dist/client/connection.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +156 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +273 -0
- package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +26 -5
- package/node_modules/@maka/runtime-host/dist/client/index.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/remote-compatibility-error.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +27 -5
- package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +21 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +25 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +40 -20
- package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +0 -5
- package/node_modules/@maka/runtime-host/dist/protocol/session-turns.js +29 -58
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +11 -1
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +100 -24
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +5 -5
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +40 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +96 -17
- package/node_modules/@maka/runtime-host/dist/server/host-residency-registry.js +13 -7
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-admission-registry.js +3 -1
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +124 -62
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +76 -6
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +325 -73
- package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +37 -2
- package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +45 -3
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +50 -7
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +87 -25
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +8 -55
- package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +1 -16
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +460 -70
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-maintenance.js +109 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +0 -1
- package/node_modules/@maka/storage/dist/artifact-store.js +21 -10
- package/node_modules/@maka/storage/dist/artifact-stores.js +1 -1
- package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +0 -2
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +325 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +9 -7
- package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -0
- package/node_modules/@maka/storage/dist/opencode-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/operational-state-backup.js +9 -5
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +24 -4
- package/node_modules/@maka/storage/dist/session-message-projection.js +15 -0
- package/node_modules/@maka/storage/dist/session-repository.js +767 -0
- package/node_modules/@maka/storage/dist/session-store.js +25 -99
- package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +10 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +24 -8
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +7 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +44 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +129 -25
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
- package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +111 -0
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -20,12 +20,15 @@ import { createHash } from 'node:crypto';
|
|
|
20
20
|
import { Buffer } from 'node:buffer';
|
|
21
21
|
import { stableStringify } from './request-shape.js';
|
|
22
22
|
import { findCheckpointSummaryDefect, SECTIONED_SUMMARY_FORMAT, } from './history-compact-summary-validation.js';
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
23
|
+
// v3: coverage identity and the source digest stay pinned on the RAW ledger
|
|
24
|
+
// prefix — the immutable view every creation path (standalone and mid-turn)
|
|
25
|
+
// and both match sites (pre-turn replay and the mid-turn durable projection)
|
|
26
|
+
// share — while the model-visible summary is produced from the EFFECTIVE,
|
|
27
|
+
// transition-folded prefix. A v2 checkpoint's summary could quote a Tool
|
|
28
|
+
// Result body a durable projection transition had already removed, so it is
|
|
29
|
+
// superseded on load and the session re-summarizes rather than replaying a
|
|
30
|
+
// coverage claim whose summary this policy never audited (#4845).
|
|
31
|
+
export const HISTORY_COMPACT_SOURCE_POLICY_VERSION = 'maka.compactable_runtime_event_projection.v3';
|
|
29
32
|
export function buildHistoryCompactCheckpoint(input) {
|
|
30
33
|
if (input.coveredRuntimeEvents.length === 0) {
|
|
31
34
|
throw new Error('History compact checkpoint requires covered RuntimeEvents');
|
|
@@ -81,7 +84,7 @@ export function buildHistoryCompactCheckpoint(input) {
|
|
|
81
84
|
if (anchored.turnId !== input.headAnchor.turnId ||
|
|
82
85
|
anchored.turnId !== lastCovered.turnId ||
|
|
83
86
|
anchored.role !== 'user' ||
|
|
84
|
-
anchored.author !== 'user') {
|
|
87
|
+
(anchored.author !== 'user' && anchored.author !== 'host')) {
|
|
85
88
|
throw new Error("Mid-turn history compact checkpoint head anchor must be the compacted turn's user event");
|
|
86
89
|
}
|
|
87
90
|
headAnchor = {
|
|
@@ -101,6 +104,7 @@ export function buildHistoryCompactCheckpoint(input) {
|
|
|
101
104
|
runtimeEventId: lastEvent.id,
|
|
102
105
|
},
|
|
103
106
|
sourceDigest: historyCompactSourceDigest(input.coveredRuntimeEvents),
|
|
107
|
+
effectiveSourceDigest: historyCompactSourceDigest(input.effectiveCoveredRuntimeEvents ?? input.coveredRuntimeEvents),
|
|
104
108
|
};
|
|
105
109
|
const highWaterName = input.highWaterName ?? 'history-compact-high-water';
|
|
106
110
|
const highWaterSeq = input.highWaterSeq ?? createdAt;
|
|
@@ -248,6 +252,11 @@ export function validateHistoryCompactCheckpointShape(value, sessionId) {
|
|
|
248
252
|
nonEmpty(through?.turnId) &&
|
|
249
253
|
nonEmpty(through?.runtimeEventId) &&
|
|
250
254
|
nonEmpty(coverage?.sourceDigest) &&
|
|
255
|
+
// A checkpoint minted under the current source policy pins the effective
|
|
256
|
+
// (transition-folded) view its summary or provider state describes;
|
|
257
|
+
// without the digest there is no content-currency binding at replay, so
|
|
258
|
+
// the record must not validate (#4845 review).
|
|
259
|
+
(checkpoint.source === undefined || nonEmpty(coverage?.effectiveSourceDigest)) &&
|
|
251
260
|
(checkpoint.source === undefined ||
|
|
252
261
|
validHistoryCompactCheckpointSource(checkpoint.source, checkpoint.sessionId, coverage)) &&
|
|
253
262
|
(checkpoint.phase === undefined ||
|
|
@@ -366,7 +375,7 @@ export function matchHistoryCompactCheckpointPrefix(checkpoint, events) {
|
|
|
366
375
|
anchor.turnId !== checkpoint.headAnchor.turnId ||
|
|
367
376
|
anchor.turnId !== checkpoint.coverage.through.turnId ||
|
|
368
377
|
anchor.role !== 'user' ||
|
|
369
|
-
anchor.author !== 'user') {
|
|
378
|
+
(anchor.author !== 'user' && anchor.author !== 'host')) {
|
|
370
379
|
return {
|
|
371
380
|
coveredEventCount: 0,
|
|
372
381
|
coveredRuntimeEvents: [],
|
|
@@ -473,7 +482,7 @@ function sameHistoryCompactSourceCoverage(current, candidate) {
|
|
|
473
482
|
* response's effective projection does change the digest, so a checkpoint can
|
|
474
483
|
* never be replayed over content it never covered.
|
|
475
484
|
*/
|
|
476
|
-
function historyCompactSourceDigest(events) {
|
|
485
|
+
export function historyCompactSourceDigest(events) {
|
|
477
486
|
const hash = createHash('sha256');
|
|
478
487
|
for (const event of events) {
|
|
479
488
|
const serialized = stableStringify(effectiveDigestEvent(event));
|
|
@@ -33,7 +33,12 @@ export { HistoryCompactSummarizerError } from './history-compact-error.js';
|
|
|
33
33
|
// folded events are projected with the same policy the model would see them.
|
|
34
34
|
// The format block is the validation module's template, so the mandated
|
|
35
35
|
// format and the validation can never drift apart.
|
|
36
|
-
|
|
36
|
+
// It rides as the trailing user message, never as provider instructions
|
|
37
|
+
// (system role): agentic coding models such as kimi k3-256k ignore a system
|
|
38
|
+
// prompt in this shape and keep answering the conversation instead, so the
|
|
39
|
+
// fold fails open forever (#4634), and a distinct system prompt also forfeits
|
|
40
|
+
// the prefix cache the main-loop requests built.
|
|
41
|
+
const SUMMARIZATION_PROMPT = [
|
|
37
42
|
'You are a context summarization assistant.',
|
|
38
43
|
'Read the conversation between a user and an AI assistant, then produce a structured summary another LLM will use to continue the same task.',
|
|
39
44
|
'Do NOT continue the conversation. Do NOT answer questions in it. ONLY output the structured summary.',
|
|
@@ -45,16 +50,16 @@ const SUMMARIZATION_SYSTEM_PROMPT = [
|
|
|
45
50
|
'Keep each section concise. Preserve exact file paths, function names, commands, and error messages.',
|
|
46
51
|
].join('\n');
|
|
47
52
|
const SUMMARY_REQUEST_INSTRUCTION = 'Now write the structured summary of the conversation above. Output only the summary.';
|
|
48
|
-
function
|
|
53
|
+
function shortenSummarizationPrompt() {
|
|
49
54
|
return [
|
|
50
|
-
|
|
55
|
+
SUMMARIZATION_PROMPT,
|
|
51
56
|
'',
|
|
52
57
|
'Your previous attempt was cut off at the output limit. Produce the same summary in well under half the length: keep every section, drop detail rather than sections.',
|
|
53
58
|
].join('\n');
|
|
54
59
|
}
|
|
55
|
-
function
|
|
60
|
+
function repairSummarizationPrompt(reason) {
|
|
56
61
|
return [
|
|
57
|
-
|
|
62
|
+
SUMMARIZATION_PROMPT,
|
|
58
63
|
'',
|
|
59
64
|
`A prior attempt was rejected as ${reason}.`,
|
|
60
65
|
'Produce one complete replacement summary from the source conversation.',
|
|
@@ -85,16 +90,6 @@ export function buildLlmHistorySummarizer(options) {
|
|
|
85
90
|
],
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
|
-
// The folded span usually ends on an assistant message. A chat-template
|
|
89
|
-
// model handed a conversation that already ends with its own turn emits
|
|
90
|
-
// an end-of-sequence token and nothing else (Ollama qwen2.5: finish
|
|
91
|
-
// `stop`, one output token, empty text), so the request must end with
|
|
92
|
-
// an instruction the model can answer. Hosted providers do not need the
|
|
93
|
-
// nudge and are not disturbed by it (#4559).
|
|
94
|
-
projectedMessages.push({
|
|
95
|
-
role: 'user',
|
|
96
|
-
content: [{ type: 'text', text: SUMMARY_REQUEST_INSTRUCTION }],
|
|
97
|
-
});
|
|
98
93
|
// Nothing is trimmed on a local estimate: whether this input fits the
|
|
99
94
|
// summarizer's window is its provider's answer (`input_too_large`, which
|
|
100
95
|
// the planner retreats on), and the output is capped outright (#4559).
|
|
@@ -119,8 +114,21 @@ export function buildLlmHistorySummarizer(options) {
|
|
|
119
114
|
step += 1;
|
|
120
115
|
const result = await generateText({
|
|
121
116
|
model,
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
// The instruction rides as the trailing user message rather than the
|
|
118
|
+
// AI SDK's `instructions` (system role): the request must still end
|
|
119
|
+
// with an imperative the model can answer (#4559), and no
|
|
120
|
+
// system-role prompt may precede the conversation, which agentic
|
|
121
|
+
// models ignore and which forfeits the main loop's prefix cache
|
|
122
|
+
// (#4634).
|
|
123
|
+
messages: [
|
|
124
|
+
...messages,
|
|
125
|
+
{
|
|
126
|
+
role: 'user',
|
|
127
|
+
content: [
|
|
128
|
+
{ type: 'text', text: `${instructions}\n\n${SUMMARY_REQUEST_INSTRUCTION}` },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
124
132
|
maxOutputTokens,
|
|
125
133
|
...(options.providerOptions !== undefined
|
|
126
134
|
? { providerOptions: options.providerOptions }
|
|
@@ -142,12 +150,12 @@ export function buildLlmHistorySummarizer(options) {
|
|
|
142
150
|
: findCheckpointSummaryDefect(result.text, spanUsage ? { summarizerUsage: spanUsage } : undefined);
|
|
143
151
|
return { text: result.text, defect, truncated };
|
|
144
152
|
};
|
|
145
|
-
let initial = await generateSummary(
|
|
153
|
+
let initial = await generateSummary(SUMMARIZATION_PROMPT, projectedMessages);
|
|
146
154
|
if (initial.truncated) {
|
|
147
155
|
// The provider cut the summary at the output cap. One shorter attempt;
|
|
148
156
|
// a second cut is the provider saying this span will not summarize
|
|
149
157
|
// inside the cap, and the fold fails open.
|
|
150
|
-
initial = await generateSummary(
|
|
158
|
+
initial = await generateSummary(shortenSummarizationPrompt(), projectedMessages);
|
|
151
159
|
if (initial.truncated)
|
|
152
160
|
throw new HistoryCompactSummarizerError('output_length');
|
|
153
161
|
}
|
|
@@ -159,7 +167,7 @@ export function buildLlmHistorySummarizer(options) {
|
|
|
159
167
|
// A malformed provider completion is often repairable, but retries must
|
|
160
168
|
// be bounded: one stricter attempt, then the caller's failure circuit
|
|
161
169
|
// records the stable defect for this compaction input.
|
|
162
|
-
const repairInstructions =
|
|
170
|
+
const repairInstructions = repairSummarizationPrompt(initial.defect);
|
|
163
171
|
let repaired;
|
|
164
172
|
try {
|
|
165
173
|
repaired = await generateSummary(repairInstructions, projectedMessages);
|
|
@@ -173,7 +181,7 @@ export function buildLlmHistorySummarizer(options) {
|
|
|
173
181
|
// the fold past the summarizer provider's window, the rejection is the
|
|
174
182
|
// planner's retreat signal, not a repair failure to file under the
|
|
175
183
|
// initial defect (#4559).
|
|
176
|
-
if (classifyError(error) === '
|
|
184
|
+
if (classifyError(error) === 'context_overflow') {
|
|
177
185
|
throw new HistoryCompactSummarizerError('input_too_large', { cause: error });
|
|
178
186
|
}
|
|
179
187
|
throw new HistoryCompactSummarizerError(initial.defect, {
|
|
@@ -202,7 +210,7 @@ export function buildLlmHistorySummarizer(options) {
|
|
|
202
210
|
// The summarizer's provider is the one judge of whether this fold fits
|
|
203
211
|
// its own window: a context-length rejection is the signal the planner
|
|
204
212
|
// retreats on, so it must keep its name here (#4559).
|
|
205
|
-
if (classifyError(error) === '
|
|
213
|
+
if (classifyError(error) === 'context_overflow') {
|
|
206
214
|
throw new HistoryCompactSummarizerError('input_too_large', { cause: error });
|
|
207
215
|
}
|
|
208
216
|
throw new HistoryCompactSummarizerError('provider_error', { cause: error });
|
|
@@ -20,7 +20,7 @@ import { estimateRuntimeEventChars, estimateRuntimeEventsTokens } from './model-
|
|
|
20
20
|
import { compactionDecisionDiagnosticPatch } from './compaction-boundary.js';
|
|
21
21
|
import { HistoryCompactSummarizerError, } from './history-compact-error.js';
|
|
22
22
|
import { findCheckpointSummaryDefect } from './history-compact-summary-validation.js';
|
|
23
|
-
import { buildHistoryCompactCheckpoint, historyCompactCheckpointToRuntimeEvent, matchHistoryCompactCheckpointPrefix, projectHistoryCompactCheckpointReplay, } from './history-compact-checkpoint.js';
|
|
23
|
+
import { buildHistoryCompactCheckpoint, historyCompactCheckpointToRuntimeEvent, historyCompactSourceDigest, matchHistoryCompactCheckpointPrefix, projectHistoryCompactCheckpointReplay, } from './history-compact-checkpoint.js';
|
|
24
24
|
/**
|
|
25
25
|
* Select the largest contiguous covered prefix that is safe to fold:
|
|
26
26
|
*
|
|
@@ -177,15 +177,39 @@ export async function planHistoryCompaction(input) {
|
|
|
177
177
|
const checkpointMatch = input.previousCheckpoint
|
|
178
178
|
? matchHistoryCompactCheckpointPrefix(input.previousCheckpoint, coveredRuntimeEvents)
|
|
179
179
|
: undefined;
|
|
180
|
-
|
|
180
|
+
let previousCheckpoint = checkpointMatch && !checkpointMatch.reason ? input.previousCheckpoint : undefined;
|
|
181
|
+
// Content-currency gate for roll-forward: the inherited summary or
|
|
182
|
+
// provider state describes the EFFECTIVE view of the previous coverage at
|
|
183
|
+
// its own creation. A projection transition committed since rewrites that
|
|
184
|
+
// view without touching the raw prefix, and reusing the stale content here
|
|
185
|
+
// would launder it into the new checkpoint under the current effective
|
|
186
|
+
// digest — later replay guards would then pass it (#4845 review). On
|
|
187
|
+
// drift, discard the checkpoint and re-summarize the whole effective span.
|
|
188
|
+
if (previousCheckpoint && checkpointMatch && input.projectEffectiveCoverage) {
|
|
189
|
+
const pinned = previousCheckpoint.coverage.effectiveSourceDigest;
|
|
190
|
+
const previousEffectiveCovered = await input.projectEffectiveCoverage(checkpointMatch.coveredRuntimeEvents);
|
|
191
|
+
if (pinned === undefined || historyCompactSourceDigest(previousEffectiveCovered) !== pinned) {
|
|
192
|
+
previousCheckpoint = undefined;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
181
195
|
const newlyFoldedRuntimeEvents = previousCheckpoint
|
|
182
196
|
? checkpointMatch.successorRuntimeEvents
|
|
183
197
|
: coveredRuntimeEvents;
|
|
198
|
+
// The model-visible summary reads the effective (transition-folded) view
|
|
199
|
+
// of the covered span; the raw events keep the coverage identity.
|
|
200
|
+
const effectiveCoveredRuntimeEvents = input.projectEffectiveCoverage
|
|
201
|
+
? [...(await input.projectEffectiveCoverage(coveredRuntimeEvents))]
|
|
202
|
+
: undefined;
|
|
203
|
+
const effectiveNewlyFoldedRuntimeEvents = effectiveCoveredRuntimeEvents
|
|
204
|
+
? newlyFoldedRuntimeEvents.length === coveredRuntimeEvents.length
|
|
205
|
+
? effectiveCoveredRuntimeEvents
|
|
206
|
+
: effectiveCoveredRuntimeEvents.slice(effectiveCoveredRuntimeEvents.length - newlyFoldedRuntimeEvents.length)
|
|
207
|
+
: undefined;
|
|
184
208
|
let compacted;
|
|
185
209
|
try {
|
|
186
210
|
compacted = await Promise.resolve(input.summarize({
|
|
187
|
-
coveredRuntimeEvents,
|
|
188
|
-
newlyFoldedRuntimeEvents,
|
|
211
|
+
coveredRuntimeEvents: effectiveCoveredRuntimeEvents ?? coveredRuntimeEvents,
|
|
212
|
+
newlyFoldedRuntimeEvents: effectiveNewlyFoldedRuntimeEvents ?? newlyFoldedRuntimeEvents,
|
|
189
213
|
...(previousCheckpoint ? { previousCheckpoint } : {}),
|
|
190
214
|
}));
|
|
191
215
|
if (typeof compacted === 'string')
|
|
@@ -240,6 +264,7 @@ export async function planHistoryCompaction(input) {
|
|
|
240
264
|
const checkpoint = buildHistoryCompactCheckpoint({
|
|
241
265
|
sessionId: input.sessionId,
|
|
242
266
|
coveredRuntimeEvents,
|
|
267
|
+
...(effectiveCoveredRuntimeEvents ? { effectiveCoveredRuntimeEvents } : {}),
|
|
243
268
|
...(typeof compacted === 'string' ? { summary: compacted } : { providerState: compacted }),
|
|
244
269
|
...(phase === 'mid_turn'
|
|
245
270
|
? { phase: 'mid_turn', headAnchor: input.headAnchor }
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { createHash } from 'node:crypto';
|
|
20
|
+
import { decodeDurableToolResultProjection } from '@maka/core/durable-tool-result-projection';
|
|
21
|
+
import { decodeLedgerTransition, reduceEffectiveModelProjections, } from './model-projection-transition-ledger.js';
|
|
22
|
+
import { isArchivedToolResultPlaceholder, } from './tool-result-archive.js';
|
|
23
|
+
import { serializeToolResultProjectionV1 } from './tool-result-archive-encoding.js';
|
|
24
|
+
/**
|
|
25
|
+
* Read-only v1 reconstruction. It never calls a live tool projector, reads an
|
|
26
|
+
* Artifact, changes history, or authorizes access from a hash alone.
|
|
27
|
+
* The evidence port is trusted to return the complete bounded target history.
|
|
28
|
+
*/
|
|
29
|
+
export function createLedgerToolResultArchiveReader(evidence) {
|
|
30
|
+
return async (input) => {
|
|
31
|
+
const request = { ...input };
|
|
32
|
+
if (!isArchivedToolResultPlaceholder(request) ||
|
|
33
|
+
!/^[a-f0-9]{64}$/.test(request.bodySha256) ||
|
|
34
|
+
!Number.isSafeInteger(request.originalBytes) ||
|
|
35
|
+
request.originalBytes < 1) {
|
|
36
|
+
return { ok: false, reason: 'corrupt' };
|
|
37
|
+
}
|
|
38
|
+
const maxBytes = request.maxBytes ?? request.originalBytes;
|
|
39
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < request.originalBytes)
|
|
40
|
+
return { ok: false, reason: 'too_large' };
|
|
41
|
+
try {
|
|
42
|
+
const loaded = await evidence.read({
|
|
43
|
+
sessionId: request.sessionId,
|
|
44
|
+
runtimeEventId: request.runtimeEventId,
|
|
45
|
+
});
|
|
46
|
+
if (!loaded.ok)
|
|
47
|
+
return {
|
|
48
|
+
ok: false,
|
|
49
|
+
reason: loaded.reason === 'unavailable' ? 'read_failed' : loaded.reason,
|
|
50
|
+
};
|
|
51
|
+
const { event } = loaded;
|
|
52
|
+
const content = event.content;
|
|
53
|
+
if (event.sessionId !== request.sessionId)
|
|
54
|
+
return { ok: false, reason: 'session_mismatch' };
|
|
55
|
+
if (event.id !== request.runtimeEventId ||
|
|
56
|
+
content?.kind !== 'function_response' ||
|
|
57
|
+
content.id !== request.toolCallId ||
|
|
58
|
+
content.name !== request.toolName ||
|
|
59
|
+
content.providerExecuted ||
|
|
60
|
+
!content.modelProjection)
|
|
61
|
+
return { ok: false, reason: 'source_mismatch' };
|
|
62
|
+
let source = decodeDurableToolResultProjection(content.modelProjection);
|
|
63
|
+
const byId = new Map();
|
|
64
|
+
for (const record of loaded.transitions) {
|
|
65
|
+
const transition = decodeLedgerTransition(record, request.sessionId);
|
|
66
|
+
if (!transition ||
|
|
67
|
+
record.sessionId !== request.sessionId ||
|
|
68
|
+
transition.target.runtimeEventId !== event.id)
|
|
69
|
+
return { ok: false, reason: 'corrupt' };
|
|
70
|
+
const previous = byId.get(transition.transitionId);
|
|
71
|
+
if (previous &&
|
|
72
|
+
JSON.stringify({ ...previous, createdAt: 0 }) !==
|
|
73
|
+
JSON.stringify({ ...transition, createdAt: 0 })) {
|
|
74
|
+
return { ok: false, reason: 'corrupt' };
|
|
75
|
+
}
|
|
76
|
+
byId.set(transition.transitionId, transition);
|
|
77
|
+
}
|
|
78
|
+
const reduction = reduceEffectiveModelProjections([event], [...byId.values()]);
|
|
79
|
+
for (const transition of reduction.applied) {
|
|
80
|
+
const replacement = transition.replacement;
|
|
81
|
+
const placeholder = replacement.kind === 'json' ? replacement.value : undefined;
|
|
82
|
+
if (isArchivedToolResultPlaceholder(placeholder) &&
|
|
83
|
+
placeholder.artifactId === request.artifactId) {
|
|
84
|
+
if (placeholder.runtimeEventId !== request.runtimeEventId ||
|
|
85
|
+
placeholder.toolCallId !== request.toolCallId ||
|
|
86
|
+
placeholder.toolName !== request.toolName ||
|
|
87
|
+
placeholder.bodySha256 !== request.bodySha256 ||
|
|
88
|
+
placeholder.originalBytes !== request.originalBytes ||
|
|
89
|
+
placeholder.rewriteVersion !== request.rewriteVersion)
|
|
90
|
+
return { ok: false, reason: 'source_mismatch' };
|
|
91
|
+
const serializedResult = serializeToolResultProjectionV1(source);
|
|
92
|
+
if (Buffer.byteLength(serializedResult, 'utf8') !== request.originalBytes)
|
|
93
|
+
return { ok: false, reason: 'size_mismatch' };
|
|
94
|
+
if (createHash('sha256').update(serializedResult).digest('hex') !== request.bodySha256)
|
|
95
|
+
return { ok: false, reason: 'corrupt' };
|
|
96
|
+
return { ok: true, serializedResult };
|
|
97
|
+
}
|
|
98
|
+
source = transition.replacement;
|
|
99
|
+
}
|
|
100
|
+
return { ok: false, reason: 'not_found' };
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return { ok: false, reason: 'corrupt' };
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -28,6 +28,15 @@ export function isRuntimeHostedRootAuthority(authority) {
|
|
|
28
28
|
export class RuntimeMessageAuthorityInvariantError extends Error {
|
|
29
29
|
name = 'RuntimeMessageAuthorityInvariantError';
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The id a Root Turn's admitted prompt is durable under. A Root folded from
|
|
33
|
+
* several queued Messages carries no single Message identity, so the id comes
|
|
34
|
+
* from the Run instead — one rule, so the run that writes the prompt and the
|
|
35
|
+
* recovery that rewrites it derive the same id and the store dedupes.
|
|
36
|
+
*/
|
|
37
|
+
export function admittedPromptEventId(runId, userMessageId) {
|
|
38
|
+
return userMessageId ?? `${runId}-admitted-prompt`;
|
|
39
|
+
}
|
|
31
40
|
export class RuntimeHostedRootConflictError extends Error {
|
|
32
41
|
name = 'RuntimeHostedRootConflictError';
|
|
33
42
|
code = 'session_busy';
|
|
@@ -20,11 +20,11 @@ import { openai } from '@ai-sdk/openai';
|
|
|
20
20
|
import { anthropic } from '@ai-sdk/anthropic';
|
|
21
21
|
import { providerAuthRequiresSecret, } from '@maka/core/llm-connections';
|
|
22
22
|
import { lookupModelMetadata } from '@maka/core/model-metadata';
|
|
23
|
-
import { generalizedErrorMessage } from '@maka/core/redaction';
|
|
24
23
|
import { rawFinishReasonString } from './model-protocol.js';
|
|
25
24
|
import { resolveModelRuntime } from './model-runtime.js';
|
|
26
25
|
import { plaintextResponsesReasoningProviderOptions, safePlaintextResponsesReasoningItemId, } from './responses-reasoning-state.js';
|
|
27
|
-
import { classifyError,
|
|
26
|
+
import { classifyError, providerModelFailure } from './provider-error-classification.js';
|
|
27
|
+
import { withProviderStreamTracking, } from './provider-request-telemetry.js';
|
|
28
28
|
import { createOpenAiChatReasoningTransportState, openAiChatReasoningFieldProviderOptions, restoreOpenAiChatEmptyReasoning, } from './openai-chat-reasoning-transport.js';
|
|
29
29
|
import { mergeOpenAiResponsesProviderOptions, planOpenAiResponsesContinuation, } from './openai-responses-continuation.js';
|
|
30
30
|
import { createOpenAiResponsesTransportState, OPENAI_RESPONSES_LANE_HEADER, } from './openai-responses-websocket.js';
|
|
@@ -37,7 +37,7 @@ export class ModelAdapter {
|
|
|
37
37
|
openAiResponsesTransportState;
|
|
38
38
|
constructor(input) {
|
|
39
39
|
this.input = input;
|
|
40
|
-
this.runtime = resolveModelRuntime(input.connection, input.modelId);
|
|
40
|
+
this.runtime = input.resolvedRuntime ?? resolveModelRuntime(input.connection, input.modelId);
|
|
41
41
|
this.openAiChatReasoningTransportState = createOpenAiChatReasoningTransportState(this.runtime.reasoningReplay.kind === 'openai-chat-plaintext'
|
|
42
42
|
? this.runtime.reasoningReplay.requestField
|
|
43
43
|
: 'observed');
|
|
@@ -102,20 +102,14 @@ export class ModelAdapter {
|
|
|
102
102
|
const { streamText, wrapLanguageModel } = ai;
|
|
103
103
|
const maxOutputTokens = selectedModelMaxOutputTokens(this.input.connection, this.input.modelId, this.input.providerOptions, this.runtime);
|
|
104
104
|
const trackedModel = input.providerRequestTracker
|
|
105
|
-
?
|
|
105
|
+
? withProviderStreamTracking({
|
|
106
106
|
model: input.model,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
doStream,
|
|
114
|
-
...(input.historyCompactBoundary
|
|
115
|
-
? { historyCompactBoundary: input.historyCompactBoundary }
|
|
116
|
-
: {}),
|
|
117
|
-
}),
|
|
118
|
-
},
|
|
107
|
+
wrapLanguageModel,
|
|
108
|
+
tracker: input.providerRequestTracker,
|
|
109
|
+
abortSignal: input.abortSignal,
|
|
110
|
+
...(input.historyCompactBoundary
|
|
111
|
+
? { historyCompactBoundary: input.historyCompactBoundary }
|
|
112
|
+
: {}),
|
|
119
113
|
})
|
|
120
114
|
: input.model;
|
|
121
115
|
const usesOpenAiResponsesAdapter = hasOpenAiResponsesAdapter(this.runtime);
|
|
@@ -345,7 +339,7 @@ export class ModelAdapter {
|
|
|
345
339
|
: undefined, this.runtime);
|
|
346
340
|
}
|
|
347
341
|
makeErrorEvent(turnId, err, reasonOverride) {
|
|
348
|
-
const failure =
|
|
342
|
+
const failure = normalizeProviderFailure(err);
|
|
349
343
|
return {
|
|
350
344
|
type: 'error',
|
|
351
345
|
id: this.input.newId(),
|
|
@@ -355,7 +349,7 @@ export class ModelAdapter {
|
|
|
355
349
|
...(failure.code !== undefined ? { code: failure.code } : {}),
|
|
356
350
|
...(reasonOverride !== undefined
|
|
357
351
|
? { reason: reasonOverride }
|
|
358
|
-
: failure.kind !== 'abort'
|
|
352
|
+
: failure.kind !== 'abort'
|
|
359
353
|
? { reason: failure.kind }
|
|
360
354
|
: {}),
|
|
361
355
|
message: failure.message,
|
|
@@ -366,7 +360,7 @@ export class ModelAdapter {
|
|
|
366
360
|
}
|
|
367
361
|
classifyError(error) {
|
|
368
362
|
if (isModelFailure(error))
|
|
369
|
-
return
|
|
363
|
+
return error.kind;
|
|
370
364
|
return classifyError(error);
|
|
371
365
|
}
|
|
372
366
|
/** Map a successfully settled provider step to its runtime stop reason. */
|
|
@@ -386,19 +380,20 @@ export class ModelAdapter {
|
|
|
386
380
|
export function settleModelStepOutcome(evidence) {
|
|
387
381
|
const { aborted, failure, sawFinish, finishReason, rawFinishReason, usage, request } = evidence;
|
|
388
382
|
if (aborted || failure?.kind === 'abort') {
|
|
389
|
-
return failedStepOutcome('aborted', failure ??
|
|
383
|
+
return failedStepOutcome('aborted', failure ??
|
|
384
|
+
normalizeProviderFailure(Object.assign(new Error('aborted'), { name: 'AbortError' })), request, usage);
|
|
390
385
|
}
|
|
391
386
|
if (failure) {
|
|
392
|
-
return failedStepOutcome(
|
|
387
|
+
return failedStepOutcome('failed', failure, request, usage);
|
|
393
388
|
}
|
|
394
389
|
if (!sawFinish || finishReason === 'other' || finishReason === 'unknown') {
|
|
395
|
-
return failedStepOutcome('truncated', modelStepFailure('
|
|
390
|
+
return failedStepOutcome('truncated', modelStepFailure('stream_truncated', `Provider stream ended without finishing (${finishReason})`), request, usage);
|
|
396
391
|
}
|
|
397
392
|
if (finishReason === 'content-filter' || finishReason === 'error') {
|
|
398
393
|
const terminalFailure = finishReason === 'error'
|
|
399
394
|
? providerFinishFailure(rawFinishReason)
|
|
400
395
|
: modelStepFailure('unknown', 'Provider stopped the stream on a content filter');
|
|
401
|
-
return failedStepOutcome(
|
|
396
|
+
return failedStepOutcome('failed', terminalFailure, request, usage);
|
|
402
397
|
}
|
|
403
398
|
return {
|
|
404
399
|
kind: 'completed',
|
|
@@ -888,34 +883,8 @@ function compileProviderTool(tool) {
|
|
|
888
883
|
});
|
|
889
884
|
}
|
|
890
885
|
}
|
|
891
|
-
function normalizeModelFailure(error) {
|
|
892
|
-
if (isModelFailure(error))
|
|
893
|
-
return error;
|
|
894
|
-
const errorClass = classifyError(error);
|
|
895
|
-
const presentation = errorPresentationFromClass(errorClass);
|
|
896
|
-
const retry = providerRetryMetadata(error);
|
|
897
|
-
const code = error instanceof Error && 'code' in error
|
|
898
|
-
? String(error.code)
|
|
899
|
-
: undefined;
|
|
900
|
-
return {
|
|
901
|
-
type: 'model_failure',
|
|
902
|
-
kind: modelFailureKind(errorClass),
|
|
903
|
-
retryable: retry.retryable,
|
|
904
|
-
...(retry.retryAfterMs !== undefined ? { retryAfterMs: retry.retryAfterMs } : {}),
|
|
905
|
-
...(code !== undefined ? { code } : {}),
|
|
906
|
-
message: presentation.message ?? generalizedErrorMessage(error),
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
886
|
function normalizeProviderFailure(error) {
|
|
910
|
-
|
|
911
|
-
return error;
|
|
912
|
-
const summary = providerFailureSummary(error);
|
|
913
|
-
const failure = normalizeModelFailure(error);
|
|
914
|
-
return {
|
|
915
|
-
...failure,
|
|
916
|
-
...(summary?.code !== undefined ? { code: summary.code } : {}),
|
|
917
|
-
...(failure.kind === 'unknown' && summary !== undefined ? { message: summary.message } : {}),
|
|
918
|
-
};
|
|
887
|
+
return isModelFailure(error) ? error : providerModelFailure(error);
|
|
919
888
|
}
|
|
920
889
|
function isModelFailure(value) {
|
|
921
890
|
return (typeof value === 'object' &&
|
|
@@ -924,54 +893,6 @@ function isModelFailure(value) {
|
|
|
924
893
|
typeof value.kind === 'string' &&
|
|
925
894
|
typeof value.message === 'string');
|
|
926
895
|
}
|
|
927
|
-
function modelFailureKind(errorClass) {
|
|
928
|
-
switch (errorClass) {
|
|
929
|
-
case 'Abort':
|
|
930
|
-
return 'abort';
|
|
931
|
-
case 'Auth':
|
|
932
|
-
return 'auth';
|
|
933
|
-
case 'ContextLength':
|
|
934
|
-
return 'context_overflow';
|
|
935
|
-
case 'Network':
|
|
936
|
-
return 'network';
|
|
937
|
-
case 'ProviderBilling':
|
|
938
|
-
return 'provider_billing';
|
|
939
|
-
case 'ProviderCapacity':
|
|
940
|
-
return 'provider_capacity';
|
|
941
|
-
case 'ProviderUnavailable':
|
|
942
|
-
return 'provider_unavailable';
|
|
943
|
-
case 'RateLimit':
|
|
944
|
-
return 'rate_limit';
|
|
945
|
-
case 'Timeout':
|
|
946
|
-
return 'timeout';
|
|
947
|
-
default:
|
|
948
|
-
return 'unknown';
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
function errorClassFromFailureKind(kind) {
|
|
952
|
-
switch (kind) {
|
|
953
|
-
case 'abort':
|
|
954
|
-
return 'Abort';
|
|
955
|
-
case 'auth':
|
|
956
|
-
return 'Auth';
|
|
957
|
-
case 'context_overflow':
|
|
958
|
-
return 'ContextLength';
|
|
959
|
-
case 'network':
|
|
960
|
-
return 'Network';
|
|
961
|
-
case 'provider_billing':
|
|
962
|
-
return 'ProviderBilling';
|
|
963
|
-
case 'provider_capacity':
|
|
964
|
-
return 'ProviderCapacity';
|
|
965
|
-
case 'provider_unavailable':
|
|
966
|
-
return 'ProviderUnavailable';
|
|
967
|
-
case 'rate_limit':
|
|
968
|
-
return 'RateLimit';
|
|
969
|
-
case 'timeout':
|
|
970
|
-
return 'Timeout';
|
|
971
|
-
case 'unknown':
|
|
972
|
-
return 'Other';
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
896
|
export function normalizeAiSdkUsage(usage, options = {}) {
|
|
976
897
|
if (!usage)
|
|
977
898
|
return undefined;
|