@ai-sdk/openai 3.0.0-beta.108 → 3.0.0-beta.110
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 +5 -16
- package/dist/index.d.ts +5 -16
- package/dist/index.js +85 -151
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -151
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +84 -150
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +84 -150
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.110
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2625a04: feat(openai); update spec for mcp approval
|
|
8
|
+
- Updated dependencies [2625a04]
|
|
9
|
+
- @ai-sdk/provider@3.0.0-beta.31
|
|
10
|
+
- @ai-sdk/provider-utils@4.0.0-beta.58
|
|
11
|
+
|
|
12
|
+
## 3.0.0-beta.109
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- cbf52cd: feat: expose raw finish reason
|
|
17
|
+
- Updated dependencies [cbf52cd]
|
|
18
|
+
- @ai-sdk/provider@3.0.0-beta.30
|
|
19
|
+
- @ai-sdk/provider-utils@4.0.0-beta.57
|
|
20
|
+
|
|
3
21
|
## 3.0.0-beta.108
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -417,6 +417,11 @@ declare const openaiTools: {
|
|
|
417
417
|
authorization?: string;
|
|
418
418
|
connectorId?: string;
|
|
419
419
|
headers?: Record<string, string>;
|
|
420
|
+
requireApproval?: "always" | "never" | {
|
|
421
|
+
never?: {
|
|
422
|
+
toolNames?: string[];
|
|
423
|
+
};
|
|
424
|
+
};
|
|
420
425
|
serverDescription?: string;
|
|
421
426
|
serverUrl?: string;
|
|
422
427
|
}) => _ai_sdk_provider_utils.Tool<{}, {
|
|
@@ -426,22 +431,6 @@ declare const openaiTools: {
|
|
|
426
431
|
arguments: string;
|
|
427
432
|
output?: string | null;
|
|
428
433
|
error?: _ai_sdk_provider.JSONValue;
|
|
429
|
-
} | {
|
|
430
|
-
type: "listTools";
|
|
431
|
-
serverLabel: string;
|
|
432
|
-
tools: Array<{
|
|
433
|
-
name: string;
|
|
434
|
-
description?: string;
|
|
435
|
-
inputSchema: unknown;
|
|
436
|
-
annotations?: unknown;
|
|
437
|
-
}>;
|
|
438
|
-
error?: _ai_sdk_provider.JSONValue;
|
|
439
|
-
} | {
|
|
440
|
-
type: "approvalRequest";
|
|
441
|
-
serverLabel: string;
|
|
442
|
-
name: string;
|
|
443
|
-
arguments: string;
|
|
444
|
-
approvalRequestId: string;
|
|
445
434
|
}>;
|
|
446
435
|
};
|
|
447
436
|
|
package/dist/index.d.ts
CHANGED
|
@@ -417,6 +417,11 @@ declare const openaiTools: {
|
|
|
417
417
|
authorization?: string;
|
|
418
418
|
connectorId?: string;
|
|
419
419
|
headers?: Record<string, string>;
|
|
420
|
+
requireApproval?: "always" | "never" | {
|
|
421
|
+
never?: {
|
|
422
|
+
toolNames?: string[];
|
|
423
|
+
};
|
|
424
|
+
};
|
|
420
425
|
serverDescription?: string;
|
|
421
426
|
serverUrl?: string;
|
|
422
427
|
}) => _ai_sdk_provider_utils.Tool<{}, {
|
|
@@ -426,22 +431,6 @@ declare const openaiTools: {
|
|
|
426
431
|
arguments: string;
|
|
427
432
|
output?: string | null;
|
|
428
433
|
error?: _ai_sdk_provider.JSONValue;
|
|
429
|
-
} | {
|
|
430
|
-
type: "listTools";
|
|
431
|
-
serverLabel: string;
|
|
432
|
-
tools: Array<{
|
|
433
|
-
name: string;
|
|
434
|
-
description?: string;
|
|
435
|
-
inputSchema: unknown;
|
|
436
|
-
annotations?: unknown;
|
|
437
|
-
}>;
|
|
438
|
-
error?: _ai_sdk_provider.JSONValue;
|
|
439
|
-
} | {
|
|
440
|
-
type: "approvalRequest";
|
|
441
|
-
serverLabel: string;
|
|
442
|
-
name: string;
|
|
443
|
-
arguments: string;
|
|
444
|
-
approvalRequestId: string;
|
|
445
434
|
}>;
|
|
446
435
|
};
|
|
447
436
|
|
package/dist/index.js
CHANGED
|
@@ -256,6 +256,9 @@ function convertToOpenAIChatMessages({
|
|
|
256
256
|
}
|
|
257
257
|
case "tool": {
|
|
258
258
|
for (const toolResponse of content) {
|
|
259
|
+
if (toolResponse.type === "tool-approval-response") {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
259
262
|
const output = toolResponse.output;
|
|
260
263
|
let contentValue;
|
|
261
264
|
switch (output.type) {
|
|
@@ -315,7 +318,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
315
318
|
case "tool_calls":
|
|
316
319
|
return "tool-calls";
|
|
317
320
|
default:
|
|
318
|
-
return "
|
|
321
|
+
return "other";
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
324
|
|
|
@@ -837,7 +840,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
837
840
|
};
|
|
838
841
|
}
|
|
839
842
|
async doGenerate(options) {
|
|
840
|
-
var _a, _b, _c, _d, _e, _f;
|
|
843
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
841
844
|
const { args: body, warnings } = await this.getArgs(options);
|
|
842
845
|
const {
|
|
843
846
|
responseHeaders,
|
|
@@ -894,7 +897,10 @@ var OpenAIChatLanguageModel = class {
|
|
|
894
897
|
}
|
|
895
898
|
return {
|
|
896
899
|
content,
|
|
897
|
-
finishReason:
|
|
900
|
+
finishReason: {
|
|
901
|
+
unified: mapOpenAIFinishReason(choice.finish_reason),
|
|
902
|
+
raw: (_g = choice.finish_reason) != null ? _g : void 0
|
|
903
|
+
},
|
|
898
904
|
usage: convertOpenAIChatUsage(response.usage),
|
|
899
905
|
request: { body },
|
|
900
906
|
response: {
|
|
@@ -930,7 +936,10 @@ var OpenAIChatLanguageModel = class {
|
|
|
930
936
|
fetch: this.config.fetch
|
|
931
937
|
});
|
|
932
938
|
const toolCalls = [];
|
|
933
|
-
let finishReason =
|
|
939
|
+
let finishReason = {
|
|
940
|
+
unified: "other",
|
|
941
|
+
raw: void 0
|
|
942
|
+
};
|
|
934
943
|
let usage = void 0;
|
|
935
944
|
let metadataExtracted = false;
|
|
936
945
|
let isActiveText = false;
|
|
@@ -947,13 +956,13 @@ var OpenAIChatLanguageModel = class {
|
|
|
947
956
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
948
957
|
}
|
|
949
958
|
if (!chunk.success) {
|
|
950
|
-
finishReason = "error";
|
|
959
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
951
960
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
952
961
|
return;
|
|
953
962
|
}
|
|
954
963
|
const value = chunk.value;
|
|
955
964
|
if ("error" in value) {
|
|
956
|
-
finishReason = "error";
|
|
965
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
957
966
|
controller.enqueue({ type: "error", error: value.error });
|
|
958
967
|
return;
|
|
959
968
|
}
|
|
@@ -978,7 +987,10 @@ var OpenAIChatLanguageModel = class {
|
|
|
978
987
|
}
|
|
979
988
|
const choice = value.choices[0];
|
|
980
989
|
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
981
|
-
finishReason =
|
|
990
|
+
finishReason = {
|
|
991
|
+
unified: mapOpenAIFinishReason(choice.finish_reason),
|
|
992
|
+
raw: choice.finish_reason
|
|
993
|
+
};
|
|
982
994
|
}
|
|
983
995
|
if (((_e = choice == null ? void 0 : choice.logprobs) == null ? void 0 : _e.content) != null) {
|
|
984
996
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
@@ -1258,7 +1270,7 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
1258
1270
|
case "tool_calls":
|
|
1259
1271
|
return "tool-calls";
|
|
1260
1272
|
default:
|
|
1261
|
-
return "
|
|
1273
|
+
return "other";
|
|
1262
1274
|
}
|
|
1263
1275
|
}
|
|
1264
1276
|
|
|
@@ -1456,6 +1468,7 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1456
1468
|
};
|
|
1457
1469
|
}
|
|
1458
1470
|
async doGenerate(options) {
|
|
1471
|
+
var _a;
|
|
1459
1472
|
const { args, warnings } = await this.getArgs(options);
|
|
1460
1473
|
const {
|
|
1461
1474
|
responseHeaders,
|
|
@@ -1483,7 +1496,10 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1483
1496
|
return {
|
|
1484
1497
|
content: [{ type: "text", text: choice.text }],
|
|
1485
1498
|
usage: convertOpenAICompletionUsage(response.usage),
|
|
1486
|
-
finishReason:
|
|
1499
|
+
finishReason: {
|
|
1500
|
+
unified: mapOpenAIFinishReason2(choice.finish_reason),
|
|
1501
|
+
raw: (_a = choice.finish_reason) != null ? _a : void 0
|
|
1502
|
+
},
|
|
1487
1503
|
request: { body: args },
|
|
1488
1504
|
response: {
|
|
1489
1505
|
...getResponseMetadata2(response),
|
|
@@ -1517,7 +1533,10 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1517
1533
|
abortSignal: options.abortSignal,
|
|
1518
1534
|
fetch: this.config.fetch
|
|
1519
1535
|
});
|
|
1520
|
-
let finishReason =
|
|
1536
|
+
let finishReason = {
|
|
1537
|
+
unified: "other",
|
|
1538
|
+
raw: void 0
|
|
1539
|
+
};
|
|
1521
1540
|
const providerMetadata = { openai: {} };
|
|
1522
1541
|
let usage = void 0;
|
|
1523
1542
|
let isFirstChunk = true;
|
|
@@ -1532,13 +1551,13 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1532
1551
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1533
1552
|
}
|
|
1534
1553
|
if (!chunk.success) {
|
|
1535
|
-
finishReason = "error";
|
|
1554
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
1536
1555
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
1537
1556
|
return;
|
|
1538
1557
|
}
|
|
1539
1558
|
const value = chunk.value;
|
|
1540
1559
|
if ("error" in value) {
|
|
1541
|
-
finishReason = "error";
|
|
1560
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
1542
1561
|
controller.enqueue({ type: "error", error: value.error });
|
|
1543
1562
|
return;
|
|
1544
1563
|
}
|
|
@@ -1555,7 +1574,10 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1555
1574
|
}
|
|
1556
1575
|
const choice = value.choices[0];
|
|
1557
1576
|
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
1558
|
-
finishReason =
|
|
1577
|
+
finishReason = {
|
|
1578
|
+
unified: mapOpenAIFinishReason2(choice.finish_reason),
|
|
1579
|
+
raw: choice.finish_reason
|
|
1580
|
+
};
|
|
1559
1581
|
}
|
|
1560
1582
|
if ((choice == null ? void 0 : choice.logprobs) != null) {
|
|
1561
1583
|
providerMetadata.openai.logprobs = choice.logprobs;
|
|
@@ -2261,16 +2283,14 @@ var mcpArgsSchema = (0, import_provider_utils22.lazySchema)(
|
|
|
2261
2283
|
authorization: import_v417.z.string().optional(),
|
|
2262
2284
|
connectorId: import_v417.z.string().optional(),
|
|
2263
2285
|
headers: import_v417.z.record(import_v417.z.string(), import_v417.z.string()).optional(),
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
// ])
|
|
2273
|
-
// .optional(),
|
|
2286
|
+
requireApproval: import_v417.z.union([
|
|
2287
|
+
import_v417.z.enum(["always", "never"]),
|
|
2288
|
+
import_v417.z.object({
|
|
2289
|
+
never: import_v417.z.object({
|
|
2290
|
+
toolNames: import_v417.z.array(import_v417.z.string()).optional()
|
|
2291
|
+
}).optional()
|
|
2292
|
+
})
|
|
2293
|
+
]).optional(),
|
|
2274
2294
|
serverDescription: import_v417.z.string().optional(),
|
|
2275
2295
|
serverUrl: import_v417.z.string().optional()
|
|
2276
2296
|
}).refine(
|
|
@@ -2282,36 +2302,14 @@ var mcpArgsSchema = (0, import_provider_utils22.lazySchema)(
|
|
|
2282
2302
|
var mcpInputSchema = (0, import_provider_utils22.lazySchema)(() => (0, import_provider_utils22.zodSchema)(import_v417.z.object({})));
|
|
2283
2303
|
var mcpOutputSchema = (0, import_provider_utils22.lazySchema)(
|
|
2284
2304
|
() => (0, import_provider_utils22.zodSchema)(
|
|
2285
|
-
import_v417.z.
|
|
2286
|
-
import_v417.z.
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
}),
|
|
2294
|
-
import_v417.z.object({
|
|
2295
|
-
type: import_v417.z.literal("listTools"),
|
|
2296
|
-
serverLabel: import_v417.z.string(),
|
|
2297
|
-
tools: import_v417.z.array(
|
|
2298
|
-
import_v417.z.object({
|
|
2299
|
-
name: import_v417.z.string(),
|
|
2300
|
-
description: import_v417.z.string().optional(),
|
|
2301
|
-
inputSchema: jsonValueSchema,
|
|
2302
|
-
annotations: import_v417.z.record(import_v417.z.string(), jsonValueSchema).optional()
|
|
2303
|
-
})
|
|
2304
|
-
),
|
|
2305
|
-
error: import_v417.z.union([import_v417.z.string(), jsonValueSchema]).optional()
|
|
2306
|
-
}),
|
|
2307
|
-
import_v417.z.object({
|
|
2308
|
-
type: import_v417.z.literal("approvalRequest"),
|
|
2309
|
-
serverLabel: import_v417.z.string(),
|
|
2310
|
-
name: import_v417.z.string(),
|
|
2311
|
-
arguments: import_v417.z.string(),
|
|
2312
|
-
approvalRequestId: import_v417.z.string()
|
|
2313
|
-
})
|
|
2314
|
-
])
|
|
2305
|
+
import_v417.z.object({
|
|
2306
|
+
type: import_v417.z.literal("call"),
|
|
2307
|
+
serverLabel: import_v417.z.string(),
|
|
2308
|
+
name: import_v417.z.string(),
|
|
2309
|
+
arguments: import_v417.z.string(),
|
|
2310
|
+
output: import_v417.z.string().nullable().optional(),
|
|
2311
|
+
error: import_v417.z.union([import_v417.z.string(), jsonValueSchema]).optional()
|
|
2312
|
+
})
|
|
2315
2313
|
)
|
|
2316
2314
|
);
|
|
2317
2315
|
var mcpToolFactory = (0, import_provider_utils22.createProviderToolFactoryWithOutputSchema)({
|
|
@@ -2703,6 +2701,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2703
2701
|
}
|
|
2704
2702
|
case "tool": {
|
|
2705
2703
|
for (const part of content) {
|
|
2704
|
+
if (part.type === "tool-approval-response") {
|
|
2705
|
+
continue;
|
|
2706
|
+
}
|
|
2706
2707
|
const output = part.output;
|
|
2707
2708
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
2708
2709
|
part.toolName
|
|
@@ -2830,7 +2831,7 @@ function mapOpenAIResponseFinishReason({
|
|
|
2830
2831
|
case "content_filter":
|
|
2831
2832
|
return "content-filter";
|
|
2832
2833
|
default:
|
|
2833
|
-
return hasFunctionCall ? "tool-calls" : "
|
|
2834
|
+
return hasFunctionCall ? "tool-calls" : "other";
|
|
2834
2835
|
}
|
|
2835
2836
|
}
|
|
2836
2837
|
|
|
@@ -4146,7 +4147,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4146
4147
|
};
|
|
4147
4148
|
}
|
|
4148
4149
|
async doGenerate(options) {
|
|
4149
|
-
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;
|
|
4150
|
+
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;
|
|
4150
4151
|
const {
|
|
4151
4152
|
args: body,
|
|
4152
4153
|
warnings,
|
|
@@ -4397,54 +4398,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4397
4398
|
break;
|
|
4398
4399
|
}
|
|
4399
4400
|
case "mcp_list_tools": {
|
|
4400
|
-
content.push({
|
|
4401
|
-
type: "tool-call",
|
|
4402
|
-
toolCallId: part.id,
|
|
4403
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4404
|
-
input: JSON.stringify({}),
|
|
4405
|
-
providerExecuted: true
|
|
4406
|
-
});
|
|
4407
|
-
content.push({
|
|
4408
|
-
type: "tool-result",
|
|
4409
|
-
toolCallId: part.id,
|
|
4410
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4411
|
-
result: {
|
|
4412
|
-
type: "listTools",
|
|
4413
|
-
serverLabel: part.server_label,
|
|
4414
|
-
tools: part.tools.map((t) => {
|
|
4415
|
-
var _a2, _b2;
|
|
4416
|
-
return {
|
|
4417
|
-
name: t.name,
|
|
4418
|
-
description: (_a2 = t.description) != null ? _a2 : void 0,
|
|
4419
|
-
inputSchema: t.input_schema,
|
|
4420
|
-
annotations: (_b2 = t.annotations) != null ? _b2 : void 0
|
|
4421
|
-
};
|
|
4422
|
-
}),
|
|
4423
|
-
...part.error != null ? { error: part.error } : {}
|
|
4424
|
-
}
|
|
4425
|
-
});
|
|
4426
4401
|
break;
|
|
4427
4402
|
}
|
|
4428
4403
|
case "mcp_approval_request": {
|
|
4429
|
-
content.push({
|
|
4430
|
-
type: "tool-call",
|
|
4431
|
-
toolCallId: part.id,
|
|
4432
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4433
|
-
input: JSON.stringify({}),
|
|
4434
|
-
providerExecuted: true
|
|
4435
|
-
});
|
|
4436
|
-
content.push({
|
|
4437
|
-
type: "tool-result",
|
|
4438
|
-
toolCallId: part.id,
|
|
4439
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4440
|
-
result: {
|
|
4441
|
-
type: "approvalRequest",
|
|
4442
|
-
serverLabel: part.server_label,
|
|
4443
|
-
name: part.name,
|
|
4444
|
-
arguments: part.arguments,
|
|
4445
|
-
approvalRequestId: part.approval_request_id
|
|
4446
|
-
}
|
|
4447
|
-
});
|
|
4448
4404
|
break;
|
|
4449
4405
|
}
|
|
4450
4406
|
case "computer_call": {
|
|
@@ -4543,10 +4499,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4543
4499
|
const usage = response.usage;
|
|
4544
4500
|
return {
|
|
4545
4501
|
content,
|
|
4546
|
-
finishReason:
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4502
|
+
finishReason: {
|
|
4503
|
+
unified: mapOpenAIResponseFinishReason({
|
|
4504
|
+
finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
|
|
4505
|
+
hasFunctionCall
|
|
4506
|
+
}),
|
|
4507
|
+
raw: (_z = (_y = response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
|
|
4508
|
+
},
|
|
4550
4509
|
usage: convertOpenAIResponsesUsage(usage),
|
|
4551
4510
|
request: { body },
|
|
4552
4511
|
response: {
|
|
@@ -4587,7 +4546,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4587
4546
|
});
|
|
4588
4547
|
const self = this;
|
|
4589
4548
|
const providerKey = this.config.provider.replace(".responses", "");
|
|
4590
|
-
let finishReason =
|
|
4549
|
+
let finishReason = {
|
|
4550
|
+
unified: "other",
|
|
4551
|
+
raw: void 0
|
|
4552
|
+
};
|
|
4591
4553
|
let usage = void 0;
|
|
4592
4554
|
const logprobs = [];
|
|
4593
4555
|
let responseId = null;
|
|
@@ -4603,12 +4565,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4603
4565
|
controller.enqueue({ type: "stream-start", warnings });
|
|
4604
4566
|
},
|
|
4605
4567
|
transform(chunk, controller) {
|
|
4606
|
-
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;
|
|
4568
|
+
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, _C;
|
|
4607
4569
|
if (options.includeRawChunks) {
|
|
4608
4570
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
4609
4571
|
}
|
|
4610
4572
|
if (!chunk.success) {
|
|
4611
|
-
finishReason = "error";
|
|
4573
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
4612
4574
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
4613
4575
|
return;
|
|
4614
4576
|
}
|
|
@@ -4876,25 +4838,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4876
4838
|
});
|
|
4877
4839
|
} else if (value.item.type === "mcp_list_tools") {
|
|
4878
4840
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4879
|
-
controller.enqueue({
|
|
4880
|
-
type: "tool-result",
|
|
4881
|
-
toolCallId: value.item.id,
|
|
4882
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4883
|
-
result: {
|
|
4884
|
-
type: "listTools",
|
|
4885
|
-
serverLabel: value.item.server_label,
|
|
4886
|
-
tools: value.item.tools.map((t) => {
|
|
4887
|
-
var _a2, _b2;
|
|
4888
|
-
return {
|
|
4889
|
-
name: t.name,
|
|
4890
|
-
description: (_a2 = t.description) != null ? _a2 : void 0,
|
|
4891
|
-
inputSchema: t.input_schema,
|
|
4892
|
-
annotations: (_b2 = t.annotations) != null ? _b2 : void 0
|
|
4893
|
-
};
|
|
4894
|
-
}),
|
|
4895
|
-
...value.item.error != null ? { error: value.item.error } : {}
|
|
4896
|
-
}
|
|
4897
|
-
});
|
|
4898
4841
|
} else if (value.item.type === "apply_patch_call") {
|
|
4899
4842
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4900
4843
|
if (value.item.status === "completed") {
|
|
@@ -4915,18 +4858,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4915
4858
|
}
|
|
4916
4859
|
} else if (value.item.type === "mcp_approval_request") {
|
|
4917
4860
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4918
|
-
controller.enqueue({
|
|
4919
|
-
type: "tool-result",
|
|
4920
|
-
toolCallId: value.item.id,
|
|
4921
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4922
|
-
result: {
|
|
4923
|
-
type: "approvalRequest",
|
|
4924
|
-
serverLabel: value.item.server_label,
|
|
4925
|
-
name: value.item.name,
|
|
4926
|
-
arguments: value.item.arguments,
|
|
4927
|
-
approvalRequestId: value.item.approval_request_id
|
|
4928
|
-
}
|
|
4929
|
-
});
|
|
4930
4861
|
} else if (value.item.type === "local_shell_call") {
|
|
4931
4862
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4932
4863
|
controller.enqueue({
|
|
@@ -5107,10 +5038,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5107
5038
|
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
5108
5039
|
}
|
|
5109
5040
|
} else if (isResponseFinishedChunk(value)) {
|
|
5110
|
-
finishReason =
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5041
|
+
finishReason = {
|
|
5042
|
+
unified: mapOpenAIResponseFinishReason({
|
|
5043
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
5044
|
+
hasFunctionCall
|
|
5045
|
+
}),
|
|
5046
|
+
raw: (_k = (_j = value.response.incomplete_details) == null ? void 0 : _j.reason) != null ? _k : void 0
|
|
5047
|
+
};
|
|
5114
5048
|
usage = value.response.usage;
|
|
5115
5049
|
if (typeof value.response.service_tier === "string") {
|
|
5116
5050
|
serviceTier = value.response.service_tier;
|
|
@@ -5121,7 +5055,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5121
5055
|
controller.enqueue({
|
|
5122
5056
|
type: "source",
|
|
5123
5057
|
sourceType: "url",
|
|
5124
|
-
id: (
|
|
5058
|
+
id: (_n = (_m = (_l = self.config).generateId) == null ? void 0 : _m.call(_l)) != null ? _n : (0, import_provider_utils27.generateId)(),
|
|
5125
5059
|
url: value.annotation.url,
|
|
5126
5060
|
title: value.annotation.title
|
|
5127
5061
|
});
|
|
@@ -5129,10 +5063,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5129
5063
|
controller.enqueue({
|
|
5130
5064
|
type: "source",
|
|
5131
5065
|
sourceType: "document",
|
|
5132
|
-
id: (
|
|
5066
|
+
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils27.generateId)(),
|
|
5133
5067
|
mediaType: "text/plain",
|
|
5134
|
-
title: (
|
|
5135
|
-
filename: (
|
|
5068
|
+
title: (_s = (_r = value.annotation.quote) != null ? _r : value.annotation.filename) != null ? _s : "Document",
|
|
5069
|
+
filename: (_t = value.annotation.filename) != null ? _t : value.annotation.file_id,
|
|
5136
5070
|
...value.annotation.file_id ? {
|
|
5137
5071
|
providerMetadata: {
|
|
5138
5072
|
[providerKey]: {
|
|
@@ -5145,10 +5079,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5145
5079
|
controller.enqueue({
|
|
5146
5080
|
type: "source",
|
|
5147
5081
|
sourceType: "document",
|
|
5148
|
-
id: (
|
|
5082
|
+
id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (0, import_provider_utils27.generateId)(),
|
|
5149
5083
|
mediaType: "text/plain",
|
|
5150
|
-
title: (
|
|
5151
|
-
filename: (
|
|
5084
|
+
title: (_y = (_x = value.annotation.filename) != null ? _x : value.annotation.file_id) != null ? _y : "Document",
|
|
5085
|
+
filename: (_z = value.annotation.filename) != null ? _z : value.annotation.file_id,
|
|
5152
5086
|
providerMetadata: {
|
|
5153
5087
|
[providerKey]: {
|
|
5154
5088
|
fileId: value.annotation.file_id,
|
|
@@ -5161,7 +5095,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5161
5095
|
controller.enqueue({
|
|
5162
5096
|
type: "source",
|
|
5163
5097
|
sourceType: "document",
|
|
5164
|
-
id: (
|
|
5098
|
+
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (0, import_provider_utils27.generateId)(),
|
|
5165
5099
|
mediaType: "application/octet-stream",
|
|
5166
5100
|
title: value.annotation.file_id,
|
|
5167
5101
|
filename: value.annotation.file_id,
|
|
@@ -5611,7 +5545,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5611
5545
|
};
|
|
5612
5546
|
|
|
5613
5547
|
// src/version.ts
|
|
5614
|
-
var VERSION = true ? "3.0.0-beta.
|
|
5548
|
+
var VERSION = true ? "3.0.0-beta.110" : "0.0.0-test";
|
|
5615
5549
|
|
|
5616
5550
|
// src/openai-provider.ts
|
|
5617
5551
|
function createOpenAI(options = {}) {
|