@rynfar/meridian 1.62.3 → 1.62.4
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/{cli-3ysfatce.js → cli-n1jsth00.js} +235 -159
- package/dist/cli.js +1 -1
- package/dist/proxy/messages.d.ts +0 -28
- package/dist/proxy/messages.d.ts.map +1 -1
- package/dist/proxy/passthroughEarlyStop.d.ts +45 -42
- package/dist/proxy/passthroughEarlyStop.d.ts.map +1 -1
- package/dist/proxy/query.d.ts +3 -2
- package/dist/proxy/query.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/proxy/session/cache.d.ts +1 -1
- package/dist/proxy/session/cache.d.ts.map +1 -1
- package/dist/proxy/session/lineage.d.ts +12 -2
- package/dist/proxy/session/lineage.d.ts.map +1 -1
- package/dist/proxy/sessionStore.d.ts +6 -3
- package/dist/proxy/sessionStore.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
|
@@ -1974,13 +1974,6 @@ ${history}
|
|
|
1974
1974
|
|
|
1975
1975
|
` + last.text;
|
|
1976
1976
|
}
|
|
1977
|
-
function framePassthroughContinuation(delta) {
|
|
1978
|
-
if (!delta)
|
|
1979
|
-
return delta;
|
|
1980
|
-
return `${PASSTHROUGH_CONTINUATION_LEAD_IN}
|
|
1981
|
-
|
|
1982
|
-
${delta}`;
|
|
1983
|
-
}
|
|
1984
1977
|
function stripNonStandardStreamFields(event) {
|
|
1985
1978
|
if (event && typeof event === "object") {
|
|
1986
1979
|
const e = event;
|
|
@@ -2119,7 +2112,7 @@ function extractSystemText(system) {
|
|
|
2119
2112
|
return system.filter((b) => b?.type === "text" && typeof b.text === "string" && b.text).map((b) => b.text).filter((text) => !TRANSPORT_HEADER_BLOCK.test(text)).join(`
|
|
2120
2113
|
`);
|
|
2121
2114
|
}
|
|
2122
|
-
var HASH_IGNORED_BLOCK_TYPES, HASH_HANDLED_BLOCK_TYPES, HASH_SERIALIZED_BLOCK_TYPES,
|
|
2115
|
+
var HASH_IGNORED_BLOCK_TYPES, HASH_HANDLED_BLOCK_TYPES, HASH_SERIALIZED_BLOCK_TYPES, MULTIMODAL_TYPES, TOOL_TARGET_KEYS, TOOL_TARGET_MAX = 80, CONTENT_SUMMARY_MAX = 120, TRANSPORT_HEADER_BLOCK;
|
|
2123
2116
|
var init_messages = __esm(() => {
|
|
2124
2117
|
HASH_IGNORED_BLOCK_TYPES = new Set(["thinking", "redacted_thinking"]);
|
|
2125
2118
|
HASH_HANDLED_BLOCK_TYPES = new Set(["text", "tool_use", "tool_result"]);
|
|
@@ -2136,7 +2129,6 @@ var init_messages = __esm(() => {
|
|
|
2136
2129
|
"tool_search_tool_result",
|
|
2137
2130
|
"container_upload"
|
|
2138
2131
|
]);
|
|
2139
|
-
PASSTHROUGH_CONTINUATION_LEAD_IN = "The tool calls from your previous turn were forwarded to the client, which has now executed them — " + "their results follow. The instruction to end that turn without further text applied to it alone and " + "is now discharged: continue the work and respond.";
|
|
2140
2132
|
MULTIMODAL_TYPES = new Set(["image", "document", "file"]);
|
|
2141
2133
|
TOOL_TARGET_KEYS = ["filePath", "file_path", "path", "command", "code", "pattern", "query", "url"];
|
|
2142
2134
|
TRANSPORT_HEADER_BLOCK = /^\s*x-anthropic-[a-z0-9-]*header\s*:/i;
|
|
@@ -11111,6 +11103,17 @@ function noteAssistantContent(tracker, content) {
|
|
|
11111
11103
|
}
|
|
11112
11104
|
}
|
|
11113
11105
|
}
|
|
11106
|
+
function noteAssistantMessage(tracker, message) {
|
|
11107
|
+
const m = message;
|
|
11108
|
+
if (m?.type !== "assistant")
|
|
11109
|
+
return;
|
|
11110
|
+
const content = m.message?.content;
|
|
11111
|
+
const before = tracker.expected.size;
|
|
11112
|
+
noteAssistantContent(tracker, content);
|
|
11113
|
+
if (tracker.expected.size > before) {
|
|
11114
|
+
tracker.toolCallAssistantUuid = typeof m.uuid === "string" && m.uuid.length > 0 ? m.uuid : undefined;
|
|
11115
|
+
}
|
|
11116
|
+
}
|
|
11114
11117
|
function noteUserContent(tracker, content) {
|
|
11115
11118
|
if (!Array.isArray(content))
|
|
11116
11119
|
return;
|
|
@@ -11121,43 +11124,69 @@ function noteUserContent(tracker, content) {
|
|
|
11121
11124
|
}
|
|
11122
11125
|
}
|
|
11123
11126
|
}
|
|
11124
|
-
function
|
|
11125
|
-
if (tracker.fired)
|
|
11126
|
-
return false;
|
|
11127
|
+
function allForwardedCallsResolved(tracker) {
|
|
11127
11128
|
if (tracker.expected.size === 0)
|
|
11128
11129
|
return false;
|
|
11129
11130
|
for (const id of tracker.expected) {
|
|
11130
11131
|
if (!tracker.resolved.has(id))
|
|
11131
11132
|
return false;
|
|
11132
11133
|
}
|
|
11134
|
+
return true;
|
|
11135
|
+
}
|
|
11136
|
+
function isCompleteToolResultContinuation(messages, expectedIds) {
|
|
11137
|
+
if (expectedIds.length === 0 || messages.length === 0)
|
|
11138
|
+
return false;
|
|
11139
|
+
const expected = new Set(expectedIds);
|
|
11140
|
+
const actual = new Set;
|
|
11141
|
+
const echoedCalls = new Set;
|
|
11142
|
+
let sawUser = false;
|
|
11143
|
+
let sawNonToolResult = false;
|
|
11144
|
+
for (const message of messages) {
|
|
11145
|
+
if (message.role === "assistant" && !sawUser) {
|
|
11146
|
+
if (Array.isArray(message.content)) {
|
|
11147
|
+
for (const rawBlock of message.content) {
|
|
11148
|
+
const block = rawBlock;
|
|
11149
|
+
if (block?.type !== "tool_use")
|
|
11150
|
+
continue;
|
|
11151
|
+
if (typeof block.id !== "string" || !expected.has(block.id) || echoedCalls.has(block.id))
|
|
11152
|
+
return false;
|
|
11153
|
+
echoedCalls.add(block.id);
|
|
11154
|
+
}
|
|
11155
|
+
}
|
|
11156
|
+
continue;
|
|
11157
|
+
}
|
|
11158
|
+
if (message.role !== "user" || !Array.isArray(message.content) || sawUser)
|
|
11159
|
+
return false;
|
|
11160
|
+
sawUser = true;
|
|
11161
|
+
for (const rawBlock of message.content) {
|
|
11162
|
+
const block = rawBlock;
|
|
11163
|
+
if (block?.type === "tool_result") {
|
|
11164
|
+
if (sawNonToolResult || typeof block.tool_use_id !== "string")
|
|
11165
|
+
return false;
|
|
11166
|
+
if (!expected.has(block.tool_use_id) || actual.has(block.tool_use_id))
|
|
11167
|
+
return false;
|
|
11168
|
+
actual.add(block.tool_use_id);
|
|
11169
|
+
} else {
|
|
11170
|
+
sawNonToolResult = true;
|
|
11171
|
+
}
|
|
11172
|
+
}
|
|
11173
|
+
}
|
|
11174
|
+
return actual.size === expected.size && (echoedCalls.size === 0 || echoedCalls.size === expected.size);
|
|
11175
|
+
}
|
|
11176
|
+
function settledToolCallAssistantUuid(tracker) {
|
|
11177
|
+
return allForwardedCallsResolved(tracker) ? tracker.toolCallAssistantUuid : undefined;
|
|
11178
|
+
}
|
|
11179
|
+
function shouldEarlyStop(tracker) {
|
|
11180
|
+
if (tracker.fired || !settledToolCallAssistantUuid(tracker))
|
|
11181
|
+
return false;
|
|
11133
11182
|
tracker.fired = true;
|
|
11134
11183
|
return true;
|
|
11135
11184
|
}
|
|
11136
11185
|
function clientAbortDisposition(input) {
|
|
11137
11186
|
if (input.isIndependentSession || !input.profileSessionId)
|
|
11138
11187
|
return { action: "none" };
|
|
11139
|
-
if (!input.passthrough)
|
|
11140
|
-
return { action: "evict" };
|
|
11141
|
-
if (input.currentSessionId && !input.sawDuplicateToolUse && input.resumeBoundaryUuid) {
|
|
11142
|
-
return { action: "store", resumeUuid: input.resumeBoundaryUuid };
|
|
11143
|
-
}
|
|
11144
11188
|
return { action: "evict" };
|
|
11145
11189
|
}
|
|
11146
|
-
function resumeBoundaryUuid(message) {
|
|
11147
|
-
const m = message;
|
|
11148
|
-
if (m?.type !== "user")
|
|
11149
|
-
return;
|
|
11150
|
-
if (typeof m.uuid !== "string" || m.uuid.length === 0)
|
|
11151
|
-
return;
|
|
11152
|
-
const content = m.message?.content;
|
|
11153
|
-
if (!Array.isArray(content))
|
|
11154
|
-
return;
|
|
11155
|
-
const hasResult = content.some((block) => {
|
|
11156
|
-
const b = block;
|
|
11157
|
-
return b?.type === "tool_result";
|
|
11158
|
-
});
|
|
11159
|
-
return hasResult ? m.uuid : undefined;
|
|
11160
|
-
}
|
|
11161
11190
|
|
|
11162
11191
|
// src/proxy/envelopeIntegrity.ts
|
|
11163
11192
|
function checkEmptyToolInputs(contentBlocks, tools) {
|
|
@@ -20032,6 +20061,13 @@ function normalizeContextUsage(usage) {
|
|
|
20032
20061
|
return lastIteration ?? usage;
|
|
20033
20062
|
}
|
|
20034
20063
|
var MIN_SUFFIX_FOR_COMPACTION = 2;
|
|
20064
|
+
function withClientAssistantUuid(existing, clientMessageCount, uuid) {
|
|
20065
|
+
const next = existing.slice(0, clientMessageCount + 1);
|
|
20066
|
+
while (next.length < clientMessageCount)
|
|
20067
|
+
next.push(null);
|
|
20068
|
+
next[clientMessageCount] = typeof uuid === "string" && uuid.length > 0 ? uuid : null;
|
|
20069
|
+
return next;
|
|
20070
|
+
}
|
|
20035
20071
|
function computeLineageHash(messages) {
|
|
20036
20072
|
if (!messages || messages.length === 0)
|
|
20037
20073
|
return "";
|
|
@@ -20347,15 +20383,20 @@ function writeStore(store) {
|
|
|
20347
20383
|
}
|
|
20348
20384
|
}
|
|
20349
20385
|
}
|
|
20386
|
+
function hasLegacyUserDenialBoundary(session) {
|
|
20387
|
+
const legacy = session.passthroughResumeUuid;
|
|
20388
|
+
return typeof legacy === "string" && legacy.length > 0 && !session.passthroughToolCallAssistantUuid;
|
|
20389
|
+
}
|
|
20350
20390
|
function lookupSharedSession(key) {
|
|
20351
20391
|
const store = readStore();
|
|
20352
|
-
|
|
20392
|
+
const session = store[key];
|
|
20393
|
+
return session && !hasLegacyUserDenialBoundary(session) ? session : undefined;
|
|
20353
20394
|
}
|
|
20354
20395
|
function lookupSharedSessionByClaudeId(claudeSessionId) {
|
|
20355
20396
|
const sessions = Object.values(readStore());
|
|
20356
20397
|
let newest;
|
|
20357
20398
|
for (const session of sessions) {
|
|
20358
|
-
if (session.claudeSessionId !== claudeSessionId)
|
|
20399
|
+
if (session.claudeSessionId !== claudeSessionId || hasLegacyUserDenialBoundary(session))
|
|
20359
20400
|
continue;
|
|
20360
20401
|
if (!newest || session.lastUsedAt > newest.lastUsedAt) {
|
|
20361
20402
|
newest = session;
|
|
@@ -20363,7 +20404,7 @@ function lookupSharedSessionByClaudeId(claudeSessionId) {
|
|
|
20363
20404
|
}
|
|
20364
20405
|
return newest;
|
|
20365
20406
|
}
|
|
20366
|
-
function storeSharedSession(key, claudeSessionId, messageCount, lineageHash, messageHashes, sdkMessageUuids, contextUsage, messageBlockHashes,
|
|
20407
|
+
function storeSharedSession(key, claudeSessionId, messageCount, lineageHash, messageHashes, sdkMessageUuids, contextUsage, messageBlockHashes, passthroughToolCallAssistantUuid, passthroughToolCallIds) {
|
|
20367
20408
|
const path3 = getStorePath();
|
|
20368
20409
|
const lockPath = `${path3}.lock`;
|
|
20369
20410
|
const hasLock = skipLocking ? false : acquireLock(lockPath);
|
|
@@ -20383,7 +20424,8 @@ function storeSharedSession(key, claudeSessionId, messageCount, lineageHash, mes
|
|
|
20383
20424
|
messageHashes: messageHashes ?? existing?.messageHashes,
|
|
20384
20425
|
messageBlockHashes: messageBlockHashes ?? existing?.messageBlockHashes,
|
|
20385
20426
|
sdkMessageUuids: sdkMessageUuids ?? existing?.sdkMessageUuids,
|
|
20386
|
-
|
|
20427
|
+
passthroughToolCallAssistantUuid: passthroughToolCallAssistantUuid === undefined ? existing?.passthroughToolCallAssistantUuid : passthroughToolCallAssistantUuid ?? undefined,
|
|
20428
|
+
passthroughToolCallIds: passthroughToolCallIds === undefined ? existing?.passthroughToolCallIds : passthroughToolCallIds ?? undefined,
|
|
20387
20429
|
contextUsage: contextUsage ?? existing?.contextUsage,
|
|
20388
20430
|
...previousClaudeSessionId ? { previousClaudeSessionId } : {}
|
|
20389
20431
|
};
|
|
@@ -20581,7 +20623,8 @@ function lookupSession(sessionId, messages, workingDirectory) {
|
|
|
20581
20623
|
messageHashes: shared.messageHashes,
|
|
20582
20624
|
messageBlockHashes: shared.messageBlockHashes,
|
|
20583
20625
|
sdkMessageUuids: shared.sdkMessageUuids,
|
|
20584
|
-
|
|
20626
|
+
passthroughToolCallAssistantUuid: shared.passthroughToolCallAssistantUuid,
|
|
20627
|
+
passthroughToolCallIds: shared.passthroughToolCallIds,
|
|
20585
20628
|
contextUsage: shared.contextUsage
|
|
20586
20629
|
};
|
|
20587
20630
|
const result = classifyLineage(state, messages, sessionId);
|
|
@@ -20611,7 +20654,8 @@ function lookupSession(sessionId, messages, workingDirectory) {
|
|
|
20611
20654
|
messageHashes: shared.messageHashes,
|
|
20612
20655
|
messageBlockHashes: shared.messageBlockHashes,
|
|
20613
20656
|
sdkMessageUuids: shared.sdkMessageUuids,
|
|
20614
|
-
|
|
20657
|
+
passthroughToolCallAssistantUuid: shared.passthroughToolCallAssistantUuid,
|
|
20658
|
+
passthroughToolCallIds: shared.passthroughToolCallIds,
|
|
20615
20659
|
contextUsage: shared.contextUsage
|
|
20616
20660
|
};
|
|
20617
20661
|
const result = classifyLineage(state, messages, fp);
|
|
@@ -20646,13 +20690,14 @@ function getSessionByClaudeId(claudeSessionId) {
|
|
|
20646
20690
|
messageHashes: shared.messageHashes,
|
|
20647
20691
|
messageBlockHashes: shared.messageBlockHashes,
|
|
20648
20692
|
sdkMessageUuids: shared.sdkMessageUuids,
|
|
20649
|
-
|
|
20693
|
+
passthroughToolCallAssistantUuid: shared.passthroughToolCallAssistantUuid,
|
|
20694
|
+
passthroughToolCallIds: shared.passthroughToolCallIds,
|
|
20650
20695
|
contextUsage: shared.contextUsage
|
|
20651
20696
|
});
|
|
20652
20697
|
}
|
|
20653
20698
|
return newest;
|
|
20654
20699
|
}
|
|
20655
|
-
function storeSession(sessionId, messages, claudeSessionId, workingDirectory, sdkMessageUuids, contextUsage,
|
|
20700
|
+
function storeSession(sessionId, messages, claudeSessionId, workingDirectory, sdkMessageUuids, contextUsage, passthroughToolCallAssistantUuid, passthroughToolCallIds) {
|
|
20656
20701
|
if (!claudeSessionId)
|
|
20657
20702
|
return;
|
|
20658
20703
|
const lineageHash = computeLineageHash(messages);
|
|
@@ -20666,7 +20711,8 @@ function storeSession(sessionId, messages, claudeSessionId, workingDirectory, sd
|
|
|
20666
20711
|
messageHashes,
|
|
20667
20712
|
messageBlockHashes,
|
|
20668
20713
|
sdkMessageUuids,
|
|
20669
|
-
...
|
|
20714
|
+
...passthroughToolCallAssistantUuid ? { passthroughToolCallAssistantUuid } : {},
|
|
20715
|
+
...passthroughToolCallIds ? { passthroughToolCallIds } : {},
|
|
20670
20716
|
...contextUsage ? { contextUsage } : {}
|
|
20671
20717
|
};
|
|
20672
20718
|
if (sessionId)
|
|
@@ -20676,7 +20722,7 @@ function storeSession(sessionId, messages, claudeSessionId, workingDirectory, sd
|
|
|
20676
20722
|
fingerprintCache.set(fp, state);
|
|
20677
20723
|
const key = sessionId || fp;
|
|
20678
20724
|
if (key) {
|
|
20679
|
-
storeSharedSession(key, claudeSessionId, state.messageCount, lineageHash, messageHashes, sdkMessageUuids, contextUsage, messageBlockHashes,
|
|
20725
|
+
storeSharedSession(key, claudeSessionId, state.messageCount, lineageHash, messageHashes, sdkMessageUuids, contextUsage, messageBlockHashes, passthroughToolCallAssistantUuid ?? null, passthroughToolCallIds ?? null);
|
|
20680
20726
|
}
|
|
20681
20727
|
}
|
|
20682
20728
|
|
|
@@ -20836,21 +20882,21 @@ function stripCacheControlDeep(content) {
|
|
|
20836
20882
|
return rest;
|
|
20837
20883
|
});
|
|
20838
20884
|
}
|
|
20839
|
-
function normalizeStructuredUserContent(content) {
|
|
20885
|
+
function normalizeStructuredUserContent(content, preserveToolResultWrapper = false) {
|
|
20840
20886
|
if (!Array.isArray(content))
|
|
20841
20887
|
return content;
|
|
20842
20888
|
const normalized = [];
|
|
20843
20889
|
for (const block of content) {
|
|
20844
20890
|
if (!block || typeof block !== "object")
|
|
20845
20891
|
continue;
|
|
20846
|
-
if (block.type === "tool_result" && Array.isArray(block.content) && hasMultimodalContent(block.content)) {
|
|
20892
|
+
if (!preserveToolResultWrapper && block.type === "tool_result" && Array.isArray(block.content) && hasMultimodalContent(block.content)) {
|
|
20847
20893
|
normalized.push(...normalizeStructuredUserContent(block.content));
|
|
20848
20894
|
continue;
|
|
20849
20895
|
}
|
|
20850
20896
|
if (block.type === "tool_result" && Array.isArray(block.content)) {
|
|
20851
20897
|
normalized.push({
|
|
20852
20898
|
...block,
|
|
20853
|
-
content: normalizeStructuredUserContent(block.content)
|
|
20899
|
+
content: normalizeStructuredUserContent(block.content, preserveToolResultWrapper)
|
|
20854
20900
|
});
|
|
20855
20901
|
continue;
|
|
20856
20902
|
}
|
|
@@ -21457,15 +21503,16 @@ data: ${JSON.stringify(lastError)}
|
|
|
21457
21503
|
} : undefined
|
|
21458
21504
|
}, adapterBase);
|
|
21459
21505
|
}
|
|
21460
|
-
|
|
21506
|
+
let isResume = lineageResult.type === "continuation" || lineageResult.type === "compaction";
|
|
21461
21507
|
const isUndo = lineageResult.type === "undo";
|
|
21462
21508
|
const cachedSession = lineageResult.type !== "diverged" ? lineageResult.session : undefined;
|
|
21463
|
-
|
|
21509
|
+
let resumeSessionId = cachedSession?.claudeSessionId;
|
|
21464
21510
|
const passthrough = adapter.instancePassthrough !== undefined ? adapter.instancePassthrough : pipelineCtx.passthrough !== undefined ? pipelineCtx.passthrough : envBool("PASSTHROUGH");
|
|
21465
21511
|
const resumeFrom = lineageResult.type === "continuation" || lineageResult.type === "compaction" ? lineageResult.resumeFrom : undefined;
|
|
21466
21512
|
const resumeContentFrom = lineageResult.type === "continuation" ? lineageResult.resumeContentFrom : undefined;
|
|
21467
21513
|
const undoRollbackUuid = isUndo && lineageResult.type === "undo" ? lineageResult.rollbackUuid : undefined;
|
|
21468
|
-
|
|
21514
|
+
let passthroughToolCallAssistantUuid = passthrough && isResume ? cachedSession?.passthroughToolCallAssistantUuid : undefined;
|
|
21515
|
+
const passthroughToolCallIds = passthrough && isResume ? cachedSession?.passthroughToolCallIds : undefined;
|
|
21469
21516
|
const msgSummary = body.messages?.map((m) => {
|
|
21470
21517
|
const contentTypes = Array.isArray(m.content) ? m.content.map((b) => b.type).join(",") : "string";
|
|
21471
21518
|
return `${m.role}[${contentTypes}]`;
|
|
@@ -21531,17 +21578,28 @@ data: ${JSON.stringify(lastError)}
|
|
|
21531
21578
|
} else {
|
|
21532
21579
|
messagesToConvert = allMessages;
|
|
21533
21580
|
}
|
|
21581
|
+
if (passthroughToolCallAssistantUuid && !isCompleteToolResultContinuation(messagesToConvert, passthroughToolCallIds ?? [])) {
|
|
21582
|
+
claudeLog("passthrough.checkpoint_replay", {
|
|
21583
|
+
expectedToolIds: passthroughToolCallIds?.length ?? 0,
|
|
21584
|
+
reason: "incomplete_or_mismatched_results"
|
|
21585
|
+
});
|
|
21586
|
+
isResume = false;
|
|
21587
|
+
resumeSessionId = undefined;
|
|
21588
|
+
passthroughToolCallAssistantUuid = undefined;
|
|
21589
|
+
messagesToConvert = allMessages;
|
|
21590
|
+
}
|
|
21534
21591
|
const hasMultimodal = messagesToConvert?.some((m) => hasMultimodalContent(m.content));
|
|
21592
|
+
const hasPassthroughToolResults = Boolean(passthroughToolCallAssistantUuid) && messagesToConvert?.some((m) => m.role === "user" && Array.isArray(m.content) && m.content.some((block) => block?.type === "tool_result"));
|
|
21535
21593
|
let structuredMessages;
|
|
21536
21594
|
let textPrompt;
|
|
21537
|
-
if (hasMultimodal) {
|
|
21595
|
+
if (hasMultimodal || hasPassthroughToolResults) {
|
|
21538
21596
|
structuredMessages = [];
|
|
21539
21597
|
if (isResume) {
|
|
21540
21598
|
for (const m of messagesToConvert) {
|
|
21541
21599
|
if (m.role === "user") {
|
|
21542
21600
|
structuredMessages.push({
|
|
21543
21601
|
type: "user",
|
|
21544
|
-
message: { role: "user", content: normalizeStructuredUserContent(stripCacheControlDeep(m.content)) },
|
|
21602
|
+
message: { role: "user", content: normalizeStructuredUserContent(stripCacheControlDeep(m.content), Boolean(passthroughToolCallAssistantUuid)) },
|
|
21545
21603
|
parent_tool_use_id: null
|
|
21546
21604
|
});
|
|
21547
21605
|
}
|
|
@@ -21551,7 +21609,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
21551
21609
|
if (m.role === "user") {
|
|
21552
21610
|
structuredMessages.push({
|
|
21553
21611
|
type: "user",
|
|
21554
|
-
message: { role: "user", content: normalizeStructuredUserContent(stripCacheControlDeep(m.content)) },
|
|
21612
|
+
message: { role: "user", content: normalizeStructuredUserContent(stripCacheControlDeep(m.content), Boolean(passthroughToolCallAssistantUuid)) },
|
|
21555
21613
|
parent_tool_use_id: null
|
|
21556
21614
|
});
|
|
21557
21615
|
} else {
|
|
@@ -21569,13 +21627,6 @@ data: ${JSON.stringify(lastError)}
|
|
|
21569
21627
|
if (structuredMessages.length > 1) {
|
|
21570
21628
|
structuredMessages = consolidateMultimodalOntoLastUser(structuredMessages);
|
|
21571
21629
|
}
|
|
21572
|
-
if (passthroughResumeUuid && structuredMessages.length > 0) {
|
|
21573
|
-
structuredMessages.unshift({
|
|
21574
|
-
type: "user",
|
|
21575
|
-
message: { role: "user", content: PASSTHROUGH_CONTINUATION_LEAD_IN },
|
|
21576
|
-
parent_tool_use_id: null
|
|
21577
|
-
});
|
|
21578
|
-
}
|
|
21579
21630
|
} else {
|
|
21580
21631
|
const toolIndex = buildToolUseIndex(allMessages ?? messagesToConvert ?? []);
|
|
21581
21632
|
const promptTurns = (messagesToConvert ?? []).map((m) => {
|
|
@@ -21590,7 +21641,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
21590
21641
|
const resumeDelta = promptTurns.map((t) => t.text).filter(Boolean).join(`
|
|
21591
21642
|
|
|
21592
21643
|
`) || "";
|
|
21593
|
-
textPrompt = isResume ?
|
|
21644
|
+
textPrompt = isResume ? resumeDelta : frameReplayTurns(promptTurns);
|
|
21594
21645
|
}
|
|
21595
21646
|
const settingSources = envBool("LOAD_CONTEXT") || sdkFeatures.claudeMd === "full" ? ["user", "project"] : sdkFeatures.claudeMd === "project" ? ["project"] : pipelineCtx.settingSources ?? [];
|
|
21596
21647
|
const capturedToolUses = [];
|
|
@@ -21693,11 +21744,15 @@ data: ${JSON.stringify(lastError)}
|
|
|
21693
21744
|
}
|
|
21694
21745
|
const signature = toolUseSignature(toolName, toolInput);
|
|
21695
21746
|
const isExactDuplicate = capturedSignatures.has(signature);
|
|
21747
|
+
const isPostCheckpointCall = earlyStopFired;
|
|
21696
21748
|
const isSameToolRepeat = !earlyStopEnabled && !isExactDuplicate && capturedToolNames.has(toolName);
|
|
21697
21749
|
const exceedsForcedSingle = forceSingleToolUse && capturedToolUses.length >= 1;
|
|
21698
|
-
if (isExactDuplicate) {
|
|
21750
|
+
if (isExactDuplicate || isPostCheckpointCall) {
|
|
21699
21751
|
droppedToolUseIds.add(input.tool_use_id);
|
|
21700
|
-
claudeLog("passthrough.duplicate_tool_use_dropped", {
|
|
21752
|
+
claudeLog("passthrough.duplicate_tool_use_dropped", {
|
|
21753
|
+
name: toolName,
|
|
21754
|
+
reason: isPostCheckpointCall ? "hidden_digest" : "exact_duplicate"
|
|
21755
|
+
});
|
|
21701
21756
|
} else if (isSameToolRepeat || exceedsForcedSingle) {
|
|
21702
21757
|
droppedToolUseIds.add(input.tool_use_id);
|
|
21703
21758
|
sawDuplicateToolUse = true;
|
|
@@ -21718,10 +21773,10 @@ data: ${JSON.stringify(lastError)}
|
|
|
21718
21773
|
if (earlyStopEnabled && turnGenerating && !requestAbort.controller.signal.aborted) {
|
|
21719
21774
|
await holdDenyUntilTurnEnd();
|
|
21720
21775
|
}
|
|
21721
|
-
if (isExactDuplicate) {
|
|
21776
|
+
if (isExactDuplicate || isPostCheckpointCall) {
|
|
21722
21777
|
return {
|
|
21723
21778
|
decision: "block",
|
|
21724
|
-
reason: "This
|
|
21779
|
+
reason: "This tool call has already been handled by the client-facing turn — do not repeat it. " + "Do not call additional tools and do not generate further text — end your turn now."
|
|
21725
21780
|
};
|
|
21726
21781
|
}
|
|
21727
21782
|
if (isSameToolRepeat || exceedsForcedSingle) {
|
|
@@ -21753,13 +21808,15 @@ data: ${JSON.stringify(lastError)}
|
|
|
21753
21808
|
const upstreamStartAt = Date.now();
|
|
21754
21809
|
let firstChunkAt;
|
|
21755
21810
|
let currentSessionId;
|
|
21756
|
-
|
|
21811
|
+
let sdkUuidMap = (isResume || isUndo) && cachedSession?.sdkMessageUuids ? [...cachedSession.sdkMessageUuids] : [];
|
|
21757
21812
|
while (sdkUuidMap.length < allMessages.length)
|
|
21758
21813
|
sdkUuidMap.push(null);
|
|
21759
21814
|
claudeLog("upstream.start", { mode: "non_stream", model });
|
|
21760
21815
|
let lastUsage;
|
|
21761
21816
|
let lastStopReason;
|
|
21762
|
-
let
|
|
21817
|
+
let nextPassthroughToolCallAssistantUuid;
|
|
21818
|
+
let nextPassthroughToolCallIds;
|
|
21819
|
+
let sawCanonicalResult = false;
|
|
21763
21820
|
try {
|
|
21764
21821
|
if (!claudeExecutable) {
|
|
21765
21822
|
claudeExecutable = await resolveClaudeExecutableAsync();
|
|
@@ -21797,8 +21854,8 @@ data: ${JSON.stringify(lastError)}
|
|
|
21797
21854
|
hasDeferredTools,
|
|
21798
21855
|
resumeSessionId,
|
|
21799
21856
|
isUndo,
|
|
21800
|
-
resumeSessionAtUuid: undoRollbackUuid ??
|
|
21801
|
-
forkSession: busySessionFork ||
|
|
21857
|
+
resumeSessionAtUuid: undoRollbackUuid ?? passthroughToolCallAssistantUuid,
|
|
21858
|
+
forkSession: busySessionFork || undefined,
|
|
21802
21859
|
sdkHooks,
|
|
21803
21860
|
blockedTools: pipelineCtx.blockedTools,
|
|
21804
21861
|
incompatibleTools: pipelineCtx.incompatibleTools,
|
|
@@ -22031,25 +22088,33 @@ data: ${JSON.stringify(lastError)}
|
|
|
22031
22088
|
claudeLog("passthrough.loop_break", { mode: "non_stream", assistantMessages, captured: capturedToolUses.length });
|
|
22032
22089
|
break;
|
|
22033
22090
|
}
|
|
22034
|
-
|
|
22035
|
-
|
|
22036
|
-
|
|
22037
|
-
|
|
22038
|
-
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22042
|
-
|
|
22043
|
-
|
|
22044
|
-
|
|
22091
|
+
let assistantAddedForwardedCall = false;
|
|
22092
|
+
if (passthrough && message.type === "assistant" && !earlyStopFired && earlyStop.resolved.size === 0) {
|
|
22093
|
+
const expectedBefore = earlyStop.expected.size;
|
|
22094
|
+
noteAssistantMessage(earlyStop, message);
|
|
22095
|
+
assistantAddedForwardedCall = earlyStop.expected.size > expectedBefore;
|
|
22096
|
+
} else if (passthrough && message.type === "user" && !earlyStopFired) {
|
|
22097
|
+
noteUserContent(earlyStop, message.message?.content);
|
|
22098
|
+
if (earlyStopEnabled && shouldEarlyStop(earlyStop)) {
|
|
22099
|
+
nextPassthroughToolCallAssistantUuid = settledToolCallAssistantUuid(earlyStop);
|
|
22100
|
+
nextPassthroughToolCallIds = [...earlyStop.expected];
|
|
22101
|
+
earlyStopFired = true;
|
|
22102
|
+
for (let i = capturedToolUses.length - 1;i >= 0; i--) {
|
|
22103
|
+
if (!earlyStop.expected.has(capturedToolUses[i].id))
|
|
22104
|
+
capturedToolUses.splice(i, 1);
|
|
22045
22105
|
}
|
|
22106
|
+
claudeLog("passthrough.checkpoint_ready", {
|
|
22107
|
+
mode: "non_stream",
|
|
22108
|
+
captured: capturedToolUses.length,
|
|
22109
|
+
toolCallAssistantUuid: nextPassthroughToolCallAssistantUuid
|
|
22110
|
+
});
|
|
22046
22111
|
}
|
|
22047
22112
|
}
|
|
22048
22113
|
if (message.type === "assistant") {
|
|
22049
22114
|
releaseHeldDenies("assistant_message");
|
|
22050
22115
|
assistantMessages += 1;
|
|
22051
|
-
if (
|
|
22052
|
-
sdkUuidMap.
|
|
22116
|
+
if (!passthrough || earlyStop.expected.size === 0 || assistantAddedForwardedCall) {
|
|
22117
|
+
sdkUuidMap = withClientAssistantUuid(sdkUuidMap, allMessages.length, message.uuid);
|
|
22053
22118
|
}
|
|
22054
22119
|
if (!firstChunkAt) {
|
|
22055
22120
|
firstChunkAt = Date.now();
|
|
@@ -22093,11 +22158,12 @@ data: ${JSON.stringify(lastError)}
|
|
|
22093
22158
|
const msgUsage = message.message.usage;
|
|
22094
22159
|
if (msgUsage)
|
|
22095
22160
|
lastUsage = { ...lastUsage, ...msgUsage };
|
|
22096
|
-
if (typeof message.message.stop_reason === "string") {
|
|
22161
|
+
if (!isPassthroughTurn2 && typeof message.message.stop_reason === "string") {
|
|
22097
22162
|
lastStopReason = message.message.stop_reason;
|
|
22098
22163
|
}
|
|
22099
22164
|
}
|
|
22100
22165
|
if (message.type === "result") {
|
|
22166
|
+
sawCanonicalResult = true;
|
|
22101
22167
|
const resultUsage = message.usage;
|
|
22102
22168
|
if (resultUsage) {
|
|
22103
22169
|
lastUsage = { ...lastUsage, ...resultUsage };
|
|
@@ -22129,6 +22195,10 @@ data: ${JSON.stringify(lastError)}
|
|
|
22129
22195
|
}
|
|
22130
22196
|
} catch (error) {
|
|
22131
22197
|
releaseHeldDenies("non_stream_error");
|
|
22198
|
+
if (passthrough && capturedToolUses.length > 0 && !sawCanonicalResult) {
|
|
22199
|
+
evictSession(profileSessionId, profileScopedCwd, body.messages || []);
|
|
22200
|
+
claudeLog("passthrough.noncanonical_session_evicted", { mode: "non_stream", reason: "drain_error" });
|
|
22201
|
+
}
|
|
22132
22202
|
const stderrOutput = stderrLines.join(`
|
|
22133
22203
|
`).trim();
|
|
22134
22204
|
if (stderrOutput && error instanceof Error && !error.message.includes(stderrOutput)) {
|
|
@@ -22283,8 +22353,14 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
22283
22353
|
]);
|
|
22284
22354
|
}
|
|
22285
22355
|
if (currentSessionId && !isIndependentSession && !sawDuplicateToolUse) {
|
|
22286
|
-
|
|
22287
|
-
|
|
22356
|
+
const checkpointTurn = passthrough && contentBlocks.some((b) => b.type === "tool_use");
|
|
22357
|
+
if (checkpointTurn && (!earlyStopFired || !sawCanonicalResult)) {
|
|
22358
|
+
evictSession(profileSessionId, profileScopedCwd, body.messages || []);
|
|
22359
|
+
claudeLog("passthrough.noncanonical_session_evicted", { mode: "non_stream" });
|
|
22360
|
+
} else {
|
|
22361
|
+
storeSession(profileSessionId, body.messages || [], currentSessionId, profileScopedCwd, sdkUuidMap, lastUsage, earlyStopFired ? nextPassthroughToolCallAssistantUuid : null, earlyStopFired ? nextPassthroughToolCallIds : null);
|
|
22362
|
+
commitSessionTurn();
|
|
22363
|
+
}
|
|
22288
22364
|
}
|
|
22289
22365
|
const responseSessionId = currentSessionId || resumeSessionId || `session_${Date.now()}`;
|
|
22290
22366
|
return new Response(JSON.stringify({
|
|
@@ -22325,6 +22401,7 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
22325
22401
|
let bytesSent = 0;
|
|
22326
22402
|
let streamClosed = false;
|
|
22327
22403
|
let awaitingEarlyStopDrain = false;
|
|
22404
|
+
let exitedBeforeCanonicalTerminal = false;
|
|
22328
22405
|
claudeLog("upstream.start", { mode: "stream", model });
|
|
22329
22406
|
const safeEnqueue = (payload, source) => {
|
|
22330
22407
|
if (streamClosed)
|
|
@@ -22346,14 +22423,16 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
22346
22423
|
throw error;
|
|
22347
22424
|
}
|
|
22348
22425
|
};
|
|
22349
|
-
|
|
22426
|
+
let sdkUuidMap = (isResume || isUndo) && cachedSession?.sdkMessageUuids ? [...cachedSession.sdkMessageUuids] : [];
|
|
22350
22427
|
while (sdkUuidMap.length < allMessages.length)
|
|
22351
22428
|
sdkUuidMap.push(null);
|
|
22352
22429
|
let messageStartEmitted = false;
|
|
22353
22430
|
let lastUsage;
|
|
22354
22431
|
let hasStructuredOutput = false;
|
|
22355
22432
|
let structuredOutput;
|
|
22356
|
-
let
|
|
22433
|
+
let nextPassthroughToolCallAssistantUuid;
|
|
22434
|
+
let nextPassthroughToolCallIds;
|
|
22435
|
+
let sawCanonicalResult = false;
|
|
22357
22436
|
const silentTurnRecoveryEnabled = env("SILENT_TURN_RECOVERY") !== "0";
|
|
22358
22437
|
let silentTurnRecoveryAttempted = false;
|
|
22359
22438
|
let silentTurnRecovered = false;
|
|
@@ -22378,33 +22457,6 @@ data: ${JSON.stringify({
|
|
|
22378
22457
|
eventsForwarded += 1;
|
|
22379
22458
|
};
|
|
22380
22459
|
const openClientBlocks = new Set;
|
|
22381
|
-
let pendingEarlyStop = false;
|
|
22382
|
-
let pendingEarlyStopAt = 0;
|
|
22383
|
-
const fireEarlyStop = (reason) => {
|
|
22384
|
-
earlyStopFired = true;
|
|
22385
|
-
claudeLog("passthrough.early_stop", {
|
|
22386
|
-
mode: "stream",
|
|
22387
|
-
captured: capturedToolUses.length,
|
|
22388
|
-
drained: awaitingEarlyStopDrain,
|
|
22389
|
-
reason,
|
|
22390
|
-
deferredMs: pendingEarlyStopAt ? Date.now() - pendingEarlyStopAt : 0
|
|
22391
|
-
});
|
|
22392
|
-
pendingEarlyStop = false;
|
|
22393
|
-
flushOpenClientBlocks("early_stop");
|
|
22394
|
-
sendTerminalDelta("tool_use");
|
|
22395
|
-
safeEnqueue(encoder.encode(`event: message_stop
|
|
22396
|
-
data: ${JSON.stringify({ type: "message_stop" })}
|
|
22397
|
-
|
|
22398
|
-
`), "early_stop");
|
|
22399
|
-
requestAbort.abort("passthrough turn complete");
|
|
22400
|
-
awaitingEarlyStopDrain = false;
|
|
22401
|
-
if (!streamClosed) {
|
|
22402
|
-
streamClosed = true;
|
|
22403
|
-
try {
|
|
22404
|
-
controller.close();
|
|
22405
|
-
} catch {}
|
|
22406
|
-
}
|
|
22407
|
-
};
|
|
22408
22460
|
const flushOpenClientBlocks = (source) => {
|
|
22409
22461
|
if (openClientBlocks.size === 0)
|
|
22410
22462
|
return;
|
|
@@ -22455,8 +22507,8 @@ data: ${JSON.stringify({ type: "content_block_stop", index: idx })}
|
|
|
22455
22507
|
hasDeferredTools,
|
|
22456
22508
|
resumeSessionId,
|
|
22457
22509
|
isUndo,
|
|
22458
|
-
resumeSessionAtUuid: undoRollbackUuid ??
|
|
22459
|
-
forkSession: busySessionFork ||
|
|
22510
|
+
resumeSessionAtUuid: undoRollbackUuid ?? passthroughToolCallAssistantUuid,
|
|
22511
|
+
forkSession: busySessionFork || undefined,
|
|
22460
22512
|
sdkHooks,
|
|
22461
22513
|
blockedTools: pipelineCtx.blockedTools,
|
|
22462
22514
|
incompatibleTools: pipelineCtx.incompatibleTools,
|
|
@@ -22716,38 +22768,42 @@ data: ${JSON.stringify({ type: "content_block_stop", index: idx })}
|
|
|
22716
22768
|
try {
|
|
22717
22769
|
for await (const message of guardedResponse) {
|
|
22718
22770
|
if (streamClosed && !awaitingEarlyStopDrain) {
|
|
22771
|
+
exitedBeforeCanonicalTerminal = true;
|
|
22719
22772
|
break;
|
|
22720
22773
|
}
|
|
22721
22774
|
if (message.session_id) {
|
|
22722
22775
|
currentSessionId = message.session_id;
|
|
22723
22776
|
}
|
|
22724
|
-
|
|
22725
|
-
|
|
22777
|
+
let assistantAddedForwardedCall = false;
|
|
22778
|
+
if (earlyStopEnabled && message.type === "assistant" && !earlyStopFired) {
|
|
22779
|
+
const expectedBefore = earlyStop.expected.size;
|
|
22780
|
+
noteAssistantMessage(earlyStop, message);
|
|
22781
|
+
assistantAddedForwardedCall = earlyStop.expected.size > expectedBefore;
|
|
22782
|
+
} else if (earlyStopEnabled && message.type === "user" && !earlyStopFired) {
|
|
22783
|
+
noteUserContent(earlyStop, message.message?.content);
|
|
22726
22784
|
}
|
|
22727
|
-
|
|
22728
|
-
|
|
22729
|
-
if (
|
|
22730
|
-
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
|
|
22734
|
-
if (
|
|
22735
|
-
|
|
22736
|
-
pendingEarlyStop = true;
|
|
22737
|
-
pendingEarlyStopAt = Date.now();
|
|
22738
|
-
claudeLog("passthrough.early_stop_deferred", {
|
|
22739
|
-
openBlocks: openClientBlocks.size,
|
|
22740
|
-
captured: capturedToolUses.length
|
|
22741
|
-
});
|
|
22742
|
-
}
|
|
22743
|
-
} else {
|
|
22744
|
-
fireEarlyStop("immediate");
|
|
22745
|
-
break;
|
|
22746
|
-
}
|
|
22785
|
+
if (earlyStopEnabled && !earlyStopFired) {
|
|
22786
|
+
const hasCompleteStreamedSet = streamedToolUseIds.size > 0 && earlyStop.expected.size === streamedToolUseIds.size && [...streamedToolUseIds].every((id) => earlyStop.expected.has(id));
|
|
22787
|
+
if (!turnGenerating && openClientBlocks.size === 0 && hasCompleteStreamedSet && shouldEarlyStop(earlyStop)) {
|
|
22788
|
+
nextPassthroughToolCallAssistantUuid = settledToolCallAssistantUuid(earlyStop);
|
|
22789
|
+
nextPassthroughToolCallIds = [...earlyStop.expected];
|
|
22790
|
+
earlyStopFired = true;
|
|
22791
|
+
for (let i = capturedToolUses.length - 1;i >= 0; i--) {
|
|
22792
|
+
if (!earlyStop.expected.has(capturedToolUses[i].id))
|
|
22793
|
+
capturedToolUses.splice(i, 1);
|
|
22747
22794
|
}
|
|
22795
|
+
claudeLog("passthrough.checkpoint_ready", {
|
|
22796
|
+
mode: "stream",
|
|
22797
|
+
captured: capturedToolUses.length,
|
|
22798
|
+
toolCallAssistantUuid: nextPassthroughToolCallAssistantUuid
|
|
22799
|
+
});
|
|
22748
22800
|
}
|
|
22749
22801
|
}
|
|
22802
|
+
if (message.type === "assistant" && (!passthrough || earlyStop.expected.size === 0 || assistantAddedForwardedCall)) {
|
|
22803
|
+
sdkUuidMap = withClientAssistantUuid(sdkUuidMap, allMessages.length, message.uuid);
|
|
22804
|
+
}
|
|
22750
22805
|
if (message.type === "result") {
|
|
22806
|
+
sawCanonicalResult = true;
|
|
22751
22807
|
const resultUsage = message.usage;
|
|
22752
22808
|
if (resultUsage)
|
|
22753
22809
|
lastUsage = { ...lastUsage, ...resultUsage };
|
|
@@ -22757,6 +22813,8 @@ data: ${JSON.stringify({ type: "content_block_stop", index: idx })}
|
|
|
22757
22813
|
}
|
|
22758
22814
|
}
|
|
22759
22815
|
if (message.type === "stream_event") {
|
|
22816
|
+
if (streamClosed && awaitingEarlyStopDrain)
|
|
22817
|
+
continue;
|
|
22760
22818
|
streamEventsSeen += 1;
|
|
22761
22819
|
if (!firstChunkAt) {
|
|
22762
22820
|
firstChunkAt = Date.now();
|
|
@@ -22796,16 +22854,19 @@ data: ${JSON.stringify({ type: "content_block_stop", index: idx })}
|
|
|
22796
22854
|
lastUsage = { ...lastUsage, ...startUsage };
|
|
22797
22855
|
if (messageStartEmitted) {
|
|
22798
22856
|
if (passthrough && streamedToolUseIds.size > 0) {
|
|
22799
|
-
|
|
22800
|
-
|
|
22801
|
-
|
|
22857
|
+
if (!streamClosed) {
|
|
22858
|
+
flushOpenClientBlocks("turn2_suppression");
|
|
22859
|
+
sendTerminalDelta("tool_use");
|
|
22860
|
+
safeEnqueue(encoder.encode(`event: message_stop
|
|
22802
22861
|
data: ${JSON.stringify({ type: "message_stop" })}
|
|
22803
22862
|
|
|
22804
22863
|
`), "passthrough_turn2_stop");
|
|
22864
|
+
streamClosed = true;
|
|
22865
|
+
controller.close();
|
|
22866
|
+
}
|
|
22867
|
+
awaitingEarlyStopDrain = true;
|
|
22805
22868
|
claudeLog("passthrough.turn2_suppressed", { mode: "stream", toolUses: streamedToolUseIds.size });
|
|
22806
|
-
|
|
22807
|
-
controller.close();
|
|
22808
|
-
break;
|
|
22869
|
+
continue;
|
|
22809
22870
|
}
|
|
22810
22871
|
continue;
|
|
22811
22872
|
}
|
|
@@ -22929,10 +22990,6 @@ data: ${JSON.stringify(event)}
|
|
|
22929
22990
|
const idx = event.index;
|
|
22930
22991
|
if (typeof idx === "number")
|
|
22931
22992
|
openClientBlocks.delete(idx);
|
|
22932
|
-
if (pendingEarlyStop && openClientBlocks.size === 0) {
|
|
22933
|
-
fireEarlyStop("blocks_closed");
|
|
22934
|
-
break;
|
|
22935
|
-
}
|
|
22936
22993
|
}
|
|
22937
22994
|
if (passthrough && eventType === "message_delta" && event.delta?.stop_reason === "tool_use" && streamedToolUseIds.size > 0) {
|
|
22938
22995
|
flushOpenClientBlocks("drain_close");
|
|
@@ -22947,6 +23004,7 @@ data: ${JSON.stringify({ type: "message_stop" })}
|
|
|
22947
23004
|
awaitingEarlyStopDrain = true;
|
|
22948
23005
|
continue;
|
|
22949
23006
|
}
|
|
23007
|
+
exitedBeforeCanonicalTerminal = true;
|
|
22950
23008
|
break;
|
|
22951
23009
|
}
|
|
22952
23010
|
if (eventType === "content_block_delta") {
|
|
@@ -23042,8 +23100,14 @@ data: ${JSON.stringify({
|
|
|
23042
23100
|
plog(`[PROXY] ${requestMeta.requestId} discovered=${discoveredTools.size} (${newNames}) session_total=${allNames.length}`);
|
|
23043
23101
|
}
|
|
23044
23102
|
if (currentSessionId && !isIndependentSession && !sawDuplicateToolUse) {
|
|
23045
|
-
|
|
23046
|
-
|
|
23103
|
+
const checkpointTurn = passthrough && streamedToolUseIds.size > 0;
|
|
23104
|
+
if (exitedBeforeCanonicalTerminal || checkpointTurn && (!earlyStopFired || !sawCanonicalResult)) {
|
|
23105
|
+
evictSession(profileSessionId, profileScopedCwd, body.messages || []);
|
|
23106
|
+
claudeLog("passthrough.noncanonical_session_evicted", { mode: "stream" });
|
|
23107
|
+
} else {
|
|
23108
|
+
storeSession(profileSessionId, body.messages || [], currentSessionId, profileScopedCwd, sdkUuidMap, lastUsage, earlyStopFired ? nextPassthroughToolCallAssistantUuid : null, earlyStopFired ? nextPassthroughToolCallIds : null);
|
|
23109
|
+
commitSessionTurn();
|
|
23110
|
+
}
|
|
23047
23111
|
}
|
|
23048
23112
|
const classifyNow = () => classifyTurnOutcome({
|
|
23049
23113
|
textEvents: textEventsForwarded,
|
|
@@ -23068,7 +23132,8 @@ data: ${JSON.stringify({
|
|
|
23068
23132
|
});
|
|
23069
23133
|
const recoveryLifter = createRecoveryLifter(() => nextClientBlockIndex++);
|
|
23070
23134
|
let recoverySessionId;
|
|
23071
|
-
let
|
|
23135
|
+
let recoveryToolCallAssistantUuid;
|
|
23136
|
+
const recoveryEarlyStop = createEarlyStopTracker();
|
|
23072
23137
|
try {
|
|
23073
23138
|
for await (const event of runSdkQueryAttempt(buildQueryOptions({
|
|
23074
23139
|
prompt: SILENT_TURN_NUDGE,
|
|
@@ -23086,7 +23151,7 @@ data: ${JSON.stringify({
|
|
|
23086
23151
|
hasDeferredTools,
|
|
23087
23152
|
resumeSessionId: currentSessionId || resumeSessionId,
|
|
23088
23153
|
isUndo: false,
|
|
23089
|
-
resumeSessionAtUuid:
|
|
23154
|
+
resumeSessionAtUuid: nextPassthroughToolCallAssistantUuid,
|
|
23090
23155
|
forkSession: true,
|
|
23091
23156
|
sdkHooks,
|
|
23092
23157
|
blockedTools: pipelineCtx.blockedTools,
|
|
@@ -23116,7 +23181,12 @@ data: ${JSON.stringify({
|
|
|
23116
23181
|
const recoveryMessage = event;
|
|
23117
23182
|
if (recoveryMessage.session_id)
|
|
23118
23183
|
recoverySessionId = recoveryMessage.session_id;
|
|
23119
|
-
|
|
23184
|
+
if (recoveryMessage.type === "assistant") {
|
|
23185
|
+
noteAssistantMessage(recoveryEarlyStop, recoveryMessage);
|
|
23186
|
+
} else if (recoveryMessage.type === "user") {
|
|
23187
|
+
noteUserContent(recoveryEarlyStop, recoveryMessage.message?.content);
|
|
23188
|
+
recoveryToolCallAssistantUuid = settledToolCallAssistantUuid(recoveryEarlyStop);
|
|
23189
|
+
}
|
|
23120
23190
|
if (recoveryMessage.type !== "stream_event")
|
|
23121
23191
|
continue;
|
|
23122
23192
|
const lifted = recoveryLifter.lift(event.event);
|
|
@@ -23145,11 +23215,12 @@ data: ${JSON.stringify(lifted.frame)}
|
|
|
23145
23215
|
}
|
|
23146
23216
|
if (silentTurnRecovered && recoverySessionId && !isIndependentSession && !sawDuplicateToolUse) {
|
|
23147
23217
|
currentSessionId = recoverySessionId;
|
|
23148
|
-
|
|
23218
|
+
nextPassthroughToolCallAssistantUuid = recoveryToolCallAssistantUuid;
|
|
23219
|
+
nextPassthroughToolCallIds = recoveryToolCallAssistantUuid ? [...recoveryEarlyStop.expected] : undefined;
|
|
23149
23220
|
sdkUuidMap.length = 0;
|
|
23150
23221
|
for (let i = 0;i < allMessages.length; i++)
|
|
23151
23222
|
sdkUuidMap.push(null);
|
|
23152
|
-
storeSession(profileSessionId, body.messages || [], recoverySessionId, profileScopedCwd, sdkUuidMap, lastUsage,
|
|
23223
|
+
storeSession(profileSessionId, body.messages || [], recoverySessionId, profileScopedCwd, sdkUuidMap, lastUsage, recoveryToolCallAssistantUuid ?? null, recoveryToolCallAssistantUuid ? [...recoveryEarlyStop.expected] : null);
|
|
23153
23224
|
commitSessionTurn();
|
|
23154
23225
|
}
|
|
23155
23226
|
claudeLog("response.silent_turn_recovery_result", {
|
|
@@ -23327,18 +23398,19 @@ data: {"type":"message_stop"}
|
|
|
23327
23398
|
profileSessionId,
|
|
23328
23399
|
currentSessionId,
|
|
23329
23400
|
sawDuplicateToolUse,
|
|
23330
|
-
|
|
23401
|
+
toolCallAssistantUuid: nextPassthroughToolCallAssistantUuid,
|
|
23331
23402
|
passthrough
|
|
23332
23403
|
});
|
|
23333
|
-
if (disposition.action === "
|
|
23334
|
-
storeSession(profileSessionId, body.messages || [], currentSessionId, profileScopedCwd, sdkUuidMap, lastUsage, disposition.resumeUuid);
|
|
23335
|
-
commitSessionTurn();
|
|
23336
|
-
} else if (disposition.action === "evict") {
|
|
23404
|
+
if (disposition.action === "evict") {
|
|
23337
23405
|
evictSession(profileSessionId, profileScopedCwd, body.messages || []);
|
|
23338
23406
|
}
|
|
23339
23407
|
claudeLog("passthrough.client_abort_settled", { action: disposition.action });
|
|
23340
23408
|
return;
|
|
23341
23409
|
}
|
|
23410
|
+
if (passthrough && streamedToolUseIds.size > 0 && !sawCanonicalResult) {
|
|
23411
|
+
evictSession(profileSessionId, profileScopedCwd, body.messages || []);
|
|
23412
|
+
claudeLog("passthrough.noncanonical_session_evicted", { mode: "stream", reason: "drain_error" });
|
|
23413
|
+
}
|
|
23342
23414
|
const stderrOutput = stderrLines.join(`
|
|
23343
23415
|
`).trim();
|
|
23344
23416
|
if (stderrOutput && error instanceof Error && !error.message.includes(stderrOutput)) {
|
|
@@ -23366,7 +23438,7 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
23366
23438
|
reason: sdkTerm.reason,
|
|
23367
23439
|
passthrough,
|
|
23368
23440
|
capturedToolUses: capturedToolUses.length,
|
|
23369
|
-
abortIsOurs: sawDuplicateToolUse
|
|
23441
|
+
abortIsOurs: sawDuplicateToolUse
|
|
23370
23442
|
}) && messageStartEmitted;
|
|
23371
23443
|
if (canRecoverAsToolUse) {
|
|
23372
23444
|
diagnosticLog2.session(`${requestMeta.requestId} sdk_termination_recovered ${formatSdkTermination(sdkTerm, {
|
|
@@ -23549,6 +23621,10 @@ data: ${JSON.stringify({
|
|
|
23549
23621
|
cancel(reason) {
|
|
23550
23622
|
requestAbort.abort(reason);
|
|
23551
23623
|
requestAbort.detach();
|
|
23624
|
+
if (!isIndependentSession) {
|
|
23625
|
+
evictSession(profileSessionId, profileScopedCwd, body.messages || []);
|
|
23626
|
+
claudeLog("passthrough.client_abort_settled", { action: "evict", source: "stream_cancel" });
|
|
23627
|
+
}
|
|
23552
23628
|
}
|
|
23553
23629
|
});
|
|
23554
23630
|
const streamSessionId = resumeSessionId || `session_${Date.now()}`;
|
package/dist/cli.js
CHANGED
package/dist/proxy/messages.d.ts
CHANGED
|
@@ -100,34 +100,6 @@ export declare function frameReplayTurns(turns: Array<{
|
|
|
100
100
|
role: string;
|
|
101
101
|
text: string;
|
|
102
102
|
}>): string;
|
|
103
|
-
/**
|
|
104
|
-
* Lead-in for a passthrough continuation that forks from a deny boundary.
|
|
105
|
-
*
|
|
106
|
-
* Every forwarded tool call is denied with "do not generate further text —
|
|
107
|
-
* end your turn now" (the nudge that stops the model fabricating results for
|
|
108
|
-
* calls the client will execute). That deny is persisted as the tool_result,
|
|
109
|
-
* and the deny boundary fork puts it IMMEDIATELY before the continuation's
|
|
110
|
-
* user turn. So the last instruction in the model's context tells it to emit
|
|
111
|
-
* no text — and the next thing it must do is answer. Observed live: the model
|
|
112
|
-
* obeys the nearer instruction and returns thinking plus an EMPTY text block
|
|
113
|
-
* with stop_reason "end_turn"; the CLI's own "previous response had no visible
|
|
114
|
-
* output" nudge does not help, because the deny is still there. The proxy
|
|
115
|
-
* forwards zero text deltas, reports 200, and the client's run goes quiet with
|
|
116
|
-
* the tool results unanswered (three occurrences in 500 requests, all on a
|
|
117
|
-
* session's second turn — where the deny is the largest thing in context).
|
|
118
|
-
*
|
|
119
|
-
* The deny cannot be rewritten after the fact: it lives in the CLI's session
|
|
120
|
-
* file. So the continuation says plainly that the instruction is spent. Framing
|
|
121
|
-
* only — no transcript markers, nothing for the model to imitate (#496/#619).
|
|
122
|
-
*/
|
|
123
|
-
export declare const PASSTHROUGH_CONTINUATION_LEAD_IN: string;
|
|
124
|
-
/**
|
|
125
|
-
* Prefix a passthrough continuation delta with the lead-in above.
|
|
126
|
-
*
|
|
127
|
-
* An empty delta is returned unchanged — there is nothing to answer, so the
|
|
128
|
-
* lead-in would be the only content and would read as the user's own turn.
|
|
129
|
-
*/
|
|
130
|
-
export declare function framePassthroughContinuation(delta: string): string;
|
|
131
103
|
/**
|
|
132
104
|
* Remove fields the Claude Agent SDK attaches to streamed events that are not
|
|
133
105
|
* part of the public Anthropic streaming schema.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/proxy/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,wBAAwB,aAA6C,CAAA;AAElF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,aAA+C,CAAA;AAEpF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,2BAA2B,aAYtC,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAmBrD;AAED;;;;GAIG;AACH,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25 @@
|
|
|
8
8
|
* thinking pass per tool step, roughly doubling per-step output spend and
|
|
9
9
|
* adding a full model round-trip of latency.
|
|
10
10
|
*
|
|
11
|
-
* The
|
|
12
|
-
* the
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
11
|
+
* The SDK emits each denied call's tool_result as a `user` message before it
|
|
12
|
+
* fires the hidden digest turn. Those messages identify a stable assistant
|
|
13
|
+
* checkpoint, but they are NOT a durability acknowledgement: a live PTY E2E
|
|
14
|
+
* observed the assistant and deny in the iterator while neither existed in the
|
|
15
|
+
* session JSONL after an immediate abort. The proxy therefore freezes the
|
|
16
|
+
* assistant UUID/tool IDs at deny settlement, drains the hidden digest without
|
|
17
|
+
* forwarding it, and stores the checkpoint only after the SDK's canonical
|
|
18
|
+
* terminal result commits the transcript.
|
|
19
19
|
*
|
|
20
20
|
* Pure module — no I/O, no imports from server.ts or session/.
|
|
21
21
|
*/
|
|
22
22
|
export interface EarlyStopTracker {
|
|
23
|
-
/** tool_use ids of client-forwarded calls awaiting
|
|
23
|
+
/** tool_use ids of client-forwarded calls awaiting an iterator-observed deny */
|
|
24
24
|
expected: Set<string>;
|
|
25
25
|
/** subset of `expected` whose tool_result has been observed in the stream */
|
|
26
26
|
resolved: Set<string>;
|
|
27
|
+
/** Last assistant message containing a forwarded tool_use.
|
|
28
|
+
* The SDK's resumeSessionAt option only accepts assistant UUIDs. */
|
|
29
|
+
toolCallAssistantUuid?: string;
|
|
27
30
|
/** true once shouldEarlyStop has returned true — it fires at most once */
|
|
28
31
|
fired: boolean;
|
|
29
32
|
}
|
|
@@ -42,7 +45,17 @@ export declare function isClientForwardedToolUse(block: unknown): boolean;
|
|
|
42
45
|
*/
|
|
43
46
|
export declare function noteAssistantContent(tracker: EarlyStopTracker, content: unknown): void;
|
|
44
47
|
/**
|
|
45
|
-
* Record
|
|
48
|
+
* Record one SDK assistant message and remember the only boundary type the
|
|
49
|
+
* Agent SDK supports for resumeSessionAt: an SDKAssistantMessage UUID.
|
|
50
|
+
*
|
|
51
|
+
* The SDK may surface parallel tool calls as multiple assistant messages. The
|
|
52
|
+
* final such message is an ancestor containing the complete tool-use turn, so
|
|
53
|
+
* updating the boundary for every forwarded call leaves the correct stable
|
|
54
|
+
* checkpoint.
|
|
55
|
+
*/
|
|
56
|
+
export declare function noteAssistantMessage(tracker: EarlyStopTracker, message: unknown): void;
|
|
57
|
+
/**
|
|
58
|
+
* Record iterator-observed tool_results from a user message's content.
|
|
46
59
|
*
|
|
47
60
|
* Records EVERY tool_result id, not just already-expected ones: the CLI
|
|
48
61
|
* dispatches hooks per-block while later blocks are still streaming, and it
|
|
@@ -54,15 +67,25 @@ export declare function noteAssistantContent(tracker: EarlyStopTracker, content:
|
|
|
54
67
|
export declare function noteUserContent(tracker: EarlyStopTracker, content: unknown): void;
|
|
55
68
|
/**
|
|
56
69
|
* True exactly once: when at least one client tool call was forwarded and
|
|
57
|
-
* every forwarded call's deny has been observed in the stream.
|
|
58
|
-
* the
|
|
70
|
+
* every forwarded call's deny has been observed in the stream. The caller may
|
|
71
|
+
* freeze the checkpoint then, but must drain to a canonical SDK result before
|
|
72
|
+
* treating the UUID as durably resumable.
|
|
59
73
|
*/
|
|
74
|
+
export declare function allForwardedCallsResolved(tracker: EarlyStopTracker): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Verify that a resumed tool-result delta settles exactly the tool calls at the
|
|
77
|
+
* stored assistant checkpoint. Tool results must precede any ordinary user
|
|
78
|
+
* content, matching the Anthropic Messages protocol.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isCompleteToolResultContinuation(messages: Array<{
|
|
81
|
+
role?: unknown;
|
|
82
|
+
content?: unknown;
|
|
83
|
+
}>, expectedIds: readonly string[]): boolean;
|
|
84
|
+
/** The cache-stable assistant boundary after every forwarded call settled. */
|
|
85
|
+
export declare function settledToolCallAssistantUuid(tracker: EarlyStopTracker): string | undefined;
|
|
60
86
|
export declare function shouldEarlyStop(tracker: EarlyStopTracker): boolean;
|
|
61
87
|
/** What a client-aborted stream must do with its session mapping. */
|
|
62
88
|
export type ClientAbortDisposition = {
|
|
63
|
-
action: "store";
|
|
64
|
-
resumeUuid: string;
|
|
65
|
-
} | {
|
|
66
89
|
action: "evict";
|
|
67
90
|
} | {
|
|
68
91
|
action: "none";
|
|
@@ -71,39 +94,19 @@ export type ClientAbortDisposition = {
|
|
|
71
94
|
* Decide the fate of a session whose stream the CLIENT aborted (the user hit
|
|
72
95
|
* stop, or the connection dropped).
|
|
73
96
|
*
|
|
74
|
-
* A client abort leaves the SDK session ending in an interrupted tail
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* never recovers on its own: every following turn comes back empty until the
|
|
80
|
-
* lineage is discarded.
|
|
81
|
-
*
|
|
82
|
-
* An early stop is meridian's own doing and always has a persisted deny to
|
|
83
|
-
* fork from; a user interrupt is not an early stop and may have none. So:
|
|
84
|
-
*
|
|
85
|
-
* - a boundary was persisted → store it, and the next continuation forks
|
|
86
|
-
* there (lineage and prompt cache survive);
|
|
87
|
-
* - no boundary → nothing is safe to resume from, so drop the mapping and let
|
|
88
|
-
* the next request replay into a fresh SDK session. A cache-miss replay is
|
|
89
|
-
* the cost of not wedging the conversation.
|
|
90
|
-
*
|
|
91
|
-
* `sawDuplicateToolUse` keeps the #552 rule: such a history holds a dangling
|
|
92
|
-
* dropped call that diverges from the client's view and is never resumable.
|
|
97
|
+
* A client abort leaves the SDK session ending in an interrupted tail. Even an
|
|
98
|
+
* assistant UUID already seen in the iterator is not known durable until the
|
|
99
|
+
* canonical result: the live PTY regression yielded that UUID but never wrote
|
|
100
|
+
* it to JSONL after abort. Therefore every owned mapping is evicted; a replay
|
|
101
|
+
* costs one cache miss but cannot wedge on a missing or interrupted boundary.
|
|
93
102
|
*/
|
|
94
103
|
export declare function clientAbortDisposition(input: {
|
|
95
104
|
isIndependentSession: boolean;
|
|
96
105
|
profileSessionId?: string;
|
|
97
106
|
currentSessionId?: string;
|
|
98
107
|
sawDuplicateToolUse: boolean;
|
|
99
|
-
|
|
100
|
-
/** Only passthrough turns
|
|
108
|
+
toolCallAssistantUuid?: string;
|
|
109
|
+
/** Only passthrough turns create synthetic denial side branches. */
|
|
101
110
|
passthrough: boolean;
|
|
102
111
|
}): ClientAbortDisposition;
|
|
103
|
-
/**
|
|
104
|
-
* Resume boundary of an early-stopped session: the uuid of a persisted `user`
|
|
105
|
-
* message carrying tool_results. The last one before the abort is the final
|
|
106
|
-
* deny — continuations fork there instead of resuming the interrupted tail.
|
|
107
|
-
*/
|
|
108
|
-
export declare function resumeBoundaryUuid(message: unknown): string | undefined;
|
|
109
112
|
//# sourceMappingURL=passthroughEarlyStop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passthroughEarlyStop.d.ts","sourceRoot":"","sources":["../../src/proxy/passthroughEarlyStop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,MAAM,WAAW,gBAAgB;IAC/B,
|
|
1
|
+
{"version":3,"file":"passthroughEarlyStop.d.ts","sourceRoot":"","sources":["../../src/proxy/passthroughEarlyStop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACrB;yEACqE;IACrE,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,0EAA0E;IAC1E,KAAK,EAAE,OAAO,CAAA;CACf;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQhE;AAED;;GAEG;AACH,wBA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ED
|
@@ -43,8 +43,9 @@ export interface QueryContext {
|
|
|
43
43
|
resumeSessionId?: string;
|
|
44
44
|
/** Whether this is an undo operation */
|
|
45
45
|
isUndo: boolean;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
46
|
+
/** Resume at this SDK assistant-message UUID (undo rollback point or
|
|
47
|
+
* passthrough tool-use boundary). Maps to resumeSessionAt, which accepts
|
|
48
|
+
* SDKAssistantMessage UUIDs only; forkSession separately chooses a new ID. */
|
|
48
49
|
resumeSessionAtUuid?: string;
|
|
49
50
|
/** Fork the resumed session instead of attaching to it (#630 busy-session
|
|
50
51
|
* fallback — the original stays registered as a bg agent; the fork gets a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/proxy/query.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAW,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAEnG,OAAO,EAAE,0BAA0B,EAAwB,MAAM,oBAAoB,CAAA;AAErF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AA6CtC,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;IACnC,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,gBAAgB,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAA;IACrB,gCAAgC;IAChC,gBAAgB,EAAE,MAAM,CAAA;IACxB,0CAA0C;IAC1C,WAAW,EAAE,OAAO,CAAA;IACpB,0CAA0C;IAC1C,MAAM,EAAE,OAAO,CAAA;IACf,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,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../../src/proxy/server.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAGvD,YAAY,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAA;AAKpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAoDnG,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,oBAAoB,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/proxy/server.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAGvD,YAAY,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAA;AAKpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAoDnG,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EAGpB,KAAK,aAAa,EAGnB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAA+B,iBAAiB,EAAE,mBAAmB,EAAsC,MAAM,iBAAiB,CAAA;AAIzI,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,CAAA;AA0W7B,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CA28JhF;AAWD,wBAAgB,gCAAgC,IAAI,IAAI,CAavD;AAED,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAqHhG"}
|
|
@@ -33,5 +33,5 @@ export declare function getSessionByClaudeId(claudeSessionId: string): SessionSt
|
|
|
33
33
|
export declare function storeSession(sessionId: string | undefined, messages: Array<{
|
|
34
34
|
role: string;
|
|
35
35
|
content: unknown;
|
|
36
|
-
}>, claudeSessionId: string, workingDirectory?: string, sdkMessageUuids?: Array<string | null>, contextUsage?: TokenUsage,
|
|
36
|
+
}>, claudeSessionId: string, workingDirectory?: string, sdkMessageUuids?: Array<string | null>, contextUsage?: TokenUsage, passthroughToolCallAssistantUuid?: string | null, passthroughToolCallIds?: string[] | null): void;
|
|
37
37
|
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/proxy/session/cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,WAAW,CAAA;AAMlB,wBAAgB,mBAAmB,IAAI,MAAM,CAW5C;AAqCD;kGACkG;AAClG,wBAAgB,iBAAiB,SAYhC;AAED;iFACiF;AACjF,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EACzB,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,GAC/C,IAAI,CAoBN;AA0CD;;uDAEuD;AACvD,wBAAgB,aAAa,CAC3B,SA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CAAC,EAAE,MAAM,EACzB,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,EACtC,YAAY,CAAC,EAAE,UAAU,EACzB,gCAAgC,CAAC,EAAE,MAAM,GAAG,IAAI,EAChD,sBAAsB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,QA4CzC"}
|
|
@@ -43,11 +43,21 @@ export interface SessionState {
|
|
|
43
43
|
* Only assistant messages have UUIDs (user messages are null).
|
|
44
44
|
* Used to find the rollback point for undo. */
|
|
45
45
|
sdkMessageUuids?: Array<string | null>;
|
|
46
|
-
/**
|
|
47
|
-
|
|
46
|
+
/** SDK assistant UUID immediately before synthetic passthrough denials.
|
|
47
|
+
* Must be an assistant UUID: the Agent SDK rejects other resumeSessionAt boundaries. */
|
|
48
|
+
passthroughToolCallAssistantUuid?: string;
|
|
49
|
+
/** Forwarded tool IDs that must be settled together at the checkpoint. */
|
|
50
|
+
passthroughToolCallIds?: string[];
|
|
48
51
|
/** Last observed token usage for this session (from SDK message_start / message_delta events) */
|
|
49
52
|
contextUsage?: TokenUsage;
|
|
50
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Associate SDK assistant events from the current upstream run with the single
|
|
56
|
+
* assistant message the Anthropic client will append after this request.
|
|
57
|
+
* Multiple SDK fragments overwrite the same future slot, leaving the final
|
|
58
|
+
* assistant UUID as the undo checkpoint for the consolidated client turn.
|
|
59
|
+
*/
|
|
60
|
+
export declare function withClientAssistantUuid(existing: Array<string | null>, clientMessageCount: number, uuid: unknown): Array<string | null>;
|
|
51
61
|
/**
|
|
52
62
|
* Result of lineage verification — classifies the mutation and provides
|
|
53
63
|
* the information needed to take the correct SDK action.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineage.d.ts","sourceRoot":"","sources":["../../../src/proxy/session/lineage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,E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,YAAY,EACpB,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC;AAC/C;;gFAEgF;AAChF,yBAAyB,CAAC,EAAE,MAAM,EAAE,GACnC,eAAe,CAwBjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAcnF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,GAAG,MAAM,EAAE,CAG9F;AAcD,uEAAuE;AACvE,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAKrG;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,CAQ7F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,CA6B7F;AAyBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,GAC9C,aAAa,CAkKf"}
|
|
@@ -23,8 +23,11 @@ export interface StoredSession {
|
|
|
23
23
|
messageBlockHashes?: string[][];
|
|
24
24
|
/** Per-message SDK assistant UUIDs for undo rollback (null for user messages) */
|
|
25
25
|
sdkMessageUuids?: Array<string | null>;
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** SDK assistant UUID immediately before synthetic passthrough denials.
|
|
27
|
+
* Continuations resume the same session here, preserving the stable prefix. */
|
|
28
|
+
passthroughToolCallAssistantUuid?: string;
|
|
29
|
+
/** Forwarded tool IDs pending at the stored assistant checkpoint. */
|
|
30
|
+
passthroughToolCallIds?: string[];
|
|
28
31
|
/** Last observed token usage for this Claude session */
|
|
29
32
|
contextUsage?: TokenUsage;
|
|
30
33
|
/** Previous Claude session ID preserved when the session mapping is replaced.
|
|
@@ -40,7 +43,7 @@ export declare function setSessionStoreDir(dir: string | null, opts?: {
|
|
|
40
43
|
}): void;
|
|
41
44
|
export declare function lookupSharedSession(key: string): StoredSession | undefined;
|
|
42
45
|
export declare function lookupSharedSessionByClaudeId(claudeSessionId: string): StoredSession | undefined;
|
|
43
|
-
export declare function storeSharedSession(key: string, claudeSessionId: string, messageCount?: number, lineageHash?: string, messageHashes?: string[], sdkMessageUuids?: Array<string | null>, contextUsage?: TokenUsage, messageBlockHashes?: string[][],
|
|
46
|
+
export declare function storeSharedSession(key: string, claudeSessionId: string, messageCount?: number, lineageHash?: string, messageHashes?: string[], sdkMessageUuids?: Array<string | null>, contextUsage?: TokenUsage, messageBlockHashes?: string[][], passthroughToolCallAssistantUuid?: string | null, passthroughToolCallIds?: string[] | null): void;
|
|
44
47
|
/** Remove a single session from the shared file store.
|
|
45
48
|
* Used when a session is detected as stale (e.g. expired upstream). */
|
|
46
49
|
export declare function evictSharedSession(key: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionStore.d.ts","sourceRoot":"","sources":["../../src/proxy/sessionStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAeH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU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