@agentproto/model-catalog 0.12.7 → 0.13.1

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.
Files changed (30) hide show
  1. package/dist/access/index.mjs +4 -4
  2. package/dist/{chunk-USCEVZQG.mjs → chunk-5EX3V7QZ.mjs} +4 -4
  3. package/dist/{chunk-USCEVZQG.mjs.map → chunk-5EX3V7QZ.mjs.map} +1 -1
  4. package/dist/{chunk-ITX3DL26.mjs → chunk-6TZ6WIM3.mjs} +4 -4
  5. package/dist/{chunk-ITX3DL26.mjs.map → chunk-6TZ6WIM3.mjs.map} +1 -1
  6. package/dist/{chunk-XYM6UG7C.mjs → chunk-ALUIW3QO.mjs} +93 -98
  7. package/dist/chunk-ALUIW3QO.mjs.map +1 -0
  8. package/dist/{chunk-CEP4H4FD.mjs → chunk-NNV3NYUE.mjs} +3 -3
  9. package/dist/{chunk-CEP4H4FD.mjs.map → chunk-NNV3NYUE.mjs.map} +1 -1
  10. package/dist/{chunk-Z2WIEJR7.mjs → chunk-TVXNRUJM.mjs} +54 -66
  11. package/dist/chunk-TVXNRUJM.mjs.map +1 -0
  12. package/dist/{chunk-N2XHRKQI.mjs → chunk-TZ5LNR5F.mjs} +3 -3
  13. package/dist/{chunk-N2XHRKQI.mjs.map → chunk-TZ5LNR5F.mjs.map} +1 -1
  14. package/dist/{chunk-HC5TGYJW.mjs → chunk-UOOTUH6N.mjs} +5 -4
  15. package/dist/chunk-UOOTUH6N.mjs.map +1 -0
  16. package/dist/{chunk-UWZLV4P2.mjs → chunk-XJUZ5X3W.mjs} +5 -5
  17. package/dist/{chunk-UWZLV4P2.mjs.map → chunk-XJUZ5X3W.mjs.map} +1 -1
  18. package/dist/cost/index.mjs +6 -6
  19. package/dist/curation/index.mjs +6 -6
  20. package/dist/defaults-BDkNRPK8.d.ts +50 -0
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.mjs +10 -10
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/llm/index.d.ts +2 -44
  25. package/dist/llm/index.mjs +2 -2
  26. package/dist/route-identity/index.mjs +2 -2
  27. package/package.json +4 -4
  28. package/dist/chunk-HC5TGYJW.mjs.map +0 -1
  29. package/dist/chunk-XYM6UG7C.mjs.map +0 -1
  30. package/dist/chunk-Z2WIEJR7.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
- export { evaluateAccess, evaluateCatalogDefaults } from '../chunk-N2XHRKQI.mjs';
2
- import '../chunk-CEP4H4FD.mjs';
3
- import '../chunk-HC5TGYJW.mjs';
4
- import '../chunk-Z2WIEJR7.mjs';
1
+ export { evaluateAccess, evaluateCatalogDefaults } from '../chunk-TZ5LNR5F.mjs';
2
+ import '../chunk-NNV3NYUE.mjs';
3
+ import '../chunk-UOOTUH6N.mjs';
4
+ import '../chunk-TVXNRUJM.mjs';
5
5
  import '../chunk-QHELXPSL.mjs';
6
6
  //# sourceMappingURL=index.mjs.map
7
7
  //# sourceMappingURL=index.mjs.map
@@ -1,5 +1,5 @@
1
- import { getModel } from './chunk-UWZLV4P2.mjs';
2
- import { calculateLLMCreditCost } from './chunk-Z2WIEJR7.mjs';
1
+ import { getModel } from './chunk-XJUZ5X3W.mjs';
2
+ import { calculateLLMCreditCost } from './chunk-TVXNRUJM.mjs';
3
3
  import { computeCenticredits, pricingRegistry } from './chunk-QHELXPSL.mjs';
4
4
 
5
5
  /**
@@ -223,5 +223,5 @@ function calculateAudioCost(modelId, usage, opts) {
223
223
  }
224
224
 
225
225
  export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost };
226
- //# sourceMappingURL=chunk-USCEVZQG.mjs.map
227
- //# sourceMappingURL=chunk-USCEVZQG.mjs.map
226
+ //# sourceMappingURL=chunk-5EX3V7QZ.mjs.map
227
+ //# sourceMappingURL=chunk-5EX3V7QZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cost/index.ts"],"names":["resolved","baseCostUs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B,SAAA,CAAU,OAAA,EAAS,KAAK,KAAK,CAAA;AAC5D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,OAAA;AAAA,IACA,WAAA,EAAa,OAAA;AAAA,IACb,OAAA;AAAA,IACA,iBAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA,EAAW;AAAA,MACT,cAAA;AAAA,MACA;AAAA,KACF;AAAA,IACA,UAAA,EAAY,KAAA;AAAA,IACZ;AAAA,GACF;AACF;AAOO,SAAS,gBAAA,CACd,OAAA,EACA,KAAA,EAMA,IAAA,EACY;AACZ,EAAA,OAAO,aAAA,CAAc,SAAS,EAAE,IAAA,EAAM,OAAO,GAAG,KAAA,IAAS,IAAI,CAAA;AAC/D;AAEO,SAAS,kBAAA,CACd,OAAA,EACA,KAAA,EACA,IAAA,EACY;AACZ,EAAA,OAAO,aAAA,CAAc,SAAS,EAAE,IAAA,EAAM,SAAS,GAAG,KAAA,IAAS,IAAI,CAAA;AACjE;AAEO,SAAS,kBAAA,CACd,OAAA,EACA,KAAA,EACA,IAAA,EACY;AACZ,EAAA,OAAO,aAAA,CAAc,SAAS,EAAE,IAAA,EAAM,SAAS,GAAG,KAAA,IAAS,IAAI,CAAA;AACjE;AAEO,SAAS,kBAAA,CACd,OAAA,EACA,KAAA,EACA,IAAA,EACY;AACZ,EAAA,OAAO,aAAA,CAAc,SAAS,EAAE,IAAA,EAAM,SAAS,GAAG,KAAA,IAAS,IAAI,CAAA;AACjE","file":"chunk-USCEVZQG.mjs","sourcesContent":["/**\n * Cost dispatcher — computes credit cost + production USD cost for any\n * model id, regardless of kind. Single entry point used by orchestrator,\n * billing audits, and (eventually) the metered MCP gen layer.\n *\n * Per-kind formulas:\n * - LLM → reuses `calculateLLMCreditCost` (token math + cache + markup)\n * - Image → `creditCost × numOutputs`\n * - Video → `creditCost × multipliers[resolution|duration|mode]`\n * - Audio → `creditCost × (characters or seconds)` per `billingUnit`\n */\n\nimport {\n calculateLLMCreditCost,\n type LLMCreditCostResult,\n} from \"../llm/index.js\"\nimport { getModel } from \"../registry/index.js\"\nimport { computeCenticredits, pricingRegistry } from \"../pricing/index.js\"\n\n/**\n * Voice metadata → default audio model the dispatcher bills through.\n *\n * Voices are render-targets, not priced units. A MiniMax voice can be\n * played through `minimax/speech-02-hd` OR `…-turbo`; an ElevenLabs\n * voice through any of their model tiers. We default to the cheapest\n * model per provider so a drive-by voice-id call doesn't over-bill.\n * Callers wanting HD / premium-tier pricing should pass the audio\n * model id directly with the voice as metadata — see\n * `text-to-speech.tool.ts` for the canonical pattern.\n *\n * Add a new provider here when a new voice catalog lands (e.g.\n * `ELEVENLABS_VOICES` if/when we surface their voice IDs).\n */\nconst VOICE_PROVIDER_DEFAULT_MODEL: Record<string, string> = {\n minimax: \"minimax/speech-02-turbo\",\n elevenlabs: \"elevenlabs/flash-v2.5\",\n}\n\nexport type CostUsage =\n | {\n kind: \"llm\"\n inputTokens: number\n outputTokens: number\n cacheReadInputTokens?: number\n cacheCreationInputTokens?: number\n }\n | { kind: \"image\"; numOutputs?: number }\n | {\n kind: \"video\"\n resolution?: string\n duration?: number\n mode?: string\n }\n | { kind: \"audio\"; characters?: number; seconds?: number }\n\nexport interface CostResult {\n kind: \"llm\" | \"image\" | \"video\" | \"audio\"\n modelId: string\n /** Canonical model id after alias resolution (LLM only; same as modelId for media) */\n canonicalId: string\n /**\n * Total **centicredits** to charge (1 displayed credit = 100 cc).\n * Honors per-model overrides. Feed straight into the ledger — the\n * `credit_transactions.credits` column stores cc, so no `× 100`\n * conversion at the call site. Format for display with\n * `displayCredits(cc) → cr`.\n */\n credits: number\n /**\n * Centicredits the pure formula (provider cost × category markup)\n * would have charged, independent of any per-model override. Equal\n * to `credits` when no override is in play. Surfaced so\n * reconciliation can diff \"what we did\" vs \"what the formula said\"\n * without recomputing — persisted to `usage_events.calculated_credits`.\n */\n calculatedCredits: number\n /** Production cost in USD (provider-side, before markup) */\n baseCostUsd: number\n /** Per-kind breakdown — inputCredits/outputCredits for LLM, etc. All in cc. */\n breakdown: Record<string, number>\n /** True iff fallback pricing was used (currently LLM-only) */\n isFallback: boolean\n /** Markup applied (1.0 = catalog rate as-is) */\n markup: number\n}\n\nexport class UnknownModelError extends Error {\n constructor(public readonly modelId: string) {\n super(`Unknown model id: \"${modelId}\"`)\n this.name = \"UnknownModelError\"\n }\n}\n\nexport class CostUsageKindMismatchError extends Error {\n constructor(\n public readonly modelId: string,\n public readonly expected: string,\n public readonly got: string\n ) {\n super(\n `Model \"${modelId}\" is kind \"${expected}\", but received usage of kind \"${got}\"`\n )\n this.name = \"CostUsageKindMismatchError\"\n }\n}\n\nexport interface CalculateCostOptions {\n /**\n * App that's invoking the model. Routes per-app markup overrides\n * registered via `pricingRegistry.registerApp(appId, ...)`. When\n * omitted, core defaults apply.\n */\n appId?: string\n}\n\n/**\n * Computes credit + USD cost for a model run.\n *\n * Throws `UnknownModelError` for ids not in any catalog (LLM has its own\n * fallback path inside `calculateLLMCreditCost` — this surface preserves\n * that for back-compat).\n *\n * Throws `CostUsageKindMismatchError` if `usage.kind` doesn't match the\n * resolved model's kind (data integrity guard).\n *\n * Image / video / audio credits are derived at call time via the\n * pricing registry (`provider_cost × category-markup`). LLM keeps its\n * own per-model markup table inside `calculateLLMCreditCost` —\n * collapsing that follows in W6b.\n */\nexport function calculateCost(\n modelId: string,\n usage: CostUsage,\n opts: CalculateCostOptions = {}\n): CostResult {\n // LLM has a fallback path that returns valid pricing even for unknown\n // ids (preserves the orchestrator's existing tolerance). Other kinds\n // throw for unknowns.\n if (usage.kind === \"llm\") {\n const llmResult: LLMCreditCostResult = calculateLLMCreditCost(modelId, {\n inputTokens: usage.inputTokens,\n outputTokens: usage.outputTokens,\n cacheReadInputTokens: usage.cacheReadInputTokens,\n cacheCreationInputTokens: usage.cacheCreationInputTokens,\n })\n const resolved = getModel(modelId)\n const canonicalId =\n resolved && resolved.kind === \"llm\" ? resolved.canonicalId : modelId\n return {\n kind: \"llm\",\n modelId,\n canonicalId,\n credits: llmResult.credits,\n calculatedCredits: llmResult.calculatedCredits,\n baseCostUsd: llmResult.productionCost,\n breakdown: {\n inputCredits: llmResult.inputCredits,\n outputCredits: llmResult.outputCredits,\n cacheReadCredits: llmResult.cacheReadCredits,\n cacheWriteCredits: llmResult.cacheWriteCredits,\n },\n isFallback: llmResult.isFallback,\n markup: llmResult.markup,\n }\n }\n\n const resolved = getModel(modelId)\n if (!resolved) throw new UnknownModelError(modelId)\n // `voice` is structurally audio for billing purposes (MiniMax voice\n // metadata billed via per-character output). Accept `audio` usage on\n // voice models so the per-kind branches below can pattern-match.\n const expectedUsageKind: CostUsage[\"kind\"] =\n resolved.kind === \"voice\" ? \"audio\" : resolved.kind\n if (expectedUsageKind !== usage.kind) {\n // Pass `expectedUsageKind` (not `resolved.kind`) so the error message\n // accurately says \"audio\" rather than \"voice\" when a voice model is\n // billed — the caller must supply audio usage, not voice usage.\n throw new CostUsageKindMismatchError(modelId, expectedUsageKind, usage.kind)\n }\n\n if (resolved.kind === \"image\") {\n // `usage.kind` is \"image\" here (guarded above) but TS won't cross-narrow\n // it from `resolved.kind`, so check explicitly before reading numOutputs.\n const numOutputs = Math.max(\n 1,\n usage.kind === \"image\" ? (usage.numOutputs ?? 1) : 1\n )\n const baseCostUsd = resolved.def.pricing.baseCost * numOutputs\n const perOutputCredits = computeCenticredits({\n baseCostUsd: resolved.def.pricing.baseCost,\n category: \"image\",\n overrideCreditCost: resolved.def.pricing.overrideCreditCost,\n appId: opts.appId,\n })\n const credits = perOutputCredits * numOutputs\n // Formula-only (ignores override) — for `usage_events.calculated_credits`.\n const formulaPerOutput = computeCenticredits({\n baseCostUsd: resolved.def.pricing.baseCost,\n category: \"image\",\n appId: opts.appId,\n })\n const calculatedCredits = formulaPerOutput * numOutputs\n const markup = pricingRegistry.getMarkup(\"image\", opts.appId)\n return {\n kind: \"image\",\n modelId,\n canonicalId: modelId,\n credits,\n calculatedCredits,\n baseCostUsd,\n breakdown: {\n perOutputCredits,\n numOutputs,\n },\n isFallback: false,\n markup,\n }\n }\n\n if (resolved.kind === \"video\") {\n if (usage.kind !== \"video\") {\n throw new CostUsageKindMismatchError(modelId, \"video\", usage.kind)\n }\n const pricing = resolved.def.pricing\n // Provider-side multipliers — re-applied to BOTH the provider cost\n // (what we pay) AND the derived credit cost (so margin holds).\n const mult = pricing.multipliers\n const resMult =\n usage.resolution && mult?.resolution\n ? (mult.resolution[usage.resolution] ?? 1.0)\n : 1.0\n const durMult =\n usage.duration && mult?.duration\n ? (mult.duration[usage.duration] ?? 1.0)\n : 1.0\n const modMult =\n usage.mode && mult?.mode ? (mult.mode[usage.mode] ?? 1.0) : 1.0\n const variantMultiplier = resMult * durMult * modMult\n const baseCostUsd = pricing.baseCost * variantMultiplier\n const perClipCredits = computeCenticredits({\n baseCostUsd: pricing.baseCost,\n category: \"video\",\n overrideCreditCost: pricing.overrideCreditCost,\n appId: opts.appId,\n })\n const credits = Math.ceil(perClipCredits * variantMultiplier)\n const formulaPerClip = computeCenticredits({\n baseCostUsd: pricing.baseCost,\n category: \"video\",\n appId: opts.appId,\n })\n const calculatedCredits = Math.ceil(formulaPerClip * variantMultiplier)\n const markup = pricingRegistry.getMarkup(\"video\", opts.appId)\n return {\n kind: \"video\",\n modelId,\n canonicalId: modelId,\n credits,\n calculatedCredits,\n baseCostUsd,\n breakdown: {\n perClipCredits,\n resolutionMultiplier: resMult,\n durationMultiplier: durMult,\n modeMultiplier: modMult,\n variantMultiplier,\n },\n isFallback: false,\n markup,\n }\n }\n\n // Audio (and voice, delegated as audio — see expectedUsageKind above).\n if (usage.kind !== \"audio\") {\n throw new CostUsageKindMismatchError(modelId, \"audio\", usage.kind)\n }\n\n if (resolved.kind === \"voice\") {\n // Voice rows are metadata; delegate to the provider's default audio model.\n const provider = resolved.voice.provider\n const delegateModelId = VOICE_PROVIDER_DEFAULT_MODEL[provider]\n if (!delegateModelId) throw new UnknownModelError(modelId)\n const delegateResult = calculateCost(delegateModelId, usage, opts)\n return {\n ...delegateResult,\n modelId,\n canonicalId: delegateModelId,\n }\n }\n\n // Only `audio` remains (llm returned at top; image/video/voice handled\n // above). Narrow explicitly so `.def` is type-safe.\n if (resolved.kind !== \"audio\") throw new UnknownModelError(modelId)\n const audioPricing = resolved.def.pricing\n // Map the provider's billing unit to a quantity of billable units.\n // The catalog DATA uses `per_1k_chars` (chars ÷ 1000) and `per_minute`\n // (whole minutes, rounded UP to match provider invoicing). `per_character`\n // / `per_second` are handled too so a future data migration to those units\n // keeps working. NOTE: do not switch on the zod enum value alone — the\n // audio schema enum is stale (`per_character|per_second`) while the data\n // still ships `per_1k_chars|per_minute`; trusting the enum bills 0.\n const billingUnit = audioPricing.billingUnit as string\n let quantity: number\n switch (billingUnit) {\n case \"per_1k_chars\":\n quantity = Math.max(0, usage.characters ?? 0) / 1000\n break\n case \"per_character\":\n quantity = Math.max(0, usage.characters ?? 0)\n break\n case \"per_minute\":\n quantity = Math.ceil(Math.max(0, usage.seconds ?? 0) / 60)\n break\n case \"per_second\":\n default:\n quantity = Math.max(0, usage.seconds ?? 0)\n break\n }\n const baseCostUsd = audioPricing.baseCost * quantity\n const perUnitCredits = computeCenticredits({\n baseCostUsd: audioPricing.baseCost,\n category: \"audio\",\n overrideCreditCost: audioPricing.overrideCreditCost,\n appId: opts.appId,\n })\n // Per-call floor (1 cc) so a non-empty call never rounds to 0; a genuinely\n // empty call (quantity 0, e.g. empty-string TTS) bills nothing.\n const credits =\n quantity > 0 ? Math.max(1, Math.ceil(perUnitCredits * quantity)) : 0\n const formulaPerUnit = computeCenticredits({\n baseCostUsd: audioPricing.baseCost,\n category: \"audio\",\n appId: opts.appId,\n })\n const calculatedCredits =\n quantity > 0 ? Math.max(1, Math.ceil(formulaPerUnit * quantity)) : 0\n const markup = pricingRegistry.getMarkup(\"audio\", opts.appId)\n return {\n kind: \"audio\",\n modelId,\n canonicalId: modelId,\n credits,\n calculatedCredits,\n baseCostUsd,\n breakdown: {\n perUnitCredits,\n quantity,\n },\n isFallback: false,\n markup,\n }\n}\n\n// Thin ergonomic wrappers around `calculateCost`. Two reasons they exist:\n// 1. Callers with a known kind don't want to construct the full union.\n// 2. The kind/usage union is a `calculateCost` implementation detail —\n// wrapper types are narrower and easier to read at call sites.\n\nexport function calculateLLMCost(\n modelId: string,\n usage: {\n inputTokens: number\n outputTokens: number\n cacheReadInputTokens?: number\n cacheCreationInputTokens?: number\n },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"llm\", ...usage }, opts)\n}\n\nexport function calculateImageCost(\n modelId: string,\n usage: { numOutputs?: number },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"image\", ...usage }, opts)\n}\n\nexport function calculateVideoCost(\n modelId: string,\n usage: { resolution?: string; duration?: number; mode?: string },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"video\", ...usage }, opts)\n}\n\nexport function calculateAudioCost(\n modelId: string,\n usage: { characters?: number; seconds?: number },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"audio\", ...usage }, opts)\n}\n"]}
1
+ {"version":3,"sources":["../src/cost/index.ts"],"names":["resolved","baseCostUsd","credits","calculatedCredits","markup"],"mappings":";;;;;;;;;;;AAiCA,IAAM,4BAAA,GAAuD;AAAA,EAC3D,OAAA,EAAS,yBAAA;AAAA,EACT,UAAA,EAAY;AACd,CAAA;AAkDO,IAAM,iBAAA,GAAN,cAAgC,KAAA,CAAM;AAAA,EAC3C,YAA4B,OAAA,EAAiB;AAC3C,IAAA,KAAA,CAAM,CAAA,mBAAA,EAAsB,OAAO,CAAA,CAAA,CAAG,CAAA;AADZ,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAE1B,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AAAA,EACd;AAAA,EAH4B,OAAA;AAI9B;AAEO,IAAM,0BAAA,GAAN,cAAyC,KAAA,CAAM;AAAA,EACpD,WAAA,CACkB,OAAA,EAC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AA,EACA,KAAA,EACA,IAAA,EACY;AACZ,EAAA,OAAO,aAAA,CAAc,SAAS,EAAE,IAAA,EAAM,SAAS,GAAG,KAAA,IAAS,IAAI,CAAA;AACjE;AAEO,SAAS,kBAAA,CACd,OAAA,EACA,KAAA,EACA,IAAA,EACY;AACZ,EAAA,OAAO,aAAA,CAAc,SAAS,EAAE,IAAA,EAAM,SAAS,GAAG,KAAA,IAAS,IAAI,CAAA;AACjE;AAEO,SAAS,kBAAA,CACd,OAAA,EACA,KAAA,EACA,IAAA,EACY;AACZ,EAAA,OAAO,aAAA,CAAc,SAAS,EAAE,IAAA,EAAM,SAAS,GAAG,KAAA,IAAS,IAAI,CAAA;AACjE","file":"chunk-5EX3V7QZ.mjs","sourcesContent":["/**\n * Cost dispatcher — computes credit cost + production USD cost for any\n * model id, regardless of kind. Single entry point used by orchestrator,\n * billing audits, and (eventually) the metered MCP gen layer.\n *\n * Per-kind formulas:\n * - LLM → reuses `calculateLLMCreditCost` (token math + cache + markup)\n * - Image → `creditCost × numOutputs`\n * - Video → `creditCost × multipliers[resolution|duration|mode]`\n * - Audio → `creditCost × (characters or seconds)` per `billingUnit`\n */\n\nimport {\n calculateLLMCreditCost,\n type LLMCreditCostResult,\n} from \"../llm/index.js\"\nimport { getModel } from \"../registry/index.js\"\nimport { computeCenticredits, pricingRegistry } from \"../pricing/index.js\"\n\n/**\n * Voice metadata → default audio model the dispatcher bills through.\n *\n * Voices are render-targets, not priced units. A MiniMax voice can be\n * played through `minimax/speech-02-hd` OR `…-turbo`; an ElevenLabs\n * voice through any of their model tiers. We default to the cheapest\n * model per provider so a drive-by voice-id call doesn't over-bill.\n * Callers wanting HD / premium-tier pricing should pass the audio\n * model id directly with the voice as metadata — see\n * `text-to-speech.tool.ts` for the canonical pattern.\n *\n * Add a new provider here when a new voice catalog lands (e.g.\n * `ELEVENLABS_VOICES` if/when we surface their voice IDs).\n */\nconst VOICE_PROVIDER_DEFAULT_MODEL: Record<string, string> = {\n minimax: \"minimax/speech-02-turbo\",\n elevenlabs: \"elevenlabs/flash-v2.5\",\n}\n\nexport type CostUsage =\n | {\n kind: \"llm\"\n inputTokens: number\n outputTokens: number\n cacheReadInputTokens?: number\n cacheCreationInputTokens?: number\n }\n | { kind: \"image\"; numOutputs?: number }\n | {\n kind: \"video\"\n resolution?: string\n duration?: number\n mode?: string\n }\n | { kind: \"audio\"; characters?: number; seconds?: number }\n\nexport interface CostResult {\n kind: \"llm\" | \"image\" | \"video\" | \"audio\"\n modelId: string\n /** Canonical model id after alias resolution (LLM only; same as modelId for media) */\n canonicalId: string\n /**\n * Total **centicredits** to charge (1 displayed credit = 100 cc).\n * Honors per-model overrides. Feed straight into the ledger — the\n * `credit_transactions.credits` column stores cc, so no `× 100`\n * conversion at the call site. Format for display with\n * `displayCredits(cc) → cr`.\n */\n credits: number\n /**\n * Centicredits the pure formula (provider cost × category markup)\n * would have charged, independent of any per-model override. Equal\n * to `credits` when no override is in play. Surfaced so\n * reconciliation can diff \"what we did\" vs \"what the formula said\"\n * without recomputing — persisted to `usage_events.calculated_credits`.\n */\n calculatedCredits: number\n /** Production cost in USD (provider-side, before markup) */\n baseCostUsd: number\n /** Per-kind breakdown — inputCredits/outputCredits for LLM, etc. All in cc. */\n breakdown: Record<string, number>\n /** True iff fallback pricing was used (currently LLM-only) */\n isFallback: boolean\n /** Markup applied (1.0 = catalog rate as-is) */\n markup: number\n}\n\nexport class UnknownModelError extends Error {\n constructor(public readonly modelId: string) {\n super(`Unknown model id: \"${modelId}\"`)\n this.name = \"UnknownModelError\"\n }\n}\n\nexport class CostUsageKindMismatchError extends Error {\n constructor(\n public readonly modelId: string,\n public readonly expected: string,\n public readonly got: string\n ) {\n super(\n `Model \"${modelId}\" is kind \"${expected}\", but received usage of kind \"${got}\"`\n )\n this.name = \"CostUsageKindMismatchError\"\n }\n}\n\nexport interface CalculateCostOptions {\n /**\n * App that's invoking the model. Routes per-app markup overrides\n * registered via `pricingRegistry.registerApp(appId, ...)`. When\n * omitted, core defaults apply.\n */\n appId?: string\n}\n\n/**\n * Computes credit + USD cost for a model run.\n *\n * Throws `UnknownModelError` for ids not in any catalog (LLM has its own\n * fallback path inside `calculateLLMCreditCost` — this surface preserves\n * that for back-compat).\n *\n * Throws `CostUsageKindMismatchError` if `usage.kind` doesn't match the\n * resolved model's kind (data integrity guard).\n *\n * Image / video / audio credits are derived at call time via the\n * pricing registry (`provider_cost × category-markup`). LLM keeps its\n * own per-model markup table inside `calculateLLMCreditCost` —\n * collapsing that follows in W6b.\n */\nexport function calculateCost(\n modelId: string,\n usage: CostUsage,\n opts: CalculateCostOptions = {}\n): CostResult {\n // LLM has a fallback path that returns valid pricing even for unknown\n // ids (preserves the orchestrator's existing tolerance). Other kinds\n // throw for unknowns.\n if (usage.kind === \"llm\") {\n const llmResult: LLMCreditCostResult = calculateLLMCreditCost(modelId, {\n inputTokens: usage.inputTokens,\n outputTokens: usage.outputTokens,\n cacheReadInputTokens: usage.cacheReadInputTokens,\n cacheCreationInputTokens: usage.cacheCreationInputTokens,\n })\n const resolved = getModel(modelId)\n const canonicalId =\n resolved && resolved.kind === \"llm\" ? resolved.canonicalId : modelId\n return {\n kind: \"llm\",\n modelId,\n canonicalId,\n credits: llmResult.credits,\n calculatedCredits: llmResult.calculatedCredits,\n baseCostUsd: llmResult.productionCost,\n breakdown: {\n inputCredits: llmResult.inputCredits,\n outputCredits: llmResult.outputCredits,\n cacheReadCredits: llmResult.cacheReadCredits,\n cacheWriteCredits: llmResult.cacheWriteCredits,\n },\n isFallback: llmResult.isFallback,\n markup: llmResult.markup,\n }\n }\n\n const resolved = getModel(modelId)\n if (!resolved) throw new UnknownModelError(modelId)\n // `voice` is structurally audio for billing purposes (MiniMax voice\n // metadata billed via per-character output). Accept `audio` usage on\n // voice models so the per-kind branches below can pattern-match.\n const expectedUsageKind: CostUsage[\"kind\"] =\n resolved.kind === \"voice\" ? \"audio\" : resolved.kind\n if (expectedUsageKind !== usage.kind) {\n // Pass `expectedUsageKind` (not `resolved.kind`) so the error message\n // accurately says \"audio\" rather than \"voice\" when a voice model is\n // billed — the caller must supply audio usage, not voice usage.\n throw new CostUsageKindMismatchError(modelId, expectedUsageKind, usage.kind)\n }\n\n if (resolved.kind === \"image\") {\n // `usage.kind` is \"image\" here (guarded above) but TS won't cross-narrow\n // it from `resolved.kind`, so check explicitly before reading numOutputs.\n const numOutputs = Math.max(\n 1,\n usage.kind === \"image\" ? (usage.numOutputs ?? 1) : 1\n )\n const baseCostUsd = resolved.def.pricing.baseCost * numOutputs\n const perOutputCredits = computeCenticredits({\n baseCostUsd: resolved.def.pricing.baseCost,\n category: \"image\",\n overrideCreditCost: resolved.def.pricing.overrideCreditCost,\n appId: opts.appId,\n })\n const credits = perOutputCredits * numOutputs\n // Formula-only (ignores override) — for `usage_events.calculated_credits`.\n const formulaPerOutput = computeCenticredits({\n baseCostUsd: resolved.def.pricing.baseCost,\n category: \"image\",\n appId: opts.appId,\n })\n const calculatedCredits = formulaPerOutput * numOutputs\n const markup = pricingRegistry.getMarkup(\"image\", opts.appId)\n return {\n kind: \"image\",\n modelId,\n canonicalId: modelId,\n credits,\n calculatedCredits,\n baseCostUsd,\n breakdown: {\n perOutputCredits,\n numOutputs,\n },\n isFallback: false,\n markup,\n }\n }\n\n if (resolved.kind === \"video\") {\n if (usage.kind !== \"video\") {\n throw new CostUsageKindMismatchError(modelId, \"video\", usage.kind)\n }\n const pricing = resolved.def.pricing\n // Provider-side multipliers — re-applied to BOTH the provider cost\n // (what we pay) AND the derived credit cost (so margin holds).\n const mult = pricing.multipliers\n const resMult =\n usage.resolution && mult?.resolution\n ? (mult.resolution[usage.resolution] ?? 1.0)\n : 1.0\n const durMult =\n usage.duration && mult?.duration\n ? (mult.duration[usage.duration] ?? 1.0)\n : 1.0\n const modMult =\n usage.mode && mult?.mode ? (mult.mode[usage.mode] ?? 1.0) : 1.0\n const variantMultiplier = resMult * durMult * modMult\n const baseCostUsd = pricing.baseCost * variantMultiplier\n const perClipCredits = computeCenticredits({\n baseCostUsd: pricing.baseCost,\n category: \"video\",\n overrideCreditCost: pricing.overrideCreditCost,\n appId: opts.appId,\n })\n const credits = Math.ceil(perClipCredits * variantMultiplier)\n const formulaPerClip = computeCenticredits({\n baseCostUsd: pricing.baseCost,\n category: \"video\",\n appId: opts.appId,\n })\n const calculatedCredits = Math.ceil(formulaPerClip * variantMultiplier)\n const markup = pricingRegistry.getMarkup(\"video\", opts.appId)\n return {\n kind: \"video\",\n modelId,\n canonicalId: modelId,\n credits,\n calculatedCredits,\n baseCostUsd,\n breakdown: {\n perClipCredits,\n resolutionMultiplier: resMult,\n durationMultiplier: durMult,\n modeMultiplier: modMult,\n variantMultiplier,\n },\n isFallback: false,\n markup,\n }\n }\n\n // Audio (and voice, delegated as audio — see expectedUsageKind above).\n if (usage.kind !== \"audio\") {\n throw new CostUsageKindMismatchError(modelId, \"audio\", usage.kind)\n }\n\n if (resolved.kind === \"voice\") {\n // Voice rows are metadata; delegate to the provider's default audio model.\n const provider = resolved.voice.provider\n const delegateModelId = VOICE_PROVIDER_DEFAULT_MODEL[provider]\n if (!delegateModelId) throw new UnknownModelError(modelId)\n const delegateResult = calculateCost(delegateModelId, usage, opts)\n return {\n ...delegateResult,\n modelId,\n canonicalId: delegateModelId,\n }\n }\n\n // Only `audio` remains (llm returned at top; image/video/voice handled\n // above). Narrow explicitly so `.def` is type-safe.\n if (resolved.kind !== \"audio\") throw new UnknownModelError(modelId)\n const audioPricing = resolved.def.pricing\n // Map the provider's billing unit to a quantity of billable units.\n // The catalog DATA uses `per_1k_chars` (chars ÷ 1000) and `per_minute`\n // (whole minutes, rounded UP to match provider invoicing). `per_character`\n // / `per_second` are handled too so a future data migration to those units\n // keeps working. NOTE: do not switch on the zod enum value alone — the\n // audio schema enum is stale (`per_character|per_second`) while the data\n // still ships `per_1k_chars|per_minute`; trusting the enum bills 0.\n const billingUnit = audioPricing.billingUnit as string\n let quantity: number\n switch (billingUnit) {\n case \"per_1k_chars\":\n quantity = Math.max(0, usage.characters ?? 0) / 1000\n break\n case \"per_character\":\n quantity = Math.max(0, usage.characters ?? 0)\n break\n case \"per_minute\":\n quantity = Math.ceil(Math.max(0, usage.seconds ?? 0) / 60)\n break\n case \"per_second\":\n default:\n quantity = Math.max(0, usage.seconds ?? 0)\n break\n }\n const baseCostUsd = audioPricing.baseCost * quantity\n const perUnitCredits = computeCenticredits({\n baseCostUsd: audioPricing.baseCost,\n category: \"audio\",\n overrideCreditCost: audioPricing.overrideCreditCost,\n appId: opts.appId,\n })\n // Per-call floor (1 cc) so a non-empty call never rounds to 0; a genuinely\n // empty call (quantity 0, e.g. empty-string TTS) bills nothing.\n const credits =\n quantity > 0 ? Math.max(1, Math.ceil(perUnitCredits * quantity)) : 0\n const formulaPerUnit = computeCenticredits({\n baseCostUsd: audioPricing.baseCost,\n category: \"audio\",\n appId: opts.appId,\n })\n const calculatedCredits =\n quantity > 0 ? Math.max(1, Math.ceil(formulaPerUnit * quantity)) : 0\n const markup = pricingRegistry.getMarkup(\"audio\", opts.appId)\n return {\n kind: \"audio\",\n modelId,\n canonicalId: modelId,\n credits,\n calculatedCredits,\n baseCostUsd,\n breakdown: {\n perUnitCredits,\n quantity,\n },\n isFallback: false,\n markup,\n }\n}\n\n// Thin ergonomic wrappers around `calculateCost`. Two reasons they exist:\n// 1. Callers with a known kind don't want to construct the full union.\n// 2. The kind/usage union is a `calculateCost` implementation detail —\n// wrapper types are narrower and easier to read at call sites.\n\nexport function calculateLLMCost(\n modelId: string,\n usage: {\n inputTokens: number\n outputTokens: number\n cacheReadInputTokens?: number\n cacheCreationInputTokens?: number\n },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"llm\", ...usage }, opts)\n}\n\nexport function calculateImageCost(\n modelId: string,\n usage: { numOutputs?: number },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"image\", ...usage }, opts)\n}\n\nexport function calculateVideoCost(\n modelId: string,\n usage: { resolution?: string; duration?: number; mode?: string },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"video\", ...usage }, opts)\n}\n\nexport function calculateAudioCost(\n modelId: string,\n usage: { characters?: number; seconds?: number },\n opts?: CalculateCostOptions\n): CostResult {\n return calculateCost(modelId, { kind: \"audio\", ...usage }, opts)\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { listModels } from './chunk-UWZLV4P2.mjs';
2
- import { modelHasTag } from './chunk-CEP4H4FD.mjs';
1
+ import { listModels } from './chunk-XJUZ5X3W.mjs';
2
+ import { modelHasTag } from './chunk-NNV3NYUE.mjs';
3
3
 
4
4
  /**
5
5
  * @agentproto/model-catalog v0.1.0
@@ -130,5 +130,5 @@ function filterVoicesByProviders(voices, providerTokens) {
130
130
  }
131
131
 
132
132
  export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile };
133
- //# sourceMappingURL=chunk-ITX3DL26.mjs.map
134
- //# sourceMappingURL=chunk-ITX3DL26.mjs.map
133
+ //# sourceMappingURL=chunk-6TZ6WIM3.mjs.map
134
+ //# sourceMappingURL=chunk-6TZ6WIM3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/curation/index.ts"],"names":[],"mappings":";;;;;;;;;;AAgDA,IAAM,eAAA,GAA4C;AAAA,EAChD,EAAE,IAAI,QAAA,EAAU,KAAA,EAAO,UAAU,SAAA,EAAW,CAAC,QAAA,EAAU,iBAAiB,CAAA,EAAE;AAAA,EAC1E,EAAE,IAAI,QAAA,EAAU,KAAA,EAAO,UAAU,SAAA,EAAW,CAAC,QAAA,EAAU,aAAa,CAAA,EAAE;AAAA,EACtE,EAAE,IAAI,WAAA,EAAa,KAAA,EAAO,aAAa,SAAA,EAAW,CAAC,WAAW,CAAA,EAAE;AAAA,EAChE,EAAE,IAAI,SAAA,EAAW,KAAA,EAAO,WAAW,SAAA,EAAW,CAAC,SAAS,CAA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A,EAAM;AAChB,IAAA,IAAI,CAAC,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAA,GAAA,KAAO,YAAY,KAAA,EAAO,GAAG,CAAC,CAAA,EAAG,OAAO,KAAA;AAAA,EAClE;AACA,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,YAAA,CACd,QACA,OAAA,EACiB;AACjB,EAAA,OAAO,OAAO,MAAA,CAAO,CAAA,KAAA,KAAS,mBAAA,CAAoB,KAAA,EAAO,OAAO,CAAC,CAAA;AACnE;AAMO,SAAS,aAAa,OAAA,EAA0C;AACrE,EAAA,OAAO,YAAA,CAAa,UAAA,EAAW,EAAG,OAAO,CAAA;AAC3C;AASO,SAAS,uBAAA,CACd,QACA,cAAA,EACgB;AAChB,EAAA,IAAI,cAAA,CAAe,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AACxC,EAAA,MAAM,IAAA,GAAO,IAAI,GAAA,CAAI,eAAA,CAAgB,cAAc,CAAC,CAAA;AACpD,EAAA,OAAO,OAAO,MAAA,CAAO,CAAA,CAAA,KAAK,KAAK,GAAA,CAAI,CAAA,CAAE,QAAQ,CAAC,CAAA;AAChD","file":"chunk-ITX3DL26.mjs","sourcesContent":["/**\n * Curation — what an app SURFACES from the catalog, distinct from\n * model-access (who MAY use a model: tier/scope policy). Curation is the\n * \"feature/provider catalog\" layer: an app composes views over the one\n * registry (\"all s2s voices from OpenAI OR Google\", \"images only\", …)\n * without touching the underlying data.\n *\n * Two registries, both following the canonical profile-registry shape\n * (`listX()` / `getX(id)` throwing with the known-id list):\n *\n * 1. PROVIDER GROUPS — a company (`openai`) maps to every provider tag\n * it owns across kinds (`openai` for the LLM/audio company tag,\n * `openai-realtime` for its voice engine). This is what reconciles\n * the two provider vocabularies in the registry: audio MODELS are\n * tagged by company, voices by engine. Curating by group spans both.\n *\n * 2. SURFACE PROFILES — named presets (`voice-s2s`, `images`, …) an app\n * selects from. Permissive by default (`all`); apps narrow only when\n * a picker should diverge.\n *\n * Selection precedence (caller's job): per-call arg → per-app/guild\n * config → env → `all` fallback.\n */\n\nimport {\n listModels,\n type CatalogKind,\n type ResolvedModel,\n} from \"../registry/index.js\"\nimport { modelHasTag } from \"../enrichment/index.js\"\nimport type { CatalogVoice } from \"../schema/voice.js\"\n\n// ───────────────────────────────────────────────────────────────────────\n// Provider groups — company → provider tags across kinds\n// ───────────────────────────────────────────────────────────────────────\n\nexport interface ProviderGroup {\n /** Canonical company id, e.g. \"openai\", \"google\". */\n id: string\n /** Display label. */\n label: string\n /**\n * Every provider tag this company owns across kinds. Audio/image/LLM use\n * the company tag (`openai`); the voice engine uses its own (`openai-realtime`).\n */\n providers: readonly string[]\n}\n\nconst PROVIDER_GROUPS: readonly ProviderGroup[] = [\n { id: \"openai\", label: \"OpenAI\", providers: [\"openai\", \"openai-realtime\"] },\n { id: \"google\", label: \"Google\", providers: [\"google\", \"gemini-live\"] },\n { id: \"anthropic\", label: \"Anthropic\", providers: [\"anthropic\"] },\n { id: \"minimax\", label: \"MiniMax\", providers: [\"minimax\"] },\n { id: \"elevenlabs\", label: \"ElevenLabs\", providers: [\"elevenlabs\"] },\n { id: \"replicate\", label: \"Replicate\", providers: [\"replicate\"] },\n { id: \"deepgram\", label: \"Deepgram\", providers: [\"deepgram\"] },\n { id: \"assemblyai\", label: \"AssemblyAI\", providers: [\"assemblyai\"] },\n]\n\nexport function listProviderGroups(): readonly ProviderGroup[] {\n return PROVIDER_GROUPS\n}\n\nexport function getProviderGroup(id: string): ProviderGroup {\n const group = PROVIDER_GROUPS.find(g => g.id === id)\n if (!group) {\n const known = PROVIDER_GROUPS.map(g => g.id).join(\", \")\n throw new Error(`curation: unknown provider group \"${id}\". Known: ${known}`)\n }\n return group\n}\n\n/** The group that owns a raw provider tag, if any. */\nexport function groupForProvider(\n providerTag: string\n): ProviderGroup | undefined {\n return PROVIDER_GROUPS.find(g => g.providers.includes(providerTag))\n}\n\n/**\n * Expand a mixed list of provider-group ids and raw provider tags into the\n * flat set of provider tags to match against. A token that is a known\n * group id expands to its members; anything else passes through as a raw\n * tag (so callers can target an engine directly, e.g. `gemini-live`).\n */\nexport function expandProviders(tokens: readonly string[]): string[] {\n const out = new Set<string>()\n for (const token of tokens) {\n const group = PROVIDER_GROUPS.find(g => g.id === token)\n if (group) {\n for (const p of group.providers) out.add(p)\n } else {\n out.add(token)\n }\n }\n return [...out]\n}\n\n// ───────────────────────────────────────────────────────────────────────\n// Surface profiles — named views an app surfaces\n// ───────────────────────────────────────────────────────────────────────\n\nexport interface SurfaceProfile {\n id: string\n description: string\n /** Restrict to these kinds. Undefined/empty = every kind. */\n kinds?: readonly CatalogKind[]\n /**\n * Restrict to these provider GROUP ids or raw provider tags (OR-set).\n * Expanded via `expandProviders`, so `[\"openai\"]` covers both the\n * `openai` company tag and the `openai-realtime` voice engine.\n */\n providers?: readonly string[]\n /** Require all of these capability tags (AND-set): `s2s`, `tts`, `edit`, … */\n capabilities?: readonly string[]\n /** Require all of these arbitrary tags (AND-set). */\n tags?: readonly string[]\n}\n\nconst SURFACE_PROFILES: readonly SurfaceProfile[] = [\n {\n id: \"all\",\n description: \"Everything the catalog offers — the permissive default\",\n },\n {\n id: \"text\",\n description: \"Text models (LLMs) only\",\n kinds: [\"llm\"],\n },\n {\n id: \"images\",\n description: \"Image models only\",\n kinds: [\"image\"],\n },\n {\n id: \"video\",\n description: \"Video models only\",\n kinds: [\"video\"],\n },\n {\n id: \"audio\",\n description: \"Audio models (TTS / STT / s2s) only\",\n kinds: [\"audio\"],\n },\n {\n id: \"voice\",\n description: \"Every curated voice, any provider\",\n kinds: [\"voice\"],\n },\n {\n id: \"voice-s2s\",\n description:\n \"Speech-to-speech voice engines (OpenAI Realtime, Gemini Live)\",\n kinds: [\"voice\"],\n capabilities: [\"s2s\"],\n },\n {\n id: \"voice-tts\",\n description: \"Sequential TTS voices (MiniMax, ElevenLabs)\",\n kinds: [\"voice\"],\n capabilities: [\"tts\"],\n },\n]\n\nexport function listSurfaceProfiles(): readonly SurfaceProfile[] {\n return SURFACE_PROFILES\n}\n\nexport function getSurfaceProfile(id: string): SurfaceProfile {\n const profile = SURFACE_PROFILES.find(p => p.id === id)\n if (!profile) {\n const known = SURFACE_PROFILES.map(p => p.id).join(\", \")\n throw new Error(\n `curation: unknown surface profile \"${id}\". Known: ${known}`\n )\n }\n return profile\n}\n\n// ───────────────────────────────────────────────────────────────────────\n// Filters\n// ───────────────────────────────────────────────────────────────────────\n\n/**\n * True iff a model passes a surface profile. Provider membership, like\n * capability/tag membership, is checked against the enrichment tag\n * vocabulary (every kind emits its provider as a tag), so this is uniform\n * across kinds and naturally spans the company/engine provider split.\n */\nexport function modelMatchesProfile(\n model: ResolvedModel,\n profile: SurfaceProfile\n): boolean {\n if (profile.kinds && profile.kinds.length > 0) {\n if (!profile.kinds.includes(model.kind)) return false\n }\n if (profile.providers && profile.providers.length > 0) {\n const tags = expandProviders(profile.providers)\n if (!tags.some(tag => modelHasTag(model, tag))) return false\n }\n if (profile.capabilities) {\n if (!profile.capabilities.every(cap => modelHasTag(model, cap)))\n return false\n }\n if (profile.tags) {\n if (!profile.tags.every(tag => modelHasTag(model, tag))) return false\n }\n return true\n}\n\n/** Filter a model list down to what a surface profile exposes. */\nexport function applyProfile(\n models: ResolvedModel[],\n profile: SurfaceProfile\n): ResolvedModel[] {\n return models.filter(model => modelMatchesProfile(model, profile))\n}\n\n/**\n * The catalog as a surface profile exposes it — `applyProfile` over the\n * full registry. The composable entry point for \"show me this view\".\n */\nexport function listSurfaced(profile: SurfaceProfile): ResolvedModel[] {\n return applyProfile(listModels(), profile)\n}\n\n/**\n * Voice-list curation. The merged voice catalog (curated + live\n * ElevenLabs) is `CatalogVoice[]`, not `ResolvedModel[]`, so it gets its\n * own provider filter — same group-expansion semantics. Only the provider\n * facet of a profile applies to a raw voice list (kind is implicitly\n * voice; capability/tag live on the registry projection).\n */\nexport function filterVoicesByProviders(\n voices: CatalogVoice[],\n providerTokens: readonly string[]\n): CatalogVoice[] {\n if (providerTokens.length === 0) return voices\n const tags = new Set(expandProviders(providerTokens))\n return voices.filter(v => tags.has(v.provider))\n}\n"]}
1
+ {"version":3,"sources":["../src/curation/index.ts"],"names":[],"mappings":";;;;;;;;;;AAgDA,IAAM,eAAA,GAA4C;AAAA,EAChD,EAAE,IAAI,QAAA,EAAU,KAAA,EAAO,UAAU,SAAA,EAAW,CAAC,QAAA,EAAU,iBAAiB,CAAA,EAAE;AAAA,EAC1E,EAAE,IAAI,QAAA,EAAU,KAAA,EAAO,UAAU,SAAA,EAAW,CAAC,QAAA,EAAU,aAAa,CAAA,EAAE;AAAA,EACtE,EAAE,IAAI,WAAA,EAAa,KAAA,EAAO,aAAa,SAAA,EAAW,CAAC,WAAW,CAAA,EAAE;AAAA,EAChE,EAAE,IAAI,SAAA,EAAW,KAAA,EAAO,WAAW,SAAA,EAAW,CAAC,SAAS,CAAA,EAAE;AAAA,EAC1D,EAAE,IAAI,YAAA,EAAc,KAAA,EAAO,cAAc,SAAA,EAAW,CAAC,YAAY,CAAA,EAAE;AAAA,EACnE,EAAE,IAAI,WAAA,EAAa,KAAA,EAAO,aAAa,SAAA,EAAW,CAAC,WAAW,CAAA,EAAE;AAAA,EAChE,EAAE,IAAI,UAAA,EAAY,KAAA,EAAO,YAAY,SAAA,EAAW,CAAC,UAAU,CAAA,EAAE;AAAA,EAC7D,EAAE,IAAI,YAAA,EAAc,KAAA,EAAO,cAAc,SAAA,EAAW,CAAC,YAAY,CAAA;AACnE,CAAA;AAEO,SAAS,kBAAA,GAA+C;AAC7D,EAAA,OAAO,eAAA;AACT;AAEO,SAAS,iBAAiB,EAAA,EAA2B;AAC1D,EAAA,MAAM,QAAQ,eAAA,CAAgB,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,OAAO,EAAE,CAAA;AACnD,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,MAAM,KAAA,GAAQ,gBAAgB,GAAA,CAAI,CAAA,CAAA,KAAK,EAAE,EAAE,CAAA,CA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,QAAQ,CAAC,CAAA;AAChD","file":"chunk-6TZ6WIM3.mjs","sourcesContent":["/**\n * Curation — what an app SURFACES from the catalog, distinct from\n * model-access (who MAY use a model: tier/scope policy). Curation is the\n * \"feature/provider catalog\" layer: an app composes views over the one\n * registry (\"all s2s voices from OpenAI OR Google\", \"images only\", …)\n * without touching the underlying data.\n *\n * Two registries, both following the canonical profile-registry shape\n * (`listX()` / `getX(id)` throwing with the known-id list):\n *\n * 1. PROVIDER GROUPS — a company (`openai`) maps to every provider tag\n * it owns across kinds (`openai` for the LLM/audio company tag,\n * `openai-realtime` for its voice engine). This is what reconciles\n * the two provider vocabularies in the registry: audio MODELS are\n * tagged by company, voices by engine. Curating by group spans both.\n *\n * 2. SURFACE PROFILES — named presets (`voice-s2s`, `images`, …) an app\n * selects from. Permissive by default (`all`); apps narrow only when\n * a picker should diverge.\n *\n * Selection precedence (caller's job): per-call arg → per-app/guild\n * config → env → `all` fallback.\n */\n\nimport {\n listModels,\n type CatalogKind,\n type ResolvedModel,\n} from \"../registry/index.js\"\nimport { modelHasTag } from \"../enrichment/index.js\"\nimport type { CatalogVoice } from \"../schema/voice.js\"\n\n// ───────────────────────────────────────────────────────────────────────\n// Provider groups — company → provider tags across kinds\n// ───────────────────────────────────────────────────────────────────────\n\nexport interface ProviderGroup {\n /** Canonical company id, e.g. \"openai\", \"google\". */\n id: string\n /** Display label. */\n label: string\n /**\n * Every provider tag this company owns across kinds. Audio/image/LLM use\n * the company tag (`openai`); the voice engine uses its own (`openai-realtime`).\n */\n providers: readonly string[]\n}\n\nconst PROVIDER_GROUPS: readonly ProviderGroup[] = [\n { id: \"openai\", label: \"OpenAI\", providers: [\"openai\", \"openai-realtime\"] },\n { id: \"google\", label: \"Google\", providers: [\"google\", \"gemini-live\"] },\n { id: \"anthropic\", label: \"Anthropic\", providers: [\"anthropic\"] },\n { id: \"minimax\", label: \"MiniMax\", providers: [\"minimax\"] },\n { id: \"elevenlabs\", label: \"ElevenLabs\", providers: [\"elevenlabs\"] },\n { id: \"replicate\", label: \"Replicate\", providers: [\"replicate\"] },\n { id: \"deepgram\", label: \"Deepgram\", providers: [\"deepgram\"] },\n { id: \"assemblyai\", label: \"AssemblyAI\", providers: [\"assemblyai\"] },\n]\n\nexport function listProviderGroups(): readonly ProviderGroup[] {\n return PROVIDER_GROUPS\n}\n\nexport function getProviderGroup(id: string): ProviderGroup {\n const group = PROVIDER_GROUPS.find(g => g.id === id)\n if (!group) {\n const known = PROVIDER_GROUPS.map(g => g.id).join(\", \")\n throw new Error(`curation: unknown provider group \"${id}\". Known: ${known}`)\n }\n return group\n}\n\n/** The group that owns a raw provider tag, if any. */\nexport function groupForProvider(\n providerTag: string\n): ProviderGroup | undefined {\n return PROVIDER_GROUPS.find(g => g.providers.includes(providerTag))\n}\n\n/**\n * Expand a mixed list of provider-group ids and raw provider tags into the\n * flat set of provider tags to match against. A token that is a known\n * group id expands to its members; anything else passes through as a raw\n * tag (so callers can target an engine directly, e.g. `gemini-live`).\n */\nexport function expandProviders(tokens: readonly string[]): string[] {\n const out = new Set<string>()\n for (const token of tokens) {\n const group = PROVIDER_GROUPS.find(g => g.id === token)\n if (group) {\n for (const p of group.providers) out.add(p)\n } else {\n out.add(token)\n }\n }\n return [...out]\n}\n\n// ───────────────────────────────────────────────────────────────────────\n// Surface profiles — named views an app surfaces\n// ───────────────────────────────────────────────────────────────────────\n\nexport interface SurfaceProfile {\n id: string\n description: string\n /** Restrict to these kinds. Undefined/empty = every kind. */\n kinds?: readonly CatalogKind[]\n /**\n * Restrict to these provider GROUP ids or raw provider tags (OR-set).\n * Expanded via `expandProviders`, so `[\"openai\"]` covers both the\n * `openai` company tag and the `openai-realtime` voice engine.\n */\n providers?: readonly string[]\n /** Require all of these capability tags (AND-set): `s2s`, `tts`, `edit`, … */\n capabilities?: readonly string[]\n /** Require all of these arbitrary tags (AND-set). */\n tags?: readonly string[]\n}\n\nconst SURFACE_PROFILES: readonly SurfaceProfile[] = [\n {\n id: \"all\",\n description: \"Everything the catalog offers — the permissive default\",\n },\n {\n id: \"text\",\n description: \"Text models (LLMs) only\",\n kinds: [\"llm\"],\n },\n {\n id: \"images\",\n description: \"Image models only\",\n kinds: [\"image\"],\n },\n {\n id: \"video\",\n description: \"Video models only\",\n kinds: [\"video\"],\n },\n {\n id: \"audio\",\n description: \"Audio models (TTS / STT / s2s) only\",\n kinds: [\"audio\"],\n },\n {\n id: \"voice\",\n description: \"Every curated voice, any provider\",\n kinds: [\"voice\"],\n },\n {\n id: \"voice-s2s\",\n description:\n \"Speech-to-speech voice engines (OpenAI Realtime, Gemini Live)\",\n kinds: [\"voice\"],\n capabilities: [\"s2s\"],\n },\n {\n id: \"voice-tts\",\n description: \"Sequential TTS voices (MiniMax, ElevenLabs)\",\n kinds: [\"voice\"],\n capabilities: [\"tts\"],\n },\n]\n\nexport function listSurfaceProfiles(): readonly SurfaceProfile[] {\n return SURFACE_PROFILES\n}\n\nexport function getSurfaceProfile(id: string): SurfaceProfile {\n const profile = SURFACE_PROFILES.find(p => p.id === id)\n if (!profile) {\n const known = SURFACE_PROFILES.map(p => p.id).join(\", \")\n throw new Error(\n `curation: unknown surface profile \"${id}\". Known: ${known}`\n )\n }\n return profile\n}\n\n// ───────────────────────────────────────────────────────────────────────\n// Filters\n// ───────────────────────────────────────────────────────────────────────\n\n/**\n * True iff a model passes a surface profile. Provider membership, like\n * capability/tag membership, is checked against the enrichment tag\n * vocabulary (every kind emits its provider as a tag), so this is uniform\n * across kinds and naturally spans the company/engine provider split.\n */\nexport function modelMatchesProfile(\n model: ResolvedModel,\n profile: SurfaceProfile\n): boolean {\n if (profile.kinds && profile.kinds.length > 0) {\n if (!profile.kinds.includes(model.kind)) return false\n }\n if (profile.providers && profile.providers.length > 0) {\n const tags = expandProviders(profile.providers)\n if (!tags.some(tag => modelHasTag(model, tag))) return false\n }\n if (profile.capabilities) {\n if (!profile.capabilities.every(cap => modelHasTag(model, cap)))\n return false\n }\n if (profile.tags) {\n if (!profile.tags.every(tag => modelHasTag(model, tag))) return false\n }\n return true\n}\n\n/** Filter a model list down to what a surface profile exposes. */\nexport function applyProfile(\n models: ResolvedModel[],\n profile: SurfaceProfile\n): ResolvedModel[] {\n return models.filter(model => modelMatchesProfile(model, profile))\n}\n\n/**\n * The catalog as a surface profile exposes it — `applyProfile` over the\n * full registry. The composable entry point for \"show me this view\".\n */\nexport function listSurfaced(profile: SurfaceProfile): ResolvedModel[] {\n return applyProfile(listModels(), profile)\n}\n\n/**\n * Voice-list curation. The merged voice catalog (curated + live\n * ElevenLabs) is `CatalogVoice[]`, not `ResolvedModel[]`, so it gets its\n * own provider filter — same group-expansion semantics. Only the provider\n * facet of a profile applies to a raw voice list (kind is implicitly\n * voice; capability/tag live on the registry projection).\n */\nexport function filterVoicesByProviders(\n voices: CatalogVoice[],\n providerTokens: readonly string[]\n): CatalogVoice[] {\n if (providerTokens.length === 0) return voices\n const tags = new Set(expandProviders(providerTokens))\n return voices.filter(v => tags.has(v.provider))\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { CatalogProviderSchema } from './chunk-WG4F6IRS.mjs';
2
- import { resolvePricing, resolveAlias, OPENCODE_GO_ROUTES, OPENCODE_ZEN_ROUTES, OPENROUTER_ROUTES, DEFAULT_PRICING } from './chunk-Z2WIEJR7.mjs';
2
+ import { resolvePricing, resolveAlias, OPENCODE_GO_ROUTES, OPENCODE_ZEN_ROUTES, OPENROUTER_ROUTES, DEFAULT_PRICING } from './chunk-TVXNRUJM.mjs';
3
3
 
4
4
  /**
5
5
  * @agentproto/model-catalog v0.1.0
@@ -2437,6 +2437,22 @@ var REQUESTY_ROUTES = {
2437
2437
  vendor: "deepinfra",
2438
2438
  provider: "requesty"
2439
2439
  },
2440
+ "deepinfra/deepseek-v4.1-flash-1017": {
2441
+ inputPer1M: 0.098,
2442
+ outputPer1M: 0.294,
2443
+ cacheReadMultiplier: 0.03,
2444
+ addedAt: "2026-10-17",
2445
+ vendor: "deepinfra",
2446
+ provider: "requesty"
2447
+ },
2448
+ "deepinfra/deepseek-v4.1-flash-1017:priority": {
2449
+ inputPer1M: 0.147,
2450
+ outputPer1M: 0.441,
2451
+ cacheReadMultiplier: 0.03,
2452
+ addedAt: "2026-10-17",
2453
+ vendor: "deepinfra",
2454
+ provider: "requesty"
2455
+ },
2440
2456
  "deepinfra/deepseek-v4.1-flash:flex": {
2441
2457
  inputPer1M: 0.16,
2442
2458
  outputPer1M: 0.48,
@@ -2818,6 +2834,14 @@ var REQUESTY_ROUTES = {
2818
2834
  vendor: "fireworks",
2819
2835
  provider: "requesty"
2820
2836
  },
2837
+ "fireworks/deepseek-v4.1-flash-1017": {
2838
+ inputPer1M: 0.3,
2839
+ outputPer1M: 1.2,
2840
+ cacheReadMultiplier: 0.02,
2841
+ addedAt: "2026-10-17",
2842
+ vendor: "fireworks",
2843
+ provider: "requesty"
2844
+ },
2821
2845
  "fireworks/glm-5.1": {
2822
2846
  inputPer1M: 1.4,
2823
2847
  outputPer1M: 4.4,
@@ -4756,6 +4780,14 @@ var REQUESTY_ROUTES = {
4756
4780
  vendor: "tensorx",
4757
4781
  provider: "requesty"
4758
4782
  },
4783
+ "tensorx/deepseek-v4.1-flash-1017": {
4784
+ inputPer1M: 0.5,
4785
+ outputPer1M: 1.5,
4786
+ cacheReadMultiplier: 0.26,
4787
+ addedAt: "2026-10-17",
4788
+ vendor: "tensorx",
4789
+ provider: "requesty"
4790
+ },
4759
4791
  "tensorx/glm-5.2": {
4760
4792
  inputPer1M: 1.5,
4761
4793
  outputPer1M: 4.5,
@@ -4859,6 +4891,14 @@ var REQUESTY_ROUTES = {
4859
4891
  vendor: "together",
4860
4892
  provider: "requesty"
4861
4893
  },
4894
+ "together/deepseek-v4.1-flash-1017": {
4895
+ inputPer1M: 0.3,
4896
+ outputPer1M: 1.2,
4897
+ cacheReadMultiplier: 0.02,
4898
+ addedAt: "2026-10-17",
4899
+ vendor: "together",
4900
+ provider: "requesty"
4901
+ },
4862
4902
  "together/glm-5.3": {
4863
4903
  inputPer1M: 1.4,
4864
4904
  outputPer1M: 4.4,
@@ -6246,7 +6286,7 @@ var HUGGINGFACE_ROUTES = {
6246
6286
  provider: "cohere",
6247
6287
  status: "live",
6248
6288
  supportsTools: false,
6249
- supportsStructuredOutput: true
6289
+ supportsStructuredOutput: false
6250
6290
  }
6251
6291
  ]
6252
6292
  },
@@ -6529,7 +6569,7 @@ var HUGGINGFACE_ROUTES = {
6529
6569
  inputPer1M: 0.07,
6530
6570
  outputPer1M: 0.2,
6531
6571
  supportsTools: true,
6532
- supportsStructuredOutput: true
6572
+ supportsStructuredOutput: false
6533
6573
  }
6534
6574
  ]
6535
6575
  },
@@ -6547,7 +6587,7 @@ var HUGGINGFACE_ROUTES = {
6547
6587
  inputPer1M: 0.2,
6548
6588
  outputPer1M: 0.6,
6549
6589
  supportsTools: true,
6550
- supportsStructuredOutput: true
6590
+ supportsStructuredOutput: false
6551
6591
  }
6552
6592
  ]
6553
6593
  },
@@ -6624,7 +6664,7 @@ var HUGGINGFACE_ROUTES = {
6624
6664
  inputPer1M: 0.08,
6625
6665
  outputPer1M: 0.28,
6626
6666
  supportsTools: true,
6627
- supportsStructuredOutput: false
6667
+ supportsStructuredOutput: true
6628
6668
  },
6629
6669
  {
6630
6670
  provider: "featherless-ai",
@@ -6782,15 +6822,6 @@ var HUGGINGFACE_ROUTES = {
6782
6822
  outputPer1M: 2.4,
6783
6823
  supportsTools: true,
6784
6824
  supportsStructuredOutput: true
6785
- },
6786
- {
6787
- provider: "novita",
6788
- status: "live",
6789
- contextLength: 262144,
6790
- inputPer1M: 0.4,
6791
- outputPer1M: 3.2,
6792
- supportsTools: true,
6793
- supportsStructuredOutput: false
6794
6825
  }
6795
6826
  ]
6796
6827
  },
@@ -6973,7 +7004,7 @@ var HUGGINGFACE_ROUTES = {
6973
7004
  inputPer1M: 0.285,
6974
7005
  outputPer1M: 1.71,
6975
7006
  supportsTools: true,
6976
- supportsStructuredOutput: false
7007
+ supportsStructuredOutput: true
6977
7008
  }
6978
7009
  ]
6979
7010
  },
@@ -7028,6 +7059,15 @@ var HUGGINGFACE_ROUTES = {
7028
7059
  supportsTools: true,
7029
7060
  supportsStructuredOutput: true
7030
7061
  },
7062
+ {
7063
+ provider: "deepinfra",
7064
+ status: "live",
7065
+ contextLength: 262144,
7066
+ inputPer1M: 0.2,
7067
+ outputPer1M: 2.5,
7068
+ supportsTools: true,
7069
+ supportsStructuredOutput: true
7070
+ },
7031
7071
  {
7032
7072
  provider: "featherless-ai",
7033
7073
  status: "live"
@@ -7134,20 +7174,6 @@ var HUGGINGFACE_ROUTES = {
7134
7174
  }
7135
7175
  ]
7136
7176
  },
7137
- "XiaomiMiMo/MiMo-V2.6-Pro-RL": {
7138
- wireId: "XiaomiMiMo/MiMo-V2.6-Pro-RL",
7139
- providers: [
7140
- {
7141
- provider: "novita",
7142
- status: "live",
7143
- contextLength: 1048576,
7144
- inputPer1M: 0.435,
7145
- outputPer1M: 0.87,
7146
- supportsTools: true,
7147
- supportsStructuredOutput: false
7148
- }
7149
- ]
7150
- },
7151
7177
  "aisingapore/Gemma-SEA-LION-v4-27B-IT": {
7152
7178
  wireId: "aisingapore/Gemma-SEA-LION-v4-27B-IT",
7153
7179
  providers: [
@@ -7206,7 +7232,7 @@ var HUGGINGFACE_ROUTES = {
7206
7232
  inputPer1M: 0.7,
7207
7233
  outputPer1M: 2.5,
7208
7234
  supportsTools: true,
7209
- supportsStructuredOutput: true
7235
+ supportsStructuredOutput: false
7210
7236
  }
7211
7237
  ]
7212
7238
  },
@@ -7493,7 +7519,7 @@ var HUGGINGFACE_ROUTES = {
7493
7519
  inputPer1M: 1.32,
7494
7520
  outputPer1M: 3.96,
7495
7521
  supportsTools: true,
7496
- supportsStructuredOutput: true
7522
+ supportsStructuredOutput: false
7497
7523
  },
7498
7524
  {
7499
7525
  provider: "deepinfra",
@@ -7567,6 +7593,20 @@ var HUGGINGFACE_ROUTES = {
7567
7593
  }
7568
7594
  ]
7569
7595
  },
7596
+ "deepseek-ai/DeepSeek-V4.1-Flash-1017": {
7597
+ wireId: "deepseek-ai/DeepSeek-V4.1-Flash-1017",
7598
+ providers: [
7599
+ {
7600
+ provider: "novita",
7601
+ status: "live",
7602
+ contextLength: 1048576,
7603
+ inputPer1M: 0.3,
7604
+ outputPer1M: 1.2,
7605
+ supportsTools: true,
7606
+ supportsStructuredOutput: false
7607
+ }
7608
+ ]
7609
+ },
7570
7610
  "google/gemma-3-12b-it": {
7571
7611
  wireId: "google/gemma-3-12b-it",
7572
7612
  providers: [
@@ -7644,7 +7684,7 @@ var HUGGINGFACE_ROUTES = {
7644
7684
  inputPer1M: 0.13,
7645
7685
  outputPer1M: 0.4,
7646
7686
  supportsTools: true,
7647
- supportsStructuredOutput: false
7687
+ supportsStructuredOutput: true
7648
7688
  },
7649
7689
  {
7650
7690
  provider: "scaleway",
@@ -7905,24 +7945,6 @@ var HUGGINGFACE_ROUTES = {
7905
7945
  "meta-llama/Llama-4-Scout-17B-16E-Instruct": {
7906
7946
  wireId: "meta-llama/Llama-4-Scout-17B-16E-Instruct",
7907
7947
  providers: [
7908
- {
7909
- provider: "deepinfra",
7910
- status: "live",
7911
- contextLength: 327680,
7912
- inputPer1M: 0.1,
7913
- outputPer1M: 0.3,
7914
- supportsTools: true,
7915
- supportsStructuredOutput: true
7916
- },
7917
- {
7918
- provider: "novita",
7919
- status: "live",
7920
- contextLength: 131072,
7921
- inputPer1M: 0.18,
7922
- outputPer1M: 0.59,
7923
- supportsTools: false,
7924
- supportsStructuredOutput: false
7925
- },
7926
7948
  {
7927
7949
  provider: "nscale",
7928
7950
  status: "live",
@@ -7958,7 +7980,7 @@ var HUGGINGFACE_ROUTES = {
7958
7980
  inputPer1M: 0.3,
7959
7981
  outputPer1M: 1.2,
7960
7982
  supportsTools: true,
7961
- supportsStructuredOutput: true
7983
+ supportsStructuredOutput: false
7962
7984
  },
7963
7985
  {
7964
7986
  provider: "featherless-ai",
@@ -8035,7 +8057,7 @@ var HUGGINGFACE_ROUTES = {
8035
8057
  inputPer1M: 0.6,
8036
8058
  outputPer1M: 2.5,
8037
8059
  supportsTools: true,
8038
- supportsStructuredOutput: true
8060
+ supportsStructuredOutput: false
8039
8061
  }
8040
8062
  ]
8041
8063
  },
@@ -8062,7 +8084,7 @@ var HUGGINGFACE_ROUTES = {
8062
8084
  inputPer1M: 0.6,
8063
8085
  outputPer1M: 3,
8064
8086
  supportsTools: true,
8065
- supportsStructuredOutput: true
8087
+ supportsStructuredOutput: false
8066
8088
  }
8067
8089
  ]
8068
8090
  },
@@ -8304,7 +8326,7 @@ var HUGGINGFACE_ROUTES = {
8304
8326
  inputPer1M: 0.171,
8305
8327
  outputPer1M: 0.684,
8306
8328
  supportsTools: true,
8307
- supportsStructuredOutput: false
8329
+ supportsStructuredOutput: true
8308
8330
  },
8309
8331
  {
8310
8332
  provider: "together",
@@ -8515,7 +8537,7 @@ var HUGGINGFACE_ROUTES = {
8515
8537
  inputPer1M: 0.95,
8516
8538
  outputPer1M: 4.05,
8517
8539
  supportsTools: true,
8518
- supportsStructuredOutput: false
8540
+ supportsStructuredOutput: true
8519
8541
  },
8520
8542
  {
8521
8543
  provider: "fireworks-ai",
@@ -8531,7 +8553,7 @@ var HUGGINGFACE_ROUTES = {
8531
8553
  inputPer1M: 1,
8532
8554
  outputPer1M: 4.05,
8533
8555
  supportsTools: true,
8534
- supportsStructuredOutput: true
8556
+ supportsStructuredOutput: false
8535
8557
  }
8536
8558
  ]
8537
8559
  },
@@ -8732,6 +8754,17 @@ var HUGGINGFACE_ROUTES = {
8732
8754
  }
8733
8755
  ]
8734
8756
  },
8757
+ "zai-org/GLM-4.7-FP8": {
8758
+ wireId: "zai-org/GLM-4.7-FP8",
8759
+ providers: [
8760
+ {
8761
+ provider: "zai-org",
8762
+ status: "live",
8763
+ supportsTools: true,
8764
+ supportsStructuredOutput: false
8765
+ }
8766
+ ]
8767
+ },
8735
8768
  "zai-org/GLM-4.7-Flash": {
8736
8769
  wireId: "zai-org/GLM-4.7-Flash",
8737
8770
  providers: [
@@ -8798,35 +8831,6 @@ var HUGGINGFACE_ROUTES = {
8798
8831
  }
8799
8832
  ]
8800
8833
  },
8801
- "zai-org/GLM-5.1": {
8802
- wireId: "zai-org/GLM-5.1",
8803
- providers: [
8804
- {
8805
- provider: "deepinfra",
8806
- status: "live",
8807
- contextLength: 202752,
8808
- inputPer1M: 1.05,
8809
- outputPer1M: 3.5,
8810
- supportsTools: true,
8811
- supportsStructuredOutput: true
8812
- },
8813
- {
8814
- provider: "featherless-ai",
8815
- status: "live"
8816
- }
8817
- ]
8818
- },
8819
- "zai-org/GLM-5.1-FP8": {
8820
- wireId: "zai-org/GLM-5.1-FP8",
8821
- providers: [
8822
- {
8823
- provider: "zai-org",
8824
- status: "live",
8825
- supportsTools: true,
8826
- supportsStructuredOutput: false
8827
- }
8828
- ]
8829
- },
8830
8834
  "zai-org/GLM-5.2": {
8831
8835
  wireId: "zai-org/GLM-5.2",
8832
8836
  providers: [
@@ -8867,7 +8871,7 @@ var HUGGINGFACE_ROUTES = {
8867
8871
  inputPer1M: 2.052,
8868
8872
  outputPer1M: 6.27,
8869
8873
  supportsTools: true,
8870
- supportsStructuredOutput: true
8874
+ supportsStructuredOutput: false
8871
8875
  },
8872
8876
  {
8873
8877
  provider: "together",
@@ -8909,15 +8913,6 @@ var HUGGINGFACE_ROUTES = {
8909
8913
  supportsTools: true,
8910
8914
  supportsStructuredOutput: true
8911
8915
  },
8912
- {
8913
- provider: "deepinfra",
8914
- status: "live",
8915
- contextLength: 1048576,
8916
- inputPer1M: 0.9,
8917
- outputPer1M: 4,
8918
- supportsTools: true,
8919
- supportsStructuredOutput: true
8920
- },
8921
8916
  {
8922
8917
  provider: "featherless-ai",
8923
8918
  status: "live"
@@ -9005,7 +9000,7 @@ var HUGGINGFACE_ROUTES = {
9005
9000
  inputPer1M: 0.15,
9006
9001
  outputPer1M: 0.5,
9007
9002
  supportsTools: true,
9008
- supportsStructuredOutput: false
9003
+ supportsStructuredOutput: true
9009
9004
  },
9010
9005
  {
9011
9006
  provider: "together",
@@ -9377,5 +9372,5 @@ function diagnoseModelRef(input) {
9377
9372
  }
9378
9373
 
9379
9374
  export { InvalidModelRefError, OPENROUTER_VARIANTS, clearCustomRoutes, diagnoseModelRef, formatModelRef, isModelRefString, listRouterLlmRoutes, parseModelRef, registerCustomRoute, resolveCustomRoute, resolveLlmModelRoute, stripAnthropicNativeVendor, stripFixedNativeVendor, stripRouteSuffix, tryParseModelRef };
9380
- //# sourceMappingURL=chunk-XYM6UG7C.mjs.map
9381
- //# sourceMappingURL=chunk-XYM6UG7C.mjs.map
9375
+ //# sourceMappingURL=chunk-ALUIW3QO.mjs.map
9376
+ //# sourceMappingURL=chunk-ALUIW3QO.mjs.map