@zenning/openai 3.0.12 → 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.
@@ -2496,44 +2496,10 @@ async function convertToOpenAIResponsesInput({
2496
2496
  const input = [];
2497
2497
  const warnings = [];
2498
2498
  const processedApprovalIds = /* @__PURE__ */ new Set();
2499
- const approvalIdToToolCallId = /* @__PURE__ */ new Map();
2500
- for (const message of prompt) {
2501
- if (message.role === "assistant") {
2502
- console.log("[OpenAI Provider] Assistant message content type:", typeof message.content, "isArray:", Array.isArray(message.content));
2503
- if (Array.isArray(message.content)) {
2504
- console.log("[OpenAI Provider] Assistant content parts:", message.content.map((p) => p.type));
2505
- const approvalRequests = message.content.filter(
2506
- (p) => p.type === "tool-approval-request"
2507
- );
2508
- console.log("[OpenAI Provider] Found approval requests:", approvalRequests.length);
2509
- for (const req of approvalRequests) {
2510
- approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
2511
- }
2512
- }
2513
- }
2514
- }
2515
- console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
2516
- const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
2517
- for (const message of prompt) {
2518
- if (message.role === "tool") {
2519
- for (const part of message.content) {
2520
- if (part.type === "tool-approval-response") {
2521
- const toolCallId = approvalIdToToolCallId.get(part.approvalId);
2522
- console.log("[OpenAI Provider] Found approval response:", {
2523
- approvalId: part.approvalId,
2524
- toolCallId
2525
- });
2526
- if (toolCallId) {
2527
- toolCallsWithApprovalResponses.add(toolCallId);
2528
- }
2529
- }
2530
- }
2531
- }
2532
- }
2533
- console.log(
2534
- "[OpenAI Provider] toolCallsWithApprovalResponses:",
2535
- toolCallsWithApprovalResponses
2499
+ const hasApprovalResponses = prompt.some(
2500
+ (message) => message.role === "tool" && message.content.some((part) => part.type === "tool-approval-response")
2536
2501
  );
2502
+ console.log("[OpenAI Provider] Approval continuation detected:", hasApprovalResponses);
2537
2503
  if (compactionInput && compactionInput.length > 0) {
2538
2504
  input.push(...compactionInput);
2539
2505
  }
@@ -2611,14 +2577,6 @@ async function convertToOpenAIResponsesInput({
2611
2577
  }
2612
2578
  case "assistant": {
2613
2579
  const reasoningMessages = {};
2614
- const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
2615
- if (Array.isArray(content)) {
2616
- for (const part of content) {
2617
- if (part.type === "tool-approval-request") {
2618
- toolCallsWithApprovalRequest.add(part.toolCallId);
2619
- }
2620
- }
2621
- }
2622
2580
  for (const part of content) {
2623
2581
  switch (part.type) {
2624
2582
  case "text": {
@@ -2636,21 +2594,14 @@ async function convertToOpenAIResponsesInput({
2636
2594
  }
2637
2595
  case "tool-call": {
2638
2596
  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;
2639
- const hasApprovalResponse = toolCallsWithApprovalResponses.has(
2640
- part.toolCallId
2641
- );
2642
- const hasApprovalRequest = toolCallsWithApprovalRequest.has(
2643
- part.toolCallId
2644
- );
2645
- const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
2597
+ const skipItemReference = hasApprovalResponses;
2646
2598
  console.log("[OpenAI Provider] Processing tool-call:", {
2647
2599
  toolCallId: part.toolCallId,
2648
2600
  toolName: part.toolName,
2649
2601
  id,
2650
2602
  providerExecuted: part.providerExecuted,
2651
2603
  store,
2652
- hasApprovalResponse,
2653
- hasApprovalRequest,
2604
+ hasApprovalResponses,
2654
2605
  skipItemReference,
2655
2606
  willCreateItemReference: store && id != null && !skipItemReference
2656
2607
  });