@namzu/anthropic 1.2.0 → 1.3.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 (39) hide show
  1. package/CHANGELOG.md +280 -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/client.d.ts.map +1 -1
  29. package/dist/client.js +174 -3
  30. package/dist/client.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/__tests__/anthropic.test.ts +1 -0
  33. package/src/__tests__/block-shape-guard.test.ts +256 -0
  34. package/src/__tests__/cache-anchors.test.ts +262 -0
  35. package/src/__tests__/citations.test.ts +218 -0
  36. package/src/__tests__/content-blocks.test.ts +153 -0
  37. package/src/__tests__/document-input.test.ts +131 -0
  38. package/src/__tests__/reasoning-close.test.ts +262 -0
  39. package/src/client.ts +241 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,285 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 935b8f3: An answer can cite the document it came from
8
+
9
+ 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.
10
+
11
+ `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.
12
+
13
+ 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.
14
+
15
+ 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.
16
+
17
+ - 935b8f3: Documents and citations were designed in the SDK and never built in the drivers.
18
+
19
+ `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`.
20
+
21
+ 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.
22
+
23
+ - **`@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.
24
+ - **`@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".
25
+
26
+ 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.
27
+
28
+ - 935b8f3: Extended thinking, and images inside tool results.
29
+
30
+ Two more halves the SDK had specified and this driver had not built.
31
+
32
+ **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.
33
+
34
+ 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.
35
+
36
+ **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.
37
+
38
+ 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.
39
+
40
+ - 935b8f3: Widen the message model to content blocks: multimodal tool results, `is_error`,
41
+ and reasoning replay.
42
+
43
+ `ToolMessage.content` was `string` and `AssistantMessage` had no slot for
44
+ reasoning, so three separate things died at the provider boundary. Doing them
45
+ as one migration is deliberate — all three need the same widening, and every
46
+ stored transcript, checkpoint and `messages.json` is written in the narrow
47
+ shape, so the cost only grows.
48
+
49
+ **Tool results can carry non-text content.** `ToolResultContent` is
50
+ `string | ToolResultBlock[]`, where a block is text, image or document. String
51
+ stays first-class: the common case is unchanged and every existing tool and
52
+ driver compiles untouched. `@namzu/computer-use`'s `screenshot` returned
53
+ ~400 KB–2.7 MB of base64 **as text** — roughly 100k–670k tokens of characters
54
+ no model can decode — so computer use was effectively non-functional; it now
55
+ returns an image block with a short textual description. MCP `image` and
56
+ inline `resource` blocks are passed through instead of being filtered out.
57
+
58
+ **Failures are marked on the wire.** The executor computed `isError`, routed it
59
+ to the SSE bridge, the A2A bridge and the TUI, then dropped it at the provider
60
+ boundary — so the model's trained tool-failure recovery never fired. The
61
+ Anthropic driver now sends `is_error: true`, and the value survives the
62
+ executor's result tuple, which previously narrowed to `{toolCallId, output}`
63
+ before the message was built.
64
+
65
+ **Reasoning is representable and replayed verbatim.** `AssistantMessage.reasoning`
66
+ holds opaque `ReasoningBlock`s (thinking / redacted, with signature or encrypted
67
+ payload). The Anthropic driver used to rebuild every assistant turn as
68
+ `[text?, ...tool_use]` — precisely the pattern the verbatim-echo contract
69
+ prohibits when a `tool_result` follows — and now emits stored reasoning blocks
70
+ first, signature intact.
71
+
72
+ Drivers that cannot express non-text tool results (`@namzu/openai`,
73
+ `@namzu/ollama`) degrade through `toolResultToText`, which renders an explicit
74
+ `[image: …]` placeholder rather than dumping base64 or silently dropping it.
75
+
76
+ This is the outbound half. The Anthropic driver does not yet parse thinking
77
+ blocks out of the stream and `ChatCompletionParams` has no `thinking` field,
78
+ so `reasoning` is populated only when a caller supplies it.
79
+
80
+ - 935b8f3: Parse reasoning out of the stream, and let a run request extended thinking.
81
+
82
+ This completes the reasoning work: the previous release added storage and
83
+ verbatim replay, but nothing populated it. `StreamChunk.delta` carried only
84
+ `content` and `toolCalls`, so the Anthropic driver's `thinking_delta` and
85
+ `signature_delta` events fell through its `default: // ignore` — the blocks
86
+ could not be captured even in principle. Two consequences: the verbatim-echo
87
+ contract was unsatisfiable in practice, and a streaming UI showed a
88
+ multi-second stall with zero events while the model was demonstrably working.
89
+
90
+ - `StreamChunk.delta.reasoning` carries fragments bucketed by block index,
91
+ exactly like `toolCalls[].index`, closed by `done`.
92
+ - `streamProviderTurn` accumulates them and attaches the finished blocks to
93
+ the response in **stream-index order**, not arrival order — a provider may
94
+ interleave blocks, and the echo contract is about the original ordering.
95
+ - New `reasoning_started` / `reasoning_delta` / `reasoning_completed` run
96
+ events, wire-mapped as `reasoning.*`. The delta is ephemeral, so the
97
+ transcript records the completed block rather than every fragment.
98
+ - The Anthropic driver handles `content_block_start` for
99
+ `thinking`/`redacted_thinking`, forwards `thinking_delta` and
100
+ `signature_delta`, and closes the block on `content_block_stop`.
101
+ - `AgentRunConfig.thinking` (`ThinkingConfig`) is forwarded on every model
102
+ call. The Anthropic driver maps it to `thinking` and **omits
103
+ temperature/top_p/top_k while it is enabled**, because the API rejects them
104
+ together — sending a request known to 400 is worse than dropping a sampling
105
+ knob the caller did not prioritise.
106
+
107
+ Reasoning rides on the assistant message it belongs to, so the replay contract
108
+ holds automatically: trimming or compacting that message takes its thinking
109
+ blocks with it, and no separate atomicity rule is needed in `findSafeTrimIndex`.
110
+
111
+ - 935b8f3: A user message can carry a document
112
+
113
+ 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.
114
+
115
+ `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.
116
+
117
+ `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.
118
+
119
+ 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.
120
+
121
+ ### Patch Changes
122
+
123
+ - 935b8f3: The conversation cache anchor advances, so the next request can read it.
124
+
125
+ A single breakpoint at the conversation tail writes a new cache entry every
126
+ turn and reads none of them: by the next request the tail has moved, so the
127
+ marker sits somewhere the previous entry does not cover. The tools and
128
+ system tiers keep hitting through their own breakpoints — which is exactly
129
+ what made this invisible. Only the messages tier silently re-billed as a
130
+ write.
131
+
132
+ Both drivers now place a second anchor one turn back, which is where the
133
+ previous request put its tail marker and therefore the prefix that is
134
+ already cached.
135
+
136
+ It matters most where the history grows fastest. Pending tool results
137
+ collapse into a single message, so a fan-out of ten parallel calls appends
138
+ twenty content blocks in one turn — far enough to push the prior boundary
139
+ out of reach of a backward scan that stops at the first non-empty message.
140
+
141
+ This spends the fourth of the four allowed breakpoints, previously
142
+ documented as deliberately unspent. It is spent on the one tier that was
143
+ never hitting. A conversation with a single message still gets one anchor,
144
+ because there is nowhere behind it to put a second.
145
+
146
+ - 935b8f3: Lift the dependency floor to versions without published advisories
147
+
148
+ Eighty-two open advisories collapsed to a handful of real decisions, because most of them were the same package reached through one path.
149
+
150
+ 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.
151
+
152
+ The two vendor driver SDKs move to their current releases, closing the advisories that came with them.
153
+
154
+ 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.
155
+
156
+ - 935b8f3: Three driver defects found by auditing every provider against the same
157
+ contract checklist rather than one at a time.
158
+
159
+ **anthropic — a thinking block never reported its close.** `openReasoning`
160
+ was declared, read by the `content_block_stop` branch, and never added to:
161
+ three references in the whole file. The set was permanently empty, so the
162
+ close branch could not match and `reasoning: { done: true }` never reached
163
+ the consumer. A host that opens a thinking card on the first reasoning
164
+ delta left it spinning for the rest of the run. Stored blocks were
165
+ unaffected, so replay always looked correct — only the live stream was
166
+ broken, which is why it survived. This is the default driver.
167
+
168
+ **openai — every request to a reasoning-family model failed on turn one.**
169
+ `temperature` and `max_tokens` were sent unconditionally, and those models
170
+ reject both, requiring `max_completion_tokens`. The rejection is a 400,
171
+ which classifies as `invalid_request` and is not retryable, so the run
172
+ died immediately whenever a token cap was set — which the runtime always
173
+ does. Model family is now detected by id prefix, conservatively: an
174
+ unknown model keeps the standard parameters, because a false positive
175
+ silently strips `temperature` from a model that honours it while a false
176
+ negative produces a clear error naming the parameter.
177
+
178
+ **http — every streamed turn reported zero tokens.** The body builder never
179
+ requested usage on a streamed response, so a conforming endpoint sent none
180
+ and the (complete) parsing had nothing to parse. Cost read as free, and any
181
+ budget or compaction threshold keyed on usage never fired however large the
182
+ thread grew.
183
+
184
+ - 935b8f3: Five places where namzu gave up, or claimed to recover, too early.
185
+
186
+ **A transient failure now pauses instead of failing.** A 503 that survived
187
+ every in-turn recovery — retry with jitter, the one-shot compaction relief,
188
+ mid-stream salvage — settled the run as `failed`, identically to a bad API
189
+ key. The host could not tell them apart, and recovering meant knowing about
190
+ checkpoints and driving replay itself. The state was never the problem:
191
+ checkpoints are written every iteration by default and the failed run is
192
+ persisted with full messages. Only the settle and the signal were missing.
193
+
194
+ A retryable failure with a checkpoint to resume from now emits `run_paused`
195
+ naming that checkpoint, leaves the span OK rather than ERROR, and sets
196
+ `stopReason: 'paused'`. Both conditions are required — pausing on a
197
+ permanent error would invite a resume that cannot work, and pausing with
198
+ nowhere to resume from produces a run nobody can ever pick up.
199
+
200
+ **A forced compaction pass can no longer decline to do anything.** A forced
201
+ pass runs because the provider _rejected_ the prompt as too long, and two
202
+ things let it treat that as advisory. It re-applied the chars/4 estimate
203
+ after clearing stale tool results — the estimate the provider had just
204
+ refuted — and returned early if that said the context was fine. And relief
205
+ reported success on ANY positive shed, so clearing one short result counted
206
+ and the retry burned a whole model call to be told the same thing. The
207
+ early return is now force-gated, and a shed has to clear a floor (a
208
+ fraction of the prompt, at least a couple of thousand characters) to count.
209
+
210
+ Separately, the relief latch is per **stuck point**, not per run. It exists
211
+ to stop a second overflow immediately after a successful compaction from
212
+ looping; as a run-scoped flag it meant one relief at iteration 3 disarmed
213
+ the mechanism for the rest of the run, leaving iteration 40 to die with
214
+ obvious moves left. It is now cleared by a turn that actually succeeded.
215
+
216
+ **An eval case can no longer hang the suite.** `executeCase` was a bare
217
+ await, so a `run` closure that never settled blocked its worker and
218
+ `runExperiment` never returned — no report, no partial results, nothing to
219
+ read. `ExperimentConfig.timeoutMs` bounds a case and hands `run` an
220
+ `AbortSignal` as a third argument; a timed-out case is reported and the
221
+ suite continues, exactly like a case that threw, with its real elapsed time
222
+ rather than zero. Unset means no deadline, which is today's behaviour. The
223
+ documented path already inherits deadlines from the runtime it drives; this
224
+ covers what those cannot see — a closure that does not go through
225
+ `query()`, and a mid-iteration provider stall.
226
+
227
+ **A malformed content block is named, not smuggled.** One driver built an
228
+ image block by calling `String()` on whatever `data` and `mediaType`
229
+ happened to be, behind only a truthiness check — so a non-string `data`
230
+ became the literal `"[object Object]"` as the base64 payload, and the wire
231
+ rejected the whole request with nothing naming the block at fault. That is
232
+ reachable: a remote tool result is cast without validation on the way in.
233
+ It now type- and media-type-guards and degrades to a named placeholder,
234
+ matching the sibling driver that already did, and without inlining the
235
+ payload it refused to send.
236
+
237
+ **Failures have somewhere to grow remediation.** A stale API key surfaced
238
+ as whatever prose the vendor SDK happened to write: no id to grep in logs,
239
+ no instruction on what to change, and no growth point — a newly-observed
240
+ failure shape could only be given curated copy by editing the classifier.
241
+ `explainError` adds an ordered, id-keyed rule layer matching on
242
+ **structural** signals (code, status, an explicit hint) rather than
243
+ volatile vendor prose. `run_failed` carries the result as `explanation`;
244
+ `withHint(err, '…')` lets a throw site attach what only it knows, and
245
+ outranks every generic rule. It returns `null` when no rule claims the
246
+ failure — inventing advice for something uncharacterised is worse than
247
+ saying nothing, because it sends the reader somewhere specific and wrong.
248
+ The container backend's readiness, port-mapping and worker-fetch failures
249
+ now carry hints.
250
+
251
+ - 935b8f3: namzu's own vocabulary, everywhere.
252
+
253
+ Comments across the kernel explained namzu's design by naming another
254
+ product: "mirrors X's container architecture", "reference: X's
255
+ `normalizePathForSandbox()`", "which is what Y and Z both do", "Claude Code
256
+ uses 2000 for the same reason". Behaviour was correct throughout — this is
257
+ about what the code says it is. A kernel that explains itself by citation
258
+ reads as a reimplementation of something else, and namzu is not one.
259
+
260
+ Every such comment now states the reason directly. Where a rule exists
261
+ because a provider requires it, the comment says what the requirement is
262
+ rather than whose it is — which is also more useful, since the same
263
+ requirement usually holds for more than one provider, and a reader who has
264
+ never used the named one can still follow it.
265
+
266
+ **Breaking (types only, no runtime behaviour):**
267
+
268
+ - `ToolCatalogSurface`: the `'cowork'` member is now `'supervised'`.
269
+ - `ToolSource.skill.type`: `'anthropic' | 'custom'` is now
270
+ `'published' | 'custom'`.
271
+
272
+ Both are descriptive metadata with no construction site anywhere in the
273
+ workspace, so nothing internal moved. An external consumer that names
274
+ either value gets a compile error pointing at the line.
275
+
276
+ **Deliberately unchanged**, because these are addresses rather than
277
+ borrowed naming: model-id prefixes in the context-window table (data the
278
+ runtime matches against), API-key detection patterns in the guardrail
279
+ presets (a pattern is worthless if you cannot tell what it detects),
280
+ namzu's own provider package names, and the credential-store integration in
281
+ the CLI, whose service name and file path are literally the other tool's.
282
+
3
283
  ## 1.2.0
4
284
 
5
285
  ### 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,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEvE,6EAA6E;AAC7E,2EAA2E;AAC3E,8CAA8C;AAC9C,UAAU,CAAC,GAAG,EAAE;IACf,IAAI,gBAAgB,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/C,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;IACzC,CAAC;AACF,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IACjC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACpC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;YACnD,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC7D,iBAAiB,EAAE,CAAA;YACnB,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC5D,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;QAC5D,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;YAC1E,iBAAiB,EAAE,CAAA;YACnB,MAAM,CAAC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AAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,CAAC;KACR,CAAA;IACD,MAAM;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE;QAClC,KAAK,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;KAC3B,CAAA;IACD,MAAM;QACL,IAAI,EAAE,cAAc;KACpB,CAAA;AACF,CAAC"}
@@ -0,0 +1,2 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-shape-guard.test.js","sourceRoot":"","sources":["../../src/__tests__/block-shape-guard.test.ts"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CAAA;QAEtD,kEAAkE;QAClE,yDAAyD;QACzD,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,aAAa,EAAE,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAChF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAA;QAExD,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,aAAa,EAAE,CAAA;IACzC,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACvD,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,CAAC,MAAM,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAA;IAC7E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cache-anchors.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-anchors.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cache-anchors.test.ts"],"names":[],"mappings":""}