@zenning/openai 3.0.19 → 3.0.21

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/dist/index.mjs CHANGED
@@ -2547,7 +2547,8 @@ async function convertToOpenAIResponsesInput({
2547
2547
  hasShellTool = false,
2548
2548
  hasApplyPatchTool = false,
2549
2549
  compactionInput,
2550
- previousResponseId
2550
+ previousResponseId,
2551
+ containsApprovalResponses
2551
2552
  }) {
2552
2553
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2553
2554
  const input = [];
@@ -2634,13 +2635,10 @@ async function convertToOpenAIResponsesInput({
2634
2635
  switch (part.type) {
2635
2636
  case "text": {
2636
2637
  const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName]) == null ? void 0 : _b.itemId;
2637
- if (store && id != null && !previousResponseId) {
2638
+ if (store && id != null) {
2638
2639
  input.push({ type: "item_reference", id });
2639
2640
  break;
2640
2641
  }
2641
- if (store && id != null && previousResponseId) {
2642
- break;
2643
- }
2644
2642
  input.push({
2645
2643
  role: "assistant",
2646
2644
  content: [{ type: "output_text", text: part.text }],
@@ -2651,16 +2649,16 @@ async function convertToOpenAIResponsesInput({
2651
2649
  case "tool-call": {
2652
2650
  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
2651
  if (part.providerExecuted) {
2654
- if (store && id != null && !previousResponseId) {
2652
+ if (store && id != null && !containsApprovalResponses) {
2655
2653
  input.push({ type: "item_reference", id });
2656
2654
  }
2657
2655
  break;
2658
2656
  }
2659
- if (store && id != null && !previousResponseId) {
2657
+ if (store && id != null && !containsApprovalResponses) {
2660
2658
  input.push({ type: "item_reference", id });
2661
2659
  break;
2662
2660
  }
2663
- if (store && id != null && previousResponseId) {
2661
+ if (store && id != null && containsApprovalResponses) {
2664
2662
  break;
2665
2663
  }
2666
2664
  const resolvedToolName = toolNameMapping.toProviderToolName(
@@ -2718,10 +2716,9 @@ async function convertToOpenAIResponsesInput({
2718
2716
  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") {
2719
2717
  break;
2720
2718
  }
2721
- if (store && !previousResponseId) {
2719
+ if (store) {
2722
2720
  const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2723
2721
  input.push({ type: "item_reference", id: itemId });
2724
- } else if (store) {
2725
2722
  } else {
2726
2723
  warnings.push({
2727
2724
  type: "other",
@@ -2739,7 +2736,7 @@ async function convertToOpenAIResponsesInput({
2739
2736
  const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
2740
2737
  if (reasoningId != null) {
2741
2738
  const reasoningMessage = reasoningMessages[reasoningId];
2742
- if (store && !previousResponseId) {
2739
+ if (store) {
2743
2740
  if (reasoningMessage === void 0) {
2744
2741
  input.push({ type: "item_reference", id: reasoningId });
2745
2742
  reasoningMessages[reasoningId] = {
@@ -2748,14 +2745,6 @@ async function convertToOpenAIResponsesInput({
2748
2745
  summary: []
2749
2746
  };
2750
2747
  }
2751
- } else if (store) {
2752
- if (reasoningMessage === void 0) {
2753
- reasoningMessages[reasoningId] = {
2754
- type: "reasoning",
2755
- id: reasoningId,
2756
- summary: []
2757
- };
2758
- }
2759
2748
  } else {
2760
2749
  const summaryParts = [];
2761
2750
  if (part.text.length > 0) {
@@ -3875,7 +3864,12 @@ var openaiResponsesProviderOptionsSchema = lazySchema18(
3875
3864
  type: z20.literal("compaction"),
3876
3865
  encrypted_content: z20.string()
3877
3866
  })
3878
- ).optional()
3867
+ ).optional(),
3868
+ /**
3869
+ * Whether the request contains tool approval responses.
3870
+ * Defaults to `false`.
3871
+ */
3872
+ containsApprovalResponses: z20.boolean().optional()
3879
3873
  })
3880
3874
  )
3881
3875
  );
@@ -4108,7 +4102,7 @@ var OpenAIResponsesLanguageModel = class {
4108
4102
  toolChoice,
4109
4103
  responseFormat
4110
4104
  }) {
4111
- var _a, _b, _c, _d, _e, _f, _g;
4105
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4112
4106
  const warnings = [];
4113
4107
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4114
4108
  if (topK != null) {
@@ -4172,10 +4166,11 @@ var OpenAIResponsesLanguageModel = class {
4172
4166
  hasShellTool: hasOpenAITool("openai.shell"),
4173
4167
  hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
4174
4168
  compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
4175
- previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0
4169
+ previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
4170
+ containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
4176
4171
  });
4177
4172
  warnings.push(...inputWarnings);
4178
- const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4173
+ const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
4179
4174
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4180
4175
  function addInclude(key) {
4181
4176
  if (include == null) {
@@ -4191,9 +4186,9 @@ var OpenAIResponsesLanguageModel = class {
4191
4186
  if (topLogprobs) {
4192
4187
  addInclude("message.output_text.logprobs");
4193
4188
  }
4194
- const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4189
+ const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
4195
4190
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4196
- )) == null ? void 0 : _f.name;
4191
+ )) == null ? void 0 : _g.name;
4197
4192
  if (webSearchToolName) {
4198
4193
  addInclude("web_search_call.action.sources");
4199
4194
  }
@@ -4216,7 +4211,7 @@ var OpenAIResponsesLanguageModel = class {
4216
4211
  format: responseFormat.schema != null ? {
4217
4212
  type: "json_schema",
4218
4213
  strict: strictJsonSchema,
4219
- name: (_g = responseFormat.name) != null ? _g : "response",
4214
+ name: (_h = responseFormat.name) != null ? _h : "response",
4220
4215
  description: responseFormat.description,
4221
4216
  schema: responseFormat.schema
4222
4217
  } : { type: "json_object" }
@@ -5870,7 +5865,7 @@ var OpenAITranscriptionModel = class {
5870
5865
  };
5871
5866
 
5872
5867
  // src/version.ts
5873
- var VERSION = true ? "3.0.19" : "0.0.0-test";
5868
+ var VERSION = true ? "3.0.21" : "0.0.0-test";
5874
5869
 
5875
5870
  // src/openai-provider.ts
5876
5871
  function createOpenAI(options = {}) {