@zenning/openai 3.0.16 → 3.0.18
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 +28 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -36
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +27 -35
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +27 -35
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -2470,14 +2470,12 @@ async function convertToOpenAIResponsesInput({
|
|
|
2470
2470
|
hasShellTool = false,
|
|
2471
2471
|
hasApplyPatchTool = false,
|
|
2472
2472
|
compactionInput,
|
|
2473
|
-
|
|
2473
|
+
previousResponseId
|
|
2474
2474
|
}) {
|
|
2475
2475
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2476
2476
|
const input = [];
|
|
2477
2477
|
const warnings = [];
|
|
2478
2478
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2479
|
-
const skipItemReferences = (providerOptions == null ? void 0 : providerOptions.skipItemReferencesForApproval) === true;
|
|
2480
|
-
console.log("[OpenAI Provider] Skip item references flag:", skipItemReferences);
|
|
2481
2479
|
if (compactionInput && compactionInput.length > 0) {
|
|
2482
2480
|
input.push(...compactionInput);
|
|
2483
2481
|
}
|
|
@@ -2559,7 +2557,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2559
2557
|
switch (part.type) {
|
|
2560
2558
|
case "text": {
|
|
2561
2559
|
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName]) == null ? void 0 : _b.itemId;
|
|
2562
|
-
if (store && id != null) {
|
|
2560
|
+
if (store && id != null && !previousResponseId) {
|
|
2563
2561
|
input.push({ type: "item_reference", id });
|
|
2564
2562
|
break;
|
|
2565
2563
|
}
|
|
@@ -2572,31 +2570,16 @@ async function convertToOpenAIResponsesInput({
|
|
|
2572
2570
|
}
|
|
2573
2571
|
case "tool-call": {
|
|
2574
2572
|
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;
|
|
2575
|
-
console.log("[OpenAI Provider] Processing tool-call:", {
|
|
2576
|
-
toolCallId: part.toolCallId,
|
|
2577
|
-
toolName: part.toolName,
|
|
2578
|
-
id,
|
|
2579
|
-
providerExecuted: part.providerExecuted,
|
|
2580
|
-
store,
|
|
2581
|
-
skipItemReferences,
|
|
2582
|
-
willCreateItemReference: store && id != null && !skipItemReferences
|
|
2583
|
-
});
|
|
2584
2573
|
if (part.providerExecuted) {
|
|
2585
|
-
if (store && id != null && !
|
|
2586
|
-
console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
|
|
2574
|
+
if (store && id != null && !previousResponseId) {
|
|
2587
2575
|
input.push({ type: "item_reference", id });
|
|
2588
2576
|
}
|
|
2589
2577
|
break;
|
|
2590
2578
|
}
|
|
2591
|
-
if (store && id != null && !
|
|
2592
|
-
console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
|
|
2579
|
+
if (store && id != null && !previousResponseId) {
|
|
2593
2580
|
input.push({ type: "item_reference", id });
|
|
2594
2581
|
break;
|
|
2595
2582
|
}
|
|
2596
|
-
if (skipItemReferences) {
|
|
2597
|
-
console.log("[OpenAI Provider] Skipping function_call due to approval continuation flag");
|
|
2598
|
-
break;
|
|
2599
|
-
}
|
|
2600
2583
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
2601
2584
|
part.toolName
|
|
2602
2585
|
);
|
|
@@ -2652,9 +2635,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2652
2635
|
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") {
|
|
2653
2636
|
break;
|
|
2654
2637
|
}
|
|
2655
|
-
if (store) {
|
|
2638
|
+
if (store && !previousResponseId) {
|
|
2656
2639
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2657
2640
|
input.push({ type: "item_reference", id: itemId });
|
|
2641
|
+
} else if (store) {
|
|
2658
2642
|
} else {
|
|
2659
2643
|
warnings.push({
|
|
2660
2644
|
type: "other",
|
|
@@ -2664,15 +2648,15 @@ async function convertToOpenAIResponsesInput({
|
|
|
2664
2648
|
break;
|
|
2665
2649
|
}
|
|
2666
2650
|
case "reasoning": {
|
|
2667
|
-
const
|
|
2651
|
+
const providerOptions = await (0, import_provider_utils22.parseProviderOptions)({
|
|
2668
2652
|
provider: providerOptionsName,
|
|
2669
2653
|
providerOptions: part.providerOptions,
|
|
2670
2654
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
2671
2655
|
});
|
|
2672
|
-
const reasoningId =
|
|
2656
|
+
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2673
2657
|
if (reasoningId != null) {
|
|
2674
2658
|
const reasoningMessage = reasoningMessages[reasoningId];
|
|
2675
|
-
if (store) {
|
|
2659
|
+
if (store && !previousResponseId) {
|
|
2676
2660
|
if (reasoningMessage === void 0) {
|
|
2677
2661
|
input.push({ type: "item_reference", id: reasoningId });
|
|
2678
2662
|
reasoningMessages[reasoningId] = {
|
|
@@ -2681,6 +2665,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2681
2665
|
summary: []
|
|
2682
2666
|
};
|
|
2683
2667
|
}
|
|
2668
|
+
} else if (store) {
|
|
2669
|
+
if (reasoningMessage === void 0) {
|
|
2670
|
+
reasoningMessages[reasoningId] = {
|
|
2671
|
+
type: "reasoning",
|
|
2672
|
+
id: reasoningId,
|
|
2673
|
+
summary: []
|
|
2674
|
+
};
|
|
2675
|
+
}
|
|
2684
2676
|
} else {
|
|
2685
2677
|
const summaryParts = [];
|
|
2686
2678
|
if (part.text.length > 0) {
|
|
@@ -2698,14 +2690,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2698
2690
|
reasoningMessages[reasoningId] = {
|
|
2699
2691
|
type: "reasoning",
|
|
2700
2692
|
id: reasoningId,
|
|
2701
|
-
encrypted_content:
|
|
2693
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2702
2694
|
summary: summaryParts
|
|
2703
2695
|
};
|
|
2704
2696
|
input.push(reasoningMessages[reasoningId]);
|
|
2705
2697
|
} else {
|
|
2706
2698
|
reasoningMessage.summary.push(...summaryParts);
|
|
2707
|
-
if ((
|
|
2708
|
-
reasoningMessage.encrypted_content =
|
|
2699
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2700
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2709
2701
|
}
|
|
2710
2702
|
}
|
|
2711
2703
|
}
|
|
@@ -2729,7 +2721,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2729
2721
|
continue;
|
|
2730
2722
|
}
|
|
2731
2723
|
processedApprovalIds.add(approvalResponse.approvalId);
|
|
2732
|
-
if (store) {
|
|
2724
|
+
if (store && !previousResponseId) {
|
|
2733
2725
|
input.push({
|
|
2734
2726
|
type: "item_reference",
|
|
2735
2727
|
id: approvalResponse.approvalId
|
|
@@ -4323,7 +4315,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4323
4315
|
toolChoice,
|
|
4324
4316
|
responseFormat
|
|
4325
4317
|
}) {
|
|
4326
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4318
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4327
4319
|
const warnings = [];
|
|
4328
4320
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4329
4321
|
if (topK != null) {
|
|
@@ -4387,10 +4379,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4387
4379
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
4388
4380
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4389
4381
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4390
|
-
|
|
4382
|
+
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0
|
|
4391
4383
|
});
|
|
4392
4384
|
warnings.push(...inputWarnings);
|
|
4393
|
-
const strictJsonSchema = (
|
|
4385
|
+
const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
4394
4386
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4395
4387
|
function addInclude(key) {
|
|
4396
4388
|
if (include == null) {
|
|
@@ -4406,9 +4398,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4406
4398
|
if (topLogprobs) {
|
|
4407
4399
|
addInclude("message.output_text.logprobs");
|
|
4408
4400
|
}
|
|
4409
|
-
const webSearchToolName = (
|
|
4401
|
+
const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
|
|
4410
4402
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4411
|
-
)) == null ? void 0 :
|
|
4403
|
+
)) == null ? void 0 : _f.name;
|
|
4412
4404
|
if (webSearchToolName) {
|
|
4413
4405
|
addInclude("web_search_call.action.sources");
|
|
4414
4406
|
}
|
|
@@ -4431,7 +4423,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4431
4423
|
format: responseFormat.schema != null ? {
|
|
4432
4424
|
type: "json_schema",
|
|
4433
4425
|
strict: strictJsonSchema,
|
|
4434
|
-
name: (
|
|
4426
|
+
name: (_g = responseFormat.name) != null ? _g : "response",
|
|
4435
4427
|
description: responseFormat.description,
|
|
4436
4428
|
schema: responseFormat.schema
|
|
4437
4429
|
} : { type: "json_object" }
|