@namzu/anthropic 3.3.2 → 4.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,194 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 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.
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ - 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.
14
+
15
+ `@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.
16
+
17
+ `@namzu/cli` preserves and validates the additive assistant source shape in stateless and durable history.
18
+
19
+ **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.
20
+
21
+ ### Patch Changes
22
+
23
+ - 15f8ee4: Bound provider stream silence, including query-owned advisory calls and
24
+ RouterAgent routing decisions, compaction verifiers and model-graded eval
25
+ judges, to five minutes by default and abort the stalled provider transport,
26
+ with network-classified retry and fallback recovery where those policies
27
+ apply. This changes the previous default, under which a provider iterator could
28
+ remain silent forever. Set `streamIdleTimeoutMs: 0` on the run, agent, manual
29
+ compaction, verifier, or judge config to keep the old unbounded behavior, or set
30
+ a positive millisecond value to choose a different bound.
31
+
32
+ Queries whose caller signal is already aborted now settle as cancelled before
33
+ starting provider, provider-metadata, or tool work. A later cancellation also
34
+ settles while an optional context-window resolver remains pending, even when
35
+ that resolver ignores its signal. With no caller cancellation, `timeoutMs`
36
+ bounds the optional metadata lookup, aborts its private transport signal, and
37
+ falls back to the static context-window table instead of blocking the run.
38
+
39
+ The OpenRouter context-window lookup now forwards cancellation to its model-list
40
+ transport. Only fulfilled listings are cached, so cancelling one concurrent
41
+ query cannot abort another query's shared metadata request or force that query
42
+ onto the static context-window table.
43
+
44
+ `runExperiment({ timeoutMs })` now applies one validated wall-clock deadline to
45
+ both case execution and scoring. Scorers receive its optional cancellation
46
+ signal; a non-cooperative scorer is detached, and `judgeScorer` forwards the
47
+ signal to its bounded provider transport. Values outside the positive platform
48
+ timer range are refused before a case starts; omit the field for the prior
49
+ unbounded case behavior.
50
+
51
+ Compaction verification inside a query now carries the run cancellation cause
52
+ to its provider transport without placing a second idle timer around retry and
53
+ fallback. Public `buildVerifiedSummary`, `compactNow`, and `compactRegion`
54
+ calls bound raw provider silence themselves and accept optional `signal` and
55
+ `streamIdleTimeoutMs`; malformed values and pre-cancelled manual work are
56
+ refused before provider work or a no-op result.
57
+
58
+ HTTP embedding batches now have a 30-second whole-request default, including
59
+ response-body reads, where the previous default could wait forever. Set
60
+ `requestTimeoutMs: 0` on `HttpEmbeddingProvider` to keep the former unbounded
61
+ behavior. Invalid timeout values and non-positive or fractional `batchSize`
62
+ or `dimensions` values are refused at construction instead of silently
63
+ disabling the bound or entering a non-progressing batch loop. Successful HTTP
64
+ responses must contain exactly one unique, in-range result per input and finite
65
+ vectors of the configured dimension; malformed or incomplete batches are
66
+ refused atomically instead of reaching ingestion with missing embeddings.
67
+
68
+ Public RAG operations accept optional cancellation context. The shipped
69
+ `knowledge_search` tool forwards its run-owned signal through
70
+ `KnowledgeBase`, retrieval or ingestion, and the embedding provider. The HTTP
71
+ provider preserves the caller's exact cancellation reason while aborting only
72
+ its private fetch transport. Custom embedding providers receive the signal as
73
+ a cooperative request; callers still own their wait boundary if a custom
74
+ implementation ignores it. Default retrieval and ingestion recheck authority
75
+ after that custom call settles, so a late result cannot start a vector search
76
+ or persist chunks after cancellation. `VectorStore.search` and `upsert` now
77
+ receive the same optional operation context. The default pipelines also race
78
+ those store promises against cancellation, so a non-cooperative custom store
79
+ cannot leave the public query or ingestion call pending forever.
80
+
81
+ A2A agent-card discovery now has a 30-second whole fetch-and-body default and
82
+ accepts an optional caller signal and `timeoutMs`; set `timeoutMs: 0` to retain
83
+ the former unbounded behavior. `A2ADelegate.timeoutMs` now starts before
84
+ `message/send` and bounds the whole delegation instead of polling only. A
85
+ pre-cancelled dispatch starts no remote work, pending fetch and body promises
86
+ cannot hold `waitForTask`, and caller cancellation preserves its exact cause on
87
+ the private transport. Poll and delegation timers are validated at
88
+ construction. Once a safe task id exists, cancellation or timeout sends one
89
+ independently bounded `tasks/cancel`; during initial task creation the client
90
+ keeps a short cleanup grace and explicitly reports an unknown remote outcome if
91
+ the peer never returns an addressable id. Poll replies are bound to that initial
92
+ id, and transport or protocol failures after it is known make the same bounded
93
+ cleanup attempt before the original failure is returned. An `input-required`
94
+ task is also bounded-cancelled before the delegate reports that it cannot
95
+ supply the requested input.
96
+
97
+ Connector execution now carries optional operation authority through the
98
+ manager, every connector-tool adapter, real query runs, tenant/environment
99
+ facades, health checks, and `MCPConnectorBridge.callTool`. Custom connectors
100
+ receive the signal; if they ignore it, the manager settles with an honest
101
+ unknown remote outcome and rejects a late success that does not identify a
102
+ received response. A tenant call cancelled before admission no longer spends a
103
+ rate-limit slot.
104
+
105
+ `HttpConnector` and `WebhookConnector` now apply one validated 30-second
106
+ fetch-and-body deadline and a streaming 2 MiB response limit by default. Set
107
+ positive `timeoutMs` and `maxResponseBytes` values to choose different bounds.
108
+ Cancellation, deadline, or response-size failure aborts only the private
109
+ transport/body reader and preserves the caller's exact cause. Result metadata
110
+ distinguishes `not_started`, `unknown`, and `response_received`, includes retry
111
+ safety, and keeps a received status visible when its body is unavailable.
112
+
113
+ Dynamic HTTP paths and webhook URL overrides must remain on the configured
114
+ origin. Model-authored routing headers are refused, redirects are not followed,
115
+ and 3xx responses are no longer reported as success. Configure a separate
116
+ connector instance for each authorized origin; callers that previously used a
117
+ cross-origin webhook override must migrate to that instance.
118
+
119
+ `GuardedFetchProvider` now applies one validated 30-second deadline across DNS
120
+ resolution, every manually admitted redirect fetch, and the final response
121
+ body, while preserving a caller's exact cancellation cause on a private
122
+ transport signal. Its 2 MiB default response cap is enforced from streamed
123
+ bytes rather than after `response.text()` allocates the whole body; overflow
124
+ cancels the reader and returns a valid UTF-8 prefix. Redirect bodies are
125
+ cancelled when abandoned, and a spent redirect budget causes no DNS lookup for
126
+ the next target. Set positive `timeoutMs` and `maxBytes` values or a
127
+ non-negative integer `maxRedirects` to choose other bounds. Custom
128
+ `GuardedFetchConfig.resolve` functions may now accept the operation signal as
129
+ a second argument. IPv4-mapped IPv6 literals are canonicalized back to their
130
+ IPv4 address before range checks, closing the hexadecimal mapped loopback and
131
+ link-local bypass; the full IPv6 link-local and multicast ranges are also
132
+ refused.
133
+
134
+ MCP request methods now accept optional cancellation authority, and generated
135
+ MCP tool and prompt adapters forward the run-owned tool signal. A pre-aborted
136
+ request starts no transport work; a pending request preserves the caller's
137
+ exact cause, aborts a private transport, removes its correlated pending id, and
138
+ makes a one-second best-effort `notifications/cancelled` attempt. The
139
+ notification does not prove that an already-started remote side effect stopped.
140
+ Paged list calls recheck the same signal before each page.
141
+
142
+ `MCPClient.requestTimeoutMs` and HTTP MCP transport `timeoutMs` values must now
143
+ be positive platform-range integers. A shorter transport deadline remains a
144
+ request-timeout terminal and emits the same correlated cancellation. HTTP
145
+ fetches and response-body reads share operation authority; disconnect owns
146
+ active requests and cancellation cleanup. Reconnects fence late POST responses
147
+ and SSE batches from prior generations, clear Streamable session state, and
148
+ accept session ids only from successful `initialize` responses. Per-send
149
+ failure no longer marks a Streamable client connection-wide errored or rejects
150
+ unrelated concurrent calls. `MCPTransport.send` now accepts optional
151
+ `MCPTransportSendOptions`; custom transports should refuse pre-aborted work and
152
+ stop their per-send I/O when its signal fires.
153
+
154
+ Provider model listings and credential probes now accept optional cancellation
155
+ signals. Retry, fallback, stream-idle and instrumentation decorators preserve
156
+ that authority, and every bundled CLI driver forwards it to the underlying
157
+ transport where supported or refuses a result that arrived after cancellation.
158
+ Existing zero-argument provider implementations remain valid.
159
+
160
+ The interactive provider picker now cancels model discovery, credential checks
161
+ and subscription sign-in when the operator backs out, supersedes the work, or
162
+ leaves the screen. Late results cannot reopen an old model step, accept a
163
+ credential, re-probe the application, or persist a subscription credential
164
+ after cancellation. Model listing and credential probing both settle after a
165
+ three-second bound even when a custom provider ignores its signal.
166
+
167
+ Between-turn and durable-resume subscription refreshes now settle on caller
168
+ cancellation and apply one 30-second bound across the token request and response
169
+ body. Refreshes in one session are serialized and re-read their source at the
170
+ head of the queue, preventing a later stale caller from downgrading a token
171
+ published by an earlier one. Namzu's credential file uses an exact conditional
172
+ replacement under a cross-process, atomically published lock; an external
173
+ rotation or logout wins, and an uncertain publication refuses instead of using
174
+ an uncommitted refresh. Borrowed macOS Keychain credentials are read-only: a
175
+ changed or removed entry wins, and a successful refresh of an unchanged entry
176
+ remains session-local.
177
+
178
+ ## 3.4.0
179
+
180
+ ### Minor Changes
181
+
182
+ - 03e363c: Declare the Node floor these packages already had, and export a type `TelemetryConfig` already required.
183
+
184
+ **`engines.node: ">=20.0.0"`.** Only `@namzu/cli` declared one; the other fourteen published without any, so npm could not warn a consumer installing onto an unsupported runtime — they got a crash at some later import instead. The floor is not new: `@namzu/cli` has declared it since it shipped and `install.sh` has enforced it since it existed. This makes the other fourteen say the same thing.
185
+
186
+ If you install with `engine-strict=true` on Node 18, an install that previously emitted nothing will now fail. Upgrade to Node 20 or newer, which the code already assumed. Everyone else sees no change, or an `EBADENGINE` warning that replaces a later crash.
187
+
188
+ Worth stating plainly: CI verifies Node 22 and 24. The 20 floor is a declared minimum, not a tested one.
189
+
190
+ **`SpanProcessorLike` is now exported from `@namzu/telemetry`.** `TelemetryConfig.spanProcessors` takes `readonly SpanProcessorLike[]`, and the type had no export — a field on the public surface whose type was not on it, so a host supplying the value had to inline the shape or reach for `any`.
191
+
3
192
  ## 3.3.2
4
193
 
5
194
  ### Patch 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,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