@zenning/openai 3.0.12 → 3.0.14

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,18 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.14
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
+ - approvals4
9
+
10
+ ## 3.0.13
11
+
12
+ ### Patch Changes
13
+
14
+ - 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.
15
+
3
16
  ## 3.0.12
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2484,44 +2484,8 @@ 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") {
2490
- console.log("[OpenAI Provider] Assistant message content type:", typeof message.content, "isArray:", Array.isArray(message.content));
2491
- if (Array.isArray(message.content)) {
2492
- console.log("[OpenAI Provider] Assistant content parts:", message.content.map((p) => p.type));
2493
- const approvalRequests = message.content.filter(
2494
- (p) => p.type === "tool-approval-request"
2495
- );
2496
- console.log("[OpenAI Provider] Found approval requests:", approvalRequests.length);
2497
- for (const req of approvalRequests) {
2498
- approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
2499
- }
2500
- }
2501
- }
2502
- }
2503
- console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
2504
- const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
2505
- for (const message of prompt) {
2506
- if (message.role === "tool") {
2507
- for (const part of message.content) {
2508
- if (part.type === "tool-approval-response") {
2509
- const toolCallId = approvalIdToToolCallId.get(part.approvalId);
2510
- console.log("[OpenAI Provider] Found approval response:", {
2511
- approvalId: part.approvalId,
2512
- toolCallId
2513
- });
2514
- if (toolCallId) {
2515
- toolCallsWithApprovalResponses.add(toolCallId);
2516
- }
2517
- }
2518
- }
2519
- }
2520
- }
2521
- console.log(
2522
- "[OpenAI Provider] toolCallsWithApprovalResponses:",
2523
- toolCallsWithApprovalResponses
2524
- );
2487
+ const skipItemReferences = (providerOptionsName && (store == null ? void 0 : store.skipItemReferencesForApproval)) === true;
2488
+ console.log("[OpenAI Provider] Skip item references flag:", skipItemReferences);
2525
2489
  if (compactionInput && compactionInput.length > 0) {
2526
2490
  input.push(...compactionInput);
2527
2491
  }
@@ -2599,14 +2563,6 @@ async function convertToOpenAIResponsesInput({
2599
2563
  }
2600
2564
  case "assistant": {
2601
2565
  const reasoningMessages = {};
2602
- const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
2603
- if (Array.isArray(content)) {
2604
- for (const part of content) {
2605
- if (part.type === "tool-approval-request") {
2606
- toolCallsWithApprovalRequest.add(part.toolCallId);
2607
- }
2608
- }
2609
- }
2610
2566
  for (const part of content) {
2611
2567
  switch (part.type) {
2612
2568
  case "text": {
@@ -2624,32 +2580,23 @@ async function convertToOpenAIResponsesInput({
2624
2580
  }
2625
2581
  case "tool-call": {
2626
2582
  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;
2627
- const hasApprovalResponse = toolCallsWithApprovalResponses.has(
2628
- part.toolCallId
2629
- );
2630
- const hasApprovalRequest = toolCallsWithApprovalRequest.has(
2631
- part.toolCallId
2632
- );
2633
- const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
2634
2583
  console.log("[OpenAI Provider] Processing tool-call:", {
2635
2584
  toolCallId: part.toolCallId,
2636
2585
  toolName: part.toolName,
2637
2586
  id,
2638
2587
  providerExecuted: part.providerExecuted,
2639
2588
  store,
2640
- hasApprovalResponse,
2641
- hasApprovalRequest,
2642
- skipItemReference,
2643
- willCreateItemReference: store && id != null && !skipItemReference
2589
+ skipItemReferences,
2590
+ willCreateItemReference: store && id != null && !skipItemReferences
2644
2591
  });
2645
2592
  if (part.providerExecuted) {
2646
- if (store && id != null && !skipItemReference) {
2593
+ if (store && id != null && !skipItemReferences) {
2647
2594
  console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
2648
2595
  input.push({ type: "item_reference", id });
2649
2596
  }
2650
2597
  break;
2651
2598
  }
2652
- if (store && id != null && !skipItemReference) {
2599
+ if (store && id != null && !skipItemReferences) {
2653
2600
  console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
2654
2601
  input.push({ type: "item_reference", id });
2655
2602
  break;
@@ -5837,7 +5784,7 @@ var OpenAITranscriptionModel = class {
5837
5784
  };
5838
5785
 
5839
5786
  // src/version.ts
5840
- var VERSION = true ? "3.0.11" : "0.0.0-test";
5787
+ var VERSION = true ? "3.0.13" : "0.0.0-test";
5841
5788
 
5842
5789
  // src/openai-provider.ts
5843
5790
  function createOpenAI(options = {}) {