@namzu/openai 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,143 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 935b8f3: Documents and citations were designed in the SDK and never built in the drivers.
8
+
9
+ `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`.
10
+
11
+ 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.
12
+
13
+ - **`@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.
14
+ - **`@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".
15
+
16
+ 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.
17
+
18
+ - 935b8f3: Four drivers dumped tool-result payloads into the prompt, and one ignored the strict-schema hint.
19
+
20
+ **A tool result carrying an image was `JSON.stringify`d** on four drivers, so a screenshot reached the model as a wall of quoted base64. The model paid for every character, could read none of them, and — worse — saw a serialized object where a picture should be, with nothing saying anything had been withheld. The SDK's `toolResultToText` exists for exactly this and produces a named placeholder reporting the media type and the size. All four now use it: `@namzu/bedrock`, both dialects of `@namzu/http`, and `@namzu/lmstudio`.
21
+
22
+ **`enforceToolInputSchema` was ignored by `@namzu/openai`.** It names the tools whose model-facing schema should be enforced by constrained generation rather than merely suggested; both sibling drivers consumed it. A caller who had asked for a guaranteed-valid tool input silently got a best-effort one and learned about it from a repair attempt. This is the wire the flag maps onto most directly — it takes the flag on the function itself. The existing test asserting the tools went through untouched read as "the hint is kept out of the request" and actually pinned "the hint does nothing"; it now asserts the hint is consumed and still never appears verbatim.
23
+
24
+ **An extended-thinking request is refused by `@namzu/openai` rather than dropped.** The parameter was accepted and ignored, so a caller who asked for reasoning got an ordinary completion with an empty reasoning list — which reads as "the model did not reason" rather than "nobody asked it to". Turning thinking off stays a no-op, since that is the state the driver is already in.
25
+
26
+ Eleven previously empty test files now cover these drivers, including the capability claims themselves: every driver that declares no vision, documents or tools is pinned against drift in both directions, because the runtime warns or fails on those flags before a request is built, and a flag flipped ahead of its mapping is as wrong as a mapping written without the flag.
27
+
28
+ - 935b8f3: Tool arguments can be made valid by construction
29
+
30
+ namzu has a whole repair path for arguments that do not match a tool's schema — a repair hook, a bounded retry, a model-visible error. This wire format offers a mode where the endpoint constrains decoding to the schema, so invalid arguments cannot be emitted at all, which is strictly better than repairing them well.
31
+
32
+ `strictTools: true` turns it on. Off by default because it is a real trade: strict decoding requires every property to be required, so the driver rewrites each schema — objects close, every property joins `required`, and one that was optional widens to accept `null` so "leave it out" stays expressible. An optional argument therefore becomes one the model must pass explicitly as null, and that change to what the model is told belongs to the tool's author rather than the driver.
33
+
34
+ The rewrite is not separable from the flag: the endpoint rejects strict mode on a schema that has not been closed for it, so sending one without the other would turn a correctness feature into a 400.
35
+
36
+ - 935b8f3: A user message can carry a document
37
+
38
+ 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.
39
+
40
+ `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.
41
+
42
+ `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.
43
+
44
+ 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.
45
+
46
+ ### Patch Changes
47
+
48
+ - 935b8f3: Three driver defects found by auditing every provider against the same
49
+ contract checklist rather than one at a time.
50
+
51
+ **anthropic — a thinking block never reported its close.** `openReasoning`
52
+ was declared, read by the `content_block_stop` branch, and never added to:
53
+ three references in the whole file. The set was permanently empty, so the
54
+ close branch could not match and `reasoning: { done: true }` never reached
55
+ the consumer. A host that opens a thinking card on the first reasoning
56
+ delta left it spinning for the rest of the run. Stored blocks were
57
+ unaffected, so replay always looked correct — only the live stream was
58
+ broken, which is why it survived. This is the default driver.
59
+
60
+ **openai — every request to a reasoning-family model failed on turn one.**
61
+ `temperature` and `max_tokens` were sent unconditionally, and those models
62
+ reject both, requiring `max_completion_tokens`. The rejection is a 400,
63
+ which classifies as `invalid_request` and is not retryable, so the run
64
+ died immediately whenever a token cap was set — which the runtime always
65
+ does. Model family is now detected by id prefix, conservatively: an
66
+ unknown model keeps the standard parameters, because a false positive
67
+ silently strips `temperature` from a model that honours it while a false
68
+ negative produces a clear error naming the parameter.
69
+
70
+ **http — every streamed turn reported zero tokens.** The body builder never
71
+ requested usage on a streamed response, so a conforming endpoint sent none
72
+ and the (complete) parsing had nothing to parse. Cost read as free, and any
73
+ budget or compaction threshold keyed on usage never fired however large the
74
+ thread grew.
75
+
76
+ - 935b8f3: Widen the message model to content blocks: multimodal tool results, `is_error`,
77
+ and reasoning replay.
78
+
79
+ `ToolMessage.content` was `string` and `AssistantMessage` had no slot for
80
+ reasoning, so three separate things died at the provider boundary. Doing them
81
+ as one migration is deliberate — all three need the same widening, and every
82
+ stored transcript, checkpoint and `messages.json` is written in the narrow
83
+ shape, so the cost only grows.
84
+
85
+ **Tool results can carry non-text content.** `ToolResultContent` is
86
+ `string | ToolResultBlock[]`, where a block is text, image or document. String
87
+ stays first-class: the common case is unchanged and every existing tool and
88
+ driver compiles untouched. `@namzu/computer-use`'s `screenshot` returned
89
+ ~400 KB–2.7 MB of base64 **as text** — roughly 100k–670k tokens of characters
90
+ no model can decode — so computer use was effectively non-functional; it now
91
+ returns an image block with a short textual description. MCP `image` and
92
+ inline `resource` blocks are passed through instead of being filtered out.
93
+
94
+ **Failures are marked on the wire.** The executor computed `isError`, routed it
95
+ to the SSE bridge, the A2A bridge and the TUI, then dropped it at the provider
96
+ boundary — so the model's trained tool-failure recovery never fired. The
97
+ Anthropic driver now sends `is_error: true`, and the value survives the
98
+ executor's result tuple, which previously narrowed to `{toolCallId, output}`
99
+ before the message was built.
100
+
101
+ **Reasoning is representable and replayed verbatim.** `AssistantMessage.reasoning`
102
+ holds opaque `ReasoningBlock`s (thinking / redacted, with signature or encrypted
103
+ payload). The Anthropic driver used to rebuild every assistant turn as
104
+ `[text?, ...tool_use]` — precisely the pattern the verbatim-echo contract
105
+ prohibits when a `tool_result` follows — and now emits stored reasoning blocks
106
+ first, signature intact.
107
+
108
+ Drivers that cannot express non-text tool results (`@namzu/openai`,
109
+ `@namzu/ollama`) degrade through `toolResultToText`, which renders an explicit
110
+ `[image: …]` placeholder rather than dumping base64 or silently dropping it.
111
+
112
+ This is the outbound half. The Anthropic driver does not yet parse thinking
113
+ blocks out of the stream and `ChatCompletionParams` has no `thinking` field,
114
+ so `reasoning` is populated only when a caller supplies it.
115
+
116
+ - 935b8f3: A turn that asked for tools no longer ends because the provider said it
117
+ didn't.
118
+
119
+ The iteration loop ended the turn on `finishReason === 'stop'` **before**
120
+ looking at whether the model had asked for tools. Endpoints on the OpenAI
121
+ wire shape — gateways and local servers especially — routinely report `stop`
122
+ on the same response that carries a populated `tool_calls`, and three of
123
+ this repo's drivers passed that value straight through.
124
+
125
+ The damage was total and silent: every requested call skipped, an assistant
126
+ turn left carrying `tool_use` blocks nothing ever answered, and the run
127
+ settling as though it had finished the work it never started.
128
+
129
+ - **The runtime now treats tool calls as the fact and the finish reason as
130
+ the summary.** When they disagree, the calls win. This is the load-bearing
131
+ fix: it protects every driver, including ones this repo does not ship.
132
+ - **The three drivers that cast the reason raw now report it honestly** —
133
+ a stream that produced a tool call reports `tool_calls`, whatever the
134
+ endpoint called it. Defence in depth, and it makes the reported reason
135
+ true for anyone else reading it.
136
+
137
+ The existing suite could not catch this: the scripted mock reports
138
+ `tool_calls` whenever it emits one, which is what an honest provider does
139
+ and therefore never the case that breaks.
140
+
3
141
  ## 1.0.3
4
142
 
5
143
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=document-input.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-input.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/document-input.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,92 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { OPENAI_CAPABILITIES, toOpenAIMessages } from '../client.js';
3
+ /**
4
+ * This driver declared `supportsDocuments: true` and had no document
5
+ * branch: every attachment became an `image_url` part, so a PDF went up as
6
+ * `data:application/pdf;base64,...` inside an image. The capability was a
7
+ * claim nothing in the mapper could honour.
8
+ *
9
+ * Citations are the other half, and this wire has no way to return them.
10
+ * Sending the document anyway would answer the question and drop the
11
+ * checkability the caller asked for — silently, since an empty citation
12
+ * list reads as "the model cited nothing" rather than "nobody asked". So a
13
+ * document requesting citations is refused here rather than degraded.
14
+ */
15
+ const PDF = 'JVBERi0xLjQKJSVFT0Y=';
16
+ function partsFor(attachments, content = 'summarize this') {
17
+ const [message] = toOpenAIMessages([
18
+ { role: 'user', content, attachments },
19
+ ]);
20
+ return message?.content;
21
+ }
22
+ describe('a document attachment reaches the wire as a file', () => {
23
+ it('sends a file part, not an image part', async () => {
24
+ const parts = partsFor([{ type: 'document', data: PDF, mediaType: 'application/pdf' }]);
25
+ const file = parts.find((p) => p.type === 'file');
26
+ expect(file?.file).toMatchObject({ file_data: `data:application/pdf;base64,${PDF}` });
27
+ // The bug in one assertion: it used to be an image part.
28
+ expect(parts.some((p) => p.type === 'image_url')).toBe(false);
29
+ });
30
+ it('keeps the prose ahead of the file', () => {
31
+ const parts = partsFor([{ type: 'document', data: PDF, mediaType: 'application/pdf' }]);
32
+ expect(parts[0]).toEqual({ type: 'text', text: 'summarize this' });
33
+ });
34
+ it('carries the filename when one was given', () => {
35
+ const parts = partsFor([
36
+ { type: 'document', data: PDF, mediaType: 'application/pdf', name: 'lease.pdf' },
37
+ ]);
38
+ expect((parts.find((p) => p.type === 'file')?.file).filename).toBe('lease.pdf');
39
+ });
40
+ it('omits the filename when none was given', () => {
41
+ const parts = partsFor([{ type: 'document', data: PDF, mediaType: 'application/pdf' }]);
42
+ expect(parts.find((p) => p.type === 'file')?.file).not.toHaveProperty('filename');
43
+ });
44
+ it('still maps an image attachment as an image', () => {
45
+ const parts = partsFor([{ type: 'image', data: 'AAAA', mediaType: 'image/png' }]);
46
+ expect(parts.find((p) => p.type === 'image_url')?.image_url).toEqual({
47
+ url: 'data:image/png;base64,AAAA',
48
+ });
49
+ expect(parts.some((p) => p.type === 'file')).toBe(false);
50
+ });
51
+ it('carries both kinds in one message, in the order given', () => {
52
+ const parts = partsFor([
53
+ { type: 'document', data: PDF, mediaType: 'application/pdf' },
54
+ { type: 'image', data: 'AAAA', mediaType: 'image/png' },
55
+ ]);
56
+ expect(parts.map((p) => p.type)).toEqual(['text', 'file', 'image_url']);
57
+ });
58
+ it('leaves a plain text message as a string', () => {
59
+ const [message] = toOpenAIMessages([
60
+ { role: 'user', content: 'no attachments here' },
61
+ ]);
62
+ expect(message?.content).toBe('no attachments here');
63
+ });
64
+ });
65
+ describe('a document asking for citations is refused, not answered without them', () => {
66
+ it('throws rather than sending it', () => {
67
+ expect(() => partsFor([{ type: 'document', data: PDF, mediaType: 'application/pdf', citations: true }])).toThrow(/citations/i);
68
+ });
69
+ it('names the document, so the caller knows which one to change', () => {
70
+ expect(() => partsFor([
71
+ {
72
+ type: 'document',
73
+ data: PDF,
74
+ mediaType: 'application/pdf',
75
+ name: 'lease.pdf',
76
+ citations: true,
77
+ },
78
+ ])).toThrow(/lease\.pdf/);
79
+ });
80
+ it('says what to do instead', () => {
81
+ expect(() => partsFor([{ type: 'document', data: PDF, mediaType: 'application/pdf', citations: true }])).toThrow(/Drop `citations`/);
82
+ });
83
+ it('accepts the same document without the request', () => {
84
+ expect(() => partsFor([{ type: 'document', data: PDF, mediaType: 'application/pdf', citations: false }])).not.toThrow();
85
+ });
86
+ });
87
+ describe('the capability claim matches the mapper', () => {
88
+ it('declares document support, which is now true', () => {
89
+ expect(OPENAI_CAPABILITIES.supportsDocuments).toBe(true);
90
+ });
91
+ });
92
+ //# sourceMappingURL=document-input.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-input.test.js","sourceRoot":"","sources":["../../src/__tests__/document-input.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEpE;;;;;;;;;;;GAWG;AAEH,MAAM,GAAG,GAAG,sBAAsB,CAAA;AAElC,SAAS,QAAQ,CAAC,WAAsB,EAAE,OAAO,GAAG,gBAAgB;IACnE,MAAM,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC;QAClC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE;KACS,CAAC,CAAA;IACjD,OAAO,OAAO,EAAE,OAA+C,CAAA;AAChE,CAAC;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;aACf;SACD,CAAC,CACF,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QAClC,MAAM,CAAC,GAAG,EAAE,CACX,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAC1F,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,GAAG,EAAE,CACX,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAC3F,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IAChB,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACxD,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -40,6 +40,7 @@ describe('@namzu/openai', () => {
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', () => {
@@ -83,8 +84,14 @@ describe('@namzu/openai', () => {
83
84
  role: 'user',
84
85
  content: [
85
86
  { type: 'text', text: 'what is in this image?' },
86
- { type: 'image_url', image_url: { url: 'data:image/png;base64,aGVsbG8=' } },
87
- { type: 'image_url', image_url: { url: 'data:image/jpeg;base64,d29ybGQ=' } },
87
+ {
88
+ type: 'image_url',
89
+ image_url: { url: 'data:image/png;base64,aGVsbG8=' },
90
+ },
91
+ {
92
+ type: 'image_url',
93
+ image_url: { url: 'data:image/jpeg;base64,d29ybGQ=' },
94
+ },
88
95
  ],
89
96
  });
90
97
  });
@@ -99,7 +106,12 @@ describe('@namzu/openai', () => {
99
106
  const [mapped] = toOpenAIMessages(messages);
100
107
  expect(mapped).toEqual({
101
108
  role: 'user',
102
- content: [{ type: 'image_url', image_url: { url: 'data:image/webp;base64,aGVsbG8=' } }],
109
+ content: [
110
+ {
111
+ type: 'image_url',
112
+ image_url: { url: 'data:image/webp;base64,aGVsbG8=' },
113
+ },
114
+ ],
103
115
  });
104
116
  });
105
117
  it('keeps plain text-only user messages in string form (no content parts)', () => {
@@ -107,5 +119,64 @@ describe('@namzu/openai', () => {
107
119
  expect(toOpenAIMessages(messages)).toEqual([{ role: 'user', content: 'hello' }]);
108
120
  });
109
121
  });
122
+ it('keeps the Namzu enforcement hint out of the OpenAI SDK request', async () => {
123
+ const provider = new OpenAIProvider({ apiKey: 'test-key' });
124
+ let requestBody;
125
+ provider.client = {
126
+ chat: {
127
+ completions: {
128
+ create: async (body) => {
129
+ requestBody = body;
130
+ return (async function* () {
131
+ yield {
132
+ id: 'msg_done',
133
+ choices: [{ index: 0, delta: {}, finish_reason: 'stop' }],
134
+ usage: {
135
+ prompt_tokens: 1,
136
+ completion_tokens: 0,
137
+ total_tokens: 1,
138
+ },
139
+ };
140
+ })();
141
+ },
142
+ },
143
+ },
144
+ };
145
+ const tools = [
146
+ {
147
+ type: 'function',
148
+ function: {
149
+ name: 'edit',
150
+ description: 'Edit',
151
+ parameters: { type: 'object' },
152
+ },
153
+ },
154
+ ];
155
+ for await (const _chunk of provider.chatStream({
156
+ model: 'gpt-5',
157
+ messages: [{ role: 'user', content: 'edit' }],
158
+ tools,
159
+ enforceToolInputSchema: ['edit'],
160
+ })) {
161
+ // Drain the test stream.
162
+ }
163
+ // The hint is not a wire field, so it must never appear verbatim —
164
+ // that is what "keeps it out of the request" means.
165
+ expect(requestBody).not.toHaveProperty('enforceToolInputSchema');
166
+ // It is consumed, not ignored. This used to assert the tools went
167
+ // through untouched, which read as "the hint is kept out" and
168
+ // actually pinned "the hint does nothing".
169
+ expect(requestBody?.tools).toEqual([
170
+ {
171
+ type: 'function',
172
+ function: {
173
+ name: 'edit',
174
+ description: 'Edit',
175
+ parameters: { type: 'object' },
176
+ strict: true,
177
+ },
178
+ },
179
+ ]);
180
+ });
110
181
  });
111
182
  //# sourceMappingURL=openai.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.test.js","sourceRoot":"","sources":["../../src/__tests__/openai.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,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjF,6EAA6E;AAC7E,wEAAwE;AACxE,8CAA8C;AAC9C,UAAU,CAAC,GAAG,EAAE;IACf,IAAI,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5C,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,CAAC;AACF,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAChD,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC1D,cAAc,EAAE,CAAA;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AC1B,CAAC;QAED,mEAAmE;QACnE,oDAAoD;QACpD,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAA;QAChE,kEAAkE;QAClE,8DAA8D;QAC9D,2CAA2C;QAC3C,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC;YAClC;gBACC,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE;oBACT,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,MAAM;oBACnB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC9B,MAAM,EAAE,IAAI;iBACZ;aACD;SACD,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reasoning-params.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoning-params.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/reasoning-params.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { OPENAI_CAPABILITIES, assertThinkingSupported } from '../client.js';
3
+ /**
4
+ * This driver does not implement extended thinking, and used to accept the
5
+ * request anyway.
6
+ *
7
+ * So a caller who asked for reasoning got an ordinary completion: no
8
+ * thinking, no reasoning blocks, and no error. The empty reasoning list
9
+ * that came back reads as "the model did not reason" rather than "nobody
10
+ * asked it to" — which is the failure mode, not the missing feature. Same
11
+ * call as the citations one in this driver: refuse what cannot be
12
+ * delivered rather than deliver something else quietly.
13
+ */
14
+ describe('an extended-thinking request is refused, not dropped', () => {
15
+ it('throws when thinking is asked for', () => {
16
+ expect(() => assertThinkingSupported({ thinking: { type: 'enabled' } })).toThrow(/extended thinking/i);
17
+ });
18
+ it('says what to do instead', () => {
19
+ expect(() => assertThinkingSupported({ thinking: { type: 'enabled' } })).toThrow(/Drop `thinking`/);
20
+ });
21
+ it('explains why silence would be worse than an error', () => {
22
+ // The message has to name the symptom the caller would otherwise
23
+ // see, or they will read the empty list as an answer.
24
+ expect(() => assertThinkingSupported({ thinking: { type: 'enabled' } })).toThrow(/empty reasoning list/);
25
+ });
26
+ });
27
+ describe('asking for it to be off is honoured as a no-op', () => {
28
+ it('accepts an explicit disable', () => {
29
+ // Off is the state this driver is already in, so refusing here would
30
+ // reject a request it is in fact satisfying.
31
+ expect(() => assertThinkingSupported({ thinking: { type: 'disabled' } })).not.toThrow();
32
+ });
33
+ it('accepts a call that says nothing about thinking', () => {
34
+ expect(() => assertThinkingSupported({})).not.toThrow();
35
+ });
36
+ });
37
+ describe('the declared capabilities stay honest', () => {
38
+ it('claims the tools and streaming it does implement', () => {
39
+ expect(OPENAI_CAPABILITIES.supportsTools).toBe(true);
40
+ expect(OPENAI_CAPABILITIES.supportsStreaming).toBe(true);
41
+ expect(OPENAI_CAPABILITIES.supportsFunctionCalling).toBe(true);
42
+ });
43
+ it('claims the vision and documents it now maps', () => {
44
+ expect(OPENAI_CAPABILITIES.supportsVision).toBe(true);
45
+ expect(OPENAI_CAPABILITIES.supportsDocuments).toBe(true);
46
+ });
47
+ it('answers every flag the negotiation reads', () => {
48
+ // An absent flag defaults to permissive, so a missing one is not a
49
+ // neutral omission — it is a claim.
50
+ for (const flag of [
51
+ 'supportsTools',
52
+ 'supportsStreaming',
53
+ 'supportsFunctionCalling',
54
+ 'supportsVision',
55
+ 'supportsDocuments',
56
+ ]) {
57
+ expect(typeof OPENAI_CAPABILITIES[flag]).toBe('boolean');
58
+ }
59
+ });
60
+ });
61
+ //# sourceMappingURL=reasoning-params.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoning-params.test.js","sourceRoot":"","sources":["../../src/__tests__/reasoning-params.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,mBAAmB,EAAE,uB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AAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IACxD,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IACtD,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC3D,MAAM,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACpD,MAAM,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxD,MAAM,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,MAAM,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACnD,mEAAmE;QACnE,oCAAoC;QACpC,KAAK,MAAM,IAAI,IAAI;YAClB,eAAe;YACf,mBAAmB;YACnB,yBAAyB;YACzB,gBAAgB;YAChB,mBAAmB;SACV,EAAE,CAAC;YACZ,MAAM,CAAC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACzD,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=strict-schema.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict-schema.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/strict-schema.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,85 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { toOpenAITools } from '../client.js';
3
+ /**
4
+ * `enforceToolInputSchema` names the tools whose model-facing schema should
5
+ * be enforced by constrained generation rather than merely suggested.
6
+ *
7
+ * Both sibling drivers consumed it. This one dropped it on the floor, so a
8
+ * caller who had asked for a guaranteed-valid tool input silently got a
9
+ * best-effort one, and learned about it from a repair attempt rather than
10
+ * from an error. This is the wire the flag maps onto most directly — it
11
+ * takes the flag on the function itself.
12
+ */
13
+ const TOOLS = [
14
+ {
15
+ type: 'function',
16
+ function: {
17
+ name: 'read',
18
+ description: 'read a file',
19
+ parameters: { type: 'object', properties: { path: { type: 'string' } } },
20
+ },
21
+ },
22
+ {
23
+ type: 'function',
24
+ function: { name: 'write', description: 'write a file', parameters: { type: 'object' } },
25
+ },
26
+ ];
27
+ function toolsFor(enforceToolInputSchema) {
28
+ return toOpenAITools({
29
+ model: 'm',
30
+ messages: [],
31
+ tools: TOOLS,
32
+ ...(enforceToolInputSchema ? { enforceToolInputSchema } : {}),
33
+ });
34
+ }
35
+ describe('the schema of a named tool is enforced, not suggested', () => {
36
+ it('marks the tool the caller named', () => {
37
+ const tools = toolsFor(['read']);
38
+ expect(tools?.find((t) => t.function.name === 'read')?.function.strict).toBe(true);
39
+ });
40
+ it('leaves every other tool alone', () => {
41
+ const tools = toolsFor(['read']);
42
+ // Enforcement is not free and not always possible; marking a tool
43
+ // nobody asked about changes behaviour the caller did not ask to
44
+ // change.
45
+ expect(tools?.find((t) => t.function.name === 'write')?.function).not.toHaveProperty('strict');
46
+ });
47
+ it('marks several when several were named', () => {
48
+ const tools = toolsFor(['read', 'write']);
49
+ expect(tools?.every((t) => t.function.strict === true)).toBe(true);
50
+ });
51
+ it('marks nothing when the hint is absent', () => {
52
+ expect(toolsFor()?.some((t) => 'strict' in t.function)).toBe(false);
53
+ });
54
+ it('marks nothing when the hint names no tool', () => {
55
+ expect(toolsFor([])?.some((t) => 'strict' in t.function)).toBe(false);
56
+ });
57
+ it('ignores a name that matches no registered tool', () => {
58
+ const tools = toolsFor(['nonexistent']);
59
+ expect(tools).toHaveLength(2);
60
+ expect(tools?.some((t) => 'strict' in t.function)).toBe(false);
61
+ });
62
+ });
63
+ describe('the rest of the tool schema is untouched', () => {
64
+ it('keeps the name, description and parameters', () => {
65
+ const read = toolsFor(['read'])?.find((t) => t.function.name === 'read');
66
+ expect(read?.function.description).toBe('read a file');
67
+ expect(read?.function.parameters).toMatchObject({
68
+ type: 'object',
69
+ properties: { path: { type: 'string' } },
70
+ });
71
+ });
72
+ it('substitutes an empty object for missing parameters', () => {
73
+ const tools = toOpenAITools({
74
+ model: 'm',
75
+ messages: [],
76
+ tools: [{ type: 'function', function: { name: 'ping' } }],
77
+ });
78
+ expect(tools?.[0]?.function.parameters).toEqual({});
79
+ });
80
+ it('sends no tools at all when there are none', () => {
81
+ expect(toOpenAITools({ model: 'm', messages: [] })).toBeUndefined();
82
+ expect(toOpenAITools({ model: 'm', messages: [], tools: [] })).toBeUndefined();
83
+ });
84
+ });
85
+ //# sourceMappingURL=strict-schema.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict-schema.test.js","sourceRoot":"","sources":["../../src/__tests__/strict-schema.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C;;;;;;;;;GASG;AAEH,MAAM,KAAK,GAAG;IACb;QACC,IAAI,EAAE,UAAmB;QACzB,QAAQ,EAAE;YACT,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,aAAa;YAC1B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;SACxE;KACD;IACD;QACC,IAAI,EAAE,UAAmB;QACzB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,E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import type { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
2
+ import type { ChatCompletionMessageParam, ChatCompletionTool } from 'openai/resources/chat/completions';
3
3
  import type { OpenAIConfig } from './types.js';
4
4
  /**
5
5
  * Full capability set — this driver maps tools (`toOpenAITools`), streams
@@ -7,7 +7,34 @@ import type { OpenAIConfig } from './types.js';
7
7
  * content parts with base64 data URIs (`toOpenAIMessages`).
8
8
  */
9
9
  export declare const OPENAI_CAPABILITIES: ProviderCapabilities;
10
+ /**
11
+ * Refuse an extended-thinking request this driver does not implement.
12
+ *
13
+ * The parameter was accepted and dropped, so a caller who had asked for
14
+ * reasoning got an ordinary completion: no thinking, no reasoning blocks,
15
+ * no error — and the empty reasoning array reads as "the model did not
16
+ * reason" rather than "nobody asked it to". Turning it OFF is honoured as
17
+ * a no-op, because that is the state the driver is already in.
18
+ */
19
+ export declare function assertThinkingSupported(params: {
20
+ thinking?: {
21
+ type: 'enabled' | 'disabled';
22
+ };
23
+ }): void;
10
24
  export declare function toOpenAIMessages(messages: ChatCompletionParams['messages']): ChatCompletionMessageParam[];
25
+ /**
26
+ * Tool schemas, with constrained generation where the caller asked for it.
27
+ *
28
+ * `enforceToolInputSchema` names the tools whose schema should be enforced
29
+ * rather than suggested. Both sibling drivers consumed it; this one dropped
30
+ * it on the floor, so a caller who had asked for a guaranteed-valid tool
31
+ * input got a best-effort one — and found out from a repair attempt rather
32
+ * than from an error.
33
+ *
34
+ * This wire is the one the flag maps onto most directly: it takes `strict`
35
+ * on the function itself.
36
+ */
37
+ export declare function toOpenAITools(params: ChatCompletionParams): ChatCompletionTool[] | undefined;
11
38
  export declare class OpenAIProvider implements LLMProvider {
12
39
  readonly id = "openai";
13
40
  readonly name = "OpenAI";
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EAEpB,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,WAAW,EA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