@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,186 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9e1c9a3: Repair Claude subscription sign-in by matching the current registered browser request, letting the provider picker accept its returned authorization code, and preserving the subscription-routing identity on model requests. Print the TUI banner once during boot and keep the permanent idle key legend out of the footer while preserving state-specific interaction hints.
8
+
9
+ ## 4.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 94d3306: Add the chain-aware `reasoningEffortLevelsFor(model, thinking)` provider capability while retaining `effortLevelsFor` as a deprecated compatibility member. The four capability states now distinguish a driver with no menu, an unknown model, an explicitly unsupported model, and an exact selectable set; fallback chains expose only levels every reachable member accepts.
14
+
15
+ The TUI adds session-scoped `/effort [level|default]`, sends the selection to later main-query turns, and resets it atomically when a provider/model replacement succeeds. Failed or cancelled replacements preserve the current selection.
16
+
17
+ OpenAI publishes exact known-model menus and keeps unknown compatible-endpoint models unknown. DeepSeek explicitly publishes no supported levels. Anthropic now refuses unsupported effort levels before transport instead of silently dropping them; callers upgrading Anthropic must choose a level returned by `reasoningEffortLevelsFor()` or omit `effort` to retain the provider default.
18
+
19
+ - ee4fd1d: Persist provider-native reasoning state with the exact provider, model, and fallback-chain member that produced it. Same-route sessions now replay native reasoning after restart, `/resume`, and `/fork`; a model, provider, or member switch keeps portable assistant/tool history without sending foreign native reasoning metadata.
20
+
21
+ `@namzu/sdk` adds `ProviderRoute`, `AssistantMessageSource`, optional assistant source/replay fields, and the provider request/stream/response plumbing. Fallback and forced-final turns now attribute provenance and cost to the member that actually answered.
22
+
23
+ `@namzu/cli` preserves and validates the additive assistant source shape in stateless and durable history.
24
+
25
+ **What breaks in the drivers:** hand-built assistant reasoning and histories written by earlier versions do not carry a validated route-bound replay envelope, so they are no longer emitted as native `reasoning_content` or signed thinking. Their portable assistant text and tool exchanges remain available, but an upstream that requires native metadata for an old tool continuation may refuse that request; compact or start a fresh conversation before continuing such legacy history. Preserve the complete assistant message returned by new runs, including `source.replayState`. Direct callers of the exported DeepSeek `toDeepSeekMessages` converter must also pass the target `ProviderRoute` as its second argument.
26
+
27
+ ### Patch Changes
28
+
29
+ - 15f8ee4: Bound provider stream silence, including query-owned advisory calls and
30
+ RouterAgent routing decisions, compaction verifiers and model-graded eval
31
+ judges, to five minutes by default and abort the stalled provider transport,
32
+ with network-classified retry and fallback recovery where those policies
33
+ apply. This changes the previous default, under which a provider iterator could
34
+ remain silent forever. Set `streamIdleTimeoutMs: 0` on the run, agent, manual
35
+ compaction, verifier, or judge config to keep the old unbounded behavior, or set
36
+ a positive millisecond value to choose a different bound.
37
+
38
+ Queries whose caller signal is already aborted now settle as cancelled before
39
+ starting provider, provider-metadata, or tool work. A later cancellation also
40
+ settles while an optional context-window resolver remains pending, even when
41
+ that resolver ignores its signal. With no caller cancellation, `timeoutMs`
42
+ bounds the optional metadata lookup, aborts its private transport signal, and
43
+ falls back to the static context-window table instead of blocking the run.
44
+
45
+ The OpenRouter context-window lookup now forwards cancellation to its model-list
46
+ transport. Only fulfilled listings are cached, so cancelling one concurrent
47
+ query cannot abort another query's shared metadata request or force that query
48
+ onto the static context-window table.
49
+
50
+ `runExperiment({ timeoutMs })` now applies one validated wall-clock deadline to
51
+ both case execution and scoring. Scorers receive its optional cancellation
52
+ signal; a non-cooperative scorer is detached, and `judgeScorer` forwards the
53
+ signal to its bounded provider transport. Values outside the positive platform
54
+ timer range are refused before a case starts; omit the field for the prior
55
+ unbounded case behavior.
56
+
57
+ Compaction verification inside a query now carries the run cancellation cause
58
+ to its provider transport without placing a second idle timer around retry and
59
+ fallback. Public `buildVerifiedSummary`, `compactNow`, and `compactRegion`
60
+ calls bound raw provider silence themselves and accept optional `signal` and
61
+ `streamIdleTimeoutMs`; malformed values and pre-cancelled manual work are
62
+ refused before provider work or a no-op result.
63
+
64
+ HTTP embedding batches now have a 30-second whole-request default, including
65
+ response-body reads, where the previous default could wait forever. Set
66
+ `requestTimeoutMs: 0` on `HttpEmbeddingProvider` to keep the former unbounded
67
+ behavior. Invalid timeout values and non-positive or fractional `batchSize`
68
+ or `dimensions` values are refused at construction instead of silently
69
+ disabling the bound or entering a non-progressing batch loop. Successful HTTP
70
+ responses must contain exactly one unique, in-range result per input and finite
71
+ vectors of the configured dimension; malformed or incomplete batches are
72
+ refused atomically instead of reaching ingestion with missing embeddings.
73
+
74
+ Public RAG operations accept optional cancellation context. The shipped
75
+ `knowledge_search` tool forwards its run-owned signal through
76
+ `KnowledgeBase`, retrieval or ingestion, and the embedding provider. The HTTP
77
+ provider preserves the caller's exact cancellation reason while aborting only
78
+ its private fetch transport. Custom embedding providers receive the signal as
79
+ a cooperative request; callers still own their wait boundary if a custom
80
+ implementation ignores it. Default retrieval and ingestion recheck authority
81
+ after that custom call settles, so a late result cannot start a vector search
82
+ or persist chunks after cancellation. `VectorStore.search` and `upsert` now
83
+ receive the same optional operation context. The default pipelines also race
84
+ those store promises against cancellation, so a non-cooperative custom store
85
+ cannot leave the public query or ingestion call pending forever.
86
+
87
+ A2A agent-card discovery now has a 30-second whole fetch-and-body default and
88
+ accepts an optional caller signal and `timeoutMs`; set `timeoutMs: 0` to retain
89
+ the former unbounded behavior. `A2ADelegate.timeoutMs` now starts before
90
+ `message/send` and bounds the whole delegation instead of polling only. A
91
+ pre-cancelled dispatch starts no remote work, pending fetch and body promises
92
+ cannot hold `waitForTask`, and caller cancellation preserves its exact cause on
93
+ the private transport. Poll and delegation timers are validated at
94
+ construction. Once a safe task id exists, cancellation or timeout sends one
95
+ independently bounded `tasks/cancel`; during initial task creation the client
96
+ keeps a short cleanup grace and explicitly reports an unknown remote outcome if
97
+ the peer never returns an addressable id. Poll replies are bound to that initial
98
+ id, and transport or protocol failures after it is known make the same bounded
99
+ cleanup attempt before the original failure is returned. An `input-required`
100
+ task is also bounded-cancelled before the delegate reports that it cannot
101
+ supply the requested input.
102
+
103
+ Connector execution now carries optional operation authority through the
104
+ manager, every connector-tool adapter, real query runs, tenant/environment
105
+ facades, health checks, and `MCPConnectorBridge.callTool`. Custom connectors
106
+ receive the signal; if they ignore it, the manager settles with an honest
107
+ unknown remote outcome and rejects a late success that does not identify a
108
+ received response. A tenant call cancelled before admission no longer spends a
109
+ rate-limit slot.
110
+
111
+ `HttpConnector` and `WebhookConnector` now apply one validated 30-second
112
+ fetch-and-body deadline and a streaming 2 MiB response limit by default. Set
113
+ positive `timeoutMs` and `maxResponseBytes` values to choose different bounds.
114
+ Cancellation, deadline, or response-size failure aborts only the private
115
+ transport/body reader and preserves the caller's exact cause. Result metadata
116
+ distinguishes `not_started`, `unknown`, and `response_received`, includes retry
117
+ safety, and keeps a received status visible when its body is unavailable.
118
+
119
+ Dynamic HTTP paths and webhook URL overrides must remain on the configured
120
+ origin. Model-authored routing headers are refused, redirects are not followed,
121
+ and 3xx responses are no longer reported as success. Configure a separate
122
+ connector instance for each authorized origin; callers that previously used a
123
+ cross-origin webhook override must migrate to that instance.
124
+
125
+ `GuardedFetchProvider` now applies one validated 30-second deadline across DNS
126
+ resolution, every manually admitted redirect fetch, and the final response
127
+ body, while preserving a caller's exact cancellation cause on a private
128
+ transport signal. Its 2 MiB default response cap is enforced from streamed
129
+ bytes rather than after `response.text()` allocates the whole body; overflow
130
+ cancels the reader and returns a valid UTF-8 prefix. Redirect bodies are
131
+ cancelled when abandoned, and a spent redirect budget causes no DNS lookup for
132
+ the next target. Set positive `timeoutMs` and `maxBytes` values or a
133
+ non-negative integer `maxRedirects` to choose other bounds. Custom
134
+ `GuardedFetchConfig.resolve` functions may now accept the operation signal as
135
+ a second argument. IPv4-mapped IPv6 literals are canonicalized back to their
136
+ IPv4 address before range checks, closing the hexadecimal mapped loopback and
137
+ link-local bypass; the full IPv6 link-local and multicast ranges are also
138
+ refused.
139
+
140
+ MCP request methods now accept optional cancellation authority, and generated
141
+ MCP tool and prompt adapters forward the run-owned tool signal. A pre-aborted
142
+ request starts no transport work; a pending request preserves the caller's
143
+ exact cause, aborts a private transport, removes its correlated pending id, and
144
+ makes a one-second best-effort `notifications/cancelled` attempt. The
145
+ notification does not prove that an already-started remote side effect stopped.
146
+ Paged list calls recheck the same signal before each page.
147
+
148
+ `MCPClient.requestTimeoutMs` and HTTP MCP transport `timeoutMs` values must now
149
+ be positive platform-range integers. A shorter transport deadline remains a
150
+ request-timeout terminal and emits the same correlated cancellation. HTTP
151
+ fetches and response-body reads share operation authority; disconnect owns
152
+ active requests and cancellation cleanup. Reconnects fence late POST responses
153
+ and SSE batches from prior generations, clear Streamable session state, and
154
+ accept session ids only from successful `initialize` responses. Per-send
155
+ failure no longer marks a Streamable client connection-wide errored or rejects
156
+ unrelated concurrent calls. `MCPTransport.send` now accepts optional
157
+ `MCPTransportSendOptions`; custom transports should refuse pre-aborted work and
158
+ stop their per-send I/O when its signal fires.
159
+
160
+ Provider model listings and credential probes now accept optional cancellation
161
+ signals. Retry, fallback, stream-idle and instrumentation decorators preserve
162
+ that authority, and every bundled CLI driver forwards it to the underlying
163
+ transport where supported or refuses a result that arrived after cancellation.
164
+ Existing zero-argument provider implementations remain valid.
165
+
166
+ The interactive provider picker now cancels model discovery, credential checks
167
+ and subscription sign-in when the operator backs out, supersedes the work, or
168
+ leaves the screen. Late results cannot reopen an old model step, accept a
169
+ credential, re-probe the application, or persist a subscription credential
170
+ after cancellation. Model listing and credential probing both settle after a
171
+ three-second bound even when a custom provider ignores its signal.
172
+
173
+ Between-turn and durable-resume subscription refreshes now settle on caller
174
+ cancellation and apply one 30-second bound across the token request and response
175
+ body. Refreshes in one session are serialized and re-read their source at the
176
+ head of the queue, preventing a later stale caller from downgrading a token
177
+ published by an earlier one. Namzu's credential file uses an exact conditional
178
+ replacement under a cross-process, atomically published lock; an external
179
+ rotation or logout wins, and an uncertain publication refuses instead of using
180
+ an uncommitted refresh. Borrowed macOS Keychain credentials are read-only: a
181
+ changed or removed entry wins, and a successful refresh of an unchanged entry
182
+ remains session-local.
183
+
3
184
  ## 3.4.0
4
185
 
5
186
  ### Minor Changes
package/README.md CHANGED
@@ -3,10 +3,10 @@ type: Reference
3
3
  title: "@namzu/anthropic"
4
4
  description: >-
5
5
  The Anthropic model driver for the Namzu agent kernel. Implements
6
- LLMProvider over the vendor's official SDK, so the kernel drives it
7
- through the same interface as every other driver.
6
+ LLMProvider over the vendor's official SDK with route-bound signed-thinking
7
+ replay, so the kernel can resume native tool continuations safely.
8
8
  tags: [readme, package, provider, anthropic]
9
- timestamp: 2026-08-17T00:00:00Z
9
+ timestamp: 2026-08-20T00:00:00Z
10
10
  status: active
11
11
  diataxis: reference
12
12
  -->
@@ -67,6 +67,12 @@ const response = await collectChatCompletion(
67
67
  `chatStream` is the only model entry point; a non-streaming call is that stream
68
68
  collected. In practice the kernel's run loop calls it and hands you events.
69
69
 
70
+ Signed thinking and encrypted redacted blocks are persisted with versioned
71
+ adapter state plus their exact provider/model/fallback route. The same
72
+ configured route replays them after restart or `/resume`; another model,
73
+ provider, or chain member receives portable assistant/tool history without
74
+ foreign native thinking metadata.
75
+
70
76
  Set exactly one of `apiKey` or `authToken`. The kernel's credential vault can
71
77
  hold the key instead, so it never reaches the driver's config as a plain
72
78
  string.
package/dist/client.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare class AnthropicProvider implements LLMProvider {
23
23
  */
24
24
  private createRaw;
25
25
  chatStream(params: ChatCompletionParams): AsyncIterable<StreamChunk>;
26
- listModels(): Promise<ModelInfo[]>;
26
+ listModels(signal?: AbortSignal): Promise<ModelInfo[]>;
27
27
  /**
28
28
  * Ask the API whether this credential works, and let the answer through.
29
29
  *
@@ -35,7 +35,7 @@ export declare class AnthropicProvider implements LLMProvider {
35
35
  * An SDK too old to expose `models.list` throws rather than passing, so the
36
36
  * caller reports unverifiable — nothing was asked, so nothing is known.
37
37
  */
38
- probeCredential(): Promise<void>;
38
+ probeCredential(signal?: AbortSignal): Promise<void>;
39
39
  private knownModels;
40
40
  healthCheck(): Promise<boolean>;
41
41
  /**
@@ -52,6 +52,7 @@ export declare class AnthropicProvider implements LLMProvider {
52
52
  * the capability tests catch it.
53
53
  */
54
54
  effortLevelsFor(model: string, thinking?: ThinkingConfig): readonly ReasoningEffort[];
55
+ reasoningEffortLevelsFor(model: string, thinking?: ThinkingConfig): readonly ReasoningEffort[];
55
56
  }
56
57
  /**
57
58
  * The menu this driver offers when the network cannot supply one.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,oBAAoB,EAGpB,WAAW,EACX,SAAS,EACT,oBAAoB,EAEpB,eAAe,EACf,WAAW,EACX,cAAc,EAId,MAAM,YAAY,CAAA;AAkBnB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAwmBjD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBAMpC,CAAA;AAED,qBAAa,iBAAkB,YAAW,WAAW;IACpD,QAAQ,CAAC,EAAE,eAAc;IACzB,QAAQ,CAAC,IAAI,eAAc;IAC3B,QAAQ,CAAC,YAAY,uBAAyB;IAE9C,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,eAAe;IAqCnC,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,iBAAiB;IA+EzB;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAcV,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,aAAa,CAAC,WAAW,CAAC;IAiPrE,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAkCxC;;;;;;;;;;OAUG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IActC,OAAO,CAAC,WAAW;IAMb,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAOrC;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,KAAK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