@eddyskywalker/dsh-chatgpt-subscription 0.10.10 → 0.10.11
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/CHANGELOG.md +23 -0
- package/README.md +10 -6
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/index.js +179 -75
- package/lib/types/client/claude/ClaudeSection.d.ts.map +1 -1
- package/lib/types/host/claude/adapter.d.ts.map +1 -1
- package/lib/types/host/claude/client.d.ts +6 -1
- package/lib/types/host/claude/client.d.ts.map +1 -1
- package/lib/types/host/claude/mapper.d.ts +33 -12
- package/lib/types/host/claude/mapper.d.ts.map +1 -1
- package/lib/types/host/claude/model-catalog.d.ts +19 -4
- package/lib/types/host/claude/model-catalog.d.ts.map +1 -1
- package/lib/types/host/claude/oauth.d.ts.map +1 -1
- package/lib/types/host/claude/types.d.ts +18 -1
- package/lib/types/host/claude/types.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -26351,6 +26351,17 @@ const OAUTH_BETA = "oauth-2025-04-20";
|
|
|
26351
26351
|
const CLAUDE_CODE_BETA = "claude-code-20250219";
|
|
26352
26352
|
/** Lets thinking blocks interleave with tool use across a multi-turn loop. */
|
|
26353
26353
|
const INTERLEAVED_THINKING_BETA = "interleaved-thinking-2025-05-14";
|
|
26354
|
+
/**
|
|
26355
|
+
* Licenses `thinking.block_binding` in a request body.
|
|
26356
|
+
*
|
|
26357
|
+
* The field is not optional to license: the vendor documents that a body
|
|
26358
|
+
* carrying `block_binding` WITHOUT this beta is a 400 whose message ends
|
|
26359
|
+
* `block_binding: Extra inputs are not permitted` — every request, every turn.
|
|
26360
|
+
* The mid-convo thinking form always sends `block_binding`, so a request that
|
|
26361
|
+
* uses that form must carry this value. The reference sends it for exactly those
|
|
26362
|
+
* models (`THINKING_BINDING_CONTROLS_BETA`, pushed when `supportsMidConvoEffort`).
|
|
26363
|
+
*/
|
|
26364
|
+
const THINKING_BINDING_CONTROLS_BETA = "thinking-binding-controls-2026-08-01";
|
|
26354
26365
|
/** Anthropic protocol revision sent as `anthropic-version`. */
|
|
26355
26366
|
const ANTHROPIC_VERSION = "2023-06-01";
|
|
26356
26367
|
/**
|
|
@@ -26380,12 +26391,18 @@ const ANTHROPIC_VERSION = "2023-06-01";
|
|
|
26380
26391
|
* trades a clear refusal for an unpredictable one. Note that npm's `stable`
|
|
26381
26392
|
* dist-tag can itself sit below a model's floor, so `latest` is the tag to read.
|
|
26382
26393
|
*
|
|
26394
|
+
* It must also be at or above the release that FIRST SHIPPED each model in the
|
|
26395
|
+
* table, whether or not a floor for that model has been observed: upstream has
|
|
26396
|
+
* so far gated a new model on the release that added it (Opus 5.5 arrived in
|
|
26397
|
+
* 2.1.280 and is refused below 2.1.280). Claude Sonnet 5.5 arrived in 2.1.284,
|
|
26398
|
+
* so 2.1.283 could not be relied on to reach it; 2.1.285 is npm `latest`.
|
|
26399
|
+
*
|
|
26383
26400
|
* It is still not a literal that only moves when this package is republished: a
|
|
26384
26401
|
* user whose installed baseline has aged past the server's floor has to be able
|
|
26385
26402
|
* to raise it without waiting for a release. Read the effective value with
|
|
26386
26403
|
* {@link claudeCliVersion}, pin one with {@link setClaudeCliVersion}.
|
|
26387
26404
|
*/
|
|
26388
|
-
const CLAUDE_CLI_VERSION = "2.1.
|
|
26405
|
+
const CLAUDE_CLI_VERSION = "2.1.285";
|
|
26389
26406
|
/**
|
|
26390
26407
|
* Loopback callback port the subscription flow defaults to.
|
|
26391
26408
|
*
|
|
@@ -26743,8 +26760,10 @@ function loopbackRedirectUri(port = DEFAULT_CALLBACK_PORT) {
|
|
|
26743
26760
|
* LOCAL ADDITIONS — the rows the reference snapshot predates
|
|
26744
26761
|
* ---------------------------------------------------------------------------
|
|
26745
26762
|
*
|
|
26746
|
-
* `claude-opus-5-5`
|
|
26747
|
-
* `LOCALLY_CURATED_MODEL_IDS`; the two must be
|
|
26763
|
+
* `claude-opus-5-5` and `claude-sonnet-5-5` are the two such rows today. The
|
|
26764
|
+
* mirror list in the test is `LOCALLY_CURATED_MODEL_IDS`; the two must be
|
|
26765
|
+
* changed together. Sonnet 5.5's own reasons are recorded at its row; what
|
|
26766
|
+
* follows below is Opus 5.5's.
|
|
26748
26767
|
*
|
|
26749
26768
|
* It is CURATED rather than transcribed because the snapshot this table copies
|
|
26750
26769
|
* has no entry for it, and the one thing a transcription table must never do is
|
|
@@ -26796,8 +26815,8 @@ function loopbackRedirectUri(port = DEFAULT_CALLBACK_PORT) {
|
|
|
26796
26815
|
* the user has to reach.
|
|
26797
26816
|
*/
|
|
26798
26817
|
/**
|
|
26799
|
-
*
|
|
26800
|
-
* followed by the curated
|
|
26818
|
+
* Sixteen rows: the snapshot's own 14, in the snapshot's own declaration order,
|
|
26819
|
+
* followed by the curated rows the snapshot predates (see LOCAL ADDITIONS above).
|
|
26801
26820
|
*
|
|
26802
26821
|
* The order matters and is not cosmetic. The test asserts the snapshot's ids
|
|
26803
26822
|
* appear in the table as a SUBSEQUENCE, so a curated row may be appended or
|
|
@@ -27065,7 +27084,26 @@ const CLAUDE_MODELS = Object.freeze([
|
|
|
27065
27084
|
"max"
|
|
27066
27085
|
],
|
|
27067
27086
|
canDisableThinking: false,
|
|
27068
|
-
minCliVersion: "2.1.280"
|
|
27087
|
+
minCliVersion: "2.1.280",
|
|
27088
|
+
bindsThinkingToPrefix: true
|
|
27089
|
+
},
|
|
27090
|
+
{
|
|
27091
|
+
id: "claude-sonnet-5-5",
|
|
27092
|
+
name: "Claude Sonnet 5.5",
|
|
27093
|
+
contextWindow: 1e6,
|
|
27094
|
+
maxTokens: 128e3,
|
|
27095
|
+
supportsImage: true,
|
|
27096
|
+
supportsTemperature: false,
|
|
27097
|
+
thinkingMode: "mid-convo",
|
|
27098
|
+
reasoningEfforts: [
|
|
27099
|
+
"low",
|
|
27100
|
+
"medium",
|
|
27101
|
+
"high",
|
|
27102
|
+
"xhigh",
|
|
27103
|
+
"max"
|
|
27104
|
+
],
|
|
27105
|
+
canDisableThinking: false,
|
|
27106
|
+
bindsThinkingToPrefix: true
|
|
27069
27107
|
}
|
|
27070
27108
|
]);
|
|
27071
27109
|
/** Every id the fallback table knows, in declaration order. */
|
|
@@ -27165,6 +27203,10 @@ function claudeThinkingMode(modelId, catalog) {
|
|
|
27165
27203
|
function claudeModelSupportsTemperature(modelId, catalog) {
|
|
27166
27204
|
return resolveClaudeModel(modelId, catalog ?? CLAUDE_MODELS).supportsTemperature;
|
|
27167
27205
|
}
|
|
27206
|
+
/** Whether one model runs the documented preserved-thinking prefix check. */
|
|
27207
|
+
function claudeModelBindsThinkingToPrefix(modelId, catalog) {
|
|
27208
|
+
return resolveClaudeModel(modelId, catalog ?? CLAUDE_MODELS).bindsThinkingToPrefix === true;
|
|
27209
|
+
}
|
|
27168
27210
|
/** Whether thinking can be turned off for one model. */
|
|
27169
27211
|
function claudeModelCanDisableThinking(modelId, catalog) {
|
|
27170
27212
|
return resolveClaudeModel(modelId, catalog ?? CLAUDE_MODELS).canDisableThinking;
|
|
@@ -27990,6 +28032,7 @@ function claudeBetas(options = {}) {
|
|
|
27990
28032
|
if (options.model === void 0 || !isHaikuModel(options.model)) betas.push(CLAUDE_CODE_BETA);
|
|
27991
28033
|
betas.push(OAUTH_BETA);
|
|
27992
28034
|
if (options.thinking === true) betas.push(INTERLEAVED_THINKING_BETA);
|
|
28035
|
+
if (options.thinkingBinding === true) betas.push(THINKING_BINDING_CONTROLS_BETA);
|
|
27993
28036
|
return betas;
|
|
27994
28037
|
}
|
|
27995
28038
|
/** The `User-Agent` value this line reports for one surface. */
|
|
@@ -28136,7 +28179,7 @@ async function performCatalogLoad(credentials, options) {
|
|
|
28136
28179
|
let models;
|
|
28137
28180
|
let live = false;
|
|
28138
28181
|
try {
|
|
28139
|
-
const response = await fetchFn("https://api.anthropic.com/v1/models", {
|
|
28182
|
+
const response = await fetchFn("https://api.anthropic.com/v1/models?limit=1000", {
|
|
28140
28183
|
method: "GET",
|
|
28141
28184
|
headers: buildClaudeHeaders(credentials.accessToken, { method: "GET" }),
|
|
28142
28185
|
signal: timeoutSignal(options.signal, DISCOVERY_TIMEOUT_MS)
|
|
@@ -28603,8 +28646,15 @@ function classifyFailure(status, bodyText, headers = {}) {
|
|
|
28603
28646
|
retryAfterMs: retryAfter
|
|
28604
28647
|
};
|
|
28605
28648
|
switch (envelope.type) {
|
|
28606
|
-
case ERROR_TYPE.AUTHENTICATION:
|
|
28607
28649
|
case ERROR_TYPE.PERMISSION: return {
|
|
28650
|
+
...base,
|
|
28651
|
+
kind: "request",
|
|
28652
|
+
message: envelope.message ?? "This Claude account is not permitted to use the requested resource.",
|
|
28653
|
+
retryable: false,
|
|
28654
|
+
accountScoped: false,
|
|
28655
|
+
resetsAt: null
|
|
28656
|
+
};
|
|
28657
|
+
case ERROR_TYPE.AUTHENTICATION: return {
|
|
28608
28658
|
...base,
|
|
28609
28659
|
kind: "credential",
|
|
28610
28660
|
message: envelope.message ?? "Claude rejected the stored credential. Sign in again.",
|
|
@@ -28762,7 +28812,9 @@ function classifyFailure(status, bodyText, headers = {}) {
|
|
|
28762
28812
|
* everything, including a caller asking for thinking off: the
|
|
28763
28813
|
* block_binding exists so a prefix mismatch is dropped instead of
|
|
28764
28814
|
* surfacing as a persistent 400, and suppressing it is exactly
|
|
28765
|
-
* how that 400 comes back.
|
|
28815
|
+
* how that 400 comes back. The field is itself a 400 unless the
|
|
28816
|
+
* request carries the thinking-binding-controls beta, so the
|
|
28817
|
+
* adapter reads claudeBodyBindsThinking(body) to add it.
|
|
28766
28818
|
* adaptive -> { type: 'adaptive', display: 'summarized' }, plus
|
|
28767
28819
|
* output_config = { effort } when an effort was named. The budget
|
|
28768
28820
|
* form is rejected by these models.
|
|
@@ -28855,11 +28907,12 @@ function classifyFailure(status, bodyText, headers = {}) {
|
|
|
28855
28907
|
* 'error' event THROWS, because a severed reply flushed as a clean stop is a
|
|
28856
28908
|
* wrong answer rather than a visible failure.
|
|
28857
28909
|
*
|
|
28858
|
-
* Reasoning deltas are
|
|
28859
|
-
*
|
|
28860
|
-
* block may be replayed
|
|
28861
|
-
*
|
|
28862
|
-
*
|
|
28910
|
+
* Reasoning deltas are STREAMED as they arrive (see openThinkingBlock); only the
|
|
28911
|
+
* replay entry waits for content_block_stop, because the signature that decides
|
|
28912
|
+
* whether the block may be replayed arrives at the END of the block. They used
|
|
28913
|
+
* to be buffered until the stop, which made DSH start the step's first-token
|
|
28914
|
+
* clock after all thinking was done - so TPS divided every thinking token by the
|
|
28915
|
+
* answer's time alone, and TTFT absorbed the whole thinking phase.
|
|
28863
28916
|
*
|
|
28864
28917
|
* ---------------------------------------------------------------------------
|
|
28865
28918
|
* 7. PROMPT CACHING IS ON BY DEFAULT, AND IT IS THE REQUEST THAT TURNS IT ON
|
|
@@ -28958,9 +29011,17 @@ function jsonSafeValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
28958
29011
|
seen.delete(value);
|
|
28959
29012
|
}
|
|
28960
29013
|
}
|
|
28961
|
-
/**
|
|
29014
|
+
/**
|
|
29015
|
+
* Strip what the wire cannot carry: a NUL, which would truncate the string
|
|
29016
|
+
* inside a JSON encoder, and an UNPAIRED surrogate. JSON.stringify writes the
|
|
29017
|
+
* latter as a lone `\uD83D` escape, which upstream rejects as invalid JSON ("no
|
|
29018
|
+
* low surrogate in string") - and since the text sits in history, every later
|
|
29019
|
+
* request fails the same way. A tool output sliced mid-emoji is enough to
|
|
29020
|
+
* produce one. Paired surrogates (emoji) are untouched. Same rule as the
|
|
29021
|
+
* reference's sanitizeSurrogates.
|
|
29022
|
+
*/
|
|
28962
29023
|
function sanitizeText(text) {
|
|
28963
|
-
return text.replace(/\0/g, "");
|
|
29024
|
+
return text.replace(/\0|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
28964
29025
|
}
|
|
28965
29026
|
/**
|
|
28966
29027
|
* Whether one failure is a cancellation rather than a real read failure.
|
|
@@ -29175,7 +29236,8 @@ function claudeThinking(model, effort, level, maxTokens, customBudgets) {
|
|
|
29175
29236
|
if (mode === "adaptive") return {
|
|
29176
29237
|
thinking: {
|
|
29177
29238
|
type: "adaptive",
|
|
29178
|
-
display: "summarized"
|
|
29239
|
+
display: "summarized",
|
|
29240
|
+
...claudeModelBindsThinkingToPrefix(model) ? { block_binding: { prefix_mismatch_behavior: "drop_block" } } : {}
|
|
29179
29241
|
},
|
|
29180
29242
|
...namedEffort === void 0 ? {} : { outputConfig: { effort: namedEffort } }
|
|
29181
29243
|
};
|
|
@@ -29738,9 +29800,10 @@ function toolResultContent(blocks, images) {
|
|
|
29738
29800
|
for (const block of blocks) {
|
|
29739
29801
|
if (!isRecord$5(block)) continue;
|
|
29740
29802
|
if (block.type === "text" && typeof block.text === "string") {
|
|
29741
|
-
|
|
29803
|
+
const text = sanitizeText(block.text);
|
|
29804
|
+
if (text !== "") out.push({
|
|
29742
29805
|
type: "text",
|
|
29743
|
-
text
|
|
29806
|
+
text
|
|
29744
29807
|
});
|
|
29745
29808
|
continue;
|
|
29746
29809
|
}
|
|
@@ -29760,7 +29823,7 @@ function toolResultContent(blocks, images) {
|
|
|
29760
29823
|
if (!hasImage) return void 0;
|
|
29761
29824
|
if (out[0]?.type !== "text") out.unshift({
|
|
29762
29825
|
type: "text",
|
|
29763
|
-
text: ""
|
|
29826
|
+
text: "(see attached image)"
|
|
29764
29827
|
});
|
|
29765
29828
|
return out;
|
|
29766
29829
|
}
|
|
@@ -29889,6 +29952,17 @@ function buildClaudeRequestBody(options, images = NO_RESOLVED_IMAGES, request =
|
|
|
29889
29952
|
return body;
|
|
29890
29953
|
}
|
|
29891
29954
|
/**
|
|
29955
|
+
* Whether one built body carries `thinking.block_binding`.
|
|
29956
|
+
*
|
|
29957
|
+
* Read off the BODY rather than re-derived from the catalog, because the header
|
|
29958
|
+
* this answers for (THINKING_BINDING_CONTROLS_BETA) exists to license that one
|
|
29959
|
+
* field: sent without it the field is a 400 on every request, so the header must
|
|
29960
|
+
* follow the bytes, not a second copy of the rule that produced them.
|
|
29961
|
+
*/
|
|
29962
|
+
function claudeBodyBindsThinking(body) {
|
|
29963
|
+
return isRecord$5(body.thinking) && body.thinking.block_binding !== void 0;
|
|
29964
|
+
}
|
|
29965
|
+
/**
|
|
29892
29966
|
* Fresh stream state.
|
|
29893
29967
|
*
|
|
29894
29968
|
* @param toolNames - the SAME ClaudeToolNames the request was built with, so a
|
|
@@ -29913,6 +29987,7 @@ function createStreamState$1(toolNames) {
|
|
|
29913
29987
|
cacheReadTokens: 0,
|
|
29914
29988
|
cacheWriteTokens: 0,
|
|
29915
29989
|
reasoningTokens: 0,
|
|
29990
|
+
reportedReasoningTokens: void 0,
|
|
29916
29991
|
sawUsage: false,
|
|
29917
29992
|
finished: false
|
|
29918
29993
|
};
|
|
@@ -30009,14 +30084,15 @@ function closeToolCall(state, contentIndex) {
|
|
|
30009
30084
|
}];
|
|
30010
30085
|
}
|
|
30011
30086
|
/**
|
|
30012
|
-
*
|
|
30087
|
+
* Close one thinking block: end it for the caller and record its replay entry.
|
|
30013
30088
|
*
|
|
30014
|
-
*
|
|
30015
|
-
*
|
|
30016
|
-
*
|
|
30017
|
-
*
|
|
30089
|
+
* Its text already reached the caller as it streamed (see openThinkingBlock);
|
|
30090
|
+
* what waits for the close is the replay entry, because the signature arrives
|
|
30091
|
+
* last. A signed block is replayed verbatim afterwards. An unsigned one is
|
|
30092
|
+
* still shown (the model did think) but the request builder drops it on the
|
|
30093
|
+
* next turn, since it cannot be sent back.
|
|
30018
30094
|
*/
|
|
30019
|
-
function
|
|
30095
|
+
function closeThinkingBlock(state, contentIndex) {
|
|
30020
30096
|
const pending = state.pending.get(contentIndex);
|
|
30021
30097
|
if (pending === void 0) return [];
|
|
30022
30098
|
state.pending.delete(contentIndex);
|
|
@@ -30036,20 +30112,45 @@ function emitPendingThinking(state, contentIndex) {
|
|
|
30036
30112
|
...pending.signature === "" ? {} : { signature: pending.signature }
|
|
30037
30113
|
};
|
|
30038
30114
|
state.reasoningTokens += estimateReasoningTokens(text);
|
|
30115
|
+
return [{
|
|
30116
|
+
type: "block-end",
|
|
30117
|
+
index: pending.index,
|
|
30118
|
+
block
|
|
30119
|
+
}];
|
|
30120
|
+
}
|
|
30121
|
+
/**
|
|
30122
|
+
* Open one thinking block and stream whatever text its start already carries.
|
|
30123
|
+
*
|
|
30124
|
+
* STREAMED, not held to content_block_stop: DSH times a step's first token from
|
|
30125
|
+
* the first non-empty delta, and the usage it divides by that window counts every
|
|
30126
|
+
* thinking token. Holding the text until the block closed started the clock
|
|
30127
|
+
* after all the thinking was done - inflating TPS and TTFT alike - and kept the
|
|
30128
|
+
* UI blank for the whole thinking phase. Only the replay entry waits for the
|
|
30129
|
+
* close, because the signature arrives last.
|
|
30130
|
+
*/
|
|
30131
|
+
function openThinkingBlock(state, contentIndex, block, kind) {
|
|
30132
|
+
const index = state.blocks.length;
|
|
30133
|
+
state.blocks.push({
|
|
30134
|
+
type: "reasoning",
|
|
30135
|
+
text: ""
|
|
30136
|
+
});
|
|
30137
|
+
const seed = kind === "thinking" ? asString$2(block.thinking) ?? "" : "";
|
|
30138
|
+
state.pending.set(contentIndex, {
|
|
30139
|
+
index,
|
|
30140
|
+
kind,
|
|
30141
|
+
text: seed,
|
|
30142
|
+
signature: asString$2(block.signature) ?? "",
|
|
30143
|
+
data: asString$2(block.data) ?? ""
|
|
30144
|
+
});
|
|
30039
30145
|
const out = [{
|
|
30040
30146
|
type: "block-start",
|
|
30041
|
-
index
|
|
30147
|
+
index,
|
|
30042
30148
|
blockType: "reasoning"
|
|
30043
30149
|
}];
|
|
30044
|
-
if (
|
|
30150
|
+
if (seed !== "") out.push({
|
|
30045
30151
|
type: "reasoning-delta",
|
|
30046
|
-
index
|
|
30047
|
-
text
|
|
30048
|
-
});
|
|
30049
|
-
out.push({
|
|
30050
|
-
type: "block-end",
|
|
30051
|
-
index: pending.index,
|
|
30052
|
-
block
|
|
30152
|
+
index,
|
|
30153
|
+
text: seed
|
|
30053
30154
|
});
|
|
30054
30155
|
return out;
|
|
30055
30156
|
}
|
|
@@ -30066,7 +30167,7 @@ function flushOpenBlocks(state) {
|
|
|
30066
30167
|
});
|
|
30067
30168
|
for (const [contentIndex, pending] of state.pending) closers.push({
|
|
30068
30169
|
index: pending.index,
|
|
30069
|
-
close: () =>
|
|
30170
|
+
close: () => closeThinkingBlock(state, contentIndex)
|
|
30070
30171
|
});
|
|
30071
30172
|
closers.sort((left, right) => left.index - right.index);
|
|
30072
30173
|
const out = [];
|
|
@@ -30085,17 +30186,25 @@ function flushOpenBlocks(state) {
|
|
|
30085
30186
|
* the billed-input total unaccountable.
|
|
30086
30187
|
*/
|
|
30087
30188
|
function tokenUsage(state) {
|
|
30189
|
+
const reasoningTokens = Math.min(state.reportedReasoningTokens ?? state.reasoningTokens, state.outputTokens);
|
|
30088
30190
|
return {
|
|
30089
30191
|
inputTokens: state.inputTokens,
|
|
30090
30192
|
outputTokens: state.outputTokens,
|
|
30091
30193
|
...state.cacheReadTokens > 0 ? { cacheReadTokens: state.cacheReadTokens } : {},
|
|
30092
30194
|
...state.cacheWriteTokens > 0 ? { cacheWriteTokens: state.cacheWriteTokens } : {},
|
|
30093
|
-
...
|
|
30195
|
+
...reasoningTokens > 0 ? { reasoningTokens } : {}
|
|
30094
30196
|
};
|
|
30095
30197
|
}
|
|
30096
30198
|
function finishReasonFor(state) {
|
|
30097
30199
|
const reason = state.finishReason ?? "";
|
|
30098
|
-
if (reason === "
|
|
30200
|
+
if (reason === "refusal" || reason === "sensitive") return {
|
|
30201
|
+
kind: "error",
|
|
30202
|
+
failure: {
|
|
30203
|
+
message: state.stopExplanation ?? "Claude declined to respond (stop_reason: " + reason + ").",
|
|
30204
|
+
code: "PROVIDER_ERROR"
|
|
30205
|
+
}
|
|
30206
|
+
};
|
|
30207
|
+
if (reason === "max_tokens" || reason === "model_context_window_exceeded") return { kind: "max-tokens" };
|
|
30099
30208
|
if (state.hasToolCall || reason === "tool_use") return { kind: "tool-calls" };
|
|
30100
30209
|
return { kind: "stop" };
|
|
30101
30210
|
}
|
|
@@ -30143,6 +30252,8 @@ function applyUsage(state, usage, cumulativeOutput) {
|
|
|
30143
30252
|
if (usage.cache_creation_input_tokens !== void 0) state.cacheWriteTokens = numberOr(usage.cache_creation_input_tokens, state.cacheWriteTokens);
|
|
30144
30253
|
if (usage.cache_read_input_tokens !== void 0) state.cacheReadTokens = numberOr(usage.cache_read_input_tokens, state.cacheReadTokens);
|
|
30145
30254
|
if (usage.output_tokens !== void 0) state.outputTokens = cumulativeOutput ? numberOr(usage.output_tokens, state.outputTokens) : state.outputTokens + numberOr(usage.output_tokens, 0);
|
|
30255
|
+
const details = isRecord$5(usage.output_tokens_details) ? usage.output_tokens_details : void 0;
|
|
30256
|
+
if (details !== void 0 && details.thinking_tokens !== void 0) state.reportedReasoningTokens = numberOr(details.thinking_tokens, state.reportedReasoningTokens ?? 0);
|
|
30146
30257
|
}
|
|
30147
30258
|
/**
|
|
30148
30259
|
* Feed one SSE line of a Messages response into the state.
|
|
@@ -30213,19 +30324,8 @@ function processStreamLine(line, state) {
|
|
|
30213
30324
|
return out;
|
|
30214
30325
|
}
|
|
30215
30326
|
if (blockType === "thinking" || blockType === "redacted_thinking") {
|
|
30216
|
-
|
|
30217
|
-
|
|
30218
|
-
state.blocks.push({
|
|
30219
|
-
type: "reasoning",
|
|
30220
|
-
text: ""
|
|
30221
|
-
});
|
|
30222
|
-
state.pending.set(contentIndex, {
|
|
30223
|
-
index,
|
|
30224
|
-
kind: blockType === "redacted_thinking" ? "redacted_thinking" : "thinking",
|
|
30225
|
-
text: asString$2(block.thinking) ?? "",
|
|
30226
|
-
signature: asString$2(block.signature) ?? "",
|
|
30227
|
-
data: asString$2(block.data) ?? ""
|
|
30228
|
-
});
|
|
30327
|
+
out.push(...closeThinkingBlock(state, contentIndex));
|
|
30328
|
+
out.push(...openThinkingBlock(state, contentIndex, block, blockType));
|
|
30229
30329
|
return out;
|
|
30230
30330
|
}
|
|
30231
30331
|
out.push(...openTextAt(state, contentIndex).chunks);
|
|
@@ -30258,8 +30358,14 @@ function processStreamLine(line, state) {
|
|
|
30258
30358
|
}
|
|
30259
30359
|
if (deltaType === "thinking_delta") {
|
|
30260
30360
|
const pending = state.pending.get(contentIndex);
|
|
30261
|
-
const text = asString$2(delta.thinking) ?? "";
|
|
30262
|
-
if (pending
|
|
30361
|
+
const text = sanitizeText(asString$2(delta.thinking) ?? "");
|
|
30362
|
+
if (pending === void 0 || pending.kind !== "thinking" || text === "") return out;
|
|
30363
|
+
pending.text += text;
|
|
30364
|
+
out.push({
|
|
30365
|
+
type: "reasoning-delta",
|
|
30366
|
+
index: pending.index,
|
|
30367
|
+
text
|
|
30368
|
+
});
|
|
30263
30369
|
return out;
|
|
30264
30370
|
}
|
|
30265
30371
|
const text = asString$2(delta.text) ?? "";
|
|
@@ -30278,13 +30384,16 @@ function processStreamLine(line, state) {
|
|
|
30278
30384
|
if (type === "content_block_stop") {
|
|
30279
30385
|
const contentIndex = numberOr(event.index, -1);
|
|
30280
30386
|
if (state.toolCalls.has(contentIndex)) return closeToolCall(state, contentIndex);
|
|
30281
|
-
if (state.pending.has(contentIndex)) return
|
|
30387
|
+
if (state.pending.has(contentIndex)) return closeThinkingBlock(state, contentIndex);
|
|
30282
30388
|
return closeTextBlock(state, contentIndex);
|
|
30283
30389
|
}
|
|
30284
30390
|
if (type === "message_delta") {
|
|
30285
30391
|
const delta = isRecord$5(event.delta) ? event.delta : void 0;
|
|
30286
30392
|
const stop = delta === void 0 ? void 0 : asString$2(delta.stop_reason);
|
|
30287
30393
|
if (stop !== void 0 && stop !== "") state.finishReason = stop;
|
|
30394
|
+
const details = delta !== void 0 && isRecord$5(delta.stop_details) ? delta.stop_details : void 0;
|
|
30395
|
+
const explanation = details === void 0 ? void 0 : asString$2(details.explanation);
|
|
30396
|
+
if (explanation !== void 0 && explanation !== "") state.stopExplanation = explanation;
|
|
30288
30397
|
const usage = isRecord$5(event.usage) ? event.usage : void 0;
|
|
30289
30398
|
if (usage !== void 0) applyUsage(state, usage, true);
|
|
30290
30399
|
return out;
|
|
@@ -30719,7 +30828,7 @@ async function refreshAccessToken(refreshToken, options = {}) {
|
|
|
30719
30828
|
try {
|
|
30720
30829
|
return await postTokenGrant(body, options, false, [refreshToken]);
|
|
30721
30830
|
} catch (error) {
|
|
30722
|
-
if (error instanceof
|
|
30831
|
+
if (!(error instanceof ClaudeRetryableError)) throw error;
|
|
30723
30832
|
lastError = error;
|
|
30724
30833
|
}
|
|
30725
30834
|
if (attempt < REFRESH_MAX_ATTEMPTS - 1) await sleep(REFRESH_BACKOFF_BASE_MS * 2 ** attempt, options.signal);
|
|
@@ -31804,19 +31913,20 @@ var ClaudeAdapter = class extends LlmAdapter {
|
|
|
31804
31913
|
* no credentials were resolved for it.
|
|
31805
31914
|
*/
|
|
31806
31915
|
async attemptRequest(credentials, requestOptions, images, toolNames, thinking, signal, fetchFn) {
|
|
31807
|
-
const
|
|
31916
|
+
const payload = buildClaudeRequestBody(requestOptions, images, {
|
|
31808
31917
|
toolNames,
|
|
31809
31918
|
cacheControl: true
|
|
31810
|
-
})
|
|
31919
|
+
});
|
|
31811
31920
|
try {
|
|
31812
31921
|
return await fetchFn("https://api.anthropic.com/v1/messages?beta=true", {
|
|
31813
31922
|
method: "POST",
|
|
31814
31923
|
headers: buildClaudeHeaders(credentials.accessToken, {
|
|
31815
31924
|
model: requestOptions.model,
|
|
31816
31925
|
thinking,
|
|
31926
|
+
thinkingBinding: claudeBodyBindsThinking(payload),
|
|
31817
31927
|
method: "POST"
|
|
31818
31928
|
}),
|
|
31819
|
-
body,
|
|
31929
|
+
body: JSON.stringify(payload),
|
|
31820
31930
|
signal
|
|
31821
31931
|
});
|
|
31822
31932
|
} catch (error) {
|
|
@@ -33586,24 +33696,18 @@ function registerClaudeRoutes(ctx, store, modelSettings, preferences, options =
|
|
|
33586
33696
|
* is addressed at THAT account, which is what makes a re-login repair the row
|
|
33587
33697
|
* the user clicked instead of adding a second one.
|
|
33588
33698
|
*/
|
|
33589
|
-
const loginStore = (accountId) => {
|
|
33590
|
-
|
|
33591
|
-
|
|
33592
|
-
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
};
|
|
33597
|
-
return {
|
|
33598
|
-
read: () => base.read(),
|
|
33599
|
-
write: async (credentials) => {
|
|
33600
|
-
await base.write(credentials);
|
|
33601
|
-
if (pool !== void 0 && accountId !== void 0) await pool.clearAuthFailed(accountId).catch(() => void 0);
|
|
33602
|
-
clearCachedQuota$1();
|
|
33603
|
-
clearCachedCatalog();
|
|
33699
|
+
const loginStore = (accountId) => ({
|
|
33700
|
+
read: async () => pool !== void 0 && accountId !== void 0 ? pool.credentialStoreFor(accountId).read() : (await activeAccount()).credentials ?? null,
|
|
33701
|
+
write: async (credentials) => {
|
|
33702
|
+
if (pool === void 0) await store.saveAccount(credentials);
|
|
33703
|
+
else {
|
|
33704
|
+
const landed = await pool.addAccount(credentials);
|
|
33705
|
+
if (accountId !== void 0 && landed.id === accountId) await pool.clearAuthFailed(accountId).catch(() => void 0);
|
|
33604
33706
|
}
|
|
33605
|
-
|
|
33606
|
-
|
|
33707
|
+
clearCachedQuota$1();
|
|
33708
|
+
clearCachedCatalog();
|
|
33709
|
+
}
|
|
33710
|
+
});
|
|
33607
33711
|
const readStatus = (quotaError = null) => activeAccount().then((active) => getClaudeWebStatus(store, modelSettings, preferences, options, quotaError, active));
|
|
33608
33712
|
return ctx.webServer.register({
|
|
33609
33713
|
kind: "prefix",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClaudeSection.d.ts","sourceRoot":"","sources":["../../../../src/client/claude/ClaudeSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAA;AA2BvE,UAAU,KAAK;IACb,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;CAChC;AAoBD,wEAAwE;AACxE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOlE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AA+ED,wBAAgB,aAAa,CAAC,EAAE,aAAa,EAAE,kBAAkB,EAAE,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"ClaudeSection.d.ts","sourceRoot":"","sources":["../../../../src/client/claude/ClaudeSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAA;AA2BvE,UAAU,KAAK;IACb,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;CAChC;AAoBD,wEAAwE;AACxE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOlE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AA+ED,wBAAgB,aAAa,CAAC,EAAE,aAAa,EAAE,kBAAkB,EAAE,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CAk5B9F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/claude/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoHG;AAEH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,iBAAiB,EAEjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAs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,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAO7D;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,QAAQ,CA8D3D;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -145,6 +145,11 @@ export interface ClaudeHeaderOptions {
|
|
|
145
145
|
model?: string;
|
|
146
146
|
/** Whether this request enables thinking; adds the interleaved-thinking beta. */
|
|
147
147
|
thinking?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Whether this request's body carries `thinking.block_binding`; adds the beta
|
|
150
|
+
* that licenses the field. Without it the body is a 400 on every request.
|
|
151
|
+
*/
|
|
152
|
+
thinkingBinding?: boolean;
|
|
148
153
|
/** HTTP method. `content-type` is emitted unless this is a GET. */
|
|
149
154
|
method?: 'GET' | 'POST' | string;
|
|
150
155
|
/** Which product identity to report. Defaults to the Messages-API one. */
|
|
@@ -158,7 +163,7 @@ export interface ClaudeHeaderOptions {
|
|
|
158
163
|
* Order is not observable — the server parses the header as a set — so the order
|
|
159
164
|
* below is chosen for readability in a log rather than to match a reference.
|
|
160
165
|
*/
|
|
161
|
-
export declare function claudeBetas(options?: Pick<ClaudeHeaderOptions, 'model' | 'thinking'>): string[];
|
|
166
|
+
export declare function claudeBetas(options?: Pick<ClaudeHeaderOptions, 'model' | 'thinking' | 'thinkingBinding'>): string[];
|
|
162
167
|
/** The `User-Agent` value this line reports for one surface. */
|
|
163
168
|
export declare function claudeUserAgent(kind?: ClaudeUserAgentKind): string;
|
|
164
169
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/claude/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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5B;AAMD;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,SAAS,GACT,oBAAoB,GACpB,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,SAAS,CAAA;AAEb,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAA;IACvB,uEAAuE;IACvE,IAAI,EAAE,eAAe,GAAG,IAAI,CAAA;IAC5B,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;IACf,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,aAAa,EAAE,OAAO,CAAA;IACtB,qEAAqE;IACrE,mBAAmB,EAAE,OAAO,CAAA;IAC5B,sEAAsE;IACtE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,oEAAoE;IACpE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,6FAA6F;AAC7F,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;gBAEnB,OAAO,EAAE,aAAa;CAKnC;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAa5D;AAkDD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,kBAAuB,GAC/B,aAAa,CA0Hf"}
|
|
@@ -46,7 +46,9 @@
|
|
|
46
46
|
* everything, including a caller asking for thinking off: the
|
|
47
47
|
* block_binding exists so a prefix mismatch is dropped instead of
|
|
48
48
|
* surfacing as a persistent 400, and suppressing it is exactly
|
|
49
|
-
* how that 400 comes back.
|
|
49
|
+
* how that 400 comes back. The field is itself a 400 unless the
|
|
50
|
+
* request carries the thinking-binding-controls beta, so the
|
|
51
|
+
* adapter reads claudeBodyBindsThinking(body) to add it.
|
|
50
52
|
* adaptive -> { type: 'adaptive', display: 'summarized' }, plus
|
|
51
53
|
* output_config = { effort } when an effort was named. The budget
|
|
52
54
|
* form is rejected by these models.
|
|
@@ -139,11 +141,12 @@
|
|
|
139
141
|
* 'error' event THROWS, because a severed reply flushed as a clean stop is a
|
|
140
142
|
* wrong answer rather than a visible failure.
|
|
141
143
|
*
|
|
142
|
-
* Reasoning deltas are
|
|
143
|
-
*
|
|
144
|
-
* block may be replayed
|
|
145
|
-
*
|
|
146
|
-
*
|
|
144
|
+
* Reasoning deltas are STREAMED as they arrive (see openThinkingBlock); only the
|
|
145
|
+
* replay entry waits for content_block_stop, because the signature that decides
|
|
146
|
+
* whether the block may be replayed arrives at the END of the block. They used
|
|
147
|
+
* to be buffered until the stop, which made DSH start the step's first-token
|
|
148
|
+
* clock after all thinking was done - so TPS divided every thinking token by the
|
|
149
|
+
* answer's time alone, and TTFT absorbed the whole thinking phase.
|
|
147
150
|
*
|
|
148
151
|
* ---------------------------------------------------------------------------
|
|
149
152
|
* 7. PROMPT CACHING IS ON BY DEFAULT, AND IT IS THE REQUEST THAT TURNS IT ON
|
|
@@ -463,6 +466,15 @@ export interface ClaudeRequestOptions {
|
|
|
463
466
|
* is skipped only when request.cacheControl is explicitly false.
|
|
464
467
|
*/
|
|
465
468
|
export declare function buildClaudeRequestBody(options: GenerateOptions, images?: ResolvedRequestImages, request?: ClaudeRequestOptions): Record<string, unknown>;
|
|
469
|
+
/**
|
|
470
|
+
* Whether one built body carries `thinking.block_binding`.
|
|
471
|
+
*
|
|
472
|
+
* Read off the BODY rather than re-derived from the catalog, because the header
|
|
473
|
+
* this answers for (THINKING_BINDING_CONTROLS_BETA) exists to license that one
|
|
474
|
+
* field: sent without it the field is a 400 on every request, so the header must
|
|
475
|
+
* follow the bytes, not a second copy of the rule that produced them.
|
|
476
|
+
*/
|
|
477
|
+
export declare function claudeBodyBindsThinking(body: Record<string, unknown>): boolean;
|
|
466
478
|
/** One tool_use block accumulating across input_json_delta fragments. */
|
|
467
479
|
interface PendingToolCall {
|
|
468
480
|
/** Index of the DSH block this call occupies. */
|
|
@@ -482,12 +494,12 @@ interface OpenTextBlock {
|
|
|
482
494
|
text: string;
|
|
483
495
|
}
|
|
484
496
|
/**
|
|
485
|
-
* One thinking or redacted_thinking block
|
|
497
|
+
* One open thinking or redacted_thinking block.
|
|
486
498
|
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
* visible reasoning text.
|
|
499
|
+
* Its text streams to the caller as it arrives; this record accumulates the
|
|
500
|
+
* same text, the signature (which arrives at the END of the block) and a
|
|
501
|
+
* redacted block's payload, for the replay entry written when it closes. A
|
|
502
|
+
* redacted block's payload is never paraphrased into visible reasoning text.
|
|
491
503
|
*/
|
|
492
504
|
interface PendingThinking {
|
|
493
505
|
index: number;
|
|
@@ -504,7 +516,7 @@ export interface ClaudeStreamState {
|
|
|
504
516
|
openText: Map<number, OpenTextBlock>;
|
|
505
517
|
/** Anthropic content index -> the accumulating tool call. */
|
|
506
518
|
toolCalls: Map<number, PendingToolCall>;
|
|
507
|
-
/** Anthropic content index ->
|
|
519
|
+
/** Anthropic content index -> an open thinking block. */
|
|
508
520
|
pending: Map<number, PendingThinking>;
|
|
509
521
|
/**
|
|
510
522
|
* Anthropic content index -> the wire block that produced the emitted block.
|
|
@@ -525,11 +537,20 @@ export interface ClaudeStreamState {
|
|
|
525
537
|
hasToolCall: boolean;
|
|
526
538
|
/** Anthropic stop_reason, verbatim. */
|
|
527
539
|
finishReason: string | null;
|
|
540
|
+
/** `stop_details.explanation` from the final message_delta, when stated. */
|
|
541
|
+
stopExplanation?: string;
|
|
528
542
|
inputTokens: number;
|
|
529
543
|
outputTokens: number;
|
|
530
544
|
cacheReadTokens: number;
|
|
531
545
|
cacheWriteTokens: number;
|
|
546
|
+
/** Estimate from the streamed (possibly summarized) thinking text. */
|
|
532
547
|
reasoningTokens: number;
|
|
548
|
+
/**
|
|
549
|
+
* The server's own `usage.output_tokens_details.thinking_tokens`, when stated.
|
|
550
|
+
* It counts the RAW reasoning, which the summarized text returned on Claude 4+
|
|
551
|
+
* models understates, so it outranks the estimate above.
|
|
552
|
+
*/
|
|
553
|
+
reportedReasoningTokens: number | undefined;
|
|
533
554
|
sawUsage: boolean;
|
|
534
555
|
finished: boolean;
|
|
535
556
|
}
|