@zenning/openai 3.0.21 → 3.0.23
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +24 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +23 -13
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +23 -13
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2548,12 +2548,14 @@ 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();
|
|
2558
|
+
const approvalToolCallIds = new Set(approvalToolCallIdsArray || []);
|
|
2557
2559
|
if (compactionInput && compactionInput.length > 0) {
|
|
2558
2560
|
input.push(...compactionInput);
|
|
2559
2561
|
}
|
|
@@ -2648,17 +2650,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
2648
2650
|
}
|
|
2649
2651
|
case "tool-call": {
|
|
2650
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;
|
|
2653
|
+
const toolHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2651
2654
|
if (part.providerExecuted) {
|
|
2652
|
-
if (store && id != null && !
|
|
2655
|
+
if (store && id != null && !toolHadApproval) {
|
|
2653
2656
|
input.push({ type: "item_reference", id });
|
|
2654
2657
|
}
|
|
2655
2658
|
break;
|
|
2656
2659
|
}
|
|
2657
|
-
if (store && id != null && !
|
|
2660
|
+
if (store && id != null && !toolHadApproval) {
|
|
2658
2661
|
input.push({ type: "item_reference", id });
|
|
2659
2662
|
break;
|
|
2660
2663
|
}
|
|
2661
|
-
if (store && id != null &&
|
|
2664
|
+
if (store && id != null && toolHadApproval) {
|
|
2662
2665
|
break;
|
|
2663
2666
|
}
|
|
2664
2667
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
@@ -2716,10 +2719,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2716
2719
|
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") {
|
|
2717
2720
|
break;
|
|
2718
2721
|
}
|
|
2719
|
-
|
|
2722
|
+
const toolResultHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2723
|
+
if (store && !toolResultHadApproval) {
|
|
2720
2724
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2721
2725
|
input.push({ type: "item_reference", id: itemId });
|
|
2722
|
-
} else {
|
|
2726
|
+
} else if (!store) {
|
|
2723
2727
|
warnings.push({
|
|
2724
2728
|
type: "other",
|
|
2725
2729
|
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
@@ -3869,7 +3873,12 @@ var openaiResponsesProviderOptionsSchema = lazySchema18(
|
|
|
3869
3873
|
* Whether the request contains tool approval responses.
|
|
3870
3874
|
* Defaults to `false`.
|
|
3871
3875
|
*/
|
|
3872
|
-
containsApprovalResponses: z20.boolean().optional()
|
|
3876
|
+
containsApprovalResponses: z20.boolean().optional(),
|
|
3877
|
+
/**
|
|
3878
|
+
* Array of tool call IDs that have approval responses (approved or denied).
|
|
3879
|
+
* Used to skip item_reference for tools that had user approval flow.
|
|
3880
|
+
*/
|
|
3881
|
+
approvalToolCallIds: z20.array(z20.string()).optional()
|
|
3873
3882
|
})
|
|
3874
3883
|
)
|
|
3875
3884
|
);
|
|
@@ -4102,7 +4111,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4102
4111
|
toolChoice,
|
|
4103
4112
|
responseFormat
|
|
4104
4113
|
}) {
|
|
4105
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4106
4115
|
const warnings = [];
|
|
4107
4116
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4108
4117
|
if (topK != null) {
|
|
@@ -4167,10 +4176,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4167
4176
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4168
4177
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4169
4178
|
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
|
|
4170
|
-
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
|
|
4179
|
+
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false,
|
|
4180
|
+
approvalToolCallIds: (_f = openaiOptions == null ? void 0 : openaiOptions.approvalToolCallIds) != null ? _f : void 0
|
|
4171
4181
|
});
|
|
4172
4182
|
warnings.push(...inputWarnings);
|
|
4173
|
-
const strictJsonSchema = (
|
|
4183
|
+
const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
|
|
4174
4184
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4175
4185
|
function addInclude(key) {
|
|
4176
4186
|
if (include == null) {
|
|
@@ -4186,9 +4196,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4186
4196
|
if (topLogprobs) {
|
|
4187
4197
|
addInclude("message.output_text.logprobs");
|
|
4188
4198
|
}
|
|
4189
|
-
const webSearchToolName = (
|
|
4199
|
+
const webSearchToolName = (_h = tools == null ? void 0 : tools.find(
|
|
4190
4200
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4191
|
-
)) == null ? void 0 :
|
|
4201
|
+
)) == null ? void 0 : _h.name;
|
|
4192
4202
|
if (webSearchToolName) {
|
|
4193
4203
|
addInclude("web_search_call.action.sources");
|
|
4194
4204
|
}
|
|
@@ -4211,7 +4221,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4211
4221
|
format: responseFormat.schema != null ? {
|
|
4212
4222
|
type: "json_schema",
|
|
4213
4223
|
strict: strictJsonSchema,
|
|
4214
|
-
name: (
|
|
4224
|
+
name: (_i = responseFormat.name) != null ? _i : "response",
|
|
4215
4225
|
description: responseFormat.description,
|
|
4216
4226
|
schema: responseFormat.schema
|
|
4217
4227
|
} : { type: "json_object" }
|
|
@@ -5865,7 +5875,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5865
5875
|
};
|
|
5866
5876
|
|
|
5867
5877
|
// src/version.ts
|
|
5868
|
-
var VERSION = true ? "3.0.
|
|
5878
|
+
var VERSION = true ? "3.0.23" : "0.0.0-test";
|
|
5869
5879
|
|
|
5870
5880
|
// src/openai-provider.ts
|
|
5871
5881
|
function createOpenAI(options = {}) {
|