@namzu/anthropic 3.1.0 → 3.2.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 +73 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +30 -3
- package/dist/client.js.map +1 -1
- package/package.json +12 -2
- package/src/client.ts +33 -3
- package/dist/__tests__/anthropic.test.d.ts +0 -2
- package/dist/__tests__/anthropic.test.d.ts.map +0 -1
- package/dist/__tests__/anthropic.test.js +0 -425
- package/dist/__tests__/anthropic.test.js.map +0 -1
- package/dist/__tests__/background-delegation.live.test.d.ts +0 -2
- package/dist/__tests__/background-delegation.live.test.d.ts.map +0 -1
- package/dist/__tests__/background-delegation.live.test.js +0 -212
- package/dist/__tests__/background-delegation.live.test.js.map +0 -1
- package/dist/__tests__/block-shape-guard.test.d.ts +0 -2
- package/dist/__tests__/block-shape-guard.test.d.ts.map +0 -1
- package/dist/__tests__/block-shape-guard.test.js +0 -218
- package/dist/__tests__/block-shape-guard.test.js.map +0 -1
- package/dist/__tests__/cache-anchors.test.d.ts +0 -2
- package/dist/__tests__/cache-anchors.test.d.ts.map +0 -1
- package/dist/__tests__/cache-anchors.test.js +0 -220
- package/dist/__tests__/cache-anchors.test.js.map +0 -1
- package/dist/__tests__/citations.test.d.ts +0 -2
- package/dist/__tests__/citations.test.d.ts.map +0 -1
- package/dist/__tests__/citations.test.js +0 -189
- package/dist/__tests__/citations.test.js.map +0 -1
- package/dist/__tests__/content-blocks.test.d.ts +0 -2
- package/dist/__tests__/content-blocks.test.d.ts.map +0 -1
- package/dist/__tests__/content-blocks.test.js +0 -131
- package/dist/__tests__/content-blocks.test.js.map +0 -1
- package/dist/__tests__/document-input.test.d.ts +0 -2
- package/dist/__tests__/document-input.test.d.ts.map +0 -1
- package/dist/__tests__/document-input.test.js +0 -98
- package/dist/__tests__/document-input.test.js.map +0 -1
- package/dist/__tests__/effort-levels-are-askable.test.d.ts +0 -2
- package/dist/__tests__/effort-levels-are-askable.test.d.ts.map +0 -1
- package/dist/__tests__/effort-levels-are-askable.test.js +0 -74
- package/dist/__tests__/effort-levels-are-askable.test.js.map +0 -1
- package/dist/__tests__/error-taxonomy.test.d.ts +0 -16
- package/dist/__tests__/error-taxonomy.test.d.ts.map +0 -1
- package/dist/__tests__/error-taxonomy.test.js +0 -242
- package/dist/__tests__/error-taxonomy.test.js.map +0 -1
- package/dist/__tests__/reasoning-close.test.d.ts +0 -2
- package/dist/__tests__/reasoning-close.test.d.ts.map +0 -1
- package/dist/__tests__/reasoning-close.test.js +0 -219
- package/dist/__tests__/reasoning-close.test.js.map +0 -1
- package/dist/__tests__/thinking-capability.test.d.ts +0 -2
- package/dist/__tests__/thinking-capability.test.d.ts.map +0 -1
- package/dist/__tests__/thinking-capability.test.js +0 -206
- package/dist/__tests__/thinking-capability.test.js.map +0 -1
- package/dist/__tests__/thinking-contract.live.test.d.ts +0 -2
- package/dist/__tests__/thinking-contract.live.test.d.ts.map +0 -1
- package/dist/__tests__/thinking-contract.live.test.js +0 -97
- package/dist/__tests__/thinking-contract.live.test.js.map +0 -1
- package/dist/__tests__/thinking-request-body.test.d.ts +0 -2
- package/dist/__tests__/thinking-request-body.test.d.ts.map +0 -1
- package/dist/__tests__/thinking-request-body.test.js +0 -90
- package/dist/__tests__/thinking-request-body.test.js.map +0 -1
- package/dist/__tests__/wire-contract.live.test.d.ts +0 -2
- package/dist/__tests__/wire-contract.live.test.d.ts.map +0 -1
- package/dist/__tests__/wire-contract.live.test.js +0 -272
- package/dist/__tests__/wire-contract.live.test.js.map +0 -1
- package/src/__tests__/anthropic.test.ts +0 -490
- package/src/__tests__/background-delegation.live.test.ts +0 -243
- package/src/__tests__/block-shape-guard.test.ts +0 -256
- package/src/__tests__/cache-anchors.test.ts +0 -262
- package/src/__tests__/citations.test.ts +0 -218
- package/src/__tests__/content-blocks.test.ts +0 -153
- package/src/__tests__/document-input.test.ts +0 -131
- package/src/__tests__/effort-levels-are-askable.test.ts +0 -86
- package/src/__tests__/error-taxonomy.test.ts +0 -274
- package/src/__tests__/reasoning-close.test.ts +0 -262
- package/src/__tests__/thinking-capability.test.ts +0 -235
- package/src/__tests__/thinking-contract.live.test.ts +0 -125
- package/src/__tests__/thinking-request-body.test.ts +0 -111
- package/src/__tests__/wire-contract.live.test.ts +0 -331
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { resolveEffort, resolveThinkingBody, resolveThinkingCapability, } from '../thinking-capability.js';
|
|
3
|
-
/**
|
|
4
|
-
* The driver mapped `enabled` straight through and everything else to
|
|
5
|
-
* `disabled`. On a current model that is not a degraded request, it is a
|
|
6
|
-
* failed one: `thinking.type.enabled` is rejected with a 400 from 4.7 onward,
|
|
7
|
-
* `adaptive` is rejected on 4.5 and earlier, and the always-on models reject
|
|
8
|
-
* `disabled`.
|
|
9
|
-
*
|
|
10
|
-
* The table below is transcribed from the vendor's per-model reference, one
|
|
11
|
-
* case per row, because that table IS the specification — a summary of it in
|
|
12
|
-
* prose would be the thing that drifts.
|
|
13
|
-
*/
|
|
14
|
-
const ALL = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
15
|
-
/** 4.6 has `max` but not `xhigh` — `xhigh` arrived with 4.7. */
|
|
16
|
-
const NO_XHIGH = ['low', 'medium', 'high', 'max'];
|
|
17
|
-
/** 4.5 has neither. */
|
|
18
|
-
const BASE = ['low', 'medium', 'high'];
|
|
19
|
-
const NONE = [];
|
|
20
|
-
/**
|
|
21
|
-
* [model, adaptive, manual, canDisable, effort levels]
|
|
22
|
-
*
|
|
23
|
-
* Every currently-served model, plus the legacy ones a gateway may still be
|
|
24
|
-
* pointed at. `effort` is the accepted LEVELS, not a flag: the ceiling moved
|
|
25
|
-
* twice, so a boolean could not say that `xhigh` is rejected on 4.6 and `max`
|
|
26
|
-
* is rejected on 4.5 — which is exactly what it failed to say.
|
|
27
|
-
*/
|
|
28
|
-
const CAPPED = BASE; // opus 5+ with thinking off
|
|
29
|
-
const TABLE = [
|
|
30
|
-
// Always-on families: thinking cannot be switched off at any version.
|
|
31
|
-
['claude-fable-5', true, false, false, ALL, ALL],
|
|
32
|
-
['claude-mythos-5', true, false, false, ALL, ALL],
|
|
33
|
-
// The preview takes `max` and NOT `xhigh`, which is the pairing it is easy
|
|
34
|
-
// to assume away — the reference says outright that some models supporting
|
|
35
|
-
// `max` do not support `xhigh`, and this is one. Reading the levels as a
|
|
36
|
-
// ladder is what put ALL on this row originally, and a ladder reading sends
|
|
37
|
-
// a level the wire rejects.
|
|
38
|
-
['claude-mythos-preview', true, true, false, NO_XHIGH, NO_XHIGH],
|
|
39
|
-
// 4.7 and later: adaptive only, and it can still be disabled.
|
|
40
|
-
['claude-opus-5', true, false, true, ALL, CAPPED],
|
|
41
|
-
['claude-sonnet-5', true, false, true, ALL, ALL],
|
|
42
|
-
['claude-opus-4-8', true, false, true, ALL, ALL],
|
|
43
|
-
['claude-opus-4-7', true, false, true, ALL, ALL],
|
|
44
|
-
// 4.6: both modes, manual deprecated but working — and no `xhigh`.
|
|
45
|
-
['claude-opus-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
|
|
46
|
-
['claude-sonnet-4-6', true, true, true, NO_XHIGH, NO_XHIGH],
|
|
47
|
-
// 4.5 and earlier: manual only. Opus 4.5 is the one that takes effort,
|
|
48
|
-
// and only the first three levels.
|
|
49
|
-
['claude-opus-4-5', false, true, true, BASE, BASE],
|
|
50
|
-
['claude-haiku-4-5', false, true, true, NONE, NONE],
|
|
51
|
-
['claude-sonnet-4-5', false, true, true, NONE, NONE],
|
|
52
|
-
['claude-opus-4-1', false, true, true, NONE, NONE],
|
|
53
|
-
];
|
|
54
|
-
describe('what each model accepts', () => {
|
|
55
|
-
for (const [model, adaptive, manual, canDisable, effort, effortWhenDisabled] of TABLE) {
|
|
56
|
-
it(`resolves ${model}`, () => {
|
|
57
|
-
expect(resolveThinkingCapability(model)).toEqual({
|
|
58
|
-
adaptive,
|
|
59
|
-
manual,
|
|
60
|
-
canDisable,
|
|
61
|
-
effort,
|
|
62
|
-
effortWhenDisabled,
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
it('tolerates a vendor prefix and a date suffix', () => {
|
|
67
|
-
expect(resolveThinkingCapability('anthropic/claude-sonnet-5')).toMatchObject({
|
|
68
|
-
adaptive: true,
|
|
69
|
-
manual: false,
|
|
70
|
-
});
|
|
71
|
-
expect(resolveThinkingCapability('claude-sonnet-4-5-20250929')).toMatchObject({
|
|
72
|
-
adaptive: false,
|
|
73
|
-
manual: true,
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
it('does not read a date suffix as the minor version', () => {
|
|
77
|
-
// The row this table did not have. Every dated id it listed carried a
|
|
78
|
-
// REAL minor (`4-5-20250929`), so the `<family>-<major>-<DATE>` shape —
|
|
79
|
-
// a dated id naming no minor — was never exercised, and the matcher
|
|
80
|
-
// parsed its date as minor 20250514. That compared as enormously newer
|
|
81
|
-
// than 4.1, so these two were classified adaptive-only and had their
|
|
82
|
-
// caller's thinking budget silently discarded.
|
|
83
|
-
for (const model of ['claude-sonnet-4-20250514', 'claude-opus-4-20250514']) {
|
|
84
|
-
expect(resolveThinkingCapability(model), model).toMatchObject({
|
|
85
|
-
adaptive: false,
|
|
86
|
-
manual: true,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
it('treats an unrecognised model as manual-only', () => {
|
|
91
|
-
// The pre-existing behaviour, and the safe answer for a name this
|
|
92
|
-
// table has not seen: an older model behind a gateway keeps working,
|
|
93
|
-
// and a newer one fails with the vendor's own clear 400 rather than
|
|
94
|
-
// with a request this driver quietly rewrote.
|
|
95
|
-
expect(resolveThinkingCapability('some-gateway/mystery-model')).toEqual({
|
|
96
|
-
adaptive: false,
|
|
97
|
-
manual: true,
|
|
98
|
-
canDisable: true,
|
|
99
|
-
effort: [],
|
|
100
|
-
effortWhenDisabled: [],
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe('turning an intent into a body this model accepts', () => {
|
|
105
|
-
const adaptiveOnly = resolveThinkingCapability('claude-sonnet-5');
|
|
106
|
-
const manualOnly = resolveThinkingCapability('claude-sonnet-4-5');
|
|
107
|
-
const alwaysOn = resolveThinkingCapability('claude-fable-5');
|
|
108
|
-
it('sends adaptive to an adaptive model', () => {
|
|
109
|
-
expect(resolveThinkingBody({ type: 'adaptive' }, adaptiveOnly)).toEqual({ type: 'adaptive' });
|
|
110
|
-
});
|
|
111
|
-
it('rewrites a manual intent to adaptive where manual is rejected', () => {
|
|
112
|
-
// The caller asked to think. This model's way of thinking is adaptive,
|
|
113
|
-
// and the budget has no meaning there, so it goes.
|
|
114
|
-
expect(resolveThinkingBody({ type: 'enabled', budgetTokens: 10_000 }, adaptiveOnly)).toEqual({
|
|
115
|
-
type: 'adaptive',
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
it('rewrites an adaptive intent to manual where adaptive is rejected', () => {
|
|
119
|
-
expect(resolveThinkingBody({ type: 'adaptive' }, manualOnly)).toEqual({ type: 'enabled' });
|
|
120
|
-
});
|
|
121
|
-
it('keeps the budget on a model that has budgets', () => {
|
|
122
|
-
expect(resolveThinkingBody({ type: 'enabled', budgetTokens: 10_000 }, manualOnly)).toEqual({
|
|
123
|
-
type: 'enabled',
|
|
124
|
-
budget_tokens: 10_000,
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
it('carries display through, which is the whole reason thinking text arrives', () => {
|
|
128
|
-
// It defaults to `omitted` on newer models, so a caller who wants to
|
|
129
|
-
// show reasoning and never serializes this gets empty blocks.
|
|
130
|
-
expect(resolveThinkingBody({ type: 'adaptive', display: 'summarized' }, adaptiveOnly)).toEqual({
|
|
131
|
-
type: 'adaptive',
|
|
132
|
-
display: 'summarized',
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
it('omits the field entirely when a model cannot be told to stop thinking', () => {
|
|
136
|
-
// Not an error: failing here teaches nothing the vendor 400 would not,
|
|
137
|
-
// and it breaks a caller whose config spans models. No field means the
|
|
138
|
-
// model's documented default, which is the closest honest reading.
|
|
139
|
-
expect(resolveThinkingBody({ type: 'disabled' }, alwaysOn)).toBeUndefined();
|
|
140
|
-
});
|
|
141
|
-
it('honours disable where it is accepted', () => {
|
|
142
|
-
expect(resolveThinkingBody({ type: 'disabled' }, adaptiveOnly)).toEqual({ type: 'disabled' });
|
|
143
|
-
});
|
|
144
|
-
it('sends nothing when the caller asked for nothing', () => {
|
|
145
|
-
expect(resolveThinkingBody(undefined, adaptiveOnly)).toBeUndefined();
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
describe('when effort rides along', () => {
|
|
149
|
-
const adaptiveOnly = resolveThinkingCapability('claude-sonnet-5');
|
|
150
|
-
const noEffort = resolveThinkingCapability('claude-sonnet-4-5');
|
|
151
|
-
it('passes effort to a model that takes it', () => {
|
|
152
|
-
expect(resolveEffort('high', { type: 'adaptive' }, adaptiveOnly)).toBe('high');
|
|
153
|
-
});
|
|
154
|
-
it('drops effort on a model that does not', () => {
|
|
155
|
-
expect(resolveEffort('high', { type: 'enabled' }, noEffort)).toBeUndefined();
|
|
156
|
-
});
|
|
157
|
-
it('keeps effort on the one manual model that accepts it', () => {
|
|
158
|
-
// Opus 4.5: effort shapes the answer, the budget sets thinking depth,
|
|
159
|
-
// and both are meant to be set. So effort is not adaptive-only and
|
|
160
|
-
// must not be gated on the mode.
|
|
161
|
-
const opus45 = resolveThinkingCapability('claude-opus-4-5');
|
|
162
|
-
expect(resolveEffort('high', { type: 'enabled', budget_tokens: 8000 }, opus45)).toBe('high');
|
|
163
|
-
});
|
|
164
|
-
it('caps effort with thinking off only where the wire caps it', () => {
|
|
165
|
-
// This rule used to be blanket: thinking off at `xhigh`/`max` was
|
|
166
|
-
// refused on every model that can disable thinking, reasoning that the
|
|
167
|
-
// pairing is incoherent anyway. Measured against the live API, that was
|
|
168
|
-
// too wide — only the Opus 5 family rejects it:
|
|
169
|
-
//
|
|
170
|
-
// claude-opus-5 + disabled + max -> 400 "not supported when thinking is disabled"
|
|
171
|
-
// claude-sonnet-5 + disabled + max -> accepted
|
|
172
|
-
// claude-opus-4-8 + disabled + max -> accepted
|
|
173
|
-
//
|
|
174
|
-
// So the blanket rule was dropping an effort the caller asked for and
|
|
175
|
-
// the wire would have honoured. Looking incoherent is not the same as
|
|
176
|
-
// being rejected, and only the wire decides which.
|
|
177
|
-
const opus5 = resolveThinkingCapability('claude-opus-5');
|
|
178
|
-
expect(resolveEffort('max', { type: 'disabled' }, opus5)).toBeUndefined();
|
|
179
|
-
expect(resolveEffort('xhigh', { type: 'disabled' }, opus5)).toBeUndefined();
|
|
180
|
-
expect(resolveEffort('high', { type: 'disabled' }, opus5)).toBe('high');
|
|
181
|
-
// …and uncapped with thinking on, on the same model.
|
|
182
|
-
expect(resolveEffort('max', { type: 'adaptive' }, opus5)).toBe('max');
|
|
183
|
-
// `adaptiveOnly` here is Sonnet 5, which the wire does not cap.
|
|
184
|
-
expect(resolveEffort('max', { type: 'disabled' }, adaptiveOnly)).toBe('max');
|
|
185
|
-
});
|
|
186
|
-
it('drops a level this model does not have', () => {
|
|
187
|
-
// The ceiling moved twice, so "does this model take effort?" was never
|
|
188
|
-
// a yes/no question. While it was modelled as one, `xhigh` on a 4.6 and
|
|
189
|
-
// `max` on a 4.5 went to the wire, and the vendor rejects an unknown
|
|
190
|
-
// level rather than clamping it.
|
|
191
|
-
const v46 = resolveThinkingCapability('claude-opus-4-6');
|
|
192
|
-
expect(resolveEffort('xhigh', { type: 'adaptive' }, v46)).toBeUndefined();
|
|
193
|
-
expect(resolveEffort('max', { type: 'adaptive' }, v46)).toBe('max');
|
|
194
|
-
const opus45 = resolveThinkingCapability('claude-opus-4-5');
|
|
195
|
-
expect(resolveEffort('max', { type: 'enabled' }, opus45)).toBeUndefined();
|
|
196
|
-
expect(resolveEffort('xhigh', { type: 'enabled' }, opus45)).toBeUndefined();
|
|
197
|
-
expect(resolveEffort('high', { type: 'enabled' }, opus45)).toBe('high');
|
|
198
|
-
});
|
|
199
|
-
it('takes every level on a current model', () => {
|
|
200
|
-
const opus5 = resolveThinkingCapability('claude-opus-5');
|
|
201
|
-
for (const level of ['low', 'medium', 'high', 'xhigh', 'max']) {
|
|
202
|
-
expect(resolveEffort(level, { type: 'adaptive' }, opus5), level).toBe(level);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
//# sourceMappingURL=thinking-capability.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,GAAG,IAAI,CAAA,CAAC,4BAA4B;AAChD,MAAM,KAAK,GAAuE;IACjF,sEAAsE;IACtE,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC;IAChD,CAAC,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GA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CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC/C,MAAM,KAAK,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAA;QACxD,KAAK,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,EAAE,CAAC;YACxE,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC7E,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-contract.live.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/thinking-contract.live.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,97 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,KAA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CAAC,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpE,MAAM,CACL,MAAM,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1F,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEhB,2EAA2E;QAC3E,MAAM,IAAI,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAA;QACtD,MAAM,cAAc,GAAG,mBAAmB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,CAAA;QACtE,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC9D,MAAM,CACL,MAAM,IAAI,CAAC,cAAc,EAAE,EAAE,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-request-body.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/thinking-request-body.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { AnthropicProvider } from '../client.js';
|
|
3
|
-
/**
|
|
4
|
-
* The resolver's own tests pass whether or not the client calls it. These
|
|
5
|
-
* drive the real `chatStream` and read the body that would have gone on the
|
|
6
|
-
* wire, because "declared, typed, exported, and never sent" is precisely the
|
|
7
|
-
* defect being fixed here — `display` had been on `ThinkingConfig` all along
|
|
8
|
-
* and the request builder dropped it.
|
|
9
|
-
*/
|
|
10
|
-
async function bodyFor(params) {
|
|
11
|
-
const seen = {};
|
|
12
|
-
const provider = new AnthropicProvider({ apiKey: 'test-key' });
|
|
13
|
-
provider.client = {
|
|
14
|
-
messages: {
|
|
15
|
-
create: vi.fn(async (body) => {
|
|
16
|
-
seen.body = body;
|
|
17
|
-
return (async function* () {
|
|
18
|
-
yield { type: 'message_start', message: { id: 'msg_1' } };
|
|
19
|
-
})();
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
for await (const _chunk of provider.chatStream({
|
|
24
|
-
model: 'claude-sonnet-5',
|
|
25
|
-
messages: [{ role: 'user', content: 'hi' }],
|
|
26
|
-
...params,
|
|
27
|
-
})) {
|
|
28
|
-
// drain
|
|
29
|
-
}
|
|
30
|
-
return seen.body ?? {};
|
|
31
|
-
}
|
|
32
|
-
describe('the thinking configuration that reaches the wire', () => {
|
|
33
|
-
it('sends adaptive to a model that only accepts adaptive', async () => {
|
|
34
|
-
const body = await bodyFor({ model: 'claude-sonnet-5', thinking: { type: 'adaptive' } });
|
|
35
|
-
expect(body.thinking).toEqual({ type: 'adaptive' });
|
|
36
|
-
});
|
|
37
|
-
it('does not send a manual budget to a model that rejects manual mode', async () => {
|
|
38
|
-
// This is the failure being fixed: the old builder passed `enabled`
|
|
39
|
-
// straight through, and the vendor answers that with a 400.
|
|
40
|
-
const body = await bodyFor({
|
|
41
|
-
model: 'claude-sonnet-5',
|
|
42
|
-
thinking: { type: 'enabled', budgetTokens: 10_000 },
|
|
43
|
-
});
|
|
44
|
-
expect(body.thinking).toEqual({ type: 'adaptive' });
|
|
45
|
-
expect(JSON.stringify(body)).not.toContain('budget_tokens');
|
|
46
|
-
});
|
|
47
|
-
it('still sends a manual budget to a manual model', async () => {
|
|
48
|
-
const body = await bodyFor({
|
|
49
|
-
model: 'claude-sonnet-4-5',
|
|
50
|
-
thinking: { type: 'enabled', budgetTokens: 10_000 },
|
|
51
|
-
});
|
|
52
|
-
expect(body.thinking).toEqual({ type: 'enabled', budget_tokens: 10_000 });
|
|
53
|
-
});
|
|
54
|
-
it('serializes display, without which the thinking text comes back empty', async () => {
|
|
55
|
-
const body = await bodyFor({
|
|
56
|
-
model: 'claude-sonnet-5',
|
|
57
|
-
thinking: { type: 'adaptive', display: 'summarized' },
|
|
58
|
-
});
|
|
59
|
-
expect(body.thinking).toEqual({ type: 'adaptive', display: 'summarized' });
|
|
60
|
-
});
|
|
61
|
-
it('sends effort beside thinking, not inside it', async () => {
|
|
62
|
-
const body = await bodyFor({
|
|
63
|
-
model: 'claude-sonnet-5',
|
|
64
|
-
thinking: { type: 'adaptive' },
|
|
65
|
-
effort: 'xhigh',
|
|
66
|
-
});
|
|
67
|
-
expect(body.output_config).toEqual({ effort: 'xhigh' });
|
|
68
|
-
expect(body.thinking).toEqual({ type: 'adaptive' });
|
|
69
|
-
});
|
|
70
|
-
it('sends effort even with no thinking configuration at all', async () => {
|
|
71
|
-
// Effort shapes the whole response, so it is not conditional on a
|
|
72
|
-
// thinking block being present.
|
|
73
|
-
const body = await bodyFor({ model: 'claude-sonnet-5', effort: 'low' });
|
|
74
|
-
expect(body.output_config).toEqual({ effort: 'low' });
|
|
75
|
-
});
|
|
76
|
-
it('drops effort on a model that does not accept it', async () => {
|
|
77
|
-
const body = await bodyFor({ model: 'claude-sonnet-4-5', effort: 'high' });
|
|
78
|
-
expect(body.output_config).toBeUndefined();
|
|
79
|
-
});
|
|
80
|
-
it('omits thinking entirely on a model that cannot be told to stop', async () => {
|
|
81
|
-
const body = await bodyFor({ model: 'claude-fable-5', thinking: { type: 'disabled' } });
|
|
82
|
-
expect(body.thinking).toBeUndefined();
|
|
83
|
-
});
|
|
84
|
-
it('sends no thinking field when the caller configured none', async () => {
|
|
85
|
-
const body = await bodyFor({ model: 'claude-sonnet-5' });
|
|
86
|
-
expect(body.thinking).toBeUndefined();
|
|
87
|
-
expect(body.output_config).toBeUndefined();
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
//# sourceMappingURL=thinking-request-body.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-request-body.test.js","sourceRoot":"","sources":["../../src/__tests__/thinking-request-body.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;;GAMG;AAEH,KAAK,UAAU,OAAO,CAAC,MAAqC;IAC3D,MAAM,IAAI,GAAuC,EAAE,CAAA;IACnD,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAC7D;IAAC,QAAqE,CAAC,MAAM,GAAG;QAChF,QAAQ,EAAE;YACT,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,IAA6B,EAAE,EAAE;gBACrD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;gBAChB,OAAO,CAAC,KAAK,SAAS,CAAC;oBACtB,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,CAAA;gBAC1D,CAAC,CAAC,EAAE,CAAA;YACL,CAAC,CAAC;SACF;KACD,CAAA;IACD,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAC;QAC9C,KAAK,EAAE,iBAAiB;QACxB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3C,GAAG,MAAM;KACe,CAAC,EAAE,CAAC;QAC5B,QAAQ;IACT,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,IAAI,EAAE,CAAA;AACvB,CAAC;AAED,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;IACjE,EAAE,CAAC,sDAAsD,EAA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