@zenning/openai 3.0.8 → 3.0.11
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 +19 -0
- package/dist/index.js +64 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +63 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +63 -2
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2552,6 +2552,39 @@ async function convertToOpenAIResponsesInput({
|
|
|
2552
2552
|
const input = [];
|
|
2553
2553
|
const warnings = [];
|
|
2554
2554
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2555
|
+
const approvalIdToToolCallId = /* @__PURE__ */ new Map();
|
|
2556
|
+
for (const message of prompt) {
|
|
2557
|
+
if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
2558
|
+
const approvalRequests = message.content.filter(
|
|
2559
|
+
(p) => p.type === "tool-approval-request"
|
|
2560
|
+
);
|
|
2561
|
+
for (const req of approvalRequests) {
|
|
2562
|
+
approvalIdToToolCallId.set(req.approvalId, req.toolCallId);
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
console.log("[OpenAI Provider] approvalIdToToolCallId:", approvalIdToToolCallId);
|
|
2567
|
+
const toolCallsWithApprovalResponses = /* @__PURE__ */ new Set();
|
|
2568
|
+
for (const message of prompt) {
|
|
2569
|
+
if (message.role === "tool") {
|
|
2570
|
+
for (const part of message.content) {
|
|
2571
|
+
if (part.type === "tool-approval-response") {
|
|
2572
|
+
const toolCallId = approvalIdToToolCallId.get(part.approvalId);
|
|
2573
|
+
console.log("[OpenAI Provider] Found approval response:", {
|
|
2574
|
+
approvalId: part.approvalId,
|
|
2575
|
+
toolCallId
|
|
2576
|
+
});
|
|
2577
|
+
if (toolCallId) {
|
|
2578
|
+
toolCallsWithApprovalResponses.add(toolCallId);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
console.log(
|
|
2585
|
+
"[OpenAI Provider] toolCallsWithApprovalResponses:",
|
|
2586
|
+
toolCallsWithApprovalResponses
|
|
2587
|
+
);
|
|
2555
2588
|
if (compactionInput && compactionInput.length > 0) {
|
|
2556
2589
|
input.push(...compactionInput);
|
|
2557
2590
|
}
|
|
@@ -2629,6 +2662,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2629
2662
|
}
|
|
2630
2663
|
case "assistant": {
|
|
2631
2664
|
const reasoningMessages = {};
|
|
2665
|
+
const toolCallsWithApprovalRequest = /* @__PURE__ */ new Set();
|
|
2666
|
+
if (Array.isArray(content)) {
|
|
2667
|
+
for (const part of content) {
|
|
2668
|
+
if (part.type === "tool-approval-request") {
|
|
2669
|
+
toolCallsWithApprovalRequest.add(part.toolCallId);
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2632
2673
|
for (const part of content) {
|
|
2633
2674
|
switch (part.type) {
|
|
2634
2675
|
case "text": {
|
|
@@ -2646,13 +2687,33 @@ async function convertToOpenAIResponsesInput({
|
|
|
2646
2687
|
}
|
|
2647
2688
|
case "tool-call": {
|
|
2648
2689
|
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;
|
|
2690
|
+
const hasApprovalResponse = toolCallsWithApprovalResponses.has(
|
|
2691
|
+
part.toolCallId
|
|
2692
|
+
);
|
|
2693
|
+
const hasApprovalRequest = toolCallsWithApprovalRequest.has(
|
|
2694
|
+
part.toolCallId
|
|
2695
|
+
);
|
|
2696
|
+
const skipItemReference = hasApprovalResponse || hasApprovalRequest && toolCallsWithApprovalResponses.size > 0;
|
|
2697
|
+
console.log("[OpenAI Provider] Processing tool-call:", {
|
|
2698
|
+
toolCallId: part.toolCallId,
|
|
2699
|
+
toolName: part.toolName,
|
|
2700
|
+
id,
|
|
2701
|
+
providerExecuted: part.providerExecuted,
|
|
2702
|
+
store,
|
|
2703
|
+
hasApprovalResponse,
|
|
2704
|
+
hasApprovalRequest,
|
|
2705
|
+
skipItemReference,
|
|
2706
|
+
willCreateItemReference: store && id != null && !skipItemReference
|
|
2707
|
+
});
|
|
2649
2708
|
if (part.providerExecuted) {
|
|
2650
|
-
if (store && id != null) {
|
|
2709
|
+
if (store && id != null && !skipItemReference) {
|
|
2710
|
+
console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
|
|
2651
2711
|
input.push({ type: "item_reference", id });
|
|
2652
2712
|
}
|
|
2653
2713
|
break;
|
|
2654
2714
|
}
|
|
2655
|
-
if (store && id != null) {
|
|
2715
|
+
if (store && id != null && !skipItemReference) {
|
|
2716
|
+
console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
|
|
2656
2717
|
input.push({ type: "item_reference", id });
|
|
2657
2718
|
break;
|
|
2658
2719
|
}
|
|
@@ -5853,7 +5914,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5853
5914
|
};
|
|
5854
5915
|
|
|
5855
5916
|
// src/version.ts
|
|
5856
|
-
var VERSION = true ? "3.0.
|
|
5917
|
+
var VERSION = true ? "3.0.10" : "0.0.0-test";
|
|
5857
5918
|
|
|
5858
5919
|
// src/openai-provider.ts
|
|
5859
5920
|
function createOpenAI(options = {}) {
|