@zenning/openai 1.5.0 → 1.6.0

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.d.mts CHANGED
@@ -444,7 +444,7 @@ declare const openai: OpenAIProvider;
444
444
  declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
445
445
  metadata: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
446
446
  parallelToolCalls: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
447
- include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
447
+ include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<["file_search_call.results", "code_interpreter_call.output", "web_search_call.results", "message.input_image.image_url", "computer_call_output.output.image_url", "reasoning.encrypted_content", "message.output_text.logprobs"]>, "many">>>;
448
448
  previousResponseId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
449
449
  forceNoTemperature: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
450
450
  store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
@@ -459,7 +459,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
459
459
  store?: boolean | null | undefined;
460
460
  metadata?: any;
461
461
  reasoningEffort?: string | null | undefined;
462
- include?: string[] | null | undefined;
462
+ include?: ("file_search_call.results" | "code_interpreter_call.output" | "web_search_call.results" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null | undefined;
463
463
  parallelToolCalls?: boolean | null | undefined;
464
464
  previousResponseId?: string | null | undefined;
465
465
  strictSchemas?: boolean | null | undefined;
@@ -471,7 +471,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
471
471
  store?: boolean | null | undefined;
472
472
  metadata?: any;
473
473
  reasoningEffort?: string | null | undefined;
474
- include?: string[] | null | undefined;
474
+ include?: ("file_search_call.results" | "code_interpreter_call.output" | "web_search_call.results" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null | undefined;
475
475
  parallelToolCalls?: boolean | null | undefined;
476
476
  previousResponseId?: string | null | undefined;
477
477
  strictSchemas?: boolean | null | undefined;
package/dist/index.d.ts CHANGED
@@ -444,7 +444,7 @@ declare const openai: OpenAIProvider;
444
444
  declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
445
445
  metadata: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
446
446
  parallelToolCalls: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
447
- include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
447
+ include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<["file_search_call.results", "code_interpreter_call.output", "web_search_call.results", "message.input_image.image_url", "computer_call_output.output.image_url", "reasoning.encrypted_content", "message.output_text.logprobs"]>, "many">>>;
448
448
  previousResponseId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
449
449
  forceNoTemperature: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
450
450
  store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
@@ -459,7 +459,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
459
459
  store?: boolean | null | undefined;
460
460
  metadata?: any;
461
461
  reasoningEffort?: string | null | undefined;
462
- include?: string[] | null | undefined;
462
+ include?: ("file_search_call.results" | "code_interpreter_call.output" | "web_search_call.results" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null | undefined;
463
463
  parallelToolCalls?: boolean | null | undefined;
464
464
  previousResponseId?: string | null | undefined;
465
465
  strictSchemas?: boolean | null | undefined;
@@ -471,7 +471,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
471
471
  store?: boolean | null | undefined;
472
472
  metadata?: any;
473
473
  reasoningEffort?: string | null | undefined;
474
- include?: string[] | null | undefined;
474
+ include?: ("file_search_call.results" | "code_interpreter_call.output" | "web_search_call.results" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null | undefined;
475
475
  parallelToolCalls?: boolean | null | undefined;
476
476
  previousResponseId?: string | null | undefined;
477
477
  strictSchemas?: boolean | null | undefined;
package/dist/index.js CHANGED
@@ -2630,55 +2630,31 @@ var OpenAIResponsesLanguageModel = class {
2630
2630
  }
2631
2631
  const reasoningSummary = (_b = (_a15 = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a15.summary) != null ? _b : null;
2632
2632
  const allAnnotations = outputTextElements.flatMap((content) => content.annotations);
2633
- console.log("\u{1F4CB} Processing annotations in doGenerate:", JSON.stringify({
2634
- msg: "ai-sdk: content annotations",
2635
- count: allAnnotations.length,
2636
- annotations: allAnnotations
2637
- }, null, 2));
2638
2633
  return {
2639
2634
  text: outputTextElements.map((content) => content.text).join("\n"),
2640
2635
  sources: outputTextElements.flatMap(
2641
2636
  (content) => content.annotations.map((annotation) => {
2642
- var _a16, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l;
2643
- console.log("\u{1F517} Processing annotation for source:", JSON.stringify(annotation, null, 2));
2644
- try {
2645
- if (annotation.type === "url_citation") {
2646
- const urlSource = {
2647
- sourceType: "url",
2648
- id: (_c2 = (_b2 = (_a16 = this.config).generateId) == null ? void 0 : _b2.call(_a16)) != null ? _c2 : (0, import_provider_utils9.generateId)(),
2649
- url: annotation.url,
2650
- title: annotation.title
2651
- };
2652
- console.log("\u2705 Created URL source:", JSON.stringify(urlSource, null, 2));
2653
- return urlSource;
2654
- } else if (annotation.type === "file_citation") {
2655
- const urlSource = {
2656
- sourceType: "url",
2657
- id: (_f2 = (_e2 = (_d2 = this.config).generateId) == null ? void 0 : _e2.call(_d2)) != null ? _f2 : (0, import_provider_utils9.generateId)(),
2658
- url: `file://${annotation.file_id}`,
2659
- title: annotation.quote || annotation.filename || "Document"
2660
- };
2661
- console.log("\u{1F4C4} Created URL source for file citation:", JSON.stringify(urlSource, null, 2));
2662
- return urlSource;
2663
- } else {
2664
- console.log("\u26A0\uFE0F Unknown annotation type in doGenerate:", annotation.type);
2665
- return {
2666
- sourceType: "url",
2667
- id: (_i = (_h = (_g2 = this.config).generateId) == null ? void 0 : _h.call(_g2)) != null ? _i : (0, import_provider_utils9.generateId)(),
2668
- url: "",
2669
- title: "Unknown Source"
2670
- };
2671
- }
2672
- } catch (error) {
2673
- console.error("\u274C Error creating source in doGenerate:", {
2674
- annotation,
2675
- error: error instanceof Error ? error.message : String(error)
2676
- });
2637
+ var _a16, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i;
2638
+ if (annotation.type === "url_citation") {
2639
+ return {
2640
+ sourceType: "url",
2641
+ id: (_c2 = (_b2 = (_a16 = this.config).generateId) == null ? void 0 : _b2.call(_a16)) != null ? _c2 : (0, import_provider_utils9.generateId)(),
2642
+ url: annotation.url,
2643
+ title: annotation.title
2644
+ };
2645
+ } else if (annotation.type === "file_citation") {
2677
2646
  return {
2678
2647
  sourceType: "url",
2679
- id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0, import_provider_utils9.generateId)(),
2648
+ id: (_f2 = (_e2 = (_d2 = this.config).generateId) == null ? void 0 : _e2.call(_d2)) != null ? _f2 : (0, import_provider_utils9.generateId)(),
2649
+ url: `file://${annotation.file_id}`,
2650
+ title: annotation.quote || annotation.filename || "Document"
2651
+ };
2652
+ } else {
2653
+ return {
2654
+ sourceType: "url",
2655
+ id: (_i = (_h = (_g2 = this.config).generateId) == null ? void 0 : _h.call(_g2)) != null ? _i : (0, import_provider_utils9.generateId)(),
2680
2656
  url: "",
2681
- title: "Error Source"
2657
+ title: "Unknown Source"
2682
2658
  };
2683
2659
  }
2684
2660
  })
@@ -2723,16 +2699,10 @@ var OpenAIResponsesLanguageModel = class {
2723
2699
  };
2724
2700
  }
2725
2701
  async doStream(options) {
2726
- console.log("\u{1F680} Starting doStream with options:", JSON.stringify({
2727
- modelId: this.modelId,
2728
- hasAbortSignal: !!options.abortSignal
2729
- }, null, 2));
2730
2702
  const { args: body, warnings } = this.getArgs(options);
2731
- console.log("\u{1F4E4} Request body:", JSON.stringify(body, null, 2));
2732
2703
  let response;
2733
2704
  let responseHeaders;
2734
2705
  try {
2735
- console.log("\u{1F4E1} Making API request...");
2736
2706
  const result = await (0, import_provider_utils9.postJsonToApi)({
2737
2707
  url: this.config.url({
2738
2708
  path: "/responses",
@@ -2752,7 +2722,6 @@ var OpenAIResponsesLanguageModel = class {
2752
2722
  });
2753
2723
  response = result.value;
2754
2724
  responseHeaders = result.responseHeaders;
2755
- console.log("\u2705 API request successful, starting stream processing");
2756
2725
  } catch (error) {
2757
2726
  console.error("\u274C API request failed:", error);
2758
2727
  throw error;
@@ -2770,9 +2739,8 @@ var OpenAIResponsesLanguageModel = class {
2770
2739
  stream: response.pipeThrough(
2771
2740
  new TransformStream({
2772
2741
  transform(chunk, controller) {
2773
- var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2742
+ var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2774
2743
  try {
2775
- console.log("\u{1F4E6} Processing chunk:", JSON.stringify(chunk, null, 2));
2776
2744
  if (!chunk.success) {
2777
2745
  console.error("\u274C Chunk parsing failed:", chunk.error);
2778
2746
  finishReason = "error";
@@ -2780,9 +2748,7 @@ var OpenAIResponsesLanguageModel = class {
2780
2748
  return;
2781
2749
  }
2782
2750
  const value = chunk.value;
2783
- console.log("\u{1F4E5} Chunk value type:", value.type);
2784
2751
  if (isResponseOutputItemAddedChunk(value)) {
2785
- console.log("\u{1F4DD} Output item added:", JSON.stringify(value, null, 2));
2786
2752
  if (value.item.type === "function_call") {
2787
2753
  ongoingToolCalls[value.output_index] = {
2788
2754
  toolName: value.item.name,
@@ -2845,7 +2811,6 @@ var OpenAIResponsesLanguageModel = class {
2845
2811
  });
2846
2812
  }
2847
2813
  } else if (isResponseCreatedChunk(value)) {
2848
- console.log("\u{1F680} Response created:", JSON.stringify(value, null, 2));
2849
2814
  responseId = value.response.id;
2850
2815
  controller.enqueue({
2851
2816
  type: "response-metadata",
@@ -2854,19 +2819,16 @@ var OpenAIResponsesLanguageModel = class {
2854
2819
  modelId: value.response.model
2855
2820
  });
2856
2821
  } else if (isTextDeltaChunk(value)) {
2857
- console.log("\u{1F4DD} Text delta chunk:", JSON.stringify(value, null, 2));
2858
2822
  controller.enqueue({
2859
2823
  type: "text-delta",
2860
2824
  textDelta: value.delta
2861
2825
  });
2862
2826
  } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2863
- console.log("\u{1F9E0} Reasoning summary delta:", JSON.stringify(value, null, 2));
2864
2827
  controller.enqueue({
2865
2828
  type: "reasoning",
2866
2829
  textDelta: value.delta
2867
2830
  });
2868
2831
  } else if (isResponseOutputItemDoneChunk(value)) {
2869
- console.log("\u2705 Output item done:", JSON.stringify(value, null, 2));
2870
2832
  if (value.item.type === "function_call") {
2871
2833
  ongoingToolCalls[value.output_index] = void 0;
2872
2834
  hasToolCalls = true;
@@ -2898,115 +2860,67 @@ var OpenAIResponsesLanguageModel = class {
2898
2860
  args: ""
2899
2861
  });
2900
2862
  } else if (value.item.type === "file_search_call") {
2901
- console.log("\u{1F4C1} File search call completed:", JSON.stringify({
2902
- id: value.item.id,
2903
- status: value.item.status,
2904
- queries: value.item.queries,
2905
- resultsCount: ((_a15 = value.item.results) == null ? void 0 : _a15.length) || 0
2906
- }, null, 2));
2907
2863
  ongoingToolCalls[value.output_index] = void 0;
2908
2864
  hasToolCalls = true;
2909
- try {
2910
- controller.enqueue({
2911
- type: "tool-call",
2912
- toolCallType: "function",
2913
- toolCallId: value.item.id,
2914
- toolName: "file_search",
2915
- args: JSON.stringify({
2916
- queries: value.item.queries,
2917
- results: value.item.results
2918
- })
2919
- });
2920
- console.log("\u2705 File search tool call enqueued successfully");
2921
- } catch (error) {
2922
- console.error("\u274C Error enqueuing file search tool call:", error);
2923
- }
2865
+ controller.enqueue({
2866
+ type: "tool-call",
2867
+ toolCallType: "function",
2868
+ toolCallId: value.item.id,
2869
+ toolName: "file_search",
2870
+ args: JSON.stringify({
2871
+ queries: value.item.queries,
2872
+ results: value.item.results
2873
+ })
2874
+ });
2924
2875
  }
2925
2876
  } else if (isResponseFinishedChunk(value)) {
2926
- console.log("\u{1F3C1} Response finished:", JSON.stringify(value, null, 2));
2927
2877
  finishReason = mapOpenAIResponseFinishReason({
2928
- finishReason: (_b = value.response.incomplete_details) == null ? void 0 : _b.reason,
2878
+ finishReason: (_a15 = value.response.incomplete_details) == null ? void 0 : _a15.reason,
2929
2879
  hasToolCalls
2930
2880
  });
2931
2881
  promptTokens = value.response.usage.input_tokens;
2932
2882
  completionTokens = value.response.usage.output_tokens;
2933
- cachedPromptTokens = (_d = (_c = value.response.usage.input_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : cachedPromptTokens;
2934
- reasoningTokens = (_f = (_e = value.response.usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : reasoningTokens;
2883
+ cachedPromptTokens = (_c = (_b = value.response.usage.input_tokens_details) == null ? void 0 : _b.cached_tokens) != null ? _c : cachedPromptTokens;
2884
+ reasoningTokens = (_e = (_d = value.response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : reasoningTokens;
2935
2885
  } else if (isResponseAnnotationAddedChunk(value)) {
2936
- console.log("\u{1F50D} Processing annotation chunk:", JSON.stringify({
2937
- type: value.type,
2938
- annotation: value.annotation
2939
- }, null, 2));
2940
2886
  try {
2941
- console.log("\u{1F50D} Annotation processing - step 1: Validating annotation structure");
2942
- if (!value.annotation || typeof value.annotation !== "object") {
2943
- throw new Error("Invalid annotation structure");
2944
- }
2945
- console.log("\u{1F50D} Annotation processing - step 2: Checking annotation type");
2946
2887
  if (value.annotation.type === "url_citation") {
2947
- console.log("\u{1F310} Processing URL citation");
2948
2888
  const urlSource = {
2949
2889
  sourceType: "url",
2950
- id: (_i = (_h = (_g = self.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils9.generateId)(),
2890
+ id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils9.generateId)(),
2951
2891
  url: String(value.annotation.url || ""),
2952
2892
  title: String(value.annotation.title || "Web Source")
2953
2893
  };
2954
- console.log("\u2705 Created URL source:", JSON.stringify(urlSource, null, 2));
2955
- console.log("\u{1F50D} Annotation processing - step 3: Enqueuing URL source");
2956
2894
  controller.enqueue({
2957
2895
  type: "source",
2958
2896
  source: urlSource
2959
2897
  });
2960
- console.log("\u2705 URL source enqueued successfully");
2961
2898
  } else if (value.annotation.type === "file_citation") {
2962
- console.log("\u{1F4C4} Processing FILE citation - using URL format for v4 compatibility");
2963
- console.log("\u{1F4C4} File citation raw data:", JSON.stringify(value.annotation, null, 2));
2964
2899
  const urlSource = {
2965
2900
  sourceType: "url",
2966
- id: (_l = (_k = (_j = self.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0, import_provider_utils9.generateId)(),
2901
+ id: (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0, import_provider_utils9.generateId)(),
2967
2902
  url: `file://${value.annotation.file_id}`,
2968
2903
  title: String(value.annotation.quote || value.annotation.filename || "Document")
2969
2904
  };
2970
- console.log("\u{1F4C4} Created URL source for file citation:", JSON.stringify(urlSource, null, 2));
2971
- console.log("\u{1F50D} Annotation processing - step 3: Enqueuing URL source");
2972
2905
  controller.enqueue({
2973
2906
  type: "source",
2974
2907
  source: urlSource
2975
2908
  });
2976
- console.log("\u2705 File citation URL source enqueued successfully");
2977
- } else {
2978
- console.log("\u26A0\uFE0F Unknown annotation type:", value.annotation.type);
2979
2909
  }
2980
2910
  } catch (error) {
2981
- console.error("\u274C CRITICAL ERROR in annotation processing:", {
2982
- step: "annotation processing",
2983
- annotation: value.annotation,
2984
- error: error instanceof Error ? error.message : String(error),
2985
- stack: error instanceof Error ? error.stack : void 0
2986
- });
2987
- console.log("\u{1F6E1}\uFE0F Continuing stream without this annotation to prevent total failure");
2911
+ console.error("\u274C Error processing annotation:", error);
2988
2912
  }
2989
2913
  } else if (isResponseInProgressChunk(value)) {
2990
- console.log("\u23F3 Response in progress (ignored):", value.type);
2991
2914
  } else if (isResponseContentPartAddedChunk(value)) {
2992
- console.log("\u{1F4DD} Content part added (ignored):", value.type);
2993
2915
  } else if (isResponseOutputTextDoneChunk(value)) {
2994
- console.log("\u2705 Output text done (ignored):", value.type);
2995
2916
  } else if (isResponseContentPartDoneChunk(value)) {
2996
- console.log("\u2705 Content part done (ignored):", value.type);
2997
2917
  } else if (isResponseFileSearchCallInProgressChunk(value)) {
2998
- console.log("\u{1F50D} File search in progress (ignored):", value.type);
2999
2918
  } else if (isResponseFileSearchCallSearchingChunk(value)) {
3000
- console.log("\u{1F50D} File search searching (ignored):", value.type);
3001
2919
  } else if (isResponseFileSearchCallCompletedChunk(value)) {
3002
- console.log("\u2705 File search completed (ignored):", value.type);
3003
2920
  } else if (isResponseFileSearchCallQueryAddedChunk(value)) {
3004
- console.log("\u{1F50D} File search query added (ignored):", value.type, "Query:", value.query);
3005
2921
  } else if (isResponseFileSearchCallResultAddedChunk(value)) {
3006
- console.log("\u{1F4C4} File search result added (ignored):", value.type);
3007
- console.log("\u{1F4C4} File search result details:", JSON.stringify(value.result, null, 2));
3008
2922
  } else {
3009
- console.log("\u2753 Unhandled chunk type:", value.type, JSON.stringify(value, null, 2));
2923
+ console.log("\u2753 Unhandled chunk type:", value.type);
3010
2924
  }
3011
2925
  } catch (error) {
3012
2926
  console.error("\u{1F4A5} FATAL ERROR in chunk processing:", {
@@ -3108,6 +3022,9 @@ var responseOutputItemDoneSchema = import_zod11.z.object({
3108
3022
  })
3109
3023
  ]).nullish()
3110
3024
  }),
3025
+ import_zod11.z.object({
3026
+ type: import_zod11.z.literal("code_interpreter_call")
3027
+ }),
3111
3028
  import_zod11.z.object({
3112
3029
  type: import_zod11.z.literal("computer_call"),
3113
3030
  id: import_zod11.z.string(),
@@ -3367,7 +3284,17 @@ function getResponsesModelConfig(modelId) {
3367
3284
  var openaiResponsesProviderOptionsSchema = import_zod11.z.object({
3368
3285
  metadata: import_zod11.z.any().nullish(),
3369
3286
  parallelToolCalls: import_zod11.z.boolean().nullish(),
3370
- include: import_zod11.z.array(import_zod11.z.string()).nullish(),
3287
+ include: import_zod11.z.array(
3288
+ import_zod11.z.enum([
3289
+ "file_search_call.results",
3290
+ "code_interpreter_call.output",
3291
+ "web_search_call.results",
3292
+ "message.input_image.image_url",
3293
+ "computer_call_output.output.image_url",
3294
+ "reasoning.encrypted_content",
3295
+ "message.output_text.logprobs"
3296
+ ])
3297
+ ).nullish(),
3371
3298
  previousResponseId: import_zod11.z.string().nullish(),
3372
3299
  forceNoTemperature: import_zod11.z.boolean().nullish(),
3373
3300
  store: import_zod11.z.boolean().nullish(),