@zenning/openai 2.2.0 → 2.3.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.
@@ -247,6 +247,38 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
247
247
  user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
248
248
  }, z.core.$strip>;
249
249
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
250
+ declare const openaiResponsesTextUIPartProviderMetadataSchema: z.ZodObject<{
251
+ openai: z.ZodObject<{
252
+ itemId: z.ZodString;
253
+ annotations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
254
+ type: z.ZodLiteral<"url_citation">;
255
+ url: z.ZodString;
256
+ title: z.ZodString;
257
+ }, z.core.$strip>, z.ZodObject<{
258
+ type: z.ZodLiteral<"file_citation">;
259
+ file_id: z.ZodString;
260
+ filename: z.ZodOptional<z.ZodNullable<z.ZodString>>;
261
+ index: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
262
+ start_index: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
263
+ end_index: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
264
+ quote: z.ZodOptional<z.ZodNullable<z.ZodString>>;
265
+ }, z.core.$strip>, z.ZodObject<{
266
+ type: z.ZodLiteral<"container_file_citation">;
267
+ container_id: z.ZodString;
268
+ end_index: z.ZodNumber;
269
+ file_id: z.ZodString;
270
+ filename: z.ZodString;
271
+ start_index: z.ZodNumber;
272
+ }, z.core.$strip>]>>;
273
+ }, z.core.$strip>;
274
+ }, z.core.$strip>;
275
+ declare const openaiSourceExecutionFileProviderMetadataSchema: z.ZodObject<{
276
+ openai: z.ZodObject<{
277
+ containerId: z.ZodString;
278
+ fileId: z.ZodString;
279
+ filename: z.ZodString;
280
+ }, z.core.$strip>;
281
+ }, z.core.$strip>;
250
282
 
251
283
  declare const codeInterpreterInputSchema: z.ZodObject<{
252
284
  code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -562,4 +594,4 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _zenning_provider
562
594
  result: string;
563
595
  }>;
564
596
 
565
- export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAIResponsesProviderOptions, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions };
597
+ export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAIResponsesProviderOptions, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiResponsesTextUIPartProviderMetadataSchema, openaiSourceExecutionFileProviderMetadataSchema };
@@ -247,6 +247,38 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
247
247
  user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
248
248
  }, z.core.$strip>;
249
249
  type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
250
+ declare const openaiResponsesTextUIPartProviderMetadataSchema: z.ZodObject<{
251
+ openai: z.ZodObject<{
252
+ itemId: z.ZodString;
253
+ annotations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
254
+ type: z.ZodLiteral<"url_citation">;
255
+ url: z.ZodString;
256
+ title: z.ZodString;
257
+ }, z.core.$strip>, z.ZodObject<{
258
+ type: z.ZodLiteral<"file_citation">;
259
+ file_id: z.ZodString;
260
+ filename: z.ZodOptional<z.ZodNullable<z.ZodString>>;
261
+ index: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
262
+ start_index: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
263
+ end_index: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
264
+ quote: z.ZodOptional<z.ZodNullable<z.ZodString>>;
265
+ }, z.core.$strip>, z.ZodObject<{
266
+ type: z.ZodLiteral<"container_file_citation">;
267
+ container_id: z.ZodString;
268
+ end_index: z.ZodNumber;
269
+ file_id: z.ZodString;
270
+ filename: z.ZodString;
271
+ start_index: z.ZodNumber;
272
+ }, z.core.$strip>]>>;
273
+ }, z.core.$strip>;
274
+ }, z.core.$strip>;
275
+ declare const openaiSourceExecutionFileProviderMetadataSchema: z.ZodObject<{
276
+ openai: z.ZodObject<{
277
+ containerId: z.ZodString;
278
+ fileId: z.ZodString;
279
+ filename: z.ZodString;
280
+ }, z.core.$strip>;
281
+ }, z.core.$strip>;
250
282
 
251
283
  declare const codeInterpreterInputSchema: z.ZodObject<{
252
284
  code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -562,4 +594,4 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _zenning_provider
562
594
  result: string;
563
595
  }>;
564
596
 
565
- export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAIResponsesProviderOptions, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions };
597
+ export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAIResponsesProviderOptions, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiResponsesTextUIPartProviderMetadataSchema, openaiSourceExecutionFileProviderMetadataSchema };
@@ -43,7 +43,9 @@ __export(index_exports, {
43
43
  openAITranscriptionProviderOptions: () => openAITranscriptionProviderOptions,
44
44
  openaiChatLanguageModelOptions: () => openaiChatLanguageModelOptions,
45
45
  openaiCompletionProviderOptions: () => openaiCompletionProviderOptions,
46
- openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions
46
+ openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions,
47
+ openaiResponsesTextUIPartProviderMetadataSchema: () => openaiResponsesTextUIPartProviderMetadataSchema,
48
+ openaiSourceExecutionFileProviderMetadataSchema: () => openaiSourceExecutionFileProviderMetadataSchema
47
49
  });
48
50
  module.exports = __toCommonJS(index_exports);
49
51
 
@@ -2710,6 +2712,11 @@ var localShellCallItem = import_v419.z.object({
2710
2712
  env: import_v419.z.record(import_v419.z.string(), import_v419.z.string()).optional()
2711
2713
  })
2712
2714
  });
2715
+ var sourceExecutionFileCodeInterpreterItem = import_v419.z.object({
2716
+ containerId: import_v419.z.string(),
2717
+ fileId: import_v419.z.string(),
2718
+ filename: import_v419.z.string()
2719
+ });
2713
2720
  var imageGenerationCallItem = import_v419.z.object({
2714
2721
  type: import_v419.z.literal("image_generation_call"),
2715
2722
  id: import_v419.z.string(),
@@ -2935,7 +2942,7 @@ var OpenAIResponsesLanguageModel = class {
2935
2942
  };
2936
2943
  }
2937
2944
  async doGenerate(options) {
2938
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
2945
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
2939
2946
  const {
2940
2947
  args: body,
2941
2948
  warnings,
@@ -2945,6 +2952,7 @@ var OpenAIResponsesLanguageModel = class {
2945
2952
  path: "/responses",
2946
2953
  modelId: this.modelId
2947
2954
  });
2955
+ const providerKey = this.config.provider.replace(".responses", "");
2948
2956
  const {
2949
2957
  responseHeaders,
2950
2958
  value: response,
@@ -2993,7 +3001,12 @@ var OpenAIResponsesLanguageModel = class {
2993
3001
  quote: import_v419.z.string().nullish()
2994
3002
  }),
2995
3003
  import_v419.z.object({
2996
- type: import_v419.z.literal("container_file_citation")
3004
+ type: import_v419.z.literal("container_file_citation"),
3005
+ container_id: import_v419.z.string(),
3006
+ end_index: import_v419.z.number(),
3007
+ file_id: import_v419.z.string(),
3008
+ filename: import_v419.z.string(),
3009
+ start_index: import_v419.z.number()
2997
3010
  })
2998
3011
  ])
2999
3012
  )
@@ -3115,7 +3128,8 @@ var OpenAIResponsesLanguageModel = class {
3115
3128
  text: contentPart.text,
3116
3129
  providerMetadata: {
3117
3130
  openai: {
3118
- itemId: part.id
3131
+ itemId: part.id,
3132
+ annotations: contentPart.annotations
3119
3133
  }
3120
3134
  }
3121
3135
  });
@@ -3140,6 +3154,19 @@ var OpenAIResponsesLanguageModel = class {
3140
3154
  startIndex: (_m = annotation.start_index) != null ? _m : void 0,
3141
3155
  endIndex: (_n = annotation.end_index) != null ? _n : void 0
3142
3156
  });
3157
+ } else if (annotation.type === "container_file_citation") {
3158
+ content.push({
3159
+ type: "source",
3160
+ sourceType: "executionFile",
3161
+ id: (_q = (_p = (_o = this.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils16.generateId)(),
3162
+ providerMetadata: {
3163
+ [providerKey]: {
3164
+ containerId: annotation.container_id,
3165
+ fileId: annotation.file_id,
3166
+ filename: annotation.filename
3167
+ }
3168
+ }
3169
+ });
3143
3170
  }
3144
3171
  }
3145
3172
  }
@@ -3211,13 +3238,13 @@ var OpenAIResponsesLanguageModel = class {
3211
3238
  toolName: "file_search",
3212
3239
  result: {
3213
3240
  queries: part.queries,
3214
- results: (_p = (_o = part.results) == null ? void 0 : _o.map((result) => ({
3241
+ results: (_s = (_r = part.results) == null ? void 0 : _r.map((result) => ({
3215
3242
  attributes: result.attributes,
3216
3243
  fileId: result.file_id,
3217
3244
  filename: result.filename,
3218
3245
  score: result.score,
3219
3246
  text: result.text
3220
- }))) != null ? _p : null
3247
+ }))) != null ? _s : null
3221
3248
  },
3222
3249
  providerExecuted: true
3223
3250
  });
@@ -3259,15 +3286,15 @@ var OpenAIResponsesLanguageModel = class {
3259
3286
  return {
3260
3287
  content,
3261
3288
  finishReason: mapOpenAIResponseFinishReason({
3262
- finishReason: (_q = response.incomplete_details) == null ? void 0 : _q.reason,
3289
+ finishReason: (_t = response.incomplete_details) == null ? void 0 : _t.reason,
3263
3290
  hasFunctionCall
3264
3291
  }),
3265
3292
  usage: {
3266
3293
  inputTokens: response.usage.input_tokens,
3267
3294
  outputTokens: response.usage.output_tokens,
3268
3295
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
3269
- reasoningTokens: (_s = (_r = response.usage.output_tokens_details) == null ? void 0 : _r.reasoning_tokens) != null ? _s : void 0,
3270
- cachedInputTokens: (_u = (_t = response.usage.input_tokens_details) == null ? void 0 : _t.cached_tokens) != null ? _u : void 0
3296
+ reasoningTokens: (_v = (_u = response.usage.output_tokens_details) == null ? void 0 : _u.reasoning_tokens) != null ? _v : void 0,
3297
+ cachedInputTokens: (_x = (_w = response.usage.input_tokens_details) == null ? void 0 : _w.cached_tokens) != null ? _x : void 0
3271
3298
  },
3272
3299
  request: { body },
3273
3300
  response: {
@@ -3314,6 +3341,7 @@ var OpenAIResponsesLanguageModel = class {
3314
3341
  const logprobs = [];
3315
3342
  let responseId = null;
3316
3343
  const ongoingToolCalls = {};
3344
+ const ongoingAnnotations = [];
3317
3345
  let hasFunctionCall = false;
3318
3346
  const activeReasoning = {};
3319
3347
  let serviceTier;
@@ -3324,7 +3352,7 @@ var OpenAIResponsesLanguageModel = class {
3324
3352
  controller.enqueue({ type: "stream-start", warnings });
3325
3353
  },
3326
3354
  transform(chunk, controller) {
3327
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
3355
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
3328
3356
  if (options.includeRawChunks) {
3329
3357
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3330
3358
  }
@@ -3400,6 +3428,7 @@ var OpenAIResponsesLanguageModel = class {
3400
3428
  providerExecuted: true
3401
3429
  });
3402
3430
  } else if (value.item.type === "message") {
3431
+ ongoingAnnotations.splice(0, ongoingAnnotations.length);
3403
3432
  controller.enqueue({
3404
3433
  type: "text-start",
3405
3434
  id: value.item.id,
@@ -3425,7 +3454,7 @@ var OpenAIResponsesLanguageModel = class {
3425
3454
  }
3426
3455
  });
3427
3456
  }
3428
- } else if (isResponseOutputItemDoneChunk(value)) {
3457
+ } else if (isResponseOutputItemDoneChunk(value) && value.item.type !== "message") {
3429
3458
  if (value.item.type === "function_call") {
3430
3459
  ongoingToolCalls[value.output_index] = void 0;
3431
3460
  hasFunctionCall = true;
@@ -3546,11 +3575,6 @@ var OpenAIResponsesLanguageModel = class {
3546
3575
  openai: { itemId: value.item.id }
3547
3576
  }
3548
3577
  });
3549
- } else if (value.item.type === "message") {
3550
- controller.enqueue({
3551
- type: "text-end",
3552
- id: value.item.id
3553
- });
3554
3578
  } else if (isResponseOutputItemDoneReasoningChunk(value)) {
3555
3579
  const activeReasoningPart = activeReasoning[value.item.id];
3556
3580
  for (const summaryIndex of activeReasoningPart.summaryParts) {
@@ -3679,6 +3703,7 @@ var OpenAIResponsesLanguageModel = class {
3679
3703
  serviceTier = value.response.service_tier;
3680
3704
  }
3681
3705
  } else if (isResponseAnnotationAddedChunk(value)) {
3706
+ ongoingAnnotations.push(value.annotation);
3682
3707
  if (value.annotation.type === "url_citation") {
3683
3708
  controller.enqueue({
3684
3709
  type: "source",
@@ -3699,7 +3724,31 @@ var OpenAIResponsesLanguageModel = class {
3699
3724
  startIndex: (_x = value.annotation.start_index) != null ? _x : void 0,
3700
3725
  endIndex: (_y = value.annotation.end_index) != null ? _y : void 0
3701
3726
  });
3727
+ } else if (value.annotation.type === "container_file_citation") {
3728
+ controller.enqueue({
3729
+ type: "source",
3730
+ sourceType: "executionFile",
3731
+ id: (_B = (_A = (_z = self.config).generateId) == null ? void 0 : _A.call(_z)) != null ? _B : (0, import_provider_utils16.generateId)(),
3732
+ providerMetadata: {
3733
+ openai: {
3734
+ containerId: value.annotation.container_id,
3735
+ fileId: value.annotation.file_id,
3736
+ filename: value.annotation.filename
3737
+ }
3738
+ }
3739
+ });
3702
3740
  }
3741
+ } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "message") {
3742
+ controller.enqueue({
3743
+ type: "text-end",
3744
+ id: value.item.id,
3745
+ providerMetadata: {
3746
+ openai: {
3747
+ itemId: value.item.id,
3748
+ annotations: ongoingAnnotations
3749
+ }
3750
+ }
3751
+ });
3703
3752
  } else if (isErrorChunk(value)) {
3704
3753
  controller.enqueue({ type: "error", error: value });
3705
3754
  }
@@ -3896,6 +3945,14 @@ var responseAnnotationAddedSchema = import_v419.z.object({
3896
3945
  start_index: import_v419.z.number().nullish(),
3897
3946
  end_index: import_v419.z.number().nullish(),
3898
3947
  quote: import_v419.z.string().nullish()
3948
+ }),
3949
+ import_v419.z.object({
3950
+ type: import_v419.z.literal("container_file_citation"),
3951
+ container_id: import_v419.z.string(),
3952
+ end_index: import_v419.z.number(),
3953
+ file_id: import_v419.z.string(),
3954
+ filename: import_v419.z.string(),
3955
+ start_index: import_v419.z.number()
3899
3956
  })
3900
3957
  ])
3901
3958
  });
@@ -4047,6 +4104,15 @@ var openaiResponsesProviderOptionsSchema = import_v419.z.object({
4047
4104
  textVerbosity: import_v419.z.enum(["low", "medium", "high"]).nullish(),
4048
4105
  user: import_v419.z.string().nullish()
4049
4106
  });
4107
+ var openaiResponsesTextUIPartProviderMetadataSchema = import_v419.z.object({
4108
+ openai: import_v419.z.object({
4109
+ itemId: import_v419.z.string(),
4110
+ annotations: import_v419.z.array(responseAnnotationAddedSchema.shape.annotation)
4111
+ })
4112
+ });
4113
+ var openaiSourceExecutionFileProviderMetadataSchema = import_v419.z.object({
4114
+ openai: sourceExecutionFileCodeInterpreterItem
4115
+ });
4050
4116
  // Annotate the CommonJS export names for ESM import in node:
4051
4117
  0 && (module.exports = {
4052
4118
  OpenAIChatLanguageModel,
@@ -4072,6 +4138,8 @@ var openaiResponsesProviderOptionsSchema = import_v419.z.object({
4072
4138
  openAITranscriptionProviderOptions,
4073
4139
  openaiChatLanguageModelOptions,
4074
4140
  openaiCompletionProviderOptions,
4075
- openaiEmbeddingProviderOptions
4141
+ openaiEmbeddingProviderOptions,
4142
+ openaiResponsesTextUIPartProviderMetadataSchema,
4143
+ openaiSourceExecutionFileProviderMetadataSchema
4076
4144
  });
4077
4145
  //# sourceMappingURL=index.js.map