@zenning/openai 3.0.22 → 3.0.24
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +38 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -26
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +37 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +37 -25
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -462,6 +462,7 @@ declare const openaiResponsesProviderOptionsSchema: _zenning_provider_utils.Lazy
|
|
|
462
462
|
encrypted_content: string;
|
|
463
463
|
}[] | undefined;
|
|
464
464
|
containsApprovalResponses?: boolean | undefined;
|
|
465
|
+
approvalToolCallIds?: string[] | undefined;
|
|
465
466
|
}>;
|
|
466
467
|
type OpenAIResponsesProviderOptions = InferSchema<typeof openaiResponsesProviderOptionsSchema>;
|
|
467
468
|
|
package/dist/index.d.ts
CHANGED
|
@@ -462,6 +462,7 @@ declare const openaiResponsesProviderOptionsSchema: _zenning_provider_utils.Lazy
|
|
|
462
462
|
encrypted_content: string;
|
|
463
463
|
}[] | undefined;
|
|
464
464
|
containsApprovalResponses?: boolean | undefined;
|
|
465
|
+
approvalToolCallIds?: string[] | undefined;
|
|
465
466
|
}>;
|
|
466
467
|
type OpenAIResponsesProviderOptions = InferSchema<typeof openaiResponsesProviderOptionsSchema>;
|
|
467
468
|
|
package/dist/index.js
CHANGED
|
@@ -2480,27 +2480,21 @@ async function convertToOpenAIResponsesInput({
|
|
|
2480
2480
|
hasApplyPatchTool = false,
|
|
2481
2481
|
compactionInput,
|
|
2482
2482
|
previousResponseId,
|
|
2483
|
-
containsApprovalResponses
|
|
2483
|
+
containsApprovalResponses,
|
|
2484
|
+
approvalToolCallIds: approvalToolCallIdsArray
|
|
2484
2485
|
}) {
|
|
2485
2486
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2486
2487
|
const input = [];
|
|
2487
2488
|
const warnings = [];
|
|
2488
2489
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2489
|
-
const approvalToolCallIds =
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
if ((approval == null ? void 0 : approval.approved) != null) {
|
|
2498
|
-
approvalToolCallIds.add(part.toolCallId);
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2490
|
+
const approvalToolCallIds = new Set(approvalToolCallIdsArray || []);
|
|
2491
|
+
console.log("CALDEBUG [convertToOpenAIResponsesInput] Starting conversion:", {
|
|
2492
|
+
containsApprovalResponses,
|
|
2493
|
+
approvalToolCallIdsCount: approvalToolCallIds.size,
|
|
2494
|
+
approvalToolCallIds: Array.from(approvalToolCallIds),
|
|
2495
|
+
previousResponseId,
|
|
2496
|
+
promptLength: prompt.length
|
|
2497
|
+
});
|
|
2504
2498
|
if (compactionInput && compactionInput.length > 0) {
|
|
2505
2499
|
input.push(...compactionInput);
|
|
2506
2500
|
}
|
|
@@ -2664,10 +2658,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2664
2658
|
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") {
|
|
2665
2659
|
break;
|
|
2666
2660
|
}
|
|
2667
|
-
|
|
2661
|
+
const toolResultHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2662
|
+
if (store && !toolResultHadApproval) {
|
|
2668
2663
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2669
2664
|
input.push({ type: "item_reference", id: itemId });
|
|
2670
|
-
} else {
|
|
2665
|
+
} else if (!store) {
|
|
2671
2666
|
warnings.push({
|
|
2672
2667
|
type: "other",
|
|
2673
2668
|
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
@@ -2734,6 +2729,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2734
2729
|
break;
|
|
2735
2730
|
}
|
|
2736
2731
|
case "tool": {
|
|
2732
|
+
console.log("CALDEBUG [convertToOpenAIResponsesInput] Processing tool role message:", {
|
|
2733
|
+
partsCount: content.length,
|
|
2734
|
+
partTypes: content.map((p) => p.type)
|
|
2735
|
+
});
|
|
2737
2736
|
for (const part of content) {
|
|
2738
2737
|
if (part.type === "tool-approval-response") {
|
|
2739
2738
|
const approvalResponse = part;
|
|
@@ -2757,6 +2756,13 @@ async function convertToOpenAIResponsesInput({
|
|
|
2757
2756
|
const output = part.output;
|
|
2758
2757
|
if (output.type === "execution-denied") {
|
|
2759
2758
|
const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
|
|
2759
|
+
console.log("CALDEBUG [convertToOpenAIResponsesInput] Found execution-denied:", {
|
|
2760
|
+
toolCallId: part.toolCallId,
|
|
2761
|
+
toolName: part.toolName,
|
|
2762
|
+
hasApprovalId: !!approvalId,
|
|
2763
|
+
approvalId,
|
|
2764
|
+
willSkip: !!approvalId
|
|
2765
|
+
});
|
|
2760
2766
|
if (approvalId) {
|
|
2761
2767
|
continue;
|
|
2762
2768
|
}
|
|
@@ -3817,7 +3823,12 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils25.lazySchem
|
|
|
3817
3823
|
* Whether the request contains tool approval responses.
|
|
3818
3824
|
* Defaults to `false`.
|
|
3819
3825
|
*/
|
|
3820
|
-
containsApprovalResponses: import_v420.z.boolean().optional()
|
|
3826
|
+
containsApprovalResponses: import_v420.z.boolean().optional(),
|
|
3827
|
+
/**
|
|
3828
|
+
* Array of tool call IDs that have approval responses (approved or denied).
|
|
3829
|
+
* Used to skip item_reference for tools that had user approval flow.
|
|
3830
|
+
*/
|
|
3831
|
+
approvalToolCallIds: import_v420.z.array(import_v420.z.string()).optional()
|
|
3821
3832
|
})
|
|
3822
3833
|
)
|
|
3823
3834
|
);
|
|
@@ -4048,7 +4059,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4048
4059
|
toolChoice,
|
|
4049
4060
|
responseFormat
|
|
4050
4061
|
}) {
|
|
4051
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4062
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4052
4063
|
const warnings = [];
|
|
4053
4064
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4054
4065
|
if (topK != null) {
|
|
@@ -4113,10 +4124,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4113
4124
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4114
4125
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4115
4126
|
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
|
|
4116
|
-
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
|
|
4127
|
+
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false,
|
|
4128
|
+
approvalToolCallIds: (_f = openaiOptions == null ? void 0 : openaiOptions.approvalToolCallIds) != null ? _f : void 0
|
|
4117
4129
|
});
|
|
4118
4130
|
warnings.push(...inputWarnings);
|
|
4119
|
-
const strictJsonSchema = (
|
|
4131
|
+
const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
|
|
4120
4132
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4121
4133
|
function addInclude(key) {
|
|
4122
4134
|
if (include == null) {
|
|
@@ -4132,9 +4144,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4132
4144
|
if (topLogprobs) {
|
|
4133
4145
|
addInclude("message.output_text.logprobs");
|
|
4134
4146
|
}
|
|
4135
|
-
const webSearchToolName = (
|
|
4147
|
+
const webSearchToolName = (_h = tools == null ? void 0 : tools.find(
|
|
4136
4148
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4137
|
-
)) == null ? void 0 :
|
|
4149
|
+
)) == null ? void 0 : _h.name;
|
|
4138
4150
|
if (webSearchToolName) {
|
|
4139
4151
|
addInclude("web_search_call.action.sources");
|
|
4140
4152
|
}
|
|
@@ -4157,7 +4169,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4157
4169
|
format: responseFormat.schema != null ? {
|
|
4158
4170
|
type: "json_schema",
|
|
4159
4171
|
strict: strictJsonSchema,
|
|
4160
|
-
name: (
|
|
4172
|
+
name: (_i = responseFormat.name) != null ? _i : "response",
|
|
4161
4173
|
description: responseFormat.description,
|
|
4162
4174
|
schema: responseFormat.schema
|
|
4163
4175
|
} : { type: "json_object" }
|
|
@@ -5799,7 +5811,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5799
5811
|
};
|
|
5800
5812
|
|
|
5801
5813
|
// src/version.ts
|
|
5802
|
-
var VERSION = true ? "3.0.
|
|
5814
|
+
var VERSION = true ? "3.0.24" : "0.0.0-test";
|
|
5803
5815
|
|
|
5804
5816
|
// src/openai-provider.ts
|
|
5805
5817
|
function createOpenAI(options = {}) {
|