@zenning/openai 3.0.21 → 3.0.22

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.
@@ -2477,6 +2477,21 @@ async function convertToOpenAIResponsesInput({
2477
2477
  const input = [];
2478
2478
  const warnings = [];
2479
2479
  const processedApprovalIds = /* @__PURE__ */ new Set();
2480
+ const approvalToolCallIds = /* @__PURE__ */ new Set();
2481
+ if (containsApprovalResponses) {
2482
+ for (const message of prompt) {
2483
+ if (message.role !== "assistant") continue;
2484
+ if (typeof message.content === "string") continue;
2485
+ for (const part of message.content) {
2486
+ if (part.type === "tool-call") {
2487
+ const approval = part.approval;
2488
+ if ((approval == null ? void 0 : approval.approved) != null) {
2489
+ approvalToolCallIds.add(part.toolCallId);
2490
+ }
2491
+ }
2492
+ }
2493
+ }
2494
+ }
2480
2495
  if (compactionInput && compactionInput.length > 0) {
2481
2496
  input.push(...compactionInput);
2482
2497
  }
@@ -2571,17 +2586,18 @@ async function convertToOpenAIResponsesInput({
2571
2586
  }
2572
2587
  case "tool-call": {
2573
2588
  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;
2589
+ const toolHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
2574
2590
  if (part.providerExecuted) {
2575
- if (store && id != null && !containsApprovalResponses) {
2591
+ if (store && id != null && !toolHadApproval) {
2576
2592
  input.push({ type: "item_reference", id });
2577
2593
  }
2578
2594
  break;
2579
2595
  }
2580
- if (store && id != null && !containsApprovalResponses) {
2596
+ if (store && id != null && !toolHadApproval) {
2581
2597
  input.push({ type: "item_reference", id });
2582
2598
  break;
2583
2599
  }
2584
- if (store && id != null && containsApprovalResponses) {
2600
+ if (store && id != null && toolHadApproval) {
2585
2601
  break;
2586
2602
  }
2587
2603
  const resolvedToolName = toolNameMapping.toProviderToolName(