@namzu/anthropic 2.0.1 → 3.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 +70 -0
- package/dist/__tests__/thinking-capability.test.js +44 -21
- package/dist/__tests__/thinking-capability.test.js.map +1 -1
- package/dist/__tests__/thinking-contract.live.test.d.ts +2 -0
- package/dist/__tests__/thinking-contract.live.test.d.ts.map +1 -0
- package/dist/__tests__/thinking-contract.live.test.js +97 -0
- package/dist/__tests__/thinking-contract.live.test.js.map +1 -0
- package/dist/__tests__/wire-contract.live.test.d.ts +2 -0
- package/dist/__tests__/wire-contract.live.test.d.ts.map +1 -0
- package/dist/__tests__/wire-contract.live.test.js +186 -0
- package/dist/__tests__/wire-contract.live.test.js.map +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -2
- package/dist/client.js.map +1 -1
- package/dist/thinking-capability.d.ts +26 -6
- package/dist/thinking-capability.d.ts.map +1 -1
- package/dist/thinking-capability.js +52 -16
- package/dist/thinking-capability.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/thinking-capability.test.ts +46 -22
- package/src/__tests__/thinking-contract.live.test.ts +125 -0
- package/src/__tests__/wire-contract.live.test.ts +237 -0
- package/src/client.ts +11 -1
- package/src/thinking-capability.ts +68 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- f8355de: tool schemas are rendered in the dialect each wire actually parses
|
|
8
|
+
|
|
9
|
+
A tool with a tuple-shaped field took down every request that offered it. The
|
|
10
|
+
kernel renders one canonical JSON Schema in draft-07, where a tuple is
|
|
11
|
+
`items: [a, b]`; one of the wires namzu speaks validates tool input as JSON
|
|
12
|
+
Schema 2020-12, where that spelling is invalid and a tuple must be
|
|
13
|
+
`prefixItems`. Every driver forwarded the rendering verbatim, so the built-in
|
|
14
|
+
`read` tool — whose `readRange` is a Zod tuple — produced a 400 that rejected
|
|
15
|
+
the **whole** request, taking every other tool in the call down with it. The
|
|
16
|
+
turn died before generating a token.
|
|
17
|
+
|
|
18
|
+
The failure had nothing to do with strict tool use, which is why the guard
|
|
19
|
+
added for the previous schema outage never saw it: it fires with strict
|
|
20
|
+
validation unset, and with strict on the dialect error arrives _first_.
|
|
21
|
+
|
|
22
|
+
Which dialect a wire parses is a property of the wire, so the conversion now
|
|
23
|
+
happens at each driver's boundary rather than in the renderer:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { toSchemaDialect, findDraft07Only } from "@namzu/sdk";
|
|
27
|
+
|
|
28
|
+
toSchemaDialect(schema, "2020-12"); // items: [a, b] -> prefixItems: [a, b]
|
|
29
|
+
findDraft07Only(schema); // paths that no 2020-12 parser will accept
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`renderToolSchema` is exported now too, so a caller assembling its own tool
|
|
33
|
+
payload gets the same memoized, `$schema`-stripped, deep-frozen rendering the
|
|
34
|
+
kernel puts on the wire — byte-identical across iterations, which matters
|
|
35
|
+
because the tools block sits at position 0 of the prompt-cache prefix.
|
|
36
|
+
|
|
37
|
+
`ToolCatalog` used to convert schemas through its own inline call with the same
|
|
38
|
+
options. Same output, none of the guarantees: no `$schema` stripping, no
|
|
39
|
+
memoization, no freeze. It goes through `renderToolSchema` now.
|
|
40
|
+
|
|
41
|
+
**Breaking, for the three drivers.** Their `@namzu/sdk` peer range was
|
|
42
|
+
`>=1.3.0` and is now `>=6.0.0`. That range was already wrong — the drivers call
|
|
43
|
+
kernel functions added well after 1.3.0 — and it would now let a package
|
|
44
|
+
manager install a combination that throws on every request carrying a tool.
|
|
45
|
+
Upgrade the kernel alongside the driver.
|
|
46
|
+
|
|
47
|
+
The conversion follows the model on multi-vendor wires. Bedrock's Converse API
|
|
48
|
+
carries several vendors through one request shape, and the 2020-12 requirement
|
|
49
|
+
was measured on one of them, so schemas bound for the others are left in the
|
|
50
|
+
dialect they were rendered in. Guessing there would trade a known break for an
|
|
51
|
+
unmeasured one.
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- f8355de: reasoning effort is dropped only on the models that actually refuse it
|
|
56
|
+
|
|
57
|
+
With thinking switched off, the driver discarded `xhigh` and `max` on every
|
|
58
|
+
model that can switch thinking off. The reasoning was that the pairing is
|
|
59
|
+
incoherent anyway — asking a model not to think and then to think as hard as
|
|
60
|
+
possible.
|
|
61
|
+
|
|
62
|
+
Measured against the live API, the rule was too wide. One model family rejects
|
|
63
|
+
that combination with _"effort is not supported when thinking is disabled"_;
|
|
64
|
+
its siblings accept it and honour the effort. So the blanket rule was silently
|
|
65
|
+
discarding a setting the caller asked for and the wire would have applied, on
|
|
66
|
+
models where nothing was wrong.
|
|
67
|
+
|
|
68
|
+
Looking incoherent is not the same as being rejected, and only the wire decides
|
|
69
|
+
which. The capability table now carries the levels accepted with thinking off
|
|
70
|
+
as a separate set from the levels accepted generally, because on most models
|
|
71
|
+
those two sets are identical and on one family they are not.
|
|
72
|
+
|
|
3
73
|
## 2.0.1
|
|
4
74
|
|
|
5
75
|
### Patch Changes
|
|
@@ -25,30 +25,37 @@ const NONE = [];
|
|
|
25
25
|
* twice, so a boolean could not say that `xhigh` is rejected on 4.6 and `max`
|
|
26
26
|
* is rejected on 4.5 — which is exactly what it failed to say.
|
|
27
27
|
*/
|
|
28
|
+
const CAPPED = BASE; // opus 5+ with thinking off
|
|
28
29
|
const TABLE = [
|
|
29
30
|
// Always-on families: thinking cannot be switched off at any version.
|
|
30
|
-
['claude-fable-5', true, false, false, ALL],
|
|
31
|
-
['claude-mythos-5', true, false, false, ALL],
|
|
32
|
-
['claude-mythos-preview', true, true, false, ALL],
|
|
31
|
+
['claude-fable-5', true, false, false, ALL, ALL],
|
|
32
|
+
['claude-mythos-5', true, false, false, ALL, ALL],
|
|
33
|
+
['claude-mythos-preview', true, true, false, ALL, ALL],
|
|
33
34
|
// 4.7 and later: adaptive only, and it can still be disabled.
|
|
34
|
-
['claude-opus-5', true, false, true, ALL],
|
|
35
|
-
['claude-sonnet-5', true, false, true, ALL],
|
|
36
|
-
['claude-opus-4-8', true, false, true, ALL],
|
|
37
|
-
['claude-opus-4-7', true, false, true, ALL],
|
|
35
|
+
['claude-opus-5', true, false, true, ALL, CAPPED],
|
|
36
|
+
['claude-sonnet-5', true, false, true, ALL, ALL],
|
|
37
|
+
['claude-opus-4-8', true, false, true, ALL, ALL],
|
|
38
|
+
['claude-opus-4-7', true, false, true, ALL, ALL],
|
|
38
39
|
// 4.6: both modes, manual deprecated but working — and no `xhigh`.
|
|
39
|
-
['claude-opus-4-6', true, true, true, NO_XHIGH],
|
|
40
|
-
['claude-sonnet-4-6', true, true, true, NO_XHIGH],
|
|
40
|
+
['claude-opus-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
|
|
41
|
+
['claude-sonnet-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
|
|
41
42
|
// 4.5 and earlier: manual only. Opus 4.5 is the one that takes effort,
|
|
42
43
|
// and only the first three levels.
|
|
43
|
-
['claude-opus-4-5', false, true, true, BASE],
|
|
44
|
-
['claude-haiku-4-5', false, true, true, NONE],
|
|
45
|
-
['claude-sonnet-4-5', false, true, true, NONE],
|
|
46
|
-
['claude-opus-4-1', false, true, true, NONE],
|
|
44
|
+
['claude-opus-4-5', false, true, true, BASE, BASE],
|
|
45
|
+
['claude-haiku-4-5', false, true, true, NONE, NONE],
|
|
46
|
+
['claude-sonnet-4-5', false, true, true, NONE, NONE],
|
|
47
|
+
['claude-opus-4-1', false, true, true, NONE, NONE],
|
|
47
48
|
];
|
|
48
49
|
describe('what each model accepts', () => {
|
|
49
|
-
for (const [model, adaptive, manual, canDisable, effort] of TABLE) {
|
|
50
|
+
for (const [model, adaptive, manual, canDisable, effort, effortWhenDisabled] of TABLE) {
|
|
50
51
|
it(`resolves ${model}`, () => {
|
|
51
|
-
expect(resolveThinkingCapability(model)).toEqual({
|
|
52
|
+
expect(resolveThinkingCapability(model)).toEqual({
|
|
53
|
+
adaptive,
|
|
54
|
+
manual,
|
|
55
|
+
canDisable,
|
|
56
|
+
effort,
|
|
57
|
+
effortWhenDisabled,
|
|
58
|
+
});
|
|
52
59
|
});
|
|
53
60
|
}
|
|
54
61
|
it('tolerates a vendor prefix and a date suffix', () => {
|
|
@@ -85,6 +92,7 @@ describe('what each model accepts', () => {
|
|
|
85
92
|
manual: true,
|
|
86
93
|
canDisable: true,
|
|
87
94
|
effort: [],
|
|
95
|
+
effortWhenDisabled: [],
|
|
88
96
|
});
|
|
89
97
|
});
|
|
90
98
|
});
|
|
@@ -148,12 +156,27 @@ describe('when effort rides along', () => {
|
|
|
148
156
|
const opus45 = resolveThinkingCapability('claude-opus-4-5');
|
|
149
157
|
expect(resolveEffort('high', { type: 'enabled', budget_tokens: 8000 }, opus45)).toBe('high');
|
|
150
158
|
});
|
|
151
|
-
it('
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
it('caps effort with thinking off only where the wire caps it', () => {
|
|
160
|
+
// This rule used to be blanket: thinking off at `xhigh`/`max` was
|
|
161
|
+
// refused on every model that can disable thinking, reasoning that the
|
|
162
|
+
// pairing is incoherent anyway. Measured against the live API, that was
|
|
163
|
+
// too wide — only the Opus 5 family rejects it:
|
|
164
|
+
//
|
|
165
|
+
// claude-opus-5 + disabled + max -> 400 "not supported when thinking is disabled"
|
|
166
|
+
// claude-sonnet-5 + disabled + max -> accepted
|
|
167
|
+
// claude-opus-4-8 + disabled + max -> accepted
|
|
168
|
+
//
|
|
169
|
+
// So the blanket rule was dropping an effort the caller asked for and
|
|
170
|
+
// the wire would have honoured. Looking incoherent is not the same as
|
|
171
|
+
// being rejected, and only the wire decides which.
|
|
172
|
+
const opus5 = resolveThinkingCapability('claude-opus-5');
|
|
173
|
+
expect(resolveEffort('max', { type: 'disabled' }, opus5)).toBeUndefined();
|
|
174
|
+
expect(resolveEffort('xhigh', { type: 'disabled' }, opus5)).toBeUndefined();
|
|
175
|
+
expect(resolveEffort('high', { type: 'disabled' }, opus5)).toBe('high');
|
|
176
|
+
// …and uncapped with thinking on, on the same model.
|
|
177
|
+
expect(resolveEffort('max', { type: 'adaptive' }, opus5)).toBe('max');
|
|
178
|
+
// `adaptiveOnly` here is Sonnet 5, which the wire does not cap.
|
|
179
|
+
expect(resolveEffort('max', { type: 'disabled' }, adaptiveOnly)).toBe('max');
|
|
157
180
|
});
|
|
158
181
|
it('drops a level this model does not have', () => {
|
|
159
182
|
// The ceiling moved twice, so "does this model take effort?" was never
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-capability.test.js","sourceRoot":"","sources":["../../src/__tests__/thinking-capability.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,2BAA2B,CAAA;AAElC;;;;;;;;;;GAUG;AAEH,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;AACrD,gEAAgE;AAChE,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACjD,uBAAuB;AACvB,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AACtC,MAAM,IAAI,GAAa,EAAE,CAAA;AAEzB;;;;;;;GAOG;AACH,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"thinking-capability.test.js","sourceRoot":"","sources":["../../src/__tests__/thinking-capability.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM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":""}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { resolveEffort, resolveThinkingBody, resolveThinkingCapability, } from '../thinking-capability.js';
|
|
3
|
+
/**
|
|
4
|
+
* The capability table, checked against the wire it describes.
|
|
5
|
+
*
|
|
6
|
+
* `thinking-capability.ts` encodes which thinking modes and which `effort`
|
|
7
|
+
* levels each model accepts. Every version of that table so far was
|
|
8
|
+
* transcribed from documentation, and the last transcription was wrong twice —
|
|
9
|
+
* it modelled `effort` as a boolean when the accepted levels are a set, so
|
|
10
|
+
* `xhigh` on a 4.6 and `max` on a 4.5 were forwarded to a wire that rejects an
|
|
11
|
+
* unknown level rather than clamping it.
|
|
12
|
+
*
|
|
13
|
+
* A table about a wire is only as good as the wire says it is. These tests ask.
|
|
14
|
+
*
|
|
15
|
+
* Skipped without a key. Deliberately narrow: two current models, cheap
|
|
16
|
+
* requests (`max_tokens: 1`), and only the rows that would silently rot.
|
|
17
|
+
*/
|
|
18
|
+
const KEY = process.env.ANTHROPIC_API_KEY;
|
|
19
|
+
/** Cheap and current: one adaptive-only model, one manual-only model. */
|
|
20
|
+
const ADAPTIVE_MODEL = process.env.NAMZU_WIRE_TEST_MODEL ?? 'claude-sonnet-5';
|
|
21
|
+
const CAPPED_MODEL = 'claude-opus-5';
|
|
22
|
+
const MANUAL_MODEL = 'claude-haiku-4-5';
|
|
23
|
+
async function send(model, extra) {
|
|
24
|
+
const res = await fetch('https://api.anthropic.com/v1/messages', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: {
|
|
27
|
+
'x-api-key': KEY,
|
|
28
|
+
'anthropic-version': '2023-06-01',
|
|
29
|
+
'content-type': 'application/json',
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
model,
|
|
33
|
+
max_tokens: 1,
|
|
34
|
+
messages: [{ role: 'user', content: 'hi' }],
|
|
35
|
+
...extra,
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
if (res.ok)
|
|
39
|
+
return true;
|
|
40
|
+
const body = await res.json().catch(() => ({}));
|
|
41
|
+
return body?.error?.message ?? `HTTP ${res.status}`;
|
|
42
|
+
}
|
|
43
|
+
describe.skipIf(!KEY)('the effort levels the table claims are the ones the wire takes', () => {
|
|
44
|
+
it.each(['low', 'medium', 'high', 'xhigh', 'max'])('%s is accepted on a current model, and the table says so', async (level) => {
|
|
45
|
+
const capability = resolveThinkingCapability(ADAPTIVE_MODEL);
|
|
46
|
+
expect(capability.effort, `table omits ${level}`).toContain(level);
|
|
47
|
+
const resolved = resolveEffort(level, { type: 'adaptive' }, capability);
|
|
48
|
+
expect(resolved, 'resolver dropped a level the table allows').toBe(level);
|
|
49
|
+
const result = await send(ADAPTIVE_MODEL, {
|
|
50
|
+
thinking: { type: 'adaptive' },
|
|
51
|
+
output_config: { effort: level },
|
|
52
|
+
});
|
|
53
|
+
expect(result).toBe(true);
|
|
54
|
+
}, 120_000);
|
|
55
|
+
it('drops effort on a model that takes none, and the wire agrees it would have failed', async () => {
|
|
56
|
+
const capability = resolveThinkingCapability(MANUAL_MODEL);
|
|
57
|
+
expect(capability.effort).toEqual([]);
|
|
58
|
+
expect(resolveEffort('high', { type: 'enabled' }, capability)).toBeUndefined();
|
|
59
|
+
// The half that matters: had the resolver NOT dropped it, this is what
|
|
60
|
+
// the wire would have said. A table claiming "no effort here" is only
|
|
61
|
+
// worth something if sending effort really does fail.
|
|
62
|
+
const result = await send(MANUAL_MODEL, { output_config: { effort: 'high' } });
|
|
63
|
+
expect(result).not.toBe(true);
|
|
64
|
+
}, 120_000);
|
|
65
|
+
});
|
|
66
|
+
describe.skipIf(!KEY)('the thinking body the resolver builds is one the wire accepts', () => {
|
|
67
|
+
it('adaptive, on a model the table calls adaptive-only', async () => {
|
|
68
|
+
const capability = resolveThinkingCapability(ADAPTIVE_MODEL);
|
|
69
|
+
expect(capability.adaptive).toBe(true);
|
|
70
|
+
const body = resolveThinkingBody({ type: 'adaptive' }, capability);
|
|
71
|
+
expect(await send(ADAPTIVE_MODEL, { thinking: body })).toBe(true);
|
|
72
|
+
}, 120_000);
|
|
73
|
+
it('rewrites a manual intent rather than sending one the model refuses', async () => {
|
|
74
|
+
// The resolver turns `enabled` into `adaptive` where manual is rejected.
|
|
75
|
+
// If it did not, this is the request that would go out — so both halves
|
|
76
|
+
// are asserted: what we send is accepted, and what we avoided is not.
|
|
77
|
+
const capability = resolveThinkingCapability(ADAPTIVE_MODEL);
|
|
78
|
+
const body = resolveThinkingBody({ type: 'enabled', budgetTokens: 2048 }, capability);
|
|
79
|
+
expect(body).toEqual({ type: 'adaptive' });
|
|
80
|
+
expect(await send(ADAPTIVE_MODEL, { thinking: body })).toBe(true);
|
|
81
|
+
expect(await send(ADAPTIVE_MODEL, { thinking: { type: 'enabled', budget_tokens: 2048 } })).not.toBe(true);
|
|
82
|
+
}, 120_000);
|
|
83
|
+
it('caps effort with thinking off only where the wire actually caps it', async () => {
|
|
84
|
+
// Both directions, because the first version of this rule was too wide.
|
|
85
|
+
const capped = resolveThinkingCapability(CAPPED_MODEL);
|
|
86
|
+
const disabledOnCapped = resolveThinkingBody({ type: 'disabled' }, capped);
|
|
87
|
+
expect(resolveEffort('max', disabledOnCapped, capped)).toBeUndefined();
|
|
88
|
+
expect(resolveEffort('high', disabledOnCapped, capped)).toBe('high');
|
|
89
|
+
expect(await send(CAPPED_MODEL, { thinking: disabledOnCapped, output_config: { effort: 'max' } })).not.toBe(true);
|
|
90
|
+
// …and a model the wire does NOT cap keeps the level the caller asked for.
|
|
91
|
+
const open = resolveThinkingCapability(ADAPTIVE_MODEL);
|
|
92
|
+
const disabledOnOpen = resolveThinkingBody({ type: 'disabled' }, open);
|
|
93
|
+
expect(resolveEffort('max', disabledOnOpen, open)).toBe('max');
|
|
94
|
+
expect(await send(ADAPTIVE_MODEL, { thinking: disabledOnOpen, output_config: { effort: 'max' } })).toBe(true);
|
|
95
|
+
}, 120_000);
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=thinking-contract.live.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking-contract.live.test.js","sourceRoot":"","sources":["../../src/__tests__/thinking-contract.live.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,2BAA2B,CAAA;AAElC;;;;;;;;;;;;;;GAcG;AAEH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;AAEzC,yEAAyE;AACzE,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,iBAAiB,CAAA;AAC7E,MAAM,YAAY,GAAG,eAAe,CAAA;AACpC,MAAM,YAAY,GAAG,kBAAkB,CAAA;AAEvC,KAAK,UAAU,IAAI,CAAC,KAAa,EAAE,KAA8B;IAChE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,uCAAuC,EAAE;QAChE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACR,WAAW,EAAE,GAAa;YAC1B,mBAAmB,EAAE,YAAY;YACjC,cAAc,EAAE,kBAAkB;SAClC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACpB,KAAK;YACL,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC3C,GAAG,KAAK;SACR,CAAC;KACF,CAAC,CAAA;IACF,IAAI,GAAG,CAAC,EAAE;QAAE,OAAO,IAAI,CAAA;IACvB,MAAM,IAAI,GAAY,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACxD,OAAQ,IAAgD,EAAE,KAAK,EAAE,OAAO,IAA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AAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,CAAC,EAAE,OAAO,CAAC,CAAA;AACZ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-contract.live.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/wire-contract.live.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { findDraft07Only, findStrictSchemaViolations, getBuiltinTools, renderToolSchema, toSchemaDialect, } from '@namzu/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* The test that would have caught both outages.
|
|
5
|
+
*
|
|
6
|
+
* Every other test in this repo renders a schema and asserts something about
|
|
7
|
+
* the object. Both production breakages were schemas that looked fine as
|
|
8
|
+
* objects and were rejected by the wire:
|
|
9
|
+
*
|
|
10
|
+
* - `edit.insertLine` used `oneOf`, which strict tool use refuses.
|
|
11
|
+
* - `read.readRange` is a Zod tuple, which renders draft-07 `items: [a, b]`
|
|
12
|
+
* while this wire requires draft 2020-12 — rejected with `strict` unset,
|
|
13
|
+
* so a guard scoped to strict never saw it.
|
|
14
|
+
*
|
|
15
|
+
* Neither could fail offline, because neither was wrong offline. So this one
|
|
16
|
+
* talks to the real API.
|
|
17
|
+
*
|
|
18
|
+
* It asks the cheapest question that still exercises schema validation:
|
|
19
|
+
* `max_tokens: 1` and a one-word prompt. Validation happens before generation,
|
|
20
|
+
* so a rejected schema costs nothing and an accepted one costs a single token.
|
|
21
|
+
*
|
|
22
|
+
* Skipped without a key, so CI stays green where none is configured. Run it
|
|
23
|
+
* with:
|
|
24
|
+
*
|
|
25
|
+
* ANTHROPIC_API_KEY=… pnpm --filter @namzu/anthropic test
|
|
26
|
+
*/
|
|
27
|
+
const KEY = process.env.ANTHROPIC_API_KEY;
|
|
28
|
+
const MODEL = process.env.NAMZU_WIRE_TEST_MODEL ?? 'claude-haiku-4-5';
|
|
29
|
+
async function offerTools(tools) {
|
|
30
|
+
const res = await fetch('https://api.anthropic.com/v1/messages', {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'x-api-key': KEY,
|
|
34
|
+
'anthropic-version': '2023-06-01',
|
|
35
|
+
'content-type': 'application/json',
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
model: MODEL,
|
|
39
|
+
max_tokens: 1,
|
|
40
|
+
messages: [{ role: 'user', content: 'hi' }],
|
|
41
|
+
tools,
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
const body = await res.json().catch(() => ({}));
|
|
45
|
+
const message = body?.error?.message ?? (res.ok ? '' : 'unknown');
|
|
46
|
+
return { ok: res.ok, status: res.status, message };
|
|
47
|
+
}
|
|
48
|
+
/** A tool as this driver would put it on the wire. */
|
|
49
|
+
function wireTool(name, schema, strict) {
|
|
50
|
+
return {
|
|
51
|
+
name,
|
|
52
|
+
description: 'contract probe',
|
|
53
|
+
input_schema: toSchemaDialect(schema, '2020-12'),
|
|
54
|
+
...(strict ? { strict: true } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
describe.skipIf(!KEY)('every shipped tool is expressible on this wire', () => {
|
|
58
|
+
const tools = getBuiltinTools();
|
|
59
|
+
it('offers all of them in one request, the way a real run does', async () => {
|
|
60
|
+
// One request with the whole toolset, because that is the shape that
|
|
61
|
+
// broke: the wire rejects the WHOLE request for one bad schema, so a
|
|
62
|
+
// per-tool loop would pass while a real run still died.
|
|
63
|
+
const payload = tools.map((t) => wireTool(t.name, t.modelInputSchema ??
|
|
64
|
+
renderToolSchema(t.inputSchema), Boolean(t.enforceModelInput)));
|
|
65
|
+
const result = await offerTools(payload);
|
|
66
|
+
expect(result.ok, `HTTP ${result.status}: ${result.message}`).toBe(true);
|
|
67
|
+
}, 180_000);
|
|
68
|
+
it.each(tools.map((t) => [t.name, t]))('%s alone', async (name, tool) => {
|
|
69
|
+
// And individually, so a failure names the tool instead of the batch.
|
|
70
|
+
const schema = tool.modelInputSchema ??
|
|
71
|
+
renderToolSchema(tool.inputSchema);
|
|
72
|
+
const result = await offerTools([wireTool(name, schema, Boolean(tool.enforceModelInput))]);
|
|
73
|
+
expect(result.ok, `HTTP ${result.status}: ${result.message}`).toBe(true);
|
|
74
|
+
}, 180_000);
|
|
75
|
+
});
|
|
76
|
+
describe.skipIf(!KEY)('the dialect conversion is what makes the difference', () => {
|
|
77
|
+
it('rejects the draft-07 tuple and accepts the converted one', async () => {
|
|
78
|
+
// Pins the actual mechanism rather than trusting that conversion helped.
|
|
79
|
+
// If the wire ever starts accepting draft-07 tuples this test says so,
|
|
80
|
+
// and if it ever stops accepting `prefixItems` it says that too.
|
|
81
|
+
const draft07 = {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
range: {
|
|
85
|
+
type: 'array',
|
|
86
|
+
minItems: 2,
|
|
87
|
+
maxItems: 2,
|
|
88
|
+
items: [{ type: 'integer' }, { type: 'integer' }],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
const before = await offerTools([{ name: 'probe', description: 'p', input_schema: draft07 }]);
|
|
93
|
+
expect(before.ok).toBe(false);
|
|
94
|
+
expect(before.message).toMatch(/2020-12/);
|
|
95
|
+
const after = await offerTools([
|
|
96
|
+
{ name: 'probe', description: 'p', input_schema: toSchemaDialect(draft07, '2020-12') },
|
|
97
|
+
]);
|
|
98
|
+
expect(after.ok, `HTTP ${after.status}: ${after.message}`).toBe(true);
|
|
99
|
+
}, 180_000);
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* The strict subset, measured rather than read.
|
|
103
|
+
*
|
|
104
|
+
* `findStrictSchemaViolations` carries a deny-list, and the first version of it
|
|
105
|
+
* was derived from prose. It was wrong in both directions: it refused
|
|
106
|
+
* `minLength`/`maxLength`, which this wire accepts, so it would have blocked
|
|
107
|
+
* working tools; and it permitted `prefixItems`, which this wire rejects, so it
|
|
108
|
+
* would have vouched for a broken one. A deny-list nobody probed is a guess in
|
|
109
|
+
* a confident tone.
|
|
110
|
+
*
|
|
111
|
+
* This block is where the list comes from. Each row is one request; a row that
|
|
112
|
+
* changes means the subset moved, and the deny-list has to move with it.
|
|
113
|
+
*/
|
|
114
|
+
const STRICT_SUBSET = [
|
|
115
|
+
['minLength/maxLength', { type: 'string', minLength: 1, maxLength: 9 }, true],
|
|
116
|
+
['pattern', { type: 'string', pattern: '^a+$' }, true],
|
|
117
|
+
['format', { type: 'string', format: 'uri' }, true],
|
|
118
|
+
['enum', { type: 'string', enum: ['a', 'b'] }, true],
|
|
119
|
+
['anyOf', { anyOf: [{ type: 'integer' }, { const: 'end' }] }, true],
|
|
120
|
+
// `minItems` is a bound on the VALUE, not a rejected keyword: 0 and 1 pass,
|
|
121
|
+
// anything above does not. A blanket denial would refuse the ordinary
|
|
122
|
+
// spelling of a non-empty array.
|
|
123
|
+
['minItems: 0', { type: 'array', items: { type: 'string' }, minItems: 0 }, true],
|
|
124
|
+
['minItems: 1', { type: 'array', items: { type: 'string' }, minItems: 1 }, true],
|
|
125
|
+
['minItems: 2', { type: 'array', items: { type: 'string' }, minItems: 2 }, false],
|
|
126
|
+
['maxItems', { type: 'array', items: { type: 'string' }, maxItems: 3 }, false],
|
|
127
|
+
['uniqueItems', { type: 'array', items: { type: 'string' }, uniqueItems: true }, false],
|
|
128
|
+
['minimum', { type: 'integer', minimum: 0 }, false],
|
|
129
|
+
['oneOf', { oneOf: [{ type: 'integer' }, { const: 'end' }] }, false],
|
|
130
|
+
['not', { not: { type: 'null' } }, false],
|
|
131
|
+
// The one that interacts with the dialect fix: a tuple is unexpressible
|
|
132
|
+
// under strict in EITHER spelling, so converting it only changes the error.
|
|
133
|
+
['prefixItems', { type: 'array', prefixItems: [{ type: 'integer' }] }, false],
|
|
134
|
+
];
|
|
135
|
+
describe.skipIf(!KEY)('the strict subset is what the deny-list says it is', () => {
|
|
136
|
+
it.each(STRICT_SUBSET.map(([label, schema, accepted]) => [label, schema, accepted]))('strict + %s', async (label, propSchema, accepted) => {
|
|
137
|
+
const result = await offerTools([
|
|
138
|
+
{
|
|
139
|
+
name: 'probe',
|
|
140
|
+
description: 'p',
|
|
141
|
+
strict: true,
|
|
142
|
+
input_schema: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: { f: propSchema },
|
|
145
|
+
required: ['f'],
|
|
146
|
+
additionalProperties: false,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
]);
|
|
150
|
+
expect(result.ok, `${label}: HTTP ${result.status}: ${result.message}`).toBe(accepted);
|
|
151
|
+
// And the offline check has to agree with the wire, which is the
|
|
152
|
+
// whole point of pinning both in one place.
|
|
153
|
+
expect(findStrictSchemaViolations({ properties: { f: propSchema } }).length === 0).toBe(accepted);
|
|
154
|
+
}, 180_000);
|
|
155
|
+
it('rejects the draft-07 tuple before it ever gets to the strict question', async () => {
|
|
156
|
+
// Dialect first, subset second. This is why a guard scoped to strict
|
|
157
|
+
// could not have caught `read.readRange`: the tuple is refused with
|
|
158
|
+
// `strict` unset too.
|
|
159
|
+
const tuple = {
|
|
160
|
+
type: 'object',
|
|
161
|
+
properties: { f: { type: 'array', items: [{ type: 'integer' }, { type: 'integer' }] } },
|
|
162
|
+
};
|
|
163
|
+
const result = await offerTools([{ name: 'probe', description: 'p', input_schema: tuple }]);
|
|
164
|
+
expect(result.ok).toBe(false);
|
|
165
|
+
expect(result.message).toMatch(/2020-12/);
|
|
166
|
+
}, 180_000);
|
|
167
|
+
});
|
|
168
|
+
describe('what can be checked without a key', () => {
|
|
169
|
+
it('leaves no draft-07-only construct in any shipped tool', () => {
|
|
170
|
+
// The offline half of the same guarantee, so a contributor without a
|
|
171
|
+
// key still gets the signal — just not the proof.
|
|
172
|
+
for (const tool of getBuiltinTools()) {
|
|
173
|
+
const schema = tool.modelInputSchema ??
|
|
174
|
+
renderToolSchema(tool.inputSchema);
|
|
175
|
+
const converted = toSchemaDialect(schema, '2020-12');
|
|
176
|
+
expect(findDraft07Only(converted), tool.name).toEqual([]);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
it('still finds one before conversion, so the sweep is not vacuous', () => {
|
|
180
|
+
// `read` renders a Zod tuple. If this ever stops finding anything, the
|
|
181
|
+
// test above has quietly become a tautology.
|
|
182
|
+
const withTuple = getBuiltinTools().filter((t) => !t.modelInputSchema && findDraft07Only(renderToolSchema(t.inputSchema)).length > 0);
|
|
183
|
+
expect(withTuple.map((t) => t.name)).toContain('read');
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
//# sourceMappingURL=wire-contract.live.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-contract.live.test.js","sourceRoot":"","sources":["../../src/__tests__/wire-contract.live.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACN,eAAe,EACf,0BAA0B,EAC1B,eAAe,EACf,gBAAgB,EAChB,eAAe,GACf,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;AACzC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,kBAAkB,CAAA;AAQrE,KAAK,UAAU,UAAU,CAAC,KAAgB;IACzC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,uCAAuC,EAAE;QAChE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACR,WAAW,EAAE,GAAa;YAC1B,mBAAmB,EAAE,YAAY;YACjC,cAAc,EAAE,kBAAkB;SAClC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACpB,KAAK,EAAE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;QAC1D,CAAC;IACF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACzE,uEAAuE;QACvE,6CAA6C;QAC7C,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC,MAAM,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,IAAI,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CACzF,CAAA;QACD,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -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,WAAW,EAIX,MAAM,YAAY,CAAA;
|
|
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,WAAW,EAIX,MAAM,YAAY,CAAA;AAiBnB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA0kBjD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBAMpC,CAAA;AAED,qBAAa,iBAAkB,YAAW,WAAW;IACpD,QAAQ,CAAC,EAAE,eAAc;IACzB,QAAQ,CAAC,IAAI,eAAc;IAC3B,QAAQ,CAAC,YAAY,uBAAyB;IAE9C,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,eAAe;IA8BnC,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,iBAAiB;IAyEzB;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAcV,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,aAAa,CAAC,WAAW,CAAC;IAiPrE,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IA+BxC,OAAO,CAAC,WAAW;IAmCb,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAMrC"}
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
|
-
import { ProviderRequestError, assertStrictSchema, isCallerAbortError, isProviderRequestError, modelVersionAtLeast, providerVendorError, toolResultToText, } from '@namzu/sdk';
|
|
3
|
+
import { ProviderRequestError, assertStrictSchema, isCallerAbortError, isProviderRequestError, modelVersionAtLeast, providerVendorError, toSchemaDialect, toolResultToText, } from '@namzu/sdk';
|
|
4
4
|
import { MODEL_ID_GRAMMAR, resolveEffort, resolveThinkingBody, resolveThinkingCapability, } from './thinking-capability.js';
|
|
5
5
|
// Floor for `max_tokens` when neither the request nor the provider
|
|
6
6
|
// config supplied one. Anthropic's API requires the field, so we cannot
|
|
@@ -237,7 +237,13 @@ function toAnthropicTools(params, cachingEnabled, strictToolUseEnabled) {
|
|
|
237
237
|
return {
|
|
238
238
|
name: t.function.name,
|
|
239
239
|
description: t.function.description ?? '',
|
|
240
|
-
|
|
240
|
+
// This wire parses draft 2020-12, and the renderer emits draft-07.
|
|
241
|
+
// The two disagree about tuples — draft-07 puts the positional
|
|
242
|
+
// schemas in `items`, 2020-12 in `prefixItems` — and the wire
|
|
243
|
+
// rejects the WHOLE request for it, not the one field. Converting
|
|
244
|
+
// here rather than in the renderer keeps the dialect where the
|
|
245
|
+
// knowledge is: only this file knows which wire it is talking to.
|
|
246
|
+
input_schema: toSchemaDialect(t.function.parameters ?? { type: 'object' }, '2020-12'),
|
|
241
247
|
...(strict ? { strict: true } : {}),
|
|
242
248
|
};
|
|
243
249
|
});
|