@zenning/openai 3.0.19 → 3.0.20

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,18 +2593,15 @@ 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) {
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) {
2604
2602
  input.push({ type: "item_reference", id });
2605
2603
  break;
2606
2604
  }
2607
- if (store && id != null && previousResponseId) {
2608
- break;
2609
- }
2610
2605
  const resolvedToolName = toolNameMapping.toProviderToolName(
2611
2606
  part.toolName
2612
2607
  );
@@ -2662,10 +2657,9 @@ async function convertToOpenAIResponsesInput({
2662
2657
  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
2658
  break;
2664
2659
  }
2665
- if (store && !previousResponseId) {
2660
+ if (store) {
2666
2661
  const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2667
2662
  input.push({ type: "item_reference", id: itemId });
2668
- } else if (store) {
2669
2663
  } else {
2670
2664
  warnings.push({
2671
2665
  type: "other",
@@ -2683,7 +2677,7 @@ async function convertToOpenAIResponsesInput({
2683
2677
  const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
2684
2678
  if (reasoningId != null) {
2685
2679
  const reasoningMessage = reasoningMessages[reasoningId];
2686
- if (store && !previousResponseId) {
2680
+ if (store) {
2687
2681
  if (reasoningMessage === void 0) {
2688
2682
  input.push({ type: "item_reference", id: reasoningId });
2689
2683
  reasoningMessages[reasoningId] = {
@@ -2692,14 +2686,6 @@ async function convertToOpenAIResponsesInput({
2692
2686
  summary: []
2693
2687
  };
2694
2688
  }
2695
- } else if (store) {
2696
- if (reasoningMessage === void 0) {
2697
- reasoningMessages[reasoningId] = {
2698
- type: "reasoning",
2699
- id: reasoningId,
2700
- summary: []
2701
- };
2702
- }
2703
2689
  } else {
2704
2690
  const summaryParts = [];
2705
2691
  if (part.text.length > 0) {
@@ -3819,7 +3805,12 @@ var openaiResponsesProviderOptionsSchema = lazySchema15(
3819
3805
  type: z17.literal("compaction"),
3820
3806
  encrypted_content: z17.string()
3821
3807
  })
3822
- ).optional()
3808
+ ).optional(),
3809
+ /**
3810
+ * Whether the request contains tool approval responses.
3811
+ * Defaults to `false`.
3812
+ */
3813
+ containsApprovalResponses: z17.boolean().optional()
3823
3814
  })
3824
3815
  )
3825
3816
  );
@@ -4368,7 +4359,7 @@ var OpenAIResponsesLanguageModel = class {
4368
4359
  toolChoice,
4369
4360
  responseFormat
4370
4361
  }) {
4371
- var _a, _b, _c, _d, _e, _f, _g;
4362
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4372
4363
  const warnings = [];
4373
4364
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4374
4365
  if (topK != null) {
@@ -4432,10 +4423,11 @@ var OpenAIResponsesLanguageModel = class {
4432
4423
  hasShellTool: hasOpenAITool("openai.shell"),
4433
4424
  hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
4434
4425
  compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
4435
- previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0
4426
+ previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
4427
+ containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
4436
4428
  });
4437
4429
  warnings.push(...inputWarnings);
4438
- const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4430
+ const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
4439
4431
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4440
4432
  function addInclude(key) {
4441
4433
  if (include == null) {
@@ -4451,9 +4443,9 @@ var OpenAIResponsesLanguageModel = class {
4451
4443
  if (topLogprobs) {
4452
4444
  addInclude("message.output_text.logprobs");
4453
4445
  }
4454
- const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4446
+ const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
4455
4447
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4456
- )) == null ? void 0 : _f.name;
4448
+ )) == null ? void 0 : _g.name;
4457
4449
  if (webSearchToolName) {
4458
4450
  addInclude("web_search_call.action.sources");
4459
4451
  }
@@ -4476,7 +4468,7 @@ var OpenAIResponsesLanguageModel = class {
4476
4468
  format: responseFormat.schema != null ? {
4477
4469
  type: "json_schema",
4478
4470
  strict: strictJsonSchema,
4479
- name: (_g = responseFormat.name) != null ? _g : "response",
4471
+ name: (_h = responseFormat.name) != null ? _h : "response",
4480
4472
  description: responseFormat.description,
4481
4473
  schema: responseFormat.schema
4482
4474
  } : { type: "json_object" }