@zenning/openai 3.0.17 → 3.0.19
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 +12 -0
- package/dist/index.js +32 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -34
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +31 -33
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +31 -33
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2547,14 +2547,12 @@ async function convertToOpenAIResponsesInput({
|
|
|
2547
2547
|
hasShellTool = false,
|
|
2548
2548
|
hasApplyPatchTool = false,
|
|
2549
2549
|
compactionInput,
|
|
2550
|
-
|
|
2550
|
+
previousResponseId
|
|
2551
2551
|
}) {
|
|
2552
2552
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2553
2553
|
const input = [];
|
|
2554
2554
|
const warnings = [];
|
|
2555
2555
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2556
|
-
const skipItemReferences = (providerOptions == null ? void 0 : providerOptions.skipItemReferencesForApproval) === true;
|
|
2557
|
-
console.log("[OpenAI Provider] Skip item references flag:", skipItemReferences, "providerOptions:", providerOptions);
|
|
2558
2556
|
if (compactionInput && compactionInput.length > 0) {
|
|
2559
2557
|
input.push(...compactionInput);
|
|
2560
2558
|
}
|
|
@@ -2636,10 +2634,13 @@ async function convertToOpenAIResponsesInput({
|
|
|
2636
2634
|
switch (part.type) {
|
|
2637
2635
|
case "text": {
|
|
2638
2636
|
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName]) == null ? void 0 : _b.itemId;
|
|
2639
|
-
if (store && id != null) {
|
|
2637
|
+
if (store && id != null && !previousResponseId) {
|
|
2640
2638
|
input.push({ type: "item_reference", id });
|
|
2641
2639
|
break;
|
|
2642
2640
|
}
|
|
2641
|
+
if (store && id != null && previousResponseId) {
|
|
2642
|
+
break;
|
|
2643
|
+
}
|
|
2643
2644
|
input.push({
|
|
2644
2645
|
role: "assistant",
|
|
2645
2646
|
content: [{ type: "output_text", text: part.text }],
|
|
@@ -2649,29 +2650,17 @@ async function convertToOpenAIResponsesInput({
|
|
|
2649
2650
|
}
|
|
2650
2651
|
case "tool-call": {
|
|
2651
2652
|
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;
|
|
2652
|
-
console.log("[OpenAI Provider] Processing tool-call:", {
|
|
2653
|
-
toolCallId: part.toolCallId,
|
|
2654
|
-
toolName: part.toolName,
|
|
2655
|
-
id,
|
|
2656
|
-
providerExecuted: part.providerExecuted,
|
|
2657
|
-
store,
|
|
2658
|
-
skipItemReferences,
|
|
2659
|
-
willCreateItemReference: store && id != null && !skipItemReferences
|
|
2660
|
-
});
|
|
2661
2653
|
if (part.providerExecuted) {
|
|
2662
|
-
if (store && id != null && !
|
|
2663
|
-
console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
|
|
2654
|
+
if (store && id != null && !previousResponseId) {
|
|
2664
2655
|
input.push({ type: "item_reference", id });
|
|
2665
2656
|
}
|
|
2666
2657
|
break;
|
|
2667
2658
|
}
|
|
2668
|
-
if (store && id != null && !
|
|
2669
|
-
console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
|
|
2659
|
+
if (store && id != null && !previousResponseId) {
|
|
2670
2660
|
input.push({ type: "item_reference", id });
|
|
2671
2661
|
break;
|
|
2672
2662
|
}
|
|
2673
|
-
if (
|
|
2674
|
-
console.log("[OpenAI Provider] Skipping function_call due to approval continuation flag");
|
|
2663
|
+
if (store && id != null && previousResponseId) {
|
|
2675
2664
|
break;
|
|
2676
2665
|
}
|
|
2677
2666
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
@@ -2729,9 +2718,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2729
2718
|
if (part.output.type === "execution-denied" || part.output.type === "json" && typeof part.output.value === "object" && part.output.value != null && "type" in part.output.value && part.output.value.type === "execution-denied") {
|
|
2730
2719
|
break;
|
|
2731
2720
|
}
|
|
2732
|
-
if (store) {
|
|
2721
|
+
if (store && !previousResponseId) {
|
|
2733
2722
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2734
2723
|
input.push({ type: "item_reference", id: itemId });
|
|
2724
|
+
} else if (store) {
|
|
2735
2725
|
} else {
|
|
2736
2726
|
warnings.push({
|
|
2737
2727
|
type: "other",
|
|
@@ -2741,15 +2731,15 @@ async function convertToOpenAIResponsesInput({
|
|
|
2741
2731
|
break;
|
|
2742
2732
|
}
|
|
2743
2733
|
case "reasoning": {
|
|
2744
|
-
const
|
|
2734
|
+
const providerOptions = await parseProviderOptions4({
|
|
2745
2735
|
provider: providerOptionsName,
|
|
2746
2736
|
providerOptions: part.providerOptions,
|
|
2747
2737
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
2748
2738
|
});
|
|
2749
|
-
const reasoningId =
|
|
2739
|
+
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2750
2740
|
if (reasoningId != null) {
|
|
2751
2741
|
const reasoningMessage = reasoningMessages[reasoningId];
|
|
2752
|
-
if (store) {
|
|
2742
|
+
if (store && !previousResponseId) {
|
|
2753
2743
|
if (reasoningMessage === void 0) {
|
|
2754
2744
|
input.push({ type: "item_reference", id: reasoningId });
|
|
2755
2745
|
reasoningMessages[reasoningId] = {
|
|
@@ -2758,6 +2748,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2758
2748
|
summary: []
|
|
2759
2749
|
};
|
|
2760
2750
|
}
|
|
2751
|
+
} else if (store) {
|
|
2752
|
+
if (reasoningMessage === void 0) {
|
|
2753
|
+
reasoningMessages[reasoningId] = {
|
|
2754
|
+
type: "reasoning",
|
|
2755
|
+
id: reasoningId,
|
|
2756
|
+
summary: []
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2761
2759
|
} else {
|
|
2762
2760
|
const summaryParts = [];
|
|
2763
2761
|
if (part.text.length > 0) {
|
|
@@ -2775,14 +2773,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2775
2773
|
reasoningMessages[reasoningId] = {
|
|
2776
2774
|
type: "reasoning",
|
|
2777
2775
|
id: reasoningId,
|
|
2778
|
-
encrypted_content:
|
|
2776
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2779
2777
|
summary: summaryParts
|
|
2780
2778
|
};
|
|
2781
2779
|
input.push(reasoningMessages[reasoningId]);
|
|
2782
2780
|
} else {
|
|
2783
2781
|
reasoningMessage.summary.push(...summaryParts);
|
|
2784
|
-
if ((
|
|
2785
|
-
reasoningMessage.encrypted_content =
|
|
2782
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2783
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2786
2784
|
}
|
|
2787
2785
|
}
|
|
2788
2786
|
}
|
|
@@ -2806,7 +2804,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2806
2804
|
continue;
|
|
2807
2805
|
}
|
|
2808
2806
|
processedApprovalIds.add(approvalResponse.approvalId);
|
|
2809
|
-
if (store) {
|
|
2807
|
+
if (store && !previousResponseId) {
|
|
2810
2808
|
input.push({
|
|
2811
2809
|
type: "item_reference",
|
|
2812
2810
|
id: approvalResponse.approvalId
|
|
@@ -4110,7 +4108,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4110
4108
|
toolChoice,
|
|
4111
4109
|
responseFormat
|
|
4112
4110
|
}) {
|
|
4113
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4111
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4114
4112
|
const warnings = [];
|
|
4115
4113
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4116
4114
|
if (topK != null) {
|
|
@@ -4174,10 +4172,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4174
4172
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
4175
4173
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4176
4174
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4177
|
-
|
|
4175
|
+
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0
|
|
4178
4176
|
});
|
|
4179
4177
|
warnings.push(...inputWarnings);
|
|
4180
|
-
const strictJsonSchema = (
|
|
4178
|
+
const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
4181
4179
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4182
4180
|
function addInclude(key) {
|
|
4183
4181
|
if (include == null) {
|
|
@@ -4193,9 +4191,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4193
4191
|
if (topLogprobs) {
|
|
4194
4192
|
addInclude("message.output_text.logprobs");
|
|
4195
4193
|
}
|
|
4196
|
-
const webSearchToolName = (
|
|
4194
|
+
const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
|
|
4197
4195
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4198
|
-
)) == null ? void 0 :
|
|
4196
|
+
)) == null ? void 0 : _f.name;
|
|
4199
4197
|
if (webSearchToolName) {
|
|
4200
4198
|
addInclude("web_search_call.action.sources");
|
|
4201
4199
|
}
|
|
@@ -4218,7 +4216,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4218
4216
|
format: responseFormat.schema != null ? {
|
|
4219
4217
|
type: "json_schema",
|
|
4220
4218
|
strict: strictJsonSchema,
|
|
4221
|
-
name: (
|
|
4219
|
+
name: (_g = responseFormat.name) != null ? _g : "response",
|
|
4222
4220
|
description: responseFormat.description,
|
|
4223
4221
|
schema: responseFormat.schema
|
|
4224
4222
|
} : { type: "json_object" }
|
|
@@ -5872,7 +5870,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5872
5870
|
};
|
|
5873
5871
|
|
|
5874
5872
|
// src/version.ts
|
|
5875
|
-
var VERSION = true ? "3.0.
|
|
5873
|
+
var VERSION = true ? "3.0.19" : "0.0.0-test";
|
|
5876
5874
|
|
|
5877
5875
|
// src/openai-provider.ts
|
|
5878
5876
|
function createOpenAI(options = {}) {
|