@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.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +21 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +21 -2
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.js
CHANGED
|
@@ -2477,6 +2477,21 @@ async function convertToOpenAIResponsesInput({
|
|
|
2477
2477
|
const input = [];
|
|
2478
2478
|
const warnings = [];
|
|
2479
2479
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2480
|
+
const approvalToolCallIds = /* @__PURE__ */ new Set();
|
|
2481
|
+
if (containsApprovalResponses) {
|
|
2482
|
+
for (const message of prompt) {
|
|
2483
|
+
if (message.role !== "assistant") continue;
|
|
2484
|
+
if (typeof message.content === "string") continue;
|
|
2485
|
+
for (const part of message.content) {
|
|
2486
|
+
if (part.type === "tool-call") {
|
|
2487
|
+
const approval = part.approval;
|
|
2488
|
+
if ((approval == null ? void 0 : approval.approved) != null) {
|
|
2489
|
+
approvalToolCallIds.add(part.toolCallId);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2480
2495
|
if (compactionInput && compactionInput.length > 0) {
|
|
2481
2496
|
input.push(...compactionInput);
|
|
2482
2497
|
}
|
|
@@ -2571,16 +2586,20 @@ async function convertToOpenAIResponsesInput({
|
|
|
2571
2586
|
}
|
|
2572
2587
|
case "tool-call": {
|
|
2573
2588
|
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;
|
|
2589
|
+
const toolHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2574
2590
|
if (part.providerExecuted) {
|
|
2575
|
-
if (store && id != null) {
|
|
2591
|
+
if (store && id != null && !toolHadApproval) {
|
|
2576
2592
|
input.push({ type: "item_reference", id });
|
|
2577
2593
|
}
|
|
2578
2594
|
break;
|
|
2579
2595
|
}
|
|
2580
|
-
if (store && id != null) {
|
|
2596
|
+
if (store && id != null && !toolHadApproval) {
|
|
2581
2597
|
input.push({ type: "item_reference", id });
|
|
2582
2598
|
break;
|
|
2583
2599
|
}
|
|
2600
|
+
if (store && id != null && toolHadApproval) {
|
|
2601
|
+
break;
|
|
2602
|
+
}
|
|
2584
2603
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
2585
2604
|
part.toolName
|
|
2586
2605
|
);
|