@zenning/openai 3.0.11 → 3.0.13

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix duplicate item_reference for approval responses. Skip creating item_reference for all tool-calls when approval responses are detected in the prompt, preventing duplicate item errors with previousResponseId.
8
+
9
+ ## 3.0.12
10
+
11
+ ### Patch Changes
12
+
13
+ - approvals3
14
+
3
15
  ## 3.0.11
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2484,39 +2484,10 @@ 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
2487
+ const hasApprovalResponses = prompt.some(
2488
+ (message) => message.role === "tool" && message.content.some((part) => part.type === "tool-approval-response")
2519
2489
  );
2490
+ console.log("[OpenAI Provider] Approval continuation detected:", hasApprovalResponses);
2520
2491
  if (compactionInput && compactionInput.length > 0) {
2521
2492
  input.push(...compactionInput);
2522
2493
  }
@@ -2594,14 +2565,6 @@ async function convertToOpenAIResponsesInput({
2594
2565
  }
2595
2566
  case "assistant": {
2596
2567
  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
- }
2605
2568
  for (const part of content) {
2606
2569
  switch (part.type) {
2607
2570
  case "text": {
@@ -2619,21 +2582,14 @@ async function convertToOpenAIResponsesInput({
2619
2582
  }
2620
2583
  case "tool-call": {
2621
2584
  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;
2585
+ const skipItemReference = hasApprovalResponses;
2629
2586
  console.log("[OpenAI Provider] Processing tool-call:", {
2630
2587
  toolCallId: part.toolCallId,
2631
2588
  toolName: part.toolName,
2632
2589
  id,
2633
2590
  providerExecuted: part.providerExecuted,
2634
2591
  store,
2635
- hasApprovalResponse,
2636
- hasApprovalRequest,
2592
+ hasApprovalResponses,
2637
2593
  skipItemReference,
2638
2594
  willCreateItemReference: store && id != null && !skipItemReference
2639
2595
  });
@@ -5832,7 +5788,7 @@ var OpenAITranscriptionModel = class {
5832
5788
  };
5833
5789
 
5834
5790
  // src/version.ts
5835
- var VERSION = true ? "3.0.10" : "0.0.0-test";
5791
+ var VERSION = true ? "3.0.12" : "0.0.0-test";
5836
5792
 
5837
5793
  // src/openai-provider.ts
5838
5794
  function createOpenAI(options = {}) {