@namzu/anthropic 1.2.0 → 2.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +336 -0
  2. package/dist/__tests__/anthropic.test.js +1 -0
  3. package/dist/__tests__/anthropic.test.js.map +1 -1
  4. package/dist/__tests__/block-shape-guard.test.d.ts +2 -0
  5. package/dist/__tests__/block-shape-guard.test.d.ts.map +1 -0
  6. package/dist/__tests__/block-shape-guard.test.js +218 -0
  7. package/dist/__tests__/block-shape-guard.test.js.map +1 -0
  8. package/dist/__tests__/cache-anchors.test.d.ts +2 -0
  9. package/dist/__tests__/cache-anchors.test.d.ts.map +1 -0
  10. package/dist/__tests__/cache-anchors.test.js +220 -0
  11. package/dist/__tests__/cache-anchors.test.js.map +1 -0
  12. package/dist/__tests__/citations.test.d.ts +2 -0
  13. package/dist/__tests__/citations.test.d.ts.map +1 -0
  14. package/dist/__tests__/citations.test.js +189 -0
  15. package/dist/__tests__/citations.test.js.map +1 -0
  16. package/dist/__tests__/content-blocks.test.d.ts +2 -0
  17. package/dist/__tests__/content-blocks.test.d.ts.map +1 -0
  18. package/dist/__tests__/content-blocks.test.js +131 -0
  19. package/dist/__tests__/content-blocks.test.js.map +1 -0
  20. package/dist/__tests__/document-input.test.d.ts +2 -0
  21. package/dist/__tests__/document-input.test.d.ts.map +1 -0
  22. package/dist/__tests__/document-input.test.js +98 -0
  23. package/dist/__tests__/document-input.test.js.map +1 -0
  24. package/dist/__tests__/reasoning-close.test.d.ts +2 -0
  25. package/dist/__tests__/reasoning-close.test.d.ts.map +1 -0
  26. package/dist/__tests__/reasoning-close.test.js +219 -0
  27. package/dist/__tests__/reasoning-close.test.js.map +1 -0
  28. package/dist/__tests__/thinking-capability.test.d.ts +2 -0
  29. package/dist/__tests__/thinking-capability.test.d.ts.map +1 -0
  30. package/dist/__tests__/thinking-capability.test.js +127 -0
  31. package/dist/__tests__/thinking-capability.test.js.map +1 -0
  32. package/dist/__tests__/thinking-request-body.test.d.ts +2 -0
  33. package/dist/__tests__/thinking-request-body.test.d.ts.map +1 -0
  34. package/dist/__tests__/thinking-request-body.test.js +90 -0
  35. package/dist/__tests__/thinking-request-body.test.js.map +1 -0
  36. package/dist/client.d.ts.map +1 -1
  37. package/dist/client.js +186 -3
  38. package/dist/client.js.map +1 -1
  39. package/dist/thinking-capability.d.ts +78 -0
  40. package/dist/thinking-capability.d.ts.map +1 -0
  41. package/dist/thinking-capability.js +114 -0
  42. package/dist/thinking-capability.js.map +1 -0
  43. package/package.json +4 -4
  44. package/src/__tests__/anthropic.test.ts +1 -0
  45. package/src/__tests__/block-shape-guard.test.ts +256 -0
  46. package/src/__tests__/cache-anchors.test.ts +262 -0
  47. package/src/__tests__/citations.test.ts +218 -0
  48. package/src/__tests__/content-blocks.test.ts +153 -0
  49. package/src/__tests__/document-input.test.ts +131 -0
  50. package/src/__tests__/reasoning-close.test.ts +262 -0
  51. package/src/__tests__/thinking-capability.test.ts +150 -0
  52. package/src/__tests__/thinking-request-body.test.ts +111 -0
  53. package/src/client.ts +265 -7
  54. package/src/thinking-capability.ts +177 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,341 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 1cd1094: Thinking is now resolved per model, `effort` is sendable, and thinking tokens
8
+ are reported.
9
+
10
+ **Thinking on a current model was a failed request, not a degraded one.** The
11
+ driver mapped `type: 'enabled'` straight to the wire and everything else to
12
+ `disabled`. The vendor rejects a mismatched mode with a 400 rather than
13
+ falling back: `thinking.type.enabled` is refused from Claude 4.7 onward,
14
+ `adaptive` is refused on 4.5 and earlier, and the always-on models refuse
15
+ `disabled`. One body for every model does not compromise quality, it fails.
16
+
17
+ `ThinkingConfig.type` gains `'adaptive'`, and the Anthropic driver resolves the
18
+ declared intent against the model it is about to call — sending the mode that
19
+ model accepts, dropping a budget where budgets have no meaning, and omitting
20
+ the field entirely rather than asking an always-on model to stop thinking. An
21
+ unrecognised model is treated as manual-only, which is the previous behaviour
22
+ and keeps a gateway serving an older model working.
23
+
24
+ **`ThinkingConfig.display` is narrowed to `'summarized' | 'omitted'`**, and now
25
+ actually reaches the wire. It was `'full' | 'summarized'`: `'full'` is not a
26
+ value any vendor accepts — a declared option that could only ever have been
27
+ rejected — and `'omitted'` was missing. It also was not serialized at all,
28
+ which matters more than it sounds: `display` defaults to `'omitted'` on newer
29
+ models, so a caller wanting to show reasoning received thinking blocks with
30
+ empty text and nothing to explain why.
31
+
32
+ **`effort` is new on `ChatCompletionParams`** — `'low' | 'medium' | 'high' |
33
+ 'xhigh' | 'max'`. It goes out as `output_config.effort`, a _sibling_ of
34
+ `thinking` rather than a field inside it, because it shapes the whole response
35
+ and one manual-mode model accepts it alongside a token budget; nesting it would
36
+ have made that combination unsayable. It is dropped on models that do not
37
+ accept it, and refused in the one combination the vendor rejects — thinking
38
+ disabled at `xhigh`/`max`.
39
+
40
+ **`TokenUsage.reasoningTokens`** carries `output_tokens_details.thinking_tokens`
41
+ when the vendor reports it. It is a _subset_ of `completionTokens`, not an
42
+ addition — reasoning is billed as output, so summing it into a total would
43
+ double-count. Absent means not reported, never zero: coercing would claim every
44
+ turn on every silent driver did no thinking, and streamed events carry the
45
+ breakdown only on the final delta.
46
+
47
+ **Migration.** `display: 'full'` no longer compiles — use `'summarized'`, which
48
+ is what it meant. Code passing `thinking: { type: 'enabled', budgetTokens }`
49
+ keeps working and is now translated per model instead of rejected by newer
50
+ ones. `assertThinkingSupported` in `@namzu/openai` refuses `'adaptive'` as it
51
+ already refused `'enabled'`, since that driver implements neither.
52
+
53
+ Not changed: a report accompanying this work claimed `temperature`, `top_p` and
54
+ `top_k` are rejected on 5-series models and should be dropped by the driver.
55
+ The Messages reference, the extended-thinking page and the thinking
56
+ troubleshooting page document no such restriction, so nothing was implemented —
57
+ silently dropping sampling parameters that would have worked is its own defect.
58
+
59
+ ## 1.3.0
60
+
61
+ ### Minor Changes
62
+
63
+ - 935b8f3: An answer can cite the document it came from
64
+
65
+ Sending a document buys the provider's native handling of it — page structure, built-in OCR, and the ability to say which passage an answer rests on. namzu could send the document and could not receive the third: an answer about a contract arrived as prose, and checking it meant reading the contract again by hand. A citation is the difference between an answer you trust and one you verify.
66
+
67
+ `citations: true` on a document attachment asks for them; they come back on the assistant message as `Citation[]`. Opt-in per document, because the provider splits the document into citable units and the answer carries the passages it leaned on — tokens a turn that never wanted a citation should not pay.
68
+
69
+ The location is a union — `page`, `char` or `block` — rather than a page number, because providers segment differently and the segmentation is theirs. Flattening all three would invent a page number for the two that have none. Web-search and search-result citations are deliberately dropped: they point at something that was never in the request, so there is no attachment to resolve them against, and a citation the reader cannot go and look at is worse than none.
70
+
71
+ Citations ride with the turn that made them, like reasoning blocks, so compaction takes a turn's evidence with it rather than leaving citations pointing at prose that is gone.
72
+
73
+ - 935b8f3: Documents and citations were designed in the SDK and never built in the drivers.
74
+
75
+ `DocumentAttachment` and `Citation` existed in `@namzu/sdk` with a page of documentation about why native document handling is worth having — page structure, the provider's own extraction, and the ability to say which passage an answer rests on. The stream chunk carried a citation slot, the run's stream aggregator collected them onto the assistant message, and the iteration attached them to the turn. Both these drivers declared `supportsDocuments: true`.
76
+
77
+ Neither had a document branch. Every attachment was mapped as an image — a PDF went up as an image block with `media_type: application/pdf` on one wire and as `data:application/pdf;base64,…` inside an `image_url` part on the other, shapes the APIs reject. And only the mock provider ever emitted a citation, so in a real run the slot was always empty: an answer about a contract arrived as prose, and checking it meant reading the contract again.
78
+
79
+ - **`@namzu/anthropic`** now sends a native document block carrying the media type, the optional title, and — only when the attachment asked for them, because they cost tokens — citations. It parses citation deltas back onto the stream, keeping the location as the discriminated union the SDK defines: a provider that segments by character offset has no page number, and a citation whose location cannot be named is dropped rather than given an invented one. A citation that looks checkable and is not is worse than none.
80
+ - **`@namzu/openai`** now sends a document as a `file` content part with its filename. That wire has no way to return citations, so a document that asks for them is refused with a message naming the document and what to do instead — answering without them would drop the checkability the caller asked for, and an empty citation list reads as "the model cited nothing" rather than "nobody asked".
81
+
82
+ The drivers that declare `supportsDocuments: false` were already honest: none of them map attachments at all, and the runtime warns (or fails under `strictCapabilities`) before the request is built.
83
+
84
+ - 935b8f3: Extended thinking, and images inside tool results.
85
+
86
+ Two more halves the SDK had specified and this driver had not built.
87
+
88
+ **Extended thinking.** The stream chunk carried a `reasoning` channel whose own comment named the failure — `thinking_delta` and `signature_delta` fell through the driver's `default: // ignore` — the run's aggregator bucketed fragments by index and closed them on `done`, and `ReasoningBlock` recorded the signature with a note that replaying it unchanged is mandatory. The driver requested no thinking, parsed none, and replayed none, so the feature was unreachable on a model where it is off by default and untunable on one where it is on.
89
+
90
+ It now sends the `thinking` request with the caller's budget, streams each block with its fragments and its signature, closes the block so the aggregator knows the signature has landed, and replays reasoning blocks verbatim and first on the next request. Verbatim is not a style choice: the signature is verified upstream, so a block re-rendered, reordered, or stripped of its signature invalidates the whole conversation rather than that block. A redacted block travels as its opaque payload.
91
+
92
+ **Images in tool results.** A tool result carrying content blocks was `JSON.stringify`d, so a screenshot reached the model as a wall of quoted base64 — the exact thing the SDK's degrade helper exists to prevent, and pure waste besides: the model paid for every character and could read none of them. This wire carries image blocks inside a tool result natively; the mapper simply never used the shape. Documents still degrade to the named placeholder, because tool results here take text and images, and the wrong block fails the request rather than just the block.
93
+
94
+ Six previously empty test files now cover this driver: document input, citations, extended thinking, tool-result content blocks, cache-breakpoint placement, and the request shapes the wire rejects outright — an empty content array, an orphan tool result, a `tool_choice` sent without tools.
95
+
96
+ - 935b8f3: Widen the message model to content blocks: multimodal tool results, `is_error`,
97
+ and reasoning replay.
98
+
99
+ `ToolMessage.content` was `string` and `AssistantMessage` had no slot for
100
+ reasoning, so three separate things died at the provider boundary. Doing them
101
+ as one migration is deliberate — all three need the same widening, and every
102
+ stored transcript, checkpoint and `messages.json` is written in the narrow
103
+ shape, so the cost only grows.
104
+
105
+ **Tool results can carry non-text content.** `ToolResultContent` is
106
+ `string | ToolResultBlock[]`, where a block is text, image or document. String
107
+ stays first-class: the common case is unchanged and every existing tool and
108
+ driver compiles untouched. `@namzu/computer-use`'s `screenshot` returned
109
+ ~400 KB–2.7 MB of base64 **as text** — roughly 100k–670k tokens of characters
110
+ no model can decode — so computer use was effectively non-functional; it now
111
+ returns an image block with a short textual description. MCP `image` and
112
+ inline `resource` blocks are passed through instead of being filtered out.
113
+
114
+ **Failures are marked on the wire.** The executor computed `isError`, routed it
115
+ to the SSE bridge, the A2A bridge and the TUI, then dropped it at the provider
116
+ boundary — so the model's trained tool-failure recovery never fired. The
117
+ Anthropic driver now sends `is_error: true`, and the value survives the
118
+ executor's result tuple, which previously narrowed to `{toolCallId, output}`
119
+ before the message was built.
120
+
121
+ **Reasoning is representable and replayed verbatim.** `AssistantMessage.reasoning`
122
+ holds opaque `ReasoningBlock`s (thinking / redacted, with signature or encrypted
123
+ payload). The Anthropic driver used to rebuild every assistant turn as
124
+ `[text?, ...tool_use]` — precisely the pattern the verbatim-echo contract
125
+ prohibits when a `tool_result` follows — and now emits stored reasoning blocks
126
+ first, signature intact.
127
+
128
+ Drivers that cannot express non-text tool results (`@namzu/openai`,
129
+ `@namzu/ollama`) degrade through `toolResultToText`, which renders an explicit
130
+ `[image: …]` placeholder rather than dumping base64 or silently dropping it.
131
+
132
+ This is the outbound half. The Anthropic driver does not yet parse thinking
133
+ blocks out of the stream and `ChatCompletionParams` has no `thinking` field,
134
+ so `reasoning` is populated only when a caller supplies it.
135
+
136
+ - 935b8f3: Parse reasoning out of the stream, and let a run request extended thinking.
137
+
138
+ This completes the reasoning work: the previous release added storage and
139
+ verbatim replay, but nothing populated it. `StreamChunk.delta` carried only
140
+ `content` and `toolCalls`, so the Anthropic driver's `thinking_delta` and
141
+ `signature_delta` events fell through its `default: // ignore` — the blocks
142
+ could not be captured even in principle. Two consequences: the verbatim-echo
143
+ contract was unsatisfiable in practice, and a streaming UI showed a
144
+ multi-second stall with zero events while the model was demonstrably working.
145
+
146
+ - `StreamChunk.delta.reasoning` carries fragments bucketed by block index,
147
+ exactly like `toolCalls[].index`, closed by `done`.
148
+ - `streamProviderTurn` accumulates them and attaches the finished blocks to
149
+ the response in **stream-index order**, not arrival order — a provider may
150
+ interleave blocks, and the echo contract is about the original ordering.
151
+ - New `reasoning_started` / `reasoning_delta` / `reasoning_completed` run
152
+ events, wire-mapped as `reasoning.*`. The delta is ephemeral, so the
153
+ transcript records the completed block rather than every fragment.
154
+ - The Anthropic driver handles `content_block_start` for
155
+ `thinking`/`redacted_thinking`, forwards `thinking_delta` and
156
+ `signature_delta`, and closes the block on `content_block_stop`.
157
+ - `AgentRunConfig.thinking` (`ThinkingConfig`) is forwarded on every model
158
+ call. The Anthropic driver maps it to `thinking` and **omits
159
+ temperature/top_p/top_k while it is enabled**, because the API rejects them
160
+ together — sending a request known to 400 is worse than dropping a sampling
161
+ knob the caller did not prioritise.
162
+
163
+ Reasoning rides on the assistant message it belongs to, so the replay contract
164
+ holds automatically: trimming or compacting that message takes its thinking
165
+ blocks with it, and no separate atomicity rule is needed in `findSafeTrimIndex`.
166
+
167
+ - 935b8f3: A user message can carry a document
168
+
169
+ Documents existed in the type system only in the tool-result direction, and both first-party drivers mapped images only on the input side. So "here is the contract, answer questions about it" — a mainstream workload — was reachable only by having a tool read the file and stringify it. That loses the provider's native document handling (page structure, built-in OCR, citations) and pays the text cost instead.
170
+
171
+ `UserMessage.attachments` is now `MessageAttachment[]`: an image or a document. The discriminant is optional and stays optional — an attachment without one is an image, which is what every attachment was before, so no existing caller changes.
172
+
173
+ `supportsDocuments` sits beside `supportsVision` in the driver capability declaration, and the runtime checks it the same way: a document sent to a driver that declares `false` warns before the request, or throws under `strictCapabilities`, instead of letting the model answer about a file it never saw. The two are counted separately because they are separate wire shapes and a driver can map one without the other.
174
+
175
+ The two first-party drivers map documents natively. The remaining five map images only and now say so; a document reaching them degrades to a named placeholder that says which kind was dropped, rather than one that calls a document an image.
176
+
177
+ ### Patch Changes
178
+
179
+ - 935b8f3: The conversation cache anchor advances, so the next request can read it.
180
+
181
+ A single breakpoint at the conversation tail writes a new cache entry every
182
+ turn and reads none of them: by the next request the tail has moved, so the
183
+ marker sits somewhere the previous entry does not cover. The tools and
184
+ system tiers keep hitting through their own breakpoints — which is exactly
185
+ what made this invisible. Only the messages tier silently re-billed as a
186
+ write.
187
+
188
+ Both drivers now place a second anchor one turn back, which is where the
189
+ previous request put its tail marker and therefore the prefix that is
190
+ already cached.
191
+
192
+ It matters most where the history grows fastest. Pending tool results
193
+ collapse into a single message, so a fan-out of ten parallel calls appends
194
+ twenty content blocks in one turn — far enough to push the prior boundary
195
+ out of reach of a backward scan that stops at the first non-empty message.
196
+
197
+ This spends the fourth of the four allowed breakpoints, previously
198
+ documented as deliberately unspent. It is spent on the one tier that was
199
+ never hitting. A conversation with a single message still gets one anchor,
200
+ because there is nowhere behind it to put a second.
201
+
202
+ - 935b8f3: Lift the dependency floor to versions without published advisories
203
+
204
+ Eighty-two open advisories collapsed to a handful of real decisions, because most of them were the same package reached through one path.
205
+
206
+ The telemetry exporters carried a serialization library with twenty-four advisories against it, two of them critical. The exporters move from the 0.57 line to 0.221, and the stable packages beside them from 1.x to 2.x — a major bump for this package, since a consumer pinning the older peers must move with it.
207
+
208
+ The two vendor driver SDKs move to their current releases, closing the advisories that came with them.
209
+
210
+ The test runner accounted for fourteen critical advisories on its own. It is a development dependency and never reaches a published artifact, but it runs in CI against the repository's own contents, so it moves to the first patched release rather than being waved through as out-of-scope.
211
+
212
+ - 935b8f3: Three driver defects found by auditing every provider against the same
213
+ contract checklist rather than one at a time.
214
+
215
+ **anthropic — a thinking block never reported its close.** `openReasoning`
216
+ was declared, read by the `content_block_stop` branch, and never added to:
217
+ three references in the whole file. The set was permanently empty, so the
218
+ close branch could not match and `reasoning: { done: true }` never reached
219
+ the consumer. A host that opens a thinking card on the first reasoning
220
+ delta left it spinning for the rest of the run. Stored blocks were
221
+ unaffected, so replay always looked correct — only the live stream was
222
+ broken, which is why it survived. This is the default driver.
223
+
224
+ **openai — every request to a reasoning-family model failed on turn one.**
225
+ `temperature` and `max_tokens` were sent unconditionally, and those models
226
+ reject both, requiring `max_completion_tokens`. The rejection is a 400,
227
+ which classifies as `invalid_request` and is not retryable, so the run
228
+ died immediately whenever a token cap was set — which the runtime always
229
+ does. Model family is now detected by id prefix, conservatively: an
230
+ unknown model keeps the standard parameters, because a false positive
231
+ silently strips `temperature` from a model that honours it while a false
232
+ negative produces a clear error naming the parameter.
233
+
234
+ **http — every streamed turn reported zero tokens.** The body builder never
235
+ requested usage on a streamed response, so a conforming endpoint sent none
236
+ and the (complete) parsing had nothing to parse. Cost read as free, and any
237
+ budget or compaction threshold keyed on usage never fired however large the
238
+ thread grew.
239
+
240
+ - 935b8f3: Five places where namzu gave up, or claimed to recover, too early.
241
+
242
+ **A transient failure now pauses instead of failing.** A 503 that survived
243
+ every in-turn recovery — retry with jitter, the one-shot compaction relief,
244
+ mid-stream salvage — settled the run as `failed`, identically to a bad API
245
+ key. The host could not tell them apart, and recovering meant knowing about
246
+ checkpoints and driving replay itself. The state was never the problem:
247
+ checkpoints are written every iteration by default and the failed run is
248
+ persisted with full messages. Only the settle and the signal were missing.
249
+
250
+ A retryable failure with a checkpoint to resume from now emits `run_paused`
251
+ naming that checkpoint, leaves the span OK rather than ERROR, and sets
252
+ `stopReason: 'paused'`. Both conditions are required — pausing on a
253
+ permanent error would invite a resume that cannot work, and pausing with
254
+ nowhere to resume from produces a run nobody can ever pick up.
255
+
256
+ **A forced compaction pass can no longer decline to do anything.** A forced
257
+ pass runs because the provider _rejected_ the prompt as too long, and two
258
+ things let it treat that as advisory. It re-applied the chars/4 estimate
259
+ after clearing stale tool results — the estimate the provider had just
260
+ refuted — and returned early if that said the context was fine. And relief
261
+ reported success on ANY positive shed, so clearing one short result counted
262
+ and the retry burned a whole model call to be told the same thing. The
263
+ early return is now force-gated, and a shed has to clear a floor (a
264
+ fraction of the prompt, at least a couple of thousand characters) to count.
265
+
266
+ Separately, the relief latch is per **stuck point**, not per run. It exists
267
+ to stop a second overflow immediately after a successful compaction from
268
+ looping; as a run-scoped flag it meant one relief at iteration 3 disarmed
269
+ the mechanism for the rest of the run, leaving iteration 40 to die with
270
+ obvious moves left. It is now cleared by a turn that actually succeeded.
271
+
272
+ **An eval case can no longer hang the suite.** `executeCase` was a bare
273
+ await, so a `run` closure that never settled blocked its worker and
274
+ `runExperiment` never returned — no report, no partial results, nothing to
275
+ read. `ExperimentConfig.timeoutMs` bounds a case and hands `run` an
276
+ `AbortSignal` as a third argument; a timed-out case is reported and the
277
+ suite continues, exactly like a case that threw, with its real elapsed time
278
+ rather than zero. Unset means no deadline, which is today's behaviour. The
279
+ documented path already inherits deadlines from the runtime it drives; this
280
+ covers what those cannot see — a closure that does not go through
281
+ `query()`, and a mid-iteration provider stall.
282
+
283
+ **A malformed content block is named, not smuggled.** One driver built an
284
+ image block by calling `String()` on whatever `data` and `mediaType`
285
+ happened to be, behind only a truthiness check — so a non-string `data`
286
+ became the literal `"[object Object]"` as the base64 payload, and the wire
287
+ rejected the whole request with nothing naming the block at fault. That is
288
+ reachable: a remote tool result is cast without validation on the way in.
289
+ It now type- and media-type-guards and degrades to a named placeholder,
290
+ matching the sibling driver that already did, and without inlining the
291
+ payload it refused to send.
292
+
293
+ **Failures have somewhere to grow remediation.** A stale API key surfaced
294
+ as whatever prose the vendor SDK happened to write: no id to grep in logs,
295
+ no instruction on what to change, and no growth point — a newly-observed
296
+ failure shape could only be given curated copy by editing the classifier.
297
+ `explainError` adds an ordered, id-keyed rule layer matching on
298
+ **structural** signals (code, status, an explicit hint) rather than
299
+ volatile vendor prose. `run_failed` carries the result as `explanation`;
300
+ `withHint(err, '…')` lets a throw site attach what only it knows, and
301
+ outranks every generic rule. It returns `null` when no rule claims the
302
+ failure — inventing advice for something uncharacterised is worse than
303
+ saying nothing, because it sends the reader somewhere specific and wrong.
304
+ The container backend's readiness, port-mapping and worker-fetch failures
305
+ now carry hints.
306
+
307
+ - 935b8f3: namzu's own vocabulary, everywhere.
308
+
309
+ Comments across the kernel explained namzu's design by naming another
310
+ product: "mirrors X's container architecture", "reference: X's
311
+ `normalizePathForSandbox()`", "which is what Y and Z both do", "Claude Code
312
+ uses 2000 for the same reason". Behaviour was correct throughout — this is
313
+ about what the code says it is. A kernel that explains itself by citation
314
+ reads as a reimplementation of something else, and namzu is not one.
315
+
316
+ Every such comment now states the reason directly. Where a rule exists
317
+ because a provider requires it, the comment says what the requirement is
318
+ rather than whose it is — which is also more useful, since the same
319
+ requirement usually holds for more than one provider, and a reader who has
320
+ never used the named one can still follow it.
321
+
322
+ **Breaking (types only, no runtime behaviour):**
323
+
324
+ - `ToolCatalogSurface`: the `'cowork'` member is now `'supervised'`.
325
+ - `ToolSource.skill.type`: `'anthropic' | 'custom'` is now
326
+ `'published' | 'custom'`.
327
+
328
+ Both are descriptive metadata with no construction site anywhere in the
329
+ workspace, so nothing internal moved. An external consumer that names
330
+ either value gets a compile error pointing at the line.
331
+
332
+ **Deliberately unchanged**, because these are addresses rather than
333
+ borrowed naming: model-id prefixes in the context-window table (data the
334
+ runtime matches against), API-key detection patterns in the guardrail
335
+ presets (a pattern is worthless if you cannot tell what it detects),
336
+ namzu's own provider package names, and the credential-store integration in
337
+ the CLI, whose service name and file path are literally the other tool's.
338
+
3
339
  ## 1.2.0
4
340
 
5
341
  ### Minor Changes
@@ -40,6 +40,7 @@ describe('@namzu/anthropic', () => {
40
40
  supportsStreaming: true,
41
41
  supportsFunctionCalling: true,
42
42
  supportsVision: true,
43
+ supportsDocuments: true,
43
44
  });
44
45
  });
45
46
  it('is exposed on the provider instance for runtime negotiation', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.test.js","sourceRoot":"","sources":["../../src/__tests__/anthropic.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAErE,OAAO,EAAE,UAAU,EAAE,QAAQ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
1
+ export {};
2
+ //# sourceMappingURL=block-shape-guard.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-shape-guard.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/block-shape-guard.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,218 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { AnthropicProvider } from '../client.js';
3
+ /**
4
+ * The wire rejects a whole request over one malformed block, so the
5
+ * failures that matter here are structural: a block in the wrong place, a
6
+ * message whose content array is empty, an orphan tool result, or a
7
+ * `tool_choice` sent without tools. None of them is visible in isolation —
8
+ * each shows up as a 400 for the entire conversation.
9
+ *
10
+ * These pin the shapes the mapper must not produce, alongside the ones it
11
+ * must. What must NOT hold is the point: a guard asserting only the happy
12
+ * shape passes while the mapper emits a request no server accepts.
13
+ */
14
+ function bodyCapturer() {
15
+ const seen = {};
16
+ const provider = new AnthropicProvider({ apiKey: 'test-key' });
17
+ provider.client = {
18
+ messages: {
19
+ create: vi.fn(async (body) => {
20
+ seen.body = body;
21
+ return (async function* () {
22
+ yield { type: 'message_start', message: { id: 'msg_1' } };
23
+ })();
24
+ }),
25
+ },
26
+ };
27
+ return { provider, seen };
28
+ }
29
+ async function bodyFor(params) {
30
+ const { provider, seen } = bodyCapturer();
31
+ for await (const _chunk of provider.chatStream({
32
+ model: 'm',
33
+ messages: [{ role: 'user', content: 'hi' }],
34
+ ...params,
35
+ })) {
36
+ // drain
37
+ }
38
+ return seen.body ?? {};
39
+ }
40
+ function messagesOf(body) {
41
+ return (body.messages ?? []);
42
+ }
43
+ function allBlocks(body) {
44
+ return messagesOf(body).flatMap((m) => (Array.isArray(m.content) ? m.content : []));
45
+ }
46
+ const TOOLS = [
47
+ {
48
+ type: 'function',
49
+ function: { name: 'read', description: 'read', parameters: { type: 'object' } },
50
+ },
51
+ ];
52
+ describe('no message goes out with an empty content array', () => {
53
+ it('holds for a plain conversation', async () => {
54
+ const body = await bodyFor({
55
+ messages: [
56
+ { role: 'user', content: 'a' },
57
+ { role: 'assistant', content: 'b' },
58
+ ],
59
+ });
60
+ for (const message of messagesOf(body)) {
61
+ if (Array.isArray(message.content))
62
+ expect(message.content.length).toBeGreaterThan(0);
63
+ }
64
+ });
65
+ it('holds for an assistant turn that called a tool with no prose', async () => {
66
+ const body = await bodyFor({
67
+ messages: [
68
+ { role: 'user', content: 'read it' },
69
+ {
70
+ role: 'assistant',
71
+ content: null,
72
+ toolCalls: [
73
+ { id: 'call_1', type: 'function', function: { name: 'read', arguments: '{}' } },
74
+ ],
75
+ },
76
+ { role: 'tool', toolCallId: 'call_1', content: 'file body' },
77
+ ],
78
+ });
79
+ for (const message of messagesOf(body)) {
80
+ if (Array.isArray(message.content))
81
+ expect(message.content.length).toBeGreaterThan(0);
82
+ }
83
+ });
84
+ });
85
+ describe('a system message never appears among the turns', () => {
86
+ it('is lifted out entirely, not left as a user message', async () => {
87
+ const body = await bodyFor({
88
+ messages: [
89
+ { role: 'system', content: 'be terse' },
90
+ { role: 'user', content: 'hi' },
91
+ ],
92
+ });
93
+ expect(messagesOf(body).map((m) => m.role)).toEqual(['user']);
94
+ expect(body.system).toBeDefined();
95
+ });
96
+ });
97
+ describe('tool results are grouped into one user turn, in order', () => {
98
+ it('collapses two results answering one assistant turn', async () => {
99
+ const body = await bodyFor({
100
+ messages: [
101
+ { role: 'user', content: 'read both' },
102
+ {
103
+ role: 'assistant',
104
+ content: null,
105
+ toolCalls: [
106
+ { id: 'call_1', type: 'function', function: { name: 'read', arguments: '{}' } },
107
+ { id: 'call_2', type: 'function', function: { name: 'read', arguments: '{}' } },
108
+ ],
109
+ },
110
+ { role: 'tool', toolCallId: 'call_1', content: 'one' },
111
+ { role: 'tool', toolCallId: 'call_2', content: 'two' },
112
+ ],
113
+ });
114
+ const resultTurns = messagesOf(body).filter((m) => Array.isArray(m.content) && m.content.every((b) => b.type === 'tool_result'));
115
+ expect(resultTurns).toHaveLength(1);
116
+ expect((resultTurns[0]?.content).map((b) => b.tool_use_id)).toEqual(['call_1', 'call_2']);
117
+ });
118
+ it('every tool result answers a tool call that was actually made', async () => {
119
+ const body = await bodyFor({
120
+ messages: [
121
+ { role: 'user', content: 'read it' },
122
+ {
123
+ role: 'assistant',
124
+ content: null,
125
+ toolCalls: [
126
+ { id: 'call_1', type: 'function', function: { name: 'read', arguments: '{}' } },
127
+ ],
128
+ },
129
+ { role: 'tool', toolCallId: 'call_1', content: 'body' },
130
+ ],
131
+ });
132
+ const issued = new Set(allBlocks(body)
133
+ .filter((b) => b.type === 'tool_use')
134
+ .map((b) => b.id));
135
+ for (const result of allBlocks(body).filter((b) => b.type === 'tool_result')) {
136
+ // An orphan tool_result is rejected for the whole conversation.
137
+ expect(issued.has(result.tool_use_id)).toBe(true);
138
+ }
139
+ });
140
+ it('places the results after the turn that asked for them', async () => {
141
+ const body = await bodyFor({
142
+ messages: [
143
+ { role: 'user', content: 'read it' },
144
+ {
145
+ role: 'assistant',
146
+ content: null,
147
+ toolCalls: [
148
+ { id: 'call_1', type: 'function', function: { name: 'read', arguments: '{}' } },
149
+ ],
150
+ },
151
+ { role: 'tool', toolCallId: 'call_1', content: 'body' },
152
+ ],
153
+ });
154
+ const roles = messagesOf(body).map((m) => m.role);
155
+ expect(roles).toEqual(['user', 'assistant', 'user']);
156
+ });
157
+ });
158
+ describe('a malformed tool argument does not become a malformed block', () => {
159
+ it('sends an empty object rather than an unparsed string', async () => {
160
+ const body = await bodyFor({
161
+ messages: [
162
+ { role: 'user', content: 'go' },
163
+ {
164
+ role: 'assistant',
165
+ content: null,
166
+ toolCalls: [
167
+ { id: 'call_1', type: 'function', function: { name: 'read', arguments: '{not json' } },
168
+ ],
169
+ },
170
+ ],
171
+ });
172
+ expect(allBlocks(body).find((b) => b.type === 'tool_use')?.input).toEqual({});
173
+ });
174
+ it('reads empty arguments as an empty object', async () => {
175
+ const body = await bodyFor({
176
+ messages: [
177
+ { role: 'user', content: 'go' },
178
+ {
179
+ role: 'assistant',
180
+ content: null,
181
+ toolCalls: [
182
+ { id: 'call_1', type: 'function', function: { name: 'read', arguments: '' } },
183
+ ],
184
+ },
185
+ ],
186
+ });
187
+ expect(allBlocks(body).find((b) => b.type === 'tool_use')?.input).toEqual({});
188
+ });
189
+ });
190
+ describe('tool_choice is only legal beside tools', () => {
191
+ it('is sent when tools are', async () => {
192
+ const body = await bodyFor({ tools: TOOLS, toolChoice: 'required' });
193
+ expect(body.tools).toBeDefined();
194
+ expect(body.tool_choice).toBeDefined();
195
+ });
196
+ it('is withheld when there are no tools', async () => {
197
+ const body = await bodyFor({ toolChoice: 'required' });
198
+ // The API rejects the request outright; a driver that forwards it
199
+ // turns a caller's harmless default into a hard failure.
200
+ expect(body.tool_choice).toBeUndefined();
201
+ });
202
+ it('is withheld when a parallel-call hint is the only reason for it', async () => {
203
+ const body = await bodyFor({ parallelToolCalls: false });
204
+ expect(body.tool_choice).toBeUndefined();
205
+ });
206
+ });
207
+ describe('the required fields are always present', () => {
208
+ it('always sends max_tokens, which the API demands', async () => {
209
+ expect(await bodyFor({})).toHaveProperty('max_tokens');
210
+ });
211
+ it('honours the caller max over the default', async () => {
212
+ expect(await bodyFor({ maxTokens: 128 })).toMatchObject({ max_tokens: 128 });
213
+ });
214
+ it('marks the request as streaming', async () => {
215
+ expect(await bodyFor({})).toMatchObject({ stream: true });
216
+ });
217
+ });
218
+ //# sourceMappingURL=block-shape-guard.test.js.map