@namzu/openai 1.0.2 → 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 +168 -0
- package/dist/__tests__/document-input.test.d.ts +2 -0
- package/dist/__tests__/document-input.test.d.ts.map +1 -0
- package/dist/__tests__/document-input.test.js +92 -0
- package/dist/__tests__/document-input.test.js.map +1 -0
- package/dist/__tests__/error-taxonomy.test.d.ts +14 -0
- package/dist/__tests__/error-taxonomy.test.d.ts.map +1 -0
- package/dist/__tests__/error-taxonomy.test.js +203 -0
- package/dist/__tests__/error-taxonomy.test.js.map +1 -0
- package/dist/__tests__/openai.test.js +74 -3
- package/dist/__tests__/openai.test.js.map +1 -1
- package/dist/__tests__/reasoning-params.test.d.ts +2 -0
- package/dist/__tests__/reasoning-params.test.d.ts.map +1 -0
- package/dist/__tests__/reasoning-params.test.js +61 -0
- package/dist/__tests__/reasoning-params.test.js.map +1 -0
- package/dist/__tests__/strict-schema.test.d.ts +2 -0
- package/dist/__tests__/strict-schema.test.d.ts.map +1 -0
- package/dist/__tests__/strict-schema.test.js +85 -0
- package/dist/__tests__/strict-schema.test.js.map +1 -0
- package/dist/client.d.ts +28 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +162 -67
- package/dist/client.js.map +1 -1
- package/dist/strict-schema.d.ts +2 -0
- package/dist/strict-schema.d.ts.map +1 -0
- package/dist/strict-schema.js +2 -0
- package/dist/strict-schema.js.map +1 -0
- package/package.json +4 -4
- package/src/__tests__/document-input.test.ts +125 -0
- package/src/__tests__/error-taxonomy.test.ts +234 -0
- package/src/__tests__/openai.test.ts +77 -3
- package/src/__tests__/reasoning-params.test.ts +76 -0
- package/src/__tests__/strict-schema.test.ts +110 -0
- package/src/client.ts +169 -67
- package/src/strict-schema.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,173 @@
|
|
|
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
|
+
|
|
141
|
+
## 1.0.3
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- 3fd2524: Normalize request-start and mid-stream failures across all seven provider
|
|
146
|
+
drivers with the new public `ProviderRequestError` taxonomy. Errors expose
|
|
147
|
+
`kind` (`throttle`, `network`, `auth`, `context_overflow`, `bad_request`, or
|
|
148
|
+
`server`), `providerId`, and optional `status` / `retryAfterMs`, with
|
|
149
|
+
`isProviderRequestError` available for structural narrowing across package
|
|
150
|
+
copies.
|
|
151
|
+
|
|
152
|
+
Provider error messages and metadata deliberately omit vendor response bodies,
|
|
153
|
+
URLs, messages, and causes because upstream errors can echo credentials. HTTP
|
|
154
|
+
dialect-mismatch diagnostics now keep only the endpoint origin and status.
|
|
155
|
+
Caller-owned aborts remain unchanged instead of being reclassified.
|
|
156
|
+
|
|
157
|
+
The runtime preserves the classified error through streaming and publishes its
|
|
158
|
+
safe metadata as `Run.lastProviderError` and
|
|
159
|
+
`run_failed.providerError`. Bedrock stream-exception events and provider
|
|
160
|
+
iterator/SSE failures no longer appear as clean end-of-stream.
|
|
161
|
+
|
|
162
|
+
`retryAfterMs` is metadata only; this change does not add retries or alter vendor
|
|
163
|
+
SDK retry settings. Provider packages now require `@namzu/sdk >=1.3.0`, the
|
|
164
|
+
first SDK release containing these runtime helpers and types.
|
|
165
|
+
|
|
166
|
+
Ollama now maps `done_reason: "length"` truthfully so runtime continuation can
|
|
167
|
+
run. LM Studio treats content-free `contextLengthReached` as context overflow,
|
|
168
|
+
while preserving `"length"` after partial content, and creates its WebSocket
|
|
169
|
+
client lazily on first use.
|
|
170
|
+
|
|
3
171
|
## 1.0.2
|
|
4
172
|
|
|
5
173
|
### Patch Changes
|
|
@@ -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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I;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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider error taxonomy — OpenAI driver.
|
|
3
|
+
*
|
|
4
|
+
* Like the Anthropic driver, this one lets the vendor SDK's own error type
|
|
5
|
+
* escape verbatim (`RateLimitError`, `BadRequestError`, …). Those carry a
|
|
6
|
+
* status but are vendor classes, so no caller can classify them without
|
|
7
|
+
* importing `openai` — and their `message` interpolates the response body.
|
|
8
|
+
*
|
|
9
|
+
* Transport seam: `OpenAIConfig.baseURL` — a loopback server answering
|
|
10
|
+
* with a scripted status/headers/body, so the REAL vendor client runs
|
|
11
|
+
* (including its internal retries, which this group must not disturb).
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=error-taxonomy.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-taxonomy.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/error-taxonomy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider error taxonomy — OpenAI driver.
|
|
3
|
+
*
|
|
4
|
+
* Like the Anthropic driver, this one lets the vendor SDK's own error type
|
|
5
|
+
* escape verbatim (`RateLimitError`, `BadRequestError`, …). Those carry a
|
|
6
|
+
* status but are vendor classes, so no caller can classify them without
|
|
7
|
+
* importing `openai` — and their `message` interpolates the response body.
|
|
8
|
+
*
|
|
9
|
+
* Transport seam: `OpenAIConfig.baseURL` — a loopback server answering
|
|
10
|
+
* with a scripted status/headers/body, so the REAL vendor client runs
|
|
11
|
+
* (including its internal retries, which this group must not disturb).
|
|
12
|
+
*/
|
|
13
|
+
import { createServer } from 'node:http';
|
|
14
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
15
|
+
import { OpenAIProvider } from '../client.js';
|
|
16
|
+
/** Obviously fake, non-functional token — present only as a leak probe. */
|
|
17
|
+
const FAKE_CREDENTIAL = 'sk-ant-FAKE-DO-NOT-USE-0000';
|
|
18
|
+
let server;
|
|
19
|
+
afterEach(async () => {
|
|
20
|
+
if (server) {
|
|
21
|
+
await new Promise((resolve) => server?.close(() => resolve()));
|
|
22
|
+
server = undefined;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
async function startEndpoint(reply) {
|
|
26
|
+
server = createServer((_req, res) => {
|
|
27
|
+
res.writeHead(reply.status, {
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
...(reply.headers ?? {}),
|
|
30
|
+
});
|
|
31
|
+
res.end(reply.body);
|
|
32
|
+
});
|
|
33
|
+
await new Promise((resolve) => server?.listen(0, '127.0.0.1', () => resolve()));
|
|
34
|
+
const { port } = server.address();
|
|
35
|
+
return `http://127.0.0.1:${port}/v1`;
|
|
36
|
+
}
|
|
37
|
+
async function captureChatStreamError(reply) {
|
|
38
|
+
const baseURL = await startEndpoint(reply);
|
|
39
|
+
// maxRetries is deliberately NOT set: this group classifies errors and
|
|
40
|
+
// must leave the vendor SDK's own retry behaviour exactly as it is.
|
|
41
|
+
const provider = new OpenAIProvider({
|
|
42
|
+
apiKey: 'test-key',
|
|
43
|
+
model: 'gpt-4o-mini',
|
|
44
|
+
baseURL,
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
for await (const _chunk of provider.chatStream({
|
|
48
|
+
model: 'gpt-4o-mini',
|
|
49
|
+
messages: [{ role: 'user', content: 'hi' }],
|
|
50
|
+
})) {
|
|
51
|
+
// drain
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
return err;
|
|
56
|
+
}
|
|
57
|
+
throw new Error('expected chatStream to throw');
|
|
58
|
+
}
|
|
59
|
+
async function captureProviderError(provider, signal) {
|
|
60
|
+
try {
|
|
61
|
+
for await (const _chunk of provider.chatStream({
|
|
62
|
+
model: 'gpt-4o-mini',
|
|
63
|
+
messages: [{ role: 'user', content: 'hi' }],
|
|
64
|
+
signal,
|
|
65
|
+
})) {
|
|
66
|
+
// drain
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return err;
|
|
71
|
+
}
|
|
72
|
+
throw new Error('expected chatStream to throw');
|
|
73
|
+
}
|
|
74
|
+
describe('@namzu/openai — provider error taxonomy', () => {
|
|
75
|
+
it('(a) 429 with `retry-after: 2` throws a throttle-classified error carrying retryAfterMs', async () => {
|
|
76
|
+
const err = await captureChatStreamError({
|
|
77
|
+
status: 429,
|
|
78
|
+
headers: { 'retry-after': '2' },
|
|
79
|
+
body: JSON.stringify({
|
|
80
|
+
error: { message: 'Rate limit reached', type: 'rate_limit_error' },
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
expect(err).toMatchObject({
|
|
84
|
+
name: 'ProviderRequestError',
|
|
85
|
+
kind: 'throttle',
|
|
86
|
+
status: 429,
|
|
87
|
+
retryAfterMs: 2000,
|
|
88
|
+
providerId: 'openai',
|
|
89
|
+
});
|
|
90
|
+
}, 60_000);
|
|
91
|
+
it("(c) 400 whose body reports a context-length overflow classifies as 'context_overflow'", async () => {
|
|
92
|
+
const err = await captureChatStreamError({
|
|
93
|
+
status: 400,
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
error: {
|
|
96
|
+
message: "This model's maximum context length is 128000 tokens. However, your messages resulted in 190210 tokens.",
|
|
97
|
+
type: 'invalid_request_error',
|
|
98
|
+
code: 'context_length_exceeded',
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
expect(err).toMatchObject({
|
|
103
|
+
name: 'ProviderRequestError',
|
|
104
|
+
kind: 'context_overflow',
|
|
105
|
+
status: 400,
|
|
106
|
+
providerId: 'openai',
|
|
107
|
+
});
|
|
108
|
+
}, 30_000);
|
|
109
|
+
it("(c) 400 that is not an overflow classifies as 'bad_request'", async () => {
|
|
110
|
+
const err = await captureChatStreamError({
|
|
111
|
+
status: 400,
|
|
112
|
+
body: JSON.stringify({
|
|
113
|
+
error: {
|
|
114
|
+
message: "Unrecognized request argument: 'temperture'",
|
|
115
|
+
type: 'invalid_request_error',
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
});
|
|
119
|
+
expect(err).toMatchObject({
|
|
120
|
+
name: 'ProviderRequestError',
|
|
121
|
+
kind: 'bad_request',
|
|
122
|
+
status: 400,
|
|
123
|
+
providerId: 'openai',
|
|
124
|
+
});
|
|
125
|
+
}, 30_000);
|
|
126
|
+
it("(auth) 401 classifies as 'auth'", async () => {
|
|
127
|
+
const err = await captureChatStreamError({
|
|
128
|
+
status: 401,
|
|
129
|
+
body: JSON.stringify({
|
|
130
|
+
error: {
|
|
131
|
+
message: 'Incorrect API key provided',
|
|
132
|
+
type: 'invalid_request_error',
|
|
133
|
+
},
|
|
134
|
+
}),
|
|
135
|
+
});
|
|
136
|
+
expect(err).toMatchObject({
|
|
137
|
+
name: 'ProviderRequestError',
|
|
138
|
+
kind: 'auth',
|
|
139
|
+
status: 401,
|
|
140
|
+
providerId: 'openai',
|
|
141
|
+
});
|
|
142
|
+
}, 30_000);
|
|
143
|
+
it('(d) SECURITY: a credential echoed back in a 401 body never reaches the thrown message', async () => {
|
|
144
|
+
const err = await captureChatStreamError({
|
|
145
|
+
status: 401,
|
|
146
|
+
body: JSON.stringify({
|
|
147
|
+
error: { message: `Incorrect API key provided: ${FAKE_CREDENTIAL}` },
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
expect(err.message).not.toContain(FAKE_CREDENTIAL);
|
|
151
|
+
expect(JSON.stringify(err)).not.toContain(FAKE_CREDENTIAL);
|
|
152
|
+
expect('cause' in err).toBe(false);
|
|
153
|
+
}, 30_000);
|
|
154
|
+
it('classifies and sanitizes an SDK failure thrown after streaming began', async () => {
|
|
155
|
+
const vendor = Object.assign(new Error(`overloaded_error ${FAKE_CREDENTIAL}`), {
|
|
156
|
+
name: 'APIError',
|
|
157
|
+
});
|
|
158
|
+
const provider = new OpenAIProvider({
|
|
159
|
+
apiKey: 'test-key',
|
|
160
|
+
model: 'gpt-4o-mini',
|
|
161
|
+
});
|
|
162
|
+
const stream = {
|
|
163
|
+
async *[Symbol.asyncIterator]() {
|
|
164
|
+
yield {
|
|
165
|
+
id: 'chatcmpl-1',
|
|
166
|
+
choices: [{ delta: { content: 'partial' }, finish_reason: null }],
|
|
167
|
+
usage: null,
|
|
168
|
+
};
|
|
169
|
+
throw vendor;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
provider.client = {
|
|
173
|
+
chat: { completions: { create: async () => stream } },
|
|
174
|
+
};
|
|
175
|
+
const err = await captureProviderError(provider);
|
|
176
|
+
expect(err).toMatchObject({
|
|
177
|
+
name: 'ProviderRequestError',
|
|
178
|
+
kind: 'server',
|
|
179
|
+
providerId: 'openai',
|
|
180
|
+
});
|
|
181
|
+
expect(err.message).not.toContain(FAKE_CREDENTIAL);
|
|
182
|
+
expect('cause' in err).toBe(false);
|
|
183
|
+
});
|
|
184
|
+
it('preserves the caller abort reason when the SDK replaces the error object', async () => {
|
|
185
|
+
const controller = new AbortController();
|
|
186
|
+
const reason = new Error('user stopped');
|
|
187
|
+
const sdkAbort = Object.assign(new Error('request aborted'), {
|
|
188
|
+
name: 'APIUserAbortError',
|
|
189
|
+
});
|
|
190
|
+
controller.abort(reason);
|
|
191
|
+
const provider = new OpenAIProvider({
|
|
192
|
+
apiKey: 'test-key',
|
|
193
|
+
model: 'gpt-4o-mini',
|
|
194
|
+
});
|
|
195
|
+
provider.client = {
|
|
196
|
+
chat: { completions: { create: async () => Promise.reject(sdkAbort) } },
|
|
197
|
+
};
|
|
198
|
+
const err = await captureProviderError(provider, controller.signal);
|
|
199
|
+
expect(sdkAbort).not.toBe(reason);
|
|
200
|
+
expect(err).toBe(reason);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
//# sourceMappingURL=error-taxonomy.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-taxonomy.test.js","sourceRoot":"","sources":["../../src/__tests__/error-taxonomy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAe,YAAY,EAAE,MAAM,WAAW,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,2EAA2E;AAC3E,MAAM,eAAe,GAAG,6BAA6B,CAAA;AAQrD,IAAI,MAA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,QAA2C,CAAC,MAAM,GAAG;YACtD,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE;SACvE,CAAA;QAED,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QAEnE,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACjC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzB,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
|
-
{
|
|
87
|
-
|
|
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: [
|
|
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,uCAA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