@ai-sdk/huggingface 2.0.0-beta.23 → 2.0.0-beta.25

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_utils4 = 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_utils3 = 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 z2 } 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,8 +80,10 @@ 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");
93
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
83
+ import {
84
+ UnsupportedFunctionalityError
85
+ } from "@ai-sdk/provider";
86
+ import { isProviderReference } from "@ai-sdk/provider-utils";
94
87
  async function convertToHuggingFaceResponsesMessages({
95
88
  prompt
96
89
  }) {
@@ -111,8 +104,8 @@ async function convertToHuggingFaceResponsesMessages({
111
104
  return { type: "input_text", text: part.text };
112
105
  }
113
106
  case "file": {
114
- if ((0, import_provider_utils2.isProviderReference)(part.data)) {
115
- throw new import_provider.UnsupportedFunctionalityError({
107
+ if (isProviderReference(part.data)) {
108
+ throw new UnsupportedFunctionalityError({
116
109
  functionality: "file parts with provider references"
117
110
  });
118
111
  }
@@ -123,7 +116,7 @@ async function convertToHuggingFaceResponsesMessages({
123
116
  image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`
124
117
  };
125
118
  } else {
126
- throw new import_provider.UnsupportedFunctionalityError({
119
+ throw new UnsupportedFunctionalityError({
127
120
  functionality: `file part media type ${part.mediaType}`
128
121
  });
129
122
  }
@@ -259,7 +252,7 @@ function mapHuggingFaceResponsesFinishReason(finishReason) {
259
252
  }
260
253
 
261
254
  // src/responses/huggingface-responses-language-model.ts
262
- var HuggingFaceResponsesLanguageModel = class {
255
+ var HuggingFaceResponsesLanguageModel = class _HuggingFaceResponsesLanguageModel {
263
256
  constructor(modelId, config) {
264
257
  this.specificationVersion = "v4";
265
258
  this.supportedUrls = {
@@ -268,6 +261,18 @@ var HuggingFaceResponsesLanguageModel = class {
268
261
  this.modelId = modelId;
269
262
  this.config = config;
270
263
  }
264
+ static [WORKFLOW_SERIALIZE](model) {
265
+ return serializeModelOptions({
266
+ modelId: model.modelId,
267
+ config: model.config
268
+ });
269
+ }
270
+ static [WORKFLOW_DESERIALIZE](options) {
271
+ return new _HuggingFaceResponsesLanguageModel(
272
+ options.modelId,
273
+ options.config
274
+ );
275
+ }
271
276
  get provider() {
272
277
  return this.config.provider;
273
278
  }
@@ -307,7 +312,7 @@ var HuggingFaceResponsesLanguageModel = class {
307
312
  prompt
308
313
  });
309
314
  warnings.push(...messageWarnings);
310
- const huggingfaceOptions = await (0, import_provider_utils3.parseProviderOptions)({
315
+ const huggingfaceOptions = await parseProviderOptions({
311
316
  provider: "huggingface",
312
317
  providerOptions,
313
318
  schema: huggingfaceResponsesProviderOptionsSchema
@@ -354,7 +359,7 @@ var HuggingFaceResponsesLanguageModel = class {
354
359
  return { args: baseArgs, warnings };
355
360
  }
356
361
  async doGenerate(options) {
357
- var _a, _b, _c, _d, _e, _f, _g;
362
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
358
363
  const { args, warnings } = await this.getArgs(options);
359
364
  const body = {
360
365
  ...args,
@@ -368,19 +373,19 @@ var HuggingFaceResponsesLanguageModel = class {
368
373
  value: response,
369
374
  responseHeaders,
370
375
  rawValue: rawResponse
371
- } = await (0, import_provider_utils3.postJsonToApi)({
376
+ } = await postJsonToApi({
372
377
  url,
373
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
378
+ headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
374
379
  body,
375
380
  failedResponseHandler: huggingfaceFailedResponseHandler,
376
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
381
+ successfulResponseHandler: createJsonResponseHandler(
377
382
  huggingfaceResponsesResponseSchema
378
383
  ),
379
384
  abortSignal: options.abortSignal,
380
385
  fetch: this.config.fetch
381
386
  });
382
387
  if (response.error) {
383
- throw new import_provider2.APICallError({
388
+ throw new APICallError({
384
389
  message: response.error.message,
385
390
  url,
386
391
  requestBodyValues: body,
@@ -409,7 +414,7 @@ var HuggingFaceResponsesLanguageModel = class {
409
414
  content.push({
410
415
  type: "source",
411
416
  sourceType: "url",
412
- id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : (0, import_provider_utils3.generateId)(),
417
+ id: (_e = (_d = (_c = this.config).generateId) == null ? void 0 : _d.call(_c)) != null ? _e : generateId(),
413
418
  url: annotation.url,
414
419
  title: annotation.title
415
420
  });
@@ -494,9 +499,9 @@ var HuggingFaceResponsesLanguageModel = class {
494
499
  content,
495
500
  finishReason: {
496
501
  unified: mapHuggingFaceResponsesFinishReason(
497
- (_e = (_d = response.incomplete_details) == null ? void 0 : _d.reason) != null ? _e : "stop"
502
+ (_g = (_f = response.incomplete_details) == null ? void 0 : _f.reason) != null ? _g : "stop"
498
503
  ),
499
- raw: (_g = (_f = response.incomplete_details) == null ? void 0 : _f.reason) != null ? _g : void 0
504
+ raw: (_i = (_h = response.incomplete_details) == null ? void 0 : _h.reason) != null ? _i : void 0
500
505
  },
501
506
  usage: convertHuggingFaceResponsesUsage(response.usage),
502
507
  request: { body },
@@ -516,20 +521,21 @@ var HuggingFaceResponsesLanguageModel = class {
516
521
  };
517
522
  }
518
523
  async doStream(options) {
524
+ var _a, _b;
519
525
  const { args, warnings } = await this.getArgs(options);
520
526
  const body = {
521
527
  ...args,
522
528
  stream: true
523
529
  };
524
- const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
530
+ const { value: response, responseHeaders } = await postJsonToApi({
525
531
  url: this.config.url({
526
532
  path: "/responses",
527
533
  modelId: this.modelId
528
534
  }),
529
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
535
+ headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
530
536
  body,
531
537
  failedResponseHandler: huggingfaceFailedResponseHandler,
532
- successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
538
+ successfulResponseHandler: createEventSourceResponseHandler(
533
539
  huggingfaceResponsesChunkSchema
534
540
  ),
535
541
  abortSignal: options.abortSignal,
@@ -548,7 +554,7 @@ var HuggingFaceResponsesLanguageModel = class {
548
554
  controller.enqueue({ type: "stream-start", warnings });
549
555
  },
550
556
  transform(chunk, controller) {
551
- var _a, _b, _c, _d;
557
+ var _a2, _b2, _c, _d;
552
558
  if (!chunk.success) {
553
559
  finishReason = {
554
560
  unified: "error",
@@ -630,7 +636,7 @@ var HuggingFaceResponsesLanguageModel = class {
630
636
  responseId = value.response.id;
631
637
  finishReason = {
632
638
  unified: mapHuggingFaceResponsesFinishReason(
633
- (_b = (_a = value.response.incomplete_details) == null ? void 0 : _a.reason) != null ? _b : "stop"
639
+ (_b2 = (_a2 = value.response.incomplete_details) == null ? void 0 : _a2.reason) != null ? _b2 : "stop"
634
640
  ),
635
641
  raw: (_d = (_c = value.response.incomplete_details) == null ? void 0 : _c.reason) != null ? _d : void 0
636
642
  };
@@ -682,231 +688,231 @@ var HuggingFaceResponsesLanguageModel = class {
682
688
  };
683
689
  }
684
690
  };
685
- var huggingfaceResponsesProviderOptionsSchema = import_v42.z.object({
686
- metadata: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
687
- instructions: import_v42.z.string().optional(),
688
- strictJsonSchema: import_v42.z.boolean().optional(),
689
- reasoningEffort: import_v42.z.string().optional()
691
+ var huggingfaceResponsesProviderOptionsSchema = z2.object({
692
+ metadata: z2.record(z2.string(), z2.string()).optional(),
693
+ instructions: z2.string().optional(),
694
+ strictJsonSchema: z2.boolean().optional(),
695
+ reasoningEffort: z2.string().optional()
690
696
  });
691
- var huggingfaceResponsesOutputSchema = import_v42.z.discriminatedUnion("type", [
692
- import_v42.z.object({
693
- type: import_v42.z.literal("message"),
694
- id: import_v42.z.string(),
695
- role: import_v42.z.string().optional(),
696
- status: import_v42.z.string().optional(),
697
- content: import_v42.z.array(
698
- import_v42.z.object({
699
- type: import_v42.z.literal("output_text"),
700
- text: import_v42.z.string(),
701
- annotations: import_v42.z.array(import_v42.z.any()).optional()
697
+ var huggingfaceResponsesOutputSchema = z2.discriminatedUnion("type", [
698
+ z2.object({
699
+ type: z2.literal("message"),
700
+ id: z2.string(),
701
+ role: z2.string().optional(),
702
+ status: z2.string().optional(),
703
+ content: z2.array(
704
+ z2.object({
705
+ type: z2.literal("output_text"),
706
+ text: z2.string(),
707
+ annotations: z2.array(z2.any()).optional()
702
708
  })
703
709
  )
704
710
  }),
705
- import_v42.z.object({
706
- type: import_v42.z.literal("reasoning"),
707
- id: import_v42.z.string(),
708
- status: import_v42.z.string().optional(),
709
- content: import_v42.z.array(
710
- import_v42.z.object({
711
- type: import_v42.z.literal("reasoning_text"),
712
- text: import_v42.z.string()
711
+ z2.object({
712
+ type: z2.literal("reasoning"),
713
+ id: z2.string(),
714
+ status: z2.string().optional(),
715
+ content: z2.array(
716
+ z2.object({
717
+ type: z2.literal("reasoning_text"),
718
+ text: z2.string()
713
719
  })
714
720
  ),
715
- summary: import_v42.z.array(
716
- import_v42.z.object({
717
- type: import_v42.z.literal("reasoning_summary"),
718
- text: import_v42.z.string()
721
+ summary: z2.array(
722
+ z2.object({
723
+ type: z2.literal("reasoning_summary"),
724
+ text: z2.string()
719
725
  }).optional()
720
726
  ).optional()
721
727
  }),
722
- import_v42.z.object({
723
- type: import_v42.z.literal("function_call"),
724
- id: import_v42.z.string(),
725
- call_id: import_v42.z.string(),
726
- name: import_v42.z.string(),
727
- arguments: import_v42.z.string(),
728
- output: import_v42.z.string().optional(),
729
- status: import_v42.z.string().optional()
728
+ z2.object({
729
+ type: z2.literal("function_call"),
730
+ id: z2.string(),
731
+ call_id: z2.string(),
732
+ name: z2.string(),
733
+ arguments: z2.string(),
734
+ output: z2.string().optional(),
735
+ status: z2.string().optional()
730
736
  }),
731
- import_v42.z.object({
732
- type: import_v42.z.literal("mcp_call"),
733
- id: import_v42.z.string(),
734
- name: import_v42.z.string(),
735
- arguments: import_v42.z.string(),
736
- output: import_v42.z.string().optional(),
737
- status: import_v42.z.string().optional()
737
+ z2.object({
738
+ type: z2.literal("mcp_call"),
739
+ id: z2.string(),
740
+ name: z2.string(),
741
+ arguments: z2.string(),
742
+ output: z2.string().optional(),
743
+ status: z2.string().optional()
738
744
  }),
739
- import_v42.z.object({
740
- type: import_v42.z.literal("mcp_list_tools"),
741
- id: import_v42.z.string(),
742
- server_label: import_v42.z.string(),
743
- tools: import_v42.z.array(import_v42.z.any()).optional(),
744
- status: import_v42.z.string().optional()
745
+ z2.object({
746
+ type: z2.literal("mcp_list_tools"),
747
+ id: z2.string(),
748
+ server_label: z2.string(),
749
+ tools: z2.array(z2.any()).optional(),
750
+ status: z2.string().optional()
745
751
  })
746
752
  ]);
747
- var huggingfaceResponsesResponseSchema = import_v42.z.object({
748
- id: import_v42.z.string(),
749
- model: import_v42.z.string(),
750
- object: import_v42.z.string(),
751
- created_at: import_v42.z.number(),
752
- status: import_v42.z.string(),
753
- error: import_v42.z.any().nullable(),
754
- instructions: import_v42.z.any().nullable(),
755
- max_output_tokens: import_v42.z.any().nullable(),
756
- metadata: import_v42.z.any().nullable(),
757
- tool_choice: import_v42.z.any(),
758
- tools: import_v42.z.array(import_v42.z.any()),
759
- temperature: import_v42.z.number(),
760
- top_p: import_v42.z.number(),
761
- incomplete_details: import_v42.z.object({
762
- reason: import_v42.z.string()
753
+ var huggingfaceResponsesResponseSchema = z2.object({
754
+ id: z2.string(),
755
+ model: z2.string(),
756
+ object: z2.string(),
757
+ created_at: z2.number(),
758
+ status: z2.string(),
759
+ error: z2.any().nullable(),
760
+ instructions: z2.any().nullable(),
761
+ max_output_tokens: z2.any().nullable(),
762
+ metadata: z2.any().nullable(),
763
+ tool_choice: z2.any(),
764
+ tools: z2.array(z2.any()),
765
+ temperature: z2.number(),
766
+ top_p: z2.number(),
767
+ incomplete_details: z2.object({
768
+ reason: z2.string()
763
769
  }).nullable().optional(),
764
- usage: import_v42.z.object({
765
- input_tokens: import_v42.z.number(),
766
- input_tokens_details: import_v42.z.object({
767
- cached_tokens: import_v42.z.number()
770
+ usage: z2.object({
771
+ input_tokens: z2.number(),
772
+ input_tokens_details: z2.object({
773
+ cached_tokens: z2.number()
768
774
  }).optional(),
769
- output_tokens: import_v42.z.number(),
770
- output_tokens_details: import_v42.z.object({
771
- reasoning_tokens: import_v42.z.number()
775
+ output_tokens: z2.number(),
776
+ output_tokens_details: z2.object({
777
+ reasoning_tokens: z2.number()
772
778
  }).optional(),
773
- total_tokens: import_v42.z.number()
779
+ total_tokens: z2.number()
774
780
  }).nullable().optional(),
775
- output: import_v42.z.array(huggingfaceResponsesOutputSchema),
776
- output_text: import_v42.z.string().nullable().optional()
781
+ output: z2.array(huggingfaceResponsesOutputSchema),
782
+ output_text: z2.string().nullable().optional()
777
783
  });
778
- var responseOutputItemAddedSchema = import_v42.z.object({
779
- type: import_v42.z.literal("response.output_item.added"),
780
- output_index: import_v42.z.number(),
781
- item: import_v42.z.discriminatedUnion("type", [
782
- import_v42.z.object({
783
- type: import_v42.z.literal("message"),
784
- id: import_v42.z.string(),
785
- role: import_v42.z.string().optional(),
786
- status: import_v42.z.string().optional(),
787
- content: import_v42.z.array(import_v42.z.any()).optional()
784
+ var responseOutputItemAddedSchema = z2.object({
785
+ type: z2.literal("response.output_item.added"),
786
+ output_index: z2.number(),
787
+ item: z2.discriminatedUnion("type", [
788
+ z2.object({
789
+ type: z2.literal("message"),
790
+ id: z2.string(),
791
+ role: z2.string().optional(),
792
+ status: z2.string().optional(),
793
+ content: z2.array(z2.any()).optional()
788
794
  }),
789
- import_v42.z.object({
790
- type: import_v42.z.literal("reasoning"),
791
- id: import_v42.z.string(),
792
- status: import_v42.z.string().optional(),
793
- content: import_v42.z.array(import_v42.z.any()).optional(),
794
- summary: import_v42.z.array(import_v42.z.any()).optional()
795
+ z2.object({
796
+ type: z2.literal("reasoning"),
797
+ id: z2.string(),
798
+ status: z2.string().optional(),
799
+ content: z2.array(z2.any()).optional(),
800
+ summary: z2.array(z2.any()).optional()
795
801
  }),
796
- import_v42.z.object({
797
- type: import_v42.z.literal("mcp_list_tools"),
798
- id: import_v42.z.string(),
799
- server_label: import_v42.z.string(),
800
- tools: import_v42.z.array(import_v42.z.any()).optional(),
801
- error: import_v42.z.string().optional()
802
+ z2.object({
803
+ type: z2.literal("mcp_list_tools"),
804
+ id: z2.string(),
805
+ server_label: z2.string(),
806
+ tools: z2.array(z2.any()).optional(),
807
+ error: z2.string().optional()
802
808
  }),
803
- import_v42.z.object({
804
- type: import_v42.z.literal("mcp_call"),
805
- id: import_v42.z.string(),
806
- server_label: import_v42.z.string(),
807
- name: import_v42.z.string(),
808
- arguments: import_v42.z.string(),
809
- output: import_v42.z.string().optional(),
810
- error: import_v42.z.string().optional()
809
+ z2.object({
810
+ type: z2.literal("mcp_call"),
811
+ id: z2.string(),
812
+ server_label: z2.string(),
813
+ name: z2.string(),
814
+ arguments: z2.string(),
815
+ output: z2.string().optional(),
816
+ error: z2.string().optional()
811
817
  }),
812
- import_v42.z.object({
813
- type: import_v42.z.literal("function_call"),
814
- id: import_v42.z.string(),
815
- call_id: import_v42.z.string(),
816
- name: import_v42.z.string(),
817
- arguments: import_v42.z.string(),
818
- output: import_v42.z.string().optional(),
819
- error: import_v42.z.string().optional()
818
+ z2.object({
819
+ type: z2.literal("function_call"),
820
+ id: z2.string(),
821
+ call_id: z2.string(),
822
+ name: z2.string(),
823
+ arguments: z2.string(),
824
+ output: z2.string().optional(),
825
+ error: z2.string().optional()
820
826
  })
821
827
  ]),
822
- sequence_number: import_v42.z.number()
828
+ sequence_number: z2.number()
823
829
  });
824
- var responseOutputItemDoneSchema = import_v42.z.object({
825
- type: import_v42.z.literal("response.output_item.done"),
826
- output_index: import_v42.z.number(),
827
- item: import_v42.z.discriminatedUnion("type", [
828
- import_v42.z.object({
829
- type: import_v42.z.literal("message"),
830
- id: import_v42.z.string(),
831
- role: import_v42.z.string().optional(),
832
- status: import_v42.z.string().optional(),
833
- content: import_v42.z.array(import_v42.z.any()).optional()
830
+ var responseOutputItemDoneSchema = z2.object({
831
+ type: z2.literal("response.output_item.done"),
832
+ output_index: z2.number(),
833
+ item: z2.discriminatedUnion("type", [
834
+ z2.object({
835
+ type: z2.literal("message"),
836
+ id: z2.string(),
837
+ role: z2.string().optional(),
838
+ status: z2.string().optional(),
839
+ content: z2.array(z2.any()).optional()
834
840
  }),
835
- import_v42.z.object({
836
- type: import_v42.z.literal("mcp_list_tools"),
837
- id: import_v42.z.string(),
838
- server_label: import_v42.z.string(),
839
- tools: import_v42.z.array(import_v42.z.any()).optional(),
840
- error: import_v42.z.string().optional()
841
+ z2.object({
842
+ type: z2.literal("mcp_list_tools"),
843
+ id: z2.string(),
844
+ server_label: z2.string(),
845
+ tools: z2.array(z2.any()).optional(),
846
+ error: z2.string().optional()
841
847
  }),
842
- import_v42.z.object({
843
- type: import_v42.z.literal("mcp_call"),
844
- id: import_v42.z.string(),
845
- server_label: import_v42.z.string(),
846
- name: import_v42.z.string(),
847
- arguments: import_v42.z.string(),
848
- output: import_v42.z.string().optional(),
849
- error: import_v42.z.string().optional()
848
+ z2.object({
849
+ type: z2.literal("mcp_call"),
850
+ id: z2.string(),
851
+ server_label: z2.string(),
852
+ name: z2.string(),
853
+ arguments: z2.string(),
854
+ output: z2.string().optional(),
855
+ error: z2.string().optional()
850
856
  }),
851
- import_v42.z.object({
852
- type: import_v42.z.literal("function_call"),
853
- id: import_v42.z.string(),
854
- call_id: import_v42.z.string(),
855
- name: import_v42.z.string(),
856
- arguments: import_v42.z.string(),
857
- output: import_v42.z.string().optional(),
858
- error: import_v42.z.string().optional()
857
+ z2.object({
858
+ type: z2.literal("function_call"),
859
+ id: z2.string(),
860
+ call_id: z2.string(),
861
+ name: z2.string(),
862
+ arguments: z2.string(),
863
+ output: z2.string().optional(),
864
+ error: z2.string().optional()
859
865
  }),
860
- import_v42.z.object({
861
- type: import_v42.z.literal("reasoning"),
862
- id: import_v42.z.string(),
863
- status: import_v42.z.string().optional(),
864
- content: import_v42.z.array(import_v42.z.any()).optional(),
865
- summary: import_v42.z.array(import_v42.z.any()).optional()
866
+ z2.object({
867
+ type: z2.literal("reasoning"),
868
+ id: z2.string(),
869
+ status: z2.string().optional(),
870
+ content: z2.array(z2.any()).optional(),
871
+ summary: z2.array(z2.any()).optional()
866
872
  })
867
873
  ]),
868
- sequence_number: import_v42.z.number()
874
+ sequence_number: z2.number()
869
875
  });
870
- var textDeltaChunkSchema = import_v42.z.object({
871
- type: import_v42.z.literal("response.output_text.delta"),
872
- item_id: import_v42.z.string(),
873
- output_index: import_v42.z.number(),
874
- content_index: import_v42.z.number(),
875
- delta: import_v42.z.string(),
876
- sequence_number: import_v42.z.number()
876
+ var textDeltaChunkSchema = z2.object({
877
+ type: z2.literal("response.output_text.delta"),
878
+ item_id: z2.string(),
879
+ output_index: z2.number(),
880
+ content_index: z2.number(),
881
+ delta: z2.string(),
882
+ sequence_number: z2.number()
877
883
  });
878
- var reasoningTextDeltaChunkSchema = import_v42.z.object({
879
- type: import_v42.z.literal("response.reasoning_text.delta"),
880
- item_id: import_v42.z.string(),
881
- output_index: import_v42.z.number(),
882
- content_index: import_v42.z.number(),
883
- delta: import_v42.z.string(),
884
- sequence_number: import_v42.z.number()
884
+ var reasoningTextDeltaChunkSchema = z2.object({
885
+ type: z2.literal("response.reasoning_text.delta"),
886
+ item_id: z2.string(),
887
+ output_index: z2.number(),
888
+ content_index: z2.number(),
889
+ delta: z2.string(),
890
+ sequence_number: z2.number()
885
891
  });
886
- var reasoningTextEndChunkSchema = import_v42.z.object({
887
- type: import_v42.z.literal("response.reasoning_text.done"),
888
- item_id: import_v42.z.string(),
889
- output_index: import_v42.z.number(),
890
- content_index: import_v42.z.number(),
891
- text: import_v42.z.string(),
892
- sequence_number: import_v42.z.number()
892
+ var reasoningTextEndChunkSchema = z2.object({
893
+ type: z2.literal("response.reasoning_text.done"),
894
+ item_id: z2.string(),
895
+ output_index: z2.number(),
896
+ content_index: z2.number(),
897
+ text: z2.string(),
898
+ sequence_number: z2.number()
893
899
  });
894
- var responseCompletedChunkSchema = import_v42.z.object({
895
- type: import_v42.z.literal("response.completed"),
900
+ var responseCompletedChunkSchema = z2.object({
901
+ type: z2.literal("response.completed"),
896
902
  response: huggingfaceResponsesResponseSchema,
897
- sequence_number: import_v42.z.number()
903
+ sequence_number: z2.number()
898
904
  });
899
- var responseCreatedChunkSchema = import_v42.z.object({
900
- type: import_v42.z.literal("response.created"),
901
- response: import_v42.z.object({
902
- id: import_v42.z.string(),
903
- object: import_v42.z.string(),
904
- created_at: import_v42.z.number(),
905
- status: import_v42.z.string(),
906
- model: import_v42.z.string()
905
+ var responseCreatedChunkSchema = z2.object({
906
+ type: z2.literal("response.created"),
907
+ response: z2.object({
908
+ id: z2.string(),
909
+ object: z2.string(),
910
+ created_at: z2.number(),
911
+ status: z2.string(),
912
+ model: z2.string()
907
913
  })
908
914
  });
909
- var huggingfaceResponsesChunkSchema = import_v42.z.union([
915
+ var huggingfaceResponsesChunkSchema = z2.union([
910
916
  responseOutputItemAddedSchema,
911
917
  responseOutputItemDoneSchema,
912
918
  reasoningTextDeltaChunkSchema,
@@ -914,7 +920,7 @@ var huggingfaceResponsesChunkSchema = import_v42.z.union([
914
920
  textDeltaChunkSchema,
915
921
  responseCompletedChunkSchema,
916
922
  responseCreatedChunkSchema,
917
- import_v42.z.object({ type: import_v42.z.string() }).loose()
923
+ z2.object({ type: z2.string() }).loose()
918
924
  // fallback for unknown chunks
919
925
  ]);
920
926
  function isResponseOutputItemAddedChunk(chunk) {
@@ -942,9 +948,9 @@ function isResponseCreatedChunk(chunk) {
942
948
  // src/huggingface-provider.ts
943
949
  function createHuggingFace(options = {}) {
944
950
  var _a;
945
- const baseURL = (_a = (0, import_provider_utils4.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://router.huggingface.co/v1";
951
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://router.huggingface.co/v1";
946
952
  const getHeaders = () => ({
947
- Authorization: `Bearer ${(0, import_provider_utils4.loadApiKey)({
953
+ Authorization: `Bearer ${loadApiKey({
948
954
  apiKey: options.apiKey,
949
955
  environmentVariableName: "HUGGINGFACE_API_KEY",
950
956
  description: "Hugging Face"
@@ -958,7 +964,7 @@ function createHuggingFace(options = {}) {
958
964
  url: ({ path }) => `${baseURL}${path}`,
959
965
  headers: getHeaders,
960
966
  fetch: options.fetch,
961
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils4.generateId
967
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2
962
968
  });
963
969
  };
964
970
  const provider = (modelId) => createResponsesModel(modelId);
@@ -966,7 +972,7 @@ function createHuggingFace(options = {}) {
966
972
  provider.languageModel = createResponsesModel;
967
973
  provider.responses = createResponsesModel;
968
974
  provider.embeddingModel = (modelId) => {
969
- throw new import_provider3.NoSuchModelError({
975
+ throw new NoSuchModelError({
970
976
  modelId,
971
977
  modelType: "embeddingModel",
972
978
  message: "Hugging Face Responses API does not support text embeddings. Use the Hugging Face Inference API directly for embeddings."
@@ -974,7 +980,7 @@ function createHuggingFace(options = {}) {
974
980
  };
975
981
  provider.textEmbeddingModel = provider.embeddingModel;
976
982
  provider.imageModel = (modelId) => {
977
- throw new import_provider3.NoSuchModelError({
983
+ throw new NoSuchModelError({
978
984
  modelId,
979
985
  modelType: "imageModel",
980
986
  message: "Hugging Face Responses API does not support image generation. Use the Hugging Face Inference API directly for image models."
@@ -983,9 +989,8 @@ function createHuggingFace(options = {}) {
983
989
  return provider;
984
990
  }
985
991
  var huggingface = createHuggingFace();
986
- // Annotate the CommonJS export names for ESM import in node:
987
- 0 && (module.exports = {
992
+ export {
988
993
  createHuggingFace,
989
994
  huggingface
990
- });
995
+ };
991
996
  //# sourceMappingURL=index.js.map