@yaks/openai 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +389 -2
- package/_dist/batches.d.ts +77 -0
- package/_dist/batches.d.ts.map +1 -0
- package/_dist/credential.d.ts +13 -0
- package/_dist/credential.d.ts.map +1 -0
- package/_dist/images.d.ts +15 -0
- package/_dist/images.d.ts.map +1 -0
- package/_dist/list.d.ts +8 -0
- package/_dist/list.d.ts.map +1 -0
- package/_dist/media.d.ts +11 -0
- package/_dist/media.d.ts.map +1 -0
- package/_dist/mod.d.ts +30 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/project-keys.d.ts +4 -0
- package/_dist/project-keys.d.ts.map +1 -0
- package/_dist/provider.d.ts +48 -0
- package/_dist/provider.d.ts.map +1 -0
- package/_dist/responses.d.ts +51 -0
- package/_dist/responses.d.ts.map +1 -0
- package/_dist/transport.d.ts +121 -0
- package/_dist/transport.d.ts.map +1 -0
- package/_dist/vocab.d.ts +10 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/batches.js +145 -0
- package/batches.js.map +1 -0
- package/batches.ts +194 -0
- package/credential.js +30 -0
- package/credential.js.map +1 -0
- package/credential.ts +40 -0
- package/deno.json +1 -0
- package/generations.js +288 -0
- package/generations.js.map +1 -0
- package/generations.ts +365 -0
- package/images.js +37 -0
- package/images.js.map +1 -0
- package/images.ts +63 -0
- package/info.js +55 -0
- package/info.js.map +1 -0
- package/info.ts +59 -0
- package/limits.js +50 -0
- package/limits.js.map +1 -0
- package/limits.ts +48 -0
- package/list.js +88 -0
- package/list.js.map +1 -0
- package/list.ts +127 -0
- package/mark.js +29 -0
- package/mark.js.map +1 -0
- package/mark.ts +50 -0
- package/media.js +60 -0
- package/media.js.map +1 -0
- package/media.ts +94 -0
- package/mod.js +28 -0
- package/mod.js.map +1 -0
- package/mod.ts +64 -0
- package/native.js +176 -0
- package/native.js.map +1 -0
- package/native.ts +221 -0
- package/package.json +36 -4
- package/project-keys.js +32 -0
- package/project-keys.js.map +1 -0
- package/project-keys.ts +43 -0
- package/provider.js +190 -0
- package/provider.js.map +1 -0
- package/provider.ts +292 -0
- package/reads.js +167 -0
- package/reads.js.map +1 -0
- package/reads.ts +169 -0
- package/responses.js +612 -0
- package/responses.js.map +1 -0
- package/responses.ts +706 -0
- package/transport.js +646 -0
- package/transport.js.map +1 -0
- package/transport.ts +972 -0
- package/vocab.js +23 -0
- package/vocab.js.map +1 -0
- package/vocab.json +25 -0
- package/vocab.ts +29 -0
package/transport.js
ADDED
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
// One implementation of the Responses HTTP protocol, shared by the
|
|
2
|
+
// provider-neutral Model adapter and
|
|
3
|
+
// callers that need provider-native items, usage, evidence, and frame hooks.
|
|
4
|
+
import { sleep, system } from "@yaks/fp";
|
|
5
|
+
import { CODEX } from "./credential.js";
|
|
6
|
+
import { jsonFrames } from "@yaks/model/sse";
|
|
7
|
+
import { STALL_TIMEOUT, watchdog } from "@yaks/model/stall";
|
|
8
|
+
/** Stable credential fault text for callers that schedule sign-in recovery. */ export let CREDENTIAL_FAULT = 'responses: credential unavailable';
|
|
9
|
+
let knownEvents = new Set([
|
|
10
|
+
'response.created',
|
|
11
|
+
'response.in_progress',
|
|
12
|
+
'response.completed',
|
|
13
|
+
'response.web_search_call.in_progress',
|
|
14
|
+
'response.web_search_call.searching',
|
|
15
|
+
'response.web_search_call.completed',
|
|
16
|
+
'response.failed',
|
|
17
|
+
'response.incomplete',
|
|
18
|
+
'response.output_item.added',
|
|
19
|
+
'response.output_item.done',
|
|
20
|
+
'response.content_part.added',
|
|
21
|
+
'response.content_part.done',
|
|
22
|
+
'response.output_text.delta',
|
|
23
|
+
'response.output_text.done',
|
|
24
|
+
'response.refusal.delta',
|
|
25
|
+
'response.refusal.done',
|
|
26
|
+
'response.reasoning_summary_part.added',
|
|
27
|
+
'response.reasoning_summary_part.done',
|
|
28
|
+
'response.reasoning_summary_text.delta',
|
|
29
|
+
'response.reasoning_summary_text.done',
|
|
30
|
+
'response.function_call_arguments.delta',
|
|
31
|
+
'response.function_call_arguments.done',
|
|
32
|
+
'error'
|
|
33
|
+
]);
|
|
34
|
+
let knownItems = new Set([
|
|
35
|
+
'image_generation_call',
|
|
36
|
+
'web_search_call',
|
|
37
|
+
'message',
|
|
38
|
+
'reasoning',
|
|
39
|
+
'function_call',
|
|
40
|
+
'compaction',
|
|
41
|
+
'custom_tool_call'
|
|
42
|
+
]);
|
|
43
|
+
let record = (value)=>value != null && typeof value == 'object' && !Array.isArray(value);
|
|
44
|
+
/** An HTTP or connection failure. `kind` is stable even when the provider
|
|
45
|
+
* supplies no code. */ export class ResponseError extends Error {
|
|
46
|
+
kind;
|
|
47
|
+
status;
|
|
48
|
+
code;
|
|
49
|
+
limits;
|
|
50
|
+
evidence;
|
|
51
|
+
items;
|
|
52
|
+
body;
|
|
53
|
+
usage;
|
|
54
|
+
constructor(kind, message){
|
|
55
|
+
super(message), this.kind = kind, /** How long the provider asked to wait, in milliseconds, when it answered. */ this.wait = 0;
|
|
56
|
+
this.name = 'ResponseError';
|
|
57
|
+
}
|
|
58
|
+
wait;
|
|
59
|
+
get retry() {
|
|
60
|
+
return transient(this) ? {
|
|
61
|
+
after: this.wait
|
|
62
|
+
} : undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let fault = (kind, message, fields = {})=>Object.assign(new ResponseError(kind, message), fields);
|
|
66
|
+
// Capacity is answered as a code at least as often as a status: a 200 stream
|
|
67
|
+
// can end in `response.failed` carrying error.code=server_is_overloaded, and a
|
|
68
|
+
// refusal body can name server_error with no 5xx of its own. Both are the
|
|
69
|
+
// backend asking us to come back, so they retry like a dropped connection.
|
|
70
|
+
let busy = new Set([
|
|
71
|
+
'server_is_overloaded',
|
|
72
|
+
'server_error',
|
|
73
|
+
'overloaded',
|
|
74
|
+
'overloaded_error',
|
|
75
|
+
'rate_limit_exceeded'
|
|
76
|
+
]);
|
|
77
|
+
// A spent allowance also answers 429, but it is the provider's no: the Codex
|
|
78
|
+
// backend's plan window, the API's billing quota and a project's spend limit
|
|
79
|
+
// stay spent for hours, so asking again in seconds meets the same limit. A
|
|
80
|
+
// request the model cannot take (too long, malformed, refused) fails the same
|
|
81
|
+
// way however often it is sent.
|
|
82
|
+
let spent = new Set([
|
|
83
|
+
'usage_limit_reached',
|
|
84
|
+
'insufficient_quota',
|
|
85
|
+
'project_spend_limit_exceeded',
|
|
86
|
+
'billing_hard_limit_reached'
|
|
87
|
+
]);
|
|
88
|
+
let final = new Set([
|
|
89
|
+
...spent,
|
|
90
|
+
'usage_not_included',
|
|
91
|
+
'context_length_exceeded',
|
|
92
|
+
'invalid_prompt',
|
|
93
|
+
'invalid_request_error'
|
|
94
|
+
]);
|
|
95
|
+
// Final provider failures and malformed events are not network failures.
|
|
96
|
+
// A stall is a network failure: a connection that was established and then went
|
|
97
|
+
// silent told us nothing about this request, so the next attempt starts as
|
|
98
|
+
// cleanly as it would after a dropped connection
|
|
99
|
+
// (T-37332 — two stalls ended a session that had retries left). A stream that
|
|
100
|
+
// ends in `response.failed` or an `error` event is the provider failing this
|
|
101
|
+
// request — the Codex backend says `unknown` or `server_error` — and is asked
|
|
102
|
+
// again unless its code says the request itself cannot succeed, as the Codex
|
|
103
|
+
// CLI does (T-62140).
|
|
104
|
+
let transient = (error)=>!(error.code != null && final.has(error.code)) && (error.kind == 'transport' || error.kind == 'disconnected' || error.kind == 'stalled' || error.kind == 'failed' || error.kind == 'error' || error.kind == 'no_stream' || error.status == 429 || error.status != null && error.status >= 500 && error.status < 600 || error.code != null && busy.has(error.code));
|
|
105
|
+
// A rate limit: a request refused for coming too fast, which passes, unlike a
|
|
106
|
+
// spent allowance, which does not.
|
|
107
|
+
let limited = (status, code)=>!(code != null && spent.has(code)) && (status == 429 || code == 'rate_limit_exceeded');
|
|
108
|
+
// The wait a rate limit asks for in its prose: "Please try again in 1.898s".
|
|
109
|
+
let waitIn = (text)=>{
|
|
110
|
+
let m = /try again in\s*(\d+(?:\.\d+)?)\s*(ms|s|seconds?)\b/i.exec(text);
|
|
111
|
+
return m ? Number(m[1]) * (m[2].toLowerCase() == 'ms' ? 1 : 1000) : 0;
|
|
112
|
+
};
|
|
113
|
+
/** How long the provider asked to wait before the next attempt, in
|
|
114
|
+
* milliseconds, up to a minute, as of `now`: a Retry-After header, or a rate
|
|
115
|
+
* limit's "try again in". */ let waitOf = (kept, text, now)=>{
|
|
116
|
+
let value = kept['retry-after'];
|
|
117
|
+
let ms = !value ? waitIn(text) : /^\d+(\.\d+)?$/.test(value) ? Number(value) * 1000 : Date.parse(value) - now;
|
|
118
|
+
return Number.isFinite(ms) ? Math.min(60_000, Math.max(0, ms)) : 0;
|
|
119
|
+
};
|
|
120
|
+
// A failure's line, in the provider's own words: what ended the request, then
|
|
121
|
+
// its code and its message, and for a rate limit (`limit`, the wait it asked
|
|
122
|
+
// for) that it is one.
|
|
123
|
+
let said = (what, detail, limit)=>{
|
|
124
|
+
let words = detail.filter(Boolean).join(': ');
|
|
125
|
+
let rate = limit == null ? '' : ` (rate limited${limit ? `; asked to wait ${Math.round(limit / 100) / 10}s` : ''})`;
|
|
126
|
+
return `responses: ${what}${words ? ` — ${words}` : ''}${rate}`;
|
|
127
|
+
};
|
|
128
|
+
// Stop is prompt even during backoff, and never starts another HTTP attempt.
|
|
129
|
+
let backoff = (ms, clock, signal, pause)=>{
|
|
130
|
+
if (!pause) {
|
|
131
|
+
return sleep(ms, signal, clock).then(()=>signal?.throwIfAborted());
|
|
132
|
+
}
|
|
133
|
+
if (!signal) return pause(ms);
|
|
134
|
+
return new Promise((resolve, reject)=>{
|
|
135
|
+
signal.throwIfAborted();
|
|
136
|
+
let close = ()=>signal.removeEventListener('abort', abort);
|
|
137
|
+
let abort = ()=>{
|
|
138
|
+
close();
|
|
139
|
+
reject(signal.reason);
|
|
140
|
+
};
|
|
141
|
+
signal.addEventListener('abort', abort, {
|
|
142
|
+
once: true
|
|
143
|
+
});
|
|
144
|
+
Promise.resolve().then(()=>pause(ms)).then(()=>{
|
|
145
|
+
close();
|
|
146
|
+
resolve();
|
|
147
|
+
}, (error)=>{
|
|
148
|
+
close();
|
|
149
|
+
reject(error);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
let scrub = (value, secrets)=>{
|
|
154
|
+
if (typeof value == 'string') {
|
|
155
|
+
let text = value;
|
|
156
|
+
for (let secret of secrets){
|
|
157
|
+
if (secret) text = text.replaceAll(secret, '[redacted]');
|
|
158
|
+
}
|
|
159
|
+
return text;
|
|
160
|
+
}
|
|
161
|
+
if (Array.isArray(value)) return value.map((item)=>scrub(item, secrets));
|
|
162
|
+
if (!record(value)) return value;
|
|
163
|
+
return Object.fromEntries(Object.entries(value).map(([name, item])=>[
|
|
164
|
+
name,
|
|
165
|
+
scrub(item, secrets)
|
|
166
|
+
]));
|
|
167
|
+
};
|
|
168
|
+
let safe = (value, secrets)=>{
|
|
169
|
+
let clean = scrub(value, secrets);
|
|
170
|
+
if (!record(clean)) {
|
|
171
|
+
throw fault('malformed_stream', 'responses: expected an object');
|
|
172
|
+
}
|
|
173
|
+
return clean;
|
|
174
|
+
};
|
|
175
|
+
/** A short machine token — a fault code, a class name, an incomplete reason. */ let codeOf = (value)=>typeof value == 'string' && /^[\w.:-]{1,64}$/.test(value) ? value : undefined;
|
|
176
|
+
// Fetch failures often hide the useful network error in `cause`. Carry enough
|
|
177
|
+
// of that chain into a failed session to diagnose the next outage, without
|
|
178
|
+
// recording credentials or URL parameters from a custom endpoint.
|
|
179
|
+
let networkReason = (error, secrets)=>{
|
|
180
|
+
let parts = [];
|
|
181
|
+
for(let n = 0; n < 3 && error instanceof Error; n++){
|
|
182
|
+
let code = codeOf(error.code);
|
|
183
|
+
let name = code ?? codeOf(error.name) ?? 'Error';
|
|
184
|
+
let message = error.message.replace(/https?:\/\/[^\s)]+/g, '[endpoint]');
|
|
185
|
+
let clean = scrub(message, secrets);
|
|
186
|
+
parts.push(clean ? `${name}: ${clean}` : name);
|
|
187
|
+
error = error.cause;
|
|
188
|
+
}
|
|
189
|
+
return parts.join(' <- ').slice(0, 400);
|
|
190
|
+
};
|
|
191
|
+
// An HTTP-error body carries both a short machine `code` and the human
|
|
192
|
+
// `message` naming what it rejected ("No tool output for function call …").
|
|
193
|
+
// A failed session stamps only the fault's .message, so the reason is the
|
|
194
|
+
// half that makes the failure diagnosable — carry both through, redacted.
|
|
195
|
+
let explain = (body, secrets)=>{
|
|
196
|
+
let parsed;
|
|
197
|
+
try {
|
|
198
|
+
parsed = scrub(JSON.parse(body), secrets);
|
|
199
|
+
} catch {
|
|
200
|
+
let reason = scrub(body, secrets);
|
|
201
|
+
return typeof reason == 'string' && reason.trim() ? {
|
|
202
|
+
reason: reason.trim()
|
|
203
|
+
} : {};
|
|
204
|
+
}
|
|
205
|
+
if (!record(parsed)) {
|
|
206
|
+
return typeof parsed == 'string' && parsed.trim() ? {
|
|
207
|
+
reason: parsed.trim()
|
|
208
|
+
} : {};
|
|
209
|
+
}
|
|
210
|
+
let error = record(parsed.error) ? parsed.error : record(parsed.detail) ? parsed.detail : parsed;
|
|
211
|
+
let code = codeOf(error.code) ?? codeOf(error.type);
|
|
212
|
+
let detail = typeof parsed.detail == 'string' ? parsed.detail : undefined;
|
|
213
|
+
let reason = typeof error.message == 'string' && error.message.trim() ? error.message.trim() : detail?.trim() ? detail.trim() : undefined;
|
|
214
|
+
return {
|
|
215
|
+
code,
|
|
216
|
+
reason
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
let eventCode = (frame)=>{
|
|
220
|
+
if (!frame) return undefined;
|
|
221
|
+
let response = record(frame.response) ? frame.response : frame;
|
|
222
|
+
let error = record(response.error) ? response.error : undefined;
|
|
223
|
+
// A nested error names its class in `type` when `code` is null. A bare error
|
|
224
|
+
// frame's own `type` is the event name ('error'), never the fault's class.
|
|
225
|
+
return error ? codeOf(error.code) ?? codeOf(error.type) : codeOf(response.code);
|
|
226
|
+
};
|
|
227
|
+
// The provider's own words for a stream's failure: the message of the error it
|
|
228
|
+
// carried, which names what went wrong where the code is only `unknown`.
|
|
229
|
+
let eventMessage = (frame)=>{
|
|
230
|
+
if (!frame) return undefined;
|
|
231
|
+
let response = record(frame.response) ? frame.response : frame;
|
|
232
|
+
let error = record(response.error) ? response.error : response;
|
|
233
|
+
let message = typeof error.message == 'string' ? error.message.trim() : '';
|
|
234
|
+
return message || undefined;
|
|
235
|
+
};
|
|
236
|
+
let incomplete = (frame)=>{
|
|
237
|
+
if (frame?.type != 'response.incomplete') return undefined;
|
|
238
|
+
let response = record(frame.response) ? frame.response : {};
|
|
239
|
+
let details = record(response.incomplete_details) ? response.incomplete_details : {};
|
|
240
|
+
return codeOf(details.reason);
|
|
241
|
+
};
|
|
242
|
+
// The headers that speak of the account's limits: Retry-After, the API's
|
|
243
|
+
// rate limits, and the Codex backend's plan windows and credits
|
|
244
|
+
// (`x-codex-primary-used-percent`, …), but not the opaque turn state it hands
|
|
245
|
+
// back beside them.
|
|
246
|
+
let limitName = (name)=>name == 'retry-after' || name.startsWith('x-ratelimit-') || name.startsWith('x-codex-') && name != 'x-codex-turn-state';
|
|
247
|
+
let limits = (headers)=>{
|
|
248
|
+
let out = {};
|
|
249
|
+
headers.forEach((value, name)=>{
|
|
250
|
+
if (limitName(name.toLowerCase())) out[name.toLowerCase()] = value;
|
|
251
|
+
});
|
|
252
|
+
return out;
|
|
253
|
+
};
|
|
254
|
+
/** Decode SSE across arbitrary byte chunks, including CRLF and a final frame
|
|
255
|
+
* without a blank line. The reader is released even if a consumer throws. */ export let frames = (body)=>jsonFrames(body, (kind, message)=>kind == 'stalled' ? fault(kind, 'responses: stream stalled') : fault(kind, message), (value)=>{
|
|
256
|
+
if (typeof value.type != 'string') {
|
|
257
|
+
throw fault('malformed_stream', 'responses: stream event has no type');
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
let usage = (value)=>{
|
|
261
|
+
if (!record(value)) return undefined;
|
|
262
|
+
let input = record(value.input_tokens_details) ? value.input_tokens_details : {};
|
|
263
|
+
let output = record(value.output_tokens_details) ? value.output_tokens_details : {};
|
|
264
|
+
return {
|
|
265
|
+
input: Number(value.input_tokens ?? 0),
|
|
266
|
+
cached: Number(input.cached_tokens ?? 0),
|
|
267
|
+
output: Number(value.output_tokens ?? 0),
|
|
268
|
+
reasoning: Number(output.reasoning_tokens ?? 0),
|
|
269
|
+
raw: value
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
let terminal = async (response, secrets, clock, notify, kick)=>{
|
|
273
|
+
if (!response.body) {
|
|
274
|
+
throw fault('no_stream', 'responses: provider returned no stream');
|
|
275
|
+
}
|
|
276
|
+
// Headers arrived; reset the deadline for the wait on the first frame, then on
|
|
277
|
+
// every frame the gap to the next one.
|
|
278
|
+
kick?.();
|
|
279
|
+
let items = [];
|
|
280
|
+
let unknown = [];
|
|
281
|
+
let completed;
|
|
282
|
+
let ended;
|
|
283
|
+
let cut = false;
|
|
284
|
+
for await (let parsed of frames(response.body)){
|
|
285
|
+
let frame = secrets.length ? safe(parsed, secrets) : parsed;
|
|
286
|
+
kick?.();
|
|
287
|
+
await notify?.(frame);
|
|
288
|
+
kick?.();
|
|
289
|
+
if (!knownEvents.has(frame.type)) unknown.push(frame);
|
|
290
|
+
if (frame.type == 'response.output_item.done') {
|
|
291
|
+
let item = safe(frame.item, secrets);
|
|
292
|
+
if (typeof item.type != 'string') {
|
|
293
|
+
throw fault('malformed_stream', 'responses: completed item has no type');
|
|
294
|
+
}
|
|
295
|
+
items.push(item);
|
|
296
|
+
}
|
|
297
|
+
// A response stopped at its output limit is a reply cut short; one
|
|
298
|
+
// incomplete for any other reason failed.
|
|
299
|
+
let stopped = incomplete(frame) == 'max_output_tokens';
|
|
300
|
+
if (frame.type == 'response.completed' || stopped) {
|
|
301
|
+
cut = stopped;
|
|
302
|
+
completed = safe(frame.response, secrets);
|
|
303
|
+
} else if (frame.type == 'response.failed' || frame.type == 'response.incomplete' || frame.type == 'error') ended = frame;
|
|
304
|
+
}
|
|
305
|
+
// A 200 that ends in an overload still carries the account's rate-limit
|
|
306
|
+
// headers; pass them along so the backoff honors a Retry-After sent there,
|
|
307
|
+
// and keep the event that ended it, as sent, for whoever reads the failure.
|
|
308
|
+
let failing = (kind, frame)=>{
|
|
309
|
+
let code = eventCode(frame) ?? incomplete(frame);
|
|
310
|
+
let reason = eventMessage(frame);
|
|
311
|
+
// A request that failed or stopped short says what it used.
|
|
312
|
+
let answered = frame?.response;
|
|
313
|
+
let used = record(answered) ? answered.usage : frame?.usage;
|
|
314
|
+
let kept = limits(response.headers);
|
|
315
|
+
let wait = waitOf(kept, reason ?? '', clock.now());
|
|
316
|
+
let rate = limited(200, code) ? wait : undefined;
|
|
317
|
+
return fault(kind, said(kind, [
|
|
318
|
+
code,
|
|
319
|
+
reason
|
|
320
|
+
], rate), {
|
|
321
|
+
code,
|
|
322
|
+
limits: kept,
|
|
323
|
+
wait,
|
|
324
|
+
...frame ? {
|
|
325
|
+
body: JSON.stringify(frame)
|
|
326
|
+
} : {},
|
|
327
|
+
...record(used) ? {
|
|
328
|
+
usage: used
|
|
329
|
+
} : {},
|
|
330
|
+
evidence: frame ? [
|
|
331
|
+
...unknown,
|
|
332
|
+
frame
|
|
333
|
+
] : unknown,
|
|
334
|
+
items
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
if (!completed) {
|
|
338
|
+
throw failing(ended?.type?.replace('response.', '') ?? 'disconnected', ended);
|
|
339
|
+
}
|
|
340
|
+
if (completed.status != (cut ? 'incomplete' : 'completed')) {
|
|
341
|
+
throw failing('failed', completed);
|
|
342
|
+
}
|
|
343
|
+
if (typeof completed.model != 'string') {
|
|
344
|
+
throw fault('malformed_stream', 'responses: completion names no serving model');
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
model: completed.model,
|
|
348
|
+
items,
|
|
349
|
+
unknown,
|
|
350
|
+
unknownItems: items.filter((item)=>!knownItems.has(item.type)),
|
|
351
|
+
usage: usage(completed.usage),
|
|
352
|
+
response: completed,
|
|
353
|
+
limits: limits(response.headers),
|
|
354
|
+
...cut ? {
|
|
355
|
+
cut
|
|
356
|
+
} : {}
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
let credential = (value, optional = false)=>{
|
|
360
|
+
if (!optional && !value.token?.trim()) {
|
|
361
|
+
throw fault('no_credential', 'responses: no credential');
|
|
362
|
+
}
|
|
363
|
+
return value;
|
|
364
|
+
};
|
|
365
|
+
let credentials = async (load, message, pause, optional = false, retries = 0, hint, redact = false)=>{
|
|
366
|
+
for(let failures = 0;; failures++){
|
|
367
|
+
try {
|
|
368
|
+
return credential(await load(), optional);
|
|
369
|
+
} catch (error) {
|
|
370
|
+
if (failures >= retries) {
|
|
371
|
+
let reason = hint ?? (!redact && error instanceof Error ? error.message : undefined);
|
|
372
|
+
throw fault('no_credential', reason ? `${message} — ${reason}` : message);
|
|
373
|
+
}
|
|
374
|
+
await pause(200 * 2 ** failures);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
export let request = (value, store = false)=>{
|
|
379
|
+
let include = Array.isArray(value.include) ? [
|
|
380
|
+
...value.include
|
|
381
|
+
] : [];
|
|
382
|
+
if (!include.includes('reasoning.encrypted_content')) {
|
|
383
|
+
include.push('reasoning.encrypted_content');
|
|
384
|
+
}
|
|
385
|
+
return {
|
|
386
|
+
...value,
|
|
387
|
+
include,
|
|
388
|
+
store,
|
|
389
|
+
stream: true
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
// What the input token count reads of a request: the fields that make its
|
|
393
|
+
// input, never how it is run, stored or cached, which it refuses.
|
|
394
|
+
let COUNTED = [
|
|
395
|
+
'model',
|
|
396
|
+
'input',
|
|
397
|
+
'instructions',
|
|
398
|
+
'tools',
|
|
399
|
+
'tool_choice',
|
|
400
|
+
'parallel_tool_calls',
|
|
401
|
+
'previous_response_id',
|
|
402
|
+
'reasoning',
|
|
403
|
+
'text',
|
|
404
|
+
'truncation'
|
|
405
|
+
];
|
|
406
|
+
let countable = (value)=>Object.fromEntries(Object.entries(value).filter(([key])=>COUNTED.includes(key)));
|
|
407
|
+
/** The provider-native transport. `run` reads through EOF; `reach` probes
|
|
408
|
+
* connectivity, not authorization. Neither keeps conversation state. */ export let transport = (options)=>{
|
|
409
|
+
let fetcher = options.fetch ?? fetch;
|
|
410
|
+
let base = options.base?.replace(/\/$/, '');
|
|
411
|
+
let retries = Math.max(0, options.retries ?? 2);
|
|
412
|
+
let patienceMs = Math.max(0, options.patienceMs ?? 0);
|
|
413
|
+
let stallMs = Math.max(0, options.stallMs ?? STALL_TIMEOUT * 1000);
|
|
414
|
+
let clock = options.clock ?? system;
|
|
415
|
+
let pause = options.pause ?? ((ms)=>sleep(ms, undefined, clock));
|
|
416
|
+
let id = options.id ?? (()=>crypto.randomUUID());
|
|
417
|
+
// Refresh replaces the credential at the HTTP edge, but completed provider
|
|
418
|
+
// items from later turns may still echo something seen before the refresh.
|
|
419
|
+
// Keep every credential this transport has held as a redaction term for its
|
|
420
|
+
// whole lifetime; none of them leave this closure.
|
|
421
|
+
let secrets = [];
|
|
422
|
+
let remember = (auth)=>{
|
|
423
|
+
if (!options.redact) return;
|
|
424
|
+
for (let value of [
|
|
425
|
+
auth.token,
|
|
426
|
+
auth.account ?? ''
|
|
427
|
+
]){
|
|
428
|
+
if (value && !secrets.includes(value)) secrets.push(value);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
let run = async (value, run = {})=>{
|
|
432
|
+
let auth = await credentials(options.credentials.get, CREDENTIAL_FAULT, pause, options.authentication == 'optional', retries, options.credentials.hint, options.redact);
|
|
433
|
+
remember(auth);
|
|
434
|
+
let refreshed = false;
|
|
435
|
+
let failures = 0;
|
|
436
|
+
let waited = 0;
|
|
437
|
+
let requestId = id();
|
|
438
|
+
let shaped = options.shape?.(value) ?? request(value, options.store);
|
|
439
|
+
let prepare = ()=>{
|
|
440
|
+
let endpoint = (base ?? auth.base ?? 'https://api.openai.com/v1').replace(/\/$/, '');
|
|
441
|
+
// The Codex endpoint rejects max_output_tokens; the public API accepts it.
|
|
442
|
+
let payload = JSON.stringify(endpoint == CODEX ? Object.fromEntries(Object.entries(shaped).filter(([key])=>key != 'max_output_tokens')) : shaped);
|
|
443
|
+
let headers = new Headers(options.headers);
|
|
444
|
+
headers.set('accept', 'text/event-stream');
|
|
445
|
+
if (auth.token) headers.set('authorization', `Bearer ${auth.token}`);
|
|
446
|
+
headers.set('content-type', 'application/json');
|
|
447
|
+
headers.set('x-client-request-id', requestId);
|
|
448
|
+
if (auth.account) headers.set('chatgpt-account-id', auth.account);
|
|
449
|
+
if (endpoint == CODEX && run.conversation) {
|
|
450
|
+
headers.set('session_id', run.conversation);
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
endpoint,
|
|
454
|
+
payload,
|
|
455
|
+
headers
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
let prepared = prepare();
|
|
459
|
+
let hookFailed = false;
|
|
460
|
+
while(true){
|
|
461
|
+
run.signal?.throwIfAborted();
|
|
462
|
+
let { endpoint, payload, headers } = prepared;
|
|
463
|
+
await run.submit?.(JSON.parse(payload));
|
|
464
|
+
run.signal?.throwIfAborted();
|
|
465
|
+
// One deadline spans this whole exchange — the connect, the wait on the
|
|
466
|
+
// first frame, and every mid-stream gap — each frame pushing it forward.
|
|
467
|
+
// A trip aborts its own signal (not run.signal), so the throw below is a
|
|
468
|
+
// named stall the caller can fail on, never a silent hang.
|
|
469
|
+
let dog = watchdog(Math.max(0, run.stallMs ?? stallMs), clock, run.signal);
|
|
470
|
+
try {
|
|
471
|
+
let response;
|
|
472
|
+
try {
|
|
473
|
+
response = await fetcher(`${endpoint}/responses`, {
|
|
474
|
+
method: 'POST',
|
|
475
|
+
headers,
|
|
476
|
+
body: payload,
|
|
477
|
+
signal: dog.signal
|
|
478
|
+
});
|
|
479
|
+
} catch (error) {
|
|
480
|
+
if (dog.stalled()) {
|
|
481
|
+
throw fault('stalled', 'responses: transport stalled');
|
|
482
|
+
}
|
|
483
|
+
if (run.signal?.aborted || error?.name == 'AbortError') {
|
|
484
|
+
throw error;
|
|
485
|
+
}
|
|
486
|
+
let reason = networkReason(error, secrets);
|
|
487
|
+
throw fault('transport', `responses: transport failed${reason ? ` — ${reason}` : ''}`);
|
|
488
|
+
}
|
|
489
|
+
if (response.status == 401 && !run.submit && !refreshed && options.credentials.refresh) {
|
|
490
|
+
dog.close();
|
|
491
|
+
await response.body?.cancel();
|
|
492
|
+
auth = await credentials(()=>options.credentials.refresh(auth), 'responses: credential refresh failed', pause, options.authentication == 'optional', retries, undefined, options.redact);
|
|
493
|
+
remember(auth);
|
|
494
|
+
prepared = prepare();
|
|
495
|
+
refreshed = true;
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
dog.kick();
|
|
499
|
+
if (!response.ok) {
|
|
500
|
+
// Once HTTP has refused the request its status wins, even if its
|
|
501
|
+
// diagnostic body drops. A broken 401 body is not a retryable 200.
|
|
502
|
+
let body = await response.text().catch(()=>'');
|
|
503
|
+
let status = response.status;
|
|
504
|
+
let { code, reason } = explain(body, secrets);
|
|
505
|
+
let kept = limits(response.headers);
|
|
506
|
+
let wait = waitOf(kept, reason ?? '', clock.now());
|
|
507
|
+
let rate = limited(status, code) ? wait : undefined;
|
|
508
|
+
throw fault(`http_${status}`, said(`HTTP ${status}`, [
|
|
509
|
+
reason
|
|
510
|
+
], rate), {
|
|
511
|
+
status,
|
|
512
|
+
code,
|
|
513
|
+
limits: kept,
|
|
514
|
+
wait,
|
|
515
|
+
...body ? {
|
|
516
|
+
body: scrub(body, secrets)
|
|
517
|
+
} : {}
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
return await terminal(response, secrets, clock, async (event)=>{
|
|
521
|
+
try {
|
|
522
|
+
await run.event?.(event);
|
|
523
|
+
} catch (error) {
|
|
524
|
+
hookFailed = true;
|
|
525
|
+
throw error;
|
|
526
|
+
}
|
|
527
|
+
}, dog.kick);
|
|
528
|
+
} catch (error) {
|
|
529
|
+
if (run.signal?.aborted || hookFailed) throw error;
|
|
530
|
+
let fail = error;
|
|
531
|
+
if (dog.stalled() && !(error instanceof ResponseError && error.kind == 'stalled')) {
|
|
532
|
+
fail = fault('stalled', 'responses: stream stalled');
|
|
533
|
+
}
|
|
534
|
+
// Patience outlasts the attempt count: an outage fails every attempt
|
|
535
|
+
// the same way, and a caller that states how long it can wait rides one
|
|
536
|
+
// out instead of failing in five seconds.
|
|
537
|
+
if (run.submit || (typeof run.noRetry == 'function' ? run.noRetry() : run.noRetry) || !(fail instanceof ResponseError) || !transient(fail) || failures >= retries && waited >= patienceMs) {
|
|
538
|
+
throw fail;
|
|
539
|
+
}
|
|
540
|
+
// Nothing from this attempt is committed. Reuse the exact body and
|
|
541
|
+
// correlation id; only a complete exchange may reach the runner.
|
|
542
|
+
dog.close();
|
|
543
|
+
let wait = Math.max(Math.min(1000 * 4 ** failures++, 60_000), fail.wait);
|
|
544
|
+
waited += wait;
|
|
545
|
+
await backoff(wait, clock, run.signal, options.pause);
|
|
546
|
+
} finally{
|
|
547
|
+
dog.close();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
// A connectivity probe distinct from "credentials exist": reach the serving
|
|
552
|
+
// endpoint and report whether the transport got there at all. Any HTTP answer
|
|
553
|
+
// — even 401 or 5xx — proves the endpoint is reachable; only a network failure
|
|
554
|
+
// or a bounded timeout (the silent hang `run` guards mid-stream) reads as
|
|
555
|
+
// unreachable. A readiness gate pairs this with the account's signed-in state,
|
|
556
|
+
// so a machine that cannot reach the provider drops out of the dispatch
|
|
557
|
+
// rotation (T-24135).
|
|
558
|
+
let reach = async ()=>{
|
|
559
|
+
let auth;
|
|
560
|
+
try {
|
|
561
|
+
auth = await credentials(options.credentials.get, CREDENTIAL_FAULT, pause, options.authentication == 'optional');
|
|
562
|
+
} catch {
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
remember(auth);
|
|
566
|
+
let headers = new Headers(options.headers);
|
|
567
|
+
headers.set('accept', 'application/json');
|
|
568
|
+
if (auth.token) headers.set('authorization', `Bearer ${auth.token}`);
|
|
569
|
+
if (auth.account) headers.set('chatgpt-account-id', auth.account);
|
|
570
|
+
let endpoint = (base ?? auth.base ?? 'https://api.openai.com/v1').replace(/\/$/, '');
|
|
571
|
+
// A watchdog never kicked is a plain deadline.
|
|
572
|
+
let deadline = watchdog(5000, clock);
|
|
573
|
+
try {
|
|
574
|
+
let response = await fetcher(`${endpoint}/models`, {
|
|
575
|
+
method: 'GET',
|
|
576
|
+
headers,
|
|
577
|
+
signal: deadline.signal
|
|
578
|
+
});
|
|
579
|
+
await response.body?.cancel();
|
|
580
|
+
return true;
|
|
581
|
+
} catch {
|
|
582
|
+
return false;
|
|
583
|
+
} finally{
|
|
584
|
+
deadline.close();
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
// One JSON exchange beside a run: undefined where the endpoint has no such
|
|
588
|
+
// thing (404).
|
|
589
|
+
let exchange = async (path, what, method, signal, payload)=>{
|
|
590
|
+
let auth = await credentials(options.credentials.get, CREDENTIAL_FAULT, pause, options.authentication == 'optional', retries, options.credentials.hint, options.redact);
|
|
591
|
+
remember(auth);
|
|
592
|
+
let headers = new Headers(options.headers);
|
|
593
|
+
headers.set('accept', 'application/json');
|
|
594
|
+
if (auth.token) headers.set('authorization', `Bearer ${auth.token}`);
|
|
595
|
+
if (auth.account) headers.set('chatgpt-account-id', auth.account);
|
|
596
|
+
if (payload) headers.set('content-type', 'application/json');
|
|
597
|
+
let endpoint = (base ?? auth.base ?? 'https://api.openai.com/v1').replace(/\/$/, '');
|
|
598
|
+
let dog = watchdog(stallMs, clock, signal);
|
|
599
|
+
try {
|
|
600
|
+
let answer = await fetcher(endpoint + path, {
|
|
601
|
+
method,
|
|
602
|
+
headers,
|
|
603
|
+
...payload ? {
|
|
604
|
+
body: JSON.stringify(payload)
|
|
605
|
+
} : {},
|
|
606
|
+
signal: dog.signal
|
|
607
|
+
});
|
|
608
|
+
if (answer.status == 404) {
|
|
609
|
+
await answer.body?.cancel();
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
if (!answer.ok) {
|
|
613
|
+
await answer.body?.cancel();
|
|
614
|
+
throw fault('http_' + answer.status, `responses: ${what} returned HTTP ${answer.status}`, {
|
|
615
|
+
status: answer.status
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
return safe(await answer.json(), secrets);
|
|
619
|
+
} catch (error) {
|
|
620
|
+
signal?.throwIfAborted();
|
|
621
|
+
if (error instanceof ResponseError) throw error;
|
|
622
|
+
throw fault('transport', `responses: could not read ${what}`);
|
|
623
|
+
} finally{
|
|
624
|
+
dog.close();
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
let background = (response, method, signal)=>exchange('/responses/' + encodeURIComponent(response) + (method == 'POST' ? '/cancel' : ''), 'background request', method, signal);
|
|
628
|
+
let count = async (value, signal)=>{
|
|
629
|
+
let answer = await exchange('/responses/input_tokens', 'input token count', 'POST', signal, countable(value));
|
|
630
|
+
let n = answer?.input_tokens;
|
|
631
|
+
if (typeof n != 'number' || !Number.isSafeInteger(n) || n < 0) {
|
|
632
|
+
throw fault('transport', 'responses: no input token count');
|
|
633
|
+
}
|
|
634
|
+
return n;
|
|
635
|
+
};
|
|
636
|
+
return {
|
|
637
|
+
run,
|
|
638
|
+
reach,
|
|
639
|
+
get: (response, signal)=>background(response, 'GET', signal),
|
|
640
|
+
cancel: async (response)=>{
|
|
641
|
+
await background(response, 'POST');
|
|
642
|
+
},
|
|
643
|
+
count
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
//# sourceMappingURL=transport.js.map
|
package/transport.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sources":["./transport.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,qCAA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