dsh-lcx-codex 0.4.2 → 0.4.3-pre.13
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/README.md +75 -224
- package/THIRD_PARTY_NOTICES.md +64 -0
- package/cordis.patch.yml +3 -20
- package/lib/auxiliary-usage.js +63 -0
- package/lib/client.js +1398 -167
- package/lib/compact-v2.js +218 -199
- package/lib/dsh-compat.js +294 -100
- package/lib/dsh-responses.js +512 -277
- package/lib/grok-native-search.js +391 -0
- package/lib/index.js +1066 -758
- package/lib/invocation-policy-scope.js +261 -0
- package/lib/json-store.js +57 -31
- package/lib/native-checkpoint.js +520 -194
- package/lib/pi-responses-runtime.js +1571 -0
- package/lib/responses-request.js +109 -121
- package/lib/responses-stream.js +1280 -447
- package/lib/route.js +425 -369
- package/lib/search-accounting.js +86 -0
- package/lib/search-usage.js +86 -0
- package/lib/service-mutex.js +73 -64
- package/lib/token-budget.js +176 -108
- package/lib/transport.js +308 -68
- package/lib/types/client/index.d.ts +18 -0
- package/lib/types/client/search-media.d.ts +16 -0
- package/lib/types/index.d.ts +83 -0
- package/lib/web-run-output.js +189 -18
- package/lib/web-search-alpha.js +1067 -163
- package/lib/web-search-capability.js +80 -65
- package/lib/web-search-hosted.js +321 -33
- package/lib/web-search-ref-store.js +145 -60
- package/package.json +112 -32
- package/ARCHITECTURE.md +0 -117
- package/CHANGELOG.md +0 -224
- package/README_EN.md +0 -277
- package/assets/dsh-lcx-codex-banner.jpg +0 -0
- package/lib/legacy-v3.js +0 -20
- package/lib/responses-replay.js +0 -68
- package/scripts/probe-alpha.mjs +0 -43
- package/scripts/validate-dsh-schema.mjs +0 -31
|
@@ -0,0 +1,1571 @@
|
|
|
1
|
+
// Generated from public @earendil-works/pi-ai@0.85.1 by scripts/build-pi-runtime.mjs. Do not edit.
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
try {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw mod = 0, e;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
// scripts/runtime-dsh015/node_modules/partial-json/dist/options.js
|
|
33
|
+
var require_options = __commonJS({
|
|
34
|
+
"scripts/runtime-dsh015/node_modules/partial-json/dist/options.js"(exports) {
|
|
35
|
+
"use strict";
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.Allow = exports.ALL = exports.COLLECTION = exports.ATOM = exports.SPECIAL = exports.INF = exports._INFINITY = exports.INFINITY = exports.NAN = exports.BOOL = exports.NULL = exports.OBJ = exports.ARR = exports.NUM = exports.STR = void 0;
|
|
38
|
+
exports.STR = 1;
|
|
39
|
+
exports.NUM = 2;
|
|
40
|
+
exports.ARR = 4;
|
|
41
|
+
exports.OBJ = 8;
|
|
42
|
+
exports.NULL = 16;
|
|
43
|
+
exports.BOOL = 32;
|
|
44
|
+
exports.NAN = 64;
|
|
45
|
+
exports.INFINITY = 128;
|
|
46
|
+
exports._INFINITY = 256;
|
|
47
|
+
exports.INF = exports.INFINITY | exports._INFINITY;
|
|
48
|
+
exports.SPECIAL = exports.NULL | exports.BOOL | exports.INF | exports.NAN;
|
|
49
|
+
exports.ATOM = exports.STR | exports.NUM | exports.SPECIAL;
|
|
50
|
+
exports.COLLECTION = exports.ARR | exports.OBJ;
|
|
51
|
+
exports.ALL = exports.ATOM | exports.COLLECTION;
|
|
52
|
+
exports.Allow = { STR: exports.STR, NUM: exports.NUM, ARR: exports.ARR, OBJ: exports.OBJ, NULL: exports.NULL, BOOL: exports.BOOL, NAN: exports.NAN, INFINITY: exports.INFINITY, _INFINITY: exports._INFINITY, INF: exports.INF, SPECIAL: exports.SPECIAL, ATOM: exports.ATOM, COLLECTION: exports.COLLECTION, ALL: exports.ALL };
|
|
53
|
+
exports.default = exports.Allow;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// scripts/runtime-dsh015/node_modules/partial-json/dist/index.js
|
|
58
|
+
var require_dist = __commonJS({
|
|
59
|
+
"scripts/runtime-dsh015/node_modules/partial-json/dist/index.js"(exports) {
|
|
60
|
+
"use strict";
|
|
61
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
62
|
+
if (k2 === void 0) k2 = k;
|
|
63
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
64
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
65
|
+
desc = { enumerable: true, get: function() {
|
|
66
|
+
return m[k];
|
|
67
|
+
} };
|
|
68
|
+
}
|
|
69
|
+
Object.defineProperty(o, k2, desc);
|
|
70
|
+
}) : (function(o, m, k, k2) {
|
|
71
|
+
if (k2 === void 0) k2 = k;
|
|
72
|
+
o[k2] = m[k];
|
|
73
|
+
}));
|
|
74
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
75
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
76
|
+
};
|
|
77
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
+
exports.Allow = exports.MalformedJSON = exports.PartialJSON = exports.parseJSON = exports.parse = void 0;
|
|
79
|
+
var options_1 = require_options();
|
|
80
|
+
Object.defineProperty(exports, "Allow", { enumerable: true, get: function() {
|
|
81
|
+
return options_1.Allow;
|
|
82
|
+
} });
|
|
83
|
+
__exportStar(require_options(), exports);
|
|
84
|
+
var PartialJSON = class extends Error {
|
|
85
|
+
};
|
|
86
|
+
exports.PartialJSON = PartialJSON;
|
|
87
|
+
var MalformedJSON = class extends Error {
|
|
88
|
+
};
|
|
89
|
+
exports.MalformedJSON = MalformedJSON;
|
|
90
|
+
function parseJSON(jsonString, allowPartial = options_1.Allow.ALL) {
|
|
91
|
+
if (typeof jsonString !== "string") {
|
|
92
|
+
throw new TypeError(`expecting str, got ${typeof jsonString}`);
|
|
93
|
+
}
|
|
94
|
+
if (!jsonString.trim()) {
|
|
95
|
+
throw new Error(`${jsonString} is empty`);
|
|
96
|
+
}
|
|
97
|
+
return _parseJSON(jsonString.trim(), allowPartial);
|
|
98
|
+
}
|
|
99
|
+
exports.parseJSON = parseJSON;
|
|
100
|
+
var _parseJSON = (jsonString, allow) => {
|
|
101
|
+
const length = jsonString.length;
|
|
102
|
+
let index = 0;
|
|
103
|
+
const markPartialJSON = (msg) => {
|
|
104
|
+
throw new PartialJSON(`${msg} at position ${index}`);
|
|
105
|
+
};
|
|
106
|
+
const throwMalformedError = (msg) => {
|
|
107
|
+
throw new MalformedJSON(`${msg} at position ${index}`);
|
|
108
|
+
};
|
|
109
|
+
const parseAny = () => {
|
|
110
|
+
skipBlank();
|
|
111
|
+
if (index >= length)
|
|
112
|
+
markPartialJSON("Unexpected end of input");
|
|
113
|
+
if (jsonString[index] === '"')
|
|
114
|
+
return parseStr();
|
|
115
|
+
if (jsonString[index] === "{")
|
|
116
|
+
return parseObj();
|
|
117
|
+
if (jsonString[index] === "[")
|
|
118
|
+
return parseArr();
|
|
119
|
+
if (jsonString.substring(index, index + 4) === "null" || options_1.Allow.NULL & allow && length - index < 4 && "null".startsWith(jsonString.substring(index))) {
|
|
120
|
+
index += 4;
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (jsonString.substring(index, index + 4) === "true" || options_1.Allow.BOOL & allow && length - index < 4 && "true".startsWith(jsonString.substring(index))) {
|
|
124
|
+
index += 4;
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
if (jsonString.substring(index, index + 5) === "false" || options_1.Allow.BOOL & allow && length - index < 5 && "false".startsWith(jsonString.substring(index))) {
|
|
128
|
+
index += 5;
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (jsonString.substring(index, index + 8) === "Infinity" || options_1.Allow.INFINITY & allow && length - index < 8 && "Infinity".startsWith(jsonString.substring(index))) {
|
|
132
|
+
index += 8;
|
|
133
|
+
return Infinity;
|
|
134
|
+
}
|
|
135
|
+
if (jsonString.substring(index, index + 9) === "-Infinity" || options_1.Allow._INFINITY & allow && 1 < length - index && length - index < 9 && "-Infinity".startsWith(jsonString.substring(index))) {
|
|
136
|
+
index += 9;
|
|
137
|
+
return -Infinity;
|
|
138
|
+
}
|
|
139
|
+
if (jsonString.substring(index, index + 3) === "NaN" || options_1.Allow.NAN & allow && length - index < 3 && "NaN".startsWith(jsonString.substring(index))) {
|
|
140
|
+
index += 3;
|
|
141
|
+
return NaN;
|
|
142
|
+
}
|
|
143
|
+
return parseNum();
|
|
144
|
+
};
|
|
145
|
+
const parseStr = () => {
|
|
146
|
+
const start = index;
|
|
147
|
+
let escape = false;
|
|
148
|
+
index++;
|
|
149
|
+
while (index < length && (jsonString[index] !== '"' || escape && jsonString[index - 1] === "\\")) {
|
|
150
|
+
escape = jsonString[index] === "\\" ? !escape : false;
|
|
151
|
+
index++;
|
|
152
|
+
}
|
|
153
|
+
if (jsonString.charAt(index) == '"') {
|
|
154
|
+
try {
|
|
155
|
+
return JSON.parse(jsonString.substring(start, ++index - Number(escape)));
|
|
156
|
+
} catch (e) {
|
|
157
|
+
throwMalformedError(String(e));
|
|
158
|
+
}
|
|
159
|
+
} else if (options_1.Allow.STR & allow) {
|
|
160
|
+
try {
|
|
161
|
+
return JSON.parse(jsonString.substring(start, index - Number(escape)) + '"');
|
|
162
|
+
} catch (e) {
|
|
163
|
+
return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("\\")) + '"');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
markPartialJSON("Unterminated string literal");
|
|
167
|
+
};
|
|
168
|
+
const parseObj = () => {
|
|
169
|
+
index++;
|
|
170
|
+
skipBlank();
|
|
171
|
+
const obj = {};
|
|
172
|
+
try {
|
|
173
|
+
while (jsonString[index] !== "}") {
|
|
174
|
+
skipBlank();
|
|
175
|
+
if (index >= length && options_1.Allow.OBJ & allow)
|
|
176
|
+
return obj;
|
|
177
|
+
const key = parseStr();
|
|
178
|
+
skipBlank();
|
|
179
|
+
index++;
|
|
180
|
+
try {
|
|
181
|
+
const value = parseAny();
|
|
182
|
+
obj[key] = value;
|
|
183
|
+
} catch (e) {
|
|
184
|
+
if (options_1.Allow.OBJ & allow)
|
|
185
|
+
return obj;
|
|
186
|
+
else
|
|
187
|
+
throw e;
|
|
188
|
+
}
|
|
189
|
+
skipBlank();
|
|
190
|
+
if (jsonString[index] === ",")
|
|
191
|
+
index++;
|
|
192
|
+
}
|
|
193
|
+
} catch (e) {
|
|
194
|
+
if (options_1.Allow.OBJ & allow)
|
|
195
|
+
return obj;
|
|
196
|
+
else
|
|
197
|
+
markPartialJSON("Expected '}' at end of object");
|
|
198
|
+
}
|
|
199
|
+
index++;
|
|
200
|
+
return obj;
|
|
201
|
+
};
|
|
202
|
+
const parseArr = () => {
|
|
203
|
+
index++;
|
|
204
|
+
const arr = [];
|
|
205
|
+
try {
|
|
206
|
+
while (jsonString[index] !== "]") {
|
|
207
|
+
arr.push(parseAny());
|
|
208
|
+
skipBlank();
|
|
209
|
+
if (jsonString[index] === ",") {
|
|
210
|
+
index++;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (e) {
|
|
214
|
+
if (options_1.Allow.ARR & allow) {
|
|
215
|
+
return arr;
|
|
216
|
+
}
|
|
217
|
+
markPartialJSON("Expected ']' at end of array");
|
|
218
|
+
}
|
|
219
|
+
index++;
|
|
220
|
+
return arr;
|
|
221
|
+
};
|
|
222
|
+
const parseNum = () => {
|
|
223
|
+
if (index === 0) {
|
|
224
|
+
if (jsonString === "-")
|
|
225
|
+
throwMalformedError("Not sure what '-' is");
|
|
226
|
+
try {
|
|
227
|
+
return JSON.parse(jsonString);
|
|
228
|
+
} catch (e) {
|
|
229
|
+
if (options_1.Allow.NUM & allow)
|
|
230
|
+
try {
|
|
231
|
+
return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
|
|
232
|
+
} catch (e2) {
|
|
233
|
+
}
|
|
234
|
+
throwMalformedError(String(e));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const start = index;
|
|
238
|
+
if (jsonString[index] === "-")
|
|
239
|
+
index++;
|
|
240
|
+
while (jsonString[index] && ",]}".indexOf(jsonString[index]) === -1)
|
|
241
|
+
index++;
|
|
242
|
+
if (index == length && !(options_1.Allow.NUM & allow))
|
|
243
|
+
markPartialJSON("Unterminated number literal");
|
|
244
|
+
try {
|
|
245
|
+
return JSON.parse(jsonString.substring(start, index));
|
|
246
|
+
} catch (e) {
|
|
247
|
+
if (jsonString.substring(start, index) === "-")
|
|
248
|
+
markPartialJSON("Not sure what '-' is");
|
|
249
|
+
try {
|
|
250
|
+
return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("e")));
|
|
251
|
+
} catch (e2) {
|
|
252
|
+
throwMalformedError(String(e2));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const skipBlank = () => {
|
|
257
|
+
while (index < length && " \n\r ".includes(jsonString[index])) {
|
|
258
|
+
index++;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
return parseAny();
|
|
262
|
+
};
|
|
263
|
+
var parse = parseJSON;
|
|
264
|
+
exports.parse = parse;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json
|
|
269
|
+
var cloudflare_ai_gateway_default = { "anthropic-messages": { "claude-fable-5": { id: "claude-fable-5", name: "Claude Fable 5", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true }, thinkingLevelMap: { off: null, xhigh: "xhigh", max: "max" } }, "claude-fable-5.1": { id: "claude-fable-5.1", name: "Claude Fable 5.1", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 0.25, cacheWrite: 12.5 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true }, thinkingLevelMap: { off: null, xhigh: "xhigh", max: "max" } }, "claude-haiku-4.5": { id: "claude-haiku-4.5", name: "Claude Haiku 4.5 (latest)", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 }, contextWindow: 2e5, maxTokens: 64e3, compat: { sendSessionAffinityHeaders: true } }, "claude-opus-4.5": { id: "claude-opus-4.5", name: "Claude Opus 4.5 (latest)", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 2e5, maxTokens: 64e3, compat: { sendSessionAffinityHeaders: true } }, "claude-opus-4.6": { id: "claude-opus-4.6", name: "Claude Opus 4.6", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true }, thinkingLevelMap: { max: "max" } }, "claude-opus-4.7": { id: "claude-opus-4.7", name: "Claude Opus 4.7", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true, supportsTemperature: false }, thinkingLevelMap: { xhigh: "xhigh", max: "max" } }, "claude-opus-4.8": { id: "claude-opus-4.8", name: "Claude Opus 4.8", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true, supportsTemperature: false }, thinkingLevelMap: { xhigh: "xhigh", max: "max" } }, "claude-opus-5": { id: "claude-opus-5", name: "Claude Opus 5", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true, supportsTemperature: false }, thinkingLevelMap: { xhigh: "xhigh", max: "max" } }, "claude-sonnet-4.5": { id: "claude-sonnet-4.5", name: "Claude Sonnet 4.5 (latest)", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, contextWindow: 1e6, maxTokens: 64e3, compat: { sendSessionAffinityHeaders: true } }, "claude-sonnet-4.6": { id: "claude-sonnet-4.6", name: "Claude Sonnet 4.6", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true }, thinkingLevelMap: { max: "max" } }, "claude-sonnet-5": { id: "claude-sonnet-5", name: "Claude Sonnet 5", api: "anthropic-messages", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }, contextWindow: 1e6, maxTokens: 128e3, compat: { sendSessionAffinityHeaders: true, forceAdaptiveThinking: true }, thinkingLevelMap: { xhigh: "xhigh", max: "max" } } }, "openai-completions": { "workers-ai/@cf/deepseek-ai/deepseek-v4-flash-0731": { id: "workers-ai/@cf/deepseek-ai/deepseek-v4-flash-0731", name: "DeepSeek V4 Flash 0731", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 0.44, output: 1.32, cacheRead: 0.014, cacheWrite: 0 }, contextWindow: 1310720, maxTokens: 1048576, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true, requiresReasoningContentOnAssistantMessages: true, thinkingFormat: "deepseek" }, thinkingLevelMap: { minimal: null, low: null, medium: null, high: "high", max: "max" } }, "workers-ai/@cf/deepseek-ai/deepseek-v4-pro-0813": { id: "workers-ai/@cf/deepseek-ai/deepseek-v4-pro-0813", name: "DeepSeek V4 Pro 0813", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 1.32, output: 3.96, cacheRead: 0.044, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 1048576, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true, requiresReasoningContentOnAssistantMessages: true, thinkingFormat: "deepseek" }, thinkingLevelMap: { minimal: null, low: null, medium: null, high: "high", max: "max" } }, "workers-ai/@cf/google/gemma-4-26b-a4b-it": { id: "workers-ai/@cf/google/gemma-4-26b-a4b-it", name: "Gemma 4 26B A4B IT", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text", "image"], cost: { input: 0.1, output: 0.3, cacheRead: 0, cacheWrite: 0 }, contextWindow: 256e3, maxTokens: 16384, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/ibm-granite/granite-4.0-h-micro": { id: "workers-ai/@cf/ibm-granite/granite-4.0-h-micro", name: "Granite 4.0 H Micro", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: false, input: ["text"], cost: { input: 0.017, output: 0.112, cacheRead: 0, cacheWrite: 0 }, contextWindow: 131e3, maxTokens: 131e3, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast": { id: "workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast", name: "Llama 3.3 70B Instruct fp8 Fast", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: false, input: ["text"], cost: { input: 0.293, output: 2.253, cacheRead: 0, cacheWrite: 0 }, contextWindow: 24e3, maxTokens: 24e3, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/meta/llama-4-scout-17b-16e-instruct": { id: "workers-ai/@cf/meta/llama-4-scout-17b-16e-instruct", name: "Llama 4 Scout 17B 16E Instruct", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: false, input: ["text", "image"], cost: { input: 0.27, output: 0.85, cacheRead: 0, cacheWrite: 0 }, contextWindow: 131e3, maxTokens: 16384, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/mistralai/mistral-small-3.1-24b-instruct": { id: "workers-ai/@cf/mistralai/mistral-small-3.1-24b-instruct", name: "Mistral Small 3.1 24B Instruct", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: false, input: ["text"], cost: { input: 0.351, output: 0.555, cacheRead: 0, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 128e3, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/moonshotai/kimi-k2.6": { id: "workers-ai/@cf/moonshotai/kimi-k2.6", name: "Kimi K2.6", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text", "image"], cost: { input: 0.95, output: 4, cacheRead: 0.16, cacheWrite: 0 }, contextWindow: 262144, maxTokens: 256e3, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/moonshotai/kimi-k2.7-code": { id: "workers-ai/@cf/moonshotai/kimi-k2.7-code", name: "Kimi K2.7 Code", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text", "image"], cost: { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 }, contextWindow: 262144, maxTokens: 262144, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/nvidia/nemotron-3-120b-a12b": { id: "workers-ai/@cf/nvidia/nemotron-3-120b-a12b", name: "Nemotron 3 Super 120B", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 0.5, output: 1.5, cacheRead: 0, cacheWrite: 0 }, contextWindow: 256e3, maxTokens: 256e3, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/openai/gpt-oss-120b": { id: "workers-ai/@cf/openai/gpt-oss-120b", name: "GPT OSS 120B", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 0.35, output: 0.75, cacheRead: 0, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/openai/gpt-oss-20b": { id: "workers-ai/@cf/openai/gpt-oss-20b", name: "GPT OSS 20B", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 0.2, output: 0.3, cacheRead: 0, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/qwen/qwen3-30b-a3b-fp8": { id: "workers-ai/@cf/qwen/qwen3-30b-a3b-fp8", name: "Qwen3 30B A3b fp8", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 0.0509, output: 0.335, cacheRead: 0, cacheWrite: 0 }, contextWindow: 32768, maxTokens: 32768, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/qwen/qwen3.8-27b": { id: "workers-ai/@cf/qwen/qwen3.8-27b", name: "Qwen3.8 27B", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text", "image"], cost: { input: 0.45, output: 3.2, cacheRead: 0.05, cacheWrite: 0 }, contextWindow: 262144, maxTokens: 262144, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/zai-org/glm-4.7-flash": { id: "workers-ai/@cf/zai-org/glm-4.7-flash", name: "GLM-4.7-Flash", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 0.0605, output: 0.4, cacheRead: 0, cacheWrite: 0 }, contextWindow: 131072, maxTokens: 131072, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/zai-org/glm-5.2": { id: "workers-ai/@cf/zai-org/glm-5.2", name: "Glm 5.2", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, contextWindow: 262144, maxTokens: 256e3, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/zai-org/glm-5.3": { id: "workers-ai/@cf/zai-org/glm-5.3", name: "Glm 5.3", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, contextWindow: 1310720, maxTokens: 1310720, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } }, "workers-ai/@cf/zai-org/glm-5.3-flash": { id: "workers-ai/@cf/zai-org/glm-5.3-flash", name: "Glm 5.3 Flash", api: "openai-completions", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat", reasoning: true, input: ["text", "image"], cost: { input: 0.15, output: 0.5, cacheRead: 0.03, cacheWrite: 0 }, contextWindow: 1310720, maxTokens: 1048576, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsStrictMode: false, supportsLongCacheRetention: false, sendSessionAffinityHeaders: true } } }, "openai-responses": { "gpt-4.1": { id: "gpt-4.1", name: "GPT-4.1", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: false, input: ["text", "image"], cost: { input: 2, output: 8, cacheRead: 0.5, cacheWrite: 0 }, contextWindow: 1047576, maxTokens: 32768, compat: { supportsStrictMode: true } }, "gpt-4.1-mini": { id: "gpt-4.1-mini", name: "GPT-4.1 mini", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: false, input: ["text", "image"], cost: { input: 0.4, output: 1.6, cacheRead: 0.1, cacheWrite: 0 }, contextWindow: 1047576, maxTokens: 32768, compat: { supportsStrictMode: true } }, "gpt-4.1-nano": { id: "gpt-4.1-nano", name: "GPT-4.1 nano", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: false, input: ["text", "image"], cost: { input: 0.1, output: 0.4, cacheRead: 0.025, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 32768, compat: { supportsStrictMode: true } }, "gpt-4o": { id: "gpt-4o", name: "GPT-4o", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: false, input: ["text", "image"], cost: { input: 1.25, output: 5, cacheRead: 0.625, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStrictMode: true } }, "gpt-4o-mini": { id: "gpt-4o-mini", name: "GPT-4o mini", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: false, input: ["text", "image"], cost: { input: 0.075, output: 0.3, cacheRead: 0.0375, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStrictMode: true } }, "gpt-5": { id: "gpt-5", name: "GPT-5", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5-mini": { id: "gpt-5-mini", name: "GPT-5 Mini", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5-nano": { id: "gpt-5-nano", name: "GPT-5 Nano", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 0.05, output: 0.4, cacheRead: 5e-3, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.1": { id: "gpt-5.1", name: "GPT-5.1", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.4": { id: "gpt-5.4", name: "GPT-5.4", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.4-mini": { id: "gpt-5.4-mini", name: "GPT-5.4 mini", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.4-nano": { id: "gpt-5.4-nano", name: "GPT-5.4 nano", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.25, cacheRead: 0.02, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.4-pro": { id: "gpt-5.4-pro", name: "GPT-5.4 Pro", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 30, output: 180, cacheRead: 0, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.5": { id: "gpt-5.5", name: "GPT-5.5", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 30, cacheRead: 0, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.5-pro": { id: "gpt-5.5-pro", name: "GPT-5.5 Pro", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 30, output: 180, cacheRead: 0, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.6-luna": { id: "gpt-5.6-luna", name: "GPT-5.6 Luna", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25, tiers: [{ inputTokensAbove: 272e3, input: 0.4, output: 1.8, cacheRead: 0.04, cacheWrite: 0.5 }] }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.6-sol": { id: "gpt-5.6-sol", name: "GPT-5.6 Sol", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 10, cacheRead: 0.25, cacheWrite: 3.125 }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.6-terra": { id: "gpt-5.6-terra", name: "GPT-5.6 Terra", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 2.5, tiers: [{ inputTokensAbove: 272e3, input: 4, output: 18, cacheRead: 0.4, cacheWrite: 5 }] }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, o3: { id: "o3", name: "o3", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 8, cacheRead: 0.5, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } }, "o3-mini": { id: "o3-mini", name: "o3-mini", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text"], cost: { input: 1.1, output: 4.4, cacheRead: 0.55, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } }, "o4-mini": { id: "o4-mini", name: "o4-mini", api: "openai-responses", provider: "cloudflare-ai-gateway", baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai", reasoning: true, input: ["text", "image"], cost: { input: 1.1, output: 4.4, cacheRead: 0.275, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } } } };
|
|
270
|
+
|
|
271
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/model-catalog.js
|
|
272
|
+
function flattenModelCatalog(_provider, groups) {
|
|
273
|
+
return Object.assign({}, ...Object.values(groups));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js
|
|
277
|
+
var CLOUDFLARE_AI_GATEWAY_MODELS = flattenModelCatalog("cloudflare-ai-gateway", cloudflare_ai_gateway_default);
|
|
278
|
+
|
|
279
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json
|
|
280
|
+
var github_copilot_default = { "anthropic-messages": { "claude-fable-5": { id: "claude-fable-5", name: "Claude Fable 5", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 }, contextWindow: 1e6, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true } }, "claude-fable-5.1": { id: "claude-fable-5.1", name: "Claude Fable 5.1", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 0.25, cacheWrite: 12.5 }, contextWindow: 1e6, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true } }, "claude-haiku-4.5": { id: "claude-haiku-4.5", name: "Claude Haiku 4.5 (latest)", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 }, contextWindow: 2e5, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsEagerToolInputStreaming: false } }, "claude-opus-4.7": { id: "claude-opus-4.7", name: "Claude Opus 4.7", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 32e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { xhigh: "xhigh", max: "max", minimal: "low" }, compat: { forceAdaptiveThinking: true, supportsTemperature: false } }, "claude-opus-4.8": { id: "claude-opus-4.8", name: "Claude Opus 4.8", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { xhigh: "xhigh", max: "max", minimal: "low" }, compat: { forceAdaptiveThinking: true, supportsTemperature: false } }, "claude-opus-5": { id: "claude-opus-5", name: "Claude Opus 5", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { xhigh: "xhigh", max: "max", minimal: "low" }, compat: { forceAdaptiveThinking: true, supportsTemperature: false } }, "claude-sonnet-4.6": { id: "claude-sonnet-4.6", name: "Claude Sonnet 4.6", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, contextWindow: 1e6, maxTokens: 32e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { max: "max", minimal: "low" }, compat: { forceAdaptiveThinking: true } }, "claude-sonnet-5": { id: "claude-sonnet-5", name: "Claude Sonnet 5", api: "anthropic-messages", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }, contextWindow: 1e6, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true } } }, "openai-completions": { "gemini-3.5-flash": { id: "gemini-3.5-flash", name: "Gemini 3.5 Flash", api: "openai-completions", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 1.5, output: 9, cacheRead: 0.15, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false } }, "gemini-3.6-flash": { id: "gemini-3.6-flash", name: "Gemini 3.6 Flash", api: "openai-completions", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false } }, "gemini-3.7-flash": { id: "gemini-3.7-flash", name: "Gemini 3.7 Flash", api: "openai-completions", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false } }, "gemini-3.8-flash": { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash", api: "openai-completions", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false } }, "gpt-6-astra": { id: "gpt-6-astra", name: "GPT-6 Astra", api: "openai-completions", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5, tiers: [{ inputTokensAbove: 272e3, input: 20, output: 75, cacheRead: 2, cacheWrite: 25 }] }, contextWindow: 105e4, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false }, thinkingLevelMap: { xhigh: "xhigh", max: "max" } }, "kimi-k2.7-code": { id: "kimi-k2.7-code", name: "Kimi K2.7 Code", api: "openai-completions", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 }, contextWindow: 256e3, maxTokens: 32e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false } }, "kimi-k3": { id: "kimi-k3", name: "Kimi K3", api: "openai-completions", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 131072, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false } } }, "openai-responses": { "gpt-5-mini": { id: "gpt-5-mini", name: "GPT-5 Mini", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0 }, contextWindow: 264e3, maxTokens: 64e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.3-codex": { id: "gpt-5.3-codex", name: "GPT-5.3 Codex", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.4": { id: "gpt-5.4", name: "GPT-5.4", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0, tiers: [{ inputTokensAbove: 272e3, input: 5, output: 22.5, cacheRead: 0.5, cacheWrite: 0 }] }, contextWindow: 1e6, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.4-mini": { id: "gpt-5.4-mini", name: "GPT-5.4 mini", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.4-nano": { id: "gpt-5.4-nano", name: "GPT-5.4 nano", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.25, cacheRead: 0.02, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", xhigh: "xhigh" }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.5": { id: "gpt-5.5", name: "GPT-5.5", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0, tiers: [{ inputTokensAbove: 272e3, input: 10, output: 45, cacheRead: 1, cacheWrite: 0 }] }, contextWindow: 1e6, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.6-luna": { id: "gpt-5.6-luna", name: "GPT-5.6 Luna", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25, tiers: [{ inputTokensAbove: 2e5, input: 0.4, output: 1.8, cacheRead: 0.04, cacheWrite: 0.5 }] }, contextWindow: 105e4, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.6-sol": { id: "gpt-5.6-sol", name: "GPT-5.6 Sol", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 4, output: 20, cacheRead: 0.4, cacheWrite: 5, tiers: [{ inputTokensAbove: 272e3, input: 8, output: 30, cacheRead: 0.8, cacheWrite: 10 }] }, contextWindow: 105e4, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsOpenAIGrammarTools: true } }, "gpt-5.6-terra": { id: "gpt-5.6-terra", name: "GPT-5.6 Terra", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 2.5, tiers: [{ inputTokensAbove: 272e3, input: 4, output: 18, cacheRead: 0.4, cacheWrite: 5 }] }, contextWindow: 105e4, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: "low", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsOpenAIGrammarTools: true } }, "grok-4.5": { id: "grok-4.5", name: "Grok 4.5", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0, tiers: [{ inputTokensAbove: 2e5, input: 4, output: 12, cacheRead: 1, cacheWrite: 0 }] }, contextWindow: 5e5, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "grok-4.6": { id: "grok-4.6", name: "Grok 4.6", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0, tiers: [{ inputTokensAbove: 2e5, input: 4, output: 12, cacheRead: 1, cacheWrite: 0 }] }, contextWindow: 5e5, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "mai-code-1-flash-picker": { id: "mai-code-1-flash-picker", name: "MAI-Code-1-Flash", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text"], cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 256e3, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "mai-code-1.1-flash": { id: "mai-code-1.1-flash", name: "MAI-Code-1.1-Flash", api: "openai-responses", provider: "github-copilot", baseUrl: "https://api.individual.githubcopilot.com", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0 }, contextWindow: 256e3, maxTokens: 128e3, headers: { "User-Agent": "GitHubCopilotChat/0.35.0", "Editor-Version": "vscode/1.107.0", "Editor-Plugin-Version": "copilot-chat/0.35.0", "Copilot-Integration-Id": "vscode-chat" }, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } } } };
|
|
281
|
+
|
|
282
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js
|
|
283
|
+
var GITHUB_COPILOT_MODELS = flattenModelCatalog("github-copilot", github_copilot_default);
|
|
284
|
+
|
|
285
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json
|
|
286
|
+
var openai_default = { "openai-responses": { "gpt-4": { id: "gpt-4", name: "GPT-4", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text"], cost: { input: 30, output: 60, cacheRead: 0, cacheWrite: 0 }, contextWindow: 8192, maxTokens: 8192, compat: { supportsStrictMode: true } }, "gpt-4-turbo": { id: "gpt-4-turbo", name: "GPT-4 Turbo", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 10, output: 30, cacheRead: 0, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 4096, compat: { supportsStrictMode: true } }, "gpt-4.1": { id: "gpt-4.1", name: "GPT-4.1", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 2, output: 8, cacheRead: 0.5, cacheWrite: 0 }, contextWindow: 1047576, maxTokens: 32768, compat: { supportsStrictMode: true } }, "gpt-4.1-mini": { id: "gpt-4.1-mini", name: "GPT-4.1 mini", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 0.4, output: 1.6, cacheRead: 0.1, cacheWrite: 0 }, contextWindow: 1047576, maxTokens: 32768, compat: { supportsStrictMode: true } }, "gpt-4.1-nano": { id: "gpt-4.1-nano", name: "GPT-4.1 nano", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 0.1, output: 0.4, cacheRead: 0.025, cacheWrite: 0 }, contextWindow: 1047576, maxTokens: 32768, compat: { supportsStrictMode: true } }, "gpt-4o": { id: "gpt-4o", name: "GPT-4o", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 2.5, output: 10, cacheRead: 1.25, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStrictMode: true } }, "gpt-4o-2024-05-13": { id: "gpt-4o-2024-05-13", name: "GPT-4o (2024-05-13)", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 5, output: 15, cacheRead: 0, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 4096, compat: { supportsStrictMode: true } }, "gpt-4o-2024-08-06": { id: "gpt-4o-2024-08-06", name: "GPT-4o (2024-08-06)", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 2.5, output: 10, cacheRead: 1.25, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStrictMode: true } }, "gpt-4o-2024-11-20": { id: "gpt-4o-2024-11-20", name: "GPT-4o (2024-11-20)", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 2.5, output: 10, cacheRead: 1.25, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStrictMode: true } }, "gpt-4o-mini": { id: "gpt-4o-mini", name: "GPT-4o mini", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 0.15, output: 0.6, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, compat: { supportsStrictMode: true } }, "gpt-5": { id: "gpt-5", name: "GPT-5", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5-chat-latest": { id: "gpt-5-chat-latest", name: "GPT-5 Chat Latest", api: "openai-responses", baseUrl: "https://api.openai.com/v1", provider: "openai", reasoning: false, input: ["text", "image"], cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, thinkingLevelMap: { off: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5-mini": { id: "gpt-5-mini", name: "GPT-5 Mini", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5-nano": { id: "gpt-5-nano", name: "GPT-5 Nano", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.05, output: 0.4, cacheRead: 5e-3, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5-pro": { id: "gpt-5-pro", name: "GPT-5 Pro", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 15, output: 120, cacheRead: 0, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: null, high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.1": { id: "gpt-5.1", name: "GPT-5.1", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.2": { id: "gpt-5.2", name: "GPT-5.2", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.2-chat-latest": { id: "gpt-5.2-chat-latest", name: "GPT-5.2 Chat", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: null, xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.2-pro": { id: "gpt-5.2-pro", name: "GPT-5.2 Pro", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 21, output: 168, cacheRead: 0, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.3-chat-latest": { id: "gpt-5.3-chat-latest", name: "GPT-5.3 Chat (latest)", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: false, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 16384, thinkingLevelMap: { off: null, xhigh: "xhigh" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.3-codex": { id: "gpt-5.3-codex", name: "GPT-5.3 Codex", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.3-codex-spark": { id: "gpt-5.3-codex-spark", name: "GPT-5.3 Codex Spark", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 32e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.4": { id: "gpt-5.4", name: "GPT-5.4", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0, tiers: [{ inputTokensAbove: 272e3, input: 5, output: 22.5, cacheRead: 0.5, cacheWrite: 0 }] }, contextWindow: 272e3, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true } }, "gpt-5.4-mini": { id: "gpt-5.4-mini", name: "GPT-5.4 mini", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true } }, "gpt-5.4-nano": { id: "gpt-5.4-nano", name: "GPT-5.4 nano", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.25, cacheRead: 0.02, cacheWrite: 0 }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.4-pro": { id: "gpt-5.4-pro", name: "GPT-5.4 Pro", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 30, output: 180, cacheRead: 0, cacheWrite: 0, tiers: [{ inputTokensAbove: 272e3, input: 60, output: 270, cacheRead: 0, cacheWrite: 0 }] }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true } }, "gpt-5.5": { id: "gpt-5.5", name: "GPT-5.5", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0, tiers: [{ inputTokensAbove: 272e3, input: 10, output: 45, cacheRead: 1, cacheWrite: 0 }] }, contextWindow: 272e3, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true } }, "gpt-5.5-pro": { id: "gpt-5.5-pro", name: "GPT-5.5 Pro", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 30, output: 180, cacheRead: 0, cacheWrite: 0, tiers: [{ inputTokensAbove: 272e3, input: 60, output: 270, cacheRead: 0, cacheWrite: 0 }] }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true } }, "gpt-5.6-luna": { id: "gpt-5.6-luna", name: "GPT-5.6 Luna", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25, tiers: [{ inputTokensAbove: 272e3, input: 0.4, output: 1.8, cacheRead: 0.04, cacheWrite: 0.5 }] }, contextWindow: 272e3, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true, supportsExplicitPromptCacheMode: true } }, "gpt-5.6-sol": { id: "gpt-5.6-sol", name: "GPT-5.6 Sol", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 4, output: 20, cacheRead: 0.4, cacheWrite: 5, tiers: [{ inputTokensAbove: 272e3, input: 8, output: 30, cacheRead: 0.8, cacheWrite: 10 }] }, contextWindow: 272e3, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true, supportsExplicitPromptCacheMode: true } }, "gpt-5.6-terra": { id: "gpt-5.6-terra", name: "GPT-5.6 Terra", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 2.5, tiers: [{ inputTokensAbove: 272e3, input: 4, output: 18, cacheRead: 0.4, cacheWrite: 5 }] }, contextWindow: 272e3, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true, supportsExplicitPromptCacheMode: true } }, "gpt-6-astra": { id: "gpt-6-astra", name: "GPT-6 Astra", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5, tiers: [{ inputTokensAbove: 272e3, input: 20, output: 75, cacheRead: 2, cacheWrite: 25 }] }, contextWindow: 272e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, compat: { supportsStrictMode: true, supportsOpenAIGrammarTools: true, supportsAdditionalTools: true, supportsToolSearch: true, supportsExplicitPromptCacheMode: true } }, "gpt-realtime-2.1": { id: "gpt-realtime-2.1", name: "GPT-Realtime-2.1", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 4, output: 24, cacheRead: 0.4, cacheWrite: 0 }, contextWindow: 128e3, maxTokens: 32e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null }, compat: { supportsStrictMode: true } }, o1: { id: "o1", name: "o1", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 15, output: 60, cacheRead: 7.5, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } }, "o1-pro": { id: "o1-pro", name: "o1-pro", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 150, output: 600, cacheRead: 0, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } }, o3: { id: "o3", name: "o3", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 8, cacheRead: 0.5, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } }, "o3-mini": { id: "o3-mini", name: "o3-mini", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text"], cost: { input: 1.1, output: 4.4, cacheRead: 0.55, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } }, "o3-pro": { id: "o3-pro", name: "o3-pro", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 20, output: 80, cacheRead: 0, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } }, "o4-mini": { id: "o4-mini", name: "o4-mini", api: "openai-responses", provider: "openai", baseUrl: "https://api.openai.com/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.1, output: 4.4, cacheRead: 0.275, cacheWrite: 0 }, contextWindow: 2e5, maxTokens: 1e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null }, compat: { supportsStrictMode: true } } } };
|
|
287
|
+
|
|
288
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js
|
|
289
|
+
var OPENAI_MODELS = flattenModelCatalog("openai", openai_default);
|
|
290
|
+
|
|
291
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json
|
|
292
|
+
var opencode_default = { "anthropic-messages": { "claude-fable-5": { id: "claude-fable-5", name: "Claude Fable 5", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { off: null, xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true } }, "claude-fable-5-1": { id: "claude-fable-5-1", name: "Claude Fable 5.1", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 0.25, cacheWrite: 12.5 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { off: null, xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true } }, "claude-haiku-4-5": { id: "claude-haiku-4-5", name: "Claude Haiku 4.5", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 }, contextWindow: 2e5, maxTokens: 64e3 }, "claude-opus-4-5": { id: "claude-opus-4-5", name: "Claude Opus 4.5", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 2e5, maxTokens: 64e3 }, "claude-opus-4-6": { id: "claude-opus-4-6", name: "Claude Opus 4.6", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { max: "max" }, compat: { forceAdaptiveThinking: true } }, "claude-opus-4-7": { id: "claude-opus-4-7", name: "Claude Opus 4.7", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true, supportsTemperature: false } }, "claude-opus-4-8": { id: "claude-opus-4-8", name: "Claude Opus 4.8", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true, supportsTemperature: false } }, "claude-opus-5": { id: "claude-opus-5", name: "Claude Opus 5", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true, supportsTemperature: false } }, "claude-sonnet-4": { id: "claude-sonnet-4", name: "Claude Sonnet 4", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, contextWindow: 2e5, maxTokens: 64e3 }, "claude-sonnet-4-5": { id: "claude-sonnet-4-5", name: "Claude Sonnet 4.5", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, contextWindow: 2e5, maxTokens: 64e3 }, "claude-sonnet-4-6": { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, contextWindow: 1e6, maxTokens: 64e3, thinkingLevelMap: { max: "max" }, compat: { forceAdaptiveThinking: true } }, "claude-sonnet-5": { id: "claude-sonnet-5", name: "Claude Sonnet 5", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }, contextWindow: 1e6, maxTokens: 128e3, thinkingLevelMap: { xhigh: "xhigh", max: "max" }, compat: { forceAdaptiveThinking: true } }, "qwen3.5-plus": { id: "qwen3.5-plus", name: "Qwen3.5 Plus", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25 }, contextWindow: 262144, maxTokens: 65536 }, "qwen3.6-plus": { id: "qwen3.6-plus", name: "Qwen3.6 Plus", api: "anthropic-messages", provider: "opencode", baseUrl: "https://opencode.ai/zen", reasoning: true, input: ["text", "image"], cost: { input: 0.5, output: 3, cacheRead: 0.05, cacheWrite: 0.625 }, contextWindow: 262144, maxTokens: 65536 } }, "google-generative-ai": { "gemini-3-flash": { id: "gemini-3-flash", name: "Gemini 3 Flash", api: "google-generative-ai", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.5, output: 3, cacheRead: 0.05, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 65536, thinkingLevelMap: { off: null } }, "gemini-3.1-pro": { id: "gemini-3.1-pro", name: "Gemini 3.1 Pro Preview", api: "google-generative-ai", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 65536, thinkingLevelMap: { off: null, minimal: null, low: "LOW", medium: null, high: "HIGH" } }, "gemini-3.5-flash": { id: "gemini-3.5-flash", name: "Gemini 3.5 Flash", api: "google-generative-ai", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.5, output: 9, cacheRead: 0.15, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 65536, thinkingLevelMap: { off: null } }, "gemini-3.5-flash-lite": { id: "gemini-3.5-flash-lite", name: "Gemini 3.5 Flash Lite", api: "google-generative-ai", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.3, output: 2.5, cacheRead: 0.03, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 65536, thinkingLevelMap: { off: null } }, "gemini-3.6-flash": { id: "gemini-3.6-flash", name: "Gemini 3.6 Flash", api: "google-generative-ai", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 65536, thinkingLevelMap: { off: null } }, "gemini-3.7-flash": { id: "gemini-3.7-flash", name: "Gemini 3.7 Flash", api: "google-generative-ai", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 65536, thinkingLevelMap: { off: null } }, "gemini-3.8-flash": { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash", api: "google-generative-ai", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0 }, contextWindow: 1048576, maxTokens: 65536, thinkingLevelMap: { off: null } } }, "openai-completions": { "big-pickle": { id: "big-pickle", name: "Big Pickle", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 2e5, maxTokens: 32e3 }, "deepseek-v4-flash": { id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 0.14, output: 0.28, cacheRead: 0.028, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", supportsLongCacheRetention: false, requiresReasoningContentOnAssistantMessages: true }, contextWindow: 1e6, maxTokens: 384e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: "max" } }, "deepseek-v4-flash-vision-exp": { id: "deepseek-v4-flash-vision-exp", name: "DeepSeek V4 Flash Vision Exp", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.14, output: 0.28, cacheRead: 0.028, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", requiresReasoningContentOnAssistantMessages: true }, contextWindow: 1e6, maxTokens: 384e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: "max" } }, "deepseek-v4-pro": { id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 1.74, output: 3.84, cacheRead: 0.145, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", supportsLongCacheRetention: false, requiresReasoningContentOnAssistantMessages: true }, contextWindow: 1e6, maxTokens: 384e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: null, high: "high", xhigh: null, max: "max" } }, "glm-5": { id: "glm-5", name: "GLM-5", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 1, output: 3.2, cacheRead: 0.2, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 204800, maxTokens: 131072 }, "glm-5.1": { id: "glm-5.1", name: "GLM-5.1", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 204800, maxTokens: 131072 }, "glm-5.2": { id: "glm-5.2", name: "GLM-5.2", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: null, medium: null, high: "high", xhigh: null, max: "max" } }, "glm-5.3": { id: "glm-5.3", name: "GLM-5.3", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: "max" } }, "glm-5.3-flash": { id: "glm-5.3-flash", name: "GLM-5.3-Flash", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.15, output: 0.5, cacheRead: 0.03, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: "max" } }, "kimi-k2.5": { id: "kimi-k2.5", name: "Kimi K2.5", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.6, output: 3, cacheRead: 0.08, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", supportsLongCacheRetention: false }, contextWindow: 262144, maxTokens: 65536 }, "kimi-k2.6": { id: "kimi-k2.6", name: "Kimi K2.6", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.95, output: 4, cacheRead: 0.16, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, thinkingFormat: "deepseek", supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsLongCacheRetention: false }, contextWindow: 262144, maxTokens: 65536 }, "kimi-k2.7-code": { id: "kimi-k2.7-code", name: "Kimi K2.7 Code", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 262144, maxTokens: 262144 }, "kimi-k3": { id: "kimi-k3", name: "Kimi K3", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: null, medium: null, high: null, xhigh: null, max: "max" } }, "ling-3.0-flash-fin-free": { id: "ling-3.0-flash-fin-free", name: "Ling 3.0 Flash Fin Free", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 262144, maxTokens: 32768 }, "mimo-v2.5-free": { id: "mimo-v2.5-free", name: "MiMo V2.5 Free", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 2e5, maxTokens: 32e3 }, "minimax-m2.5": { id: "minimax-m2.5", name: "MiniMax-M2.5", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 204800, maxTokens: 131072 }, "minimax-m2.7": { id: "minimax-m2.7", name: "MiniMax-M2.7", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", supportsLongCacheRetention: false }, contextWindow: 204800, maxTokens: 131072 }, "minimax-m3": { id: "minimax-m3", name: "MiniMax-M3", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 512e3, maxTokens: 128e3 }, "nemotron-3-ultra-free": { id: "nemotron-3-ultra-free", name: "Nemotron 3 Ultra Free", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 128e3 }, "nemotron-3.5-lightning-free": { id: "nemotron-3.5-lightning-free", name: "Nemotron 3.5 Lightning Free", api: "openai-completions", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 262144, maxTokens: 262144 } }, "openai-responses": { "gpt-5": { id: "gpt-5", name: "GPT-5", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.07, output: 8.5, cacheRead: 0.107, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "gpt-5-codex": { id: "gpt-5-codex", name: "GPT-5 Codex", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.07, output: 8.5, cacheRead: 0.107, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "gpt-5-nano": { id: "gpt-5-nano", name: "GPT-5 Nano", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.05, output: 0.4, cacheRead: 5e-3, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "gpt-5.1": { id: "gpt-5.1", name: "GPT-5.1", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.07, output: 8.5, cacheRead: 0.107, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "gpt-5.1-codex": { id: "gpt-5.1-codex", name: "GPT-5.1 Codex", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.07, output: 8.5, cacheRead: 0.107, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "gpt-5.1-codex-max": { id: "gpt-5.1-codex-max", name: "GPT-5.1 Codex Max", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.1-codex-mini": { id: "gpt-5.1-codex-mini", name: "GPT-5.1 Codex Mini", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "gpt-5.2": { id: "gpt-5.2", name: "GPT-5.2", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.2-codex": { id: "gpt-5.2-codex", name: "GPT-5.2 Codex", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.3-codex": { id: "gpt-5.3-codex", name: "GPT-5.3 Codex", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.4": { id: "gpt-5.4", name: "GPT-5.4", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 272e3, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.4-mini": { id: "gpt-5.4-mini", name: "GPT-5.4 Mini", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.4-nano": { id: "gpt-5.4-nano", name: "GPT-5.4 Nano", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.25, cacheRead: 0.02, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 4e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.4-pro": { id: "gpt-5.4-pro", name: "GPT-5.4 Pro", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 30, output: 180, cacheRead: 30, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.5": { id: "gpt-5.5", name: "GPT-5.5", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.5-pro": { id: "gpt-5.5-pro", name: "GPT-5.5 Pro", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 30, output: 180, cacheRead: 30, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "gpt-5.6-luna": { id: "gpt-5.6-luna", name: "GPT-5.6 Luna", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" } }, "gpt-5.6-sol": { id: "gpt-5.6-sol", name: "GPT-5.6 Sol (50% Off)", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" } }, "gpt-5.6-terra": { id: "gpt-5.6-terra", name: "GPT-5.6 Terra", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 3.125 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" } }, "gpt-6-astra": { id: "gpt-6-astra", name: "GPT-6 Astra", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 }, compat: { sessionAffinityFormat: "openai-nosession", supportsOpenAIGrammarTools: true }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" } }, "grok-4.5": { id: "grok-4.5", name: "Grok 4.5", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.3, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 5e5, maxTokens: 5e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "grok-4.6": { id: "grok-4.6", name: "Grok 4.6", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 5e5, maxTokens: 5e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "grok-build-0.1": { id: "grok-build-0.1", name: "Grok Build 0.1", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1, output: 2, cacheRead: 0.2, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession", supportsReasoningEffort: false }, contextWindow: 256e3, maxTokens: 256e3, thinkingLevelMap: { off: null, minimal: null, low: null, medium: null } }, "muse-spark-1.2": { id: "muse-spark-1.2", name: "Muse Spark 1.2", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "muse-spark-1.2-contributor-free": { id: "muse-spark-1.2-contributor-free", name: "Muse Spark 1.2 Free", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "muse-spark-1.3": { id: "muse-spark-1.3", name: "Muse Spark 1.3", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" } }, "muse-spark-1.3-contributor-free": { id: "muse-spark-1.3-contributor-free", name: "Muse Spark 1.3 Free", api: "openai-responses", provider: "opencode", baseUrl: "https://opencode.ai/zen/v1", reasoning: true, input: ["text", "image"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } } } };
|
|
293
|
+
|
|
294
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js
|
|
295
|
+
var OPENCODE_MODELS = flattenModelCatalog("opencode", opencode_default);
|
|
296
|
+
|
|
297
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json
|
|
298
|
+
var opencode_go_default = { "anthropic-messages": { "minimax-m3": { id: "minimax-m3", name: "MiniMax-M3", api: "anthropic-messages", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go", reasoning: true, input: ["text", "image"], cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 131072 }, "qwen3.8-flash": { id: "qwen3.8-flash", name: "Qwen3.8 Flash", api: "anthropic-messages", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go", reasoning: true, input: ["text", "image"], cost: { input: 0.15, output: 0.47, cacheRead: 0.016, cacheWrite: 0.2 }, contextWindow: 1e6, maxTokens: 131072 } }, "openai-completions": { "deepseek-v4-flash": { id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 0.22, output: 0.66, cacheRead: 7e-3, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", requiresReasoningContentOnAssistantMessages: true, thinkingFormat: "deepseek" }, contextWindow: 1e6, maxTokens: 384e3, thinkingLevelMap: { minimal: null, low: "low", medium: null, high: "high", max: "max" } }, "deepseek-v4-flash-vision-exp": { id: "deepseek-v4-flash-vision-exp", name: "DeepSeek V4 Flash Vision Exp", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.22, output: 0.66, cacheRead: 7e-3, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", requiresReasoningContentOnAssistantMessages: true, thinkingFormat: "deepseek" }, contextWindow: 1e6, maxTokens: 384e3, thinkingLevelMap: { minimal: null, low: "low", medium: null, high: "high", max: "max" } }, "deepseek-v4-pro": { id: "deepseek-v4-pro", name: "DeepSeek V4 Pro (New)", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 0.66, output: 1.98, cacheRead: 0.022, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens", requiresReasoningContentOnAssistantMessages: true, thinkingFormat: "deepseek" }, contextWindow: 1e6, maxTokens: 384e3, thinkingLevelMap: { minimal: null, low: null, medium: null, high: "high", max: "max" } }, "glm-5.1": { id: "glm-5.1", name: "GLM-5.1", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 202752, maxTokens: 32768 }, "glm-5.2": { id: "glm-5.2", name: "GLM-5.2", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: null, medium: null, high: "high", xhigh: null, max: "max" } }, "glm-5.3": { id: "glm-5.3", name: "GLM-5.3", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: "max" } }, "glm-5.3-flash": { id: "glm-5.3-flash", name: "GLM-5.3-Flash (2x usage)", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.075, output: 0.25, cacheRead: 0.015, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: "max" } }, hy3: { id: "hy3", name: "Hy3", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 0.14, output: 0.58, cacheRead: 0.035, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 256e3, maxTokens: 128e3, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: null } }, "hy4-preview": { id: "hy4-preview", name: "Hy4 preview", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 0.834, output: 2.501, cacheRead: 0.042, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1024e3, maxTokens: 64e3, thinkingLevelMap: { off: "none", minimal: null, low: null, medium: null, high: "high", xhigh: null, max: null } }, "kimi-k2.6": { id: "kimi-k2.6", name: "Kimi K2.6", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.95, output: 4, cacheRead: 0.16, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, thinkingFormat: "deepseek", supportsReasoningEffort: false, maxTokensField: "max_tokens", supportsLongCacheRetention: false }, contextWindow: 262144, maxTokens: 65536, thinkingLevelMap: { minimal: null, low: null, medium: null } }, "kimi-k2.7-code": { id: "kimi-k2.7-code", name: "Kimi K2.7 Code", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 262144, maxTokens: 262144 }, "kimi-k3": { id: "kimi-k3", name: "Kimi K3", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: null, medium: null, high: null, xhigh: null, max: "max" } }, "longcat-2.0": { id: "longcat-2.0", name: "LongCat-2.0", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 0.3, output: 1.2, cacheRead: 6e-3, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072 }, "mimo-v2.5": { id: "mimo-v2.5", name: "MiMo V2.5", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.14, output: 0.28, cacheRead: 28e-4, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 128e3 }, "mimo-v2.5-pro": { id: "mimo-v2.5-pro", name: "MiMo V2.5 Pro", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 0.435, output: 0.87, cacheRead: 3625e-6, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1048576, maxTokens: 128e3 }, "minimax-m2.7": { id: "minimax-m2.7", name: "MiniMax-M2.7", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 204800, maxTokens: 131072 }, "omen-alpha": { id: "omen-alpha", name: "Omen Alpha", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 0.66, cacheRead: 0.04, cacheWrite: 0 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 5e5, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: null } }, "qwen3.6-plus": { id: "qwen3.6-plus", name: "Qwen3.6 Plus", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.5, output: 3, cacheRead: 0.05, cacheWrite: 0.625 }, compat: { supportsStore: false, supportsDeveloperRole: false, thinkingFormat: "qwen", maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 65536 }, "qwen3.7-max": { id: "qwen3.7-max", name: "Qwen3.7 Max", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text"], cost: { input: 2.5, output: 7.5, cacheRead: 0.5, cacheWrite: 3.125 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 65536 }, "qwen3.7-plus": { id: "qwen3.7-plus", name: "Qwen3.7 Plus", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.4, output: 1.6, cacheRead: 0.04, cacheWrite: 0.5 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 65536 }, "qwen3.8-max": { id: "qwen3.8-max", name: "Qwen3.8 Max", api: "openai-completions", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.25, cacheWrite: 2.5 }, compat: { supportsStore: false, supportsDeveloperRole: false, maxTokensField: "max_tokens" }, contextWindow: 1e6, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: null, xhigh: "xhigh", max: null } } }, "openai-responses": { "gpt-5.6-luna": { id: "gpt-5.6-luna", name: "GPT-5.6 Luna", api: "openai-responses", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 105e4, maxTokens: 128e3, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" } }, "grok-4.6": { id: "grok-4.6", name: "Grok 4.6", api: "openai-responses", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 5e5, maxTokens: 5e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "muse-spark-1.2-contributor": { id: "muse-spark-1.2-contributor", name: "Muse Spark 1.2 Contributor", api: "openai-responses", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.1, output: 0.2, cacheRead: 2e-3, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } }, "muse-spark-1.3-contributor": { id: "muse-spark-1.3-contributor", name: "Muse Spark 1.3 Contributor", api: "openai-responses", provider: "opencode-go", baseUrl: "https://opencode.ai/zen/go/v1", reasoning: true, input: ["text", "image"], cost: { input: 0.1, output: 0.2, cacheRead: 2e-3, cacheWrite: 0 }, compat: { sessionAffinityFormat: "openai-nosession" }, contextWindow: 1048576, maxTokens: 131072, thinkingLevelMap: { off: null, minimal: "minimal", low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } } } };
|
|
299
|
+
|
|
300
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js
|
|
301
|
+
var OPENCODE_GO_MODELS = flattenModelCatalog("opencode-go", opencode_go_default);
|
|
302
|
+
|
|
303
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json
|
|
304
|
+
var xai_default = { "openai-responses": { "grok-4.3": { id: "grok-4.3", name: "Grok 4.3", api: "openai-responses", provider: "xai", baseUrl: "https://api.x.ai/v1", compat: { supportsLongCacheRetention: false }, reasoning: true, input: ["text", "image"], cost: { input: 1.25, output: 2.5, cacheRead: 0.2, cacheWrite: 0 }, contextWindow: 1e6, maxTokens: 3e4, thinkingLevelMap: { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "grok-4.5": { id: "grok-4.5", name: "Grok 4.5", api: "openai-responses", provider: "xai", baseUrl: "https://api.x.ai/v1", compat: { supportsLongCacheRetention: false }, reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.3, cacheWrite: 0 }, contextWindow: 5e5, maxTokens: 5e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null } }, "grok-4.6": { id: "grok-4.6", name: "Grok 4.6", api: "openai-responses", provider: "xai", baseUrl: "https://api.x.ai/v1", compat: { supportsLongCacheRetention: false }, reasoning: true, input: ["text", "image"], cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 }, contextWindow: 5e5, maxTokens: 5e5, thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: null } } } };
|
|
305
|
+
|
|
306
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js
|
|
307
|
+
var XAI_MODELS = flattenModelCatalog("xai", xai_default);
|
|
308
|
+
|
|
309
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
|
|
310
|
+
var EventStream = class {
|
|
311
|
+
queue = [];
|
|
312
|
+
waiting = [];
|
|
313
|
+
done = false;
|
|
314
|
+
finalResultPromise;
|
|
315
|
+
resolveFinalResult;
|
|
316
|
+
isComplete;
|
|
317
|
+
extractResult;
|
|
318
|
+
constructor(isComplete, extractResult) {
|
|
319
|
+
this.isComplete = isComplete;
|
|
320
|
+
this.extractResult = extractResult;
|
|
321
|
+
this.finalResultPromise = new Promise((resolve) => {
|
|
322
|
+
this.resolveFinalResult = resolve;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
push(event) {
|
|
326
|
+
if (this.done)
|
|
327
|
+
return;
|
|
328
|
+
if (this.isComplete(event)) {
|
|
329
|
+
this.done = true;
|
|
330
|
+
this.resolveFinalResult(this.extractResult(event));
|
|
331
|
+
}
|
|
332
|
+
const waiter = this.waiting.shift();
|
|
333
|
+
if (waiter) {
|
|
334
|
+
waiter({ value: event, done: false });
|
|
335
|
+
} else {
|
|
336
|
+
this.queue.push(event);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
end(result) {
|
|
340
|
+
this.done = true;
|
|
341
|
+
if (result !== void 0) {
|
|
342
|
+
this.resolveFinalResult(result);
|
|
343
|
+
}
|
|
344
|
+
while (this.waiting.length > 0) {
|
|
345
|
+
const waiter = this.waiting.shift();
|
|
346
|
+
waiter({ value: void 0, done: true });
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
async *[Symbol.asyncIterator]() {
|
|
350
|
+
while (true) {
|
|
351
|
+
if (this.queue.length > 0) {
|
|
352
|
+
yield this.queue.shift();
|
|
353
|
+
} else if (this.done) {
|
|
354
|
+
return;
|
|
355
|
+
} else {
|
|
356
|
+
const result = await new Promise((resolve) => this.waiting.push(resolve));
|
|
357
|
+
if (result.done)
|
|
358
|
+
return;
|
|
359
|
+
yield result.value;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
result() {
|
|
364
|
+
return this.finalResultPromise;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var AssistantMessageEventStream = class extends EventStream {
|
|
368
|
+
constructor() {
|
|
369
|
+
super((event) => event.type === "done" || event.type === "error", (event) => {
|
|
370
|
+
if (event.type === "done") {
|
|
371
|
+
return event.message;
|
|
372
|
+
} else if (event.type === "error") {
|
|
373
|
+
return event.error;
|
|
374
|
+
}
|
|
375
|
+
throw new Error("Unexpected event type for final result");
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
function createAssistantMessageEventStream() {
|
|
380
|
+
return new AssistantMessageEventStream();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/models.js
|
|
384
|
+
function calculateCost(model, usage) {
|
|
385
|
+
const inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;
|
|
386
|
+
let rates = model.cost;
|
|
387
|
+
let matchedThreshold = -1;
|
|
388
|
+
for (const tier of model.cost.tiers ?? []) {
|
|
389
|
+
if (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {
|
|
390
|
+
rates = tier;
|
|
391
|
+
matchedThreshold = tier.inputTokensAbove;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const longWrite = usage.cacheWrite1h ?? 0;
|
|
395
|
+
const shortWrite = usage.cacheWrite - longWrite;
|
|
396
|
+
usage.cost.input = rates.input / 1e6 * usage.input;
|
|
397
|
+
usage.cost.output = rates.output / 1e6 * usage.output;
|
|
398
|
+
usage.cost.cacheRead = rates.cacheRead / 1e6 * usage.cacheRead;
|
|
399
|
+
usage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1e6;
|
|
400
|
+
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
401
|
+
return usage.cost;
|
|
402
|
+
}
|
|
403
|
+
var EXTENDED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
404
|
+
function getSupportedThinkingLevels(model) {
|
|
405
|
+
if (!model.reasoning)
|
|
406
|
+
return ["off"];
|
|
407
|
+
return EXTENDED_THINKING_LEVELS.filter((level) => {
|
|
408
|
+
const mapped = model.thinkingLevelMap?.[level];
|
|
409
|
+
if (mapped === null)
|
|
410
|
+
return false;
|
|
411
|
+
if (level === "xhigh" || level === "max")
|
|
412
|
+
return mapped !== void 0;
|
|
413
|
+
return true;
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/utils/hash.js
|
|
418
|
+
function shortHash(str) {
|
|
419
|
+
let h1 = 3735928559;
|
|
420
|
+
let h2 = 1103547991;
|
|
421
|
+
for (let i = 0; i < str.length; i++) {
|
|
422
|
+
const ch = str.charCodeAt(i);
|
|
423
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
424
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
425
|
+
}
|
|
426
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
427
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
428
|
+
return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js
|
|
432
|
+
var import_partial_json = __toESM(require_dist(), 1);
|
|
433
|
+
var VALID_JSON_ESCAPES = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t", "u"]);
|
|
434
|
+
function isControlCharacter(char) {
|
|
435
|
+
const codePoint = char.codePointAt(0);
|
|
436
|
+
return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
|
|
437
|
+
}
|
|
438
|
+
function escapeControlCharacter(char) {
|
|
439
|
+
switch (char) {
|
|
440
|
+
case "\b":
|
|
441
|
+
return "\\b";
|
|
442
|
+
case "\f":
|
|
443
|
+
return "\\f";
|
|
444
|
+
case "\n":
|
|
445
|
+
return "\\n";
|
|
446
|
+
case "\r":
|
|
447
|
+
return "\\r";
|
|
448
|
+
case " ":
|
|
449
|
+
return "\\t";
|
|
450
|
+
default:
|
|
451
|
+
return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function repairJson(json) {
|
|
455
|
+
let repaired = "";
|
|
456
|
+
let inString = false;
|
|
457
|
+
for (let index = 0; index < json.length; index++) {
|
|
458
|
+
const char = json[index];
|
|
459
|
+
if (!inString) {
|
|
460
|
+
repaired += char;
|
|
461
|
+
if (char === '"') {
|
|
462
|
+
inString = true;
|
|
463
|
+
}
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (char === '"') {
|
|
467
|
+
repaired += char;
|
|
468
|
+
inString = false;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (char === "\\") {
|
|
472
|
+
const nextChar = json[index + 1];
|
|
473
|
+
if (nextChar === void 0) {
|
|
474
|
+
repaired += "\\\\";
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (nextChar === "u") {
|
|
478
|
+
const unicodeDigits = json.slice(index + 2, index + 6);
|
|
479
|
+
if (/^[0-9a-fA-F]{4}$/.test(unicodeDigits)) {
|
|
480
|
+
repaired += `\\u${unicodeDigits}`;
|
|
481
|
+
index += 5;
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (VALID_JSON_ESCAPES.has(nextChar)) {
|
|
486
|
+
repaired += `\\${nextChar}`;
|
|
487
|
+
index += 1;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
repaired += "\\\\";
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
repaired += isControlCharacter(char) ? escapeControlCharacter(char) : char;
|
|
494
|
+
}
|
|
495
|
+
return repaired;
|
|
496
|
+
}
|
|
497
|
+
function parseJsonWithRepair(json) {
|
|
498
|
+
try {
|
|
499
|
+
return JSON.parse(json);
|
|
500
|
+
} catch (error) {
|
|
501
|
+
const repairedJson = repairJson(json);
|
|
502
|
+
if (repairedJson !== json) {
|
|
503
|
+
return JSON.parse(repairedJson);
|
|
504
|
+
}
|
|
505
|
+
throw error;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function parseStreamingJson(partialJson) {
|
|
509
|
+
if (!partialJson || partialJson.trim() === "") {
|
|
510
|
+
return {};
|
|
511
|
+
}
|
|
512
|
+
try {
|
|
513
|
+
return parseJsonWithRepair(partialJson);
|
|
514
|
+
} catch {
|
|
515
|
+
try {
|
|
516
|
+
const result = (0, import_partial_json.parse)(partialJson);
|
|
517
|
+
return result ?? {};
|
|
518
|
+
} catch {
|
|
519
|
+
try {
|
|
520
|
+
const result = (0, import_partial_json.parse)(repairJson(partialJson));
|
|
521
|
+
return result ?? {};
|
|
522
|
+
} catch {
|
|
523
|
+
return {};
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js
|
|
530
|
+
function sanitizeSurrogates(text) {
|
|
531
|
+
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js
|
|
535
|
+
var UnsupportedStrictJsonSchemaError = class extends Error {
|
|
536
|
+
};
|
|
537
|
+
var UNSUPPORTED_STRICT_SCHEMA_KEYS = [
|
|
538
|
+
"$ref",
|
|
539
|
+
"$defs",
|
|
540
|
+
"definitions",
|
|
541
|
+
"allOf",
|
|
542
|
+
"oneOf",
|
|
543
|
+
"patternProperties",
|
|
544
|
+
"dependentSchemas",
|
|
545
|
+
"dependencies",
|
|
546
|
+
"unevaluatedProperties",
|
|
547
|
+
"propertyNames",
|
|
548
|
+
"contains",
|
|
549
|
+
"prefixItems",
|
|
550
|
+
"not",
|
|
551
|
+
"if",
|
|
552
|
+
"then",
|
|
553
|
+
"else"
|
|
554
|
+
];
|
|
555
|
+
function isJsonSchemaObject(value) {
|
|
556
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
557
|
+
}
|
|
558
|
+
function isStructuredSchema(schema) {
|
|
559
|
+
if (!isJsonSchemaObject(schema))
|
|
560
|
+
return false;
|
|
561
|
+
const types = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
|
|
562
|
+
return types.includes("object") || types.includes("array") || schema.properties !== void 0 || schema.items !== void 0;
|
|
563
|
+
}
|
|
564
|
+
function schemaAllowsNull(schema) {
|
|
565
|
+
if (!isJsonSchemaObject(schema))
|
|
566
|
+
return false;
|
|
567
|
+
if (schema.type === "null" || Array.isArray(schema.type) && schema.type.includes("null"))
|
|
568
|
+
return true;
|
|
569
|
+
if (schema.const === null || Array.isArray(schema.enum) && schema.enum.includes(null))
|
|
570
|
+
return true;
|
|
571
|
+
return Array.isArray(schema.anyOf) && schema.anyOf.some((variant) => schemaAllowsNull(variant));
|
|
572
|
+
}
|
|
573
|
+
function makeJsonSchemaNodeStrict(schema) {
|
|
574
|
+
if (!isJsonSchemaObject(schema)) {
|
|
575
|
+
throw new UnsupportedStrictJsonSchemaError("boolean schemas are unsupported");
|
|
576
|
+
}
|
|
577
|
+
for (const key of UNSUPPORTED_STRICT_SCHEMA_KEYS) {
|
|
578
|
+
if (schema[key] !== void 0) {
|
|
579
|
+
throw new UnsupportedStrictJsonSchemaError(`${key} schemas are unsupported`);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (schema.anyOf !== void 0) {
|
|
583
|
+
if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {
|
|
584
|
+
throw new UnsupportedStrictJsonSchemaError("anyOf must contain at least one schema");
|
|
585
|
+
}
|
|
586
|
+
for (const variant of schema.anyOf) {
|
|
587
|
+
if (isStructuredSchema(variant)) {
|
|
588
|
+
throw new UnsupportedStrictJsonSchemaError("object and array unions are unsupported");
|
|
589
|
+
}
|
|
590
|
+
makeJsonSchemaNodeStrict(variant);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if (schema.items !== void 0) {
|
|
594
|
+
if (Array.isArray(schema.items)) {
|
|
595
|
+
throw new UnsupportedStrictJsonSchemaError("tuple schemas are unsupported");
|
|
596
|
+
}
|
|
597
|
+
makeJsonSchemaNodeStrict(schema.items);
|
|
598
|
+
}
|
|
599
|
+
const isObjectSchema = schema.type === "object";
|
|
600
|
+
if (schema.properties !== void 0 && !isObjectSchema) {
|
|
601
|
+
throw new UnsupportedStrictJsonSchemaError("properties require type object");
|
|
602
|
+
}
|
|
603
|
+
if (!isObjectSchema)
|
|
604
|
+
return;
|
|
605
|
+
if (schema.additionalProperties !== void 0 && schema.additionalProperties !== false) {
|
|
606
|
+
throw new UnsupportedStrictJsonSchemaError("schema-valued or true additionalProperties is unsupported");
|
|
607
|
+
}
|
|
608
|
+
if (schema.properties !== void 0 && !isJsonSchemaObject(schema.properties)) {
|
|
609
|
+
throw new UnsupportedStrictJsonSchemaError("object properties must be a schema map");
|
|
610
|
+
}
|
|
611
|
+
if (schema.required !== void 0 && (!Array.isArray(schema.required) || schema.required.some((key) => typeof key !== "string"))) {
|
|
612
|
+
throw new UnsupportedStrictJsonSchemaError("object required must be a string array");
|
|
613
|
+
}
|
|
614
|
+
const properties = schema.properties ?? {};
|
|
615
|
+
const propertyNames = Object.keys(properties);
|
|
616
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required : []);
|
|
617
|
+
if ([...required].some((key) => !propertyNames.includes(key))) {
|
|
618
|
+
throw new UnsupportedStrictJsonSchemaError("required contains an unknown property");
|
|
619
|
+
}
|
|
620
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
621
|
+
makeJsonSchemaNodeStrict(property);
|
|
622
|
+
if (!required.has(key) && !schemaAllowsNull(property)) {
|
|
623
|
+
properties[key] = { anyOf: [property, { type: "null" }] };
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
schema.required = propertyNames;
|
|
627
|
+
schema.additionalProperties = false;
|
|
628
|
+
}
|
|
629
|
+
function makeStrictJsonSchema(schema) {
|
|
630
|
+
const cloned = structuredClone(schema);
|
|
631
|
+
if (!isJsonSchemaObject(cloned)) {
|
|
632
|
+
throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
|
|
633
|
+
}
|
|
634
|
+
makeJsonSchemaNodeStrict(cloned);
|
|
635
|
+
if (cloned.type !== "object") {
|
|
636
|
+
throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
|
|
637
|
+
}
|
|
638
|
+
return cloned;
|
|
639
|
+
}
|
|
640
|
+
function getJsonSchemaToolParameters(tool, strict) {
|
|
641
|
+
return strict === true ? makeStrictJsonSchema(tool.parameters) : tool.parameters;
|
|
642
|
+
}
|
|
643
|
+
function getGrammarToolInput(toolName, arguments_, inputProperty) {
|
|
644
|
+
const input = arguments_[inputProperty];
|
|
645
|
+
if (typeof input !== "string") {
|
|
646
|
+
throw new Error(`Grammar tool call "${toolName}" requires argument "${inputProperty}" to be a string.`);
|
|
647
|
+
}
|
|
648
|
+
return input;
|
|
649
|
+
}
|
|
650
|
+
function appendGrammarToolInputJsonDelta(buffer, inputProperty, nextInput, close) {
|
|
651
|
+
if (buffer.closed) {
|
|
652
|
+
if (close && nextInput === buffer.input)
|
|
653
|
+
return void 0;
|
|
654
|
+
throw new Error(`grammar tool input for property "${inputProperty}" changed after it was closed`);
|
|
655
|
+
}
|
|
656
|
+
if (!nextInput.startsWith(buffer.input)) {
|
|
657
|
+
throw new Error(`grammar tool input for property "${inputProperty}" changed non-monotonically`);
|
|
658
|
+
}
|
|
659
|
+
const inputDelta = nextInput.slice(buffer.input.length);
|
|
660
|
+
if (!close && inputDelta.length === 0)
|
|
661
|
+
return void 0;
|
|
662
|
+
let delta = "";
|
|
663
|
+
if (!buffer.started) {
|
|
664
|
+
delta += `{${JSON.stringify(inputProperty)}:"`;
|
|
665
|
+
buffer.started = true;
|
|
666
|
+
}
|
|
667
|
+
delta += JSON.stringify(inputDelta).slice(1, -1);
|
|
668
|
+
buffer.input = nextInput;
|
|
669
|
+
if (close) {
|
|
670
|
+
delta += '"}';
|
|
671
|
+
buffer.closed = true;
|
|
672
|
+
}
|
|
673
|
+
return delta;
|
|
674
|
+
}
|
|
675
|
+
function inferGrammarInputProperty(tool) {
|
|
676
|
+
const schema = tool.parameters;
|
|
677
|
+
if (schema.type !== "object") {
|
|
678
|
+
throw new Error("grammar constrained sampling requires an object parameter schema");
|
|
679
|
+
}
|
|
680
|
+
if (!Array.isArray(schema.required) || schema.required.length !== 1 || typeof schema.required[0] !== "string") {
|
|
681
|
+
throw new Error("grammar constrained sampling requires exactly one required string property");
|
|
682
|
+
}
|
|
683
|
+
const inputProperty = schema.required[0];
|
|
684
|
+
if (!schema.properties?.[inputProperty]) {
|
|
685
|
+
throw new Error(`grammar constrained sampling requires a properties entry for ${inputProperty}`);
|
|
686
|
+
}
|
|
687
|
+
if (schema.properties[inputProperty]?.type !== "string") {
|
|
688
|
+
throw new Error(`grammar constrained sampling property ${inputProperty} must have type string`);
|
|
689
|
+
}
|
|
690
|
+
return inputProperty;
|
|
691
|
+
}
|
|
692
|
+
function resolveJsonSchemaStrictSampling(tool, supportsStrictMode) {
|
|
693
|
+
const config = tool.constrainedSampling;
|
|
694
|
+
if (!config || config.type !== "json_schema")
|
|
695
|
+
return void 0;
|
|
696
|
+
if (supportsStrictMode) {
|
|
697
|
+
try {
|
|
698
|
+
makeStrictJsonSchema(tool.parameters);
|
|
699
|
+
return true;
|
|
700
|
+
} catch (error) {
|
|
701
|
+
if (!(error instanceof UnsupportedStrictJsonSchemaError))
|
|
702
|
+
throw error;
|
|
703
|
+
if (config.strict !== "require")
|
|
704
|
+
return void 0;
|
|
705
|
+
throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}.`);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
if (config.strict === "require") {
|
|
709
|
+
throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`);
|
|
710
|
+
}
|
|
711
|
+
return void 0;
|
|
712
|
+
}
|
|
713
|
+
function resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools) {
|
|
714
|
+
const config = tool.constrainedSampling;
|
|
715
|
+
if (!config || config.type !== "grammar") {
|
|
716
|
+
return void 0;
|
|
717
|
+
}
|
|
718
|
+
if (!supportsOpenAIGrammarTools) {
|
|
719
|
+
return void 0;
|
|
720
|
+
}
|
|
721
|
+
const larkDefinition = config.variants.openai_lark;
|
|
722
|
+
const regexDefinition = config.variants.openai_regex;
|
|
723
|
+
const hasLarkDefinition = typeof larkDefinition === "string" && larkDefinition.trim().length > 0;
|
|
724
|
+
const hasRegexDefinition = typeof regexDefinition === "string" && regexDefinition.trim().length > 0;
|
|
725
|
+
if (!hasLarkDefinition && !hasRegexDefinition) {
|
|
726
|
+
throw new Error(`Tool "${tool.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);
|
|
727
|
+
}
|
|
728
|
+
try {
|
|
729
|
+
return {
|
|
730
|
+
format: hasLarkDefinition ? "lark" : "regex",
|
|
731
|
+
definition: hasLarkDefinition ? larkDefinition : regexDefinition,
|
|
732
|
+
inputProperty: inferGrammarInputProperty(tool)
|
|
733
|
+
};
|
|
734
|
+
} catch (error) {
|
|
735
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
736
|
+
throw new Error(`Tool "${tool.name}" cannot use grammar constrained sampling: ${message}.`);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
function createGrammarToolInputProperties(tools, supportsOpenAIGrammarTools) {
|
|
740
|
+
const properties = /* @__PURE__ */ new Map();
|
|
741
|
+
for (const tool of tools ?? []) {
|
|
742
|
+
const grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);
|
|
743
|
+
if (grammar) {
|
|
744
|
+
properties.set(tool.name, grammar.inputProperty);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return properties;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js
|
|
751
|
+
var NON_VISION_USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
|
|
752
|
+
var NON_VISION_TOOL_IMAGE_PLACEHOLDER = "(tool image omitted: model does not support images)";
|
|
753
|
+
function replaceImagesWithPlaceholder(content, placeholder) {
|
|
754
|
+
const result = [];
|
|
755
|
+
let previousWasPlaceholder = false;
|
|
756
|
+
for (const block of content) {
|
|
757
|
+
if (block.type === "image") {
|
|
758
|
+
if (!previousWasPlaceholder) {
|
|
759
|
+
result.push({ type: "text", text: placeholder });
|
|
760
|
+
}
|
|
761
|
+
previousWasPlaceholder = true;
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
result.push(block);
|
|
765
|
+
previousWasPlaceholder = block.text === placeholder;
|
|
766
|
+
}
|
|
767
|
+
return result;
|
|
768
|
+
}
|
|
769
|
+
function downgradeUnsupportedImages(messages, model) {
|
|
770
|
+
if (model.input.includes("image")) {
|
|
771
|
+
return messages;
|
|
772
|
+
}
|
|
773
|
+
return messages.map((msg) => {
|
|
774
|
+
if (msg.role === "user" && Array.isArray(msg.content)) {
|
|
775
|
+
return {
|
|
776
|
+
...msg,
|
|
777
|
+
content: replaceImagesWithPlaceholder(msg.content, NON_VISION_USER_IMAGE_PLACEHOLDER)
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
if (msg.role === "toolResult") {
|
|
781
|
+
return {
|
|
782
|
+
...msg,
|
|
783
|
+
content: replaceImagesWithPlaceholder(msg.content, NON_VISION_TOOL_IMAGE_PLACEHOLDER)
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
return msg;
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
function transformMessages(messages, model, normalizeToolCallId) {
|
|
790
|
+
const toolCallIdMap = /* @__PURE__ */ new Map();
|
|
791
|
+
const normalizedMessages = messages.map((msg) => msg.content == null ? { ...msg, content: [] } : msg);
|
|
792
|
+
const imageAwareMessages = downgradeUnsupportedImages(normalizedMessages, model);
|
|
793
|
+
const transformed = imageAwareMessages.map((msg) => {
|
|
794
|
+
if (msg.role === "user") {
|
|
795
|
+
return msg;
|
|
796
|
+
}
|
|
797
|
+
if (msg.role === "toolResult") {
|
|
798
|
+
const normalizedId = toolCallIdMap.get(msg.toolCallId);
|
|
799
|
+
if (normalizedId && normalizedId !== msg.toolCallId) {
|
|
800
|
+
return { ...msg, toolCallId: normalizedId };
|
|
801
|
+
}
|
|
802
|
+
return msg;
|
|
803
|
+
}
|
|
804
|
+
if (msg.role === "assistant") {
|
|
805
|
+
const assistantMsg = msg;
|
|
806
|
+
const isSameModel = assistantMsg.provider === model.provider && assistantMsg.api === model.api && assistantMsg.model === model.id;
|
|
807
|
+
const transformedContent = assistantMsg.content.flatMap((block) => {
|
|
808
|
+
if (block.type === "thinking") {
|
|
809
|
+
if (block.redacted) {
|
|
810
|
+
return isSameModel ? block : [];
|
|
811
|
+
}
|
|
812
|
+
if (isSameModel && block.thinkingSignature)
|
|
813
|
+
return block;
|
|
814
|
+
if (!block.thinking || block.thinking.trim() === "")
|
|
815
|
+
return [];
|
|
816
|
+
if (isSameModel)
|
|
817
|
+
return block;
|
|
818
|
+
return {
|
|
819
|
+
type: "text",
|
|
820
|
+
text: block.thinking
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
if (block.type === "text") {
|
|
824
|
+
if (isSameModel)
|
|
825
|
+
return block;
|
|
826
|
+
return {
|
|
827
|
+
type: "text",
|
|
828
|
+
text: block.text
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
if (block.type === "toolCall") {
|
|
832
|
+
const toolCall = block;
|
|
833
|
+
let normalizedToolCall = toolCall;
|
|
834
|
+
if (!isSameModel && toolCall.thoughtSignature) {
|
|
835
|
+
normalizedToolCall = { ...toolCall };
|
|
836
|
+
delete normalizedToolCall.thoughtSignature;
|
|
837
|
+
}
|
|
838
|
+
if (!isSameModel && normalizeToolCallId) {
|
|
839
|
+
const normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);
|
|
840
|
+
if (normalizedId !== toolCall.id) {
|
|
841
|
+
toolCallIdMap.set(toolCall.id, normalizedId);
|
|
842
|
+
normalizedToolCall = { ...normalizedToolCall, id: normalizedId };
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return normalizedToolCall;
|
|
846
|
+
}
|
|
847
|
+
return block;
|
|
848
|
+
});
|
|
849
|
+
return {
|
|
850
|
+
...assistantMsg,
|
|
851
|
+
content: transformedContent
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
return msg;
|
|
855
|
+
});
|
|
856
|
+
const result = [];
|
|
857
|
+
let pendingToolCalls = [];
|
|
858
|
+
let existingToolResultIds = /* @__PURE__ */ new Set();
|
|
859
|
+
const insertSyntheticToolResults = () => {
|
|
860
|
+
if (pendingToolCalls.length > 0) {
|
|
861
|
+
for (const tc of pendingToolCalls) {
|
|
862
|
+
if (!existingToolResultIds.has(tc.id)) {
|
|
863
|
+
result.push({
|
|
864
|
+
role: "toolResult",
|
|
865
|
+
toolCallId: tc.id,
|
|
866
|
+
toolName: tc.name,
|
|
867
|
+
content: [{ type: "text", text: "No result provided" }],
|
|
868
|
+
isError: true,
|
|
869
|
+
timestamp: Date.now()
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
pendingToolCalls = [];
|
|
874
|
+
existingToolResultIds = /* @__PURE__ */ new Set();
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
for (let i = 0; i < transformed.length; i++) {
|
|
878
|
+
const msg = transformed[i];
|
|
879
|
+
if (msg.role === "assistant") {
|
|
880
|
+
insertSyntheticToolResults();
|
|
881
|
+
const assistantMsg = msg;
|
|
882
|
+
if (assistantMsg.stopReason === "error" || assistantMsg.stopReason === "aborted") {
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
const toolCalls = assistantMsg.content.filter((b) => b.type === "toolCall");
|
|
886
|
+
if (toolCalls.length > 0) {
|
|
887
|
+
pendingToolCalls = toolCalls;
|
|
888
|
+
existingToolResultIds = /* @__PURE__ */ new Set();
|
|
889
|
+
}
|
|
890
|
+
result.push(msg);
|
|
891
|
+
} else if (msg.role === "toolResult") {
|
|
892
|
+
existingToolResultIds.add(msg.toolCallId);
|
|
893
|
+
result.push(msg);
|
|
894
|
+
} else if (msg.role === "user") {
|
|
895
|
+
insertSyntheticToolResults();
|
|
896
|
+
result.push(msg);
|
|
897
|
+
} else {
|
|
898
|
+
result.push(msg);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
insertSyntheticToolResults();
|
|
902
|
+
return result;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
|
|
906
|
+
function encodeTextSignatureV1(id, phase) {
|
|
907
|
+
const payload = { v: 1, id };
|
|
908
|
+
if (phase)
|
|
909
|
+
payload.phase = phase;
|
|
910
|
+
return JSON.stringify(payload);
|
|
911
|
+
}
|
|
912
|
+
function parseTextSignature(signature) {
|
|
913
|
+
if (!signature)
|
|
914
|
+
return void 0;
|
|
915
|
+
if (signature.startsWith("{")) {
|
|
916
|
+
try {
|
|
917
|
+
const parsed = JSON.parse(signature);
|
|
918
|
+
if (parsed.v === 1 && typeof parsed.id === "string") {
|
|
919
|
+
if (parsed.phase === "commentary" || parsed.phase === "final_answer") {
|
|
920
|
+
return { id: parsed.id, phase: parsed.phase };
|
|
921
|
+
}
|
|
922
|
+
return { id: parsed.id };
|
|
923
|
+
}
|
|
924
|
+
} catch {
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return { id: signature };
|
|
928
|
+
}
|
|
929
|
+
function convertToolResultOutput(model, content) {
|
|
930
|
+
const textResult = content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
|
|
931
|
+
const images = content.filter((c) => c.type === "image");
|
|
932
|
+
const hasText = textResult.length > 0;
|
|
933
|
+
if (images.length === 0 || !model.input.includes("image")) {
|
|
934
|
+
return sanitizeSurrogates(hasText ? textResult : images.length > 0 ? "(see attached image)" : "(no tool output)");
|
|
935
|
+
}
|
|
936
|
+
const output = [];
|
|
937
|
+
if (hasText) {
|
|
938
|
+
output.push({ type: "input_text", text: sanitizeSurrogates(textResult) });
|
|
939
|
+
}
|
|
940
|
+
for (const image of images) {
|
|
941
|
+
output.push({
|
|
942
|
+
type: "input_image",
|
|
943
|
+
detail: "auto",
|
|
944
|
+
image_url: `data:${image.mimeType};base64,${image.data}`
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
return output;
|
|
948
|
+
}
|
|
949
|
+
function convertResponsesMessages(model, context, allowedToolCallProviders, options) {
|
|
950
|
+
const messages = [];
|
|
951
|
+
const loadedToolNames = /* @__PURE__ */ new Set();
|
|
952
|
+
const normalizeIdPart = (part) => {
|
|
953
|
+
const sanitized = part.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
954
|
+
const normalized = sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized;
|
|
955
|
+
return normalized.replace(/_+$/, "");
|
|
956
|
+
};
|
|
957
|
+
const buildForeignResponsesItemId = (itemId) => {
|
|
958
|
+
const normalized = `fc_${shortHash(itemId)}`;
|
|
959
|
+
return normalized.length > 64 ? normalized.slice(0, 64) : normalized;
|
|
960
|
+
};
|
|
961
|
+
const normalizeToolCallId = (id, _targetModel, source) => {
|
|
962
|
+
if (!allowedToolCallProviders.has(model.provider))
|
|
963
|
+
return normalizeIdPart(id);
|
|
964
|
+
if (!id.includes("|"))
|
|
965
|
+
return normalizeIdPart(id);
|
|
966
|
+
const [callId, itemId] = id.split("|");
|
|
967
|
+
const normalizedCallId = normalizeIdPart(callId);
|
|
968
|
+
const isForeignToolCall = source.provider !== model.provider || source.api !== model.api;
|
|
969
|
+
let normalizedItemId = isForeignToolCall ? buildForeignResponsesItemId(itemId) : normalizeIdPart(itemId);
|
|
970
|
+
if (!normalizedItemId.startsWith("fc_")) {
|
|
971
|
+
normalizedItemId = normalizeIdPart(`fc_${normalizedItemId}`);
|
|
972
|
+
}
|
|
973
|
+
return `${normalizedCallId}|${normalizedItemId}`;
|
|
974
|
+
};
|
|
975
|
+
const transformedMessages = transformMessages(context.messages, model, normalizeToolCallId);
|
|
976
|
+
const includeSystemPrompt = options?.includeSystemPrompt ?? true;
|
|
977
|
+
if (includeSystemPrompt && context.systemPrompt) {
|
|
978
|
+
const compat = model.compat;
|
|
979
|
+
const role = model.reasoning && compat?.supportsDeveloperRole !== false ? "developer" : "system";
|
|
980
|
+
messages.push({
|
|
981
|
+
role,
|
|
982
|
+
content: sanitizeSurrogates(context.systemPrompt)
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
let msgIndex = 0;
|
|
986
|
+
for (const msg of transformedMessages) {
|
|
987
|
+
if (msg.role === "user") {
|
|
988
|
+
if (typeof msg.content === "string") {
|
|
989
|
+
messages.push({
|
|
990
|
+
role: "user",
|
|
991
|
+
content: [{ type: "input_text", text: sanitizeSurrogates(msg.content) }]
|
|
992
|
+
});
|
|
993
|
+
} else {
|
|
994
|
+
const content = msg.content.map((item) => {
|
|
995
|
+
if (item.type === "text") {
|
|
996
|
+
return {
|
|
997
|
+
type: "input_text",
|
|
998
|
+
text: sanitizeSurrogates(item.text)
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
return {
|
|
1002
|
+
type: "input_image",
|
|
1003
|
+
detail: "auto",
|
|
1004
|
+
image_url: `data:${item.mimeType};base64,${item.data}`
|
|
1005
|
+
};
|
|
1006
|
+
});
|
|
1007
|
+
if (content.length === 0)
|
|
1008
|
+
continue;
|
|
1009
|
+
messages.push({
|
|
1010
|
+
role: "user",
|
|
1011
|
+
content
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
} else if (msg.role === "assistant") {
|
|
1015
|
+
const output = [];
|
|
1016
|
+
const assistantMsg = msg;
|
|
1017
|
+
const isSameProviderAndApi = assistantMsg.provider === model.provider && assistantMsg.api === model.api;
|
|
1018
|
+
const isSameModel = isSameProviderAndApi && assistantMsg.model === model.id;
|
|
1019
|
+
const isDifferentModel = isSameProviderAndApi && assistantMsg.model !== model.id;
|
|
1020
|
+
let textBlockIndex = 0;
|
|
1021
|
+
for (const block of msg.content) {
|
|
1022
|
+
if (block.type === "thinking") {
|
|
1023
|
+
if (block.thinkingSignature) {
|
|
1024
|
+
const reasoningItem = JSON.parse(block.thinkingSignature);
|
|
1025
|
+
output.push(reasoningItem);
|
|
1026
|
+
}
|
|
1027
|
+
} else if (block.type === "text") {
|
|
1028
|
+
const textBlock = block;
|
|
1029
|
+
const parsedSignature = parseTextSignature(textBlock.textSignature);
|
|
1030
|
+
const fallbackMessageId = textBlockIndex === 0 ? `msg_pi_${msgIndex}` : `msg_pi_${msgIndex}_${textBlockIndex}`;
|
|
1031
|
+
textBlockIndex++;
|
|
1032
|
+
let msgId = parsedSignature?.id;
|
|
1033
|
+
if (!msgId) {
|
|
1034
|
+
msgId = fallbackMessageId;
|
|
1035
|
+
} else if (msgId.length > 64) {
|
|
1036
|
+
msgId = `msg_${shortHash(msgId)}`;
|
|
1037
|
+
}
|
|
1038
|
+
output.push({
|
|
1039
|
+
type: "message",
|
|
1040
|
+
role: "assistant",
|
|
1041
|
+
content: [{ type: "output_text", text: sanitizeSurrogates(textBlock.text), annotations: [] }],
|
|
1042
|
+
status: "completed",
|
|
1043
|
+
id: msgId,
|
|
1044
|
+
phase: parsedSignature?.phase
|
|
1045
|
+
});
|
|
1046
|
+
} else if (block.type === "toolCall") {
|
|
1047
|
+
const toolCall = block;
|
|
1048
|
+
const [callId, itemIdRaw] = toolCall.id.split("|");
|
|
1049
|
+
const customInputProperty = options?.grammarToolInputProperties?.get(toolCall.name);
|
|
1050
|
+
let itemId = itemIdRaw;
|
|
1051
|
+
if (isDifferentModel && itemId?.startsWith("fc_") || customInputProperty === void 0 && !itemId?.startsWith("fc_")) {
|
|
1052
|
+
itemId = void 0;
|
|
1053
|
+
}
|
|
1054
|
+
const canReplayNamespace = isSameModel || options?.deferredTools?.has(toolCall.name) === true;
|
|
1055
|
+
if (customInputProperty !== void 0) {
|
|
1056
|
+
output.push({
|
|
1057
|
+
type: "custom_tool_call",
|
|
1058
|
+
id: itemId,
|
|
1059
|
+
call_id: callId,
|
|
1060
|
+
name: toolCall.name,
|
|
1061
|
+
input: sanitizeSurrogates(getGrammarToolInput(toolCall.name, toolCall.arguments, customInputProperty)),
|
|
1062
|
+
...canReplayNamespace && toolCall.namespace !== void 0 ? { namespace: toolCall.namespace } : {}
|
|
1063
|
+
});
|
|
1064
|
+
} else {
|
|
1065
|
+
output.push({
|
|
1066
|
+
type: "function_call",
|
|
1067
|
+
id: itemId,
|
|
1068
|
+
call_id: callId,
|
|
1069
|
+
name: toolCall.name,
|
|
1070
|
+
arguments: JSON.stringify(toolCall.arguments),
|
|
1071
|
+
...canReplayNamespace && toolCall.namespace !== void 0 ? { namespace: toolCall.namespace } : {}
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
if (output.length === 0)
|
|
1077
|
+
continue;
|
|
1078
|
+
messages.push(...output);
|
|
1079
|
+
} else if (msg.role === "toolResult") {
|
|
1080
|
+
const [callId] = msg.toolCallId.split("|");
|
|
1081
|
+
const output = convertToolResultOutput(model, msg.content);
|
|
1082
|
+
if (options?.grammarToolInputProperties?.has(msg.toolName)) {
|
|
1083
|
+
messages.push({
|
|
1084
|
+
type: "custom_tool_call_output",
|
|
1085
|
+
call_id: callId,
|
|
1086
|
+
output
|
|
1087
|
+
});
|
|
1088
|
+
} else {
|
|
1089
|
+
messages.push({
|
|
1090
|
+
type: "function_call_output",
|
|
1091
|
+
call_id: callId,
|
|
1092
|
+
output
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
const deferredTools = [];
|
|
1096
|
+
for (const name of msg.addedToolNames ?? []) {
|
|
1097
|
+
const tool = options?.deferredTools?.get(name);
|
|
1098
|
+
if (!tool || loadedToolNames.has(name))
|
|
1099
|
+
continue;
|
|
1100
|
+
loadedToolNames.add(name);
|
|
1101
|
+
deferredTools.push(tool);
|
|
1102
|
+
}
|
|
1103
|
+
if (deferredTools.length > 0 && options?.deferredToolsMode === "additional-tools") {
|
|
1104
|
+
messages.push({
|
|
1105
|
+
type: "additional_tools",
|
|
1106
|
+
role: "developer",
|
|
1107
|
+
tools: convertResponsesTools(deferredTools, options.toolOptions)
|
|
1108
|
+
});
|
|
1109
|
+
} else if (deferredTools.length > 0 && options?.deferredToolsMode === "tool-search") {
|
|
1110
|
+
const names = deferredTools.map((tool) => tool.name);
|
|
1111
|
+
const searchCallId = `pi_tool_load_${shortHash(`${msg.toolCallId}:${names.join(",")}`)}`;
|
|
1112
|
+
messages.push({
|
|
1113
|
+
type: "tool_search_call",
|
|
1114
|
+
call_id: searchCallId,
|
|
1115
|
+
execution: "client",
|
|
1116
|
+
status: "completed",
|
|
1117
|
+
arguments: { query: names.join(" "), limit: names.length }
|
|
1118
|
+
});
|
|
1119
|
+
messages.push({
|
|
1120
|
+
type: "tool_search_output",
|
|
1121
|
+
call_id: searchCallId,
|
|
1122
|
+
execution: "client",
|
|
1123
|
+
status: "completed",
|
|
1124
|
+
tools: convertResponsesTools(deferredTools, {
|
|
1125
|
+
...options.toolOptions,
|
|
1126
|
+
deferLoading: true
|
|
1127
|
+
})
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
msgIndex++;
|
|
1132
|
+
}
|
|
1133
|
+
return messages;
|
|
1134
|
+
}
|
|
1135
|
+
function convertResponsesTools(tools, options) {
|
|
1136
|
+
const defaultStrict = options?.strict === void 0 ? false : options.strict;
|
|
1137
|
+
const supportsStrictMode = options?.supportsStrictMode ?? true;
|
|
1138
|
+
const supportsOpenAIGrammarTools = options?.supportsOpenAIGrammarTools ?? false;
|
|
1139
|
+
return tools.map((tool) => {
|
|
1140
|
+
const grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);
|
|
1141
|
+
if (grammar) {
|
|
1142
|
+
return {
|
|
1143
|
+
type: "custom",
|
|
1144
|
+
name: tool.name,
|
|
1145
|
+
description: tool.description,
|
|
1146
|
+
format: {
|
|
1147
|
+
type: "grammar",
|
|
1148
|
+
syntax: grammar.format,
|
|
1149
|
+
definition: grammar.definition
|
|
1150
|
+
},
|
|
1151
|
+
...options?.deferLoading ? { defer_loading: true } : {}
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
const constrainedStrict = resolveJsonSchemaStrictSampling(tool, supportsStrictMode);
|
|
1155
|
+
const strict = constrainedStrict ?? defaultStrict;
|
|
1156
|
+
const functionTool = {
|
|
1157
|
+
type: "function",
|
|
1158
|
+
name: tool.name,
|
|
1159
|
+
description: tool.description,
|
|
1160
|
+
parameters: getJsonSchemaToolParameters(tool, strict === true),
|
|
1161
|
+
...options?.deferLoading ? { defer_loading: true } : {}
|
|
1162
|
+
};
|
|
1163
|
+
if (supportsStrictMode) {
|
|
1164
|
+
functionTool.strict = strict;
|
|
1165
|
+
}
|
|
1166
|
+
return functionTool;
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
function getCustomToolCallInput(block) {
|
|
1170
|
+
const property = block.customInput?.property;
|
|
1171
|
+
if (property === void 0)
|
|
1172
|
+
return "";
|
|
1173
|
+
const value = block.arguments[property];
|
|
1174
|
+
return typeof value === "string" ? value : "";
|
|
1175
|
+
}
|
|
1176
|
+
function appendCustomToolCallInput(block, nextInput, close) {
|
|
1177
|
+
const customInput = block.customInput;
|
|
1178
|
+
if (!customInput)
|
|
1179
|
+
return void 0;
|
|
1180
|
+
const delta = appendGrammarToolInputJsonDelta(customInput.jsonBuffer, customInput.property, nextInput, close);
|
|
1181
|
+
block.arguments = { [customInput.property]: nextInput };
|
|
1182
|
+
return delta;
|
|
1183
|
+
}
|
|
1184
|
+
async function processResponsesStream(openaiStream, output, stream, model, options) {
|
|
1185
|
+
let sawTerminalResponseEvent = false;
|
|
1186
|
+
const outputSlots = /* @__PURE__ */ new Map();
|
|
1187
|
+
const reasoningBlocksById = /* @__PURE__ */ new Map();
|
|
1188
|
+
const applyMessagePhaseStopReason = (item) => {
|
|
1189
|
+
if (item.type === "message" && item.phase === "final_answer") {
|
|
1190
|
+
output.stopReason = "stop";
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
const getSlot = (outputIndex, type) => {
|
|
1194
|
+
const slot = outputSlots.get(outputIndex);
|
|
1195
|
+
return slot?.type === type ? slot : void 0;
|
|
1196
|
+
};
|
|
1197
|
+
const pushToolCallDelta = (slot, delta) => {
|
|
1198
|
+
if (delta === void 0)
|
|
1199
|
+
return;
|
|
1200
|
+
stream.push({
|
|
1201
|
+
type: "toolcall_delta",
|
|
1202
|
+
contentIndex: slot.contentIndex,
|
|
1203
|
+
delta,
|
|
1204
|
+
partial: output
|
|
1205
|
+
});
|
|
1206
|
+
};
|
|
1207
|
+
const createSlot = (outputIndex, item) => {
|
|
1208
|
+
if (item.type === "reasoning") {
|
|
1209
|
+
const block = { type: "thinking", thinking: "" };
|
|
1210
|
+
output.content.push(block);
|
|
1211
|
+
const slot = {
|
|
1212
|
+
type: "thinking",
|
|
1213
|
+
block,
|
|
1214
|
+
contentIndex: output.content.length - 1
|
|
1215
|
+
};
|
|
1216
|
+
outputSlots.set(outputIndex, slot);
|
|
1217
|
+
stream.push({ type: "thinking_start", contentIndex: slot.contentIndex, partial: output });
|
|
1218
|
+
return slot;
|
|
1219
|
+
}
|
|
1220
|
+
if (item.type === "message") {
|
|
1221
|
+
applyMessagePhaseStopReason(item);
|
|
1222
|
+
const block = { type: "text", text: "" };
|
|
1223
|
+
output.content.push(block);
|
|
1224
|
+
const slot = { type: "text", block, contentIndex: output.content.length - 1 };
|
|
1225
|
+
outputSlots.set(outputIndex, slot);
|
|
1226
|
+
stream.push({ type: "text_start", contentIndex: slot.contentIndex, partial: output });
|
|
1227
|
+
return slot;
|
|
1228
|
+
}
|
|
1229
|
+
if (item.type === "function_call") {
|
|
1230
|
+
const block = {
|
|
1231
|
+
type: "toolCall",
|
|
1232
|
+
id: `${item.call_id}|${item.id}`,
|
|
1233
|
+
name: item.name,
|
|
1234
|
+
arguments: {},
|
|
1235
|
+
...item.namespace !== void 0 ? { namespace: item.namespace } : {},
|
|
1236
|
+
partialJson: item.arguments || ""
|
|
1237
|
+
};
|
|
1238
|
+
output.content.push(block);
|
|
1239
|
+
const slot = {
|
|
1240
|
+
type: "toolCall",
|
|
1241
|
+
block,
|
|
1242
|
+
contentIndex: output.content.length - 1
|
|
1243
|
+
};
|
|
1244
|
+
outputSlots.set(outputIndex, slot);
|
|
1245
|
+
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
|
|
1246
|
+
return slot;
|
|
1247
|
+
}
|
|
1248
|
+
if (item.type === "custom_tool_call") {
|
|
1249
|
+
const inputProperty = options?.grammarToolInputProperties?.get(item.name) ?? "input";
|
|
1250
|
+
const input = item.input || "";
|
|
1251
|
+
const block = {
|
|
1252
|
+
type: "toolCall",
|
|
1253
|
+
id: `${item.call_id}|${item.id}`,
|
|
1254
|
+
name: item.name,
|
|
1255
|
+
arguments: { [inputProperty]: input },
|
|
1256
|
+
...item.namespace !== void 0 ? { namespace: item.namespace } : {},
|
|
1257
|
+
customInput: {
|
|
1258
|
+
property: inputProperty,
|
|
1259
|
+
jsonBuffer: { input: "", started: false, closed: false }
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
output.content.push(block);
|
|
1263
|
+
const slot = {
|
|
1264
|
+
type: "toolCall",
|
|
1265
|
+
block,
|
|
1266
|
+
contentIndex: output.content.length - 1
|
|
1267
|
+
};
|
|
1268
|
+
outputSlots.set(outputIndex, slot);
|
|
1269
|
+
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
|
|
1270
|
+
return slot;
|
|
1271
|
+
}
|
|
1272
|
+
return void 0;
|
|
1273
|
+
};
|
|
1274
|
+
const getOrCreateSlot = (outputIndex, item) => {
|
|
1275
|
+
return outputSlots.get(outputIndex) ?? createSlot(outputIndex, item);
|
|
1276
|
+
};
|
|
1277
|
+
const backfillReasoningSignatures = (responseOutput) => {
|
|
1278
|
+
for (const item of responseOutput) {
|
|
1279
|
+
if (item.type !== "reasoning" || !item.encrypted_content)
|
|
1280
|
+
continue;
|
|
1281
|
+
const block = reasoningBlocksById.get(item.id);
|
|
1282
|
+
if (!block?.thinkingSignature)
|
|
1283
|
+
continue;
|
|
1284
|
+
const storedItem = JSON.parse(block.thinkingSignature);
|
|
1285
|
+
if (storedItem.encrypted_content)
|
|
1286
|
+
continue;
|
|
1287
|
+
block.thinkingSignature = JSON.stringify({
|
|
1288
|
+
...storedItem,
|
|
1289
|
+
encrypted_content: item.encrypted_content
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
const finalizeResponse = (response) => {
|
|
1294
|
+
sawTerminalResponseEvent = true;
|
|
1295
|
+
backfillReasoningSignatures(response.output ?? []);
|
|
1296
|
+
if (response?.id) {
|
|
1297
|
+
output.responseId = response.id;
|
|
1298
|
+
}
|
|
1299
|
+
if (response?.usage) {
|
|
1300
|
+
const inputDetails = response.usage.input_tokens_details;
|
|
1301
|
+
const cachedTokens = inputDetails?.cached_tokens || 0;
|
|
1302
|
+
const cacheWriteTokens = inputDetails?.cache_write_tokens || 0;
|
|
1303
|
+
output.usage = {
|
|
1304
|
+
// OpenAI includes cached and cache-write tokens in input_tokens, so subtract both.
|
|
1305
|
+
input: Math.max(0, (response.usage.input_tokens || 0) - cachedTokens - cacheWriteTokens),
|
|
1306
|
+
output: response.usage.output_tokens || 0,
|
|
1307
|
+
cacheRead: cachedTokens,
|
|
1308
|
+
cacheWrite: cacheWriteTokens,
|
|
1309
|
+
reasoning: response.usage.output_tokens_details?.reasoning_tokens || 0,
|
|
1310
|
+
totalTokens: response.usage.total_tokens || 0,
|
|
1311
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
calculateCost(model, output.usage);
|
|
1315
|
+
if (options?.applyServiceTierPricing) {
|
|
1316
|
+
const serviceTier = options.resolveServiceTier ? options.resolveServiceTier(response?.service_tier, options.serviceTier) : response?.service_tier ?? options.serviceTier;
|
|
1317
|
+
options.applyServiceTierPricing(output.usage, serviceTier);
|
|
1318
|
+
}
|
|
1319
|
+
const status = response?.status;
|
|
1320
|
+
const incompleteDetails = response?.incomplete_details;
|
|
1321
|
+
const incompleteReason = typeof incompleteDetails?.reason === "string" ? incompleteDetails.reason : void 0;
|
|
1322
|
+
output.rawStopReason = incompleteReason ? `${status}.${incompleteReason}` : status;
|
|
1323
|
+
const mappedStop = mapStopReason(status, incompleteReason);
|
|
1324
|
+
output.stopReason = mappedStop.stopReason;
|
|
1325
|
+
if (mappedStop.errorMessage === void 0)
|
|
1326
|
+
delete output.errorMessage;
|
|
1327
|
+
else
|
|
1328
|
+
output.errorMessage = mappedStop.errorMessage;
|
|
1329
|
+
if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") {
|
|
1330
|
+
output.stopReason = "toolUse";
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
for await (const event of openaiStream) {
|
|
1334
|
+
if (event.type === "response.created") {
|
|
1335
|
+
output.responseId = event.response.id;
|
|
1336
|
+
} else if (event.type === "response.output_item.added") {
|
|
1337
|
+
createSlot(event.output_index, event.item);
|
|
1338
|
+
} else if (event.type === "response.reasoning_summary_text.delta") {
|
|
1339
|
+
const slot = getSlot(event.output_index, "thinking");
|
|
1340
|
+
if (!slot)
|
|
1341
|
+
continue;
|
|
1342
|
+
slot.block.thinking += event.delta;
|
|
1343
|
+
stream.push({
|
|
1344
|
+
type: "thinking_delta",
|
|
1345
|
+
contentIndex: slot.contentIndex,
|
|
1346
|
+
delta: event.delta,
|
|
1347
|
+
partial: output
|
|
1348
|
+
});
|
|
1349
|
+
} else if (event.type === "response.reasoning_summary_part.done") {
|
|
1350
|
+
const slot = getSlot(event.output_index, "thinking");
|
|
1351
|
+
if (!slot)
|
|
1352
|
+
continue;
|
|
1353
|
+
slot.block.thinking += "\n\n";
|
|
1354
|
+
stream.push({
|
|
1355
|
+
type: "thinking_delta",
|
|
1356
|
+
contentIndex: slot.contentIndex,
|
|
1357
|
+
delta: "\n\n",
|
|
1358
|
+
partial: output
|
|
1359
|
+
});
|
|
1360
|
+
} else if (event.type === "response.reasoning_text.delta") {
|
|
1361
|
+
const slot = getSlot(event.output_index, "thinking");
|
|
1362
|
+
if (!slot)
|
|
1363
|
+
continue;
|
|
1364
|
+
slot.block.thinking += event.delta;
|
|
1365
|
+
stream.push({
|
|
1366
|
+
type: "thinking_delta",
|
|
1367
|
+
contentIndex: slot.contentIndex,
|
|
1368
|
+
delta: event.delta,
|
|
1369
|
+
partial: output
|
|
1370
|
+
});
|
|
1371
|
+
} else if (event.type === "response.output_text.delta") {
|
|
1372
|
+
const slot = getSlot(event.output_index, "text");
|
|
1373
|
+
if (!slot)
|
|
1374
|
+
continue;
|
|
1375
|
+
slot.block.text += event.delta;
|
|
1376
|
+
stream.push({
|
|
1377
|
+
type: "text_delta",
|
|
1378
|
+
contentIndex: slot.contentIndex,
|
|
1379
|
+
delta: event.delta,
|
|
1380
|
+
partial: output
|
|
1381
|
+
});
|
|
1382
|
+
} else if (event.type === "response.refusal.delta") {
|
|
1383
|
+
const slot = getSlot(event.output_index, "text");
|
|
1384
|
+
if (!slot)
|
|
1385
|
+
continue;
|
|
1386
|
+
slot.block.text += event.delta;
|
|
1387
|
+
stream.push({
|
|
1388
|
+
type: "text_delta",
|
|
1389
|
+
contentIndex: slot.contentIndex,
|
|
1390
|
+
delta: event.delta,
|
|
1391
|
+
partial: output
|
|
1392
|
+
});
|
|
1393
|
+
} else if (event.type === "response.function_call_arguments.delta") {
|
|
1394
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
1395
|
+
if (!slot || slot.block.partialJson === void 0)
|
|
1396
|
+
continue;
|
|
1397
|
+
slot.block.partialJson += event.delta;
|
|
1398
|
+
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
1399
|
+
pushToolCallDelta(slot, event.delta);
|
|
1400
|
+
} else if (event.type === "response.function_call_arguments.done") {
|
|
1401
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
1402
|
+
if (!slot || slot.block.partialJson === void 0)
|
|
1403
|
+
continue;
|
|
1404
|
+
const previousPartialJson = slot.block.partialJson;
|
|
1405
|
+
slot.block.partialJson = event.arguments;
|
|
1406
|
+
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
1407
|
+
if (event.arguments.startsWith(previousPartialJson)) {
|
|
1408
|
+
const delta = event.arguments.slice(previousPartialJson.length);
|
|
1409
|
+
if (delta.length > 0)
|
|
1410
|
+
pushToolCallDelta(slot, delta);
|
|
1411
|
+
}
|
|
1412
|
+
} else if (event.type === "response.custom_tool_call_input.delta") {
|
|
1413
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
1414
|
+
if (!slot || !slot.block.customInput)
|
|
1415
|
+
continue;
|
|
1416
|
+
pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, getCustomToolCallInput(slot.block) + event.delta, false));
|
|
1417
|
+
} else if (event.type === "response.custom_tool_call_input.done") {
|
|
1418
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
1419
|
+
if (!slot || !slot.block.customInput)
|
|
1420
|
+
continue;
|
|
1421
|
+
pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, event.input, true));
|
|
1422
|
+
} else if (event.type === "response.output_item.done") {
|
|
1423
|
+
const item = event.item;
|
|
1424
|
+
applyMessagePhaseStopReason(item);
|
|
1425
|
+
const slot = getOrCreateSlot(event.output_index, item);
|
|
1426
|
+
if (item.type === "reasoning" && slot?.type === "thinking") {
|
|
1427
|
+
const summaryText = item.summary?.map((s) => s.text).join("\n\n") || "";
|
|
1428
|
+
const contentText = item.content?.map((c) => c.text).join("\n\n") || "";
|
|
1429
|
+
slot.block.thinking = summaryText || contentText || slot.block.thinking;
|
|
1430
|
+
slot.block.thinkingSignature = JSON.stringify(item);
|
|
1431
|
+
reasoningBlocksById.set(item.id, slot.block);
|
|
1432
|
+
stream.push({
|
|
1433
|
+
type: "thinking_end",
|
|
1434
|
+
contentIndex: slot.contentIndex,
|
|
1435
|
+
content: slot.block.thinking,
|
|
1436
|
+
partial: output
|
|
1437
|
+
});
|
|
1438
|
+
outputSlots.delete(event.output_index);
|
|
1439
|
+
} else if (item.type === "message" && slot?.type === "text") {
|
|
1440
|
+
slot.block.text = item.content?.map((c) => c.type === "output_text" ? c.text : c.refusal).join("") || "";
|
|
1441
|
+
slot.block.textSignature = encodeTextSignatureV1(item.id, item.phase ?? void 0);
|
|
1442
|
+
stream.push({
|
|
1443
|
+
type: "text_end",
|
|
1444
|
+
contentIndex: slot.contentIndex,
|
|
1445
|
+
content: slot.block.text,
|
|
1446
|
+
partial: output
|
|
1447
|
+
});
|
|
1448
|
+
outputSlots.delete(event.output_index);
|
|
1449
|
+
} else if (item.type === "function_call" && slot?.type === "toolCall" && slot.block.partialJson !== void 0) {
|
|
1450
|
+
slot.block.arguments = parseStreamingJson(item.arguments || slot.block.partialJson || "{}");
|
|
1451
|
+
if (item.namespace !== void 0)
|
|
1452
|
+
slot.block.namespace = item.namespace;
|
|
1453
|
+
delete slot.block.partialJson;
|
|
1454
|
+
stream.push({
|
|
1455
|
+
type: "toolcall_end",
|
|
1456
|
+
contentIndex: slot.contentIndex,
|
|
1457
|
+
toolCall: slot.block,
|
|
1458
|
+
partial: output
|
|
1459
|
+
});
|
|
1460
|
+
outputSlots.delete(event.output_index);
|
|
1461
|
+
} else if (item.type === "custom_tool_call" && slot?.type === "toolCall" && slot.block.customInput) {
|
|
1462
|
+
pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, item.input ?? getCustomToolCallInput(slot.block), true));
|
|
1463
|
+
if (item.namespace !== void 0)
|
|
1464
|
+
slot.block.namespace = item.namespace;
|
|
1465
|
+
delete slot.block.customInput;
|
|
1466
|
+
stream.push({
|
|
1467
|
+
type: "toolcall_end",
|
|
1468
|
+
contentIndex: slot.contentIndex,
|
|
1469
|
+
toolCall: slot.block,
|
|
1470
|
+
partial: output
|
|
1471
|
+
});
|
|
1472
|
+
outputSlots.delete(event.output_index);
|
|
1473
|
+
}
|
|
1474
|
+
} else if (event.type === "response.completed" || event.type === "response.incomplete") {
|
|
1475
|
+
finalizeResponse(event.response);
|
|
1476
|
+
} else if (event.type === "error") {
|
|
1477
|
+
throw new Error(`Error Code ${event.code}: ${event.message}` || "Unknown error");
|
|
1478
|
+
} else if (event.type === "response.failed") {
|
|
1479
|
+
sawTerminalResponseEvent = true;
|
|
1480
|
+
output.rawStopReason = event.response?.status;
|
|
1481
|
+
const error = event.response?.error;
|
|
1482
|
+
const details = event.response?.incomplete_details;
|
|
1483
|
+
const msg = error ? `${error.code || "unknown"}: ${error.message || "no message"}` : details?.reason ? `incomplete: ${details.reason}` : "Unknown error (no error details in response)";
|
|
1484
|
+
throw new Error(msg);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
if (!sawTerminalResponseEvent) {
|
|
1488
|
+
throw new Error("OpenAI Responses stream ended before a terminal response event");
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
function mapStopReason(status, incompleteReason) {
|
|
1492
|
+
if (!status)
|
|
1493
|
+
return { stopReason: "stop" };
|
|
1494
|
+
switch (status) {
|
|
1495
|
+
case "completed":
|
|
1496
|
+
return { stopReason: "stop" };
|
|
1497
|
+
case "incomplete":
|
|
1498
|
+
if (incompleteReason === "max_output_tokens") {
|
|
1499
|
+
return { stopReason: "length" };
|
|
1500
|
+
}
|
|
1501
|
+
return {
|
|
1502
|
+
stopReason: "error",
|
|
1503
|
+
errorMessage: incompleteReason ? `Response incomplete: ${incompleteReason}` : "Response incomplete without a provider reason"
|
|
1504
|
+
};
|
|
1505
|
+
case "failed":
|
|
1506
|
+
case "cancelled":
|
|
1507
|
+
return { stopReason: "error" };
|
|
1508
|
+
// These two are wonky ...
|
|
1509
|
+
case "in_progress":
|
|
1510
|
+
case "queued":
|
|
1511
|
+
return { stopReason: "stop" };
|
|
1512
|
+
default: {
|
|
1513
|
+
const _exhaustive = status;
|
|
1514
|
+
throw new Error(`Unhandled stop reason: ${_exhaustive}`);
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
// scripts/runtime-dsh015/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.js
|
|
1520
|
+
var OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
|
|
1521
|
+
function clampOpenAIPromptCacheKey(key) {
|
|
1522
|
+
if (key === void 0)
|
|
1523
|
+
return void 0;
|
|
1524
|
+
const chars = Array.from(key);
|
|
1525
|
+
if (chars.length <= OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH)
|
|
1526
|
+
return key;
|
|
1527
|
+
return chars.slice(0, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH).join("");
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
// src/pi-responses-runtime.ts
|
|
1531
|
+
var RESPONSE_CATALOGS = {
|
|
1532
|
+
"cloudflare-ai-gateway": CLOUDFLARE_AI_GATEWAY_MODELS,
|
|
1533
|
+
"github-copilot": GITHUB_COPILOT_MODELS,
|
|
1534
|
+
openai: OPENAI_MODELS,
|
|
1535
|
+
opencode: OPENCODE_MODELS,
|
|
1536
|
+
"opencode-go": OPENCODE_GO_MODELS,
|
|
1537
|
+
xai: XAI_MODELS
|
|
1538
|
+
};
|
|
1539
|
+
var providers = Object.freeze(
|
|
1540
|
+
Object.keys(RESPONSE_CATALOGS)
|
|
1541
|
+
);
|
|
1542
|
+
function responsesOnly(catalog) {
|
|
1543
|
+
return Object.values(catalog).filter(
|
|
1544
|
+
(model) => model.api === "openai-responses"
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
var models = {
|
|
1548
|
+
"cloudflare-ai-gateway": responsesOnly(RESPONSE_CATALOGS["cloudflare-ai-gateway"]),
|
|
1549
|
+
"github-copilot": responsesOnly(RESPONSE_CATALOGS["github-copilot"]),
|
|
1550
|
+
openai: responsesOnly(RESPONSE_CATALOGS.openai),
|
|
1551
|
+
opencode: responsesOnly(RESPONSE_CATALOGS.opencode),
|
|
1552
|
+
"opencode-go": responsesOnly(RESPONSE_CATALOGS["opencode-go"]),
|
|
1553
|
+
xai: responsesOnly(RESPONSE_CATALOGS.xai)
|
|
1554
|
+
};
|
|
1555
|
+
function getBuiltinProviders() {
|
|
1556
|
+
return providers;
|
|
1557
|
+
}
|
|
1558
|
+
function getBuiltinModels(provider) {
|
|
1559
|
+
return models[provider] ?? [];
|
|
1560
|
+
}
|
|
1561
|
+
export {
|
|
1562
|
+
clampOpenAIPromptCacheKey,
|
|
1563
|
+
convertResponsesMessages,
|
|
1564
|
+
convertResponsesTools,
|
|
1565
|
+
createAssistantMessageEventStream,
|
|
1566
|
+
createGrammarToolInputProperties,
|
|
1567
|
+
getBuiltinModels,
|
|
1568
|
+
getBuiltinProviders,
|
|
1569
|
+
getSupportedThinkingLevels,
|
|
1570
|
+
processResponsesStream
|
|
1571
|
+
};
|