@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.
@@ -2491,7 +2491,8 @@ async function convertToOpenAIResponsesInput({
2491
2491
  hasShellTool = false,
2492
2492
  hasApplyPatchTool = false,
2493
2493
  compactionInput,
2494
- previousResponseId
2494
+ previousResponseId,
2495
+ containsApprovalResponses
2495
2496
  }) {
2496
2497
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2497
2498
  const input = [];
@@ -2578,13 +2579,10 @@ async function convertToOpenAIResponsesInput({
2578
2579
  switch (part.type) {
2579
2580
  case "text": {
2580
2581
  const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName]) == null ? void 0 : _b.itemId;
2581
- if (store && id != null && !previousResponseId) {
2582
+ if (store && id != null) {
2582
2583
  input.push({ type: "item_reference", id });
2583
2584
  break;
2584
2585
  }
2585
- if (store && id != null && previousResponseId) {
2586
- break;
2587
- }
2588
2586
  input.push({
2589
2587
  role: "assistant",
2590
2588
  content: [{ type: "output_text", text: part.text }],
@@ -2595,16 +2593,16 @@ async function convertToOpenAIResponsesInput({
2595
2593
  case "tool-call": {
2596
2594
  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;
2597
2595
  if (part.providerExecuted) {
2598
- if (store && id != null && !previousResponseId) {
2596
+ if (store && id != null && !containsApprovalResponses) {
2599
2597
  input.push({ type: "item_reference", id });
2600
2598
  }
2601
2599
  break;
2602
2600
  }
2603
- if (store && id != null && !previousResponseId) {
2601
+ if (store && id != null && !containsApprovalResponses) {
2604
2602
  input.push({ type: "item_reference", id });
2605
2603
  break;
2606
2604
  }
2607
- if (store && id != null && previousResponseId) {
2605
+ if (store && id != null && containsApprovalResponses) {
2608
2606
  break;
2609
2607
  }
2610
2608
  const resolvedToolName = toolNameMapping.toProviderToolName(
@@ -2662,10 +2660,9 @@ async function convertToOpenAIResponsesInput({
2662
2660
  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") {
2663
2661
  break;
2664
2662
  }
2665
- if (store && !previousResponseId) {
2663
+ if (store) {
2666
2664
  const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2667
2665
  input.push({ type: "item_reference", id: itemId });
2668
- } else if (store) {
2669
2666
  } else {
2670
2667
  warnings.push({
2671
2668
  type: "other",
@@ -2683,7 +2680,7 @@ async function convertToOpenAIResponsesInput({
2683
2680
  const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
2684
2681
  if (reasoningId != null) {
2685
2682
  const reasoningMessage = reasoningMessages[reasoningId];
2686
- if (store && !previousResponseId) {
2683
+ if (store) {
2687
2684
  if (reasoningMessage === void 0) {
2688
2685
  input.push({ type: "item_reference", id: reasoningId });
2689
2686
  reasoningMessages[reasoningId] = {
@@ -2692,14 +2689,6 @@ async function convertToOpenAIResponsesInput({
2692
2689
  summary: []
2693
2690
  };
2694
2691
  }
2695
- } else if (store) {
2696
- if (reasoningMessage === void 0) {
2697
- reasoningMessages[reasoningId] = {
2698
- type: "reasoning",
2699
- id: reasoningId,
2700
- summary: []
2701
- };
2702
- }
2703
2692
  } else {
2704
2693
  const summaryParts = [];
2705
2694
  if (part.text.length > 0) {
@@ -3819,7 +3808,12 @@ var openaiResponsesProviderOptionsSchema = lazySchema15(
3819
3808
  type: z17.literal("compaction"),
3820
3809
  encrypted_content: z17.string()
3821
3810
  })
3822
- ).optional()
3811
+ ).optional(),
3812
+ /**
3813
+ * Whether the request contains tool approval responses.
3814
+ * Defaults to `false`.
3815
+ */
3816
+ containsApprovalResponses: z17.boolean().optional()
3823
3817
  })
3824
3818
  )
3825
3819
  );
@@ -4368,7 +4362,7 @@ var OpenAIResponsesLanguageModel = class {
4368
4362
  toolChoice,
4369
4363
  responseFormat
4370
4364
  }) {
4371
- var _a, _b, _c, _d, _e, _f, _g;
4365
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4372
4366
  const warnings = [];
4373
4367
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4374
4368
  if (topK != null) {
@@ -4432,10 +4426,11 @@ var OpenAIResponsesLanguageModel = class {
4432
4426
  hasShellTool: hasOpenAITool("openai.shell"),
4433
4427
  hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
4434
4428
  compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
4435
- previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0
4429
+ previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
4430
+ containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
4436
4431
  });
4437
4432
  warnings.push(...inputWarnings);
4438
- const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4433
+ const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
4439
4434
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4440
4435
  function addInclude(key) {
4441
4436
  if (include == null) {
@@ -4451,9 +4446,9 @@ var OpenAIResponsesLanguageModel = class {
4451
4446
  if (topLogprobs) {
4452
4447
  addInclude("message.output_text.logprobs");
4453
4448
  }
4454
- const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4449
+ const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
4455
4450
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4456
- )) == null ? void 0 : _f.name;
4451
+ )) == null ? void 0 : _g.name;
4457
4452
  if (webSearchToolName) {
4458
4453
  addInclude("web_search_call.action.sources");
4459
4454
  }
@@ -4476,7 +4471,7 @@ var OpenAIResponsesLanguageModel = class {
4476
4471
  format: responseFormat.schema != null ? {
4477
4472
  type: "json_schema",
4478
4473
  strict: strictJsonSchema,
4479
- name: (_g = responseFormat.name) != null ? _g : "response",
4474
+ name: (_h = responseFormat.name) != null ? _h : "response",
4480
4475
  description: responseFormat.description,
4481
4476
  schema: responseFormat.schema
4482
4477
  } : { type: "json_object" }