@zenning/openai 3.0.8 → 3.0.11
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 +19 -0
- package/dist/index.js +64 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +63 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +63 -2
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- approvals2
|
|
8
|
+
|
|
9
|
+
## 3.0.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fix tool approval with previousResponseId. Skip creating item_reference for tool-calls that have approval responses, preventing duplicate item errors when continuing from a previous response.
|
|
14
|
+
- aporovals
|
|
15
|
+
|
|
16
|
+
## 3.0.9
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Fix tool approval with previousResponseId. Skip creating item_reference for tool-calls that have approval responses, preventing duplicate item errors when continuing from a previous response.
|
|
21
|
+
|
|
3
22
|
## 3.0.8
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -2484,6 +2484,39 @@ async function convertToOpenAIResponsesInput({
|
|
|
2484
2484
|
const input = [];
|
|
2485
2485
|
const warnings = [];
|
|
2486
2486
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2487
|
+
const approvalIdToToolCallId = /* @__PURE__ */ new Map();
|
|
2488
|
+
for (const message of prompt) {
|
|
2489
|
+
if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
2490
|
+
const approvalRequests = message.content.filter(
|
|
2491
|
+
(p) => p.type === "tool-approval-request"
|
|
2492
|
+
);
|
|
2493
|
+
for (const req of approvalRequests) {
|
|
2494
|
+
approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
|
|
2499
|
+
const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
|
|
2500
|
+
for (const message of prompt) {
|
|
2501
|
+
if (message.role === "tool") {
|
|
2502
|
+
for (const part of message.content) {
|
|
2503
|
+
if (part.type === "tool-approval-response") {
|
|
2504
|
+
const toolCallId = approvalIdToToolCallId.get(part.approvalId);
|
|
2505
|
+
console.log("[OpenAI Provider] Found approval response:", {
|
|
2506
|
+
approvalId: part.approvalId,
|
|
2507
|
+
toolCallId
|
|
2508
|
+
});
|
|
2509
|
+
if (toolCallId) {
|
|
2510
|
+
toolCallsWithApprovalResponses.add(toolCallId);
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
console.log(
|
|
2517
|
+
"[OpenAI Provider] toolCallsWithApprovalResponses:",
|
|
2518
|
+
toolCallsWithApprovalResponses
|
|
2519
|
+
);
|
|
2487
2520
|
if (compactionInput && compactionInput.length > 0) {
|
|
2488
2521
|
input.push(...compactionInput);
|
|
2489
2522
|
}
|
|
@@ -2561,6 +2594,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2561
2594
|
}
|
|
2562
2595
|
case "assistant": {
|
|
2563
2596
|
const reasoningMessages = {};
|
|
2597
|
+
const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
|
|
2598
|
+
if (Array.isArray(content)) {
|
|
2599
|
+
for (const part of content) {
|
|
2600
|
+
if (part.type === "tool-approval-request") {
|
|
2601
|
+
toolCallsWithApprovalRequest.add(part.toolCallId);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2564
2605
|
for (const part of content) {
|
|
2565
2606
|
switch (part.type) {
|
|
2566
2607
|
case "text": {
|
|
@@ -2578,13 +2619,33 @@ async function convertToOpenAIResponsesInput({
|
|
|
2578
2619
|
}
|
|
2579
2620
|
case "tool-call": {
|
|
2580
2621
|
const id = (_g = (_d = (_c = part.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.itemId) != null ? _g : (_f = (_e = part.providerMetadata) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.itemId;
|
|
2622
|
+
const hasApprovalResponse = toolCallsWithApprovalResponses.has(
|
|
2623
|
+
part.toolCallId
|
|
2624
|
+
);
|
|
2625
|
+
const hasApprovalRequest = toolCallsWithApprovalRequest.has(
|
|
2626
|
+
part.toolCallId
|
|
2627
|
+
);
|
|
2628
|
+
const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
|
|
2629
|
+
console.log("[OpenAI Provider] Processing tool-call:", {
|
|
2630
|
+
toolCallId: part.toolCallId,
|
|
2631
|
+
toolName: part.toolName,
|
|
2632
|
+
id,
|
|
2633
|
+
providerExecuted: part.providerExecuted,
|
|
2634
|
+
store,
|
|
2635
|
+
hasApprovalResponse,
|
|
2636
|
+
hasApprovalRequest,
|
|
2637
|
+
skipItemReference,
|
|
2638
|
+
willCreateItemReference: store && id != null && !skipItemReference
|
|
2639
|
+
});
|
|
2581
2640
|
if (part.providerExecuted) {
|
|
2582
|
-
if (store && id != null) {
|
|
2641
|
+
if (store && id != null && !skipItemReference) {
|
|
2642
|
+
console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
|
|
2583
2643
|
input.push({ type: "item_reference", id });
|
|
2584
2644
|
}
|
|
2585
2645
|
break;
|
|
2586
2646
|
}
|
|
2587
|
-
if (store && id != null) {
|
|
2647
|
+
if (store && id != null && !skipItemReference) {
|
|
2648
|
+
console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
|
|
2588
2649
|
input.push({ type: "item_reference", id });
|
|
2589
2650
|
break;
|
|
2590
2651
|
}
|
|
@@ -5771,7 +5832,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5771
5832
|
};
|
|
5772
5833
|
|
|
5773
5834
|
// src/version.ts
|
|
5774
|
-
var VERSION = true ? "3.0.
|
|
5835
|
+
var VERSION = true ? "3.0.10" : "0.0.0-test";
|
|
5775
5836
|
|
|
5776
5837
|
// src/openai-provider.ts
|
|
5777
5838
|
function createOpenAI(options = {}) {
|