@rynfar/meridian 1.69.0 → 1.71.0
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/README.md +1 -0
- package/dist/{cli-x1sv3bqf.js → cli-6c6dj69q.js} +309 -35
- package/dist/cli.js +1 -1
- package/dist/meridian/index.js +4 -1
- package/dist/meridian-v2/index.js +20500 -41
- package/dist/meridian-v2.js +20505 -45
- package/dist/proxy/adapters/detect.d.ts.map +1 -1
- package/dist/proxy/adapters/polytoken.d.ts +36 -0
- package/dist/proxy/adapters/polytoken.d.ts.map +1 -0
- package/dist/proxy/errors.d.ts +55 -0
- package/dist/proxy/errors.d.ts.map +1 -1
- package/dist/proxy/requestAbort.d.ts +36 -0
- package/dist/proxy/requestAbort.d.ts.map +1 -1
- package/dist/proxy/sdkFeatures.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/proxy/transforms/polytoken.d.ts +18 -0
- package/dist/proxy/transforms/polytoken.d.ts.map +1 -0
- package/dist/proxy/transforms/registry.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/plugin/meridian-v2.ts +437 -0
- package/plugin/priority-attestation.ts +11 -1
|
@@ -3338,6 +3338,93 @@ var init_cherry = __esm(() => {
|
|
|
3338
3338
|
};
|
|
3339
3339
|
});
|
|
3340
3340
|
|
|
3341
|
+
// src/proxy/transforms/polytoken.ts
|
|
3342
|
+
var polytokenTransforms;
|
|
3343
|
+
var init_polytoken = __esm(() => {
|
|
3344
|
+
polytokenTransforms = [
|
|
3345
|
+
{
|
|
3346
|
+
name: "polytoken-core",
|
|
3347
|
+
adapters: ["polytoken"],
|
|
3348
|
+
onRequest(ctx) {
|
|
3349
|
+
return {
|
|
3350
|
+
...ctx,
|
|
3351
|
+
blockedTools: [],
|
|
3352
|
+
incompatibleTools: [],
|
|
3353
|
+
allowedMcpTools: [],
|
|
3354
|
+
coreToolNames: [],
|
|
3355
|
+
passthrough: true,
|
|
3356
|
+
sdkAgents: {},
|
|
3357
|
+
sdkHooks: undefined,
|
|
3358
|
+
systemContext: ctx.systemContext,
|
|
3359
|
+
supportsThinking: true,
|
|
3360
|
+
shouldTrackFileChanges: false,
|
|
3361
|
+
extractFileChangesFromToolUse: undefined
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
];
|
|
3366
|
+
});
|
|
3367
|
+
|
|
3368
|
+
// src/proxy/adapters/polytoken.ts
|
|
3369
|
+
function normalizePolytokenSessionId(value) {
|
|
3370
|
+
const trimmed = value?.trim();
|
|
3371
|
+
return trimmed ? trimmed : undefined;
|
|
3372
|
+
}
|
|
3373
|
+
var POLYTOKEN_SESSION_HEADER = "x-polytoken-session", polytokenAdapter;
|
|
3374
|
+
var init_polytoken2 = __esm(() => {
|
|
3375
|
+
init_messages();
|
|
3376
|
+
init_polytoken();
|
|
3377
|
+
polytokenAdapter = {
|
|
3378
|
+
name: "polytoken",
|
|
3379
|
+
clientEnvironmentMayDifferFromProxy: true,
|
|
3380
|
+
getSessionId(c) {
|
|
3381
|
+
return normalizePolytokenSessionId(c.req.header(POLYTOKEN_SESSION_HEADER));
|
|
3382
|
+
},
|
|
3383
|
+
extractWorkingDirectory(_body) {
|
|
3384
|
+
return;
|
|
3385
|
+
},
|
|
3386
|
+
extractClientWorkingDirectory(_body) {
|
|
3387
|
+
return;
|
|
3388
|
+
},
|
|
3389
|
+
normalizeContent(content) {
|
|
3390
|
+
return normalizeContent(content);
|
|
3391
|
+
},
|
|
3392
|
+
getBlockedBuiltinTools() {
|
|
3393
|
+
return [];
|
|
3394
|
+
},
|
|
3395
|
+
getAgentIncompatibleTools() {
|
|
3396
|
+
return [];
|
|
3397
|
+
},
|
|
3398
|
+
getMcpServerName() {
|
|
3399
|
+
return "polytoken";
|
|
3400
|
+
},
|
|
3401
|
+
getAllowedMcpTools() {
|
|
3402
|
+
return [];
|
|
3403
|
+
},
|
|
3404
|
+
getCoreToolNames() {
|
|
3405
|
+
return [];
|
|
3406
|
+
},
|
|
3407
|
+
usesPassthrough() {
|
|
3408
|
+
return true;
|
|
3409
|
+
},
|
|
3410
|
+
supportsThinking() {
|
|
3411
|
+
return true;
|
|
3412
|
+
},
|
|
3413
|
+
shouldTrackFileChanges() {
|
|
3414
|
+
return false;
|
|
3415
|
+
},
|
|
3416
|
+
buildSdkAgents(_body, _mcpToolNames) {
|
|
3417
|
+
return {};
|
|
3418
|
+
},
|
|
3419
|
+
buildSdkHooks(_body, _sdkAgents) {
|
|
3420
|
+
return;
|
|
3421
|
+
},
|
|
3422
|
+
buildSystemContextAddendum(_body, _sdkAgents) {
|
|
3423
|
+
return "";
|
|
3424
|
+
}
|
|
3425
|
+
};
|
|
3426
|
+
});
|
|
3427
|
+
|
|
3341
3428
|
// src/proxy/adapterInstances.ts
|
|
3342
3429
|
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
|
|
3343
3430
|
import { join as join5 } from "node:path";
|
|
@@ -3429,6 +3516,10 @@ __export(exports_detect, {
|
|
|
3429
3516
|
function listAdapterNames() {
|
|
3430
3517
|
return [...new Set(Object.values(ADAPTER_MAP).map((a) => a.name))];
|
|
3431
3518
|
}
|
|
3519
|
+
function resolveDefaultAdapter() {
|
|
3520
|
+
const current = (process.env.MERIDIAN_DEFAULT_AGENT || "").toLowerCase();
|
|
3521
|
+
return ADAPTER_MAP[current] ?? openCodeAdapter;
|
|
3522
|
+
}
|
|
3432
3523
|
function isLiteLLMRequest(c) {
|
|
3433
3524
|
if ((c.req.header("user-agent") || "").startsWith("litellm/"))
|
|
3434
3525
|
return true;
|
|
@@ -3456,19 +3547,20 @@ function detectAdapter(c) {
|
|
|
3456
3547
|
}
|
|
3457
3548
|
const instances = loadAdapterInstances();
|
|
3458
3549
|
const instanceNames = Object.keys(instances);
|
|
3459
|
-
if (instanceNames.length > 0) {
|
|
3460
|
-
|
|
3461
|
-
|
|
3550
|
+
if (instanceNames.length > 0 && agentOverride && instances[agentOverride]) {
|
|
3551
|
+
const inst = makeInstanceAdapter(agentOverride, instances[agentOverride]);
|
|
3552
|
+
if (inst)
|
|
3553
|
+
return inst;
|
|
3554
|
+
}
|
|
3555
|
+
if (normalizePolytokenSessionId(c.req.header("x-polytoken-session"))) {
|
|
3556
|
+
return polytokenAdapter;
|
|
3557
|
+
}
|
|
3558
|
+
for (const name of instanceNames) {
|
|
3559
|
+
if (matchesInstance(instances[name], (h) => c.req.header(h))) {
|
|
3560
|
+
const inst = makeInstanceAdapter(name, instances[name]);
|
|
3462
3561
|
if (inst)
|
|
3463
3562
|
return inst;
|
|
3464
3563
|
}
|
|
3465
|
-
for (const name of instanceNames) {
|
|
3466
|
-
if (matchesInstance(instances[name], (h) => c.req.header(h))) {
|
|
3467
|
-
const inst = makeInstanceAdapter(name, instances[name]);
|
|
3468
|
-
if (inst)
|
|
3469
|
-
return inst;
|
|
3470
|
-
}
|
|
3471
|
-
}
|
|
3472
3564
|
}
|
|
3473
3565
|
if (c.req.header("x-opencode-session")) {
|
|
3474
3566
|
return openCodeAdapter;
|
|
@@ -3486,6 +3578,9 @@ function detectAdapter(c) {
|
|
|
3486
3578
|
if (userAgent.startsWith("Charm-Crush/")) {
|
|
3487
3579
|
return crushAdapter;
|
|
3488
3580
|
}
|
|
3581
|
+
if (/^Polytoken(?:[\s/]|$)/.test(userAgent)) {
|
|
3582
|
+
return polytokenAdapter;
|
|
3583
|
+
}
|
|
3489
3584
|
if (c.req.header("x-session-affinity")) {
|
|
3490
3585
|
return openCodeAdapter;
|
|
3491
3586
|
}
|
|
@@ -3499,9 +3594,9 @@ function detectAdapter(c) {
|
|
|
3499
3594
|
if (isLiteLLMRequest(c)) {
|
|
3500
3595
|
return passthroughAdapter;
|
|
3501
3596
|
}
|
|
3502
|
-
return
|
|
3597
|
+
return resolveDefaultAdapter();
|
|
3503
3598
|
}
|
|
3504
|
-
var ADAPTER_MAP, envDefault
|
|
3599
|
+
var ADAPTER_MAP, envDefault;
|
|
3505
3600
|
var init_detect = __esm(() => {
|
|
3506
3601
|
init_opencode2();
|
|
3507
3602
|
init_droid2();
|
|
@@ -3515,6 +3610,7 @@ var init_detect = __esm(() => {
|
|
|
3515
3610
|
init_jcode();
|
|
3516
3611
|
init_codex();
|
|
3517
3612
|
init_cherry();
|
|
3613
|
+
init_polytoken2();
|
|
3518
3614
|
init_adapterInstances();
|
|
3519
3615
|
ADAPTER_MAP = {
|
|
3520
3616
|
opencode: openCodeAdapter,
|
|
@@ -3529,6 +3625,7 @@ var init_detect = __esm(() => {
|
|
|
3529
3625
|
claudecode: claudeCodeAdapter,
|
|
3530
3626
|
cherry: cherryAdapter,
|
|
3531
3627
|
cherrystudio: cherryAdapter,
|
|
3628
|
+
polytoken: polytokenAdapter,
|
|
3532
3629
|
openai: openAiAdapter,
|
|
3533
3630
|
jcode: jcodeAdapter,
|
|
3534
3631
|
codex: codexAdapter
|
|
@@ -3537,7 +3634,6 @@ var init_detect = __esm(() => {
|
|
|
3537
3634
|
if (envDefault && !ADAPTER_MAP[envDefault]) {
|
|
3538
3635
|
console.warn(`[meridian] Unknown MERIDIAN_DEFAULT_AGENT="${envDefault}". ` + `Valid values: ${Object.keys(ADAPTER_MAP).join(", ")}. Falling back to opencode.`);
|
|
3539
3636
|
}
|
|
3540
|
-
defaultAdapter = ADAPTER_MAP[envDefault] ?? openCodeAdapter;
|
|
3541
3637
|
});
|
|
3542
3638
|
|
|
3543
3639
|
// src/proxy/sdkFeatures.ts
|
|
@@ -3693,6 +3789,14 @@ var init_sdkFeatures = __esm(() => {
|
|
|
3693
3789
|
},
|
|
3694
3790
|
codex: {
|
|
3695
3791
|
codeSystemPrompt: false
|
|
3792
|
+
},
|
|
3793
|
+
polytoken: {
|
|
3794
|
+
codeSystemPrompt: false,
|
|
3795
|
+
clientSystemPrompt: true,
|
|
3796
|
+
claudeMd: "off",
|
|
3797
|
+
memory: false,
|
|
3798
|
+
dreaming: false,
|
|
3799
|
+
sharedMemory: false
|
|
3696
3800
|
}
|
|
3697
3801
|
};
|
|
3698
3802
|
VALID_CLAUDE_MD_VALUES = new Set(["off", "project", "full"]);
|
|
@@ -6766,6 +6870,13 @@ function ordinalSuffix(n) {
|
|
|
6766
6870
|
function linkRequestAbort(signal) {
|
|
6767
6871
|
const controller = new AbortController;
|
|
6768
6872
|
let attached = false;
|
|
6873
|
+
const linkedAt = Date.now();
|
|
6874
|
+
let cause;
|
|
6875
|
+
const classify = () => {
|
|
6876
|
+
if (!controller.signal.aborted)
|
|
6877
|
+
return "none";
|
|
6878
|
+
return cause ?? "unknown_abort";
|
|
6879
|
+
};
|
|
6769
6880
|
const abort = (reason) => {
|
|
6770
6881
|
if (!controller.signal.aborted)
|
|
6771
6882
|
controller.abort(reason);
|
|
@@ -6785,6 +6896,19 @@ function linkRequestAbort(signal) {
|
|
|
6785
6896
|
return;
|
|
6786
6897
|
signal.removeEventListener("abort", forwardAbort);
|
|
6787
6898
|
attached = false;
|
|
6899
|
+
},
|
|
6900
|
+
setCause: (labeled) => {
|
|
6901
|
+
cause ??= labeled;
|
|
6902
|
+
},
|
|
6903
|
+
abortSnapshot: () => {
|
|
6904
|
+
const snapshot = {
|
|
6905
|
+
cause: classify(),
|
|
6906
|
+
aborted: controller.signal.aborted
|
|
6907
|
+
};
|
|
6908
|
+
if (controller.signal.aborted) {
|
|
6909
|
+
snapshot.elapsedMs = Math.max(0, Date.now() - linkedAt);
|
|
6910
|
+
}
|
|
6911
|
+
return snapshot;
|
|
6788
6912
|
}
|
|
6789
6913
|
};
|
|
6790
6914
|
}
|
|
@@ -23563,6 +23687,7 @@ var BILLING_SIGNALS = [
|
|
|
23563
23687
|
/^\s*(?:(?:error|api error|claude code returned an error result):\s*)*credit balance is too low[.!]?\s*$/m,
|
|
23564
23688
|
/^\s*(?:(?:error|api error|claude code returned an error result|subprocess stderr):\s*)*your (?:group|organization|org)(?:'|’)s usage limit is set to \$\d/m
|
|
23565
23689
|
];
|
|
23690
|
+
var SUBSCRIPTION_ACCESS_DISABLED = /^\s*(?:(?:error|api error|claude code returned an error result|subprocess stderr):\s*|failed to authenticate\.\s*)*(?:\d{3} )?your (?:organization|org) has disabled claude subscription access/m;
|
|
23566
23691
|
var HIT_YOUR_LIMIT = /hit your (?:[\w-]+ )?limit/;
|
|
23567
23692
|
var HIT_YOUR_SPEND_LIMIT = /^\s*(?:(?:error|api error|claude code returned an error result|subprocess stderr):\s*)*you(?:'|’)ve hit your (?:[\w'’-]+ ){0,4}(?:spend|usage) limit/m;
|
|
23568
23693
|
var REACHED_YOUR_TIER_LIMIT = /^[ \t]*(?:(?:error|api error|claude code returned an error result|subprocess stderr):[ \t]*)*(?:\d{3}[ \t]+)?you(?:'|’)ve reached your (?:claude )?(?:fable|mythos|opus|sonnet|haiku)(?: \d+(?:\.\d+)*)? limit(?:(?:[.!][ \t]+|[ \t]+)(?:(?:run[ \t]+)?\/usage-credits(?:[ \t]+to[ \t]+continue)?(?:[ \t]+or[ \t]+switch[ \t]+models[ \t]+with[ \t]+\/model)?|\/model[ \t]+to[ \t]+switch[ \t]+models|switch[ \t]+to[ \t]+another[ \t]+model(?:[ \t]+to[ \t]+continue)?)\.?|[.!]?)[ \t\r]*$/m;
|
|
@@ -23591,6 +23716,13 @@ function classifyError(errMsg, model) {
|
|
|
23591
23716
|
message: "Claude OAuth token has expired and could not be refreshed automatically. Run 'claude login' in your terminal to re-authenticate."
|
|
23592
23717
|
};
|
|
23593
23718
|
}
|
|
23719
|
+
if (SUBSCRIPTION_ACCESS_DISABLED.test(lower)) {
|
|
23720
|
+
return {
|
|
23721
|
+
status: 402,
|
|
23722
|
+
type: "billing_error",
|
|
23723
|
+
message: "This account's organization has disabled Claude subscription access for Claude Code. Ask the organization admin to re-enable it, or serve this request from an API-key profile — an identical retry on this account fails the same way."
|
|
23724
|
+
};
|
|
23725
|
+
}
|
|
23594
23726
|
if (HTTP_401.test(lower) || lower.includes("authentication") || lower.includes("invalid auth") || lower.includes("credentials")) {
|
|
23595
23727
|
return {
|
|
23596
23728
|
status: 401,
|
|
@@ -23761,6 +23893,45 @@ function canRecoverCapturedToolUses(input) {
|
|
|
23761
23893
|
return false;
|
|
23762
23894
|
}
|
|
23763
23895
|
}
|
|
23896
|
+
function isStreamedToolBlockComplete(record2) {
|
|
23897
|
+
if (!record2.forwardedStart)
|
|
23898
|
+
return false;
|
|
23899
|
+
if (!record2.naturalStop)
|
|
23900
|
+
return false;
|
|
23901
|
+
if (record2.startedInputObject)
|
|
23902
|
+
return true;
|
|
23903
|
+
if (!record2.json.trim())
|
|
23904
|
+
return false;
|
|
23905
|
+
try {
|
|
23906
|
+
const parsed = JSON.parse(record2.json);
|
|
23907
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed);
|
|
23908
|
+
} catch {
|
|
23909
|
+
return false;
|
|
23910
|
+
}
|
|
23911
|
+
}
|
|
23912
|
+
function canRecoverUncapturedToolUses(input) {
|
|
23913
|
+
if (!input.uncapturedRecoveryEnabled)
|
|
23914
|
+
return false;
|
|
23915
|
+
if (!input.passthrough)
|
|
23916
|
+
return false;
|
|
23917
|
+
if (input.reason !== "max_turns")
|
|
23918
|
+
return false;
|
|
23919
|
+
if (input.attemptedMaxTurns !== 1)
|
|
23920
|
+
return false;
|
|
23921
|
+
if (input.capturedToolUses > 0)
|
|
23922
|
+
return false;
|
|
23923
|
+
if (input.streamedToolUses <= 0)
|
|
23924
|
+
return false;
|
|
23925
|
+
if (input.droppedToolUseIds > 0)
|
|
23926
|
+
return false;
|
|
23927
|
+
if (input.sawDuplicateToolUse)
|
|
23928
|
+
return false;
|
|
23929
|
+
if (input.forceSingleToolUse)
|
|
23930
|
+
return false;
|
|
23931
|
+
if (input.earlyStopFired)
|
|
23932
|
+
return false;
|
|
23933
|
+
return true;
|
|
23934
|
+
}
|
|
23764
23935
|
function extractSdkTermination(errMsg) {
|
|
23765
23936
|
const stderrTail = extractStderrTail(errMsg);
|
|
23766
23937
|
const haystack = `${errMsg}
|
|
@@ -23825,6 +23996,9 @@ function formatSdkTermination(t, ctx) {
|
|
|
23825
23996
|
parts.push(`deferred=${ctx.hasDeferredTools}`);
|
|
23826
23997
|
if (ctx.sdkSessionId)
|
|
23827
23998
|
parts.push(`session=${ctx.sdkSessionId.slice(0, 8)}`);
|
|
23999
|
+
if (ctx.abort) {
|
|
24000
|
+
parts.push(`abort=${ctx.abort.cause}`);
|
|
24001
|
+
}
|
|
23828
24002
|
if (t.rawTail)
|
|
23829
24003
|
parts.push(`raw=${JSON.stringify(t.rawTail)}`);
|
|
23830
24004
|
if (t.stderrTail)
|
|
@@ -31905,6 +32079,7 @@ var claudeCodeTransforms = [
|
|
|
31905
32079
|
];
|
|
31906
32080
|
|
|
31907
32081
|
// src/proxy/transforms/registry.ts
|
|
32082
|
+
init_polytoken();
|
|
31908
32083
|
var ADAPTER_TRANSFORMS = {
|
|
31909
32084
|
opencode: openCodeTransforms,
|
|
31910
32085
|
crush: crushTransforms,
|
|
@@ -31917,7 +32092,8 @@ var ADAPTER_TRANSFORMS = {
|
|
|
31917
32092
|
"claude-code": claudeCodeTransforms,
|
|
31918
32093
|
openai: openCodeTransforms,
|
|
31919
32094
|
jcode: openCodeTransforms,
|
|
31920
|
-
codex: [...openCodeTransforms, ...codexTransforms]
|
|
32095
|
+
codex: [...openCodeTransforms, ...codexTransforms],
|
|
32096
|
+
polytoken: polytokenTransforms
|
|
31921
32097
|
};
|
|
31922
32098
|
function getAdapterTransforms(adapterName) {
|
|
31923
32099
|
return ADAPTER_TRANSFORMS[adapterName] ?? [];
|
|
@@ -36811,6 +36987,7 @@ function createProxyServer(config2 = {}) {
|
|
|
36811
36987
|
let durableWritesRevoked = false;
|
|
36812
36988
|
let inFlightRequests = 0;
|
|
36813
36989
|
const activeRequestAborts = new Set;
|
|
36990
|
+
const activeShutdownLabels = new Map;
|
|
36814
36991
|
const internalHopToken = randomUUID6();
|
|
36815
36992
|
const errorEnvelope = (shape, type, message) => shape === "anthropic" ? { type: "error", error: { type, message } } : { error: { type, message, code: null } };
|
|
36816
36993
|
const DRAIN_MESSAGE = "Meridian is shutting down and is not accepting new requests. Retry against another instance.";
|
|
@@ -37102,6 +37279,7 @@ function createProxyServer(config2 = {}) {
|
|
|
37102
37279
|
body: options.body,
|
|
37103
37280
|
forcedProfileId: candidate,
|
|
37104
37281
|
turnWatchdogSignal: options.turnWatchdogSignal,
|
|
37282
|
+
requestAbortLink: options.requestAbortLink,
|
|
37105
37283
|
forceFreshPriorityReplay: priorityPublication !== undefined && (options.durableRoute?.forceFreshReplay === true || options.currentProfileId !== undefined && candidate !== options.currentProfileId),
|
|
37106
37284
|
priorityPublication,
|
|
37107
37285
|
priorityAttemptExposure: exposure
|
|
@@ -37179,7 +37357,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
37179
37357
|
const handleMessages = async (c, requestMeta, options) => {
|
|
37180
37358
|
const requestStartAt = requestMeta.queueEnteredAt;
|
|
37181
37359
|
const requestSignal = options.turnWatchdogSignal ? AbortSignal.any([c.req.raw.signal, options.turnWatchdogSignal]) : c.req.raw.signal;
|
|
37182
|
-
const requestAbort = linkRequestAbort(requestSignal);
|
|
37360
|
+
const requestAbort = options.requestAbortLink ?? linkRequestAbort(requestSignal);
|
|
37183
37361
|
let streamOwnsAbortLink = false;
|
|
37184
37362
|
return withClaudeLogContext({ requestId: requestMeta.requestId, endpoint: requestMeta.endpoint }, async () => {
|
|
37185
37363
|
const adapter = detectAdapter(c);
|
|
@@ -37514,6 +37692,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
37514
37692
|
wantsStream: body.stream === true,
|
|
37515
37693
|
currentProfileId: assignedProfile,
|
|
37516
37694
|
turnWatchdogSignal: options.turnWatchdogSignal,
|
|
37695
|
+
requestAbortLink: options.requestAbortLink,
|
|
37517
37696
|
publicationTurn,
|
|
37518
37697
|
claimTurn: trustedTurn,
|
|
37519
37698
|
durableRoute
|
|
@@ -37525,7 +37704,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
37525
37704
|
resolvedProfileId = profile.id;
|
|
37526
37705
|
const authStatus = await getClaudeAuthStatusAsync(profile.id !== "default" ? profile.id : undefined, Object.keys(profile.env).length > 0 ? profile.env : undefined);
|
|
37527
37706
|
const requestSource = c.req.header("x-meridian-source")?.slice(0, 64) || undefined;
|
|
37528
|
-
const declaredAgentMode = adapter.getAgentMode?.(c, body) ?? c.req.header("x-opencode-agent-mode") ?? null;
|
|
37707
|
+
const declaredAgentMode = adapter.getAgentMode?.(c, body) ?? (adapter.baseName === "polytoken" || adapter.name === "polytoken" ? undefined : c.req.header("x-opencode-agent-mode")) ?? null;
|
|
37529
37708
|
const isSubagentRequest = declaredAgentMode === "subagent" || requestSource?.startsWith("subagent-") === true;
|
|
37530
37709
|
const agentMode = isSubagentRequest ? "subagent" : declaredAgentMode;
|
|
37531
37710
|
const requestedModel = typeof body.model === "string" ? body.model : "sonnet";
|
|
@@ -37576,9 +37755,10 @@ data: ${JSON.stringify(lastError)}
|
|
|
37576
37755
|
workingDirectory
|
|
37577
37756
|
}), adapterBase);
|
|
37578
37757
|
const stream3 = pipelineCtx.prefersStreaming !== undefined ? pipelineCtx.prefersStreaming : body.stream ?? false;
|
|
37579
|
-
const
|
|
37580
|
-
const
|
|
37581
|
-
const
|
|
37758
|
+
const isPolytokenBase = adapterBase === "polytoken";
|
|
37759
|
+
const effortHeader = isPolytokenBase ? undefined : c.req.header("x-opencode-effort");
|
|
37760
|
+
const thinkingHeader = isPolytokenBase ? undefined : c.req.header("x-opencode-thinking");
|
|
37761
|
+
const taskBudgetHeader = isPolytokenBase ? undefined : c.req.header("x-opencode-task-budget");
|
|
37582
37762
|
const rawBetaHeader = c.req.header("anthropic-beta");
|
|
37583
37763
|
const betaFilter = filterBetasForProfile(rawBetaHeader, profile.type, getBetaPolicyFromEnv());
|
|
37584
37764
|
if (betaFilter.stripped.length > 0) {
|
|
@@ -37733,7 +37913,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
37733
37913
|
const trailingSystemReminderOptions = adapterBase === "claude-code" ? { allowTrailingSystemReminder: true } : undefined;
|
|
37734
37914
|
const durableCheckpointContinuation = durableCheckpointIds?.length && durableMappingAtTurn.status === "found" && matchesStoredLineagePrefix(durableMappingAtTurn.session, lineageMessages) ? coalesceCompleteToolResultContinuation((body.messages || []).slice(durableMappingAtTurn.session.messageCount), durableCheckpointIds, trailingSystemReminderOptions) : undefined;
|
|
37735
37915
|
const advancesDurableCheckpoint = Boolean(durableCheckpointContinuation);
|
|
37736
|
-
const passthrough = adapter.instancePassthrough !== undefined ? adapter.instancePassthrough : pipelineCtx.passthrough !== undefined ? pipelineCtx.passthrough : envBool("PASSTHROUGH");
|
|
37916
|
+
const passthrough = adapterBase === "polytoken" ? true : adapter.instancePassthrough !== undefined ? adapter.instancePassthrough : pipelineCtx.passthrough !== undefined ? pipelineCtx.passthrough : envBool("PASSTHROUGH");
|
|
37737
37917
|
if (advancesDurableCheckpoint && lineageResult.type !== "continuation" && lineageResult.type !== "compaction" && durableMappingAtTurn.status === "found") {
|
|
37738
37918
|
const checkpointSession = getSessionByClaudeId(durableMappingAtTurn.session.claudeSessionId);
|
|
37739
37919
|
if (checkpointSession) {
|
|
@@ -38174,7 +38354,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
38174
38354
|
}
|
|
38175
38355
|
const clientTool = requestTools.find((t) => t.name === toolName);
|
|
38176
38356
|
let toolInput = normalizeToolInput(input.tool_input, clientTool?.input_schema);
|
|
38177
|
-
if (toolName.toLowerCase() === "task" && toolInput?.subagent_type && typeof toolInput.subagent_type === "string") {
|
|
38357
|
+
if (adapterBase !== "polytoken" && toolName.toLowerCase() === "task" && toolInput?.subagent_type && typeof toolInput.subagent_type === "string") {
|
|
38178
38358
|
toolInput = { ...toolInput, subagent_type: resolveAgentAlias(toolInput.subagent_type, validAgentNames) };
|
|
38179
38359
|
}
|
|
38180
38360
|
const signature = toolUseSignature(toolName, toolInput);
|
|
@@ -38195,6 +38375,7 @@ data: ${JSON.stringify(lastError)}
|
|
|
38195
38375
|
name: toolName,
|
|
38196
38376
|
reason: exceedsForcedSingle ? "forced_single" : "same_tool_repeat"
|
|
38197
38377
|
});
|
|
38378
|
+
requestAbort.setCause("passthrough_single_step");
|
|
38198
38379
|
requestAbort.abort("passthrough single-step complete");
|
|
38199
38380
|
} else {
|
|
38200
38381
|
capturedSignatures.add(signature);
|
|
@@ -38765,7 +38946,8 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
38765
38946
|
requestSource,
|
|
38766
38947
|
isResume,
|
|
38767
38948
|
hasDeferredTools,
|
|
38768
|
-
sdkSessionId: currentSessionId || resumeSessionId
|
|
38949
|
+
sdkSessionId: currentSessionId || resumeSessionId,
|
|
38950
|
+
abort: requestAbort.abortSnapshot()
|
|
38769
38951
|
})} captured=${capturedToolUses.length}`, requestMeta.requestId);
|
|
38770
38952
|
claudeLog("passthrough.max_turns_recovered", {
|
|
38771
38953
|
mode: "non_stream",
|
|
@@ -39050,11 +39232,14 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
39050
39232
|
let nextPassthroughToolCallAssistantUuid;
|
|
39051
39233
|
let nextPassthroughToolCallIds;
|
|
39052
39234
|
let sawCanonicalResult = false;
|
|
39235
|
+
const uncapturedToolRecoveryEnabled = env("PASSTHROUGH_UNCAPTURED_TOOL_RECOVERY") === "1";
|
|
39236
|
+
const streamedToolBlockRecords = new Map;
|
|
39053
39237
|
const silentTurnRecoveryEnabled = env("SILENT_TURN_RECOVERY") !== "0";
|
|
39054
39238
|
let silentTurnRecoveryAttempted = false;
|
|
39055
39239
|
let silentTurnRecovered = false;
|
|
39056
39240
|
const streamedToolUseIds = new Set;
|
|
39057
39241
|
let pendingTerminalDelta = null;
|
|
39242
|
+
let lastAttemptMaxTurns;
|
|
39058
39243
|
let pendingStructuredFrames = [];
|
|
39059
39244
|
let pendingStructuredTextLength = 0;
|
|
39060
39245
|
let terminalDeltaSent = false;
|
|
@@ -39086,7 +39271,7 @@ data: ${JSON.stringify({
|
|
|
39086
39271
|
try {
|
|
39087
39272
|
const clientTool = requestTools.find((tool2) => tool2.name === buffered.name);
|
|
39088
39273
|
const parsed = normalizeToolInput(JSON.parse(buffered.json), clientTool?.input_schema);
|
|
39089
|
-
if (buffered.name.toLowerCase() === "task" && typeof parsed?.subagent_type === "string") {
|
|
39274
|
+
if (adapterBase !== "polytoken" && buffered.name.toLowerCase() === "task" && typeof parsed?.subagent_type === "string") {
|
|
39090
39275
|
parsed.subagent_type = resolveAgentAlias(parsed.subagent_type, validAgentNames);
|
|
39091
39276
|
}
|
|
39092
39277
|
fixed = JSON.stringify(parsed);
|
|
@@ -39198,6 +39383,7 @@ data: ${JSON.stringify({ type: "content_block_stop", index: idx })}
|
|
|
39198
39383
|
advisorModel
|
|
39199
39384
|
}, requestAbort.controller);
|
|
39200
39385
|
attemptMaxTurns = attemptQuery.options.maxTurns;
|
|
39386
|
+
lastAttemptMaxTurns = attemptMaxTurns;
|
|
39201
39387
|
for await (const event of runSdkQueryAttempt(attemptQuery, requestAbort.controller.signal, requestMeta, "stream", managedSdkAttemptLocators())) {
|
|
39202
39388
|
if (event.type === "rate_limit_event") {
|
|
39203
39389
|
rateLimitStore.record(profile.id, event.rate_limit_info);
|
|
@@ -39645,6 +39831,9 @@ data: ${JSON.stringify({ type: "content_block_stop", index: idx })}
|
|
|
39645
39831
|
if (eventType === "content_block_stop") {
|
|
39646
39832
|
flushToolArguments(clientIdx);
|
|
39647
39833
|
passthroughToolBlockNames.delete(eventIndex);
|
|
39834
|
+
const record3 = streamedToolBlockRecords.get(clientIdx);
|
|
39835
|
+
if (record3)
|
|
39836
|
+
record3.naturalStop = true;
|
|
39648
39837
|
}
|
|
39649
39838
|
}
|
|
39650
39839
|
if (eventType === "content_block_delta" && event.delta?.type === "text_delta" && shouldInjectSilentTurn({
|
|
@@ -39678,6 +39867,34 @@ data: ${JSON.stringify(event)}
|
|
|
39678
39867
|
if (typeof idx === "number")
|
|
39679
39868
|
openClientBlocks.delete(idx);
|
|
39680
39869
|
}
|
|
39870
|
+
if (passthrough && uncapturedToolRecoveryEnabled) {
|
|
39871
|
+
const clientIdx = eventIndex !== undefined ? sdkToClientIndex.get(eventIndex) ?? eventIndex : undefined;
|
|
39872
|
+
if (clientIdx !== undefined) {
|
|
39873
|
+
if (eventType === "content_block_start") {
|
|
39874
|
+
const block = event.content_block;
|
|
39875
|
+
if (block?.type === "tool_use" && typeof block?.id === "string" && block.id) {
|
|
39876
|
+
streamedToolBlockRecords.set(clientIdx, {
|
|
39877
|
+
id: block.id,
|
|
39878
|
+
name: block.name,
|
|
39879
|
+
json: "",
|
|
39880
|
+
startedInputObject: block.input !== undefined && block.input !== null,
|
|
39881
|
+
forwardedStart: true,
|
|
39882
|
+
naturalStop: false
|
|
39883
|
+
});
|
|
39884
|
+
}
|
|
39885
|
+
} else if (eventType === "content_block_delta") {
|
|
39886
|
+
const delta = event.delta;
|
|
39887
|
+
const record3 = streamedToolBlockRecords.get(clientIdx);
|
|
39888
|
+
if (record3 && delta?.type === "input_json_delta" && typeof delta.partial_json === "string") {
|
|
39889
|
+
record3.json += delta.partial_json;
|
|
39890
|
+
}
|
|
39891
|
+
} else if (eventType === "content_block_stop") {
|
|
39892
|
+
const record3 = streamedToolBlockRecords.get(clientIdx);
|
|
39893
|
+
if (record3)
|
|
39894
|
+
record3.naturalStop = true;
|
|
39895
|
+
}
|
|
39896
|
+
}
|
|
39897
|
+
}
|
|
39681
39898
|
if (passthrough && eventType === "message_delta" && event.delta?.stop_reason === "tool_use" && streamedToolUseIds.size > 0) {
|
|
39682
39899
|
flushOpenClientBlocks("drain_close");
|
|
39683
39900
|
if (earlyStopEnabled) {
|
|
@@ -40354,8 +40571,40 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
40354
40571
|
capturedToolUses: capturedToolUses.length,
|
|
40355
40572
|
abortIsOurs: sawDuplicateToolUse
|
|
40356
40573
|
}) && messageStartEmitted;
|
|
40574
|
+
const uncapturedEligible = (() => {
|
|
40575
|
+
if (!canRecoverUncapturedToolUses({
|
|
40576
|
+
reason: sdkTerm.reason,
|
|
40577
|
+
passthrough,
|
|
40578
|
+
capturedToolUses: capturedToolUses.length,
|
|
40579
|
+
streamedToolUses: streamedToolUseIds.size,
|
|
40580
|
+
droppedToolUseIds: droppedToolUseIds.size,
|
|
40581
|
+
sawDuplicateToolUse,
|
|
40582
|
+
forceSingleToolUse,
|
|
40583
|
+
earlyStopFired,
|
|
40584
|
+
uncapturedRecoveryEnabled: uncapturedToolRecoveryEnabled,
|
|
40585
|
+
attemptedMaxTurns: lastAttemptMaxTurns
|
|
40586
|
+
}))
|
|
40587
|
+
return false;
|
|
40588
|
+
if (!messageStartEmitted || streamClosed || pendingTerminalDelta)
|
|
40589
|
+
return false;
|
|
40590
|
+
if (durableWritesRevoked)
|
|
40591
|
+
return false;
|
|
40592
|
+
if (requestAbort.abortSnapshot().aborted)
|
|
40593
|
+
return false;
|
|
40594
|
+
for (const record3 of streamedToolBlockRecords.values()) {
|
|
40595
|
+
if (!isStreamedToolBlockComplete(record3))
|
|
40596
|
+
return false;
|
|
40597
|
+
const declared = requestTools.some((t) => t.name === record3.name);
|
|
40598
|
+
if (!declared)
|
|
40599
|
+
return false;
|
|
40600
|
+
}
|
|
40601
|
+
if (streamedToolBlockRecords.size !== streamedToolUseIds.size)
|
|
40602
|
+
return false;
|
|
40603
|
+
return true;
|
|
40604
|
+
})();
|
|
40605
|
+
const uncapturedRecoveryActive = uncapturedEligible;
|
|
40357
40606
|
const recoverableCheckpoint = canRecoverAsToolUse && sdkTerm.reason === "max_turns" && Boolean(currentSessionId) && Boolean(nextPassthroughToolCallAssistantUuid) && Boolean(nextPassthroughToolCallIds?.length) && earlyStopFired && !isIndependentSession && !sawDuplicateToolUse;
|
|
40358
|
-
const mustEvictBeforeRecoveredTerminal = !isIndependentSession && canRecoverAsToolUse && !recoverableCheckpoint;
|
|
40607
|
+
const mustEvictBeforeRecoveredTerminal = !isIndependentSession && canRecoverAsToolUse && !recoverableCheckpoint || !isIndependentSession && uncapturedRecoveryActive && !recoverableCheckpoint;
|
|
40359
40608
|
if (mustEvictBeforeRecoveredTerminal || !isIndependentSession && passthrough && streamedToolUseIds.size > 0 && !sawCanonicalResult && !recoverableCheckpoint) {
|
|
40360
40609
|
const evicted = evictSession2(profileSessionId, profileScopedCwd, lineageMessages, mappingExpectedGeneration);
|
|
40361
40610
|
if (mustEvictBeforeRecoveredTerminal && !evicted) {
|
|
@@ -40363,15 +40612,16 @@ Subprocess stderr: ${stderrOutput}`;
|
|
|
40363
40612
|
}
|
|
40364
40613
|
claudeLog("passthrough.noncanonical_session_evicted", { mode: "stream", reason: "drain_error" });
|
|
40365
40614
|
}
|
|
40366
|
-
if (canRecoverAsToolUse) {
|
|
40615
|
+
if (canRecoverAsToolUse || uncapturedRecoveryActive) {
|
|
40367
40616
|
idleStalls.clear(idleStallSessionKey);
|
|
40368
|
-
diagnosticLog2.session(`${requestMeta.requestId} sdk_termination_recovered ${formatSdkTermination(sdkTerm, {
|
|
40617
|
+
diagnosticLog2.session(`${requestMeta.requestId} sdk_termination_recovered${uncapturedRecoveryActive ? "_uncaptured" : ""} ${formatSdkTermination(sdkTerm, {
|
|
40369
40618
|
model,
|
|
40370
40619
|
requestSource,
|
|
40371
40620
|
isResume,
|
|
40372
40621
|
hasDeferredTools,
|
|
40373
|
-
sdkSessionId: currentSessionId || resumeSessionId
|
|
40374
|
-
|
|
40622
|
+
sdkSessionId: currentSessionId || resumeSessionId,
|
|
40623
|
+
abort: requestAbort.abortSnapshot()
|
|
40624
|
+
})} captured=${capturedToolUses.length}${uncapturedRecoveryActive ? ` completed=${streamedToolBlockRecords.size}` : ""}`, requestMeta.requestId);
|
|
40375
40625
|
flushOpenClientBlocks("recovery");
|
|
40376
40626
|
const unseenToolUses = capturedToolUses.filter((tu) => !streamedToolUseIds.has(tu.id));
|
|
40377
40627
|
for (let i = 0;i < unseenToolUses.length; i++) {
|
|
@@ -40512,7 +40762,8 @@ data: {"type":"message_stop"}
|
|
|
40512
40762
|
requestSource,
|
|
40513
40763
|
isResume,
|
|
40514
40764
|
hasDeferredTools,
|
|
40515
|
-
sdkSessionId: currentSessionId || resumeSessionId
|
|
40765
|
+
sdkSessionId: currentSessionId || resumeSessionId,
|
|
40766
|
+
abort: requestAbort.abortSnapshot()
|
|
40516
40767
|
})} blocks=${nextClientBlockIndex}`, requestMeta.requestId);
|
|
40517
40768
|
claudeLog("passthrough.capped_turn_truncated", {
|
|
40518
40769
|
mode: "stream",
|
|
@@ -40585,7 +40836,8 @@ data: {"type":"message_stop"}
|
|
|
40585
40836
|
requestSource,
|
|
40586
40837
|
isResume,
|
|
40587
40838
|
hasDeferredTools,
|
|
40588
|
-
sdkSessionId: currentSessionId || resumeSessionId
|
|
40839
|
+
sdkSessionId: currentSessionId || resumeSessionId,
|
|
40840
|
+
abort: requestAbort.abortSnapshot()
|
|
40589
40841
|
})} envelope=${messageStartEmitted ? "open" : "unopened"} blocks=${contentBlocksForwarded} ` + `text=${textEventsForwarded} tools=${capturedToolUses.length}/${streamedToolUseIds.size}`, requestMeta.requestId);
|
|
40590
40842
|
const streamErrTotalMs = Date.now() - requestStartAt;
|
|
40591
40843
|
const streamErrQueueWaitMs = totalQueueWaitMs(requestMeta);
|
|
@@ -40665,15 +40917,18 @@ data: ${JSON.stringify({
|
|
|
40665
40917
|
await abandonManagedFork("stream_complete_without_commit");
|
|
40666
40918
|
if (priorityRollbackRetirement)
|
|
40667
40919
|
await priorityRollbackRetirement;
|
|
40668
|
-
|
|
40920
|
+
if (!streamOwnsAbortLink)
|
|
40921
|
+
requestAbort.detach();
|
|
40669
40922
|
}
|
|
40670
40923
|
})().finally(() => {
|
|
40671
40924
|
resolveStreamCompletion();
|
|
40672
40925
|
});
|
|
40673
40926
|
},
|
|
40674
40927
|
cancel(reason) {
|
|
40928
|
+
requestAbort.setCause("stream_cancel");
|
|
40675
40929
|
requestAbort.abort(reason);
|
|
40676
|
-
|
|
40930
|
+
if (!streamOwnsAbortLink)
|
|
40931
|
+
requestAbort.detach();
|
|
40677
40932
|
requestMeta.cascadeSubtreeCancel?.("stream_cancel");
|
|
40678
40933
|
if (!isIndependentSession && (!managedForkTarget || managedForkPublished || clientAssistantContentExposed)) {
|
|
40679
40934
|
evictSession2(profileSessionId, profileScopedCwd, lineageMessages, mappingExpectedGeneration);
|
|
@@ -40706,7 +40961,8 @@ data: ${JSON.stringify({
|
|
|
40706
40961
|
claudeLog("proxy.error", { error: errMsg, classified: classified.type });
|
|
40707
40962
|
const sdkTerm = extractSdkTermination(errMsg);
|
|
40708
40963
|
diagnosticLog2.error(`${requestMeta.requestId} ${formatSdkTermination(sdkTerm, {
|
|
40709
|
-
requestSource: c.req.header("x-meridian-source")?.slice(0, 64) || undefined
|
|
40964
|
+
requestSource: c.req.header("x-meridian-source")?.slice(0, 64) || undefined,
|
|
40965
|
+
abort: requestAbort.abortSnapshot()
|
|
40710
40966
|
})}`, requestMeta.requestId);
|
|
40711
40967
|
const errorQueueWaitMs = totalQueueWaitMs(requestMeta);
|
|
40712
40968
|
const errorTotalMs = Date.now() - requestStartAt;
|
|
@@ -40793,6 +41049,14 @@ data: ${JSON.stringify({
|
|
|
40793
41049
|
};
|
|
40794
41050
|
const turnWatchdogAbort = new AbortController;
|
|
40795
41051
|
activeRequestAborts.add(turnWatchdogAbort);
|
|
41052
|
+
const requestSignalForLink = AbortSignal.any([c.req.raw.signal, turnWatchdogAbort.signal]);
|
|
41053
|
+
const labelClientAbort = () => {
|
|
41054
|
+
if (!turnWatchdogAbort.signal.aborted)
|
|
41055
|
+
requestAbortLink?.setCause("client_abort");
|
|
41056
|
+
};
|
|
41057
|
+
c.req.raw.signal.addEventListener("abort", labelClientAbort, { once: true });
|
|
41058
|
+
const requestAbortLink = linkRequestAbort(requestSignalForLink);
|
|
41059
|
+
activeShutdownLabels.set(turnWatchdogAbort, () => requestAbortLink.setCause("process_shutdown"));
|
|
40796
41060
|
let finished = false;
|
|
40797
41061
|
let leaseReleased = false;
|
|
40798
41062
|
let retainSessionTurnFence = false;
|
|
@@ -40821,6 +41085,8 @@ data: ${JSON.stringify({
|
|
|
40821
41085
|
if (finished)
|
|
40822
41086
|
return;
|
|
40823
41087
|
finished = true;
|
|
41088
|
+
requestAbortLink.detach();
|
|
41089
|
+
c.req.raw.signal.removeEventListener("abort", labelClientAbort);
|
|
40824
41090
|
if (retainSessionTurnFence && (sessionTurnLease || crossProcessTurnLease)) {
|
|
40825
41091
|
leaseReleased = true;
|
|
40826
41092
|
if (leaseWatchdog)
|
|
@@ -40835,6 +41101,7 @@ data: ${JSON.stringify({
|
|
|
40835
41101
|
sessionTreeRegistration?.release();
|
|
40836
41102
|
sessionTreeRegistration = undefined;
|
|
40837
41103
|
activeRequestAborts.delete(turnWatchdogAbort);
|
|
41104
|
+
activeShutdownLabels.delete(turnWatchdogAbort);
|
|
40838
41105
|
inFlightRequests--;
|
|
40839
41106
|
};
|
|
40840
41107
|
let body;
|
|
@@ -40866,7 +41133,10 @@ data: ${JSON.stringify({
|
|
|
40866
41133
|
requestId,
|
|
40867
41134
|
sessionKey: agentSessionId,
|
|
40868
41135
|
parentKey: adapter.getParentSessionId?.(c, body),
|
|
40869
|
-
abort: (reason) =>
|
|
41136
|
+
abort: (reason) => {
|
|
41137
|
+
requestAbortLink.setCause("subtree_cancel");
|
|
41138
|
+
turnWatchdogAbort.abort(reason);
|
|
41139
|
+
}
|
|
40870
41140
|
});
|
|
40871
41141
|
subtreeSessionKey = agentSessionId;
|
|
40872
41142
|
const clientSignal = c.req.raw.signal;
|
|
@@ -40887,6 +41157,7 @@ data: ${JSON.stringify({
|
|
|
40887
41157
|
leaseWatchdog = setTimeout(() => {
|
|
40888
41158
|
claudeLog("session.turn_watchdog_abort", { requestId, heldMs: SESSION_TURN_MAX_HOLD_MS });
|
|
40889
41159
|
plog(`[PROXY] ${requestId} session turn exceeded ${SESSION_TURN_MAX_HOLD_MS}ms — aborting without releasing its fencing lease`);
|
|
41160
|
+
requestAbortLink.setCause("session_watchdog");
|
|
40890
41161
|
turnWatchdogAbort.abort(new Error("Session turn exceeded its maximum hold time"));
|
|
40891
41162
|
}, SESSION_TURN_MAX_HOLD_MS);
|
|
40892
41163
|
leaseWatchdog.unref?.();
|
|
@@ -40961,7 +41232,8 @@ data: ${JSON.stringify({
|
|
|
40961
41232
|
};
|
|
40962
41233
|
const response = await handleMessages(c, requestMeta, {
|
|
40963
41234
|
body,
|
|
40964
|
-
turnWatchdogSignal: turnWatchdogAbort.signal
|
|
41235
|
+
turnWatchdogSignal: turnWatchdogAbort.signal,
|
|
41236
|
+
requestAbortLink
|
|
40965
41237
|
});
|
|
40966
41238
|
const completion = responseCompletions.get(response);
|
|
40967
41239
|
if (completion) {
|
|
@@ -41786,6 +42058,8 @@ data: ${JSON.stringify({ response: { id: responseId, status: "failed", error: {
|
|
|
41786
42058
|
},
|
|
41787
42059
|
forceAbortInFlight: () => {
|
|
41788
42060
|
durableWritesRevoked = true;
|
|
42061
|
+
for (const label of activeShutdownLabels.values())
|
|
42062
|
+
label();
|
|
41789
42063
|
for (const controller of activeRequestAborts) {
|
|
41790
42064
|
controller.abort(new Error("Proxy shutdown grace period elapsed"));
|
|
41791
42065
|
}
|