@namzu/anthropic 3.4.0 → 4.0.1

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.
@@ -163,10 +163,9 @@ export function resolveThinkingBody(thinking, capability) {
163
163
  * arrived with 4.7, and `max` does not exist below 4.6 — so `capability.effort`
164
164
  * is a set rather than a flag. It was a flag, which meant `xhigh` on a 4.6 and
165
165
  * `max` on a 4.5 were forwarded to a vendor that rejects an unknown level
166
- * rather than clamping it. Dropping the field is right where the level does
167
- * not exist: `effort` shapes an answer the model will still produce, so a
168
- * request without it is the same request at the model's own default, whereas
169
- * refusing would fail a call that has a correct answer.
166
+ * rather than clamping it. Refusing before transport is the only truthful
167
+ * outcome: silently dropping a caller's effort changes the request to the
168
+ * model default while reporting that the requested control was honoured.
170
169
  *
171
170
  * The COMBINATION has to be legal, and the legal set is per model rather than
172
171
  * universal. Opus 5 accepts `thinking: {type: "disabled"}` at `high` or below
@@ -180,10 +179,14 @@ export function resolveThinkingBody(thinking, capability) {
180
179
  * was discarding an effort the caller asked for and the wire would have
181
180
  * honoured. Incoherent-looking is not the same as rejected.
182
181
  */
183
- export function resolveEffort(effort, thinkingBody, capability) {
182
+ export function resolveEffort(effort, thinkingBody, capability, model) {
184
183
  if (effort === undefined)
185
184
  return undefined;
186
185
  const allowed = thinkingBody?.type === 'disabled' ? capability.effortWhenDisabled : capability.effort;
187
- return allowed.includes(effort) ? effort : undefined;
186
+ if (allowed.includes(effort))
187
+ return effort;
188
+ const target = model ? ` by model "${model}"` : ' by this model/thinking combination';
189
+ const offered = allowed.length > 0 ? allowed.join(', ') : 'none';
190
+ throw new Error(`AnthropicProvider: effort "${effort}" is not supported${target}. Supported levels: ${offered}. Choose one of those levels or omit \`effort\`.`);
188
191
  }
189
192
  //# sourceMappingURL=thinking-capability.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"thinking-capability.js","sourceRoot":"","sources":["../src/thinking-capability.ts"],"names":[],"mappings":"AAAA,OA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,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,aAAa,CAC5B,MAAmC,EACnC,YAAkC,EAClC,UAA8B,EAC9B,KAAc;IAEd,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC1C,MAAM,OAAO,GACZ,YAAY,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAA;IACtF,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,cAAc,KAAK,GAAG,CAAC,CAAC,CAAC,qCAAqC,CAAA;IACrF,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IAChE,MAAM,IAAI,KAAK,CACd,8BAA8B,MAAM,qBAAqB,MAAM,uBAAuB,OAAO,kDAAkD,CAC/I,CAAA;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/anthropic",
3
- "version": "3.4.0",
3
+ "version": "4.0.1",
4
4
  "description": "Anthropic LLM provider for @namzu/sdk via the official @anthropic-ai/sdk. Messages API with streaming, tool-use, and extended thinking support.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "engines": {
@@ -57,7 +57,7 @@
57
57
  "@types/node": "^22.19.17",
58
58
  "typescript": "^5.5.0",
59
59
  "vitest": "^3.2.6",
60
- "@namzu/sdk": "^30.1.0"
60
+ "@namzu/sdk": "^31.1.0"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "tsc --build",
package/src/client.ts CHANGED
@@ -7,6 +7,7 @@ import type {
7
7
  LLMProvider,
8
8
  ModelInfo,
9
9
  ProviderCapabilities,
10
+ ProviderRoute,
10
11
  ReasoningBlock,
11
12
  ReasoningEffort,
12
13
  StreamChunk,
@@ -48,8 +49,9 @@ const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 0
48
49
  // Claude Code OAuth tokens are scoped to Claude Code usage. Anthropic
49
50
  // authorizes them only when three signals are all present, else 401:
50
51
  // 1. the OAuth beta headers,
51
- // 2. a `claude-cli/<version>` user-agent (version validated server-side),
52
- // 3. a system prompt whose first block is the Claude Code identity line.
52
+ // 2. a `claude-code/<version>` user-agent (version validated server-side),
53
+ // 3. the CLI application marker,
54
+ // 4. a system prompt whose first block is the Claude Code identity line.
53
55
  const OAUTH_BETAS = 'claude-code-20250219,oauth-2025-04-20'
54
56
  const CLAUDE_CODE_SYSTEM_PREFIX = "You are Claude Code, Anthropic's official CLI for Claude."
55
57
  const CLAUDE_CODE_VERSION_FALLBACK = '2.1.74'
@@ -157,7 +159,7 @@ type AttachmentLike =
157
159
  }
158
160
 
159
161
  /**
160
- * A reasoning block, replayed exactly as it arrived.
162
+ * A reasoning block in this provider's native history shape.
161
163
  *
162
164
  * The signature is cryptographic and verified upstream: a block echoed
163
165
  * back with its text edited, its signature dropped, or its order changed
@@ -172,6 +174,17 @@ interface AnthropicThinkingBlock {
172
174
  cache_control?: AnthropicCacheControl
173
175
  }
174
176
 
177
+ type AnthropicReplayBlock =
178
+ | { type: 'thinking'; thinking: string; signature: string }
179
+ | { type: 'redacted_thinking'; data: string }
180
+
181
+ interface AnthropicReplayState {
182
+ readonly kind: 'namzu-anthropic-reasoning'
183
+ readonly version: 1
184
+ readonly route: ProviderRoute
185
+ readonly blocks: readonly AnthropicReplayBlock[]
186
+ }
187
+
175
188
  interface AnthropicDocumentBlock {
176
189
  type: 'document'
177
190
  source: { type: 'base64'; media_type: string; data: string }
@@ -223,28 +236,132 @@ function extractSystem(
223
236
  }
224
237
 
225
238
  /**
226
- * The reasoning blocks an assistant message carries, in wire form.
227
- *
228
- * Verbatim by contract, and first in the message: the API requires
229
- * thinking blocks to lead, and the signature is verified, so re-rendering
230
- * or reordering them invalidates the turn they belong to.
239
+ * Resolve the exact target member for this adapter call.
231
240
  */
232
- function replayReasoning(msg: { reasoning?: readonly ReasoningBlock[] }): AnthropicThinkingBlock[] {
233
- if (!msg.reasoning || msg.reasoning.length === 0) return []
234
- return msg.reasoning.map((block) =>
235
- block.type === 'redacted_thinking'
236
- ? {
237
- type: 'redacted_thinking' as const,
238
- ...(block.encrypted ? { data: block.encrypted } : {}),
239
- }
240
- : {
241
- type: 'thinking' as const,
242
- thinking: block.text ?? '',
243
- ...(block.signature ? { signature: block.signature } : {}),
244
- },
241
+ function resolveAnthropicRoute(model: string, candidate: ProviderRoute | undefined): ProviderRoute {
242
+ if (candidate === undefined) return { providerId: 'anthropic', model, chainIndex: 0 }
243
+ if (
244
+ candidate.providerId !== 'anthropic' ||
245
+ candidate.model !== model ||
246
+ !Number.isSafeInteger(candidate.chainIndex) ||
247
+ candidate.chainIndex < 0
248
+ ) {
249
+ throw new Error(
250
+ 'AnthropicProvider: providerRoute must name this provider, the requested model, and a non-negative integer chainIndex.',
251
+ )
252
+ }
253
+ return candidate
254
+ }
255
+
256
+ function sameRoute(left: ProviderRoute, right: ProviderRoute): boolean {
257
+ return (
258
+ left.providerId === right.providerId &&
259
+ left.model === right.model &&
260
+ left.chainIndex === right.chainIndex
261
+ )
262
+ }
263
+
264
+ function isAnthropicReplayState(value: unknown): value is AnthropicReplayState {
265
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) return false
266
+ const state = value as Record<string, unknown>
267
+ const route = state.route
268
+ if (
269
+ state.kind !== 'namzu-anthropic-reasoning' ||
270
+ state.version !== 1 ||
271
+ typeof route !== 'object' ||
272
+ route === null ||
273
+ Array.isArray(route) ||
274
+ typeof (route as Record<string, unknown>).providerId !== 'string' ||
275
+ typeof (route as Record<string, unknown>).model !== 'string' ||
276
+ !Number.isSafeInteger((route as Record<string, unknown>).chainIndex) ||
277
+ ((route as Record<string, unknown>).chainIndex as number) < 0 ||
278
+ !Array.isArray(state.blocks)
279
+ ) {
280
+ return false
281
+ }
282
+ return state.blocks.every((value) => {
283
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) return false
284
+ const block = value as Record<string, unknown>
285
+ return block.type === 'thinking'
286
+ ? typeof block.thinking === 'string' && typeof block.signature === 'string'
287
+ : block.type === 'redacted_thinking' && typeof block.data === 'string'
288
+ })
289
+ }
290
+
291
+ function durableAnthropicReasoning(
292
+ reasoning: readonly ReasoningBlock[] | undefined,
293
+ ): readonly AnthropicReplayBlock[] | undefined {
294
+ if (!reasoning || reasoning.length === 0) return undefined
295
+ const blocks: AnthropicReplayBlock[] = []
296
+ for (const block of reasoning) {
297
+ if (block.type === 'thinking') {
298
+ if (
299
+ typeof block.text !== 'string' ||
300
+ typeof block.signature !== 'string' ||
301
+ block.signature.length === 0 ||
302
+ block.encrypted !== undefined
303
+ ) {
304
+ return undefined
305
+ }
306
+ blocks.push({
307
+ type: 'thinking',
308
+ thinking: block.text,
309
+ signature: block.signature,
310
+ })
311
+ continue
312
+ }
313
+ if (
314
+ typeof block.encrypted !== 'string' ||
315
+ block.encrypted.length === 0 ||
316
+ block.text !== undefined ||
317
+ block.signature !== undefined
318
+ ) {
319
+ return undefined
320
+ }
321
+ blocks.push({ type: 'redacted_thinking', data: block.encrypted })
322
+ }
323
+ return blocks
324
+ }
325
+
326
+ function replayBlocksEqual(
327
+ left: readonly AnthropicReplayBlock[],
328
+ right: readonly AnthropicReplayBlock[],
329
+ ): boolean {
330
+ return (
331
+ left.length === right.length &&
332
+ left.every((block, index) => {
333
+ const other = right[index]
334
+ if (!other || block.type !== other.type) return false
335
+ return block.type === 'thinking' && other.type === 'thinking'
336
+ ? block.thinking === other.thinking && block.signature === other.signature
337
+ : block.type === 'redacted_thinking' &&
338
+ other.type === 'redacted_thinking' &&
339
+ block.data === other.data
340
+ })
245
341
  )
246
342
  }
247
343
 
344
+ /**
345
+ * The reasoning blocks an assistant message may restore in native wire form.
346
+ *
347
+ * Durable reasoning alone is not authority to emit signed provider metadata.
348
+ * The adapter-private envelope must be well-formed, agree with that durable
349
+ * content, and belong to the exact target route. Otherwise the assistant text
350
+ * and tool calls remain usable while native thinking is omitted.
351
+ */
352
+ function replayReasoning(
353
+ msg: Extract<ChatCompletionParams['messages'][number], { role: 'assistant' }>,
354
+ targetRoute: ProviderRoute,
355
+ ): AnthropicThinkingBlock[] {
356
+ const source = msg.source
357
+ if (!source || source.type !== 'model' || !sameRoute(source, targetRoute)) return []
358
+ const state = source.replayState
359
+ if (!isAnthropicReplayState(state) || !sameRoute(state.route, source)) return []
360
+ const durable = durableAnthropicReasoning(msg.reasoning)
361
+ if (!durable || !replayBlocksEqual(durable, state.blocks)) return []
362
+ return state.blocks.map((block) => ({ ...block }))
363
+ }
364
+
248
365
  /**
249
366
  * A tool result, in the richest form this wire accepts.
250
367
  *
@@ -269,7 +386,11 @@ function toolResultContent(
269
386
  if (block.type === 'image') {
270
387
  blocks.push({
271
388
  type: 'image',
272
- source: { type: 'base64', media_type: block.mediaType, data: block.data },
389
+ source: {
390
+ type: 'base64',
391
+ media_type: block.mediaType,
392
+ data: block.data,
393
+ },
273
394
  })
274
395
  continue
275
396
  }
@@ -280,7 +401,10 @@ function toolResultContent(
280
401
  return blocks.length > 0 ? blocks : ''
281
402
  }
282
403
 
283
- function toAnthropicMessages(messages: ChatCompletionParams['messages']): AnthropicMessageParam[] {
404
+ function toAnthropicMessages(
405
+ messages: ChatCompletionParams['messages'],
406
+ targetRoute: ProviderRoute,
407
+ ): AnthropicMessageParam[] {
284
408
  const out: AnthropicMessageParam[] = []
285
409
  let pendingToolResults: AnthropicToolResultBlock[] = []
286
410
 
@@ -295,7 +419,10 @@ function toAnthropicMessages(messages: ChatCompletionParams['messages']): Anthro
295
419
  if (msg.role === 'system') continue
296
420
 
297
421
  if (msg.role === 'tool') {
298
- const toolMsg = msg as { toolCallId?: string; content?: ToolResultContent }
422
+ const toolMsg = msg as {
423
+ toolCallId?: string
424
+ content?: ToolResultContent
425
+ }
299
426
  pendingToolResults.push({
300
427
  type: 'tool_result',
301
428
  tool_use_id: toolMsg.toolCallId ?? 'unknown',
@@ -307,7 +434,7 @@ function toAnthropicMessages(messages: ChatCompletionParams['messages']): Anthro
307
434
  flushToolResults()
308
435
 
309
436
  if (msg.role === 'assistant' && 'toolCalls' in msg && msg.toolCalls) {
310
- const blocks: AnthropicContentBlock[] = [...replayReasoning(msg)]
437
+ const blocks: AnthropicContentBlock[] = [...replayReasoning(msg, targetRoute)]
311
438
  if (msg.content && typeof msg.content === 'string') {
312
439
  blocks.push({ type: 'text', text: msg.content })
313
440
  }
@@ -331,7 +458,7 @@ function toAnthropicMessages(messages: ChatCompletionParams['messages']): Anthro
331
458
 
332
459
  // An assistant turn that reasoned replays those blocks even when it
333
460
  // called no tool: dropping them invalidates the turn upstream.
334
- const replayed = msg.role === 'assistant' ? replayReasoning(msg) : []
461
+ const replayed = msg.role === 'assistant' ? replayReasoning(msg, targetRoute) : []
335
462
  const content = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)
336
463
  if (replayed.length > 0) {
337
464
  const trailing: AnthropicContentBlock[] =
@@ -354,7 +481,11 @@ function toAnthropicMessages(messages: ChatCompletionParams['messages']): Anthro
354
481
  if (att.type === 'document') {
355
482
  blocks.push({
356
483
  type: 'document',
357
- source: { type: 'base64', media_type: att.mediaType, data: att.data },
484
+ source: {
485
+ type: 'base64',
486
+ media_type: att.mediaType,
487
+ data: att.data,
488
+ },
358
489
  ...(att.name ? { title: att.name } : {}),
359
490
  // Opt-in: citations cost tokens, so they are requested
360
491
  // only when the caller asked to be able to check the
@@ -416,7 +547,9 @@ function toAnthropicTools(
416
547
  // here rather than in the renderer keeps the dialect where the
417
548
  // knowledge is: only this file knows which wire it is talking to.
418
549
  input_schema: toSchemaDialect(
419
- (t.function.parameters as Record<string, unknown> | undefined) ?? { type: 'object' },
550
+ (t.function.parameters as Record<string, unknown> | undefined) ?? {
551
+ type: 'object',
552
+ },
420
553
  '2020-12',
421
554
  ),
422
555
  ...(strict ? { strict: true } : {}),
@@ -607,13 +740,25 @@ function toCitation(raw: RawAnthropicCitation, index: number): Citation | undefi
607
740
  | { kind: 'block'; start: number; end: number }
608
741
  | undefined => {
609
742
  if (raw.start_page_number !== undefined && raw.end_page_number !== undefined) {
610
- return { kind: 'page', start: raw.start_page_number, end: raw.end_page_number }
743
+ return {
744
+ kind: 'page',
745
+ start: raw.start_page_number,
746
+ end: raw.end_page_number,
747
+ }
611
748
  }
612
749
  if (raw.start_char_index !== undefined && raw.end_char_index !== undefined) {
613
- return { kind: 'char', start: raw.start_char_index, end: raw.end_char_index }
750
+ return {
751
+ kind: 'char',
752
+ start: raw.start_char_index,
753
+ end: raw.end_char_index,
754
+ }
614
755
  }
615
756
  if (raw.start_block_index !== undefined && raw.end_block_index !== undefined) {
616
- return { kind: 'block', start: raw.start_block_index, end: raw.end_block_index }
757
+ return {
758
+ kind: 'block',
759
+ start: raw.start_block_index,
760
+ end: raw.end_block_index,
761
+ }
617
762
  }
618
763
  return undefined
619
764
  })()
@@ -631,7 +776,14 @@ interface StreamEvent {
631
776
  type: string
632
777
  message?: { id?: string; usage?: RawAnthropicUsage }
633
778
  index?: number
634
- content_block?: { type?: string; id?: string; name?: string; data?: string }
779
+ content_block?: {
780
+ type?: string
781
+ id?: string
782
+ name?: string
783
+ data?: string
784
+ thinking?: string
785
+ signature?: string
786
+ }
635
787
  delta?: {
636
788
  type?: string
637
789
  text?: string
@@ -681,20 +833,21 @@ export class AnthropicProvider implements LLMProvider {
681
833
  if (config.authToken) {
682
834
  clientOpts.authToken = config.authToken
683
835
  // OAuth routes require both beta flags + a Claude Code user-agent;
684
- // without them Anthropic rejects subscription / Claude Code OAuth
685
- // tokens (intermittent 401/500). The system-prompt identity block
686
- // is added per-request in buildCreateParams.
836
+ // without that identity the Messages endpoint does not admit the token
837
+ // as Claude Code subscription traffic. The system-prompt identity block
838
+ // is added per request in buildCreateParams.
687
839
  const headers: Record<string, string> = {
688
840
  'anthropic-beta': OAUTH_BETAS,
689
- 'user-agent': `claude-cli/${detectClaudeCodeVersion()} (external, cli)`,
841
+ 'user-agent': `claude-code/${detectClaudeCodeVersion()} (external, cli)`,
842
+ 'x-app': 'cli',
690
843
  ...(config.defaultHeaders ?? {}),
691
844
  }
692
845
  clientOpts.defaultHeaders = headers
693
846
  } else {
694
847
  clientOpts.apiKey = config.apiKey
695
848
  // This branch ONLY. The OAuth branch above sends a Claude Code
696
- // user-agent because the token-exchange endpoint requires it —
697
- // that is load-bearing impersonation, and merging attribution
849
+ // user-agent because subscription inference requires it — that is
850
+ // load-bearing impersonation, and merging attribution
698
851
  // into it would break authentication, not improve labelling.
699
852
  clientOpts.defaultHeaders = {
700
853
  ...attributionHeaders(),
@@ -727,8 +880,9 @@ export class AnthropicProvider implements LLMProvider {
727
880
  // earlier sections too).
728
881
  const cachingEnabled = params.cacheControl !== undefined
729
882
  const model = this.resolveModel(params)
883
+ const providerRoute = resolveAnthropicRoute(model, params.providerRoute)
730
884
  const system = extractSystem(params.messages, cachingEnabled)
731
- const messages = toAnthropicMessages(params.messages)
885
+ const messages = toAnthropicMessages(params.messages, providerRoute)
732
886
  if (cachingEnabled) applyMessageCacheBreakpoint(messages)
733
887
  const tools = toAnthropicTools(
734
888
  params,
@@ -773,20 +927,24 @@ export class AnthropicProvider implements LLMProvider {
773
927
  // newer models, so a caller who wanted to show reasoning and never
774
928
  // serialized the field received thinking blocks with empty text and
775
929
  // nothing to explain why.
776
- const capability = resolveThinkingCapability(params.model)
930
+ const capability = resolveThinkingCapability(model)
777
931
  const thinkingBody = resolveThinkingBody(params.thinking, capability)
778
932
  if (thinkingBody) body.thinking = thinkingBody
779
933
 
780
934
  // A sibling of `thinking`, not a field inside it — and gated on the
781
935
  // model, since only some accept it at all.
782
- const effort = resolveEffort(params.effort, thinkingBody, capability)
936
+ const effort = resolveEffort(params.effort, thinkingBody, capability, model)
783
937
  // Merged rather than assigned. `output_config` is a shared envelope on
784
938
  // this wire — a structured-output format and a task budget live in it
785
939
  // too, and `responseFormat` already exists on the params unhandled
786
940
  // here. Assigning would mean whoever wires the next one silently
787
941
  // deletes effort, or has effort silently delete theirs, depending only
788
942
  // on which line ran last.
789
- if (effort) body.output_config = { ...(body.output_config as object | undefined), effort }
943
+ if (effort)
944
+ body.output_config = {
945
+ ...(body.output_config as object | undefined),
946
+ effort,
947
+ }
790
948
  if (params.temperature !== undefined) body.temperature = params.temperature
791
949
  if (params.topP !== undefined) body.top_p = params.topP
792
950
  if (params.topK !== undefined) body.top_k = params.topK
@@ -816,6 +974,7 @@ export class AnthropicProvider implements LLMProvider {
816
974
  }
817
975
 
818
976
  async *chatStream(params: ChatCompletionParams): AsyncIterable<StreamChunk> {
977
+ const providerRoute = resolveAnthropicRoute(this.resolveModel(params), params.providerRoute)
819
978
  const createParams = this.buildCreateParams(params, true)
820
979
  const signal = params.signal
821
980
 
@@ -840,6 +999,30 @@ export class AnthropicProvider implements LLMProvider {
840
999
  // fragments can reference the right tool call.
841
1000
  const activeTools = new Map<number, { id: string; name: string }>()
842
1001
  const activeReasoning = new Set<number>()
1002
+ const nativeReasoning = new Map<number, AnthropicReplayBlock>()
1003
+ let replayStateEmitted = false
1004
+ const completedReplayState = (): AnthropicReplayState | undefined => {
1005
+ if (replayStateEmitted || activeReasoning.size > 0 || nativeReasoning.size === 0) {
1006
+ return undefined
1007
+ }
1008
+ const blocks = [...nativeReasoning.entries()]
1009
+ .sort(([left], [right]) => left - right)
1010
+ .map(([, block]) => ({ ...block }))
1011
+ if (
1012
+ blocks.some((block) =>
1013
+ block.type === 'thinking' ? block.signature.length === 0 : block.data.length === 0,
1014
+ )
1015
+ ) {
1016
+ return undefined
1017
+ }
1018
+ replayStateEmitted = true
1019
+ return {
1020
+ kind: 'namzu-anthropic-reasoning',
1021
+ version: 1,
1022
+ route: providerRoute,
1023
+ blocks,
1024
+ }
1025
+ }
843
1026
 
844
1027
  // Anthropic Messages API streams over SSE. Do not impose a
845
1028
  // provider-local 90s idle cutoff by default: long reasoning or
@@ -902,6 +1085,18 @@ export class AnthropicProvider implements LLMProvider {
902
1085
  const block = event.content_block
903
1086
  if (block?.type === 'thinking' || block?.type === 'redacted_thinking') {
904
1087
  activeReasoning.add(idx)
1088
+ if (block.type === 'thinking') {
1089
+ nativeReasoning.set(idx, {
1090
+ type: 'thinking',
1091
+ thinking: block.thinking ?? '',
1092
+ signature: block.signature ?? '',
1093
+ })
1094
+ } else {
1095
+ nativeReasoning.set(idx, {
1096
+ type: 'redacted_thinking',
1097
+ data: block.data ?? '',
1098
+ })
1099
+ }
905
1100
  yield {
906
1101
  id: messageId,
907
1102
  delta: {
@@ -939,16 +1134,22 @@ export class AnthropicProvider implements LLMProvider {
939
1134
  if (delta?.type === 'text_delta' && delta.text) {
940
1135
  yield { id: messageId, delta: { content: delta.text } }
941
1136
  } else if (delta?.type === 'thinking_delta' && delta.thinking !== undefined) {
1137
+ const native = nativeReasoning.get(idx)
1138
+ if (native?.type === 'thinking') native.thinking += delta.thinking
942
1139
  yield {
943
1140
  id: messageId,
944
1141
  delta: { reasoning: { index: idx, text: delta.thinking } },
945
1142
  }
946
1143
  } else if (delta?.type === 'signature_delta' && delta.signature !== undefined) {
1144
+ const native = nativeReasoning.get(idx)
1145
+ if (native?.type === 'thinking') native.signature += delta.signature
947
1146
  // Arrives once, at the end of the block, and has to
948
1147
  // reach the next request unmodified.
949
1148
  yield {
950
1149
  id: messageId,
951
- delta: { reasoning: { index: idx, signature: delta.signature } },
1150
+ delta: {
1151
+ reasoning: { index: idx, signature: delta.signature },
1152
+ },
952
1153
  }
953
1154
  } else if (delta?.type === 'citations_delta' && delta.citation) {
954
1155
  // Not text: a citation lands on the assistant
@@ -988,7 +1189,10 @@ export class AnthropicProvider implements LLMProvider {
988
1189
  // Closes the block, exactly as toolCallEnd closes a
989
1190
  // tool call: without it the aggregator cannot know
990
1191
  // the signature has finished arriving.
991
- yield { id: messageId, delta: { reasoning: { index: idx, done: true } } }
1192
+ yield {
1193
+ id: messageId,
1194
+ delta: { reasoning: { index: idx, done: true } },
1195
+ }
992
1196
  break
993
1197
  }
994
1198
  const active = activeTools.get(idx)
@@ -1005,8 +1209,10 @@ export class AnthropicProvider implements LLMProvider {
1005
1209
  }
1006
1210
  case 'message_delta': {
1007
1211
  if (event.delta?.stop_reason) {
1212
+ const replayState = completedReplayState()
1008
1213
  yield {
1009
1214
  id: messageId,
1215
+ ...(replayState !== undefined ? { replayState } : {}),
1010
1216
  delta: {},
1011
1217
  finishReason: mapStopReason(event.delta.stop_reason),
1012
1218
  usage: event.usage ? parseUsage(event.usage) : undefined,
@@ -1020,8 +1226,13 @@ export class AnthropicProvider implements LLMProvider {
1020
1226
  }
1021
1227
  break
1022
1228
  }
1023
- case 'message_stop':
1229
+ case 'message_stop': {
1230
+ const replayState = completedReplayState()
1231
+ if (replayState !== undefined) {
1232
+ yield { id: messageId, delta: {}, replayState }
1233
+ }
1024
1234
  return
1235
+ }
1025
1236
  default:
1026
1237
  // Ignore unknown / ping / opaque events.
1027
1238
  break
@@ -1056,12 +1267,15 @@ export class AnthropicProvider implements LLMProvider {
1056
1267
  }
1057
1268
  }
1058
1269
 
1059
- async listModels(): Promise<ModelInfo[]> {
1270
+ async listModels(signal?: AbortSignal): Promise<ModelInfo[]> {
1271
+ signal?.throwIfAborted()
1060
1272
  try {
1061
1273
  // Models API shipped in SDK ~0.32+. Feature-detect via unknown cast so we
1062
1274
  // don't depend on the SDK's surface-level shape in a version-brittle way.
1063
1275
  const clientLike = this.client as unknown as {
1064
- models?: { list?: (opts: { limit: number }) => Promise<unknown> }
1276
+ models?: {
1277
+ list?: (opts: { limit: number }, request?: { signal?: AbortSignal }) => Promise<unknown>
1278
+ }
1065
1279
  }
1066
1280
  const models = clientLike.models
1067
1281
  if (typeof models?.list !== 'function') {
@@ -1072,9 +1286,10 @@ export class AnthropicProvider implements LLMProvider {
1072
1286
  // TypeError on EVERY call — which the catch below swallowed, so this
1073
1287
  // listing never once reached the network and the hardcoded models
1074
1288
  // were not a fallback but the only answer this method could give.
1075
- const page = (await models.list({ limit: 100 })) as {
1289
+ const page = (await models.list({ limit: 100 }, signal ? { signal } : undefined)) as {
1076
1290
  data?: Array<{ id?: string; display_name?: string; type?: string }>
1077
1291
  }
1292
+ signal?.throwIfAborted()
1078
1293
  const data = page?.data ?? []
1079
1294
  if (data.length === 0) return this.knownModels()
1080
1295
  return data.map((m) => ({
@@ -1086,6 +1301,7 @@ export class AnthropicProvider implements LLMProvider {
1086
1301
  supportsStreaming: true,
1087
1302
  }))
1088
1303
  } catch {
1304
+ if (signal?.aborted) throw signal.reason
1089
1305
  return this.knownModels()
1090
1306
  }
1091
1307
  }
@@ -1101,9 +1317,12 @@ export class AnthropicProvider implements LLMProvider {
1101
1317
  * An SDK too old to expose `models.list` throws rather than passing, so the
1102
1318
  * caller reports unverifiable — nothing was asked, so nothing is known.
1103
1319
  */
1104
- async probeCredential(): Promise<void> {
1320
+ async probeCredential(signal?: AbortSignal): Promise<void> {
1321
+ signal?.throwIfAborted()
1105
1322
  const clientLike = this.client as unknown as {
1106
- models?: { list?: (opts: { limit: number }) => Promise<unknown> }
1323
+ models?: {
1324
+ list?: (opts: { limit: number }, request?: { signal?: AbortSignal }) => Promise<unknown>
1325
+ }
1107
1326
  }
1108
1327
  const models = clientLike.models
1109
1328
  if (typeof models?.list !== 'function') {
@@ -1112,7 +1331,8 @@ export class AnthropicProvider implements LLMProvider {
1112
1331
  // Called ON the namespace. Pulling the method into a bare variable and
1113
1332
  // invoking it loses `this`, and the SDK reads `this._client` — which is
1114
1333
  // how the sibling `listModels` came to never execute at all.
1115
- await models.list({ limit: 1 })
1334
+ await models.list({ limit: 1 }, signal ? { signal } : undefined)
1335
+ signal?.throwIfAborted()
1116
1336
  }
1117
1337
 
1118
1338
  private knownModels(): ModelInfo[] {
@@ -1146,6 +1366,10 @@ export class AnthropicProvider implements LLMProvider {
1146
1366
  const body = resolveThinkingBody(thinking, capability)
1147
1367
  return body?.type === 'disabled' ? capability.effortWhenDisabled : capability.effort
1148
1368
  }
1369
+
1370
+ reasoningEffortLevelsFor(model: string, thinking?: ThinkingConfig): readonly ReasoningEffort[] {
1371
+ return this.effortLevelsFor(model, thinking)
1372
+ }
1149
1373
  }
1150
1374
 
1151
1375
  /**