@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 +13 -0
- package/dist/index.js +7 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -60
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +6 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +6 -59
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2496,44 +2496,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2496
2496
|
const input = [];
|
|
2497
2497
|
const warnings = [];
|
|
2498
2498
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2499
|
-
const
|
|
2500
|
-
|
|
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
|
|
2536
|
-
);
|
|
2499
|
+
const skipItemReferences = (providerOptionsName && (store == null ? void 0 : store.skipItemReferencesForApproval)) === true;
|
|
2500
|
+
console.log("[OpenAI Provider] Skip item references flag:", skipItemReferences);
|
|
2537
2501
|
if (compactionInput && compactionInput.length > 0) {
|
|
2538
2502
|
input.push(...compactionInput);
|
|
2539
2503
|
}
|
|
@@ -2611,14 +2575,6 @@ async function convertToOpenAIResponsesInput({
|
|
|
2611
2575
|
}
|
|
2612
2576
|
case "assistant": {
|
|
2613
2577
|
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
2578
|
for (const part of content) {
|
|
2623
2579
|
switch (part.type) {
|
|
2624
2580
|
case "text": {
|
|
@@ -2636,32 +2592,23 @@ async function convertToOpenAIResponsesInput({
|
|
|
2636
2592
|
}
|
|
2637
2593
|
case "tool-call": {
|
|
2638
2594
|
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;
|
|
2646
2595
|
console.log("[OpenAI Provider] Processing tool-call:", {
|
|
2647
2596
|
toolCallId: part.toolCallId,
|
|
2648
2597
|
toolName: part.toolName,
|
|
2649
2598
|
id,
|
|
2650
2599
|
providerExecuted: part.providerExecuted,
|
|
2651
2600
|
store,
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
skipItemReference,
|
|
2655
|
-
willCreateItemReference: store && id != null && !skipItemReference
|
|
2601
|
+
skipItemReferences,
|
|
2602
|
+
willCreateItemReference: store && id != null && !skipItemReferences
|
|
2656
2603
|
});
|
|
2657
2604
|
if (part.providerExecuted) {
|
|
2658
|
-
if (store && id != null && !
|
|
2605
|
+
if (store && id != null && !skipItemReferences) {
|
|
2659
2606
|
console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
|
|
2660
2607
|
input.push({ type: "item_reference", id });
|
|
2661
2608
|
}
|
|
2662
2609
|
break;
|
|
2663
2610
|
}
|
|
2664
|
-
if (store && id != null && !
|
|
2611
|
+
if (store && id != null && !skipItemReferences) {
|
|
2665
2612
|
console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
|
|
2666
2613
|
input.push({ type: "item_reference", id });
|
|
2667
2614
|
break;
|