@zenning/openai 3.0.17 → 3.0.19
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 +32 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -34
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +31 -33
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +31 -33
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
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, "providerOptions:", providerOptions);
|
|
2481
2479
|
if (compactionInput && compactionInput.length > 0) {
|
|
2482
2480
|
input.push(...compactionInput);
|
|
2483
2481
|
}
|
|
@@ -2559,10 +2557,13 @@ 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
|
}
|
|
2564
|
+
if (store && id != null && previousResponseId) {
|
|
2565
|
+
break;
|
|
2566
|
+
}
|
|
2566
2567
|
input.push({
|
|
2567
2568
|
role: "assistant",
|
|
2568
2569
|
content: [{ type: "output_text", text: part.text }],
|
|
@@ -2572,29 +2573,17 @@ async function convertToOpenAIResponsesInput({
|
|
|
2572
2573
|
}
|
|
2573
2574
|
case "tool-call": {
|
|
2574
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;
|
|
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
2576
|
if (part.providerExecuted) {
|
|
2585
|
-
if (store && id != null && !
|
|
2586
|
-
console.log("[OpenAI Provider] Creating item_reference (providerExecuted)");
|
|
2577
|
+
if (store && id != null && !previousResponseId) {
|
|
2587
2578
|
input.push({ type: "item_reference", id });
|
|
2588
2579
|
}
|
|
2589
2580
|
break;
|
|
2590
2581
|
}
|
|
2591
|
-
if (store && id != null && !
|
|
2592
|
-
console.log("[OpenAI Provider] Creating item_reference (non-providerExecuted)");
|
|
2582
|
+
if (store && id != null && !previousResponseId) {
|
|
2593
2583
|
input.push({ type: "item_reference", id });
|
|
2594
2584
|
break;
|
|
2595
2585
|
}
|
|
2596
|
-
if (
|
|
2597
|
-
console.log("[OpenAI Provider] Skipping function_call due to approval continuation flag");
|
|
2586
|
+
if (store && id != null && previousResponseId) {
|
|
2598
2587
|
break;
|
|
2599
2588
|
}
|
|
2600
2589
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
@@ -2652,9 +2641,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2652
2641
|
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
2642
|
break;
|
|
2654
2643
|
}
|
|
2655
|
-
if (store) {
|
|
2644
|
+
if (store && !previousResponseId) {
|
|
2656
2645
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2657
2646
|
input.push({ type: "item_reference", id: itemId });
|
|
2647
|
+
} else if (store) {
|
|
2658
2648
|
} else {
|
|
2659
2649
|
warnings.push({
|
|
2660
2650
|
type: "other",
|
|
@@ -2664,15 +2654,15 @@ async function convertToOpenAIResponsesInput({
|
|
|
2664
2654
|
break;
|
|
2665
2655
|
}
|
|
2666
2656
|
case "reasoning": {
|
|
2667
|
-
const
|
|
2657
|
+
const providerOptions = await (0, import_provider_utils22.parseProviderOptions)({
|
|
2668
2658
|
provider: providerOptionsName,
|
|
2669
2659
|
providerOptions: part.providerOptions,
|
|
2670
2660
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
2671
2661
|
});
|
|
2672
|
-
const reasoningId =
|
|
2662
|
+
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2673
2663
|
if (reasoningId != null) {
|
|
2674
2664
|
const reasoningMessage = reasoningMessages[reasoningId];
|
|
2675
|
-
if (store) {
|
|
2665
|
+
if (store && !previousResponseId) {
|
|
2676
2666
|
if (reasoningMessage === void 0) {
|
|
2677
2667
|
input.push({ type: "item_reference", id: reasoningId });
|
|
2678
2668
|
reasoningMessages[reasoningId] = {
|
|
@@ -2681,6 +2671,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2681
2671
|
summary: []
|
|
2682
2672
|
};
|
|
2683
2673
|
}
|
|
2674
|
+
} else if (store) {
|
|
2675
|
+
if (reasoningMessage === void 0) {
|
|
2676
|
+
reasoningMessages[reasoningId] = {
|
|
2677
|
+
type: "reasoning",
|
|
2678
|
+
id: reasoningId,
|
|
2679
|
+
summary: []
|
|
2680
|
+
};
|
|
2681
|
+
}
|
|
2684
2682
|
} else {
|
|
2685
2683
|
const summaryParts = [];
|
|
2686
2684
|
if (part.text.length > 0) {
|
|
@@ -2698,14 +2696,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2698
2696
|
reasoningMessages[reasoningId] = {
|
|
2699
2697
|
type: "reasoning",
|
|
2700
2698
|
id: reasoningId,
|
|
2701
|
-
encrypted_content:
|
|
2699
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2702
2700
|
summary: summaryParts
|
|
2703
2701
|
};
|
|
2704
2702
|
input.push(reasoningMessages[reasoningId]);
|
|
2705
2703
|
} else {
|
|
2706
2704
|
reasoningMessage.summary.push(...summaryParts);
|
|
2707
|
-
if ((
|
|
2708
|
-
reasoningMessage.encrypted_content =
|
|
2705
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2706
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2709
2707
|
}
|
|
2710
2708
|
}
|
|
2711
2709
|
}
|
|
@@ -2729,7 +2727,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2729
2727
|
continue;
|
|
2730
2728
|
}
|
|
2731
2729
|
processedApprovalIds.add(approvalResponse.approvalId);
|
|
2732
|
-
if (store) {
|
|
2730
|
+
if (store && !previousResponseId) {
|
|
2733
2731
|
input.push({
|
|
2734
2732
|
type: "item_reference",
|
|
2735
2733
|
id: approvalResponse.approvalId
|
|
@@ -4323,7 +4321,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4323
4321
|
toolChoice,
|
|
4324
4322
|
responseFormat
|
|
4325
4323
|
}) {
|
|
4326
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4324
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4327
4325
|
const warnings = [];
|
|
4328
4326
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4329
4327
|
if (topK != null) {
|
|
@@ -4387,10 +4385,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4387
4385
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
4388
4386
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4389
4387
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4390
|
-
|
|
4388
|
+
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0
|
|
4391
4389
|
});
|
|
4392
4390
|
warnings.push(...inputWarnings);
|
|
4393
|
-
const strictJsonSchema = (
|
|
4391
|
+
const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
4394
4392
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4395
4393
|
function addInclude(key) {
|
|
4396
4394
|
if (include == null) {
|
|
@@ -4406,9 +4404,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4406
4404
|
if (topLogprobs) {
|
|
4407
4405
|
addInclude("message.output_text.logprobs");
|
|
4408
4406
|
}
|
|
4409
|
-
const webSearchToolName = (
|
|
4407
|
+
const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
|
|
4410
4408
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4411
|
-
)) == null ? void 0 :
|
|
4409
|
+
)) == null ? void 0 : _f.name;
|
|
4412
4410
|
if (webSearchToolName) {
|
|
4413
4411
|
addInclude("web_search_call.action.sources");
|
|
4414
4412
|
}
|
|
@@ -4431,7 +4429,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4431
4429
|
format: responseFormat.schema != null ? {
|
|
4432
4430
|
type: "json_schema",
|
|
4433
4431
|
strict: strictJsonSchema,
|
|
4434
|
-
name: (
|
|
4432
|
+
name: (_g = responseFormat.name) != null ? _g : "response",
|
|
4435
4433
|
description: responseFormat.description,
|
|
4436
4434
|
schema: responseFormat.schema
|
|
4437
4435
|
} : { type: "json_object" }
|