@zenning/openai 3.0.20 → 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.
@@ -2498,6 +2498,21 @@ async function convertToOpenAIResponsesInput({
2498
2498
  const input = [];
2499
2499
  const warnings = [];
2500
2500
  const processedApprovalIds = /* @__PURE__ */ new Set();
2501
+ const approvalToolCallIds = /* @__PURE__ */ new Set();
2502
+ if (containsApprovalResponses) {
2503
+ for (const message of prompt) {
2504
+ if (message.role !== "assistant") continue;
2505
+ if (typeof message.content === "string") continue;
2506
+ for (const part of message.content) {
2507
+ if (part.type === "tool-call") {
2508
+ const approval = part.approval;
2509
+ if ((approval == null ? void 0 : approval.approved) != null) {
2510
+ approvalToolCallIds.add(part.toolCallId);
2511
+ }
2512
+ }
2513
+ }
2514
+ }
2515
+ }
2501
2516
  if (compactionInput && compactionInput.length > 0) {
2502
2517
  input.push(...compactionInput);
2503
2518
  }
@@ -2592,16 +2607,20 @@ async function convertToOpenAIResponsesInput({
2592
2607
  }
2593
2608
  case "tool-call": {
2594
2609
  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;
2610
+ const toolHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
2595
2611
  if (part.providerExecuted) {
2596
- if (store && id != null) {
2612
+ if (store && id != null && !toolHadApproval) {
2597
2613
  input.push({ type: "item_reference", id });
2598
2614
  }
2599
2615
  break;
2600
2616
  }
2601
- if (store && id != null) {
2617
+ if (store && id != null && !toolHadApproval) {
2602
2618
  input.push({ type: "item_reference", id });
2603
2619
  break;
2604
2620
  }
2621
+ if (store && id != null && toolHadApproval) {
2622
+ break;
2623
+ }
2605
2624
  const resolvedToolName = toolNameMapping.toProviderToolName(
2606
2625
  part.toolName
2607
2626
  );