@agentproto/catalog-sync 0.5.0 → 0.5.2

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.mjs CHANGED
@@ -344,6 +344,133 @@ var llmRequestyGenerator = defineGenerator({
344
344
  sources: sources2,
345
345
  generate: generate2
346
346
  });
347
+ var HUGGINGFACE_MODELS_URL = "https://router.huggingface.co/v1/models";
348
+ var OUTPUT_PATH3 = "packages/model-catalog/src/llm/huggingface-routes.generated.ts";
349
+ var HFProviderSchema = z.object({
350
+ provider: z.string(),
351
+ status: z.string(),
352
+ context_length: z.number().optional(),
353
+ pricing: z.object({
354
+ input: z.number().optional(),
355
+ output: z.number().optional()
356
+ }).optional(),
357
+ supports_tools: z.boolean().optional(),
358
+ supports_structured_output: z.boolean().optional()
359
+ }).passthrough();
360
+ var HFModelSchema = z.object({
361
+ id: z.string(),
362
+ providers: z.array(HFProviderSchema).optional()
363
+ }).passthrough();
364
+ var SnapshotSchema3 = z.object({
365
+ data: z.array(HFModelSchema)
366
+ });
367
+ function round4(n) {
368
+ return Math.round(n * 1e4) / 1e4;
369
+ }
370
+ function serializeProvider(p) {
371
+ const fields = [
372
+ `provider: ${JSON.stringify(p.provider)}`,
373
+ `status: ${JSON.stringify(p.status)}`
374
+ ];
375
+ if (p.contextLength !== void 0) fields.push(`contextLength: ${p.contextLength}`);
376
+ if (p.inputPer1M !== void 0) fields.push(`inputPer1M: ${p.inputPer1M}`);
377
+ if (p.outputPer1M !== void 0) fields.push(`outputPer1M: ${p.outputPer1M}`);
378
+ if (p.supportsTools !== void 0) fields.push(`supportsTools: ${p.supportsTools}`);
379
+ if (p.supportsStructuredOutput !== void 0) {
380
+ fields.push(`supportsStructuredOutput: ${p.supportsStructuredOutput}`);
381
+ }
382
+ return ` {
383
+ ${fields.join(",\n ")},
384
+ }`;
385
+ }
386
+ function serializeEntry3(id, e) {
387
+ const providerLines = e.providers.map(serializeProvider).join(",\n");
388
+ return [
389
+ ` ${JSON.stringify(id)}: {`,
390
+ ` wireId: ${JSON.stringify(e.wireId)},`,
391
+ ` providers: [`,
392
+ providerLines,
393
+ ` ],`,
394
+ ` },`
395
+ ].join("\n");
396
+ }
397
+ function serializeFile3(entries) {
398
+ const ids = Object.keys(entries).sort();
399
+ const lines = [
400
+ "// AUTO-GENERATED by @agentproto/catalog-sync (llm:huggingface).",
401
+ "// Do not edit by hand \u2014 re-run `pnpm --filter @agentproto/catalog-sync generate`.",
402
+ `// Source: ${HUGGINGFACE_MODELS_URL}`,
403
+ "// Per-model LIVE inference providers from the HuggingFace router. HF wire",
404
+ "// ids are case-sensitive and preserved verbatim. Provider entries are",
405
+ "// SPARSE on some models \u2014 every field below except provider/status is",
406
+ "// optional and emitted only when the upstream response carries it. Only",
407
+ '// providers with status === "live" are kept; models with zero live',
408
+ "// providers are skipped. inputPer1M/outputPer1M are USD per 1M tokens",
409
+ "// (HuggingFace router convention \u2014 already at that scale, unlike",
410
+ "// OpenRouter's per-token strings).",
411
+ "",
412
+ "export interface HuggingFaceRouteProvider {",
413
+ " provider: string",
414
+ " status: string",
415
+ " contextLength?: number",
416
+ " inputPer1M?: number",
417
+ " outputPer1M?: number",
418
+ " supportsTools?: boolean",
419
+ " supportsStructuredOutput?: boolean",
420
+ "}",
421
+ "",
422
+ "export interface HuggingFaceRoute {",
423
+ " wireId: string",
424
+ " providers: HuggingFaceRouteProvider[]",
425
+ "}",
426
+ "",
427
+ "export const HUGGINGFACE_ROUTES: Record<string, HuggingFaceRoute> = {"
428
+ ];
429
+ for (const id of ids) {
430
+ lines.push(serializeEntry3(id, entries[id]));
431
+ }
432
+ lines.push("}");
433
+ lines.push("");
434
+ return lines.join("\n");
435
+ }
436
+ async function generate3(ctx) {
437
+ const src = sources3[0];
438
+ if (!src) throw new Error("llm:huggingface: no source configured");
439
+ const parsed = SnapshotSchema3.parse(await ctx.fetchSource(src));
440
+ const entries = {};
441
+ for (const model of parsed.data) {
442
+ const liveProviders = (model.providers ?? []).filter((p) => p.status === "live");
443
+ if (liveProviders.length === 0) continue;
444
+ const providers = liveProviders.map((p) => {
445
+ const entry = {
446
+ provider: p.provider,
447
+ status: p.status
448
+ };
449
+ if (p.context_length !== void 0) entry.contextLength = p.context_length;
450
+ if (p.pricing?.input !== void 0) entry.inputPer1M = round4(p.pricing.input);
451
+ if (p.pricing?.output !== void 0) entry.outputPer1M = round4(p.pricing.output);
452
+ if (p.supports_tools !== void 0) entry.supportsTools = p.supports_tools;
453
+ if (p.supports_structured_output !== void 0) {
454
+ entry.supportsStructuredOutput = p.supports_structured_output;
455
+ }
456
+ return entry;
457
+ }).sort((a, b) => a.provider.localeCompare(b.provider));
458
+ entries[model.id] = { wireId: model.id, providers };
459
+ }
460
+ return { [OUTPUT_PATH3]: serializeFile3(entries) };
461
+ }
462
+ var sources3 = [
463
+ {
464
+ id: "llm-huggingface",
465
+ url: HUGGINGFACE_MODELS_URL
466
+ }
467
+ ];
468
+ var llmHuggingfaceGenerator = defineGenerator({
469
+ name: "llm:huggingface",
470
+ modality: "llm",
471
+ sources: sources3,
472
+ generate: generate3
473
+ });
347
474
 
348
475
  // src/generators/serialize-voices.ts
349
476
  function serializeVoice(v) {
@@ -387,7 +514,7 @@ var ELEVENLABS_SOURCE = {
387
514
  // Live refresh needs the account key; offline reads ignore this.
388
515
  headers: { "xi-api-key": "env:ELEVENLABS_API_KEY" }
389
516
  };
390
- var OUTPUT_PATH3 = "packages/catalog-sync/generated/voice-elevenlabs.generated.ts";
517
+ var OUTPUT_PATH4 = "packages/catalog-sync/generated/voice-elevenlabs.generated.ts";
391
518
  var voiceElevenlabs = defineGenerator({
392
519
  name: "voice:elevenlabs",
393
520
  modality: "voice",
@@ -398,7 +525,7 @@ var voiceElevenlabs = defineGenerator({
398
525
  );
399
526
  const voices = mapElevenLabsVoices(snapshot);
400
527
  return {
401
- [OUTPUT_PATH3]: serializeVoiceModule(
528
+ [OUTPUT_PATH4]: serializeVoiceModule(
402
529
  "voice:elevenlabs",
403
530
  "ELEVENLABS_VOICES",
404
531
  voices
@@ -418,7 +545,7 @@ var MINIMAX_SOURCE = {
418
545
  },
419
546
  body: { voice_type: "system" }
420
547
  };
421
- var OUTPUT_PATH4 = "packages/catalog-sync/generated/voice-minimax.generated.ts";
548
+ var OUTPUT_PATH5 = "packages/catalog-sync/generated/voice-minimax.generated.ts";
422
549
  var voiceMinimax = defineGenerator({
423
550
  name: "voice:minimax",
424
551
  modality: "voice",
@@ -429,7 +556,7 @@ var voiceMinimax = defineGenerator({
429
556
  );
430
557
  const voices = mapMinimaxVoices(snapshot);
431
558
  return {
432
- [OUTPUT_PATH4]: serializeVoiceModule(
559
+ [OUTPUT_PATH5]: serializeVoiceModule(
433
560
  "voice:minimax",
434
561
  "MINIMAX_VOICES",
435
562
  voices
@@ -659,7 +786,8 @@ function mapModel(raw) {
659
786
  }
660
787
  var REPLICATE_SOURCE = {
661
788
  id: "image-replicate",
662
- url: "https://api.replicate.com/v1/models?query=image+generation"
789
+ url: "https://api.replicate.com/v1/models?query=image+generation",
790
+ headers: { Authorization: "Bearer env:REPLICATE_API_TOKEN" }
663
791
  };
664
792
  var imageReplicate = defineGenerator({
665
793
  name: "image:replicate",
@@ -753,10 +881,10 @@ function resolveHeaders2(headers) {
753
881
  }
754
882
  return { headers: out, missing };
755
883
  }
756
- async function refreshSources(sources3, opts) {
884
+ async function refreshSources(sources4, opts) {
757
885
  const results = [];
758
886
  const fetchImpl = opts.fetchImpl ?? fetch;
759
- for (const { source, refreshable, notes } of sources3) {
887
+ for (const { source, refreshable, notes } of sources4) {
760
888
  if (!opts.refresh) {
761
889
  results.push({
762
890
  id: source.id,
@@ -875,6 +1003,6 @@ var OPENAI_LLM_SOURCE = {
875
1003
  };
876
1004
  var OPENAI_SOURCES = [OPENAI_LLM_SOURCE];
877
1005
 
878
- export { OPENAI_LLM_SOURCE, OPENAI_SOURCES, defineGenerator, imageReplicate, llmOpenRouterGenerator, llmRequestyGenerator, refreshSources, reviewedRefresh, runGenerators, voiceElevenlabs, voiceMinimax };
1006
+ export { OPENAI_LLM_SOURCE, OPENAI_SOURCES, defineGenerator, imageReplicate, llmHuggingfaceGenerator, llmOpenRouterGenerator, llmRequestyGenerator, refreshSources, reviewedRefresh, runGenerators, voiceElevenlabs, voiceMinimax };
879
1007
  //# sourceMappingURL=index.mjs.map
880
1008
  //# sourceMappingURL=index.mjs.map