@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/dist/index.mjs
CHANGED
|
@@ -2548,27 +2548,21 @@ async function convertToOpenAIResponsesInput({
|
|
|
2548
2548
|
hasApplyPatchTool = false,
|
|
2549
2549
|
compactionInput,
|
|
2550
2550
|
previousResponseId,
|
|
2551
|
-
containsApprovalResponses
|
|
2551
|
+
containsApprovalResponses,
|
|
2552
|
+
approvalToolCallIds: approvalToolCallIdsArray
|
|
2552
2553
|
}) {
|
|
2553
2554
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2554
2555
|
const input = [];
|
|
2555
2556
|
const warnings = [];
|
|
2556
2557
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2557
|
-
const approvalToolCallIds =
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
if ((approval == null ? void 0 : approval.approved) != null) {
|
|
2566
|
-
approvalToolCallIds.add(part.toolCallId);
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2558
|
+
const approvalToolCallIds = new Set(approvalToolCallIdsArray || []);
|
|
2559
|
+
console.log("CALDEBUG [convertToOpenAIResponsesInput] Starting conversion:", {
|
|
2560
|
+
containsApprovalResponses,
|
|
2561
|
+
approvalToolCallIdsCount: approvalToolCallIds.size,
|
|
2562
|
+
approvalToolCallIds: Array.from(approvalToolCallIds),
|
|
2563
|
+
previousResponseId,
|
|
2564
|
+
promptLength: prompt.length
|
|
2565
|
+
});
|
|
2572
2566
|
if (compactionInput && compactionInput.length > 0) {
|
|
2573
2567
|
input.push(...compactionInput);
|
|
2574
2568
|
}
|
|
@@ -2732,10 +2726,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2732
2726
|
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") {
|
|
2733
2727
|
break;
|
|
2734
2728
|
}
|
|
2735
|
-
|
|
2729
|
+
const toolResultHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2730
|
+
if (store && !toolResultHadApproval) {
|
|
2736
2731
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2737
2732
|
input.push({ type: "item_reference", id: itemId });
|
|
2738
|
-
} else {
|
|
2733
|
+
} else if (!store) {
|
|
2739
2734
|
warnings.push({
|
|
2740
2735
|
type: "other",
|
|
2741
2736
|
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
@@ -2802,6 +2797,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2802
2797
|
break;
|
|
2803
2798
|
}
|
|
2804
2799
|
case "tool": {
|
|
2800
|
+
console.log("CALDEBUG [convertToOpenAIResponsesInput] Processing tool role message:", {
|
|
2801
|
+
partsCount: content.length,
|
|
2802
|
+
partTypes: content.map((p) => p.type)
|
|
2803
|
+
});
|
|
2805
2804
|
for (const part of content) {
|
|
2806
2805
|
if (part.type === "tool-approval-response") {
|
|
2807
2806
|
const approvalResponse = part;
|
|
@@ -2825,6 +2824,13 @@ async function convertToOpenAIResponsesInput({
|
|
|
2825
2824
|
const output = part.output;
|
|
2826
2825
|
if (output.type === "execution-denied") {
|
|
2827
2826
|
const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
|
|
2827
|
+
console.log("CALDEBUG [convertToOpenAIResponsesInput] Found execution-denied:", {
|
|
2828
|
+
toolCallId: part.toolCallId,
|
|
2829
|
+
toolName: part.toolName,
|
|
2830
|
+
hasApprovalId: !!approvalId,
|
|
2831
|
+
approvalId,
|
|
2832
|
+
willSkip: !!approvalId
|
|
2833
|
+
});
|
|
2828
2834
|
if (approvalId) {
|
|
2829
2835
|
continue;
|
|
2830
2836
|
}
|
|
@@ -3885,7 +3891,12 @@ var openaiResponsesProviderOptionsSchema = lazySchema18(
|
|
|
3885
3891
|
* Whether the request contains tool approval responses.
|
|
3886
3892
|
* Defaults to `false`.
|
|
3887
3893
|
*/
|
|
3888
|
-
containsApprovalResponses: z20.boolean().optional()
|
|
3894
|
+
containsApprovalResponses: z20.boolean().optional(),
|
|
3895
|
+
/**
|
|
3896
|
+
* Array of tool call IDs that have approval responses (approved or denied).
|
|
3897
|
+
* Used to skip item_reference for tools that had user approval flow.
|
|
3898
|
+
*/
|
|
3899
|
+
approvalToolCallIds: z20.array(z20.string()).optional()
|
|
3889
3900
|
})
|
|
3890
3901
|
)
|
|
3891
3902
|
);
|
|
@@ -4118,7 +4129,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4118
4129
|
toolChoice,
|
|
4119
4130
|
responseFormat
|
|
4120
4131
|
}) {
|
|
4121
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4132
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4122
4133
|
const warnings = [];
|
|
4123
4134
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4124
4135
|
if (topK != null) {
|
|
@@ -4183,10 +4194,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4183
4194
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4184
4195
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4185
4196
|
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
|
|
4186
|
-
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
|
|
4197
|
+
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false,
|
|
4198
|
+
approvalToolCallIds: (_f = openaiOptions == null ? void 0 : openaiOptions.approvalToolCallIds) != null ? _f : void 0
|
|
4187
4199
|
});
|
|
4188
4200
|
warnings.push(...inputWarnings);
|
|
4189
|
-
const strictJsonSchema = (
|
|
4201
|
+
const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
|
|
4190
4202
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4191
4203
|
function addInclude(key) {
|
|
4192
4204
|
if (include == null) {
|
|
@@ -4202,9 +4214,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4202
4214
|
if (topLogprobs) {
|
|
4203
4215
|
addInclude("message.output_text.logprobs");
|
|
4204
4216
|
}
|
|
4205
|
-
const webSearchToolName = (
|
|
4217
|
+
const webSearchToolName = (_h = tools == null ? void 0 : tools.find(
|
|
4206
4218
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4207
|
-
)) == null ? void 0 :
|
|
4219
|
+
)) == null ? void 0 : _h.name;
|
|
4208
4220
|
if (webSearchToolName) {
|
|
4209
4221
|
addInclude("web_search_call.action.sources");
|
|
4210
4222
|
}
|
|
@@ -4227,7 +4239,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4227
4239
|
format: responseFormat.schema != null ? {
|
|
4228
4240
|
type: "json_schema",
|
|
4229
4241
|
strict: strictJsonSchema,
|
|
4230
|
-
name: (
|
|
4242
|
+
name: (_i = responseFormat.name) != null ? _i : "response",
|
|
4231
4243
|
description: responseFormat.description,
|
|
4232
4244
|
schema: responseFormat.schema
|
|
4233
4245
|
} : { type: "json_object" }
|
|
@@ -5881,7 +5893,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5881
5893
|
};
|
|
5882
5894
|
|
|
5883
5895
|
// src/version.ts
|
|
5884
|
-
var VERSION = true ? "3.0.
|
|
5896
|
+
var VERSION = true ? "3.0.24" : "0.0.0-test";
|
|
5885
5897
|
|
|
5886
5898
|
// src/openai-provider.ts
|
|
5887
5899
|
function createOpenAI(options = {}) {
|