@ai-sdk/openai 2.1.0-beta.0 → 2.1.0-beta.10
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 +97 -0
- package/dist/index.d.mts +67 -14
- package/dist/index.d.ts +67 -14
- package/dist/index.js +617 -399
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +587 -368
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +333 -23
- package/dist/internal/index.d.ts +333 -23
- package/dist/internal/index.js +633 -407
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +601 -386
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/internal/index.mjs
CHANGED
|
@@ -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) {
|
|
@@ -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
|
};
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -2036,14 +2036,39 @@ import {
|
|
|
2036
2036
|
parseProviderOptions as parseProviderOptions7,
|
|
2037
2037
|
postJsonToApi as postJsonToApi6
|
|
2038
2038
|
} from "@ai-sdk/provider-utils";
|
|
2039
|
-
import { z as
|
|
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 "@ai-sdk/provider";
|
|
2045
2045
|
import { convertToBase64 as convertToBase642, parseProviderOptions as parseProviderOptions6 } from "@ai-sdk/provider-utils";
|
|
2046
|
+
import { z as z13 } from "zod/v4";
|
|
2047
|
+
|
|
2048
|
+
// src/tool/local-shell.ts
|
|
2049
|
+
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/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,15 +2173,33 @@ 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
|
}
|
|
2202
|
+
// assistant tool result parts are from provider-executed tools:
|
|
2159
2203
|
case "tool-result": {
|
|
2160
2204
|
if (store) {
|
|
2161
2205
|
input.push({ type: "item_reference", id: part.toolCallId });
|
|
@@ -2175,26 +2219,40 @@ async function convertToOpenAIResponsesInput({
|
|
|
2175
2219
|
});
|
|
2176
2220
|
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2177
2221
|
if (reasoningId != null) {
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
if (existingReasoningMessage === void 0) {
|
|
2189
|
-
reasoningMessages[reasoningId] = {
|
|
2190
|
-
type: "reasoning",
|
|
2191
|
-
id: reasoningId,
|
|
2192
|
-
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2193
|
-
summary: summaryParts
|
|
2194
|
-
};
|
|
2195
|
-
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
|
+
}
|
|
2196
2232
|
} else {
|
|
2197
|
-
|
|
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
|
+
}
|
|
2198
2256
|
}
|
|
2199
2257
|
} else {
|
|
2200
2258
|
warnings.push({
|
|
@@ -2211,6 +2269,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2211
2269
|
case "tool": {
|
|
2212
2270
|
for (const part of content) {
|
|
2213
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
|
+
}
|
|
2214
2280
|
let contentValue;
|
|
2215
2281
|
switch (output.type) {
|
|
2216
2282
|
case "text":
|
|
@@ -2239,9 +2305,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2239
2305
|
}
|
|
2240
2306
|
return { input, warnings };
|
|
2241
2307
|
}
|
|
2242
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
2243
|
-
itemId:
|
|
2244
|
-
reasoningEncryptedContent:
|
|
2308
|
+
var openaiResponsesReasoningProviderOptionsSchema = z13.object({
|
|
2309
|
+
itemId: z13.string().nullish(),
|
|
2310
|
+
reasoningEncryptedContent: z13.string().nullish()
|
|
2245
2311
|
});
|
|
2246
2312
|
|
|
2247
2313
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -2268,110 +2334,113 @@ import {
|
|
|
2268
2334
|
} from "@ai-sdk/provider";
|
|
2269
2335
|
|
|
2270
2336
|
// src/tool/code-interpreter.ts
|
|
2271
|
-
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
2272
|
-
import { z as
|
|
2273
|
-
var codeInterpreterInputSchema =
|
|
2274
|
-
code:
|
|
2275
|
-
containerId:
|
|
2337
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
|
|
2338
|
+
import { z as z14 } from "zod/v4";
|
|
2339
|
+
var codeInterpreterInputSchema = z14.object({
|
|
2340
|
+
code: z14.string().nullish(),
|
|
2341
|
+
containerId: z14.string()
|
|
2276
2342
|
});
|
|
2277
|
-
var codeInterpreterOutputSchema =
|
|
2278
|
-
outputs:
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
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() })
|
|
2282
2348
|
])
|
|
2283
2349
|
).nullish()
|
|
2284
2350
|
});
|
|
2285
|
-
var codeInterpreterArgsSchema =
|
|
2286
|
-
container:
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
fileIds:
|
|
2351
|
+
var codeInterpreterArgsSchema = z14.object({
|
|
2352
|
+
container: z14.union([
|
|
2353
|
+
z14.string(),
|
|
2354
|
+
z14.object({
|
|
2355
|
+
fileIds: z14.array(z14.string()).optional()
|
|
2290
2356
|
})
|
|
2291
2357
|
]).optional()
|
|
2292
2358
|
});
|
|
2293
|
-
var codeInterpreterToolFactory =
|
|
2359
|
+
var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
2294
2360
|
id: "openai.code_interpreter",
|
|
2295
2361
|
name: "code_interpreter",
|
|
2296
2362
|
inputSchema: codeInterpreterInputSchema,
|
|
2297
2363
|
outputSchema: codeInterpreterOutputSchema
|
|
2298
2364
|
});
|
|
2365
|
+
var codeInterpreter = (args = {}) => {
|
|
2366
|
+
return codeInterpreterToolFactory(args);
|
|
2367
|
+
};
|
|
2299
2368
|
|
|
2300
2369
|
// src/tool/file-search.ts
|
|
2301
|
-
import { createProviderDefinedToolFactoryWithOutputSchema as
|
|
2302
|
-
import { z as
|
|
2303
|
-
var comparisonFilterSchema =
|
|
2304
|
-
key:
|
|
2305
|
-
type:
|
|
2306
|
-
value:
|
|
2370
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/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()])
|
|
2307
2376
|
});
|
|
2308
|
-
var compoundFilterSchema =
|
|
2309
|
-
type:
|
|
2310
|
-
filters:
|
|
2311
|
-
|
|
2377
|
+
var compoundFilterSchema = z15.object({
|
|
2378
|
+
type: z15.enum(["and", "or"]),
|
|
2379
|
+
filters: z15.array(
|
|
2380
|
+
z15.union([comparisonFilterSchema, z15.lazy(() => compoundFilterSchema)])
|
|
2312
2381
|
)
|
|
2313
2382
|
});
|
|
2314
|
-
var fileSearchArgsSchema =
|
|
2315
|
-
vectorStoreIds:
|
|
2316
|
-
maxNumResults:
|
|
2317
|
-
ranking:
|
|
2318
|
-
ranker:
|
|
2319
|
-
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()
|
|
2320
2389
|
}).optional(),
|
|
2321
|
-
filters:
|
|
2390
|
+
filters: z15.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
2322
2391
|
});
|
|
2323
|
-
var fileSearchOutputSchema =
|
|
2324
|
-
queries:
|
|
2325
|
-
results:
|
|
2326
|
-
|
|
2327
|
-
attributes:
|
|
2328
|
-
fileId:
|
|
2329
|
-
filename:
|
|
2330
|
-
score:
|
|
2331
|
-
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()
|
|
2332
2401
|
})
|
|
2333
2402
|
).nullable()
|
|
2334
2403
|
});
|
|
2335
|
-
var fileSearch =
|
|
2404
|
+
var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
2336
2405
|
id: "openai.file_search",
|
|
2337
2406
|
name: "file_search",
|
|
2338
|
-
inputSchema:
|
|
2407
|
+
inputSchema: z15.object({}),
|
|
2339
2408
|
outputSchema: fileSearchOutputSchema
|
|
2340
2409
|
});
|
|
2341
2410
|
|
|
2342
2411
|
// src/tool/web-search.ts
|
|
2343
2412
|
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
2344
|
-
import { z as
|
|
2345
|
-
var webSearchArgsSchema =
|
|
2346
|
-
filters:
|
|
2347
|
-
allowedDomains:
|
|
2413
|
+
import { z as z16 } from "zod/v4";
|
|
2414
|
+
var webSearchArgsSchema = z16.object({
|
|
2415
|
+
filters: z16.object({
|
|
2416
|
+
allowedDomains: z16.array(z16.string()).optional()
|
|
2348
2417
|
}).optional(),
|
|
2349
|
-
searchContextSize:
|
|
2350
|
-
userLocation:
|
|
2351
|
-
type:
|
|
2352
|
-
country:
|
|
2353
|
-
city:
|
|
2354
|
-
region:
|
|
2355
|
-
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()
|
|
2356
2425
|
}).optional()
|
|
2357
2426
|
});
|
|
2358
2427
|
var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
2359
2428
|
id: "openai.web_search",
|
|
2360
2429
|
name: "web_search",
|
|
2361
|
-
inputSchema:
|
|
2362
|
-
action:
|
|
2363
|
-
|
|
2364
|
-
type:
|
|
2365
|
-
query:
|
|
2430
|
+
inputSchema: z16.object({
|
|
2431
|
+
action: z16.discriminatedUnion("type", [
|
|
2432
|
+
z16.object({
|
|
2433
|
+
type: z16.literal("search"),
|
|
2434
|
+
query: z16.string().nullish()
|
|
2366
2435
|
}),
|
|
2367
|
-
|
|
2368
|
-
type:
|
|
2369
|
-
url:
|
|
2436
|
+
z16.object({
|
|
2437
|
+
type: z16.literal("open_page"),
|
|
2438
|
+
url: z16.string()
|
|
2370
2439
|
}),
|
|
2371
|
-
|
|
2372
|
-
type:
|
|
2373
|
-
url:
|
|
2374
|
-
pattern:
|
|
2440
|
+
z16.object({
|
|
2441
|
+
type: z16.literal("find"),
|
|
2442
|
+
url: z16.string(),
|
|
2443
|
+
pattern: z16.string()
|
|
2375
2444
|
})
|
|
2376
2445
|
]).nullish()
|
|
2377
2446
|
})
|
|
@@ -2379,89 +2448,92 @@ var webSearchToolFactory = createProviderDefinedToolFactory({
|
|
|
2379
2448
|
|
|
2380
2449
|
// src/tool/web-search-preview.ts
|
|
2381
2450
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
2382
|
-
import { z as
|
|
2383
|
-
var webSearchPreviewArgsSchema =
|
|
2451
|
+
import { z as z17 } from "zod/v4";
|
|
2452
|
+
var webSearchPreviewArgsSchema = z17.object({
|
|
2384
2453
|
/**
|
|
2385
2454
|
* Search context size to use for the web search.
|
|
2386
2455
|
* - high: Most comprehensive context, highest cost, slower response
|
|
2387
2456
|
* - medium: Balanced context, cost, and latency (default)
|
|
2388
2457
|
* - low: Least context, lowest cost, fastest response
|
|
2389
2458
|
*/
|
|
2390
|
-
searchContextSize:
|
|
2459
|
+
searchContextSize: z17.enum(["low", "medium", "high"]).optional(),
|
|
2391
2460
|
/**
|
|
2392
2461
|
* User location information to provide geographically relevant search results.
|
|
2393
2462
|
*/
|
|
2394
|
-
userLocation:
|
|
2463
|
+
userLocation: z17.object({
|
|
2395
2464
|
/**
|
|
2396
2465
|
* Type of location (always 'approximate')
|
|
2397
2466
|
*/
|
|
2398
|
-
type:
|
|
2467
|
+
type: z17.literal("approximate"),
|
|
2399
2468
|
/**
|
|
2400
2469
|
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
2401
2470
|
*/
|
|
2402
|
-
country:
|
|
2471
|
+
country: z17.string().optional(),
|
|
2403
2472
|
/**
|
|
2404
2473
|
* City name (free text, e.g., 'Minneapolis')
|
|
2405
2474
|
*/
|
|
2406
|
-
city:
|
|
2475
|
+
city: z17.string().optional(),
|
|
2407
2476
|
/**
|
|
2408
2477
|
* Region name (free text, e.g., 'Minnesota')
|
|
2409
2478
|
*/
|
|
2410
|
-
region:
|
|
2479
|
+
region: z17.string().optional(),
|
|
2411
2480
|
/**
|
|
2412
2481
|
* IANA timezone (e.g., 'America/Chicago')
|
|
2413
2482
|
*/
|
|
2414
|
-
timezone:
|
|
2483
|
+
timezone: z17.string().optional()
|
|
2415
2484
|
}).optional()
|
|
2416
2485
|
});
|
|
2417
2486
|
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
2418
2487
|
id: "openai.web_search_preview",
|
|
2419
2488
|
name: "web_search_preview",
|
|
2420
|
-
inputSchema:
|
|
2421
|
-
action:
|
|
2422
|
-
|
|
2423
|
-
type:
|
|
2424
|
-
query:
|
|
2489
|
+
inputSchema: z17.object({
|
|
2490
|
+
action: z17.discriminatedUnion("type", [
|
|
2491
|
+
z17.object({
|
|
2492
|
+
type: z17.literal("search"),
|
|
2493
|
+
query: z17.string().nullish()
|
|
2425
2494
|
}),
|
|
2426
|
-
|
|
2427
|
-
type:
|
|
2428
|
-
url:
|
|
2495
|
+
z17.object({
|
|
2496
|
+
type: z17.literal("open_page"),
|
|
2497
|
+
url: z17.string()
|
|
2429
2498
|
}),
|
|
2430
|
-
|
|
2431
|
-
type:
|
|
2432
|
-
url:
|
|
2433
|
-
pattern:
|
|
2499
|
+
z17.object({
|
|
2500
|
+
type: z17.literal("find"),
|
|
2501
|
+
url: z17.string(),
|
|
2502
|
+
pattern: z17.string()
|
|
2434
2503
|
})
|
|
2435
2504
|
]).nullish()
|
|
2436
2505
|
})
|
|
2437
2506
|
});
|
|
2438
2507
|
|
|
2439
2508
|
// src/tool/image-generation.ts
|
|
2440
|
-
import { createProviderDefinedToolFactoryWithOutputSchema as
|
|
2441
|
-
import { z as
|
|
2442
|
-
var imageGenerationArgsSchema =
|
|
2443
|
-
background:
|
|
2444
|
-
inputFidelity:
|
|
2445
|
-
inputImageMask:
|
|
2446
|
-
fileId:
|
|
2447
|
-
imageUrl:
|
|
2509
|
+
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4 } from "@ai-sdk/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()
|
|
2448
2517
|
}).optional(),
|
|
2449
|
-
model:
|
|
2450
|
-
moderation:
|
|
2451
|
-
outputCompression:
|
|
2452
|
-
outputFormat:
|
|
2453
|
-
quality:
|
|
2454
|
-
size:
|
|
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
|
+
quality: z18.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2523
|
+
size: z18.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
2455
2524
|
}).strict();
|
|
2456
|
-
var imageGenerationOutputSchema =
|
|
2457
|
-
result:
|
|
2525
|
+
var imageGenerationOutputSchema = z18.object({
|
|
2526
|
+
result: z18.string()
|
|
2458
2527
|
});
|
|
2459
|
-
var imageGenerationToolFactory =
|
|
2528
|
+
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
2460
2529
|
id: "openai.image_generation",
|
|
2461
2530
|
name: "image_generation",
|
|
2462
|
-
inputSchema:
|
|
2531
|
+
inputSchema: z18.object({}),
|
|
2463
2532
|
outputSchema: imageGenerationOutputSchema
|
|
2464
2533
|
});
|
|
2534
|
+
var imageGeneration = (args = {}) => {
|
|
2535
|
+
return imageGenerationToolFactory(args);
|
|
2536
|
+
};
|
|
2465
2537
|
|
|
2466
2538
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2467
2539
|
function prepareResponsesTools({
|
|
@@ -2502,6 +2574,12 @@ function prepareResponsesTools({
|
|
|
2502
2574
|
});
|
|
2503
2575
|
break;
|
|
2504
2576
|
}
|
|
2577
|
+
case "openai.local_shell": {
|
|
2578
|
+
openaiTools.push({
|
|
2579
|
+
type: "local_shell"
|
|
2580
|
+
});
|
|
2581
|
+
break;
|
|
2582
|
+
}
|
|
2505
2583
|
case "openai.web_search_preview": {
|
|
2506
2584
|
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
2507
2585
|
openaiTools.push({
|
|
@@ -2581,73 +2659,86 @@ function prepareResponsesTools({
|
|
|
2581
2659
|
}
|
|
2582
2660
|
|
|
2583
2661
|
// src/responses/openai-responses-language-model.ts
|
|
2584
|
-
var webSearchCallItem =
|
|
2585
|
-
type:
|
|
2586
|
-
id:
|
|
2587
|
-
status:
|
|
2588
|
-
action:
|
|
2589
|
-
|
|
2590
|
-
type:
|
|
2591
|
-
query:
|
|
2662
|
+
var webSearchCallItem = z19.object({
|
|
2663
|
+
type: z19.literal("web_search_call"),
|
|
2664
|
+
id: z19.string(),
|
|
2665
|
+
status: z19.string(),
|
|
2666
|
+
action: z19.discriminatedUnion("type", [
|
|
2667
|
+
z19.object({
|
|
2668
|
+
type: z19.literal("search"),
|
|
2669
|
+
query: z19.string().nullish()
|
|
2592
2670
|
}),
|
|
2593
|
-
|
|
2594
|
-
type:
|
|
2595
|
-
url:
|
|
2671
|
+
z19.object({
|
|
2672
|
+
type: z19.literal("open_page"),
|
|
2673
|
+
url: z19.string()
|
|
2596
2674
|
}),
|
|
2597
|
-
|
|
2598
|
-
type:
|
|
2599
|
-
url:
|
|
2600
|
-
pattern:
|
|
2675
|
+
z19.object({
|
|
2676
|
+
type: z19.literal("find"),
|
|
2677
|
+
url: z19.string(),
|
|
2678
|
+
pattern: z19.string()
|
|
2601
2679
|
})
|
|
2602
2680
|
]).nullish()
|
|
2603
2681
|
});
|
|
2604
|
-
var fileSearchCallItem =
|
|
2605
|
-
type:
|
|
2606
|
-
id:
|
|
2607
|
-
queries:
|
|
2608
|
-
results:
|
|
2609
|
-
|
|
2610
|
-
attributes:
|
|
2611
|
-
file_id:
|
|
2612
|
-
filename:
|
|
2613
|
-
score:
|
|
2614
|
-
text:
|
|
2682
|
+
var fileSearchCallItem = z19.object({
|
|
2683
|
+
type: z19.literal("file_search_call"),
|
|
2684
|
+
id: z19.string(),
|
|
2685
|
+
queries: z19.array(z19.string()),
|
|
2686
|
+
results: z19.array(
|
|
2687
|
+
z19.object({
|
|
2688
|
+
attributes: z19.record(z19.string(), z19.unknown()),
|
|
2689
|
+
file_id: z19.string(),
|
|
2690
|
+
filename: z19.string(),
|
|
2691
|
+
score: z19.number(),
|
|
2692
|
+
text: z19.string()
|
|
2615
2693
|
})
|
|
2616
2694
|
).nullish()
|
|
2617
2695
|
});
|
|
2618
|
-
var codeInterpreterCallItem =
|
|
2619
|
-
type:
|
|
2620
|
-
id:
|
|
2621
|
-
code:
|
|
2622
|
-
container_id:
|
|
2623
|
-
outputs:
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2696
|
+
var codeInterpreterCallItem = z19.object({
|
|
2697
|
+
type: z19.literal("code_interpreter_call"),
|
|
2698
|
+
id: z19.string(),
|
|
2699
|
+
code: z19.string().nullable(),
|
|
2700
|
+
container_id: z19.string(),
|
|
2701
|
+
outputs: z19.array(
|
|
2702
|
+
z19.discriminatedUnion("type", [
|
|
2703
|
+
z19.object({ type: z19.literal("logs"), logs: z19.string() }),
|
|
2704
|
+
z19.object({ type: z19.literal("image"), url: z19.string() })
|
|
2627
2705
|
])
|
|
2628
2706
|
).nullable()
|
|
2629
2707
|
});
|
|
2630
|
-
var
|
|
2631
|
-
type:
|
|
2632
|
-
id:
|
|
2633
|
-
|
|
2708
|
+
var localShellCallItem = z19.object({
|
|
2709
|
+
type: z19.literal("local_shell_call"),
|
|
2710
|
+
id: z19.string(),
|
|
2711
|
+
call_id: z19.string(),
|
|
2712
|
+
action: z19.object({
|
|
2713
|
+
type: z19.literal("exec"),
|
|
2714
|
+
command: z19.array(z19.string()),
|
|
2715
|
+
timeout_ms: z19.number().optional(),
|
|
2716
|
+
user: z19.string().optional(),
|
|
2717
|
+
working_directory: z19.string().optional(),
|
|
2718
|
+
env: z19.record(z19.string(), z19.string()).optional()
|
|
2719
|
+
})
|
|
2720
|
+
});
|
|
2721
|
+
var imageGenerationCallItem = z19.object({
|
|
2722
|
+
type: z19.literal("image_generation_call"),
|
|
2723
|
+
id: z19.string(),
|
|
2724
|
+
result: z19.string()
|
|
2634
2725
|
});
|
|
2635
2726
|
var TOP_LOGPROBS_MAX = 20;
|
|
2636
|
-
var LOGPROBS_SCHEMA =
|
|
2637
|
-
|
|
2638
|
-
token:
|
|
2639
|
-
logprob:
|
|
2640
|
-
top_logprobs:
|
|
2641
|
-
|
|
2642
|
-
token:
|
|
2643
|
-
logprob:
|
|
2727
|
+
var LOGPROBS_SCHEMA = z19.array(
|
|
2728
|
+
z19.object({
|
|
2729
|
+
token: z19.string(),
|
|
2730
|
+
logprob: z19.number(),
|
|
2731
|
+
top_logprobs: z19.array(
|
|
2732
|
+
z19.object({
|
|
2733
|
+
token: z19.string(),
|
|
2734
|
+
logprob: z19.number()
|
|
2644
2735
|
})
|
|
2645
2736
|
)
|
|
2646
2737
|
})
|
|
2647
2738
|
);
|
|
2648
2739
|
var OpenAIResponsesLanguageModel = class {
|
|
2649
2740
|
constructor(modelId, config) {
|
|
2650
|
-
this.specificationVersion = "
|
|
2741
|
+
this.specificationVersion = "v3";
|
|
2651
2742
|
this.supportedUrls = {
|
|
2652
2743
|
"image/*": [/^https?:\/\/.*$/],
|
|
2653
2744
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
@@ -2706,7 +2797,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2706
2797
|
prompt,
|
|
2707
2798
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
2708
2799
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
2709
|
-
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
|
|
2800
|
+
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
|
|
2801
|
+
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
2710
2802
|
});
|
|
2711
2803
|
warnings.push(...inputWarnings);
|
|
2712
2804
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
@@ -2871,45 +2963,45 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2871
2963
|
body,
|
|
2872
2964
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2873
2965
|
successfulResponseHandler: createJsonResponseHandler6(
|
|
2874
|
-
|
|
2875
|
-
id:
|
|
2876
|
-
created_at:
|
|
2877
|
-
error:
|
|
2878
|
-
code:
|
|
2879
|
-
message:
|
|
2966
|
+
z19.object({
|
|
2967
|
+
id: z19.string(),
|
|
2968
|
+
created_at: z19.number(),
|
|
2969
|
+
error: z19.object({
|
|
2970
|
+
code: z19.string(),
|
|
2971
|
+
message: z19.string()
|
|
2880
2972
|
}).nullish(),
|
|
2881
|
-
model:
|
|
2882
|
-
output:
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
type:
|
|
2886
|
-
role:
|
|
2887
|
-
id:
|
|
2888
|
-
content:
|
|
2889
|
-
|
|
2890
|
-
type:
|
|
2891
|
-
text:
|
|
2973
|
+
model: z19.string(),
|
|
2974
|
+
output: z19.array(
|
|
2975
|
+
z19.discriminatedUnion("type", [
|
|
2976
|
+
z19.object({
|
|
2977
|
+
type: z19.literal("message"),
|
|
2978
|
+
role: z19.literal("assistant"),
|
|
2979
|
+
id: z19.string(),
|
|
2980
|
+
content: z19.array(
|
|
2981
|
+
z19.object({
|
|
2982
|
+
type: z19.literal("output_text"),
|
|
2983
|
+
text: z19.string(),
|
|
2892
2984
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2893
|
-
annotations:
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
type:
|
|
2897
|
-
start_index:
|
|
2898
|
-
end_index:
|
|
2899
|
-
url:
|
|
2900
|
-
title:
|
|
2985
|
+
annotations: z19.array(
|
|
2986
|
+
z19.discriminatedUnion("type", [
|
|
2987
|
+
z19.object({
|
|
2988
|
+
type: z19.literal("url_citation"),
|
|
2989
|
+
start_index: z19.number(),
|
|
2990
|
+
end_index: z19.number(),
|
|
2991
|
+
url: z19.string(),
|
|
2992
|
+
title: z19.string()
|
|
2901
2993
|
}),
|
|
2902
|
-
|
|
2903
|
-
type:
|
|
2904
|
-
file_id:
|
|
2905
|
-
filename:
|
|
2906
|
-
index:
|
|
2907
|
-
start_index:
|
|
2908
|
-
end_index:
|
|
2909
|
-
quote:
|
|
2994
|
+
z19.object({
|
|
2995
|
+
type: z19.literal("file_citation"),
|
|
2996
|
+
file_id: z19.string(),
|
|
2997
|
+
filename: z19.string().nullish(),
|
|
2998
|
+
index: z19.number().nullish(),
|
|
2999
|
+
start_index: z19.number().nullish(),
|
|
3000
|
+
end_index: z19.number().nullish(),
|
|
3001
|
+
quote: z19.string().nullish()
|
|
2910
3002
|
}),
|
|
2911
|
-
|
|
2912
|
-
type:
|
|
3003
|
+
z19.object({
|
|
3004
|
+
type: z19.literal("container_file_citation")
|
|
2913
3005
|
})
|
|
2914
3006
|
])
|
|
2915
3007
|
)
|
|
@@ -2920,33 +3012,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2920
3012
|
fileSearchCallItem,
|
|
2921
3013
|
codeInterpreterCallItem,
|
|
2922
3014
|
imageGenerationCallItem,
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
3015
|
+
localShellCallItem,
|
|
3016
|
+
z19.object({
|
|
3017
|
+
type: z19.literal("function_call"),
|
|
3018
|
+
call_id: z19.string(),
|
|
3019
|
+
name: z19.string(),
|
|
3020
|
+
arguments: z19.string(),
|
|
3021
|
+
id: z19.string()
|
|
2929
3022
|
}),
|
|
2930
|
-
|
|
2931
|
-
type:
|
|
2932
|
-
id:
|
|
2933
|
-
status:
|
|
3023
|
+
z19.object({
|
|
3024
|
+
type: z19.literal("computer_call"),
|
|
3025
|
+
id: z19.string(),
|
|
3026
|
+
status: z19.string().optional()
|
|
2934
3027
|
}),
|
|
2935
|
-
|
|
2936
|
-
type:
|
|
2937
|
-
id:
|
|
2938
|
-
encrypted_content:
|
|
2939
|
-
summary:
|
|
2940
|
-
|
|
2941
|
-
type:
|
|
2942
|
-
text:
|
|
3028
|
+
z19.object({
|
|
3029
|
+
type: z19.literal("reasoning"),
|
|
3030
|
+
id: z19.string(),
|
|
3031
|
+
encrypted_content: z19.string().nullish(),
|
|
3032
|
+
summary: z19.array(
|
|
3033
|
+
z19.object({
|
|
3034
|
+
type: z19.literal("summary_text"),
|
|
3035
|
+
text: z19.string()
|
|
2943
3036
|
})
|
|
2944
3037
|
)
|
|
2945
3038
|
})
|
|
2946
3039
|
])
|
|
2947
3040
|
),
|
|
2948
|
-
service_tier:
|
|
2949
|
-
incomplete_details:
|
|
3041
|
+
service_tier: z19.string().nullish(),
|
|
3042
|
+
incomplete_details: z19.object({ reason: z19.string() }).nullish(),
|
|
2950
3043
|
usage: usageSchema2
|
|
2951
3044
|
})
|
|
2952
3045
|
),
|
|
@@ -3006,6 +3099,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3006
3099
|
});
|
|
3007
3100
|
break;
|
|
3008
3101
|
}
|
|
3102
|
+
case "local_shell_call": {
|
|
3103
|
+
content.push({
|
|
3104
|
+
type: "tool-call",
|
|
3105
|
+
toolCallId: part.call_id,
|
|
3106
|
+
toolName: "local_shell",
|
|
3107
|
+
input: JSON.stringify({ action: part.action }),
|
|
3108
|
+
providerMetadata: {
|
|
3109
|
+
openai: {
|
|
3110
|
+
itemId: part.id
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
});
|
|
3114
|
+
break;
|
|
3115
|
+
}
|
|
3009
3116
|
case "message": {
|
|
3010
3117
|
for (const contentPart of part.content) {
|
|
3011
3118
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
@@ -3263,6 +3370,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3263
3370
|
id: value.item.id,
|
|
3264
3371
|
toolName: "computer_use"
|
|
3265
3372
|
});
|
|
3373
|
+
} else if (value.item.type === "code_interpreter_call") {
|
|
3374
|
+
ongoingToolCalls[value.output_index] = {
|
|
3375
|
+
toolName: "code_interpreter",
|
|
3376
|
+
toolCallId: value.item.id,
|
|
3377
|
+
codeInterpreter: {
|
|
3378
|
+
containerId: value.item.container_id
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3381
|
+
controller.enqueue({
|
|
3382
|
+
type: "tool-input-start",
|
|
3383
|
+
id: value.item.id,
|
|
3384
|
+
toolName: "code_interpreter"
|
|
3385
|
+
});
|
|
3386
|
+
controller.enqueue({
|
|
3387
|
+
type: "tool-input-delta",
|
|
3388
|
+
id: value.item.id,
|
|
3389
|
+
delta: `{"containerId":"${value.item.container_id}","code":"`
|
|
3390
|
+
});
|
|
3266
3391
|
} else if (value.item.type === "file_search_call") {
|
|
3267
3392
|
controller.enqueue({
|
|
3268
3393
|
type: "tool-call",
|
|
@@ -3386,16 +3511,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3386
3511
|
providerExecuted: true
|
|
3387
3512
|
});
|
|
3388
3513
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3389
|
-
|
|
3390
|
-
type: "tool-call",
|
|
3391
|
-
toolCallId: value.item.id,
|
|
3392
|
-
toolName: "code_interpreter",
|
|
3393
|
-
input: JSON.stringify({
|
|
3394
|
-
code: value.item.code,
|
|
3395
|
-
containerId: value.item.container_id
|
|
3396
|
-
}),
|
|
3397
|
-
providerExecuted: true
|
|
3398
|
-
});
|
|
3514
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3399
3515
|
controller.enqueue({
|
|
3400
3516
|
type: "tool-result",
|
|
3401
3517
|
toolCallId: value.item.id,
|
|
@@ -3415,6 +3531,26 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3415
3531
|
},
|
|
3416
3532
|
providerExecuted: true
|
|
3417
3533
|
});
|
|
3534
|
+
} else if (value.item.type === "local_shell_call") {
|
|
3535
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3536
|
+
controller.enqueue({
|
|
3537
|
+
type: "tool-call",
|
|
3538
|
+
toolCallId: value.item.call_id,
|
|
3539
|
+
toolName: "local_shell",
|
|
3540
|
+
input: JSON.stringify({
|
|
3541
|
+
action: {
|
|
3542
|
+
type: "exec",
|
|
3543
|
+
command: value.item.action.command,
|
|
3544
|
+
timeoutMs: value.item.action.timeout_ms,
|
|
3545
|
+
user: value.item.action.user,
|
|
3546
|
+
workingDirectory: value.item.action.working_directory,
|
|
3547
|
+
env: value.item.action.env
|
|
3548
|
+
}
|
|
3549
|
+
}),
|
|
3550
|
+
providerMetadata: {
|
|
3551
|
+
openai: { itemId: value.item.id }
|
|
3552
|
+
}
|
|
3553
|
+
});
|
|
3418
3554
|
} else if (value.item.type === "message") {
|
|
3419
3555
|
controller.enqueue({
|
|
3420
3556
|
type: "text-end",
|
|
@@ -3445,6 +3581,40 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3445
3581
|
delta: value.delta
|
|
3446
3582
|
});
|
|
3447
3583
|
}
|
|
3584
|
+
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3585
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3586
|
+
if (toolCall != null) {
|
|
3587
|
+
controller.enqueue({
|
|
3588
|
+
type: "tool-input-delta",
|
|
3589
|
+
id: toolCall.toolCallId,
|
|
3590
|
+
// The delta is code, which is embedding in a JSON string.
|
|
3591
|
+
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
3592
|
+
delta: JSON.stringify(value.delta).slice(1, -1)
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3595
|
+
} else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
3596
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3597
|
+
if (toolCall != null) {
|
|
3598
|
+
controller.enqueue({
|
|
3599
|
+
type: "tool-input-delta",
|
|
3600
|
+
id: toolCall.toolCallId,
|
|
3601
|
+
delta: '"}'
|
|
3602
|
+
});
|
|
3603
|
+
controller.enqueue({
|
|
3604
|
+
type: "tool-input-end",
|
|
3605
|
+
id: toolCall.toolCallId
|
|
3606
|
+
});
|
|
3607
|
+
controller.enqueue({
|
|
3608
|
+
type: "tool-call",
|
|
3609
|
+
toolCallId: toolCall.toolCallId,
|
|
3610
|
+
toolName: "code_interpreter",
|
|
3611
|
+
input: JSON.stringify({
|
|
3612
|
+
code: value.code,
|
|
3613
|
+
containerId: toolCall.codeInterpreter.containerId
|
|
3614
|
+
}),
|
|
3615
|
+
providerExecuted: true
|
|
3616
|
+
});
|
|
3617
|
+
}
|
|
3448
3618
|
} else if (isResponseCreatedChunk(value)) {
|
|
3449
3619
|
responseId = value.response.id;
|
|
3450
3620
|
controller.enqueue({
|
|
@@ -3551,166 +3721,194 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3551
3721
|
};
|
|
3552
3722
|
}
|
|
3553
3723
|
};
|
|
3554
|
-
var usageSchema2 =
|
|
3555
|
-
input_tokens:
|
|
3556
|
-
input_tokens_details:
|
|
3557
|
-
output_tokens:
|
|
3558
|
-
output_tokens_details:
|
|
3724
|
+
var usageSchema2 = z19.object({
|
|
3725
|
+
input_tokens: z19.number(),
|
|
3726
|
+
input_tokens_details: z19.object({ cached_tokens: z19.number().nullish() }).nullish(),
|
|
3727
|
+
output_tokens: z19.number(),
|
|
3728
|
+
output_tokens_details: z19.object({ reasoning_tokens: z19.number().nullish() }).nullish()
|
|
3559
3729
|
});
|
|
3560
|
-
var textDeltaChunkSchema =
|
|
3561
|
-
type:
|
|
3562
|
-
item_id:
|
|
3563
|
-
delta:
|
|
3730
|
+
var textDeltaChunkSchema = z19.object({
|
|
3731
|
+
type: z19.literal("response.output_text.delta"),
|
|
3732
|
+
item_id: z19.string(),
|
|
3733
|
+
delta: z19.string(),
|
|
3564
3734
|
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3565
3735
|
});
|
|
3566
|
-
var errorChunkSchema =
|
|
3567
|
-
type:
|
|
3568
|
-
code:
|
|
3569
|
-
message:
|
|
3570
|
-
param:
|
|
3571
|
-
sequence_number:
|
|
3736
|
+
var errorChunkSchema = z19.object({
|
|
3737
|
+
type: z19.literal("error"),
|
|
3738
|
+
code: z19.string(),
|
|
3739
|
+
message: z19.string(),
|
|
3740
|
+
param: z19.string().nullish(),
|
|
3741
|
+
sequence_number: z19.number()
|
|
3572
3742
|
});
|
|
3573
|
-
var responseFinishedChunkSchema =
|
|
3574
|
-
type:
|
|
3575
|
-
response:
|
|
3576
|
-
incomplete_details:
|
|
3743
|
+
var responseFinishedChunkSchema = z19.object({
|
|
3744
|
+
type: z19.enum(["response.completed", "response.incomplete"]),
|
|
3745
|
+
response: z19.object({
|
|
3746
|
+
incomplete_details: z19.object({ reason: z19.string() }).nullish(),
|
|
3577
3747
|
usage: usageSchema2,
|
|
3578
|
-
service_tier:
|
|
3748
|
+
service_tier: z19.string().nullish()
|
|
3579
3749
|
})
|
|
3580
3750
|
});
|
|
3581
|
-
var responseCreatedChunkSchema =
|
|
3582
|
-
type:
|
|
3583
|
-
response:
|
|
3584
|
-
id:
|
|
3585
|
-
created_at:
|
|
3586
|
-
model:
|
|
3587
|
-
service_tier:
|
|
3751
|
+
var responseCreatedChunkSchema = z19.object({
|
|
3752
|
+
type: z19.literal("response.created"),
|
|
3753
|
+
response: z19.object({
|
|
3754
|
+
id: z19.string(),
|
|
3755
|
+
created_at: z19.number(),
|
|
3756
|
+
model: z19.string(),
|
|
3757
|
+
service_tier: z19.string().nullish()
|
|
3588
3758
|
})
|
|
3589
3759
|
});
|
|
3590
|
-
var responseOutputItemAddedSchema =
|
|
3591
|
-
type:
|
|
3592
|
-
output_index:
|
|
3593
|
-
item:
|
|
3594
|
-
|
|
3595
|
-
type:
|
|
3596
|
-
id:
|
|
3760
|
+
var responseOutputItemAddedSchema = z19.object({
|
|
3761
|
+
type: z19.literal("response.output_item.added"),
|
|
3762
|
+
output_index: z19.number(),
|
|
3763
|
+
item: z19.discriminatedUnion("type", [
|
|
3764
|
+
z19.object({
|
|
3765
|
+
type: z19.literal("message"),
|
|
3766
|
+
id: z19.string()
|
|
3597
3767
|
}),
|
|
3598
|
-
|
|
3599
|
-
type:
|
|
3600
|
-
id:
|
|
3601
|
-
encrypted_content:
|
|
3768
|
+
z19.object({
|
|
3769
|
+
type: z19.literal("reasoning"),
|
|
3770
|
+
id: z19.string(),
|
|
3771
|
+
encrypted_content: z19.string().nullish()
|
|
3602
3772
|
}),
|
|
3603
|
-
|
|
3604
|
-
type:
|
|
3605
|
-
id:
|
|
3606
|
-
call_id:
|
|
3607
|
-
name:
|
|
3608
|
-
arguments:
|
|
3773
|
+
z19.object({
|
|
3774
|
+
type: z19.literal("function_call"),
|
|
3775
|
+
id: z19.string(),
|
|
3776
|
+
call_id: z19.string(),
|
|
3777
|
+
name: z19.string(),
|
|
3778
|
+
arguments: z19.string()
|
|
3609
3779
|
}),
|
|
3610
|
-
|
|
3611
|
-
type:
|
|
3612
|
-
id:
|
|
3613
|
-
status:
|
|
3614
|
-
action:
|
|
3615
|
-
type:
|
|
3616
|
-
query:
|
|
3780
|
+
z19.object({
|
|
3781
|
+
type: z19.literal("web_search_call"),
|
|
3782
|
+
id: z19.string(),
|
|
3783
|
+
status: z19.string(),
|
|
3784
|
+
action: z19.object({
|
|
3785
|
+
type: z19.literal("search"),
|
|
3786
|
+
query: z19.string().optional()
|
|
3617
3787
|
}).nullish()
|
|
3618
3788
|
}),
|
|
3619
|
-
|
|
3620
|
-
type:
|
|
3621
|
-
id:
|
|
3622
|
-
status:
|
|
3789
|
+
z19.object({
|
|
3790
|
+
type: z19.literal("computer_call"),
|
|
3791
|
+
id: z19.string(),
|
|
3792
|
+
status: z19.string()
|
|
3623
3793
|
}),
|
|
3624
|
-
|
|
3625
|
-
type:
|
|
3626
|
-
id:
|
|
3794
|
+
z19.object({
|
|
3795
|
+
type: z19.literal("file_search_call"),
|
|
3796
|
+
id: z19.string()
|
|
3627
3797
|
}),
|
|
3628
|
-
|
|
3629
|
-
type:
|
|
3630
|
-
id:
|
|
3798
|
+
z19.object({
|
|
3799
|
+
type: z19.literal("image_generation_call"),
|
|
3800
|
+
id: z19.string()
|
|
3801
|
+
}),
|
|
3802
|
+
z19.object({
|
|
3803
|
+
type: z19.literal("code_interpreter_call"),
|
|
3804
|
+
id: z19.string(),
|
|
3805
|
+
container_id: z19.string(),
|
|
3806
|
+
code: z19.string().nullable(),
|
|
3807
|
+
outputs: z19.array(
|
|
3808
|
+
z19.discriminatedUnion("type", [
|
|
3809
|
+
z19.object({ type: z19.literal("logs"), logs: z19.string() }),
|
|
3810
|
+
z19.object({ type: z19.literal("image"), url: z19.string() })
|
|
3811
|
+
])
|
|
3812
|
+
).nullable(),
|
|
3813
|
+
status: z19.string()
|
|
3631
3814
|
})
|
|
3632
3815
|
])
|
|
3633
3816
|
});
|
|
3634
|
-
var responseOutputItemDoneSchema =
|
|
3635
|
-
type:
|
|
3636
|
-
output_index:
|
|
3637
|
-
item:
|
|
3638
|
-
|
|
3639
|
-
type:
|
|
3640
|
-
id:
|
|
3817
|
+
var responseOutputItemDoneSchema = z19.object({
|
|
3818
|
+
type: z19.literal("response.output_item.done"),
|
|
3819
|
+
output_index: z19.number(),
|
|
3820
|
+
item: z19.discriminatedUnion("type", [
|
|
3821
|
+
z19.object({
|
|
3822
|
+
type: z19.literal("message"),
|
|
3823
|
+
id: z19.string()
|
|
3641
3824
|
}),
|
|
3642
|
-
|
|
3643
|
-
type:
|
|
3644
|
-
id:
|
|
3645
|
-
encrypted_content:
|
|
3825
|
+
z19.object({
|
|
3826
|
+
type: z19.literal("reasoning"),
|
|
3827
|
+
id: z19.string(),
|
|
3828
|
+
encrypted_content: z19.string().nullish()
|
|
3646
3829
|
}),
|
|
3647
|
-
|
|
3648
|
-
type:
|
|
3649
|
-
id:
|
|
3650
|
-
call_id:
|
|
3651
|
-
name:
|
|
3652
|
-
arguments:
|
|
3653
|
-
status:
|
|
3830
|
+
z19.object({
|
|
3831
|
+
type: z19.literal("function_call"),
|
|
3832
|
+
id: z19.string(),
|
|
3833
|
+
call_id: z19.string(),
|
|
3834
|
+
name: z19.string(),
|
|
3835
|
+
arguments: z19.string(),
|
|
3836
|
+
status: z19.literal("completed")
|
|
3654
3837
|
}),
|
|
3655
3838
|
codeInterpreterCallItem,
|
|
3656
3839
|
imageGenerationCallItem,
|
|
3657
3840
|
webSearchCallItem,
|
|
3658
3841
|
fileSearchCallItem,
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3842
|
+
localShellCallItem,
|
|
3843
|
+
z19.object({
|
|
3844
|
+
type: z19.literal("computer_call"),
|
|
3845
|
+
id: z19.string(),
|
|
3846
|
+
status: z19.literal("completed")
|
|
3663
3847
|
})
|
|
3664
3848
|
])
|
|
3665
3849
|
});
|
|
3666
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
3667
|
-
type:
|
|
3668
|
-
item_id:
|
|
3669
|
-
output_index:
|
|
3670
|
-
delta:
|
|
3850
|
+
var responseFunctionCallArgumentsDeltaSchema = z19.object({
|
|
3851
|
+
type: z19.literal("response.function_call_arguments.delta"),
|
|
3852
|
+
item_id: z19.string(),
|
|
3853
|
+
output_index: z19.number(),
|
|
3854
|
+
delta: z19.string()
|
|
3855
|
+
});
|
|
3856
|
+
var responseCodeInterpreterCallCodeDeltaSchema = z19.object({
|
|
3857
|
+
type: z19.literal("response.code_interpreter_call_code.delta"),
|
|
3858
|
+
item_id: z19.string(),
|
|
3859
|
+
output_index: z19.number(),
|
|
3860
|
+
delta: z19.string()
|
|
3861
|
+
});
|
|
3862
|
+
var responseCodeInterpreterCallCodeDoneSchema = z19.object({
|
|
3863
|
+
type: z19.literal("response.code_interpreter_call_code.done"),
|
|
3864
|
+
item_id: z19.string(),
|
|
3865
|
+
output_index: z19.number(),
|
|
3866
|
+
code: z19.string()
|
|
3671
3867
|
});
|
|
3672
|
-
var responseAnnotationAddedSchema =
|
|
3673
|
-
type:
|
|
3674
|
-
annotation:
|
|
3675
|
-
|
|
3676
|
-
type:
|
|
3677
|
-
url:
|
|
3678
|
-
title:
|
|
3868
|
+
var responseAnnotationAddedSchema = z19.object({
|
|
3869
|
+
type: z19.literal("response.output_text.annotation.added"),
|
|
3870
|
+
annotation: z19.discriminatedUnion("type", [
|
|
3871
|
+
z19.object({
|
|
3872
|
+
type: z19.literal("url_citation"),
|
|
3873
|
+
url: z19.string(),
|
|
3874
|
+
title: z19.string()
|
|
3679
3875
|
}),
|
|
3680
|
-
|
|
3681
|
-
type:
|
|
3682
|
-
file_id:
|
|
3683
|
-
filename:
|
|
3684
|
-
index:
|
|
3685
|
-
start_index:
|
|
3686
|
-
end_index:
|
|
3687
|
-
quote:
|
|
3876
|
+
z19.object({
|
|
3877
|
+
type: z19.literal("file_citation"),
|
|
3878
|
+
file_id: z19.string(),
|
|
3879
|
+
filename: z19.string().nullish(),
|
|
3880
|
+
index: z19.number().nullish(),
|
|
3881
|
+
start_index: z19.number().nullish(),
|
|
3882
|
+
end_index: z19.number().nullish(),
|
|
3883
|
+
quote: z19.string().nullish()
|
|
3688
3884
|
})
|
|
3689
3885
|
])
|
|
3690
3886
|
});
|
|
3691
|
-
var responseReasoningSummaryPartAddedSchema =
|
|
3692
|
-
type:
|
|
3693
|
-
item_id:
|
|
3694
|
-
summary_index:
|
|
3887
|
+
var responseReasoningSummaryPartAddedSchema = z19.object({
|
|
3888
|
+
type: z19.literal("response.reasoning_summary_part.added"),
|
|
3889
|
+
item_id: z19.string(),
|
|
3890
|
+
summary_index: z19.number()
|
|
3695
3891
|
});
|
|
3696
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
3697
|
-
type:
|
|
3698
|
-
item_id:
|
|
3699
|
-
summary_index:
|
|
3700
|
-
delta:
|
|
3892
|
+
var responseReasoningSummaryTextDeltaSchema = z19.object({
|
|
3893
|
+
type: z19.literal("response.reasoning_summary_text.delta"),
|
|
3894
|
+
item_id: z19.string(),
|
|
3895
|
+
summary_index: z19.number(),
|
|
3896
|
+
delta: z19.string()
|
|
3701
3897
|
});
|
|
3702
|
-
var openaiResponsesChunkSchema =
|
|
3898
|
+
var openaiResponsesChunkSchema = z19.union([
|
|
3703
3899
|
textDeltaChunkSchema,
|
|
3704
3900
|
responseFinishedChunkSchema,
|
|
3705
3901
|
responseCreatedChunkSchema,
|
|
3706
3902
|
responseOutputItemAddedSchema,
|
|
3707
3903
|
responseOutputItemDoneSchema,
|
|
3708
3904
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3905
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3906
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
3709
3907
|
responseAnnotationAddedSchema,
|
|
3710
3908
|
responseReasoningSummaryPartAddedSchema,
|
|
3711
3909
|
responseReasoningSummaryTextDeltaSchema,
|
|
3712
3910
|
errorChunkSchema,
|
|
3713
|
-
|
|
3911
|
+
z19.object({ type: z19.string() }).loose()
|
|
3714
3912
|
// fallback for unknown chunks
|
|
3715
3913
|
]);
|
|
3716
3914
|
function isTextDeltaChunk(chunk) {
|
|
@@ -3731,6 +3929,12 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3731
3929
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3732
3930
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3733
3931
|
}
|
|
3932
|
+
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
3933
|
+
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
3934
|
+
}
|
|
3935
|
+
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
3936
|
+
return chunk.type === "response.code_interpreter_call_code.done";
|
|
3937
|
+
}
|
|
3734
3938
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3735
3939
|
return chunk.type === "response.output_item.added";
|
|
3736
3940
|
}
|
|
@@ -3783,15 +3987,15 @@ function getResponsesModelConfig(modelId) {
|
|
|
3783
3987
|
isReasoningModel: false
|
|
3784
3988
|
};
|
|
3785
3989
|
}
|
|
3786
|
-
var openaiResponsesProviderOptionsSchema =
|
|
3787
|
-
include:
|
|
3788
|
-
|
|
3990
|
+
var openaiResponsesProviderOptionsSchema = z19.object({
|
|
3991
|
+
include: z19.array(
|
|
3992
|
+
z19.enum([
|
|
3789
3993
|
"reasoning.encrypted_content",
|
|
3790
3994
|
"file_search_call.results",
|
|
3791
3995
|
"message.output_text.logprobs"
|
|
3792
3996
|
])
|
|
3793
3997
|
).nullish(),
|
|
3794
|
-
instructions:
|
|
3998
|
+
instructions: z19.string().nullish(),
|
|
3795
3999
|
/**
|
|
3796
4000
|
* Return the log probabilities of the tokens.
|
|
3797
4001
|
*
|
|
@@ -3804,25 +4008,25 @@ var openaiResponsesProviderOptionsSchema = z18.object({
|
|
|
3804
4008
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3805
4009
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3806
4010
|
*/
|
|
3807
|
-
logprobs:
|
|
4011
|
+
logprobs: z19.union([z19.boolean(), z19.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3808
4012
|
/**
|
|
3809
4013
|
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3810
4014
|
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3811
4015
|
* Any further attempts to call a tool by the model will be ignored.
|
|
3812
4016
|
*/
|
|
3813
|
-
maxToolCalls:
|
|
3814
|
-
metadata:
|
|
3815
|
-
parallelToolCalls:
|
|
3816
|
-
previousResponseId:
|
|
3817
|
-
promptCacheKey:
|
|
3818
|
-
reasoningEffort:
|
|
3819
|
-
reasoningSummary:
|
|
3820
|
-
safetyIdentifier:
|
|
3821
|
-
serviceTier:
|
|
3822
|
-
store:
|
|
3823
|
-
strictJsonSchema:
|
|
3824
|
-
textVerbosity:
|
|
3825
|
-
user:
|
|
4017
|
+
maxToolCalls: z19.number().nullish(),
|
|
4018
|
+
metadata: z19.any().nullish(),
|
|
4019
|
+
parallelToolCalls: z19.boolean().nullish(),
|
|
4020
|
+
previousResponseId: z19.string().nullish(),
|
|
4021
|
+
promptCacheKey: z19.string().nullish(),
|
|
4022
|
+
reasoningEffort: z19.string().nullish(),
|
|
4023
|
+
reasoningSummary: z19.string().nullish(),
|
|
4024
|
+
safetyIdentifier: z19.string().nullish(),
|
|
4025
|
+
serviceTier: z19.enum(["auto", "flex", "priority"]).nullish(),
|
|
4026
|
+
store: z19.boolean().nullish(),
|
|
4027
|
+
strictJsonSchema: z19.boolean().nullish(),
|
|
4028
|
+
textVerbosity: z19.enum(["low", "medium", "high"]).nullish(),
|
|
4029
|
+
user: z19.string().nullish()
|
|
3826
4030
|
});
|
|
3827
4031
|
export {
|
|
3828
4032
|
OpenAIChatLanguageModel,
|
|
@@ -3832,11 +4036,22 @@ export {
|
|
|
3832
4036
|
OpenAIResponsesLanguageModel,
|
|
3833
4037
|
OpenAISpeechModel,
|
|
3834
4038
|
OpenAITranscriptionModel,
|
|
4039
|
+
codeInterpreter,
|
|
4040
|
+
codeInterpreterArgsSchema,
|
|
4041
|
+
codeInterpreterInputSchema,
|
|
4042
|
+
codeInterpreterOutputSchema,
|
|
4043
|
+
codeInterpreterToolFactory,
|
|
4044
|
+
fileSearch,
|
|
4045
|
+
fileSearchArgsSchema,
|
|
4046
|
+
fileSearchOutputSchema,
|
|
3835
4047
|
hasDefaultResponseFormat,
|
|
4048
|
+
imageGeneration,
|
|
4049
|
+
imageGenerationArgsSchema,
|
|
4050
|
+
imageGenerationOutputSchema,
|
|
3836
4051
|
modelMaxImagesPerCall,
|
|
3837
4052
|
openAITranscriptionProviderOptions,
|
|
4053
|
+
openaiChatLanguageModelOptions,
|
|
3838
4054
|
openaiCompletionProviderOptions,
|
|
3839
|
-
openaiEmbeddingProviderOptions
|
|
3840
|
-
openaiProviderOptions
|
|
4055
|
+
openaiEmbeddingProviderOptions
|
|
3841
4056
|
};
|
|
3842
4057
|
//# sourceMappingURL=index.mjs.map
|