@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.
@@ -2475,44 +2475,8 @@ async function convertToOpenAIResponsesInput({
2475
2475
  const input = [];
2476
2476
  const warnings = [];
2477
2477
  const processedApprovalIds = /* @__PURE__ */ new Set();
2478
- const approvalIdToToolCallId = /* @__PURE__ */ new Map();
2479
- for (const message of prompt) {
2480
- if (message.role === "assistant") {
2481
- console.log("[OpenAI Provider] Assistant message content type:", typeof message.content, "isArray:", Array.isArray(message.content));
2482
- if (Array.isArray(message.content)) {
2483
- console.log("[OpenAI Provider] Assistant content parts:", message.content.map((p) => p.type));
2484
- const approvalRequests = message.content.filter(
2485
- (p) => p.type === "tool-approval-request"
2486
- );
2487
- console.log("[OpenAI Provider] Found approval requests:", approvalRequests.length);
2488
- for (const req of approvalRequests) {
2489
- approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
2490
- }
2491
- }
2492
- }
2493
- }
2494
- console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
2495
- const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
2496
- for (const message of prompt) {
2497
- if (message.role === "tool") {
2498
- for (const part of message.content) {
2499
- if (part.type === "tool-approval-response") {
2500
- const toolCallId = approvalIdToToolCallId.get(part.approvalId);
2501
- console.log("[OpenAI Provider] Found approval response:", {
2502
- approvalId: part.approvalId,
2503
- toolCallId
2504
- });
2505
- if (toolCallId) {
2506
- toolCallsWithApprovalResponses.add(toolCallId);
2507
- }
2508
- }
2509
- }
2510
- }
2511
- }
2512
- console.log(
2513
- "[OpenAI Provider] toolCallsWithApprovalResponses:",
2514
- toolCallsWithApprovalResponses
2515
- );
2478
+ const skipItemReferences = (providerOptionsName && (store == null ? void 0 : store.skipItemReferencesForApproval)) === true;
2479
+ console.log("[OpenAI Provider] Skip item references flag:", skipItemReferences);
2516
2480
  if (compactionInput && compactionInput.length > 0) {
2517
2481
  input.push(...compactionInput);
2518
2482
  }
@@ -2590,14 +2554,6 @@ async function convertToOpenAIResponsesInput({
2590
2554
  }
2591
2555
  case "assistant": {
2592
2556
  const reasoningMessages = {};
2593
- const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
2594
- if (Array.isArray(content)) {
2595
- for (const part of content) {
2596
- if (part.type === "tool-approval-request") {
2597
- toolCallsWithApprovalRequest.add(part.toolCallId);
2598
- }
2599
- }
2600
- }
2601
2557
  for (const part of content) {
2602
2558
  switch (part.type) {
2603
2559
  case "text": {
@@ -2615,32 +2571,23 @@ async function convertToOpenAIResponsesInput({
2615
2571
  }
2616
2572
  case "tool-call": {
2617
2573
  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;
2618
- const hasApprovalResponse = toolCallsWithApprovalResponses.has(
2619
- part.toolCallId
2620
- );
2621
- const hasApprovalRequest = toolCallsWithApprovalRequest.has(
2622
- part.toolCallId
2623
- );
2624
- const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
2625
2574
  console.log("[OpenAI Provider] Processing tool-call:", {
2626
2575
  toolCallId: part.toolCallId,
2627
2576
  toolName: part.toolName,
2628
2577
  id,
2629
2578
  providerExecuted: part.providerExecuted,
2630
2579
  store,
2631
- hasApprovalResponse,
2632
- hasApprovalRequest,
2633
- skipItemReference,
2634
- willCreateItemReference: store && id != null && !skipItemReference
2580
+ skipItemReferences,
2581
+ willCreateItemReference: store && id != null && !skipItemReferences
2635
2582
  });
2636
2583
  if (part.providerExecuted) {
2637
- if (store && id != null && !skipItemReference) {
2584
+ if (store && id != null && !skipItemReferences) {
2638
2585
  console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
2639
2586
  input.push({ type: "item_reference", id });
2640
2587
  }
2641
2588
  break;
2642
2589
  }
2643
- if (store && id != null && !skipItemReference) {
2590
+ if (store && id != null && !skipItemReferences) {
2644
2591
  console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
2645
2592
  input.push({ type: "item_reference", id });
2646
2593
  break;