@ai-sdk/huggingface 2.0.0-beta.9 → 2.0.0-canary.37

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.js CHANGED
@@ -1,50 +1,41 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- createHuggingFace: () => createHuggingFace,
24
- huggingface: () => huggingface
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
1
  // src/huggingface-provider.ts
29
- var import_provider3 = require("@ai-sdk/provider");
30
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ generateId as generateId2,
7
+ loadApiKey,
8
+ withoutTrailingSlash
9
+ } from "@ai-sdk/provider-utils";
31
10
 
32
11
  // src/responses/huggingface-responses-language-model.ts
33
- var import_provider2 = require("@ai-sdk/provider");
34
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
35
- var import_v42 = require("zod/v4");
12
+ import {
13
+ APICallError
14
+ } from "@ai-sdk/provider";
15
+ import {
16
+ combineHeaders,
17
+ createEventSourceResponseHandler,
18
+ createJsonResponseHandler,
19
+ generateId,
20
+ parseProviderOptions,
21
+ postJsonToApi,
22
+ serializeModelOptions,
23
+ WORKFLOW_SERIALIZE,
24
+ WORKFLOW_DESERIALIZE
25
+ } from "@ai-sdk/provider-utils";
26
+ import { z as z3 } from "zod/v4";
36
27
 
37
28
  // src/huggingface-error.ts
38
- var import_provider_utils = require("@ai-sdk/provider-utils");
39
- var import_v4 = require("zod/v4");
40
- var huggingfaceErrorDataSchema = import_v4.z.object({
41
- error: import_v4.z.object({
42
- message: import_v4.z.string(),
43
- type: import_v4.z.string().optional(),
44
- code: import_v4.z.string().optional()
29
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
30
+ import { z } from "zod/v4";
31
+ var huggingfaceErrorDataSchema = z.object({
32
+ error: z.object({
33
+ message: z.string(),
34
+ type: z.string().optional(),
35
+ code: z.string().optional()
45
36
  })
46
37
  });
47
- var huggingfaceFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
38
+ var huggingfaceFailedResponseHandler = createJsonErrorResponseHandler({
48
39
  errorSchema: huggingfaceErrorDataSchema,
49
40
  errorToMessage: (data) => data.error.message
50
41
  });
@@ -89,7 +80,13 @@ function convertHuggingFaceResponsesUsage(usage) {
89
80
  }
90
81
 
91
82
  // src/responses/convert-to-huggingface-responses-messages.ts
92
- var import_provider = require("@ai-sdk/provider");
83
+ import {
84
+ UnsupportedFunctionalityError
85
+ } from "@ai-sdk/provider";
86
+ import {
87
+ getTopLevelMediaType,
88
+ resolveFullMediaType
89
+ } from "@ai-sdk/provider-utils";
93
90
  async function convertToHuggingFaceResponsesMessages({
94
91
  prompt
95
92
  }) {
@@ -110,16 +107,30 @@ async function convertToHuggingFaceResponsesMessages({
110
107
  return { type: "input_text", text: part.text };
111
108
  }
112
109
  case "file": {
113
- if (part.mediaType.startsWith("image/")) {
114
- const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
115
- return {
116
- type: "input_image",
117
- image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`
118
- };
119
- } else {
120
- throw new import_provider.UnsupportedFunctionalityError({
121
- functionality: `file part media type ${part.mediaType}`
122
- });
110
+ switch (part.data.type) {
111
+ case "reference": {
112
+ throw new UnsupportedFunctionalityError({
113
+ functionality: "file parts with provider references"
114
+ });
115
+ }
116
+ case "text": {
117
+ throw new UnsupportedFunctionalityError({
118
+ functionality: "text file parts"
119
+ });
120
+ }
121
+ case "url":
122
+ case "data": {
123
+ if (getTopLevelMediaType(part.mediaType) === "image") {
124
+ return {
125
+ type: "input_image",
126
+ image_url: part.data.type === "url" ? part.data.url.toString() : `data:${resolveFullMediaType({ part })};base64,${part.data.data}`
127
+ };
128
+ } else {
129
+ throw new UnsupportedFunctionalityError({
130
+ functionality: `file part media type ${part.mediaType}`
131
+ });
132
+ }
133
+ }
123
134
  }
124
135
  }
125
136
  default: {
@@ -171,6 +182,15 @@ async function convertToHuggingFaceResponsesMessages({
171
182
  return { input: messages, warnings };
172
183
  }
173
184
 
185
+ // src/responses/huggingface-responses-language-model-options.ts
186
+ import { z as z2 } from "zod/v4";
187
+ var huggingfaceLanguageModelResponsesOptions = z2.object({
188
+ metadata: z2.record(z2.string(), z2.string()).optional(),
189
+ instructions: z2.string().optional(),
190
+ strictJsonSchema: z2.boolean().optional(),
191
+ reasoningEffort: z2.string().optional()
192
+ });
193
+
174
194
  // src/responses/huggingface-responses-prepare-tools.ts
175
195
  function prepareResponsesTools({
176
196
  tools,
@@ -253,7 +273,7 @@ function mapHuggingFaceResponsesFinishReason(finishReason) {
253
273
  }
254
274
 
255
275
  // src/responses/huggingface-responses-language-model.ts
256
- var HuggingFaceResponsesLanguageModel = class {
276
+ var HuggingFaceResponsesLanguageModel = class _HuggingFaceResponsesLanguageModel {
257
277
  constructor(modelId, config) {
258
278
  this.specificationVersion = "v4";
259
279
  this.supportedUrls = {
@@ -262,6 +282,18 @@ var HuggingFaceResponsesLanguageModel = class {
262
282
  this.modelId = modelId;
263
283
  this.config = config;
264
284
  }
285
+ static [WORKFLOW_SERIALIZE](model) {
286
+ return serializeModelOptions({
287
+ modelId: model.modelId,
288
+ config: model.config
289
+ });
290
+ }
291
+ static [WORKFLOW_DESERIALIZE](options) {
292
+ return new _HuggingFaceResponsesLanguageModel(
293
+ options.modelId,
294
+ options.config
295
+ );
296
+ }
265
297
  get provider() {
266
298
  return this.config.provider;
267
299
  }
@@ -301,10 +333,10 @@ var HuggingFaceResponsesLanguageModel = class {
301
333
  prompt
302
334
  });
303
335
  warnings.push(...messageWarnings);
304
- const huggingfaceOptions = await (0, import_provider_utils2.parseProviderOptions)({
336
+ const huggingfaceOptions = await parseProviderOptions({
305
337
  provider: "huggingface",
306
338
  providerOptions,
307
- schema: huggingfaceResponsesProviderOptionsSchema
339
+ schema: huggingfaceLanguageModelResponsesOptions
308
340
  });
309
341
  const {
310
342
  tools: preparedTools,
@@ -348,7 +380,7 @@ var HuggingFaceResponsesLanguageModel = class {
348
380
  return { args: baseArgs, warnings };
349
381
  }
350
382
  async doGenerate(options) {
351
- var _a, _b, _c, _d, _e, _f, _g;
383
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
352
384
  const { args, warnings } = await this.getArgs(options);
353
385
  const body = {
354
386
  ...args,
@@ -362,19 +394,19 @@ var HuggingFaceResponsesLanguageModel = class {
362
394
  value: response,
363
395
  responseHeaders,
364
396
  rawValue: rawResponse
365
- } = await (0, import_provider_utils2.postJsonToApi)({
397
+ } = await postJsonToApi({
366
398
  url,
367
- headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
399
+ headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
368
400
  body,
369
401
  failedResponseHandler: huggingfaceFailedResponseHandler,
370
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
402
+ successfulResponseHandler: createJsonResponseHandler(
371
403
  huggingfaceResponsesResponseSchema
372
404
  ),
373
405
  abortSignal: options.abortSignal,
374
406
  fetch: this.config.fetch
375
407
  });
376
408
  if (response.error) {
377
- throw new import_provider2.APICallError({
409
+ throw new APICallError({
378
410
  message: response.error.message,
379
411
  url,
380
412
  requestBodyValues: body,
@@ -403,7 +435,7 @@ var HuggingFaceResponsesLanguageModel = class {
403
435
  content.push({
404
436
  type: "source",
405
437
  sourceType: "url",
406
- id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : (0, import_provider_utils2.generateId)(),
438
+ id: (_e = (_d = (_c = this.config).generateId) == null ? void 0 : _d.call(_c)) != null ? _e : generateId(),
407
439
  url: annotation.url,
408
440
  title: annotation.title
409
441
  });
@@ -488,9 +520,9 @@ var HuggingFaceResponsesLanguageModel = class {
488
520
  content,
489
521
  finishReason: {
490
522
  unified: mapHuggingFaceResponsesFinishReason(
491
- (_e = (_d = response.incomplete_details) == null ? void 0 : _d.reason) != null ? _e : "stop"
523
+ (_g = (_f = response.incomplete_details) == null ? void 0 : _f.reason) != null ? _g : "stop"
492
524
  ),
493
- raw: (_g = (_f = response.incomplete_details) == null ? void 0 : _f.reason) != null ? _g : void 0
525
+ raw: (_i = (_h = response.incomplete_details) == null ? void 0 : _h.reason) != null ? _i : void 0
494
526
  },
495
527
  usage: convertHuggingFaceResponsesUsage(response.usage),
496
528
  request: { body },
@@ -510,20 +542,21 @@ var HuggingFaceResponsesLanguageModel = class {
510
542
  };
511
543
  }
512
544
  async doStream(options) {
545
+ var _a, _b;
513
546
  const { args, warnings } = await this.getArgs(options);
514
547
  const body = {
515
548
  ...args,
516
549
  stream: true
517
550
  };
518
- const { value: response, responseHeaders } = await (0, import_provider_utils2.postJsonToApi)({
551
+ const { value: response, responseHeaders } = await postJsonToApi({
519
552
  url: this.config.url({
520
553
  path: "/responses",
521
554
  modelId: this.modelId
522
555
  }),
523
- headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
556
+ headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
524
557
  body,
525
558
  failedResponseHandler: huggingfaceFailedResponseHandler,
526
- successfulResponseHandler: (0, import_provider_utils2.createEventSourceResponseHandler)(
559
+ successfulResponseHandler: createEventSourceResponseHandler(
527
560
  huggingfaceResponsesChunkSchema
528
561
  ),
529
562
  abortSignal: options.abortSignal,
@@ -542,7 +575,7 @@ var HuggingFaceResponsesLanguageModel = class {
542
575
  controller.enqueue({ type: "stream-start", warnings });
543
576
  },
544
577
  transform(chunk, controller) {
545
- var _a, _b, _c, _d;
578
+ var _a2, _b2, _c, _d;
546
579
  if (!chunk.success) {
547
580
  finishReason = {
548
581
  unified: "error",
@@ -624,7 +657,7 @@ var HuggingFaceResponsesLanguageModel = class {
624
657
  responseId = value.response.id;
625
658
  finishReason = {
626
659
  unified: mapHuggingFaceResponsesFinishReason(
627
- (_b = (_a = value.response.incomplete_details) == null ? void 0 : _a.reason) != null ? _b : "stop"
660
+ (_b2 = (_a2 = value.response.incomplete_details) == null ? void 0 : _a2.reason) != null ? _b2 : "stop"
628
661
  ),
629
662
  raw: (_d = (_c = value.response.incomplete_details) == null ? void 0 : _c.reason) != null ? _d : void 0
630
663
  };
@@ -676,231 +709,225 @@ var HuggingFaceResponsesLanguageModel = class {
676
709
  };
677
710
  }
678
711
  };
679
- var huggingfaceResponsesProviderOptionsSchema = import_v42.z.object({
680
- metadata: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
681
- instructions: import_v42.z.string().optional(),
682
- strictJsonSchema: import_v42.z.boolean().optional(),
683
- reasoningEffort: import_v42.z.string().optional()
684
- });
685
- var huggingfaceResponsesOutputSchema = import_v42.z.discriminatedUnion("type", [
686
- import_v42.z.object({
687
- type: import_v42.z.literal("message"),
688
- id: import_v42.z.string(),
689
- role: import_v42.z.string().optional(),
690
- status: import_v42.z.string().optional(),
691
- content: import_v42.z.array(
692
- import_v42.z.object({
693
- type: import_v42.z.literal("output_text"),
694
- text: import_v42.z.string(),
695
- annotations: import_v42.z.array(import_v42.z.any()).optional()
712
+ var huggingfaceResponsesOutputSchema = z3.discriminatedUnion("type", [
713
+ z3.object({
714
+ type: z3.literal("message"),
715
+ id: z3.string(),
716
+ role: z3.string().optional(),
717
+ status: z3.string().optional(),
718
+ content: z3.array(
719
+ z3.object({
720
+ type: z3.literal("output_text"),
721
+ text: z3.string(),
722
+ annotations: z3.array(z3.any()).optional()
696
723
  })
697
724
  )
698
725
  }),
699
- import_v42.z.object({
700
- type: import_v42.z.literal("reasoning"),
701
- id: import_v42.z.string(),
702
- status: import_v42.z.string().optional(),
703
- content: import_v42.z.array(
704
- import_v42.z.object({
705
- type: import_v42.z.literal("reasoning_text"),
706
- text: import_v42.z.string()
726
+ z3.object({
727
+ type: z3.literal("reasoning"),
728
+ id: z3.string(),
729
+ status: z3.string().optional(),
730
+ content: z3.array(
731
+ z3.object({
732
+ type: z3.literal("reasoning_text"),
733
+ text: z3.string()
707
734
  })
708
735
  ),
709
- summary: import_v42.z.array(
710
- import_v42.z.object({
711
- type: import_v42.z.literal("reasoning_summary"),
712
- text: import_v42.z.string()
736
+ summary: z3.array(
737
+ z3.object({
738
+ type: z3.literal("reasoning_summary"),
739
+ text: z3.string()
713
740
  }).optional()
714
741
  ).optional()
715
742
  }),
716
- import_v42.z.object({
717
- type: import_v42.z.literal("function_call"),
718
- id: import_v42.z.string(),
719
- call_id: import_v42.z.string(),
720
- name: import_v42.z.string(),
721
- arguments: import_v42.z.string(),
722
- output: import_v42.z.string().optional(),
723
- status: import_v42.z.string().optional()
743
+ z3.object({
744
+ type: z3.literal("function_call"),
745
+ id: z3.string(),
746
+ call_id: z3.string(),
747
+ name: z3.string(),
748
+ arguments: z3.string(),
749
+ output: z3.string().optional(),
750
+ status: z3.string().optional()
724
751
  }),
725
- import_v42.z.object({
726
- type: import_v42.z.literal("mcp_call"),
727
- id: import_v42.z.string(),
728
- name: import_v42.z.string(),
729
- arguments: import_v42.z.string(),
730
- output: import_v42.z.string().optional(),
731
- status: import_v42.z.string().optional()
752
+ z3.object({
753
+ type: z3.literal("mcp_call"),
754
+ id: z3.string(),
755
+ name: z3.string(),
756
+ arguments: z3.string(),
757
+ output: z3.string().optional(),
758
+ status: z3.string().optional()
732
759
  }),
733
- import_v42.z.object({
734
- type: import_v42.z.literal("mcp_list_tools"),
735
- id: import_v42.z.string(),
736
- server_label: import_v42.z.string(),
737
- tools: import_v42.z.array(import_v42.z.any()).optional(),
738
- status: import_v42.z.string().optional()
760
+ z3.object({
761
+ type: z3.literal("mcp_list_tools"),
762
+ id: z3.string(),
763
+ server_label: z3.string(),
764
+ tools: z3.array(z3.any()).optional(),
765
+ status: z3.string().optional()
739
766
  })
740
767
  ]);
741
- var huggingfaceResponsesResponseSchema = import_v42.z.object({
742
- id: import_v42.z.string(),
743
- model: import_v42.z.string(),
744
- object: import_v42.z.string(),
745
- created_at: import_v42.z.number(),
746
- status: import_v42.z.string(),
747
- error: import_v42.z.any().nullable(),
748
- instructions: import_v42.z.any().nullable(),
749
- max_output_tokens: import_v42.z.any().nullable(),
750
- metadata: import_v42.z.any().nullable(),
751
- tool_choice: import_v42.z.any(),
752
- tools: import_v42.z.array(import_v42.z.any()),
753
- temperature: import_v42.z.number(),
754
- top_p: import_v42.z.number(),
755
- incomplete_details: import_v42.z.object({
756
- reason: import_v42.z.string()
768
+ var huggingfaceResponsesResponseSchema = z3.object({
769
+ id: z3.string(),
770
+ model: z3.string(),
771
+ object: z3.string(),
772
+ created_at: z3.number(),
773
+ status: z3.string(),
774
+ error: z3.any().nullable(),
775
+ instructions: z3.any().nullable(),
776
+ max_output_tokens: z3.any().nullable(),
777
+ metadata: z3.any().nullable(),
778
+ tool_choice: z3.any(),
779
+ tools: z3.array(z3.any()),
780
+ temperature: z3.number(),
781
+ top_p: z3.number(),
782
+ incomplete_details: z3.object({
783
+ reason: z3.string()
757
784
  }).nullable().optional(),
758
- usage: import_v42.z.object({
759
- input_tokens: import_v42.z.number(),
760
- input_tokens_details: import_v42.z.object({
761
- cached_tokens: import_v42.z.number()
785
+ usage: z3.object({
786
+ input_tokens: z3.number(),
787
+ input_tokens_details: z3.object({
788
+ cached_tokens: z3.number()
762
789
  }).optional(),
763
- output_tokens: import_v42.z.number(),
764
- output_tokens_details: import_v42.z.object({
765
- reasoning_tokens: import_v42.z.number()
790
+ output_tokens: z3.number(),
791
+ output_tokens_details: z3.object({
792
+ reasoning_tokens: z3.number()
766
793
  }).optional(),
767
- total_tokens: import_v42.z.number()
794
+ total_tokens: z3.number()
768
795
  }).nullable().optional(),
769
- output: import_v42.z.array(huggingfaceResponsesOutputSchema),
770
- output_text: import_v42.z.string().nullable().optional()
796
+ output: z3.array(huggingfaceResponsesOutputSchema),
797
+ output_text: z3.string().nullable().optional()
771
798
  });
772
- var responseOutputItemAddedSchema = import_v42.z.object({
773
- type: import_v42.z.literal("response.output_item.added"),
774
- output_index: import_v42.z.number(),
775
- item: import_v42.z.discriminatedUnion("type", [
776
- import_v42.z.object({
777
- type: import_v42.z.literal("message"),
778
- id: import_v42.z.string(),
779
- role: import_v42.z.string().optional(),
780
- status: import_v42.z.string().optional(),
781
- content: import_v42.z.array(import_v42.z.any()).optional()
799
+ var responseOutputItemAddedSchema = z3.object({
800
+ type: z3.literal("response.output_item.added"),
801
+ output_index: z3.number(),
802
+ item: z3.discriminatedUnion("type", [
803
+ z3.object({
804
+ type: z3.literal("message"),
805
+ id: z3.string(),
806
+ role: z3.string().optional(),
807
+ status: z3.string().optional(),
808
+ content: z3.array(z3.any()).optional()
782
809
  }),
783
- import_v42.z.object({
784
- type: import_v42.z.literal("reasoning"),
785
- id: import_v42.z.string(),
786
- status: import_v42.z.string().optional(),
787
- content: import_v42.z.array(import_v42.z.any()).optional(),
788
- summary: import_v42.z.array(import_v42.z.any()).optional()
810
+ z3.object({
811
+ type: z3.literal("reasoning"),
812
+ id: z3.string(),
813
+ status: z3.string().optional(),
814
+ content: z3.array(z3.any()).optional(),
815
+ summary: z3.array(z3.any()).optional()
789
816
  }),
790
- import_v42.z.object({
791
- type: import_v42.z.literal("mcp_list_tools"),
792
- id: import_v42.z.string(),
793
- server_label: import_v42.z.string(),
794
- tools: import_v42.z.array(import_v42.z.any()).optional(),
795
- error: import_v42.z.string().optional()
817
+ z3.object({
818
+ type: z3.literal("mcp_list_tools"),
819
+ id: z3.string(),
820
+ server_label: z3.string(),
821
+ tools: z3.array(z3.any()).optional(),
822
+ error: z3.string().optional()
796
823
  }),
797
- import_v42.z.object({
798
- type: import_v42.z.literal("mcp_call"),
799
- id: import_v42.z.string(),
800
- server_label: import_v42.z.string(),
801
- name: import_v42.z.string(),
802
- arguments: import_v42.z.string(),
803
- output: import_v42.z.string().optional(),
804
- error: import_v42.z.string().optional()
824
+ z3.object({
825
+ type: z3.literal("mcp_call"),
826
+ id: z3.string(),
827
+ server_label: z3.string(),
828
+ name: z3.string(),
829
+ arguments: z3.string(),
830
+ output: z3.string().optional(),
831
+ error: z3.string().optional()
805
832
  }),
806
- import_v42.z.object({
807
- type: import_v42.z.literal("function_call"),
808
- id: import_v42.z.string(),
809
- call_id: import_v42.z.string(),
810
- name: import_v42.z.string(),
811
- arguments: import_v42.z.string(),
812
- output: import_v42.z.string().optional(),
813
- error: import_v42.z.string().optional()
833
+ z3.object({
834
+ type: z3.literal("function_call"),
835
+ id: z3.string(),
836
+ call_id: z3.string(),
837
+ name: z3.string(),
838
+ arguments: z3.string(),
839
+ output: z3.string().optional(),
840
+ error: z3.string().optional()
814
841
  })
815
842
  ]),
816
- sequence_number: import_v42.z.number()
843
+ sequence_number: z3.number()
817
844
  });
818
- var responseOutputItemDoneSchema = import_v42.z.object({
819
- type: import_v42.z.literal("response.output_item.done"),
820
- output_index: import_v42.z.number(),
821
- item: import_v42.z.discriminatedUnion("type", [
822
- import_v42.z.object({
823
- type: import_v42.z.literal("message"),
824
- id: import_v42.z.string(),
825
- role: import_v42.z.string().optional(),
826
- status: import_v42.z.string().optional(),
827
- content: import_v42.z.array(import_v42.z.any()).optional()
845
+ var responseOutputItemDoneSchema = z3.object({
846
+ type: z3.literal("response.output_item.done"),
847
+ output_index: z3.number(),
848
+ item: z3.discriminatedUnion("type", [
849
+ z3.object({
850
+ type: z3.literal("message"),
851
+ id: z3.string(),
852
+ role: z3.string().optional(),
853
+ status: z3.string().optional(),
854
+ content: z3.array(z3.any()).optional()
828
855
  }),
829
- import_v42.z.object({
830
- type: import_v42.z.literal("mcp_list_tools"),
831
- id: import_v42.z.string(),
832
- server_label: import_v42.z.string(),
833
- tools: import_v42.z.array(import_v42.z.any()).optional(),
834
- error: import_v42.z.string().optional()
856
+ z3.object({
857
+ type: z3.literal("mcp_list_tools"),
858
+ id: z3.string(),
859
+ server_label: z3.string(),
860
+ tools: z3.array(z3.any()).optional(),
861
+ error: z3.string().optional()
835
862
  }),
836
- import_v42.z.object({
837
- type: import_v42.z.literal("mcp_call"),
838
- id: import_v42.z.string(),
839
- server_label: import_v42.z.string(),
840
- name: import_v42.z.string(),
841
- arguments: import_v42.z.string(),
842
- output: import_v42.z.string().optional(),
843
- error: import_v42.z.string().optional()
863
+ z3.object({
864
+ type: z3.literal("mcp_call"),
865
+ id: z3.string(),
866
+ server_label: z3.string(),
867
+ name: z3.string(),
868
+ arguments: z3.string(),
869
+ output: z3.string().optional(),
870
+ error: z3.string().optional()
844
871
  }),
845
- import_v42.z.object({
846
- type: import_v42.z.literal("function_call"),
847
- id: import_v42.z.string(),
848
- call_id: import_v42.z.string(),
849
- name: import_v42.z.string(),
850
- arguments: import_v42.z.string(),
851
- output: import_v42.z.string().optional(),
852
- error: import_v42.z.string().optional()
872
+ z3.object({
873
+ type: z3.literal("function_call"),
874
+ id: z3.string(),
875
+ call_id: z3.string(),
876
+ name: z3.string(),
877
+ arguments: z3.string(),
878
+ output: z3.string().optional(),
879
+ error: z3.string().optional()
853
880
  }),
854
- import_v42.z.object({
855
- type: import_v42.z.literal("reasoning"),
856
- id: import_v42.z.string(),
857
- status: import_v42.z.string().optional(),
858
- content: import_v42.z.array(import_v42.z.any()).optional(),
859
- summary: import_v42.z.array(import_v42.z.any()).optional()
881
+ z3.object({
882
+ type: z3.literal("reasoning"),
883
+ id: z3.string(),
884
+ status: z3.string().optional(),
885
+ content: z3.array(z3.any()).optional(),
886
+ summary: z3.array(z3.any()).optional()
860
887
  })
861
888
  ]),
862
- sequence_number: import_v42.z.number()
889
+ sequence_number: z3.number()
863
890
  });
864
- var textDeltaChunkSchema = import_v42.z.object({
865
- type: import_v42.z.literal("response.output_text.delta"),
866
- item_id: import_v42.z.string(),
867
- output_index: import_v42.z.number(),
868
- content_index: import_v42.z.number(),
869
- delta: import_v42.z.string(),
870
- sequence_number: import_v42.z.number()
891
+ var textDeltaChunkSchema = z3.object({
892
+ type: z3.literal("response.output_text.delta"),
893
+ item_id: z3.string(),
894
+ output_index: z3.number(),
895
+ content_index: z3.number(),
896
+ delta: z3.string(),
897
+ sequence_number: z3.number()
871
898
  });
872
- var reasoningTextDeltaChunkSchema = import_v42.z.object({
873
- type: import_v42.z.literal("response.reasoning_text.delta"),
874
- item_id: import_v42.z.string(),
875
- output_index: import_v42.z.number(),
876
- content_index: import_v42.z.number(),
877
- delta: import_v42.z.string(),
878
- sequence_number: import_v42.z.number()
899
+ var reasoningTextDeltaChunkSchema = z3.object({
900
+ type: z3.literal("response.reasoning_text.delta"),
901
+ item_id: z3.string(),
902
+ output_index: z3.number(),
903
+ content_index: z3.number(),
904
+ delta: z3.string(),
905
+ sequence_number: z3.number()
879
906
  });
880
- var reasoningTextEndChunkSchema = import_v42.z.object({
881
- type: import_v42.z.literal("response.reasoning_text.done"),
882
- item_id: import_v42.z.string(),
883
- output_index: import_v42.z.number(),
884
- content_index: import_v42.z.number(),
885
- text: import_v42.z.string(),
886
- sequence_number: import_v42.z.number()
907
+ var reasoningTextEndChunkSchema = z3.object({
908
+ type: z3.literal("response.reasoning_text.done"),
909
+ item_id: z3.string(),
910
+ output_index: z3.number(),
911
+ content_index: z3.number(),
912
+ text: z3.string(),
913
+ sequence_number: z3.number()
887
914
  });
888
- var responseCompletedChunkSchema = import_v42.z.object({
889
- type: import_v42.z.literal("response.completed"),
915
+ var responseCompletedChunkSchema = z3.object({
916
+ type: z3.literal("response.completed"),
890
917
  response: huggingfaceResponsesResponseSchema,
891
- sequence_number: import_v42.z.number()
918
+ sequence_number: z3.number()
892
919
  });
893
- var responseCreatedChunkSchema = import_v42.z.object({
894
- type: import_v42.z.literal("response.created"),
895
- response: import_v42.z.object({
896
- id: import_v42.z.string(),
897
- object: import_v42.z.string(),
898
- created_at: import_v42.z.number(),
899
- status: import_v42.z.string(),
900
- model: import_v42.z.string()
920
+ var responseCreatedChunkSchema = z3.object({
921
+ type: z3.literal("response.created"),
922
+ response: z3.object({
923
+ id: z3.string(),
924
+ object: z3.string(),
925
+ created_at: z3.number(),
926
+ status: z3.string(),
927
+ model: z3.string()
901
928
  })
902
929
  });
903
- var huggingfaceResponsesChunkSchema = import_v42.z.union([
930
+ var huggingfaceResponsesChunkSchema = z3.union([
904
931
  responseOutputItemAddedSchema,
905
932
  responseOutputItemDoneSchema,
906
933
  reasoningTextDeltaChunkSchema,
@@ -908,7 +935,7 @@ var huggingfaceResponsesChunkSchema = import_v42.z.union([
908
935
  textDeltaChunkSchema,
909
936
  responseCompletedChunkSchema,
910
937
  responseCreatedChunkSchema,
911
- import_v42.z.object({ type: import_v42.z.string() }).loose()
938
+ z3.object({ type: z3.string() }).loose()
912
939
  // fallback for unknown chunks
913
940
  ]);
914
941
  function isResponseOutputItemAddedChunk(chunk) {
@@ -936,9 +963,9 @@ function isResponseCreatedChunk(chunk) {
936
963
  // src/huggingface-provider.ts
937
964
  function createHuggingFace(options = {}) {
938
965
  var _a;
939
- const baseURL = (_a = (0, import_provider_utils3.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://router.huggingface.co/v1";
966
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://router.huggingface.co/v1";
940
967
  const getHeaders = () => ({
941
- Authorization: `Bearer ${(0, import_provider_utils3.loadApiKey)({
968
+ Authorization: `Bearer ${loadApiKey({
942
969
  apiKey: options.apiKey,
943
970
  environmentVariableName: "HUGGINGFACE_API_KEY",
944
971
  description: "Hugging Face"
@@ -952,7 +979,7 @@ function createHuggingFace(options = {}) {
952
979
  url: ({ path }) => `${baseURL}${path}`,
953
980
  headers: getHeaders,
954
981
  fetch: options.fetch,
955
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils3.generateId
982
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2
956
983
  });
957
984
  };
958
985
  const provider = (modelId) => createResponsesModel(modelId);
@@ -960,7 +987,7 @@ function createHuggingFace(options = {}) {
960
987
  provider.languageModel = createResponsesModel;
961
988
  provider.responses = createResponsesModel;
962
989
  provider.embeddingModel = (modelId) => {
963
- throw new import_provider3.NoSuchModelError({
990
+ throw new NoSuchModelError({
964
991
  modelId,
965
992
  modelType: "embeddingModel",
966
993
  message: "Hugging Face Responses API does not support text embeddings. Use the Hugging Face Inference API directly for embeddings."
@@ -968,7 +995,7 @@ function createHuggingFace(options = {}) {
968
995
  };
969
996
  provider.textEmbeddingModel = provider.embeddingModel;
970
997
  provider.imageModel = (modelId) => {
971
- throw new import_provider3.NoSuchModelError({
998
+ throw new NoSuchModelError({
972
999
  modelId,
973
1000
  modelType: "imageModel",
974
1001
  message: "Hugging Face Responses API does not support image generation. Use the Hugging Face Inference API directly for image models."
@@ -976,10 +1003,14 @@ function createHuggingFace(options = {}) {
976
1003
  };
977
1004
  return provider;
978
1005
  }
979
- var huggingface = createHuggingFace();
980
- // Annotate the CommonJS export names for ESM import in node:
981
- 0 && (module.exports = {
1006
+ var huggingFace = createHuggingFace();
1007
+
1008
+ // src/version.ts
1009
+ var VERSION = true ? "2.0.0-canary.37" : "0.0.0-test";
1010
+ export {
1011
+ VERSION,
982
1012
  createHuggingFace,
983
- huggingface
984
- });
1013
+ huggingFace,
1014
+ huggingFace as huggingface
1015
+ };
985
1016
  //# sourceMappingURL=index.js.map