@zenning/openai 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +108 -0
- package/dist/index.d.mts +86 -27
- package/dist/index.d.ts +86 -27
- package/dist/index.js +738 -429
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +714 -404
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +371 -24
- package/dist/internal/index.d.ts +371 -24
- package/dist/internal/index.js +745 -429
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +715 -412
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/internal/index.mjs
CHANGED
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
isParsableJson,
|
|
11
11
|
parseProviderOptions,
|
|
12
12
|
postJsonToApi
|
|
13
|
-
} from "@
|
|
13
|
+
} from "@zenning/provider-utils";
|
|
14
14
|
import { z as z3 } from "zod/v4";
|
|
15
15
|
|
|
16
16
|
// src/openai-error.ts
|
|
17
17
|
import { z } from "zod/v4";
|
|
18
|
-
import { createJsonErrorResponseHandler } from "@
|
|
18
|
+
import { createJsonErrorResponseHandler } from "@zenning/provider-utils";
|
|
19
19
|
var openaiErrorDataSchema = z.object({
|
|
20
20
|
error: z.object({
|
|
21
21
|
message: z.string(),
|
|
@@ -36,7 +36,7 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
36
36
|
import {
|
|
37
37
|
UnsupportedFunctionalityError
|
|
38
38
|
} from "@zenning/provider";
|
|
39
|
-
import { convertToBase64 } from "@
|
|
39
|
+
import { convertToBase64 } from "@zenning/provider-utils";
|
|
40
40
|
function convertToOpenAIChatMessages({
|
|
41
41
|
prompt,
|
|
42
42
|
systemMessageMode = "system"
|
|
@@ -244,7 +244,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
244
244
|
|
|
245
245
|
// src/chat/openai-chat-options.ts
|
|
246
246
|
import { z as z2 } from "zod/v4";
|
|
247
|
-
var
|
|
247
|
+
var openaiChatLanguageModelOptions = z2.object({
|
|
248
248
|
/**
|
|
249
249
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
250
250
|
*
|
|
@@ -398,7 +398,7 @@ function prepareChatTools({
|
|
|
398
398
|
// src/chat/openai-chat-language-model.ts
|
|
399
399
|
var OpenAIChatLanguageModel = class {
|
|
400
400
|
constructor(modelId, config) {
|
|
401
|
-
this.specificationVersion = "
|
|
401
|
+
this.specificationVersion = "v3";
|
|
402
402
|
this.supportedUrls = {
|
|
403
403
|
"image/*": [/^https?:\/\/.*$/]
|
|
404
404
|
};
|
|
@@ -428,7 +428,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
428
428
|
const openaiOptions = (_a = await parseProviderOptions({
|
|
429
429
|
provider: "openai",
|
|
430
430
|
providerOptions,
|
|
431
|
-
schema:
|
|
431
|
+
schema: openaiChatLanguageModelOptions
|
|
432
432
|
})) != null ? _a : {};
|
|
433
433
|
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
434
434
|
if (topK != null) {
|
|
@@ -1059,7 +1059,7 @@ import {
|
|
|
1059
1059
|
createJsonResponseHandler as createJsonResponseHandler2,
|
|
1060
1060
|
parseProviderOptions as parseProviderOptions2,
|
|
1061
1061
|
postJsonToApi as postJsonToApi2
|
|
1062
|
-
} from "@
|
|
1062
|
+
} from "@zenning/provider-utils";
|
|
1063
1063
|
import { z as z5 } from "zod/v4";
|
|
1064
1064
|
|
|
1065
1065
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
@@ -1216,7 +1216,7 @@ var openaiCompletionProviderOptions = z4.object({
|
|
|
1216
1216
|
// src/completion/openai-completion-language-model.ts
|
|
1217
1217
|
var OpenAICompletionLanguageModel = class {
|
|
1218
1218
|
constructor(modelId, config) {
|
|
1219
|
-
this.specificationVersion = "
|
|
1219
|
+
this.specificationVersion = "v3";
|
|
1220
1220
|
this.supportedUrls = {
|
|
1221
1221
|
// No URLs are supported for completion models.
|
|
1222
1222
|
};
|
|
@@ -1495,7 +1495,7 @@ import {
|
|
|
1495
1495
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
1496
1496
|
parseProviderOptions as parseProviderOptions3,
|
|
1497
1497
|
postJsonToApi as postJsonToApi3
|
|
1498
|
-
} from "@
|
|
1498
|
+
} from "@zenning/provider-utils";
|
|
1499
1499
|
import { z as z7 } from "zod/v4";
|
|
1500
1500
|
|
|
1501
1501
|
// src/embedding/openai-embedding-options.ts
|
|
@@ -1516,7 +1516,7 @@ var openaiEmbeddingProviderOptions = z6.object({
|
|
|
1516
1516
|
// src/embedding/openai-embedding-model.ts
|
|
1517
1517
|
var OpenAIEmbeddingModel = class {
|
|
1518
1518
|
constructor(modelId, config) {
|
|
1519
|
-
this.specificationVersion = "
|
|
1519
|
+
this.specificationVersion = "v3";
|
|
1520
1520
|
this.maxEmbeddingsPerCall = 2048;
|
|
1521
1521
|
this.supportsParallelCalls = true;
|
|
1522
1522
|
this.modelId = modelId;
|
|
@@ -1586,7 +1586,7 @@ import {
|
|
|
1586
1586
|
combineHeaders as combineHeaders4,
|
|
1587
1587
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1588
1588
|
postJsonToApi as postJsonToApi4
|
|
1589
|
-
} from "@
|
|
1589
|
+
} from "@zenning/provider-utils";
|
|
1590
1590
|
import { z as z8 } from "zod/v4";
|
|
1591
1591
|
|
|
1592
1592
|
// src/image/openai-image-options.ts
|
|
@@ -1602,7 +1602,7 @@ var OpenAIImageModel = class {
|
|
|
1602
1602
|
constructor(modelId, config) {
|
|
1603
1603
|
this.modelId = modelId;
|
|
1604
1604
|
this.config = config;
|
|
1605
|
-
this.specificationVersion = "
|
|
1605
|
+
this.specificationVersion = "v3";
|
|
1606
1606
|
}
|
|
1607
1607
|
get maxImagesPerCall() {
|
|
1608
1608
|
var _a;
|
|
@@ -1689,7 +1689,7 @@ import {
|
|
|
1689
1689
|
mediaTypeToExtension,
|
|
1690
1690
|
parseProviderOptions as parseProviderOptions4,
|
|
1691
1691
|
postFormDataToApi
|
|
1692
|
-
} from "@
|
|
1692
|
+
} from "@zenning/provider-utils";
|
|
1693
1693
|
import { z as z10 } from "zod/v4";
|
|
1694
1694
|
|
|
1695
1695
|
// src/transcription/openai-transcription-options.ts
|
|
@@ -1918,7 +1918,7 @@ import {
|
|
|
1918
1918
|
createBinaryResponseHandler,
|
|
1919
1919
|
parseProviderOptions as parseProviderOptions5,
|
|
1920
1920
|
postJsonToApi as postJsonToApi5
|
|
1921
|
-
} from "@
|
|
1921
|
+
} from "@zenning/provider-utils";
|
|
1922
1922
|
import { z as z11 } from "zod/v4";
|
|
1923
1923
|
var OpenAIProviderOptionsSchema = z11.object({
|
|
1924
1924
|
instructions: z11.string().nullish(),
|
|
@@ -2035,15 +2035,40 @@ import {
|
|
|
2035
2035
|
generateId as generateId2,
|
|
2036
2036
|
parseProviderOptions as parseProviderOptions7,
|
|
2037
2037
|
postJsonToApi as postJsonToApi6
|
|
2038
|
-
} from "@
|
|
2039
|
-
import { z as
|
|
2038
|
+
} from "@zenning/provider-utils";
|
|
2039
|
+
import { z as z19 } from "zod/v4";
|
|
2040
2040
|
|
|
2041
2041
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2042
2042
|
import {
|
|
2043
2043
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2044
2044
|
} from "@zenning/provider";
|
|
2045
|
-
import { convertToBase64 as convertToBase642, parseProviderOptions as parseProviderOptions6 } from "@
|
|
2045
|
+
import { convertToBase64 as convertToBase642, parseProviderOptions as parseProviderOptions6 } from "@zenning/provider-utils";
|
|
2046
|
+
import { z as z13 } from "zod/v4";
|
|
2047
|
+
|
|
2048
|
+
// src/tool/local-shell.ts
|
|
2049
|
+
import { createProviderDefinedToolFactoryWithOutputSchema } from "@zenning/provider-utils";
|
|
2046
2050
|
import { z as z12 } from "zod/v4";
|
|
2051
|
+
var localShellInputSchema = z12.object({
|
|
2052
|
+
action: z12.object({
|
|
2053
|
+
type: z12.literal("exec"),
|
|
2054
|
+
command: z12.array(z12.string()),
|
|
2055
|
+
timeoutMs: z12.number().optional(),
|
|
2056
|
+
user: z12.string().optional(),
|
|
2057
|
+
workingDirectory: z12.string().optional(),
|
|
2058
|
+
env: z12.record(z12.string(), z12.string()).optional()
|
|
2059
|
+
})
|
|
2060
|
+
});
|
|
2061
|
+
var localShellOutputSchema = z12.object({
|
|
2062
|
+
output: z12.string()
|
|
2063
|
+
});
|
|
2064
|
+
var localShell = createProviderDefinedToolFactoryWithOutputSchema({
|
|
2065
|
+
id: "openai.local_shell",
|
|
2066
|
+
name: "local_shell",
|
|
2067
|
+
inputSchema: localShellInputSchema,
|
|
2068
|
+
outputSchema: localShellOutputSchema
|
|
2069
|
+
});
|
|
2070
|
+
|
|
2071
|
+
// src/responses/convert-to-openai-responses-input.ts
|
|
2047
2072
|
function isFileId(data, prefixes) {
|
|
2048
2073
|
if (!prefixes) return false;
|
|
2049
2074
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -2052,9 +2077,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2052
2077
|
prompt,
|
|
2053
2078
|
systemMessageMode,
|
|
2054
2079
|
fileIdPrefixes,
|
|
2055
|
-
store
|
|
2080
|
+
store,
|
|
2081
|
+
hasLocalShellTool = false
|
|
2056
2082
|
}) {
|
|
2057
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2083
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2058
2084
|
const input = [];
|
|
2059
2085
|
const warnings = [];
|
|
2060
2086
|
for (const { role, content } of prompt) {
|
|
@@ -2147,12 +2173,29 @@ async function convertToOpenAIResponsesInput({
|
|
|
2147
2173
|
if (part.providerExecuted) {
|
|
2148
2174
|
break;
|
|
2149
2175
|
}
|
|
2176
|
+
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2177
|
+
const parsedInput = localShellInputSchema.parse(part.input);
|
|
2178
|
+
input.push({
|
|
2179
|
+
type: "local_shell_call",
|
|
2180
|
+
call_id: part.toolCallId,
|
|
2181
|
+
id: (_f = (_e = (_d = part.providerOptions) == null ? void 0 : _d.openai) == null ? void 0 : _e.itemId) != null ? _f : void 0,
|
|
2182
|
+
action: {
|
|
2183
|
+
type: "exec",
|
|
2184
|
+
command: parsedInput.action.command,
|
|
2185
|
+
timeout_ms: parsedInput.action.timeoutMs,
|
|
2186
|
+
user: parsedInput.action.user,
|
|
2187
|
+
working_directory: parsedInput.action.workingDirectory,
|
|
2188
|
+
env: parsedInput.action.env
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
break;
|
|
2192
|
+
}
|
|
2150
2193
|
input.push({
|
|
2151
2194
|
type: "function_call",
|
|
2152
2195
|
call_id: part.toolCallId,
|
|
2153
2196
|
name: part.toolName,
|
|
2154
2197
|
arguments: JSON.stringify(part.input),
|
|
2155
|
-
id: (
|
|
2198
|
+
id: (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.itemId) != null ? _i : void 0
|
|
2156
2199
|
});
|
|
2157
2200
|
break;
|
|
2158
2201
|
}
|
|
@@ -2176,26 +2219,40 @@ async function convertToOpenAIResponsesInput({
|
|
|
2176
2219
|
});
|
|
2177
2220
|
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2178
2221
|
if (reasoningId != null) {
|
|
2179
|
-
const
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
if (existingReasoningMessage === void 0) {
|
|
2190
|
-
reasoningMessages[reasoningId] = {
|
|
2191
|
-
type: "reasoning",
|
|
2192
|
-
id: reasoningId,
|
|
2193
|
-
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2194
|
-
summary: summaryParts
|
|
2195
|
-
};
|
|
2196
|
-
input.push(reasoningMessages[reasoningId]);
|
|
2222
|
+
const reasoningMessage = reasoningMessages[reasoningId];
|
|
2223
|
+
if (store) {
|
|
2224
|
+
if (reasoningMessage === void 0) {
|
|
2225
|
+
input.push({ type: "item_reference", id: reasoningId });
|
|
2226
|
+
reasoningMessages[reasoningId] = {
|
|
2227
|
+
type: "reasoning",
|
|
2228
|
+
id: reasoningId,
|
|
2229
|
+
summary: []
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2197
2232
|
} else {
|
|
2198
|
-
|
|
2233
|
+
const summaryParts = [];
|
|
2234
|
+
if (part.text.length > 0) {
|
|
2235
|
+
summaryParts.push({
|
|
2236
|
+
type: "summary_text",
|
|
2237
|
+
text: part.text
|
|
2238
|
+
});
|
|
2239
|
+
} else if (reasoningMessage !== void 0) {
|
|
2240
|
+
warnings.push({
|
|
2241
|
+
type: "other",
|
|
2242
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
if (reasoningMessage === void 0) {
|
|
2246
|
+
reasoningMessages[reasoningId] = {
|
|
2247
|
+
type: "reasoning",
|
|
2248
|
+
id: reasoningId,
|
|
2249
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2250
|
+
summary: summaryParts
|
|
2251
|
+
};
|
|
2252
|
+
input.push(reasoningMessages[reasoningId]);
|
|
2253
|
+
} else {
|
|
2254
|
+
reasoningMessage.summary.push(...summaryParts);
|
|
2255
|
+
}
|
|
2199
2256
|
}
|
|
2200
2257
|
} else {
|
|
2201
2258
|
warnings.push({
|
|
@@ -2212,6 +2269,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2212
2269
|
case "tool": {
|
|
2213
2270
|
for (const part of content) {
|
|
2214
2271
|
const output = part.output;
|
|
2272
|
+
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2273
|
+
input.push({
|
|
2274
|
+
type: "local_shell_call_output",
|
|
2275
|
+
call_id: part.toolCallId,
|
|
2276
|
+
output: localShellOutputSchema.parse(output.value).output
|
|
2277
|
+
});
|
|
2278
|
+
break;
|
|
2279
|
+
}
|
|
2215
2280
|
let contentValue;
|
|
2216
2281
|
switch (output.type) {
|
|
2217
2282
|
case "text":
|
|
@@ -2240,9 +2305,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2240
2305
|
}
|
|
2241
2306
|
return { input, warnings };
|
|
2242
2307
|
}
|
|
2243
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
2244
|
-
itemId:
|
|
2245
|
-
reasoningEncryptedContent:
|
|
2308
|
+
var openaiResponsesReasoningProviderOptionsSchema = z13.object({
|
|
2309
|
+
itemId: z13.string().nullish(),
|
|
2310
|
+
reasoningEncryptedContent: z13.string().nullish()
|
|
2246
2311
|
});
|
|
2247
2312
|
|
|
2248
2313
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -2269,200 +2334,207 @@ import {
|
|
|
2269
2334
|
} from "@zenning/provider";
|
|
2270
2335
|
|
|
2271
2336
|
// src/tool/code-interpreter.ts
|
|
2272
|
-
import { createProviderDefinedToolFactoryWithOutputSchema } from "@
|
|
2273
|
-
import { z as
|
|
2274
|
-
var codeInterpreterInputSchema =
|
|
2275
|
-
code:
|
|
2276
|
-
containerId:
|
|
2337
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@zenning/provider-utils";
|
|
2338
|
+
import { z as z14 } from "zod/v4";
|
|
2339
|
+
var codeInterpreterInputSchema = z14.object({
|
|
2340
|
+
code: z14.string().nullish(),
|
|
2341
|
+
containerId: z14.string()
|
|
2277
2342
|
});
|
|
2278
|
-
var codeInterpreterOutputSchema =
|
|
2279
|
-
outputs:
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2343
|
+
var codeInterpreterOutputSchema = z14.object({
|
|
2344
|
+
outputs: z14.array(
|
|
2345
|
+
z14.discriminatedUnion("type", [
|
|
2346
|
+
z14.object({ type: z14.literal("logs"), logs: z14.string() }),
|
|
2347
|
+
z14.object({ type: z14.literal("image"), url: z14.string() })
|
|
2283
2348
|
])
|
|
2284
2349
|
).nullish()
|
|
2285
2350
|
});
|
|
2286
|
-
var codeInterpreterArgsSchema =
|
|
2287
|
-
container:
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
fileIds:
|
|
2351
|
+
var codeInterpreterArgsSchema = z14.object({
|
|
2352
|
+
container: z14.union([
|
|
2353
|
+
z14.string(),
|
|
2354
|
+
z14.object({
|
|
2355
|
+
fileIds: z14.array(z14.string()).optional()
|
|
2291
2356
|
})
|
|
2292
2357
|
]).optional()
|
|
2293
2358
|
});
|
|
2294
|
-
var codeInterpreterToolFactory =
|
|
2359
|
+
var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
2295
2360
|
id: "openai.code_interpreter",
|
|
2296
2361
|
name: "code_interpreter",
|
|
2297
2362
|
inputSchema: codeInterpreterInputSchema,
|
|
2298
2363
|
outputSchema: codeInterpreterOutputSchema
|
|
2299
2364
|
});
|
|
2365
|
+
var codeInterpreter = (args = {}) => {
|
|
2366
|
+
return codeInterpreterToolFactory(args);
|
|
2367
|
+
};
|
|
2300
2368
|
|
|
2301
2369
|
// src/tool/file-search.ts
|
|
2302
|
-
import { createProviderDefinedToolFactoryWithOutputSchema as
|
|
2303
|
-
import { z as
|
|
2304
|
-
var comparisonFilterSchema =
|
|
2305
|
-
key:
|
|
2306
|
-
type:
|
|
2307
|
-
value:
|
|
2370
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@zenning/provider-utils";
|
|
2371
|
+
import { z as z15 } from "zod/v4";
|
|
2372
|
+
var comparisonFilterSchema = z15.object({
|
|
2373
|
+
key: z15.string(),
|
|
2374
|
+
type: z15.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
2375
|
+
value: z15.union([z15.string(), z15.number(), z15.boolean()])
|
|
2308
2376
|
});
|
|
2309
|
-
var compoundFilterSchema =
|
|
2310
|
-
type:
|
|
2311
|
-
filters:
|
|
2312
|
-
|
|
2377
|
+
var compoundFilterSchema = z15.object({
|
|
2378
|
+
type: z15.enum(["and", "or"]),
|
|
2379
|
+
filters: z15.array(
|
|
2380
|
+
z15.union([comparisonFilterSchema, z15.lazy(() => compoundFilterSchema)])
|
|
2313
2381
|
)
|
|
2314
2382
|
});
|
|
2315
|
-
var fileSearchArgsSchema =
|
|
2316
|
-
vectorStoreIds:
|
|
2317
|
-
maxNumResults:
|
|
2318
|
-
ranking:
|
|
2319
|
-
ranker:
|
|
2320
|
-
scoreThreshold:
|
|
2383
|
+
var fileSearchArgsSchema = z15.object({
|
|
2384
|
+
vectorStoreIds: z15.array(z15.string()),
|
|
2385
|
+
maxNumResults: z15.number().optional(),
|
|
2386
|
+
ranking: z15.object({
|
|
2387
|
+
ranker: z15.string().optional(),
|
|
2388
|
+
scoreThreshold: z15.number().optional()
|
|
2321
2389
|
}).optional(),
|
|
2322
|
-
filters:
|
|
2390
|
+
filters: z15.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
2323
2391
|
});
|
|
2324
|
-
var fileSearchOutputSchema =
|
|
2325
|
-
queries:
|
|
2326
|
-
results:
|
|
2327
|
-
|
|
2328
|
-
attributes:
|
|
2329
|
-
fileId:
|
|
2330
|
-
filename:
|
|
2331
|
-
score:
|
|
2332
|
-
text:
|
|
2392
|
+
var fileSearchOutputSchema = z15.object({
|
|
2393
|
+
queries: z15.array(z15.string()),
|
|
2394
|
+
results: z15.array(
|
|
2395
|
+
z15.object({
|
|
2396
|
+
attributes: z15.record(z15.string(), z15.unknown()),
|
|
2397
|
+
fileId: z15.string(),
|
|
2398
|
+
filename: z15.string(),
|
|
2399
|
+
score: z15.number(),
|
|
2400
|
+
text: z15.string()
|
|
2333
2401
|
})
|
|
2334
2402
|
).nullable()
|
|
2335
2403
|
});
|
|
2336
|
-
var fileSearch =
|
|
2404
|
+
var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
2337
2405
|
id: "openai.file_search",
|
|
2338
2406
|
name: "file_search",
|
|
2339
|
-
inputSchema:
|
|
2407
|
+
inputSchema: z15.object({}),
|
|
2340
2408
|
outputSchema: fileSearchOutputSchema
|
|
2341
2409
|
});
|
|
2342
2410
|
|
|
2343
2411
|
// src/tool/web-search.ts
|
|
2344
|
-
import { createProviderDefinedToolFactory } from "@
|
|
2345
|
-
import { z as
|
|
2346
|
-
var webSearchArgsSchema =
|
|
2347
|
-
filters:
|
|
2348
|
-
allowedDomains:
|
|
2412
|
+
import { createProviderDefinedToolFactory } from "@zenning/provider-utils";
|
|
2413
|
+
import { z as z16 } from "zod/v4";
|
|
2414
|
+
var webSearchArgsSchema = z16.object({
|
|
2415
|
+
filters: z16.object({
|
|
2416
|
+
allowedDomains: z16.array(z16.string()).optional()
|
|
2349
2417
|
}).optional(),
|
|
2350
|
-
searchContextSize:
|
|
2351
|
-
userLocation:
|
|
2352
|
-
type:
|
|
2353
|
-
country:
|
|
2354
|
-
city:
|
|
2355
|
-
region:
|
|
2356
|
-
timezone:
|
|
2418
|
+
searchContextSize: z16.enum(["low", "medium", "high"]).optional(),
|
|
2419
|
+
userLocation: z16.object({
|
|
2420
|
+
type: z16.literal("approximate"),
|
|
2421
|
+
country: z16.string().optional(),
|
|
2422
|
+
city: z16.string().optional(),
|
|
2423
|
+
region: z16.string().optional(),
|
|
2424
|
+
timezone: z16.string().optional()
|
|
2357
2425
|
}).optional()
|
|
2358
2426
|
});
|
|
2359
2427
|
var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
2360
2428
|
id: "openai.web_search",
|
|
2361
2429
|
name: "web_search",
|
|
2362
|
-
inputSchema:
|
|
2363
|
-
action:
|
|
2364
|
-
|
|
2365
|
-
type:
|
|
2366
|
-
query:
|
|
2430
|
+
inputSchema: z16.object({
|
|
2431
|
+
action: z16.discriminatedUnion("type", [
|
|
2432
|
+
z16.object({
|
|
2433
|
+
type: z16.literal("search"),
|
|
2434
|
+
query: z16.string().nullish()
|
|
2367
2435
|
}),
|
|
2368
|
-
|
|
2369
|
-
type:
|
|
2370
|
-
url:
|
|
2436
|
+
z16.object({
|
|
2437
|
+
type: z16.literal("open_page"),
|
|
2438
|
+
url: z16.string()
|
|
2371
2439
|
}),
|
|
2372
|
-
|
|
2373
|
-
type:
|
|
2374
|
-
url:
|
|
2375
|
-
pattern:
|
|
2440
|
+
z16.object({
|
|
2441
|
+
type: z16.literal("find"),
|
|
2442
|
+
url: z16.string(),
|
|
2443
|
+
pattern: z16.string()
|
|
2376
2444
|
})
|
|
2377
2445
|
]).nullish()
|
|
2378
2446
|
})
|
|
2379
2447
|
});
|
|
2380
2448
|
|
|
2381
2449
|
// src/tool/web-search-preview.ts
|
|
2382
|
-
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@
|
|
2383
|
-
import { z as
|
|
2384
|
-
var webSearchPreviewArgsSchema =
|
|
2450
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@zenning/provider-utils";
|
|
2451
|
+
import { z as z17 } from "zod/v4";
|
|
2452
|
+
var webSearchPreviewArgsSchema = z17.object({
|
|
2385
2453
|
/**
|
|
2386
2454
|
* Search context size to use for the web search.
|
|
2387
2455
|
* - high: Most comprehensive context, highest cost, slower response
|
|
2388
2456
|
* - medium: Balanced context, cost, and latency (default)
|
|
2389
2457
|
* - low: Least context, lowest cost, fastest response
|
|
2390
2458
|
*/
|
|
2391
|
-
searchContextSize:
|
|
2459
|
+
searchContextSize: z17.enum(["low", "medium", "high"]).optional(),
|
|
2392
2460
|
/**
|
|
2393
2461
|
* User location information to provide geographically relevant search results.
|
|
2394
2462
|
*/
|
|
2395
|
-
userLocation:
|
|
2463
|
+
userLocation: z17.object({
|
|
2396
2464
|
/**
|
|
2397
2465
|
* Type of location (always 'approximate')
|
|
2398
2466
|
*/
|
|
2399
|
-
type:
|
|
2467
|
+
type: z17.literal("approximate"),
|
|
2400
2468
|
/**
|
|
2401
2469
|
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
2402
2470
|
*/
|
|
2403
|
-
country:
|
|
2471
|
+
country: z17.string().optional(),
|
|
2404
2472
|
/**
|
|
2405
2473
|
* City name (free text, e.g., 'Minneapolis')
|
|
2406
2474
|
*/
|
|
2407
|
-
city:
|
|
2475
|
+
city: z17.string().optional(),
|
|
2408
2476
|
/**
|
|
2409
2477
|
* Region name (free text, e.g., 'Minnesota')
|
|
2410
2478
|
*/
|
|
2411
|
-
region:
|
|
2479
|
+
region: z17.string().optional(),
|
|
2412
2480
|
/**
|
|
2413
2481
|
* IANA timezone (e.g., 'America/Chicago')
|
|
2414
2482
|
*/
|
|
2415
|
-
timezone:
|
|
2483
|
+
timezone: z17.string().optional()
|
|
2416
2484
|
}).optional()
|
|
2417
2485
|
});
|
|
2418
2486
|
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
2419
2487
|
id: "openai.web_search_preview",
|
|
2420
2488
|
name: "web_search_preview",
|
|
2421
|
-
inputSchema:
|
|
2422
|
-
action:
|
|
2423
|
-
|
|
2424
|
-
type:
|
|
2425
|
-
query:
|
|
2489
|
+
inputSchema: z17.object({
|
|
2490
|
+
action: z17.discriminatedUnion("type", [
|
|
2491
|
+
z17.object({
|
|
2492
|
+
type: z17.literal("search"),
|
|
2493
|
+
query: z17.string().nullish()
|
|
2426
2494
|
}),
|
|
2427
|
-
|
|
2428
|
-
type:
|
|
2429
|
-
url:
|
|
2495
|
+
z17.object({
|
|
2496
|
+
type: z17.literal("open_page"),
|
|
2497
|
+
url: z17.string()
|
|
2430
2498
|
}),
|
|
2431
|
-
|
|
2432
|
-
type:
|
|
2433
|
-
url:
|
|
2434
|
-
pattern:
|
|
2499
|
+
z17.object({
|
|
2500
|
+
type: z17.literal("find"),
|
|
2501
|
+
url: z17.string(),
|
|
2502
|
+
pattern: z17.string()
|
|
2435
2503
|
})
|
|
2436
2504
|
]).nullish()
|
|
2437
2505
|
})
|
|
2438
2506
|
});
|
|
2439
2507
|
|
|
2440
2508
|
// src/tool/image-generation.ts
|
|
2441
|
-
import { createProviderDefinedToolFactoryWithOutputSchema as
|
|
2442
|
-
import { z as
|
|
2443
|
-
var imageGenerationArgsSchema =
|
|
2444
|
-
background:
|
|
2445
|
-
inputFidelity:
|
|
2446
|
-
inputImageMask:
|
|
2447
|
-
fileId:
|
|
2448
|
-
imageUrl:
|
|
2509
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4 } from "@zenning/provider-utils";
|
|
2510
|
+
import { z as z18 } from "zod/v4";
|
|
2511
|
+
var imageGenerationArgsSchema = z18.object({
|
|
2512
|
+
background: z18.enum(["auto", "opaque", "transparent"]).optional(),
|
|
2513
|
+
inputFidelity: z18.enum(["low", "high"]).optional(),
|
|
2514
|
+
inputImageMask: z18.object({
|
|
2515
|
+
fileId: z18.string().optional(),
|
|
2516
|
+
imageUrl: z18.string().optional()
|
|
2449
2517
|
}).optional(),
|
|
2450
|
-
model:
|
|
2451
|
-
moderation:
|
|
2452
|
-
outputCompression:
|
|
2453
|
-
outputFormat:
|
|
2454
|
-
|
|
2455
|
-
|
|
2518
|
+
model: z18.string().optional(),
|
|
2519
|
+
moderation: z18.enum(["auto"]).optional(),
|
|
2520
|
+
outputCompression: z18.number().int().min(0).max(100).optional(),
|
|
2521
|
+
outputFormat: z18.enum(["png", "jpeg", "webp"]).optional(),
|
|
2522
|
+
partialImages: z18.number().int().min(0).max(3).optional(),
|
|
2523
|
+
quality: z18.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2524
|
+
size: z18.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
2456
2525
|
}).strict();
|
|
2457
|
-
var imageGenerationOutputSchema =
|
|
2458
|
-
result:
|
|
2526
|
+
var imageGenerationOutputSchema = z18.object({
|
|
2527
|
+
result: z18.string()
|
|
2459
2528
|
});
|
|
2460
|
-
var imageGenerationToolFactory =
|
|
2529
|
+
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
2461
2530
|
id: "openai.image_generation",
|
|
2462
2531
|
name: "image_generation",
|
|
2463
|
-
inputSchema:
|
|
2532
|
+
inputSchema: z18.object({}),
|
|
2464
2533
|
outputSchema: imageGenerationOutputSchema
|
|
2465
2534
|
});
|
|
2535
|
+
var imageGeneration = (args = {}) => {
|
|
2536
|
+
return imageGenerationToolFactory(args);
|
|
2537
|
+
};
|
|
2466
2538
|
|
|
2467
2539
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2468
2540
|
function prepareResponsesTools({
|
|
@@ -2503,6 +2575,12 @@ function prepareResponsesTools({
|
|
|
2503
2575
|
});
|
|
2504
2576
|
break;
|
|
2505
2577
|
}
|
|
2578
|
+
case "openai.local_shell": {
|
|
2579
|
+
openaiTools.push({
|
|
2580
|
+
type: "local_shell"
|
|
2581
|
+
});
|
|
2582
|
+
break;
|
|
2583
|
+
}
|
|
2506
2584
|
case "openai.web_search_preview": {
|
|
2507
2585
|
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
2508
2586
|
openaiTools.push({
|
|
@@ -2541,11 +2619,12 @@ function prepareResponsesTools({
|
|
|
2541
2619
|
image_url: args.inputImageMask.imageUrl
|
|
2542
2620
|
} : void 0,
|
|
2543
2621
|
model: args.model,
|
|
2544
|
-
size: args.size,
|
|
2545
|
-
quality: args.quality,
|
|
2546
2622
|
moderation: args.moderation,
|
|
2623
|
+
partial_images: args.partialImages,
|
|
2624
|
+
quality: args.quality,
|
|
2625
|
+
output_compression: args.outputCompression,
|
|
2547
2626
|
output_format: args.outputFormat,
|
|
2548
|
-
|
|
2627
|
+
size: args.size
|
|
2549
2628
|
});
|
|
2550
2629
|
break;
|
|
2551
2630
|
}
|
|
@@ -2582,73 +2661,91 @@ function prepareResponsesTools({
|
|
|
2582
2661
|
}
|
|
2583
2662
|
|
|
2584
2663
|
// src/responses/openai-responses-language-model.ts
|
|
2585
|
-
var webSearchCallItem =
|
|
2586
|
-
type:
|
|
2587
|
-
id:
|
|
2588
|
-
status:
|
|
2589
|
-
action:
|
|
2590
|
-
|
|
2591
|
-
type:
|
|
2592
|
-
query:
|
|
2664
|
+
var webSearchCallItem = z19.object({
|
|
2665
|
+
type: z19.literal("web_search_call"),
|
|
2666
|
+
id: z19.string(),
|
|
2667
|
+
status: z19.string(),
|
|
2668
|
+
action: z19.discriminatedUnion("type", [
|
|
2669
|
+
z19.object({
|
|
2670
|
+
type: z19.literal("search"),
|
|
2671
|
+
query: z19.string().nullish()
|
|
2593
2672
|
}),
|
|
2594
|
-
|
|
2595
|
-
type:
|
|
2596
|
-
url:
|
|
2673
|
+
z19.object({
|
|
2674
|
+
type: z19.literal("open_page"),
|
|
2675
|
+
url: z19.string()
|
|
2597
2676
|
}),
|
|
2598
|
-
|
|
2599
|
-
type:
|
|
2600
|
-
url:
|
|
2601
|
-
pattern:
|
|
2677
|
+
z19.object({
|
|
2678
|
+
type: z19.literal("find"),
|
|
2679
|
+
url: z19.string(),
|
|
2680
|
+
pattern: z19.string()
|
|
2602
2681
|
})
|
|
2603
2682
|
]).nullish()
|
|
2604
2683
|
});
|
|
2605
|
-
var fileSearchCallItem =
|
|
2606
|
-
type:
|
|
2607
|
-
id:
|
|
2608
|
-
queries:
|
|
2609
|
-
results:
|
|
2610
|
-
|
|
2611
|
-
attributes:
|
|
2612
|
-
file_id:
|
|
2613
|
-
filename:
|
|
2614
|
-
score:
|
|
2615
|
-
text:
|
|
2684
|
+
var fileSearchCallItem = z19.object({
|
|
2685
|
+
type: z19.literal("file_search_call"),
|
|
2686
|
+
id: z19.string(),
|
|
2687
|
+
queries: z19.array(z19.string()),
|
|
2688
|
+
results: z19.array(
|
|
2689
|
+
z19.object({
|
|
2690
|
+
attributes: z19.record(z19.string(), z19.unknown()),
|
|
2691
|
+
file_id: z19.string(),
|
|
2692
|
+
filename: z19.string(),
|
|
2693
|
+
score: z19.number(),
|
|
2694
|
+
text: z19.string()
|
|
2616
2695
|
})
|
|
2617
2696
|
).nullish()
|
|
2618
2697
|
});
|
|
2619
|
-
var codeInterpreterCallItem =
|
|
2620
|
-
type:
|
|
2621
|
-
id:
|
|
2622
|
-
code:
|
|
2623
|
-
container_id:
|
|
2624
|
-
outputs:
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2698
|
+
var codeInterpreterCallItem = z19.object({
|
|
2699
|
+
type: z19.literal("code_interpreter_call"),
|
|
2700
|
+
id: z19.string(),
|
|
2701
|
+
code: z19.string().nullable(),
|
|
2702
|
+
container_id: z19.string(),
|
|
2703
|
+
outputs: z19.array(
|
|
2704
|
+
z19.discriminatedUnion("type", [
|
|
2705
|
+
z19.object({ type: z19.literal("logs"), logs: z19.string() }),
|
|
2706
|
+
z19.object({ type: z19.literal("image"), url: z19.string() })
|
|
2628
2707
|
])
|
|
2629
2708
|
).nullable()
|
|
2630
2709
|
});
|
|
2631
|
-
var
|
|
2632
|
-
type:
|
|
2633
|
-
id:
|
|
2634
|
-
|
|
2710
|
+
var localShellCallItem = z19.object({
|
|
2711
|
+
type: z19.literal("local_shell_call"),
|
|
2712
|
+
id: z19.string(),
|
|
2713
|
+
call_id: z19.string(),
|
|
2714
|
+
action: z19.object({
|
|
2715
|
+
type: z19.literal("exec"),
|
|
2716
|
+
command: z19.array(z19.string()),
|
|
2717
|
+
timeout_ms: z19.number().optional(),
|
|
2718
|
+
user: z19.string().optional(),
|
|
2719
|
+
working_directory: z19.string().optional(),
|
|
2720
|
+
env: z19.record(z19.string(), z19.string()).optional()
|
|
2721
|
+
})
|
|
2722
|
+
});
|
|
2723
|
+
var sourceExecutionFileCodeInterpreterItem = z19.object({
|
|
2724
|
+
containerId: z19.string(),
|
|
2725
|
+
fileId: z19.string(),
|
|
2726
|
+
filename: z19.string()
|
|
2727
|
+
});
|
|
2728
|
+
var imageGenerationCallItem = z19.object({
|
|
2729
|
+
type: z19.literal("image_generation_call"),
|
|
2730
|
+
id: z19.string(),
|
|
2731
|
+
result: z19.string()
|
|
2635
2732
|
});
|
|
2636
2733
|
var TOP_LOGPROBS_MAX = 20;
|
|
2637
|
-
var LOGPROBS_SCHEMA =
|
|
2638
|
-
|
|
2639
|
-
token:
|
|
2640
|
-
logprob:
|
|
2641
|
-
top_logprobs:
|
|
2642
|
-
|
|
2643
|
-
token:
|
|
2644
|
-
logprob:
|
|
2734
|
+
var LOGPROBS_SCHEMA = z19.array(
|
|
2735
|
+
z19.object({
|
|
2736
|
+
token: z19.string(),
|
|
2737
|
+
logprob: z19.number(),
|
|
2738
|
+
top_logprobs: z19.array(
|
|
2739
|
+
z19.object({
|
|
2740
|
+
token: z19.string(),
|
|
2741
|
+
logprob: z19.number()
|
|
2645
2742
|
})
|
|
2646
2743
|
)
|
|
2647
2744
|
})
|
|
2648
2745
|
);
|
|
2649
2746
|
var OpenAIResponsesLanguageModel = class {
|
|
2650
2747
|
constructor(modelId, config) {
|
|
2651
|
-
this.specificationVersion = "
|
|
2748
|
+
this.specificationVersion = "v3";
|
|
2652
2749
|
this.supportedUrls = {
|
|
2653
2750
|
"image/*": [/^https?:\/\/.*$/],
|
|
2654
2751
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
@@ -2707,7 +2804,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2707
2804
|
prompt,
|
|
2708
2805
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
2709
2806
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
2710
|
-
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
|
|
2807
|
+
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
|
|
2808
|
+
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
2711
2809
|
});
|
|
2712
2810
|
warnings.push(...inputWarnings);
|
|
2713
2811
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
@@ -2852,7 +2950,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2852
2950
|
};
|
|
2853
2951
|
}
|
|
2854
2952
|
async doGenerate(options) {
|
|
2855
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2953
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
2856
2954
|
const {
|
|
2857
2955
|
args: body,
|
|
2858
2956
|
warnings,
|
|
@@ -2862,6 +2960,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2862
2960
|
path: "/responses",
|
|
2863
2961
|
modelId: this.modelId
|
|
2864
2962
|
});
|
|
2963
|
+
const providerKey = this.config.provider.replace(".responses", "");
|
|
2865
2964
|
const {
|
|
2866
2965
|
responseHeaders,
|
|
2867
2966
|
value: response,
|
|
@@ -2872,45 +2971,50 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2872
2971
|
body,
|
|
2873
2972
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2874
2973
|
successfulResponseHandler: createJsonResponseHandler6(
|
|
2875
|
-
|
|
2876
|
-
id:
|
|
2877
|
-
created_at:
|
|
2878
|
-
error:
|
|
2879
|
-
code:
|
|
2880
|
-
message:
|
|
2974
|
+
z19.object({
|
|
2975
|
+
id: z19.string(),
|
|
2976
|
+
created_at: z19.number(),
|
|
2977
|
+
error: z19.object({
|
|
2978
|
+
code: z19.string(),
|
|
2979
|
+
message: z19.string()
|
|
2881
2980
|
}).nullish(),
|
|
2882
|
-
model:
|
|
2883
|
-
output:
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
type:
|
|
2887
|
-
role:
|
|
2888
|
-
id:
|
|
2889
|
-
content:
|
|
2890
|
-
|
|
2891
|
-
type:
|
|
2892
|
-
text:
|
|
2981
|
+
model: z19.string(),
|
|
2982
|
+
output: z19.array(
|
|
2983
|
+
z19.discriminatedUnion("type", [
|
|
2984
|
+
z19.object({
|
|
2985
|
+
type: z19.literal("message"),
|
|
2986
|
+
role: z19.literal("assistant"),
|
|
2987
|
+
id: z19.string(),
|
|
2988
|
+
content: z19.array(
|
|
2989
|
+
z19.object({
|
|
2990
|
+
type: z19.literal("output_text"),
|
|
2991
|
+
text: z19.string(),
|
|
2893
2992
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2894
|
-
annotations:
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
type:
|
|
2898
|
-
start_index:
|
|
2899
|
-
end_index:
|
|
2900
|
-
url:
|
|
2901
|
-
title:
|
|
2993
|
+
annotations: z19.array(
|
|
2994
|
+
z19.discriminatedUnion("type", [
|
|
2995
|
+
z19.object({
|
|
2996
|
+
type: z19.literal("url_citation"),
|
|
2997
|
+
start_index: z19.number(),
|
|
2998
|
+
end_index: z19.number(),
|
|
2999
|
+
url: z19.string(),
|
|
3000
|
+
title: z19.string()
|
|
2902
3001
|
}),
|
|
2903
|
-
|
|
2904
|
-
type:
|
|
2905
|
-
file_id:
|
|
2906
|
-
filename:
|
|
2907
|
-
index:
|
|
2908
|
-
start_index:
|
|
2909
|
-
end_index:
|
|
2910
|
-
quote:
|
|
3002
|
+
z19.object({
|
|
3003
|
+
type: z19.literal("file_citation"),
|
|
3004
|
+
file_id: z19.string(),
|
|
3005
|
+
filename: z19.string().nullish(),
|
|
3006
|
+
index: z19.number().nullish(),
|
|
3007
|
+
start_index: z19.number().nullish(),
|
|
3008
|
+
end_index: z19.number().nullish(),
|
|
3009
|
+
quote: z19.string().nullish()
|
|
2911
3010
|
}),
|
|
2912
|
-
|
|
2913
|
-
type:
|
|
3011
|
+
z19.object({
|
|
3012
|
+
type: z19.literal("container_file_citation"),
|
|
3013
|
+
container_id: z19.string(),
|
|
3014
|
+
end_index: z19.number(),
|
|
3015
|
+
file_id: z19.string(),
|
|
3016
|
+
filename: z19.string(),
|
|
3017
|
+
start_index: z19.number()
|
|
2914
3018
|
})
|
|
2915
3019
|
])
|
|
2916
3020
|
)
|
|
@@ -2921,33 +3025,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2921
3025
|
fileSearchCallItem,
|
|
2922
3026
|
codeInterpreterCallItem,
|
|
2923
3027
|
imageGenerationCallItem,
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
3028
|
+
localShellCallItem,
|
|
3029
|
+
z19.object({
|
|
3030
|
+
type: z19.literal("function_call"),
|
|
3031
|
+
call_id: z19.string(),
|
|
3032
|
+
name: z19.string(),
|
|
3033
|
+
arguments: z19.string(),
|
|
3034
|
+
id: z19.string()
|
|
2930
3035
|
}),
|
|
2931
|
-
|
|
2932
|
-
type:
|
|
2933
|
-
id:
|
|
2934
|
-
status:
|
|
3036
|
+
z19.object({
|
|
3037
|
+
type: z19.literal("computer_call"),
|
|
3038
|
+
id: z19.string(),
|
|
3039
|
+
status: z19.string().optional()
|
|
2935
3040
|
}),
|
|
2936
|
-
|
|
2937
|
-
type:
|
|
2938
|
-
id:
|
|
2939
|
-
encrypted_content:
|
|
2940
|
-
summary:
|
|
2941
|
-
|
|
2942
|
-
type:
|
|
2943
|
-
text:
|
|
3041
|
+
z19.object({
|
|
3042
|
+
type: z19.literal("reasoning"),
|
|
3043
|
+
id: z19.string(),
|
|
3044
|
+
encrypted_content: z19.string().nullish(),
|
|
3045
|
+
summary: z19.array(
|
|
3046
|
+
z19.object({
|
|
3047
|
+
type: z19.literal("summary_text"),
|
|
3048
|
+
text: z19.string()
|
|
2944
3049
|
})
|
|
2945
3050
|
)
|
|
2946
3051
|
})
|
|
2947
3052
|
])
|
|
2948
3053
|
),
|
|
2949
|
-
service_tier:
|
|
2950
|
-
incomplete_details:
|
|
3054
|
+
service_tier: z19.string().nullish(),
|
|
3055
|
+
incomplete_details: z19.object({ reason: z19.string() }).nullish(),
|
|
2951
3056
|
usage: usageSchema2
|
|
2952
3057
|
})
|
|
2953
3058
|
),
|
|
@@ -3007,6 +3112,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3007
3112
|
});
|
|
3008
3113
|
break;
|
|
3009
3114
|
}
|
|
3115
|
+
case "local_shell_call": {
|
|
3116
|
+
content.push({
|
|
3117
|
+
type: "tool-call",
|
|
3118
|
+
toolCallId: part.call_id,
|
|
3119
|
+
toolName: "local_shell",
|
|
3120
|
+
input: JSON.stringify({ action: part.action }),
|
|
3121
|
+
providerMetadata: {
|
|
3122
|
+
openai: {
|
|
3123
|
+
itemId: part.id
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
break;
|
|
3128
|
+
}
|
|
3010
3129
|
case "message": {
|
|
3011
3130
|
for (const contentPart of part.content) {
|
|
3012
3131
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
@@ -3017,7 +3136,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3017
3136
|
text: contentPart.text,
|
|
3018
3137
|
providerMetadata: {
|
|
3019
3138
|
openai: {
|
|
3020
|
-
itemId: part.id
|
|
3139
|
+
itemId: part.id,
|
|
3140
|
+
annotations: contentPart.annotations
|
|
3021
3141
|
}
|
|
3022
3142
|
}
|
|
3023
3143
|
});
|
|
@@ -3042,6 +3162,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3042
3162
|
startIndex: (_m = annotation.start_index) != null ? _m : void 0,
|
|
3043
3163
|
endIndex: (_n = annotation.end_index) != null ? _n : void 0
|
|
3044
3164
|
});
|
|
3165
|
+
} else if (annotation.type === "container_file_citation") {
|
|
3166
|
+
content.push({
|
|
3167
|
+
type: "source",
|
|
3168
|
+
sourceType: "executionFile",
|
|
3169
|
+
id: (_q = (_p = (_o = this.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : generateId2(),
|
|
3170
|
+
providerMetadata: {
|
|
3171
|
+
[providerKey]: {
|
|
3172
|
+
containerId: annotation.container_id,
|
|
3173
|
+
fileId: annotation.file_id,
|
|
3174
|
+
filename: annotation.filename
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
});
|
|
3045
3178
|
}
|
|
3046
3179
|
}
|
|
3047
3180
|
}
|
|
@@ -3113,13 +3246,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3113
3246
|
toolName: "file_search",
|
|
3114
3247
|
result: {
|
|
3115
3248
|
queries: part.queries,
|
|
3116
|
-
results: (
|
|
3249
|
+
results: (_s = (_r = part.results) == null ? void 0 : _r.map((result) => ({
|
|
3117
3250
|
attributes: result.attributes,
|
|
3118
3251
|
fileId: result.file_id,
|
|
3119
3252
|
filename: result.filename,
|
|
3120
3253
|
score: result.score,
|
|
3121
3254
|
text: result.text
|
|
3122
|
-
}))) != null ?
|
|
3255
|
+
}))) != null ? _s : null
|
|
3123
3256
|
},
|
|
3124
3257
|
providerExecuted: true
|
|
3125
3258
|
});
|
|
@@ -3161,15 +3294,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3161
3294
|
return {
|
|
3162
3295
|
content,
|
|
3163
3296
|
finishReason: mapOpenAIResponseFinishReason({
|
|
3164
|
-
finishReason: (
|
|
3297
|
+
finishReason: (_t = response.incomplete_details) == null ? void 0 : _t.reason,
|
|
3165
3298
|
hasFunctionCall
|
|
3166
3299
|
}),
|
|
3167
3300
|
usage: {
|
|
3168
3301
|
inputTokens: response.usage.input_tokens,
|
|
3169
3302
|
outputTokens: response.usage.output_tokens,
|
|
3170
3303
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
3171
|
-
reasoningTokens: (
|
|
3172
|
-
cachedInputTokens: (
|
|
3304
|
+
reasoningTokens: (_v = (_u = response.usage.output_tokens_details) == null ? void 0 : _u.reasoning_tokens) != null ? _v : void 0,
|
|
3305
|
+
cachedInputTokens: (_x = (_w = response.usage.input_tokens_details) == null ? void 0 : _w.cached_tokens) != null ? _x : void 0
|
|
3173
3306
|
},
|
|
3174
3307
|
request: { body },
|
|
3175
3308
|
response: {
|
|
@@ -3216,6 +3349,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3216
3349
|
const logprobs = [];
|
|
3217
3350
|
let responseId = null;
|
|
3218
3351
|
const ongoingToolCalls = {};
|
|
3352
|
+
const ongoingAnnotations = [];
|
|
3219
3353
|
let hasFunctionCall = false;
|
|
3220
3354
|
const activeReasoning = {};
|
|
3221
3355
|
let serviceTier;
|
|
@@ -3226,7 +3360,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3226
3360
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3227
3361
|
},
|
|
3228
3362
|
transform(chunk, controller) {
|
|
3229
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
3363
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
3230
3364
|
if (options.includeRawChunks) {
|
|
3231
3365
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3232
3366
|
}
|
|
@@ -3267,6 +3401,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3267
3401
|
id: value.item.id,
|
|
3268
3402
|
toolName: "computer_use"
|
|
3269
3403
|
});
|
|
3404
|
+
} else if (value.item.type === "code_interpreter_call") {
|
|
3405
|
+
ongoingToolCalls[value.output_index] = {
|
|
3406
|
+
toolName: "code_interpreter",
|
|
3407
|
+
toolCallId: value.item.id,
|
|
3408
|
+
codeInterpreter: {
|
|
3409
|
+
containerId: value.item.container_id
|
|
3410
|
+
}
|
|
3411
|
+
};
|
|
3412
|
+
controller.enqueue({
|
|
3413
|
+
type: "tool-input-start",
|
|
3414
|
+
id: value.item.id,
|
|
3415
|
+
toolName: "code_interpreter"
|
|
3416
|
+
});
|
|
3417
|
+
controller.enqueue({
|
|
3418
|
+
type: "tool-input-delta",
|
|
3419
|
+
id: value.item.id,
|
|
3420
|
+
delta: `{"containerId":"${value.item.container_id}","code":"`
|
|
3421
|
+
});
|
|
3270
3422
|
} else if (value.item.type === "file_search_call") {
|
|
3271
3423
|
controller.enqueue({
|
|
3272
3424
|
type: "tool-call",
|
|
@@ -3284,6 +3436,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3284
3436
|
providerExecuted: true
|
|
3285
3437
|
});
|
|
3286
3438
|
} else if (value.item.type === "message") {
|
|
3439
|
+
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
3287
3440
|
controller.enqueue({
|
|
3288
3441
|
type: "text-start",
|
|
3289
3442
|
id: value.item.id,
|
|
@@ -3309,7 +3462,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3309
3462
|
}
|
|
3310
3463
|
});
|
|
3311
3464
|
}
|
|
3312
|
-
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
3465
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type !== "message") {
|
|
3313
3466
|
if (value.item.type === "function_call") {
|
|
3314
3467
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3315
3468
|
hasFunctionCall = true;
|
|
@@ -3390,16 +3543,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3390
3543
|
providerExecuted: true
|
|
3391
3544
|
});
|
|
3392
3545
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3393
|
-
|
|
3394
|
-
type: "tool-call",
|
|
3395
|
-
toolCallId: value.item.id,
|
|
3396
|
-
toolName: "code_interpreter",
|
|
3397
|
-
input: JSON.stringify({
|
|
3398
|
-
code: value.item.code,
|
|
3399
|
-
containerId: value.item.container_id
|
|
3400
|
-
}),
|
|
3401
|
-
providerExecuted: true
|
|
3402
|
-
});
|
|
3546
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3403
3547
|
controller.enqueue({
|
|
3404
3548
|
type: "tool-result",
|
|
3405
3549
|
toolCallId: value.item.id,
|
|
@@ -3419,10 +3563,25 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3419
3563
|
},
|
|
3420
3564
|
providerExecuted: true
|
|
3421
3565
|
});
|
|
3422
|
-
} else if (value.item.type === "
|
|
3566
|
+
} else if (value.item.type === "local_shell_call") {
|
|
3567
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3423
3568
|
controller.enqueue({
|
|
3424
|
-
type: "
|
|
3425
|
-
|
|
3569
|
+
type: "tool-call",
|
|
3570
|
+
toolCallId: value.item.call_id,
|
|
3571
|
+
toolName: "local_shell",
|
|
3572
|
+
input: JSON.stringify({
|
|
3573
|
+
action: {
|
|
3574
|
+
type: "exec",
|
|
3575
|
+
command: value.item.action.command,
|
|
3576
|
+
timeoutMs: value.item.action.timeout_ms,
|
|
3577
|
+
user: value.item.action.user,
|
|
3578
|
+
workingDirectory: value.item.action.working_directory,
|
|
3579
|
+
env: value.item.action.env
|
|
3580
|
+
}
|
|
3581
|
+
}),
|
|
3582
|
+
providerMetadata: {
|
|
3583
|
+
openai: { itemId: value.item.id }
|
|
3584
|
+
}
|
|
3426
3585
|
});
|
|
3427
3586
|
} else if (isResponseOutputItemDoneReasoningChunk(value)) {
|
|
3428
3587
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
@@ -3449,6 +3608,51 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3449
3608
|
delta: value.delta
|
|
3450
3609
|
});
|
|
3451
3610
|
}
|
|
3611
|
+
} else if (isResponseImageGenerationCallPartialImageChunk(value)) {
|
|
3612
|
+
controller.enqueue({
|
|
3613
|
+
type: "tool-result",
|
|
3614
|
+
toolCallId: value.item_id,
|
|
3615
|
+
toolName: "image_generation",
|
|
3616
|
+
result: {
|
|
3617
|
+
result: value.partial_image_b64
|
|
3618
|
+
},
|
|
3619
|
+
providerExecuted: true,
|
|
3620
|
+
preliminary: true
|
|
3621
|
+
});
|
|
3622
|
+
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3623
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3624
|
+
if (toolCall != null) {
|
|
3625
|
+
controller.enqueue({
|
|
3626
|
+
type: "tool-input-delta",
|
|
3627
|
+
id: toolCall.toolCallId,
|
|
3628
|
+
// The delta is code, which is embedding in a JSON string.
|
|
3629
|
+
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
3630
|
+
delta: JSON.stringify(value.delta).slice(1, -1)
|
|
3631
|
+
});
|
|
3632
|
+
}
|
|
3633
|
+
} else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
3634
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3635
|
+
if (toolCall != null) {
|
|
3636
|
+
controller.enqueue({
|
|
3637
|
+
type: "tool-input-delta",
|
|
3638
|
+
id: toolCall.toolCallId,
|
|
3639
|
+
delta: '"}'
|
|
3640
|
+
});
|
|
3641
|
+
controller.enqueue({
|
|
3642
|
+
type: "tool-input-end",
|
|
3643
|
+
id: toolCall.toolCallId
|
|
3644
|
+
});
|
|
3645
|
+
controller.enqueue({
|
|
3646
|
+
type: "tool-call",
|
|
3647
|
+
toolCallId: toolCall.toolCallId,
|
|
3648
|
+
toolName: "code_interpreter",
|
|
3649
|
+
input: JSON.stringify({
|
|
3650
|
+
code: value.code,
|
|
3651
|
+
containerId: toolCall.codeInterpreter.containerId
|
|
3652
|
+
}),
|
|
3653
|
+
providerExecuted: true
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3452
3656
|
} else if (isResponseCreatedChunk(value)) {
|
|
3453
3657
|
responseId = value.response.id;
|
|
3454
3658
|
controller.enqueue({
|
|
@@ -3507,6 +3711,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3507
3711
|
serviceTier = value.response.service_tier;
|
|
3508
3712
|
}
|
|
3509
3713
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
3714
|
+
ongoingAnnotations.push(value.annotation);
|
|
3510
3715
|
if (value.annotation.type === "url_citation") {
|
|
3511
3716
|
controller.enqueue({
|
|
3512
3717
|
type: "source",
|
|
@@ -3527,7 +3732,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3527
3732
|
startIndex: (_x = value.annotation.start_index) != null ? _x : void 0,
|
|
3528
3733
|
endIndex: (_y = value.annotation.end_index) != null ? _y : void 0
|
|
3529
3734
|
});
|
|
3735
|
+
} else if (value.annotation.type === "container_file_citation") {
|
|
3736
|
+
controller.enqueue({
|
|
3737
|
+
type: "source",
|
|
3738
|
+
sourceType: "executionFile",
|
|
3739
|
+
id: (_B = (_A = (_z = self.config).generateId) == null ? void 0 : _A.call(_z)) != null ? _B : generateId2(),
|
|
3740
|
+
providerMetadata: {
|
|
3741
|
+
openai: {
|
|
3742
|
+
containerId: value.annotation.container_id,
|
|
3743
|
+
fileId: value.annotation.file_id,
|
|
3744
|
+
filename: value.annotation.filename
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
});
|
|
3530
3748
|
}
|
|
3749
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type === "message") {
|
|
3750
|
+
controller.enqueue({
|
|
3751
|
+
type: "text-end",
|
|
3752
|
+
id: value.item.id,
|
|
3753
|
+
providerMetadata: {
|
|
3754
|
+
openai: {
|
|
3755
|
+
itemId: value.item.id,
|
|
3756
|
+
annotations: ongoingAnnotations
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
});
|
|
3531
3760
|
} else if (isErrorChunk(value)) {
|
|
3532
3761
|
controller.enqueue({ type: "error", error: value });
|
|
3533
3762
|
}
|
|
@@ -3558,166 +3787,209 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3558
3787
|
};
|
|
3559
3788
|
}
|
|
3560
3789
|
};
|
|
3561
|
-
var usageSchema2 =
|
|
3562
|
-
input_tokens:
|
|
3563
|
-
input_tokens_details:
|
|
3564
|
-
output_tokens:
|
|
3565
|
-
output_tokens_details:
|
|
3790
|
+
var usageSchema2 = z19.object({
|
|
3791
|
+
input_tokens: z19.number(),
|
|
3792
|
+
input_tokens_details: z19.object({ cached_tokens: z19.number().nullish() }).nullish(),
|
|
3793
|
+
output_tokens: z19.number(),
|
|
3794
|
+
output_tokens_details: z19.object({ reasoning_tokens: z19.number().nullish() }).nullish()
|
|
3566
3795
|
});
|
|
3567
|
-
var textDeltaChunkSchema =
|
|
3568
|
-
type:
|
|
3569
|
-
item_id:
|
|
3570
|
-
delta:
|
|
3796
|
+
var textDeltaChunkSchema = z19.object({
|
|
3797
|
+
type: z19.literal("response.output_text.delta"),
|
|
3798
|
+
item_id: z19.string(),
|
|
3799
|
+
delta: z19.string(),
|
|
3571
3800
|
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3572
3801
|
});
|
|
3573
|
-
var errorChunkSchema =
|
|
3574
|
-
type:
|
|
3575
|
-
code:
|
|
3576
|
-
message:
|
|
3577
|
-
param:
|
|
3578
|
-
sequence_number:
|
|
3802
|
+
var errorChunkSchema = z19.object({
|
|
3803
|
+
type: z19.literal("error"),
|
|
3804
|
+
code: z19.string(),
|
|
3805
|
+
message: z19.string(),
|
|
3806
|
+
param: z19.string().nullish(),
|
|
3807
|
+
sequence_number: z19.number()
|
|
3579
3808
|
});
|
|
3580
|
-
var responseFinishedChunkSchema =
|
|
3581
|
-
type:
|
|
3582
|
-
response:
|
|
3583
|
-
incomplete_details:
|
|
3809
|
+
var responseFinishedChunkSchema = z19.object({
|
|
3810
|
+
type: z19.enum(["response.completed", "response.incomplete"]),
|
|
3811
|
+
response: z19.object({
|
|
3812
|
+
incomplete_details: z19.object({ reason: z19.string() }).nullish(),
|
|
3584
3813
|
usage: usageSchema2,
|
|
3585
|
-
service_tier:
|
|
3814
|
+
service_tier: z19.string().nullish()
|
|
3586
3815
|
})
|
|
3587
3816
|
});
|
|
3588
|
-
var responseCreatedChunkSchema =
|
|
3589
|
-
type:
|
|
3590
|
-
response:
|
|
3591
|
-
id:
|
|
3592
|
-
created_at:
|
|
3593
|
-
model:
|
|
3594
|
-
service_tier:
|
|
3817
|
+
var responseCreatedChunkSchema = z19.object({
|
|
3818
|
+
type: z19.literal("response.created"),
|
|
3819
|
+
response: z19.object({
|
|
3820
|
+
id: z19.string(),
|
|
3821
|
+
created_at: z19.number(),
|
|
3822
|
+
model: z19.string(),
|
|
3823
|
+
service_tier: z19.string().nullish()
|
|
3595
3824
|
})
|
|
3596
3825
|
});
|
|
3597
|
-
var responseOutputItemAddedSchema =
|
|
3598
|
-
type:
|
|
3599
|
-
output_index:
|
|
3600
|
-
item:
|
|
3601
|
-
|
|
3602
|
-
type:
|
|
3603
|
-
id:
|
|
3826
|
+
var responseOutputItemAddedSchema = z19.object({
|
|
3827
|
+
type: z19.literal("response.output_item.added"),
|
|
3828
|
+
output_index: z19.number(),
|
|
3829
|
+
item: z19.discriminatedUnion("type", [
|
|
3830
|
+
z19.object({
|
|
3831
|
+
type: z19.literal("message"),
|
|
3832
|
+
id: z19.string()
|
|
3604
3833
|
}),
|
|
3605
|
-
|
|
3606
|
-
type:
|
|
3607
|
-
id:
|
|
3608
|
-
encrypted_content:
|
|
3834
|
+
z19.object({
|
|
3835
|
+
type: z19.literal("reasoning"),
|
|
3836
|
+
id: z19.string(),
|
|
3837
|
+
encrypted_content: z19.string().nullish()
|
|
3609
3838
|
}),
|
|
3610
|
-
|
|
3611
|
-
type:
|
|
3612
|
-
id:
|
|
3613
|
-
call_id:
|
|
3614
|
-
name:
|
|
3615
|
-
arguments:
|
|
3839
|
+
z19.object({
|
|
3840
|
+
type: z19.literal("function_call"),
|
|
3841
|
+
id: z19.string(),
|
|
3842
|
+
call_id: z19.string(),
|
|
3843
|
+
name: z19.string(),
|
|
3844
|
+
arguments: z19.string()
|
|
3616
3845
|
}),
|
|
3617
|
-
|
|
3618
|
-
type:
|
|
3619
|
-
id:
|
|
3620
|
-
status:
|
|
3621
|
-
action:
|
|
3622
|
-
type:
|
|
3623
|
-
query:
|
|
3846
|
+
z19.object({
|
|
3847
|
+
type: z19.literal("web_search_call"),
|
|
3848
|
+
id: z19.string(),
|
|
3849
|
+
status: z19.string(),
|
|
3850
|
+
action: z19.object({
|
|
3851
|
+
type: z19.literal("search"),
|
|
3852
|
+
query: z19.string().optional()
|
|
3624
3853
|
}).nullish()
|
|
3625
3854
|
}),
|
|
3626
|
-
|
|
3627
|
-
type:
|
|
3628
|
-
id:
|
|
3629
|
-
status:
|
|
3855
|
+
z19.object({
|
|
3856
|
+
type: z19.literal("computer_call"),
|
|
3857
|
+
id: z19.string(),
|
|
3858
|
+
status: z19.string()
|
|
3859
|
+
}),
|
|
3860
|
+
z19.object({
|
|
3861
|
+
type: z19.literal("file_search_call"),
|
|
3862
|
+
id: z19.string()
|
|
3630
3863
|
}),
|
|
3631
|
-
|
|
3632
|
-
type:
|
|
3633
|
-
id:
|
|
3864
|
+
z19.object({
|
|
3865
|
+
type: z19.literal("image_generation_call"),
|
|
3866
|
+
id: z19.string()
|
|
3634
3867
|
}),
|
|
3635
|
-
|
|
3636
|
-
type:
|
|
3637
|
-
id:
|
|
3868
|
+
z19.object({
|
|
3869
|
+
type: z19.literal("code_interpreter_call"),
|
|
3870
|
+
id: z19.string(),
|
|
3871
|
+
container_id: z19.string(),
|
|
3872
|
+
code: z19.string().nullable(),
|
|
3873
|
+
outputs: z19.array(
|
|
3874
|
+
z19.discriminatedUnion("type", [
|
|
3875
|
+
z19.object({ type: z19.literal("logs"), logs: z19.string() }),
|
|
3876
|
+
z19.object({ type: z19.literal("image"), url: z19.string() })
|
|
3877
|
+
])
|
|
3878
|
+
).nullable(),
|
|
3879
|
+
status: z19.string()
|
|
3638
3880
|
})
|
|
3639
3881
|
])
|
|
3640
3882
|
});
|
|
3641
|
-
var responseOutputItemDoneSchema =
|
|
3642
|
-
type:
|
|
3643
|
-
output_index:
|
|
3644
|
-
item:
|
|
3645
|
-
|
|
3646
|
-
type:
|
|
3647
|
-
id:
|
|
3883
|
+
var responseOutputItemDoneSchema = z19.object({
|
|
3884
|
+
type: z19.literal("response.output_item.done"),
|
|
3885
|
+
output_index: z19.number(),
|
|
3886
|
+
item: z19.discriminatedUnion("type", [
|
|
3887
|
+
z19.object({
|
|
3888
|
+
type: z19.literal("message"),
|
|
3889
|
+
id: z19.string()
|
|
3648
3890
|
}),
|
|
3649
|
-
|
|
3650
|
-
type:
|
|
3651
|
-
id:
|
|
3652
|
-
encrypted_content:
|
|
3891
|
+
z19.object({
|
|
3892
|
+
type: z19.literal("reasoning"),
|
|
3893
|
+
id: z19.string(),
|
|
3894
|
+
encrypted_content: z19.string().nullish()
|
|
3653
3895
|
}),
|
|
3654
|
-
|
|
3655
|
-
type:
|
|
3656
|
-
id:
|
|
3657
|
-
call_id:
|
|
3658
|
-
name:
|
|
3659
|
-
arguments:
|
|
3660
|
-
status:
|
|
3896
|
+
z19.object({
|
|
3897
|
+
type: z19.literal("function_call"),
|
|
3898
|
+
id: z19.string(),
|
|
3899
|
+
call_id: z19.string(),
|
|
3900
|
+
name: z19.string(),
|
|
3901
|
+
arguments: z19.string(),
|
|
3902
|
+
status: z19.literal("completed")
|
|
3661
3903
|
}),
|
|
3662
3904
|
codeInterpreterCallItem,
|
|
3663
3905
|
imageGenerationCallItem,
|
|
3664
3906
|
webSearchCallItem,
|
|
3665
3907
|
fileSearchCallItem,
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3908
|
+
localShellCallItem,
|
|
3909
|
+
z19.object({
|
|
3910
|
+
type: z19.literal("computer_call"),
|
|
3911
|
+
id: z19.string(),
|
|
3912
|
+
status: z19.literal("completed")
|
|
3670
3913
|
})
|
|
3671
3914
|
])
|
|
3672
3915
|
});
|
|
3673
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
3674
|
-
type:
|
|
3675
|
-
item_id:
|
|
3676
|
-
output_index:
|
|
3677
|
-
delta:
|
|
3916
|
+
var responseFunctionCallArgumentsDeltaSchema = z19.object({
|
|
3917
|
+
type: z19.literal("response.function_call_arguments.delta"),
|
|
3918
|
+
item_id: z19.string(),
|
|
3919
|
+
output_index: z19.number(),
|
|
3920
|
+
delta: z19.string()
|
|
3921
|
+
});
|
|
3922
|
+
var responseImageGenerationCallPartialImageSchema = z19.object({
|
|
3923
|
+
type: z19.literal("response.image_generation_call.partial_image"),
|
|
3924
|
+
item_id: z19.string(),
|
|
3925
|
+
output_index: z19.number(),
|
|
3926
|
+
partial_image_b64: z19.string()
|
|
3678
3927
|
});
|
|
3679
|
-
var
|
|
3680
|
-
type:
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3928
|
+
var responseCodeInterpreterCallCodeDeltaSchema = z19.object({
|
|
3929
|
+
type: z19.literal("response.code_interpreter_call_code.delta"),
|
|
3930
|
+
item_id: z19.string(),
|
|
3931
|
+
output_index: z19.number(),
|
|
3932
|
+
delta: z19.string()
|
|
3933
|
+
});
|
|
3934
|
+
var responseCodeInterpreterCallCodeDoneSchema = z19.object({
|
|
3935
|
+
type: z19.literal("response.code_interpreter_call_code.done"),
|
|
3936
|
+
item_id: z19.string(),
|
|
3937
|
+
output_index: z19.number(),
|
|
3938
|
+
code: z19.string()
|
|
3939
|
+
});
|
|
3940
|
+
var responseAnnotationAddedSchema = z19.object({
|
|
3941
|
+
type: z19.literal("response.output_text.annotation.added"),
|
|
3942
|
+
annotation: z19.discriminatedUnion("type", [
|
|
3943
|
+
z19.object({
|
|
3944
|
+
type: z19.literal("url_citation"),
|
|
3945
|
+
url: z19.string(),
|
|
3946
|
+
title: z19.string()
|
|
3947
|
+
}),
|
|
3948
|
+
z19.object({
|
|
3949
|
+
type: z19.literal("file_citation"),
|
|
3950
|
+
file_id: z19.string(),
|
|
3951
|
+
filename: z19.string().nullish(),
|
|
3952
|
+
index: z19.number().nullish(),
|
|
3953
|
+
start_index: z19.number().nullish(),
|
|
3954
|
+
end_index: z19.number().nullish(),
|
|
3955
|
+
quote: z19.string().nullish()
|
|
3686
3956
|
}),
|
|
3687
|
-
|
|
3688
|
-
type:
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
quote: z18.string().nullish()
|
|
3957
|
+
z19.object({
|
|
3958
|
+
type: z19.literal("container_file_citation"),
|
|
3959
|
+
container_id: z19.string(),
|
|
3960
|
+
end_index: z19.number(),
|
|
3961
|
+
file_id: z19.string(),
|
|
3962
|
+
filename: z19.string(),
|
|
3963
|
+
start_index: z19.number()
|
|
3695
3964
|
})
|
|
3696
3965
|
])
|
|
3697
3966
|
});
|
|
3698
|
-
var responseReasoningSummaryPartAddedSchema =
|
|
3699
|
-
type:
|
|
3700
|
-
item_id:
|
|
3701
|
-
summary_index:
|
|
3967
|
+
var responseReasoningSummaryPartAddedSchema = z19.object({
|
|
3968
|
+
type: z19.literal("response.reasoning_summary_part.added"),
|
|
3969
|
+
item_id: z19.string(),
|
|
3970
|
+
summary_index: z19.number()
|
|
3702
3971
|
});
|
|
3703
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
3704
|
-
type:
|
|
3705
|
-
item_id:
|
|
3706
|
-
summary_index:
|
|
3707
|
-
delta:
|
|
3972
|
+
var responseReasoningSummaryTextDeltaSchema = z19.object({
|
|
3973
|
+
type: z19.literal("response.reasoning_summary_text.delta"),
|
|
3974
|
+
item_id: z19.string(),
|
|
3975
|
+
summary_index: z19.number(),
|
|
3976
|
+
delta: z19.string()
|
|
3708
3977
|
});
|
|
3709
|
-
var openaiResponsesChunkSchema =
|
|
3978
|
+
var openaiResponsesChunkSchema = z19.union([
|
|
3710
3979
|
textDeltaChunkSchema,
|
|
3711
3980
|
responseFinishedChunkSchema,
|
|
3712
3981
|
responseCreatedChunkSchema,
|
|
3713
3982
|
responseOutputItemAddedSchema,
|
|
3714
3983
|
responseOutputItemDoneSchema,
|
|
3715
3984
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3985
|
+
responseImageGenerationCallPartialImageSchema,
|
|
3986
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3987
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
3716
3988
|
responseAnnotationAddedSchema,
|
|
3717
3989
|
responseReasoningSummaryPartAddedSchema,
|
|
3718
3990
|
responseReasoningSummaryTextDeltaSchema,
|
|
3719
3991
|
errorChunkSchema,
|
|
3720
|
-
|
|
3992
|
+
z19.object({ type: z19.string() }).loose()
|
|
3721
3993
|
// fallback for unknown chunks
|
|
3722
3994
|
]);
|
|
3723
3995
|
function isTextDeltaChunk(chunk) {
|
|
@@ -3738,6 +4010,15 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3738
4010
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3739
4011
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3740
4012
|
}
|
|
4013
|
+
function isResponseImageGenerationCallPartialImageChunk(chunk) {
|
|
4014
|
+
return chunk.type === "response.image_generation_call.partial_image";
|
|
4015
|
+
}
|
|
4016
|
+
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
4017
|
+
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
4018
|
+
}
|
|
4019
|
+
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
4020
|
+
return chunk.type === "response.code_interpreter_call_code.done";
|
|
4021
|
+
}
|
|
3741
4022
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3742
4023
|
return chunk.type === "response.output_item.added";
|
|
3743
4024
|
}
|
|
@@ -3790,15 +4071,15 @@ function getResponsesModelConfig(modelId) {
|
|
|
3790
4071
|
isReasoningModel: false
|
|
3791
4072
|
};
|
|
3792
4073
|
}
|
|
3793
|
-
var openaiResponsesProviderOptionsSchema =
|
|
3794
|
-
include:
|
|
3795
|
-
|
|
4074
|
+
var openaiResponsesProviderOptionsSchema = z19.object({
|
|
4075
|
+
include: z19.array(
|
|
4076
|
+
z19.enum([
|
|
3796
4077
|
"reasoning.encrypted_content",
|
|
3797
4078
|
"file_search_call.results",
|
|
3798
4079
|
"message.output_text.logprobs"
|
|
3799
4080
|
])
|
|
3800
4081
|
).nullish(),
|
|
3801
|
-
instructions:
|
|
4082
|
+
instructions: z19.string().nullish(),
|
|
3802
4083
|
/**
|
|
3803
4084
|
* Return the log probabilities of the tokens.
|
|
3804
4085
|
*
|
|
@@ -3811,25 +4092,34 @@ var openaiResponsesProviderOptionsSchema = z18.object({
|
|
|
3811
4092
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3812
4093
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3813
4094
|
*/
|
|
3814
|
-
logprobs:
|
|
4095
|
+
logprobs: z19.union([z19.boolean(), z19.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3815
4096
|
/**
|
|
3816
4097
|
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3817
4098
|
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3818
4099
|
* Any further attempts to call a tool by the model will be ignored.
|
|
3819
4100
|
*/
|
|
3820
|
-
maxToolCalls:
|
|
3821
|
-
metadata:
|
|
3822
|
-
parallelToolCalls:
|
|
3823
|
-
previousResponseId:
|
|
3824
|
-
promptCacheKey:
|
|
3825
|
-
reasoningEffort:
|
|
3826
|
-
reasoningSummary:
|
|
3827
|
-
safetyIdentifier:
|
|
3828
|
-
serviceTier:
|
|
3829
|
-
store:
|
|
3830
|
-
strictJsonSchema:
|
|
3831
|
-
textVerbosity:
|
|
3832
|
-
user:
|
|
4101
|
+
maxToolCalls: z19.number().nullish(),
|
|
4102
|
+
metadata: z19.any().nullish(),
|
|
4103
|
+
parallelToolCalls: z19.boolean().nullish(),
|
|
4104
|
+
previousResponseId: z19.string().nullish(),
|
|
4105
|
+
promptCacheKey: z19.string().nullish(),
|
|
4106
|
+
reasoningEffort: z19.string().nullish(),
|
|
4107
|
+
reasoningSummary: z19.string().nullish(),
|
|
4108
|
+
safetyIdentifier: z19.string().nullish(),
|
|
4109
|
+
serviceTier: z19.enum(["auto", "flex", "priority"]).nullish(),
|
|
4110
|
+
store: z19.boolean().nullish(),
|
|
4111
|
+
strictJsonSchema: z19.boolean().nullish(),
|
|
4112
|
+
textVerbosity: z19.enum(["low", "medium", "high"]).nullish(),
|
|
4113
|
+
user: z19.string().nullish()
|
|
4114
|
+
});
|
|
4115
|
+
var openaiResponsesTextUIPartProviderMetadataSchema = z19.object({
|
|
4116
|
+
openai: z19.object({
|
|
4117
|
+
itemId: z19.string(),
|
|
4118
|
+
annotations: z19.array(responseAnnotationAddedSchema.shape.annotation)
|
|
4119
|
+
})
|
|
4120
|
+
});
|
|
4121
|
+
var openaiSourceExecutionFileProviderMetadataSchema = z19.object({
|
|
4122
|
+
openai: sourceExecutionFileCodeInterpreterItem
|
|
3833
4123
|
});
|
|
3834
4124
|
export {
|
|
3835
4125
|
OpenAIChatLanguageModel,
|
|
@@ -3839,11 +4129,24 @@ export {
|
|
|
3839
4129
|
OpenAIResponsesLanguageModel,
|
|
3840
4130
|
OpenAISpeechModel,
|
|
3841
4131
|
OpenAITranscriptionModel,
|
|
4132
|
+
codeInterpreter,
|
|
4133
|
+
codeInterpreterArgsSchema,
|
|
4134
|
+
codeInterpreterInputSchema,
|
|
4135
|
+
codeInterpreterOutputSchema,
|
|
4136
|
+
codeInterpreterToolFactory,
|
|
4137
|
+
fileSearch,
|
|
4138
|
+
fileSearchArgsSchema,
|
|
4139
|
+
fileSearchOutputSchema,
|
|
3842
4140
|
hasDefaultResponseFormat,
|
|
4141
|
+
imageGeneration,
|
|
4142
|
+
imageGenerationArgsSchema,
|
|
4143
|
+
imageGenerationOutputSchema,
|
|
3843
4144
|
modelMaxImagesPerCall,
|
|
3844
4145
|
openAITranscriptionProviderOptions,
|
|
4146
|
+
openaiChatLanguageModelOptions,
|
|
3845
4147
|
openaiCompletionProviderOptions,
|
|
3846
4148
|
openaiEmbeddingProviderOptions,
|
|
3847
|
-
|
|
4149
|
+
openaiResponsesTextUIPartProviderMetadataSchema,
|
|
4150
|
+
openaiSourceExecutionFileProviderMetadataSchema
|
|
3848
4151
|
};
|
|
3849
4152
|
//# sourceMappingURL=index.mjs.map
|