@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/internal/index.js
CHANGED
|
@@ -2471,12 +2471,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2471
2471
|
hasApplyPatchTool = false,
|
|
2472
2472
|
compactionInput,
|
|
2473
2473
|
previousResponseId,
|
|
2474
|
-
containsApprovalResponses
|
|
2474
|
+
containsApprovalResponses,
|
|
2475
|
+
approvalToolCallIds: approvalToolCallIdsArray
|
|
2475
2476
|
}) {
|
|
2476
2477
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2477
2478
|
const input = [];
|
|
2478
2479
|
const warnings = [];
|
|
2479
2480
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2481
|
+
const approvalToolCallIds = new Set(approvalToolCallIdsArray || []);
|
|
2480
2482
|
if (compactionInput && compactionInput.length > 0) {
|
|
2481
2483
|
input.push(...compactionInput);
|
|
2482
2484
|
}
|
|
@@ -2571,17 +2573,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
2571
2573
|
}
|
|
2572
2574
|
case "tool-call": {
|
|
2573
2575
|
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;
|
|
2576
|
+
const toolHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2574
2577
|
if (part.providerExecuted) {
|
|
2575
|
-
if (store && id != null && !
|
|
2578
|
+
if (store && id != null && !toolHadApproval) {
|
|
2576
2579
|
input.push({ type: "item_reference", id });
|
|
2577
2580
|
}
|
|
2578
2581
|
break;
|
|
2579
2582
|
}
|
|
2580
|
-
if (store && id != null && !
|
|
2583
|
+
if (store && id != null && !toolHadApproval) {
|
|
2581
2584
|
input.push({ type: "item_reference", id });
|
|
2582
2585
|
break;
|
|
2583
2586
|
}
|
|
2584
|
-
if (store && id != null &&
|
|
2587
|
+
if (store && id != null && toolHadApproval) {
|
|
2585
2588
|
break;
|
|
2586
2589
|
}
|
|
2587
2590
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
@@ -2639,10 +2642,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2639
2642
|
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") {
|
|
2640
2643
|
break;
|
|
2641
2644
|
}
|
|
2642
|
-
|
|
2645
|
+
const toolResultHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2646
|
+
if (store && !toolResultHadApproval) {
|
|
2643
2647
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2644
2648
|
input.push({ type: "item_reference", id: itemId });
|
|
2645
|
-
} else {
|
|
2649
|
+
} else if (!store) {
|
|
2646
2650
|
warnings.push({
|
|
2647
2651
|
type: "other",
|
|
2648
2652
|
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
@@ -3792,7 +3796,12 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils24.lazySchem
|
|
|
3792
3796
|
* Whether the request contains tool approval responses.
|
|
3793
3797
|
* Defaults to `false`.
|
|
3794
3798
|
*/
|
|
3795
|
-
containsApprovalResponses: import_v417.z.boolean().optional()
|
|
3799
|
+
containsApprovalResponses: import_v417.z.boolean().optional(),
|
|
3800
|
+
/**
|
|
3801
|
+
* Array of tool call IDs that have approval responses (approved or denied).
|
|
3802
|
+
* Used to skip item_reference for tools that had user approval flow.
|
|
3803
|
+
*/
|
|
3804
|
+
approvalToolCallIds: import_v417.z.array(import_v417.z.string()).optional()
|
|
3796
3805
|
})
|
|
3797
3806
|
)
|
|
3798
3807
|
);
|
|
@@ -4315,7 +4324,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4315
4324
|
toolChoice,
|
|
4316
4325
|
responseFormat
|
|
4317
4326
|
}) {
|
|
4318
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4327
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4319
4328
|
const warnings = [];
|
|
4320
4329
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4321
4330
|
if (topK != null) {
|
|
@@ -4380,10 +4389,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4380
4389
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4381
4390
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4382
4391
|
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
|
|
4383
|
-
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
|
|
4392
|
+
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false,
|
|
4393
|
+
approvalToolCallIds: (_f = openaiOptions == null ? void 0 : openaiOptions.approvalToolCallIds) != null ? _f : void 0
|
|
4384
4394
|
});
|
|
4385
4395
|
warnings.push(...inputWarnings);
|
|
4386
|
-
const strictJsonSchema = (
|
|
4396
|
+
const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
|
|
4387
4397
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4388
4398
|
function addInclude(key) {
|
|
4389
4399
|
if (include == null) {
|
|
@@ -4399,9 +4409,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4399
4409
|
if (topLogprobs) {
|
|
4400
4410
|
addInclude("message.output_text.logprobs");
|
|
4401
4411
|
}
|
|
4402
|
-
const webSearchToolName = (
|
|
4412
|
+
const webSearchToolName = (_h = tools == null ? void 0 : tools.find(
|
|
4403
4413
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4404
|
-
)) == null ? void 0 :
|
|
4414
|
+
)) == null ? void 0 : _h.name;
|
|
4405
4415
|
if (webSearchToolName) {
|
|
4406
4416
|
addInclude("web_search_call.action.sources");
|
|
4407
4417
|
}
|
|
@@ -4424,7 +4434,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4424
4434
|
format: responseFormat.schema != null ? {
|
|
4425
4435
|
type: "json_schema",
|
|
4426
4436
|
strict: strictJsonSchema,
|
|
4427
|
-
name: (
|
|
4437
|
+
name: (_i = responseFormat.name) != null ? _i : "response",
|
|
4428
4438
|
description: responseFormat.description,
|
|
4429
4439
|
schema: responseFormat.schema
|
|
4430
4440
|
} : { type: "json_object" }
|