@bman654/clodex 2.11.7 → 2.12.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/dist/cli.js +32 -10
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -382,7 +382,7 @@ import { join } from "path";
|
|
|
382
382
|
// package.json
|
|
383
383
|
var package_default = {
|
|
384
384
|
name: "@bman654/clodex",
|
|
385
|
-
version: "2.
|
|
385
|
+
version: "2.12.0",
|
|
386
386
|
publishConfig: {
|
|
387
387
|
access: "public"
|
|
388
388
|
},
|
|
@@ -8847,7 +8847,7 @@ function instructionChangeSummary(previous, current) {
|
|
|
8847
8847
|
const firstDiffLine = previous.slice(0, prefix).split("\n").length;
|
|
8848
8848
|
return `instructions changed: previous_chars=${previous.length} current_chars=${current.length} common_prefix_chars=${prefix} common_suffix_chars=${suffix} first_diff_line=${firstDiffLine}`;
|
|
8849
8849
|
}
|
|
8850
|
-
function responsesWebSocketPartitionKey(wsUrl, payload, options = {}, authorizationFingerprint = "") {
|
|
8850
|
+
function responsesWebSocketPartitionKey(wsUrl, payload, options = {}, authorizationFingerprint = "", claudeAgentId = "") {
|
|
8851
8851
|
const promptCacheKey = payload.prompt_cache_key;
|
|
8852
8852
|
const model = payload.model;
|
|
8853
8853
|
if (typeof promptCacheKey !== "string" || !promptCacheKey || typeof model !== "string" || !model) return void 0;
|
|
@@ -8860,7 +8860,8 @@ function responsesWebSocketPartitionKey(wsUrl, payload, options = {}, authorizat
|
|
|
8860
8860
|
model,
|
|
8861
8861
|
effort,
|
|
8862
8862
|
promptCacheKey,
|
|
8863
|
-
authorizationFingerprint
|
|
8863
|
+
authorizationFingerprint,
|
|
8864
|
+
claudeAgentId
|
|
8864
8865
|
].join("");
|
|
8865
8866
|
return createHash6("sha256").update(material).digest("hex");
|
|
8866
8867
|
}
|
|
@@ -10019,16 +10020,18 @@ function createResponsesWebSocketFetch(wsUrl, log12, options = {}) {
|
|
|
10019
10020
|
}
|
|
10020
10021
|
if (hasResponsesLiteHeader(headers)) payload = applyResponsesLiteShape(payload);
|
|
10021
10022
|
const authorizationFingerprint = authorizationHeaderFingerprint(headers);
|
|
10023
|
+
const diagnosticCorrelation = diagnosticContext.getStore();
|
|
10024
|
+
const claudeAgentId = diagnosticCorrelation?.claudeAgentId ?? "";
|
|
10022
10025
|
const partitionKey = responsesWebSocketPartitionKey(
|
|
10023
10026
|
wsUrl,
|
|
10024
10027
|
payload,
|
|
10025
10028
|
options,
|
|
10026
|
-
authorizationFingerprint
|
|
10029
|
+
authorizationFingerprint,
|
|
10030
|
+
claudeAgentId
|
|
10027
10031
|
);
|
|
10028
10032
|
const promptFingerprint = responsesWebSocketPromptFingerprint(payload);
|
|
10029
10033
|
const promptFieldHashes = responsesWebSocketPromptFieldHashes(payload);
|
|
10030
10034
|
const instructionsSnapshot = instructionsFromPayload(payload);
|
|
10031
|
-
const diagnosticCorrelation = diagnosticContext.getStore();
|
|
10032
10035
|
let now = resolvedOptions.now();
|
|
10033
10036
|
const evictions = cleanupExpiredConnections(now);
|
|
10034
10037
|
let canonicalClientItems;
|
|
@@ -10236,7 +10239,9 @@ function createResponsesWebSocketFetch(wsUrl, log12, options = {}) {
|
|
|
10236
10239
|
accountIdHash: options.accountId ? createHash6("sha256").update(options.accountId).digest("hex").slice(0, 16) : "",
|
|
10237
10240
|
model: typeof payload.model === "string" ? payload.model : void 0,
|
|
10238
10241
|
effort: typeof payload.reasoning?.effort === "string" ? String(payload.reasoning.effort).trim().toLowerCase() : "",
|
|
10239
|
-
promptCacheKey: typeof payload.prompt_cache_key === "string" ? payload.prompt_cache_key : void 0
|
|
10242
|
+
promptCacheKey: typeof payload.prompt_cache_key === "string" ? payload.prompt_cache_key : void 0,
|
|
10243
|
+
claudeAgentId: claudeAgentId || void 0,
|
|
10244
|
+
claudeParentAgentId: diagnosticCorrelation?.claudeParentAgentId
|
|
10240
10245
|
},
|
|
10241
10246
|
promptFingerprint,
|
|
10242
10247
|
promptFieldHashes,
|
|
@@ -12134,6 +12139,18 @@ function extractClaudeSessionId(body, headerFallback) {
|
|
|
12134
12139
|
}
|
|
12135
12140
|
return validClaudeSessionId(headerFallback);
|
|
12136
12141
|
}
|
|
12142
|
+
var CLAUDE_AGENT_ID_RE = /^[A-Za-z0-9._-]{1,128}$/;
|
|
12143
|
+
function extractClaudeAgentIds(headers) {
|
|
12144
|
+
const read = (name) => {
|
|
12145
|
+
const raw = headers[name];
|
|
12146
|
+
const value = (Array.isArray(raw) ? raw[0] : raw)?.trim();
|
|
12147
|
+
return value && CLAUDE_AGENT_ID_RE.test(value) ? value : void 0;
|
|
12148
|
+
};
|
|
12149
|
+
return {
|
|
12150
|
+
claudeAgentId: read("x-claude-code-agent-id"),
|
|
12151
|
+
claudeParentAgentId: read("x-claude-code-parent-agent-id")
|
|
12152
|
+
};
|
|
12153
|
+
}
|
|
12137
12154
|
function claudeSessionPromptCacheKey(sessionId) {
|
|
12138
12155
|
return "relay-session-" + createHash8("sha256").update(sessionId).digest("hex").slice(0, 32);
|
|
12139
12156
|
}
|
|
@@ -13345,6 +13362,7 @@ async function startProxyCatalog(routes, defaultAliasId, debug = false, inferenc
|
|
|
13345
13362
|
const openAiOAuth = isOpenAiOAuthRoute(route);
|
|
13346
13363
|
const claudeSessionIdHeader = Array.isArray(req.headers["x-claude-code-session-id"]) ? req.headers["x-claude-code-session-id"][0] : req.headers["x-claude-code-session-id"];
|
|
13347
13364
|
const claudeSessionId = extractClaudeSessionId(anthropicBody, claudeSessionIdHeader);
|
|
13365
|
+
const claudeAgentIds = extractClaudeAgentIds(req.headers);
|
|
13348
13366
|
const translationLifecycle = createTranslationLifecycle(
|
|
13349
13367
|
inferenceLogPath,
|
|
13350
13368
|
relayRequestId,
|
|
@@ -13418,7 +13436,7 @@ async function startProxyCatalog(routes, defaultAliasId, debug = false, inferenc
|
|
|
13418
13436
|
keepAlive.unref();
|
|
13419
13437
|
try {
|
|
13420
13438
|
await withResponsesWebSocketDiagnosticContext(
|
|
13421
|
-
{ requestId: relayRequestId, claudeSessionId },
|
|
13439
|
+
{ requestId: relayRequestId, claudeSessionId, ...claudeAgentIds },
|
|
13422
13440
|
() => streamAnthropicResponse(
|
|
13423
13441
|
model,
|
|
13424
13442
|
params,
|
|
@@ -13449,7 +13467,7 @@ async function startProxyCatalog(routes, defaultAliasId, debug = false, inferenc
|
|
|
13449
13467
|
res.end();
|
|
13450
13468
|
} else {
|
|
13451
13469
|
const anthropicResponse = await withResponsesWebSocketDiagnosticContext(
|
|
13452
|
-
{ requestId: relayRequestId, claudeSessionId },
|
|
13470
|
+
{ requestId: relayRequestId, claudeSessionId, ...claudeAgentIds },
|
|
13453
13471
|
() => generateAnthropicResponse(
|
|
13454
13472
|
model,
|
|
13455
13473
|
params,
|
|
@@ -18218,6 +18236,7 @@ async function handleAnthropicMessages(req, res, options, modelCache, plog) {
|
|
|
18218
18236
|
const requestId = randomUUID5();
|
|
18219
18237
|
const claudeSessionIdHeader = Array.isArray(req.headers["x-claude-code-session-id"]) ? req.headers["x-claude-code-session-id"][0] : req.headers["x-claude-code-session-id"];
|
|
18220
18238
|
const claudeSessionId = extractClaudeSessionId(body, claudeSessionIdHeader);
|
|
18239
|
+
const claudeAgentIds = extractClaudeAgentIds(req.headers);
|
|
18221
18240
|
if (options.webSocketDiagnosticsLogPath) {
|
|
18222
18241
|
writeWebSocketDiagnosticRequestLog(options.webSocketDiagnosticsLogPath, {
|
|
18223
18242
|
requestId,
|
|
@@ -18382,7 +18401,7 @@ async function handleAnthropicMessages(req, res, options, modelCache, plog) {
|
|
|
18382
18401
|
res.write(chunk);
|
|
18383
18402
|
};
|
|
18384
18403
|
await withResponsesWebSocketDiagnosticContext(
|
|
18385
|
-
{ requestId, claudeSessionId },
|
|
18404
|
+
{ requestId, claudeSessionId, ...claudeAgentIds },
|
|
18386
18405
|
() => streamAnthropicResponse(languageModel, params, responseModelId, writeStreamChunk, void 0, {
|
|
18387
18406
|
abortSignal: clientAbort.signal,
|
|
18388
18407
|
initialInputTokens: estimateAnthropicInputTokens(body),
|
|
@@ -18398,7 +18417,7 @@ async function handleAnthropicMessages(req, res, options, modelCache, plog) {
|
|
|
18398
18417
|
res.end();
|
|
18399
18418
|
} else {
|
|
18400
18419
|
const anthropicResponse = await withResponsesWebSocketDiagnosticContext(
|
|
18401
|
-
{ requestId, claudeSessionId },
|
|
18420
|
+
{ requestId, claudeSessionId, ...claudeAgentIds },
|
|
18402
18421
|
() => generateAnthropicResponse(languageModel, params, responseModelId, {
|
|
18403
18422
|
forceStream: openAiOAuth,
|
|
18404
18423
|
abortSignal: clientAbort.signal,
|
|
@@ -19491,6 +19510,9 @@ function forwardToAdapter(req, res, rawBody, adapter, adapterRequest = http2.req
|
|
|
19491
19510
|
"Content-Length": String(rawBody.length),
|
|
19492
19511
|
"x-api-key": adapter.token,
|
|
19493
19512
|
...typeof req.headers["x-claude-code-session-id"] === "string" ? { "x-claude-code-session-id": req.headers["x-claude-code-session-id"] } : {},
|
|
19513
|
+
// Subagent identity: the relay partitions ChatGPT WebSocket heads by it.
|
|
19514
|
+
...typeof req.headers["x-claude-code-agent-id"] === "string" ? { "x-claude-code-agent-id": req.headers["x-claude-code-agent-id"] } : {},
|
|
19515
|
+
...typeof req.headers["x-claude-code-parent-agent-id"] === "string" ? { "x-claude-code-parent-agent-id": req.headers["x-claude-code-parent-agent-id"] } : {},
|
|
19494
19516
|
...lifecycle ? { "x-relay-request-id": lifecycle.requestId } : {}
|
|
19495
19517
|
}
|
|
19496
19518
|
}, (upstreamRes) => {
|