@ai-sdk/openai 3.0.0-beta.71 → 3.0.0-beta.73
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 +18 -0
- package/dist/index.d.mts +4 -20
- package/dist/index.d.ts +4 -20
- package/dist/index.js +90 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -98
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +3 -3
- package/dist/internal/index.d.ts +3 -3
- package/dist/internal/index.js +255 -240
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +270 -254
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1766,7 +1766,7 @@ var OpenAIImageModel = class {
|
|
|
1766
1766
|
|
|
1767
1767
|
// src/tool/code-interpreter.ts
|
|
1768
1768
|
import {
|
|
1769
|
-
|
|
1769
|
+
createProviderToolFactoryWithOutputSchema,
|
|
1770
1770
|
lazySchema as lazySchema8,
|
|
1771
1771
|
zodSchema as zodSchema8
|
|
1772
1772
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1803,9 +1803,8 @@ var codeInterpreterArgsSchema = lazySchema8(
|
|
|
1803
1803
|
})
|
|
1804
1804
|
)
|
|
1805
1805
|
);
|
|
1806
|
-
var codeInterpreterToolFactory =
|
|
1806
|
+
var codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
1807
1807
|
id: "openai.code_interpreter",
|
|
1808
|
-
name: "code_interpreter",
|
|
1809
1808
|
inputSchema: codeInterpreterInputSchema,
|
|
1810
1809
|
outputSchema: codeInterpreterOutputSchema
|
|
1811
1810
|
});
|
|
@@ -1815,7 +1814,7 @@ var codeInterpreter = (args = {}) => {
|
|
|
1815
1814
|
|
|
1816
1815
|
// src/tool/file-search.ts
|
|
1817
1816
|
import {
|
|
1818
|
-
|
|
1817
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
1819
1818
|
lazySchema as lazySchema9,
|
|
1820
1819
|
zodSchema as zodSchema9
|
|
1821
1820
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1860,16 +1859,15 @@ var fileSearchOutputSchema = lazySchema9(
|
|
|
1860
1859
|
})
|
|
1861
1860
|
)
|
|
1862
1861
|
);
|
|
1863
|
-
var fileSearch =
|
|
1862
|
+
var fileSearch = createProviderToolFactoryWithOutputSchema2({
|
|
1864
1863
|
id: "openai.file_search",
|
|
1865
|
-
name: "file_search",
|
|
1866
1864
|
inputSchema: z10.object({}),
|
|
1867
1865
|
outputSchema: fileSearchOutputSchema
|
|
1868
1866
|
});
|
|
1869
1867
|
|
|
1870
1868
|
// src/tool/image-generation.ts
|
|
1871
1869
|
import {
|
|
1872
|
-
|
|
1870
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
1873
1871
|
lazySchema as lazySchema10,
|
|
1874
1872
|
zodSchema as zodSchema10
|
|
1875
1873
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1897,9 +1895,8 @@ var imageGenerationInputSchema = lazySchema10(() => zodSchema10(z11.object({})))
|
|
|
1897
1895
|
var imageGenerationOutputSchema = lazySchema10(
|
|
1898
1896
|
() => zodSchema10(z11.object({ result: z11.string() }))
|
|
1899
1897
|
);
|
|
1900
|
-
var imageGenerationToolFactory =
|
|
1898
|
+
var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema3({
|
|
1901
1899
|
id: "openai.image_generation",
|
|
1902
|
-
name: "image_generation",
|
|
1903
1900
|
inputSchema: imageGenerationInputSchema,
|
|
1904
1901
|
outputSchema: imageGenerationOutputSchema
|
|
1905
1902
|
});
|
|
@@ -1909,7 +1906,7 @@ var imageGeneration = (args = {}) => {
|
|
|
1909
1906
|
|
|
1910
1907
|
// src/tool/local-shell.ts
|
|
1911
1908
|
import {
|
|
1912
|
-
|
|
1909
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
1913
1910
|
lazySchema as lazySchema11,
|
|
1914
1911
|
zodSchema as zodSchema11
|
|
1915
1912
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1931,16 +1928,15 @@ var localShellInputSchema = lazySchema11(
|
|
|
1931
1928
|
var localShellOutputSchema = lazySchema11(
|
|
1932
1929
|
() => zodSchema11(z12.object({ output: z12.string() }))
|
|
1933
1930
|
);
|
|
1934
|
-
var localShell =
|
|
1931
|
+
var localShell = createProviderToolFactoryWithOutputSchema4({
|
|
1935
1932
|
id: "openai.local_shell",
|
|
1936
|
-
name: "local_shell",
|
|
1937
1933
|
inputSchema: localShellInputSchema,
|
|
1938
1934
|
outputSchema: localShellOutputSchema
|
|
1939
1935
|
});
|
|
1940
1936
|
|
|
1941
1937
|
// src/tool/web-search.ts
|
|
1942
1938
|
import {
|
|
1943
|
-
|
|
1939
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
1944
1940
|
lazySchema as lazySchema12,
|
|
1945
1941
|
zodSchema as zodSchema12
|
|
1946
1942
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1989,9 +1985,8 @@ var webSearchOutputSchema = lazySchema12(
|
|
|
1989
1985
|
})
|
|
1990
1986
|
)
|
|
1991
1987
|
);
|
|
1992
|
-
var webSearchToolFactory =
|
|
1988
|
+
var webSearchToolFactory = createProviderToolFactoryWithOutputSchema5({
|
|
1993
1989
|
id: "openai.web_search",
|
|
1994
|
-
name: "web_search",
|
|
1995
1990
|
inputSchema: webSearchInputSchema,
|
|
1996
1991
|
outputSchema: webSearchOutputSchema
|
|
1997
1992
|
});
|
|
@@ -1999,7 +1994,7 @@ var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
|
1999
1994
|
|
|
2000
1995
|
// src/tool/web-search-preview.ts
|
|
2001
1996
|
import {
|
|
2002
|
-
|
|
1997
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
2003
1998
|
lazySchema as lazySchema13,
|
|
2004
1999
|
zodSchema as zodSchema13
|
|
2005
2000
|
} from "@ai-sdk/provider-utils";
|
|
@@ -2042,16 +2037,15 @@ var webSearchPreviewOutputSchema = lazySchema13(
|
|
|
2042
2037
|
})
|
|
2043
2038
|
)
|
|
2044
2039
|
);
|
|
2045
|
-
var webSearchPreview =
|
|
2040
|
+
var webSearchPreview = createProviderToolFactoryWithOutputSchema6({
|
|
2046
2041
|
id: "openai.web_search_preview",
|
|
2047
|
-
name: "web_search_preview",
|
|
2048
2042
|
inputSchema: webSearchPreviewInputSchema,
|
|
2049
2043
|
outputSchema: webSearchPreviewOutputSchema
|
|
2050
2044
|
});
|
|
2051
2045
|
|
|
2052
2046
|
// src/tool/mcp.ts
|
|
2053
2047
|
import {
|
|
2054
|
-
|
|
2048
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
2055
2049
|
lazySchema as lazySchema14,
|
|
2056
2050
|
zodSchema as zodSchema14
|
|
2057
2051
|
} from "@ai-sdk/provider-utils";
|
|
@@ -2133,9 +2127,8 @@ var mcpOutputSchema = lazySchema14(
|
|
|
2133
2127
|
])
|
|
2134
2128
|
)
|
|
2135
2129
|
);
|
|
2136
|
-
var mcpToolFactory =
|
|
2130
|
+
var mcpToolFactory = createProviderToolFactoryWithOutputSchema7({
|
|
2137
2131
|
id: "openai.mcp",
|
|
2138
|
-
name: "mcp",
|
|
2139
2132
|
inputSchema: mcpInputSchema,
|
|
2140
2133
|
outputSchema: mcpOutputSchema
|
|
2141
2134
|
});
|
|
@@ -2149,8 +2142,6 @@ var openaiTools = {
|
|
|
2149
2142
|
* coding, and math.
|
|
2150
2143
|
*
|
|
2151
2144
|
* @param container - The container to use for the code interpreter.
|
|
2152
|
-
*
|
|
2153
|
-
* Must have name `code_interpreter`.
|
|
2154
2145
|
*/
|
|
2155
2146
|
codeInterpreter,
|
|
2156
2147
|
/**
|
|
@@ -2158,8 +2149,6 @@ var openaiTools = {
|
|
|
2158
2149
|
* retrieve information in a knowledge base of previously uploaded files through
|
|
2159
2150
|
* semantic and keyword search.
|
|
2160
2151
|
*
|
|
2161
|
-
* Must have name `file_search`.
|
|
2162
|
-
*
|
|
2163
2152
|
* @param vectorStoreIds - The vector store IDs to use for the file search.
|
|
2164
2153
|
* @param maxNumResults - The maximum number of results to return.
|
|
2165
2154
|
* @param ranking - The ranking options to use for the file search.
|
|
@@ -2171,8 +2160,6 @@ var openaiTools = {
|
|
|
2171
2160
|
* and optionally image inputs. It leverages the GPT Image model,
|
|
2172
2161
|
* and automatically optimizes text inputs for improved performance.
|
|
2173
2162
|
*
|
|
2174
|
-
* Must have name `image_generation`.
|
|
2175
|
-
*
|
|
2176
2163
|
* @param background - Background type for the generated image. One of 'auto', 'opaque', or 'transparent'.
|
|
2177
2164
|
* @param inputFidelity - Input fidelity for the generated image. One of 'low' or 'high'.
|
|
2178
2165
|
* @param inputImageMask - Optional mask for inpainting. Contains fileId and/or imageUrl.
|
|
@@ -2190,28 +2177,20 @@ var openaiTools = {
|
|
|
2190
2177
|
* on a machine you or the user provides.
|
|
2191
2178
|
*
|
|
2192
2179
|
* Supported models: `gpt-5-codex` and `codex-mini-latest`
|
|
2193
|
-
*
|
|
2194
|
-
* Must have name `local_shell`.
|
|
2195
2180
|
*/
|
|
2196
2181
|
localShell,
|
|
2197
2182
|
/**
|
|
2198
2183
|
* Web search allows models to access up-to-date information from the internet
|
|
2199
2184
|
* and provide answers with sourced citations.
|
|
2200
2185
|
*
|
|
2201
|
-
* Must have name `web_search_preview`.
|
|
2202
|
-
*
|
|
2203
2186
|
* @param searchContextSize - The search context size to use for the web search.
|
|
2204
2187
|
* @param userLocation - The user location to use for the web search.
|
|
2205
|
-
*
|
|
2206
|
-
* @deprecated Use `webSearch` instead.
|
|
2207
2188
|
*/
|
|
2208
2189
|
webSearchPreview,
|
|
2209
2190
|
/**
|
|
2210
2191
|
* Web search allows models to access up-to-date information from the internet
|
|
2211
2192
|
* and provide answers with sourced citations.
|
|
2212
2193
|
*
|
|
2213
|
-
* Must have name `web_search`.
|
|
2214
|
-
*
|
|
2215
2194
|
* @param filters - The filters to use for the web search.
|
|
2216
2195
|
* @param searchContextSize - The search context size to use for the web search.
|
|
2217
2196
|
* @param userLocation - The user location to use for the web search.
|
|
@@ -2221,8 +2200,6 @@ var openaiTools = {
|
|
|
2221
2200
|
* MCP (Model Context Protocol) allows models to call tools exposed by
|
|
2222
2201
|
* remote MCP servers or service connectors.
|
|
2223
2202
|
*
|
|
2224
|
-
* Must have name `mcp`.
|
|
2225
|
-
*
|
|
2226
2203
|
* @param serverLabel - Label to identify the MCP server.
|
|
2227
2204
|
* @param allowedTools - Allowed tool names or filter object.
|
|
2228
2205
|
* @param authorization - OAuth access token for the MCP server/connector.
|
|
@@ -2243,6 +2220,7 @@ import {
|
|
|
2243
2220
|
combineHeaders as combineHeaders5,
|
|
2244
2221
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
2245
2222
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
2223
|
+
createToolNameMapping,
|
|
2246
2224
|
generateId as generateId2,
|
|
2247
2225
|
parseProviderOptions as parseProviderOptions5,
|
|
2248
2226
|
postJsonToApi as postJsonToApi5
|
|
@@ -2265,6 +2243,7 @@ function isFileId(data, prefixes) {
|
|
|
2265
2243
|
}
|
|
2266
2244
|
async function convertToOpenAIResponsesInput({
|
|
2267
2245
|
prompt,
|
|
2246
|
+
toolNameMapping,
|
|
2268
2247
|
systemMessageMode,
|
|
2269
2248
|
fileIdPrefixes,
|
|
2270
2249
|
store,
|
|
@@ -2347,7 +2326,6 @@ async function convertToOpenAIResponsesInput({
|
|
|
2347
2326
|
}
|
|
2348
2327
|
case "assistant": {
|
|
2349
2328
|
const reasoningMessages = {};
|
|
2350
|
-
const toolCallParts = {};
|
|
2351
2329
|
for (const part of content) {
|
|
2352
2330
|
switch (part.type) {
|
|
2353
2331
|
case "text": {
|
|
@@ -2364,7 +2342,6 @@ async function convertToOpenAIResponsesInput({
|
|
|
2364
2342
|
break;
|
|
2365
2343
|
}
|
|
2366
2344
|
case "tool-call": {
|
|
2367
|
-
toolCallParts[part.toolCallId] = part;
|
|
2368
2345
|
if (part.providerExecuted) {
|
|
2369
2346
|
break;
|
|
2370
2347
|
}
|
|
@@ -2373,7 +2350,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2373
2350
|
input.push({ type: "item_reference", id });
|
|
2374
2351
|
break;
|
|
2375
2352
|
}
|
|
2376
|
-
|
|
2353
|
+
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
2354
|
+
part.toolName
|
|
2355
|
+
);
|
|
2356
|
+
if (hasLocalShellTool && resolvedToolName === "local_shell") {
|
|
2377
2357
|
const parsedInput = await validateTypes({
|
|
2378
2358
|
value: part.input,
|
|
2379
2359
|
schema: localShellInputSchema
|
|
@@ -2396,7 +2376,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2396
2376
|
input.push({
|
|
2397
2377
|
type: "function_call",
|
|
2398
2378
|
call_id: part.toolCallId,
|
|
2399
|
-
name:
|
|
2379
|
+
name: resolvedToolName,
|
|
2400
2380
|
arguments: JSON.stringify(part.input),
|
|
2401
2381
|
id
|
|
2402
2382
|
});
|
|
@@ -2475,7 +2455,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2475
2455
|
case "tool": {
|
|
2476
2456
|
for (const part of content) {
|
|
2477
2457
|
const output = part.output;
|
|
2478
|
-
|
|
2458
|
+
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
2459
|
+
part.toolName
|
|
2460
|
+
);
|
|
2461
|
+
if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
|
|
2479
2462
|
const parsedOutput = await validateTypes({
|
|
2480
2463
|
value: output.value,
|
|
2481
2464
|
schema: localShellOutputSchema
|
|
@@ -3302,7 +3285,7 @@ async function prepareResponsesTools({
|
|
|
3302
3285
|
strict: strictJsonSchema
|
|
3303
3286
|
});
|
|
3304
3287
|
break;
|
|
3305
|
-
case "provider
|
|
3288
|
+
case "provider": {
|
|
3306
3289
|
switch (tool.id) {
|
|
3307
3290
|
case "openai.file_search": {
|
|
3308
3291
|
const args = await validateTypes2({
|
|
@@ -3402,15 +3385,6 @@ async function prepareResponsesTools({
|
|
|
3402
3385
|
authorization: args.authorization,
|
|
3403
3386
|
connector_id: args.connectorId,
|
|
3404
3387
|
headers: args.headers,
|
|
3405
|
-
// require_approval:
|
|
3406
|
-
// typeof args.requireApproval === 'string'
|
|
3407
|
-
// ? args.requireApproval
|
|
3408
|
-
// : args.requireApproval
|
|
3409
|
-
// ? {
|
|
3410
|
-
// read_only: args.requireApproval.readOnly,
|
|
3411
|
-
// tool_names: args.requireApproval.toolNames,
|
|
3412
|
-
// }
|
|
3413
|
-
// : undefined,
|
|
3414
3388
|
require_approval: "never",
|
|
3415
3389
|
server_description: args.serverDescription,
|
|
3416
3390
|
server_url: args.serverUrl
|
|
@@ -3511,8 +3485,21 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3511
3485
|
details: "conversation and previousResponseId cannot be used together"
|
|
3512
3486
|
});
|
|
3513
3487
|
}
|
|
3488
|
+
const toolNameMapping = createToolNameMapping({
|
|
3489
|
+
tools,
|
|
3490
|
+
providerToolNames: {
|
|
3491
|
+
"openai.code_interpreter": "code_interpreter",
|
|
3492
|
+
"openai.file_search": "file_search",
|
|
3493
|
+
"openai.image_generation": "image_generation",
|
|
3494
|
+
"openai.local_shell": "local_shell",
|
|
3495
|
+
"openai.web_search": "web_search",
|
|
3496
|
+
"openai.web_search_preview": "web_search_preview",
|
|
3497
|
+
"openai.mcp": "mcp"
|
|
3498
|
+
}
|
|
3499
|
+
});
|
|
3514
3500
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
3515
3501
|
prompt,
|
|
3502
|
+
toolNameMapping,
|
|
3516
3503
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
3517
3504
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
3518
3505
|
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
|
|
@@ -3529,16 +3516,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3529
3516
|
}
|
|
3530
3517
|
}
|
|
3531
3518
|
function hasOpenAITool(id) {
|
|
3532
|
-
return (tools == null ? void 0 : tools.find(
|
|
3533
|
-
(tool) => tool.type === "provider-defined" && tool.id === id
|
|
3534
|
-
)) != null;
|
|
3519
|
+
return (tools == null ? void 0 : tools.find((tool) => tool.type === "provider" && tool.id === id)) != null;
|
|
3535
3520
|
}
|
|
3536
3521
|
const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
|
|
3537
3522
|
if (topLogprobs) {
|
|
3538
3523
|
addInclude("message.output_text.logprobs");
|
|
3539
3524
|
}
|
|
3540
3525
|
const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
|
|
3541
|
-
(tool) => tool.type === "provider
|
|
3526
|
+
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
3542
3527
|
)) == null ? void 0 : _c.name;
|
|
3543
3528
|
if (webSearchToolName) {
|
|
3544
3529
|
addInclude("web_search_call.action.sources");
|
|
@@ -3666,7 +3651,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3666
3651
|
tool_choice: openaiToolChoice
|
|
3667
3652
|
},
|
|
3668
3653
|
warnings: [...warnings, ...toolWarnings],
|
|
3669
|
-
store
|
|
3654
|
+
store,
|
|
3655
|
+
toolNameMapping
|
|
3670
3656
|
};
|
|
3671
3657
|
}
|
|
3672
3658
|
async doGenerate(options) {
|
|
@@ -3674,7 +3660,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3674
3660
|
const {
|
|
3675
3661
|
args: body,
|
|
3676
3662
|
warnings,
|
|
3677
|
-
webSearchToolName
|
|
3663
|
+
webSearchToolName,
|
|
3664
|
+
toolNameMapping
|
|
3678
3665
|
} = await this.getArgs(options);
|
|
3679
3666
|
const url = this.config.url({
|
|
3680
3667
|
path: "/responses",
|
|
@@ -3734,14 +3721,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3734
3721
|
content.push({
|
|
3735
3722
|
type: "tool-call",
|
|
3736
3723
|
toolCallId: part.id,
|
|
3737
|
-
toolName: "image_generation",
|
|
3724
|
+
toolName: toolNameMapping.toCustomToolName("image_generation"),
|
|
3738
3725
|
input: "{}",
|
|
3739
3726
|
providerExecuted: true
|
|
3740
3727
|
});
|
|
3741
3728
|
content.push({
|
|
3742
3729
|
type: "tool-result",
|
|
3743
3730
|
toolCallId: part.id,
|
|
3744
|
-
toolName: "image_generation",
|
|
3731
|
+
toolName: toolNameMapping.toCustomToolName("image_generation"),
|
|
3745
3732
|
result: {
|
|
3746
3733
|
result: part.result
|
|
3747
3734
|
}
|
|
@@ -3752,7 +3739,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3752
3739
|
content.push({
|
|
3753
3740
|
type: "tool-call",
|
|
3754
3741
|
toolCallId: part.call_id,
|
|
3755
|
-
toolName: "local_shell",
|
|
3742
|
+
toolName: toolNameMapping.toCustomToolName("local_shell"),
|
|
3756
3743
|
input: JSON.stringify({
|
|
3757
3744
|
action: part.action
|
|
3758
3745
|
}),
|
|
@@ -3862,14 +3849,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3862
3849
|
content.push({
|
|
3863
3850
|
type: "tool-call",
|
|
3864
3851
|
toolCallId: part.id,
|
|
3865
|
-
toolName:
|
|
3852
|
+
toolName: toolNameMapping.toCustomToolName(
|
|
3853
|
+
webSearchToolName != null ? webSearchToolName : "web_search"
|
|
3854
|
+
),
|
|
3866
3855
|
input: JSON.stringify({}),
|
|
3867
3856
|
providerExecuted: true
|
|
3868
3857
|
});
|
|
3869
3858
|
content.push({
|
|
3870
3859
|
type: "tool-result",
|
|
3871
3860
|
toolCallId: part.id,
|
|
3872
|
-
toolName:
|
|
3861
|
+
toolName: toolNameMapping.toCustomToolName(
|
|
3862
|
+
webSearchToolName != null ? webSearchToolName : "web_search"
|
|
3863
|
+
),
|
|
3873
3864
|
result: mapWebSearchOutput(part.action)
|
|
3874
3865
|
});
|
|
3875
3866
|
break;
|
|
@@ -3878,14 +3869,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3878
3869
|
content.push({
|
|
3879
3870
|
type: "tool-call",
|
|
3880
3871
|
toolCallId: part.id,
|
|
3881
|
-
toolName: "mcp",
|
|
3872
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
3882
3873
|
input: JSON.stringify({}),
|
|
3883
3874
|
providerExecuted: true
|
|
3884
3875
|
});
|
|
3885
3876
|
content.push({
|
|
3886
3877
|
type: "tool-result",
|
|
3887
3878
|
toolCallId: part.id,
|
|
3888
|
-
toolName: "mcp",
|
|
3879
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
3889
3880
|
result: {
|
|
3890
3881
|
type: "call",
|
|
3891
3882
|
serverLabel: part.server_label,
|
|
@@ -3901,14 +3892,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3901
3892
|
content.push({
|
|
3902
3893
|
type: "tool-call",
|
|
3903
3894
|
toolCallId: part.id,
|
|
3904
|
-
toolName: "mcp",
|
|
3895
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
3905
3896
|
input: JSON.stringify({}),
|
|
3906
3897
|
providerExecuted: true
|
|
3907
3898
|
});
|
|
3908
3899
|
content.push({
|
|
3909
3900
|
type: "tool-result",
|
|
3910
3901
|
toolCallId: part.id,
|
|
3911
|
-
toolName: "mcp",
|
|
3902
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
3912
3903
|
result: {
|
|
3913
3904
|
type: "listTools",
|
|
3914
3905
|
serverLabel: part.server_label,
|
|
@@ -3930,14 +3921,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3930
3921
|
content.push({
|
|
3931
3922
|
type: "tool-call",
|
|
3932
3923
|
toolCallId: part.id,
|
|
3933
|
-
toolName: "mcp",
|
|
3924
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
3934
3925
|
input: JSON.stringify({}),
|
|
3935
3926
|
providerExecuted: true
|
|
3936
3927
|
});
|
|
3937
3928
|
content.push({
|
|
3938
3929
|
type: "tool-result",
|
|
3939
3930
|
toolCallId: part.id,
|
|
3940
|
-
toolName: "mcp",
|
|
3931
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
3941
3932
|
result: {
|
|
3942
3933
|
type: "approvalRequest",
|
|
3943
3934
|
serverLabel: part.server_label,
|
|
@@ -3952,14 +3943,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3952
3943
|
content.push({
|
|
3953
3944
|
type: "tool-call",
|
|
3954
3945
|
toolCallId: part.id,
|
|
3955
|
-
toolName: "computer_use",
|
|
3946
|
+
toolName: toolNameMapping.toCustomToolName("computer_use"),
|
|
3956
3947
|
input: "",
|
|
3957
3948
|
providerExecuted: true
|
|
3958
3949
|
});
|
|
3959
3950
|
content.push({
|
|
3960
3951
|
type: "tool-result",
|
|
3961
3952
|
toolCallId: part.id,
|
|
3962
|
-
toolName: "computer_use",
|
|
3953
|
+
toolName: toolNameMapping.toCustomToolName("computer_use"),
|
|
3963
3954
|
result: {
|
|
3964
3955
|
type: "computer_use_tool_result",
|
|
3965
3956
|
status: part.status || "completed"
|
|
@@ -3971,14 +3962,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3971
3962
|
content.push({
|
|
3972
3963
|
type: "tool-call",
|
|
3973
3964
|
toolCallId: part.id,
|
|
3974
|
-
toolName: "file_search",
|
|
3965
|
+
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
3975
3966
|
input: "{}",
|
|
3976
3967
|
providerExecuted: true
|
|
3977
3968
|
});
|
|
3978
3969
|
content.push({
|
|
3979
3970
|
type: "tool-result",
|
|
3980
3971
|
toolCallId: part.id,
|
|
3981
|
-
toolName: "file_search",
|
|
3972
|
+
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
3982
3973
|
result: {
|
|
3983
3974
|
queries: part.queries,
|
|
3984
3975
|
results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
|
|
@@ -3996,7 +3987,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3996
3987
|
content.push({
|
|
3997
3988
|
type: "tool-call",
|
|
3998
3989
|
toolCallId: part.id,
|
|
3999
|
-
toolName: "code_interpreter",
|
|
3990
|
+
toolName: toolNameMapping.toCustomToolName("code_interpreter"),
|
|
4000
3991
|
input: JSON.stringify({
|
|
4001
3992
|
code: part.code,
|
|
4002
3993
|
containerId: part.container_id
|
|
@@ -4006,7 +3997,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4006
3997
|
content.push({
|
|
4007
3998
|
type: "tool-result",
|
|
4008
3999
|
toolCallId: part.id,
|
|
4009
|
-
toolName: "code_interpreter",
|
|
4000
|
+
toolName: toolNameMapping.toCustomToolName("code_interpreter"),
|
|
4010
4001
|
result: {
|
|
4011
4002
|
outputs: part.outputs
|
|
4012
4003
|
}
|
|
@@ -4055,6 +4046,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4055
4046
|
args: body,
|
|
4056
4047
|
warnings,
|
|
4057
4048
|
webSearchToolName,
|
|
4049
|
+
toolNameMapping,
|
|
4058
4050
|
store
|
|
4059
4051
|
} = await this.getArgs(options);
|
|
4060
4052
|
const { responseHeaders, value: response } = await postJsonToApi5({
|
|
@@ -4119,13 +4111,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4119
4111
|
});
|
|
4120
4112
|
} else if (value.item.type === "web_search_call") {
|
|
4121
4113
|
ongoingToolCalls[value.output_index] = {
|
|
4122
|
-
toolName:
|
|
4114
|
+
toolName: toolNameMapping.toCustomToolName(
|
|
4115
|
+
webSearchToolName != null ? webSearchToolName : "web_search"
|
|
4116
|
+
),
|
|
4123
4117
|
toolCallId: value.item.id
|
|
4124
4118
|
};
|
|
4125
4119
|
controller.enqueue({
|
|
4126
4120
|
type: "tool-input-start",
|
|
4127
4121
|
id: value.item.id,
|
|
4128
|
-
toolName:
|
|
4122
|
+
toolName: toolNameMapping.toCustomToolName(
|
|
4123
|
+
webSearchToolName != null ? webSearchToolName : "web_search"
|
|
4124
|
+
),
|
|
4129
4125
|
providerExecuted: true
|
|
4130
4126
|
});
|
|
4131
4127
|
controller.enqueue({
|
|
@@ -4135,24 +4131,26 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4135
4131
|
controller.enqueue({
|
|
4136
4132
|
type: "tool-call",
|
|
4137
4133
|
toolCallId: value.item.id,
|
|
4138
|
-
toolName:
|
|
4134
|
+
toolName: toolNameMapping.toCustomToolName(
|
|
4135
|
+
webSearchToolName != null ? webSearchToolName : "web_search"
|
|
4136
|
+
),
|
|
4139
4137
|
input: JSON.stringify({}),
|
|
4140
4138
|
providerExecuted: true
|
|
4141
4139
|
});
|
|
4142
4140
|
} else if (value.item.type === "computer_call") {
|
|
4143
4141
|
ongoingToolCalls[value.output_index] = {
|
|
4144
|
-
toolName: "computer_use",
|
|
4142
|
+
toolName: toolNameMapping.toCustomToolName("computer_use"),
|
|
4145
4143
|
toolCallId: value.item.id
|
|
4146
4144
|
};
|
|
4147
4145
|
controller.enqueue({
|
|
4148
4146
|
type: "tool-input-start",
|
|
4149
4147
|
id: value.item.id,
|
|
4150
|
-
toolName: "computer_use",
|
|
4148
|
+
toolName: toolNameMapping.toCustomToolName("computer_use"),
|
|
4151
4149
|
providerExecuted: true
|
|
4152
4150
|
});
|
|
4153
4151
|
} else if (value.item.type === "code_interpreter_call") {
|
|
4154
4152
|
ongoingToolCalls[value.output_index] = {
|
|
4155
|
-
toolName: "code_interpreter",
|
|
4153
|
+
toolName: toolNameMapping.toCustomToolName("code_interpreter"),
|
|
4156
4154
|
toolCallId: value.item.id,
|
|
4157
4155
|
codeInterpreter: {
|
|
4158
4156
|
containerId: value.item.container_id
|
|
@@ -4161,7 +4159,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4161
4159
|
controller.enqueue({
|
|
4162
4160
|
type: "tool-input-start",
|
|
4163
4161
|
id: value.item.id,
|
|
4164
|
-
toolName: "code_interpreter",
|
|
4162
|
+
toolName: toolNameMapping.toCustomToolName("code_interpreter"),
|
|
4165
4163
|
providerExecuted: true
|
|
4166
4164
|
});
|
|
4167
4165
|
controller.enqueue({
|
|
@@ -4173,7 +4171,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4173
4171
|
controller.enqueue({
|
|
4174
4172
|
type: "tool-call",
|
|
4175
4173
|
toolCallId: value.item.id,
|
|
4176
|
-
toolName: "file_search",
|
|
4174
|
+
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
4177
4175
|
input: "{}",
|
|
4178
4176
|
providerExecuted: true
|
|
4179
4177
|
});
|
|
@@ -4181,7 +4179,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4181
4179
|
controller.enqueue({
|
|
4182
4180
|
type: "tool-call",
|
|
4183
4181
|
toolCallId: value.item.id,
|
|
4184
|
-
toolName: "image_generation",
|
|
4182
|
+
toolName: toolNameMapping.toCustomToolName("image_generation"),
|
|
4185
4183
|
input: "{}",
|
|
4186
4184
|
providerExecuted: true
|
|
4187
4185
|
});
|
|
@@ -4189,7 +4187,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4189
4187
|
controller.enqueue({
|
|
4190
4188
|
type: "tool-call",
|
|
4191
4189
|
toolCallId: value.item.id,
|
|
4192
|
-
toolName: "mcp",
|
|
4190
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4193
4191
|
input: "{}",
|
|
4194
4192
|
providerExecuted: true
|
|
4195
4193
|
});
|
|
@@ -4257,7 +4255,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4257
4255
|
controller.enqueue({
|
|
4258
4256
|
type: "tool-result",
|
|
4259
4257
|
toolCallId: value.item.id,
|
|
4260
|
-
toolName:
|
|
4258
|
+
toolName: toolNameMapping.toCustomToolName(
|
|
4259
|
+
webSearchToolName != null ? webSearchToolName : "web_search"
|
|
4260
|
+
),
|
|
4261
4261
|
result: mapWebSearchOutput(value.item.action)
|
|
4262
4262
|
});
|
|
4263
4263
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4269,14 +4269,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4269
4269
|
controller.enqueue({
|
|
4270
4270
|
type: "tool-call",
|
|
4271
4271
|
toolCallId: value.item.id,
|
|
4272
|
-
toolName: "computer_use",
|
|
4272
|
+
toolName: toolNameMapping.toCustomToolName("computer_use"),
|
|
4273
4273
|
input: "",
|
|
4274
4274
|
providerExecuted: true
|
|
4275
4275
|
});
|
|
4276
4276
|
controller.enqueue({
|
|
4277
4277
|
type: "tool-result",
|
|
4278
4278
|
toolCallId: value.item.id,
|
|
4279
|
-
toolName: "computer_use",
|
|
4279
|
+
toolName: toolNameMapping.toCustomToolName("computer_use"),
|
|
4280
4280
|
result: {
|
|
4281
4281
|
type: "computer_use_tool_result",
|
|
4282
4282
|
status: value.item.status || "completed"
|
|
@@ -4287,7 +4287,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4287
4287
|
controller.enqueue({
|
|
4288
4288
|
type: "tool-result",
|
|
4289
4289
|
toolCallId: value.item.id,
|
|
4290
|
-
toolName: "file_search",
|
|
4290
|
+
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
4291
4291
|
result: {
|
|
4292
4292
|
queries: value.item.queries,
|
|
4293
4293
|
results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
|
|
@@ -4304,7 +4304,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4304
4304
|
controller.enqueue({
|
|
4305
4305
|
type: "tool-result",
|
|
4306
4306
|
toolCallId: value.item.id,
|
|
4307
|
-
toolName: "code_interpreter",
|
|
4307
|
+
toolName: toolNameMapping.toCustomToolName("code_interpreter"),
|
|
4308
4308
|
result: {
|
|
4309
4309
|
outputs: value.item.outputs
|
|
4310
4310
|
}
|
|
@@ -4313,7 +4313,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4313
4313
|
controller.enqueue({
|
|
4314
4314
|
type: "tool-result",
|
|
4315
4315
|
toolCallId: value.item.id,
|
|
4316
|
-
toolName: "image_generation",
|
|
4316
|
+
toolName: toolNameMapping.toCustomToolName("image_generation"),
|
|
4317
4317
|
result: {
|
|
4318
4318
|
result: value.item.result
|
|
4319
4319
|
}
|
|
@@ -4323,7 +4323,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4323
4323
|
controller.enqueue({
|
|
4324
4324
|
type: "tool-result",
|
|
4325
4325
|
toolCallId: value.item.id,
|
|
4326
|
-
toolName: "mcp",
|
|
4326
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4327
4327
|
result: {
|
|
4328
4328
|
type: "call",
|
|
4329
4329
|
serverLabel: value.item.server_label,
|
|
@@ -4338,7 +4338,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4338
4338
|
controller.enqueue({
|
|
4339
4339
|
type: "tool-result",
|
|
4340
4340
|
toolCallId: value.item.id,
|
|
4341
|
-
toolName: "mcp",
|
|
4341
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4342
4342
|
result: {
|
|
4343
4343
|
type: "listTools",
|
|
4344
4344
|
serverLabel: value.item.server_label,
|
|
@@ -4359,7 +4359,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4359
4359
|
controller.enqueue({
|
|
4360
4360
|
type: "tool-result",
|
|
4361
4361
|
toolCallId: value.item.id,
|
|
4362
|
-
toolName: "mcp",
|
|
4362
|
+
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4363
4363
|
result: {
|
|
4364
4364
|
type: "approvalRequest",
|
|
4365
4365
|
serverLabel: value.item.server_label,
|
|
@@ -4373,7 +4373,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4373
4373
|
controller.enqueue({
|
|
4374
4374
|
type: "tool-call",
|
|
4375
4375
|
toolCallId: value.item.call_id,
|
|
4376
|
-
toolName: "local_shell",
|
|
4376
|
+
toolName: toolNameMapping.toCustomToolName("local_shell"),
|
|
4377
4377
|
input: JSON.stringify({
|
|
4378
4378
|
action: {
|
|
4379
4379
|
type: "exec",
|
|
@@ -4422,7 +4422,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4422
4422
|
controller.enqueue({
|
|
4423
4423
|
type: "tool-result",
|
|
4424
4424
|
toolCallId: value.item_id,
|
|
4425
|
-
toolName: "image_generation",
|
|
4425
|
+
toolName: toolNameMapping.toCustomToolName("image_generation"),
|
|
4426
4426
|
result: {
|
|
4427
4427
|
result: value.partial_image_b64
|
|
4428
4428
|
},
|
|
@@ -4454,7 +4454,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4454
4454
|
controller.enqueue({
|
|
4455
4455
|
type: "tool-call",
|
|
4456
4456
|
toolCallId: toolCall.toolCallId,
|
|
4457
|
-
toolName: "code_interpreter",
|
|
4457
|
+
toolName: toolNameMapping.toCustomToolName("code_interpreter"),
|
|
4458
4458
|
input: JSON.stringify({
|
|
4459
4459
|
code: value.code,
|
|
4460
4460
|
containerId: toolCall.codeInterpreter.containerId
|
|
@@ -5061,7 +5061,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5061
5061
|
};
|
|
5062
5062
|
|
|
5063
5063
|
// src/version.ts
|
|
5064
|
-
var VERSION = true ? "3.0.0-beta.
|
|
5064
|
+
var VERSION = true ? "3.0.0-beta.73" : "0.0.0-test";
|
|
5065
5065
|
|
|
5066
5066
|
// src/openai-provider.ts
|
|
5067
5067
|
function createOpenAI(options = {}) {
|