@agentproto/model-catalog 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/access/index.d.ts +4 -3
  2. package/dist/access/index.mjs +5 -4
  3. package/dist/{catalog-DRGEICKV.d.ts → catalog-BB0uDJh-.d.ts} +25 -37
  4. package/dist/{chunk-ALUIW3QO.mjs → chunk-BXTZ2EDE.mjs} +217 -482
  5. package/dist/chunk-BXTZ2EDE.mjs.map +1 -0
  6. package/dist/{chunk-6TZ6WIM3.mjs → chunk-DTE62ERL.mjs} +4 -4
  7. package/dist/{chunk-6TZ6WIM3.mjs.map → chunk-DTE62ERL.mjs.map} +1 -1
  8. package/dist/{chunk-XJUZ5X3W.mjs → chunk-ETI76MOK.mjs} +5 -5
  9. package/dist/{chunk-XJUZ5X3W.mjs.map → chunk-ETI76MOK.mjs.map} +1 -1
  10. package/dist/chunk-HFPX2DNR.mjs +3 -0
  11. package/dist/chunk-HFPX2DNR.mjs.map +1 -0
  12. package/dist/{chunk-UOOTUH6N.mjs → chunk-IHU6XTXS.mjs} +3 -3
  13. package/dist/{chunk-UOOTUH6N.mjs.map → chunk-IHU6XTXS.mjs.map} +1 -1
  14. package/dist/{chunk-TVXNRUJM.mjs → chunk-MZ23K5W6.mjs} +186 -204
  15. package/dist/chunk-MZ23K5W6.mjs.map +1 -0
  16. package/dist/{chunk-TZ5LNR5F.mjs → chunk-PVE3WQRH.mjs} +8 -6
  17. package/dist/chunk-PVE3WQRH.mjs.map +1 -0
  18. package/dist/{chunk-5EX3V7QZ.mjs → chunk-W7K6DGOK.mjs} +4 -4
  19. package/dist/{chunk-5EX3V7QZ.mjs.map → chunk-W7K6DGOK.mjs.map} +1 -1
  20. package/dist/{chunk-NNV3NYUE.mjs → chunk-YSEQMLV2.mjs} +14 -5
  21. package/dist/chunk-YSEQMLV2.mjs.map +1 -0
  22. package/dist/cost/index.mjs +6 -6
  23. package/dist/curation/index.d.ts +2 -2
  24. package/dist/curation/index.mjs +6 -6
  25. package/dist/evaluate-BjSlZsJf.d.ts +49 -0
  26. package/dist/{index-VuUTv1ft.d.ts → index-D8FWHlom.d.ts} +1 -1
  27. package/dist/index-DetGJJ-F.d.ts +78 -0
  28. package/dist/index.d.ts +7 -5
  29. package/dist/index.mjs +11 -10
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/lists/index.d.ts +70 -0
  32. package/dist/lists/index.mjs +290 -0
  33. package/dist/lists/index.mjs.map +1 -0
  34. package/dist/llm/index.d.ts +1 -1
  35. package/dist/llm/index.mjs +2 -2
  36. package/dist/overlay/index.d.ts +1 -1
  37. package/dist/picker/index.d.ts +112 -5
  38. package/dist/route-identity/index.d.ts +1 -1
  39. package/dist/route-identity/index.mjs +2 -2
  40. package/dist/types-DMzMWJeJ.d.ts +50 -0
  41. package/package.json +8 -3
  42. package/dist/chunk-ALUIW3QO.mjs.map +0 -1
  43. package/dist/chunk-NNV3NYUE.mjs.map +0 -1
  44. package/dist/chunk-TVXNRUJM.mjs.map +0 -1
  45. package/dist/chunk-TZ5LNR5F.mjs.map +0 -1
  46. package/dist/evaluate-B-irutMW.d.ts +0 -84
  47. package/dist/index-kbLggJk1.d.ts +0 -171
@@ -1,4 +1,4 @@
1
- import { modelMatchesPriceTier, modelHasTag } from './chunk-NNV3NYUE.mjs';
1
+ import { modelMatchesPriceTier, modelHasTag } from './chunk-YSEQMLV2.mjs';
2
2
 
3
3
  /**
4
4
  * @agentproto/model-catalog v0.1.0
@@ -30,8 +30,7 @@ var NON_MODEL_SPECIFICITY = {
30
30
  kind: 1
31
31
  };
32
32
  var NSFW_TAG_BLOCK_REASONS = /* @__PURE__ */ new Set(["nsfw", "compliance"]);
33
- function ruleMatches(rule, model) {
34
- const target = rule.target;
33
+ function modelMatchesTarget(target, model) {
35
34
  switch (target.kind) {
36
35
  case "model":
37
36
  return target.id === model.id;
@@ -57,6 +56,9 @@ function ruleMatches(rule, model) {
57
56
  return modelMatchesPriceTier(model, target.value);
58
57
  }
59
58
  }
59
+ function ruleMatches(rule, model) {
60
+ return modelMatchesTarget(rule.target, model);
61
+ }
60
62
  function evaluateAccess(input) {
61
63
  const { model, appScope, rules = [], byokActive = false } = input;
62
64
  if (appScope && appScope.kinds.length > 0 && model.kind !== "voice" && !appScope.kinds.includes(model.kind)) {
@@ -111,6 +113,6 @@ function evaluateAccess(input) {
111
113
  return { allowed: fallback.allowed, reason: fallback.reason };
112
114
  }
113
115
 
114
- export { evaluateAccess, evaluateCatalogDefaults };
115
- //# sourceMappingURL=chunk-TZ5LNR5F.mjs.map
116
- //# sourceMappingURL=chunk-TZ5LNR5F.mjs.map
116
+ export { evaluateAccess, evaluateCatalogDefaults, modelMatchesTarget };
117
+ //# sourceMappingURL=chunk-PVE3WQRH.mjs.map
118
+ //# sourceMappingURL=chunk-PVE3WQRH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/access/catalog-defaults.ts","../src/access/evaluate.ts"],"names":[],"mappings":";;;;;;;;;AAmBO,SAAS,wBACd,KAAA,EACwB;AACxB,EAAA,QAAQ,MAAM,IAAA;AAAM,IAClB,KAAK,OAAA;AACH,MAAA,OAAO,KAAA,CAAM,GAAA,CAAI,YAAA,GACb,EAAE,OAAA,EAAS,IAAA,EAAM,MAAA,EAAQ,+BAAA,EAAgC,GACzD,EAAE,OAAA,EAAS,KAAA,EAAO,QAAQ,8BAAA,EAA+B;AAAA,IAC/D,KAAK,OAAA;AACH,MAAA,OAAO,KAAA,CAAM,GAAA,CAAI,YAAA,GACb,EAAE,OAAA,EAAS,IAAA,EAAM,MAAA,EAAQ,+BAAA,EAAgC,GACzD,EAAE,OAAA,EAAS,KAAA,EAAO,QAAQ,8BAAA,EAA+B;AAAA,IAC/D,KAAK,KAAA;AAEH,MAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,MAAA,EAAQ,6BAAA,EAA8B;AAAA,IAChE,KAAK,OAAA;AACH,MAAA,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,GAAI,CAAC,CAAA;AACnE,IAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,MAAA,MAAM,SAAA,GAAY,aAAA,CAAc,GAAA,CAAI,IAAI,CAAA;AACxC,MAAA,MAAM,UAAU,SAAA,CAAU,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,WAAW,OAAO,CAAA;AACxD,MAAA,MAAM,UAAU,SAAA,CAAU,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,WAAW,OAAO,CAAA;AACxD,MAAA,MAAM,SAAS,OAAA,IAAW,OAAA;AAC1B,MAAA,IAAI,CAAC,MAAA,EAAQ;AACb,MAAA,MAAM,IAAI,MAAA,CAAO,MAAA;AACjB,MAAA,MAAM,SAAA,GACJ,CAAA,CAAE,IAAA,KAAS,OAAA,GACP,CAAA,MAAA,EAAU,CAAA,CAAqB,EAAE,CAAA,CAAA,GACjC,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAK,EAAwB,KAAK,CAAA,CAAA;AACjD,MAAA,MAAM,OAAO,MAAA,CAAO,MAAA,GAAS,CAAA,CAAA,EAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AACnD,MAAA,OAAO;AAAA,QACL,OAAA,EAAS,OAAO,MAAA,KAAW,OAAA;AAAA,QAC3B,QAAQ,CAAA,KAAA,EAAQ,SAAS,IAAI,MAAA,CAAO,MAAM,GAAG,IAAI,CAAA;AAAA,OACnD;AAAA,IACF;AAAA,EACF;AAGA,EAAA,MAAM,QAAA,GAAW,wBAAwB,KAAK,CAAA;AAC9C,EAAA,OAAO,EAAE,OAAA,EAAS,QAAA,CAAS,OAAA,EAAS,MAAA,EAAQ,SAAS,MAAA,EAAO;AAC9D","file":"chunk-PVE3WQRH.mjs","sourcesContent":["/**\n * Catalog-flag defaults — the layer that runs before any workspace\n * override. Mirrors the access-control plan:\n * - Default-allow: `lifecycle = stable && agentVisible = true`\n * - Default-block: `lifecycle = preview` or `lifecycle = deprecated`\n * - Default-block: any model with `agentVisible = false`\n *\n * Legacy catalog data (image/video) carries `agentVisible` but not\n * `lifecycle` — until v2 normalization, lifecycle defaults to \"stable\"\n * for every entry. LLM and audio entries default to allow (curated).\n */\n\nimport type { ResolvedModel } from \"../registry/index.js\"\n\nexport interface CatalogDefaultDecision {\n allowed: boolean\n reason: string\n}\n\nexport function evaluateCatalogDefaults(\n model: ResolvedModel\n): CatalogDefaultDecision {\n switch (model.kind) {\n case \"image\":\n return model.def.agentVisible\n ? { allowed: true, reason: \"catalog-default:agent-visible\" }\n : { allowed: false, reason: \"catalog-default:agent-hidden\" }\n case \"video\":\n return model.def.agentVisible\n ? { allowed: true, reason: \"catalog-default:agent-visible\" }\n : { allowed: false, reason: \"catalog-default:agent-hidden\" }\n case \"llm\":\n // LLM entries are curated — every catalog entry is visible.\n return { allowed: true, reason: \"catalog-default:llm-curated\" }\n case \"audio\":\n return model.def.agentVisible\n ? { allowed: true, reason: \"catalog-default:agent-visible\" }\n : { allowed: false, reason: \"catalog-default:agent-hidden\" }\n case \"voice\":\n // Voice metadata catalog is curated.\n return { allowed: true, reason: \"catalog-default:voice-curated\" }\n }\n}\n","/**\n * Access evaluator — resolves whether a workspace can use a given model.\n *\n * Resolution order:\n * 1. App scope — if the app opts out of the model's kind, deny.\n * 2. Workspace explicit `model:<id>` rule — terminal allow or block.\n * 3. Workspace tag / provider / priceTier / kind rules — most-specific\n * band wins. Within a band, block wins. Specificity ladder:\n * tag (4) > provider (3) > priceTier (2) > kind (1).\n * Rationale: an explicit `allow tag:image:generate` should beat a\n * blanket `block kind:llm`. The tag rule is the more specific\n * intent and reflects the operator's allowlist.\n * 4. Catalog defaults — `lifecycle=stable && agentVisible=true` → allow.\n *\n * BYOK relaxation: when `byokActive`, `priceTier=premium` blocks are\n * bypassed (BYOK users pay providers directly). NSFW / compliance\n * blocks NEVER bypass.\n */\n\nimport type { ResolvedModel } from \"../registry/index.js\"\nimport { modelHasTag, modelMatchesPriceTier } from \"../enrichment/index.js\"\nimport { evaluateCatalogDefaults } from \"./catalog-defaults.js\"\nimport type { AccessRule, AccessTarget, AppScope } from \"./types.js\"\n\n/**\n * Specificity of non-model rule targets. Higher = more specific.\n * Most-specific band wins; within a band, block wins.\n *\n * Mirrors the scope specificity logic in\n * `packages/core/src/domain/model-access/types.ts:79`.\n */\nconst NON_MODEL_SPECIFICITY: Record<\n \"tag\" | \"provider\" | \"priceTier\" | \"kind\",\n number\n> = {\n tag: 4,\n provider: 3,\n priceTier: 2,\n kind: 1,\n}\n\nexport interface AccessEvalInput {\n model: ResolvedModel\n appScope?: AppScope\n /** Workspace overrides; v1 callers pass `[]`. */\n rules?: AccessRule[]\n byokActive?: boolean\n}\n\nexport interface AccessDecision {\n allowed: boolean\n /** Stable token for logs/metrics. */\n reason: string\n}\n\nconst NSFW_TAG_BLOCK_REASONS = new Set([\"nsfw\", \"compliance\"])\n\n/**\n * Returns true iff the target matches the resolved model.\n *\n * Tag and priceTier matching go through the enrichment layer\n * (`@agentproto/model-catalog/enrichment`) — explicit per-model\n * enrichment wins, heuristic fallback fills the rest.\n *\n * Exported as `modelMatchesTarget` so the model-list selector vocabulary can\n * reuse the exact same matching semantics; `AccessTarget`, `AccessRule` and\n * `evaluateAccess` stay unchanged.\n */\nexport function modelMatchesTarget(\n target: AccessTarget,\n model: ResolvedModel,\n): boolean {\n switch (target.kind) {\n case \"model\":\n return target.id === model.id\n case \"kind\":\n return target.value === model.kind\n case \"provider\": {\n switch (model.kind) {\n case \"image\":\n return model.def.provider === target.value\n case \"video\":\n return model.def.provider === target.value\n case \"audio\":\n return model.def.provider === target.value\n case \"voice\":\n return model.voice.provider === target.value\n case \"llm\":\n // No provider field on LLM entries — best-effort by canonical id\n // structure. All LLM ids follow `<vendor>/…` or\n // `<router>/<vendor>/…` conventions, so check for an exact\n // prefix segment or an interior `/<vendor>/` segment.\n // NOTE: avoid plain `.includes(target.value)` — it would\n // false-positive on any id that merely *contains* the substring\n // (e.g. \"not-google/…\" matching provider \"google\").\n // A `<router>/<vendor>/…` id (e.g. `openrouter/anthropic/…`) can\n // match BOTH a `router` and a `vendor` provider rule — that is\n // intentional; band resolution (most-specific wins) reconciles it.\n return (\n model.canonicalId.startsWith(`${target.value}/`) ||\n model.canonicalId.includes(`/${target.value}/`)\n )\n }\n }\n case \"tag\":\n return modelHasTag(model, target.value)\n case \"priceTier\":\n return modelMatchesPriceTier(model, target.value)\n }\n}\n\n/** Rule-shaped wrapper kept for `evaluateAccess`'s own call sites. */\nfunction ruleMatches(rule: AccessRule, model: ResolvedModel): boolean {\n return modelMatchesTarget(rule.target, model)\n}\n\nexport function evaluateAccess(input: AccessEvalInput): AccessDecision {\n const { model, appScope, rules = [], byokActive = false } = input\n\n // 1. App scope. `voice` rows are metadata, not callable models — they\n // bypass kind-scope checks (gating happens on the audio MODEL the\n // voice plays through).\n if (\n appScope &&\n appScope.kinds.length > 0 &&\n model.kind !== \"voice\" &&\n !appScope.kinds.includes(model.kind)\n ) {\n return {\n allowed: false,\n reason: `app-scope:kind-not-allowed:${model.kind}`,\n }\n }\n\n // 2. Explicit per-model rules. Most specific band — terminal if any\n // matches. Within the band, block wins over allow (so a workspace\n // `block model:X` beats a tier-policy `allow model:X` regardless of\n // the order they appear in the merged rule list).\n const modelMatches = rules.filter(\n r =>\n r.target.kind === \"model\" && (r.target as { id: string }).id === model.id\n )\n if (modelMatches.length > 0) {\n const winner =\n modelMatches.find(r => r.effect === \"block\") ?? modelMatches[0]!\n return {\n allowed: winner.effect === \"allow\",\n reason: `rule:model:${winner.effect}${winner.reason ? `:${winner.reason}` : \"\"}`,\n }\n }\n\n // 3. Tag / provider / priceTier / kind rules. Most-specific band wins;\n // within a band, block wins. BYOK relaxation drops priceTier=premium\n // blocks before specificity grouping.\n const matchedByBand = new Map<number, AccessRule[]>()\n for (const rule of rules) {\n const k = rule.target.kind\n if (k === \"model\") continue\n if (!ruleMatches(rule, model)) continue\n if (rule.effect === \"block\") {\n // BYOK relaxation — same condition as before the refactor.\n if (\n byokActive &&\n rule.target.kind === \"priceTier\" &&\n rule.target.value === \"premium\" &&\n !NSFW_TAG_BLOCK_REASONS.has(rule.reason ?? \"\")\n ) {\n continue\n }\n }\n const band = NON_MODEL_SPECIFICITY[k]\n const list = matchedByBand.get(band) ?? []\n list.push(rule)\n matchedByBand.set(band, list)\n }\n\n if (matchedByBand.size > 0) {\n // Walk bands from most-specific to least-specific. The first band\n // with any matching rule decides — block wins within the band.\n const bands = Array.from(matchedByBand.keys()).sort((a, b) => b - a)\n for (const band of bands) {\n const bandRules = matchedByBand.get(band)!\n const blocked = bandRules.find(r => r.effect === \"block\")\n const allowed = bandRules.find(r => r.effect === \"allow\")\n const winner = blocked ?? allowed\n if (!winner) continue\n const t = winner.target\n const targetStr =\n t.kind === \"model\"\n ? `model:${(t as { id: string }).id}`\n : `${t.kind}:${(t as { value: string }).value}`\n const tail = winner.reason ? `:${winner.reason}` : \"\"\n return {\n allowed: winner.effect === \"allow\",\n reason: `rule:${targetStr}:${winner.effect}${tail}`,\n }\n }\n }\n\n // 4. Catalog defaults.\n const fallback = evaluateCatalogDefaults(model)\n return { allowed: fallback.allowed, reason: fallback.reason }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { getModel } from './chunk-XJUZ5X3W.mjs';
2
- import { calculateLLMCreditCost } from './chunk-TVXNRUJM.mjs';
1
+ import { getModel } from './chunk-ETI76MOK.mjs';
2
+ import { calculateLLMCreditCost } from './chunk-MZ23K5W6.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-5EX3V7QZ.mjs.map
227
- //# sourceMappingURL=chunk-5EX3V7QZ.mjs.map
226
+ //# sourceMappingURL=chunk-W7K6DGOK.mjs.map
227
+ //# sourceMappingURL=chunk-W7K6DGOK.mjs.map
@@ -1 +1 @@
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,EACA,QAAA,EACA,GAAA,EAChB;AACA,IAAA,KAAA;AAAA,MACE,CAAA,OAAA,EAAU,OAAO,CAAA,WAAA,EAAc,QAAQ,kCAAkC,GAAG,CAAA,CAAA;AAAA,KAC9E;AANgB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AACA,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAKhB,IAAA,IAAA,CAAK,IAAA,GAAO,4BAAA;AAAA,EACd;AAAA,EARkB,OAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAOpB;AA0BO,SAAS,aAAA,CACd,OAAA,EACA,KAAA,EACA,IAAA,GAA6B,EAAC,EAClB;AAIZ,EAAA,IAAI,KAAA,CAAM,SAAS,KAAA,EAAO;AACxB,IAAA,MAAM,SAAA,GAAiC,uBAAuB,OAAA,EAAS;AAAA,MACrE,aAAa,KAAA,CAAM,WAAA;AAAA,MACnB,cAAc,KAAA,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A,CAAI,CAAA,EAAG,IAAA,CAAK,IAAA,CAAK,cAAA,GAAiB,QAAQ,CAAC,CAAA,GAAI,CAAA;AACrE,EAAA,MAAM,MAAA,GAAS,eAAA,CAAgB,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-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
+ {"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,I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AA,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-W7K6DGOK.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,4 +1,4 @@
1
- import { DEFAULT_PRICING } from './chunk-TVXNRUJM.mjs';
1
+ import { DEFAULT_PRICING } from './chunk-MZ23K5W6.mjs';
2
2
 
3
3
  /**
4
4
  * @agentproto/model-catalog v0.1.0
@@ -81,6 +81,11 @@ function isActionTag(tag) {
81
81
  }
82
82
 
83
83
  // src/enrichment/index.ts
84
+ function isZeroPriced(pricing) {
85
+ return pricing.inputPer1M === 0 && pricing.outputPer1M === 0 && (pricing.tiers ?? []).every(
86
+ (tier) => tier.inputPer1M === 0 && tier.outputPer1M === 0
87
+ );
88
+ }
84
89
  var EXPLICIT_ENRICHMENT = {
85
90
  // ── LLM ──────────────────────────────────────────────────────────────
86
91
  "claude-opus-4-5": {
@@ -340,9 +345,13 @@ function mergeTags(curation, actions) {
340
345
  function getEnrichment(model) {
341
346
  const curation = getCurationEnrichment(model);
342
347
  const actions = getActions(model);
348
+ const tags = mergeTags(curation.tags, actions);
349
+ if (model.kind === "llm" && model.pricing !== void 0 && isZeroPriced(model.pricing) && !tags.includes("price:zero")) {
350
+ tags.push("price:zero");
351
+ }
343
352
  return {
344
353
  catalogPriceTier: curation.catalogPriceTier,
345
- tags: mergeTags(curation.tags, actions),
354
+ tags,
346
355
  lifecycle: curation.lifecycle,
347
356
  actions
348
357
  };
@@ -363,6 +372,6 @@ function modelMatchesKind(model, kind) {
363
372
  return model.kind === kind;
364
373
  }
365
374
 
366
- export { assertReservedPrefixDiscipline, getActions, getEnrichment, isActionTag, modelHasAction, modelHasTag, modelMatchesCatalogPriceTier, modelMatchesKind, modelMatchesPriceTier, priceTierForModel };
367
- //# sourceMappingURL=chunk-NNV3NYUE.mjs.map
368
- //# sourceMappingURL=chunk-NNV3NYUE.mjs.map
375
+ export { assertReservedPrefixDiscipline, getActions, getEnrichment, isActionTag, isZeroPriced, modelHasAction, modelHasTag, modelMatchesCatalogPriceTier, modelMatchesKind, modelMatchesPriceTier, priceTierForModel };
376
+ //# sourceMappingURL=chunk-YSEQMLV2.mjs.map
377
+ //# sourceMappingURL=chunk-YSEQMLV2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/registry/actions.ts","../src/enrichment/index.ts"],"names":[],"mappings":";;;;;;;;;AA0BA,IAAM,sBAAA,GAAyB,CAAC,MAAA,EAAQ,QAAA,EAAU,UAAU,QAAQ,CAAA;AAM7D,SAAS,WAAW,KAAA,EAAgC;AACzD,EAAA,QAAQ,MAAM,IAAA;AAAM,IAClB,KAAK,OAAA,EAAS;AACZ,MAAA,MAAM,MAAgB,EAAC;AACvB,MAAA,MAAM,CAAA,GAAI,MAAM,GAAA,CAAI,YAAA;AACpB,MAAA,IAAI,CAAA,CAAE,QAAA,EAAU,GAAA,CAAI,IAAA,CAAK,gBAAgB,CAAA;AACzC,MAAA,IAAI,CAAA,CAAE,IAAA,EAAM,GAAA,CAAI,IAAA,CAAK,YAAY,CAAA;AACjC,MAAA,IAAI,CAAA,CAAE,OAAA,EAAS,GAAA,CAAI,IAAA,CAAK,eAAe,CAAA;AACvC,MAAA,IAAI,MAAM,GAAA,CAAI,eAAA,CAAgB,SAAA,EAAW,GAAA,CAAI,KAAK,iBAAiB,CAAA;AACnE,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,IACA,KAAK,OAAA,EAAS;AACZ,MAAA,MAAM,MAAgB,EAAC;AACvB,MAAA,MAAM,CAAA,GAAI,MAAM,GAAA,CAAI,YAAA;AACpB,MAAA,IAAI,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SAAS,GAAG,CAAA;AAC/C;AAEO,SAAS,cAAA,CAAe,OAAsB,MAAA,EAAyB;AAC5E,EAAA,OAAO,aAAA,CAAc,KAAK,CAAA,CAAE,OAAA,CAAQ,SAAS,MAAM,CAAA;AACrD;AAEO,SAAS,4BAAA,CACd,OACA,IAAA,EACS;AACT,EAAA,OAAO,aAAA,CAAc,KAAK,CAAA,CAAE,gBAAA,KAAqB,IAAA;AACnD;AAQO,SAAS,qBAAA,CACd,OACA,IAAA,EACS;AACT,EAAA,OAAO,4BAAA,CAA6B,OAAO,IAAI,CAAA;AACjD;AAEO,SAAS,gBAAA,CACd,OACA,IAAA,EACS;AACT,EAAA,OAAO,MAAM,IAAA,KAAS,IAAA;AACxB","file":"chunk-YSEQMLV2.mjs","sourcesContent":["/**\n * Action projection — `<kind>:<verb>` namespaced strings derived from\n * each model's per-kind capability object.\n *\n * Convention:\n * - `image:generate`, `image:edit`, `image:upscale`, `image:reference`\n * - `video:text_to`, `video:image_to`, `video:subject_reference`,\n * `video:audio`\n * - `audio:tts`, `audio:stt`, `audio:realtime`\n * - `llm:vision`, `llm:tool_use`, `llm:reasoning`, `llm:long_context`\n *\n * Always `<kind>:<verb_or_modifier>`, snake_case.\n *\n * Action tags share a string array with curation tags but live behind the\n * reserved `<kind>:` prefix. Curation tags MUST NOT use the prefix —\n * `assertReservedPrefixDiscipline` enforces this at module load.\n *\n * The reason this lives in the catalog package (not enrichment) is that\n * actions are intrinsic to a model — derived from its capability fields,\n * not subjectively curated. Keeping the projection separate makes it\n * trivially callable from anywhere (e.g. a UI badge component) without\n * pulling the heuristic enrichment table.\n */\n\nimport type { ResolvedModel } from \"./index.js\"\n\nconst RESERVED_KIND_PREFIXES = [\"llm:\", \"image:\", \"video:\", \"audio:\"] as const\n\n/**\n * Compute the action tags a model supports. Returns an empty array for\n * models with no recognized capability bits (defensive — never throws).\n */\nexport function getActions(model: ResolvedModel): string[] {\n switch (model.kind) {\n case \"image\": {\n const out: string[] = []\n const c = model.def.capabilities\n if (c.generate) out.push(\"image:generate\")\n if (c.edit) out.push(\"image:edit\")\n if (c.upscale) out.push(\"image:upscale\")\n if (model.def.referenceImages.supported) out.push(\"image:reference\")\n return out\n }\n case \"video\": {\n const out: string[] = []\n const c = model.def.capabilities\n if (c.textToVideo) out.push(\"video:text_to\")\n if (c.imageToVideo) out.push(\"video:image_to\")\n if (c.subjectReference) out.push(\"video:subject_reference\")\n if (c.audio) out.push(\"video:audio\")\n return out\n }\n case \"audio\": {\n const out: string[] = []\n const c = model.def.capabilities\n // One action per enabled modality (a model may do more than one).\n if (c.tts) out.push(\"audio:tts\")\n if (c.stt) out.push(\"audio:stt\")\n if (c.s2s) out.push(\"audio:s2s\")\n if (c.voiceCloning) out.push(\"audio:voice_cloning\")\n if (c.streaming) out.push(\"audio:streaming\")\n if (c.diarization) out.push(\"audio:diarization\")\n if (c.timestamps) out.push(\"audio:timestamps\")\n return out\n }\n case \"voice\":\n // Voice metadata represents a render-target, not an action — tag it\n // with the engine modality so it matches the same action vocabulary\n // as audio models (s2s engines vs sequential tts).\n return model.voice.provider === \"openai-realtime\" ||\n model.voice.provider === \"gemini-live\"\n ? [\"audio:s2s\"]\n : [\"audio:tts\"]\n case \"llm\": {\n // LLM actions piggyback on the catalog-attached capability metadata\n // when present. The legacy `LLMPricing` shape doesn't carry\n // capabilities directly — those live in the agent-framework\n // catalog (to be folded into model-catalog/llm in a future phase).\n // For v1, infer from canonical id heuristics. Keep conservative:\n // only emit actions we can prove from the id.\n const out: string[] = []\n const id = model.canonicalId.toLowerCase()\n // Tool use: every modern frontier LLM supports it. Bare `gpt`,\n // `claude`, `gemini` are tool-capable; small fast variants\n // (haiku, mini, flash, lite) are too. We assume yes unless the\n // id obviously rules it out.\n out.push(\"llm:tool_use\")\n // Reasoning: opus / sonnet / pro / r1 / o1 / o3 / thinking models.\n if (\n /opus|sonnet|claude-3.7|gpt-4\\.5|gpt-5|gemini-.*-pro|deepseek-r1|o1|o3|thinking|reasoning/.test(\n id\n )\n ) {\n out.push(\"llm:reasoning\")\n }\n // Vision: Sonnet, Opus, GPT-4o, Gemini, multimodal-marked ids.\n if (\n /sonnet|opus|gpt-4o|gpt-5|gemini|claude-3|claude-haiku-4|vision|vl/.test(\n id\n )\n ) {\n out.push(\"llm:vision\")\n }\n // Long context: Gemini, GPT-4.1, Sonnet 4 (1M), Kimi, Grok 4 fast.\n if (\n /gemini|gpt-4\\.1|claude-sonnet-4|kimi|grok-4|qwen3-next|long.context/.test(\n id\n )\n ) {\n out.push(\"llm:long_context\")\n }\n return out\n }\n }\n}\n\n/**\n * Validate that a string array intended as curation tags does not use a\n * reserved `<kind>:` prefix. Run at module load on the explicit\n * enrichment map; throws on violation so the offending entry is caught\n * before any access decision is made.\n *\n * Caller pattern (in tests / module-load init):\n * for (const e of Object.values(EXPLICIT_ENRICHMENT))\n * assertReservedPrefixDiscipline(e.tags)\n */\nexport function assertReservedPrefixDiscipline(\n curationTags: readonly string[]\n): void {\n for (const tag of curationTags) {\n for (const prefix of RESERVED_KIND_PREFIXES) {\n if (tag.startsWith(prefix)) {\n throw new Error(\n `Reserved tag prefix \"${prefix}\" used in curation tag \"${tag}\". ` +\n `Action tags (\\`<kind>:<verb>\\`) are derived automatically by ` +\n `getActions() — do not put them in curation arrays.`\n )\n }\n }\n }\n}\n\n/**\n * Returns true iff the given tag is in the reserved action-tag namespace.\n * Useful for callers that need to display curation tags only (e.g.\n * an admin UI) without hardcoding the prefix list.\n */\nexport function isActionTag(tag: string): boolean {\n return RESERVED_KIND_PREFIXES.some(p => tag.startsWith(p))\n}\n","/**\n * Model enrichment — `catalogPriceTier` / `tags` / `lifecycle` / `actions`\n * per model id.\n *\n * Bridge between the legacy data shape (`ImageModelDefinition`,\n * `VideoModelDefinition`, `LLMPricing`) and the v2 access-rule\n * primitives that target by tier, tag, and action. Without this, rules\n * like `priceTier:premium` and `tag:nsfw` would never match anything.\n *\n * Two layers:\n * 1. Explicit map for the curated set we know about (overrides win).\n * 2. Heuristic inference for any model not in the explicit map\n * (catalogPriceTier from creditCost / token rates; tags from kind +\n * provider).\n *\n * Actions (`<kind>:<verb>` — e.g. `image:generate`, `llm:tool_use`) are\n * computed from per-kind capability objects via `getActions` and merged\n * into `tags` so existing tag-based access rules match action targets\n * without any evaluator change. The reserved `<kind>:` prefix is enforced\n * by `assertReservedPrefixDiscipline` at module load — free-form curation\n * tags must NOT use it.\n *\n * Add an entry to `EXPLICIT_ENRICHMENT` when you want exact control;\n * skip it when defaults are good enough.\n */\n\nimport type { CatalogPriceTier, Lifecycle, ModelKind } from \"../schema/index.js\"\nimport type { ResolvedModel } from \"../registry/index.js\"\nimport { DEFAULT_PRICING } from \"../llm/index.js\"\nimport {\n getActions,\n assertReservedPrefixDiscipline,\n} from \"../registry/actions.js\"\n\nexport interface ModelEnrichment {\n catalogPriceTier: CatalogPriceTier\n /** Curation tags + action tags (`<kind>:<verb>`) merged. */\n tags: readonly string[]\n lifecycle: Lifecycle\n /** Action tags only — convenience subset of `tags`. */\n actions: readonly string[]\n}\n\n/** The one zero-price rule: both base token prices are exactly 0 and every\n * prompt-length tier is also 0/0. A tiered model whose base is free but whose\n * long-prompt tier bills is NOT zero-priced. */\nexport function isZeroPriced(pricing: {\n inputPer1M: number\n outputPer1M: number\n tiers?: readonly {\n aboveInputTokens?: number\n inputPer1M: number\n outputPer1M: number\n }[]\n}): boolean {\n return (\n pricing.inputPer1M === 0 &&\n pricing.outputPer1M === 0 &&\n (pricing.tiers ?? []).every(\n tier => tier.inputPer1M === 0 && tier.outputPer1M === 0,\n )\n )\n}\n\n/**\n * Internal shape for the curated explicit-enrichment map. The map carries\n * only the *curation* fields — `tags` here is curation-only (no action\n * tags). `getEnrichment` adds derived `actions` and merges them into\n * `tags` at read time.\n */\ninterface ExplicitEnrichment {\n catalogPriceTier: CatalogPriceTier\n tags: readonly string[]\n lifecycle: Lifecycle\n}\n\nconst EXPLICIT_ENRICHMENT: Record<string, ExplicitEnrichment> = {\n // ── LLM ──────────────────────────────────────────────────────────────\n \"claude-opus-4-5\": {\n catalogPriceTier: \"premium\",\n tags: [\"llm\", \"anthropic\", \"premium\", \"reasoning\"],\n lifecycle: \"stable\",\n },\n \"claude-sonnet-4-5\": {\n catalogPriceTier: \"high\",\n tags: [\"llm\", \"anthropic\"],\n lifecycle: \"stable\",\n },\n \"claude-haiku-4-5\": {\n catalogPriceTier: \"low\",\n tags: [\"llm\", \"anthropic\", \"fast\"],\n lifecycle: \"stable\",\n },\n \"gemini-2.5-flash\": {\n catalogPriceTier: \"low\",\n tags: [\"llm\", \"google\", \"fast\"],\n lifecycle: \"stable\",\n },\n \"gemini-2.5-pro\": {\n catalogPriceTier: \"mid\",\n tags: [\"llm\", \"google\", \"reasoning\"],\n lifecycle: \"stable\",\n },\n \"gpt-4.1\": {\n catalogPriceTier: \"mid\",\n tags: [\"llm\", \"openai\"],\n lifecycle: \"stable\",\n },\n \"gpt-4.1-mini\": {\n catalogPriceTier: \"low\",\n tags: [\"llm\", \"openai\", \"fast\"],\n lifecycle: \"stable\",\n },\n \"gpt-4o\": {\n catalogPriceTier: \"mid\",\n tags: [\"llm\", \"openai\"],\n lifecycle: \"stable\",\n },\n \"gpt-4o-mini\": {\n catalogPriceTier: \"low\",\n tags: [\"llm\", \"openai\", \"fast\"],\n lifecycle: \"stable\",\n },\n\n // ── Image (highlights — others fall through to heuristic) ────────────\n \"nano-banana-pro\": {\n catalogPriceTier: \"high\",\n tags: [\"image\", \"google\", \"high-quality\", \"text-rendering\"],\n lifecycle: \"stable\",\n },\n \"nano-banana-2\": {\n catalogPriceTier: \"mid\",\n tags: [\"image\", \"google\"],\n lifecycle: \"stable\",\n },\n \"nano-banana\": {\n catalogPriceTier: \"low\",\n tags: [\"image\", \"google\", \"fast\"],\n lifecycle: \"stable\",\n },\n \"flux-2-dev\": {\n catalogPriceTier: \"low\",\n tags: [\"image\", \"bfl\", \"flux\"],\n lifecycle: \"stable\",\n },\n \"flux-kontext-pro\": {\n catalogPriceTier: \"low\",\n tags: [\"image\", \"bfl\", \"flux\", \"edit\"],\n lifecycle: \"stable\",\n },\n \"flux-kontext-max\": {\n catalogPriceTier: \"mid\",\n tags: [\"image\", \"bfl\", \"flux\", \"edit\", \"high-quality\"],\n lifecycle: \"stable\",\n },\n \"seedream-4\": {\n catalogPriceTier: \"low\",\n tags: [\"image\", \"bytedance\", \"photorealistic\"],\n lifecycle: \"stable\",\n },\n\n // ── Video (highlights) ──────────────────────────────────────────────\n \"google/veo-3.1\": {\n catalogPriceTier: \"high\",\n tags: [\"video\", \"google\", \"veo\", \"high-quality\", \"audio\"],\n lifecycle: \"stable\",\n },\n \"google/veo-3.1-fast\": {\n catalogPriceTier: \"mid\",\n tags: [\"video\", \"google\", \"veo\", \"fast\", \"audio\"],\n lifecycle: \"stable\",\n },\n \"kwaivgi/kling-v2.5-turbo-pro\": {\n catalogPriceTier: \"low\",\n tags: [\"video\", \"kling\", \"fast\"],\n lifecycle: \"deprecated\",\n },\n}\n\n// Module-load lint: every curation tag in the explicit map must avoid the\n// reserved `<kind>:` prefix. Action tags are derived by `getActions`,\n// never written by hand.\nfor (const entry of Object.values(EXPLICIT_ENRICHMENT)) {\n assertReservedPrefixDiscipline(entry.tags)\n}\n\n/**\n * Heuristic catalogPriceTier — used when an entry has no explicit\n * enrichment. Buckets are intentionally generous so rules don't need\n * every model priced exactly.\n */\nfunction inferCatalogPriceTier(model: ResolvedModel): CatalogPriceTier {\n switch (model.kind) {\n case \"image\": {\n // Derive from baseCost (USD) — formula bucketing keeps tiers\n // stable when category markup changes.\n const usd = model.def.pricing.baseCost\n if (usd <= 0.02) return \"low\"\n if (usd <= 0.05) return \"mid\"\n if (usd <= 0.1) return \"high\"\n return \"premium\"\n }\n case \"video\": {\n const usd = model.def.pricing.baseCost\n if (usd <= 0.3) return \"low\"\n if (usd <= 0.7) return \"mid\"\n if (usd <= 1.2) return \"high\"\n return \"premium\"\n }\n case \"llm\": {\n // Bucket on provider USD/1M output tokens (output dominates spend).\n // Stable across markup changes — was previously keyed on the\n // credit-side rate, which moved with formula tweaks. A known-but-\n // unpriced id (pricing undefined — see ResolvedModel's doc comment)\n // buckets on DEFAULT_PRICING, same fallback convention as\n // `calculateLLMCreditCost` and the HuggingFace route in\n // `route-identity/index.ts`.\n const out = model.pricing?.outputPer1M ?? DEFAULT_PRICING.outputPer1M\n if (out <= 1) return \"low\"\n if (out <= 10) return \"mid\"\n if (out <= 30) return \"high\"\n return \"premium\"\n }\n case \"audio\": {\n // Bucket on production USD per billing unit (1k chars or 1 min).\n const usd = model.def.pricing.baseCost\n if (usd <= 0.01) return \"low\"\n if (usd <= 0.05) return \"mid\"\n if (usd <= 0.2) return \"high\"\n return \"premium\"\n }\n case \"voice\":\n // Voice metadata isn't priced on its own.\n return \"low\"\n }\n}\n\n/**\n * Display price gauge level (1..5) for a model — the **visual** \"price\n * mostly\" indicator (Low / Medium / High / Max / Ultra) the pickers and the\n * estimator render as a bar. Distinct from {@link inferCatalogPriceTier}:\n * that one drives 4-value *access* rules (`priceTier:premium`) and must stay a\n * `CatalogPriceTier`; this is cosmetic and free to span 5 bands. Both bucket\n * the same provider USD cost, so they move together by construction.\n */\nexport function priceTierForModel(model: ResolvedModel): number {\n switch (model.kind) {\n case \"image\": {\n const usd = model.def.pricing.baseCost\n if (usd <= 0.02) return 1\n if (usd <= 0.05) return 2\n if (usd <= 0.1) return 3\n if (usd <= 0.2) return 4\n return 5\n }\n case \"video\": {\n const usd = model.def.pricing.baseCost\n if (usd <= 0.3) return 1\n if (usd <= 0.7) return 2\n if (usd <= 1.2) return 3\n if (usd <= 2.5) return 4\n return 5\n }\n case \"llm\": {\n // Same DEFAULT_PRICING fallback as inferCatalogPriceTier above.\n const out = model.pricing?.outputPer1M ?? DEFAULT_PRICING.outputPer1M\n if (out <= 1) return 1\n if (out <= 10) return 2\n if (out <= 30) return 3\n if (out <= 75) return 4\n return 5\n }\n case \"audio\": {\n const usd = model.def.pricing.baseCost\n if (usd <= 0.01) return 1\n if (usd <= 0.05) return 2\n if (usd <= 0.2) return 3\n if (usd <= 0.5) return 4\n return 5\n }\n case \"voice\":\n return 1\n }\n}\n\nfunction inferTags(model: ResolvedModel): string[] {\n const tags: string[] = [model.kind]\n switch (model.kind) {\n case \"image\":\n if (model.def.provider) tags.push(model.def.provider)\n if (model.def.capabilities.edit) tags.push(\"edit\")\n if (model.def.capabilities.upscale) tags.push(\"upscale\")\n if (model.def.referenceImages.supported) tags.push(\"ref-images\")\n if (!model.def.agentVisible) tags.push(\"hidden\")\n break\n case \"video\":\n tags.push(model.def.provider)\n if (model.def.capabilities.audio) tags.push(\"audio\")\n if (model.def.capabilities.subjectReference) tags.push(\"subject-ref\")\n if (model.def.capabilities.imageToVideo) tags.push(\"i2v\")\n if (model.def.capabilities.textToVideo) tags.push(\"t2v\")\n if (!model.def.agentVisible) tags.push(\"hidden\")\n break\n case \"llm\":\n // Provider inferred from canonical id prefix (anthropic / openai / google).\n if (model.canonicalId.includes(\"claude\")) tags.push(\"anthropic\")\n else if (model.canonicalId.includes(\"gpt\")) tags.push(\"openai\")\n else if (model.canonicalId.includes(\"gemini\")) tags.push(\"google\")\n break\n case \"audio\":\n tags.push(model.def.provider)\n // Modality is multi-valued — emit a tag per enabled capability so\n // access rules can target `s2s` / `tts` / `stt` independently.\n if (model.def.capabilities.tts) tags.push(\"tts\")\n if (model.def.capabilities.stt) tags.push(\"stt\")\n if (model.def.capabilities.s2s) tags.push(\"s2s\")\n for (const lang of model.def.capabilities.languages) {\n tags.push(`lang:${lang}`)\n }\n if (model.def.capabilities.voiceCloning) tags.push(\"voice-cloning\")\n if (model.def.capabilities.streaming) tags.push(\"streaming\")\n if (model.def.capabilities.diarization) tags.push(\"diarization\")\n if (model.def.capabilities.timestamps) tags.push(\"timestamps\")\n if (!model.def.agentVisible) tags.push(\"hidden\")\n break\n case \"voice\": {\n // \"voice\" is already pushed via `model.kind`. Tag the engine provider\n // and its modality (s2s engines vs sequential tts) so voice access\n // rules can target the same `s2s`/`tts` vocabulary as audio models.\n tags.push(model.voice.provider)\n const s2sVoice =\n model.voice.provider === \"openai-realtime\" ||\n model.voice.provider === \"gemini-live\"\n tags.push(s2sVoice ? \"s2s\" : \"tts\")\n tags.push(`gender:${model.voice.gender}`)\n tags.push(`lang:${model.voice.primaryLanguage}`)\n break\n }\n }\n return tags\n}\n\nfunction inferLifecycle(model: ResolvedModel): Lifecycle {\n // Image / video catalogs use `agentVisible: false` to mark legacy /\n // less-used entries — treat those as \"deprecated\" for rule purposes.\n if (model.kind === \"image\" && !model.def.agentVisible) return \"deprecated\"\n if (model.kind === \"video\" && !model.def.agentVisible) return \"deprecated\"\n return \"stable\"\n}\n\n/**\n * Compose the curation portion of enrichment (everything except actions).\n * Internal — `getEnrichment` is the public entry that adds actions.\n */\nfunction getCurationEnrichment(model: ResolvedModel): ExplicitEnrichment {\n const explicit = EXPLICIT_ENRICHMENT[model.id]\n if (explicit) return explicit\n // For LLM, also try the canonical id (e.g., \"claude-sonnet-4-5\" →\n // \"claude-sonnet-4\" maps via aliases).\n if (model.kind === \"llm\" && model.canonicalId !== model.id) {\n const byCanonical = EXPLICIT_ENRICHMENT[model.canonicalId]\n if (byCanonical) return byCanonical\n }\n return {\n catalogPriceTier: inferCatalogPriceTier(model),\n tags: inferTags(model),\n lifecycle: inferLifecycle(model),\n }\n}\n\n/**\n * Merge two tag arrays preserving first-occurrence order, deduped.\n * Used to fold action tags into curation tags without duplicating.\n */\nfunction mergeTags(\n curation: readonly string[],\n actions: readonly string[]\n): string[] {\n const out: string[] = []\n const seen = new Set<string>()\n for (const t of curation) {\n if (seen.has(t)) continue\n seen.add(t)\n out.push(t)\n }\n for (const t of actions) {\n if (seen.has(t)) continue\n seen.add(t)\n out.push(t)\n }\n return out\n}\n\n/**\n * Resolve enrichment for any model. Explicit map wins; heuristic fallback\n * fills the rest. Action tags (`<kind>:<verb>`) are derived from the\n * model's capability fields and merged into `tags`. Always returns a\n * value (never undefined).\n */\nexport function getEnrichment(model: ResolvedModel): ModelEnrichment {\n const curation = getCurationEnrichment(model)\n const actions = getActions(model)\n const tags = mergeTags(curation.tags, actions)\n // Derived on BOTH paths: the explicit map returns before `inferTags`, so a\n // curated model must still carry `price:zero` when its pricing is 0/0.\n if (\n model.kind === \"llm\" &&\n model.pricing !== undefined &&\n isZeroPriced(model.pricing) &&\n !tags.includes(\"price:zero\")\n ) {\n tags.push(\"price:zero\")\n }\n return {\n catalogPriceTier: curation.catalogPriceTier,\n tags,\n lifecycle: curation.lifecycle,\n actions,\n }\n}\n\nexport function modelHasTag(model: ResolvedModel, tag: string): boolean {\n return getEnrichment(model).tags.includes(tag)\n}\n\nexport function modelHasAction(model: ResolvedModel, action: string): boolean {\n return getEnrichment(model).actions.includes(action)\n}\n\nexport function modelMatchesCatalogPriceTier(\n model: ResolvedModel,\n tier: CatalogPriceTier\n): boolean {\n return getEnrichment(model).catalogPriceTier === tier\n}\n\n/**\n * @deprecated Use `modelMatchesCatalogPriceTier`. Kept for back-compat\n * with the v1 evaluator's switch case which still uses the\n * `priceTier` discriminator string. The function itself routes to the\n * canonical name.\n */\nexport function modelMatchesPriceTier(\n model: ResolvedModel,\n tier: CatalogPriceTier\n): boolean {\n return modelMatchesCatalogPriceTier(model, tier)\n}\n\nexport function modelMatchesKind(\n model: ResolvedModel,\n kind: ModelKind\n): boolean {\n return model.kind === kind\n}\n"]}
@@ -1,11 +1,11 @@
1
- export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from '../chunk-5EX3V7QZ.mjs';
2
- import '../chunk-XJUZ5X3W.mjs';
3
- import '../chunk-ALUIW3QO.mjs';
4
- import '../chunk-NNV3NYUE.mjs';
1
+ export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from '../chunk-W7K6DGOK.mjs';
2
+ import '../chunk-ETI76MOK.mjs';
5
3
  import '../chunk-H6JUTF3U.mjs';
4
+ import '../chunk-BXTZ2EDE.mjs';
5
+ import '../chunk-YSEQMLV2.mjs';
6
6
  import '../chunk-WG4F6IRS.mjs';
7
- import '../chunk-UOOTUH6N.mjs';
8
- import '../chunk-TVXNRUJM.mjs';
7
+ import '../chunk-IHU6XTXS.mjs';
8
+ import '../chunk-MZ23K5W6.mjs';
9
9
  import '../chunk-QHELXPSL.mjs';
10
10
  import '../chunk-2LWYZOWB.mjs';
11
11
  import '../chunk-IJZ4XPO2.mjs';
@@ -1,6 +1,6 @@
1
- import { C as CatalogKind, R as ResolvedModel } from '../index-VuUTv1ft.js';
1
+ import { C as CatalogKind, R as ResolvedModel } from '../index-D8FWHlom.js';
2
2
  import { CatalogVoice } from '../schema/voice.js';
3
- import '../catalog-DRGEICKV.js';
3
+ import '../catalog-BB0uDJh-.js';
4
4
  import '../base-BaiI72Da.js';
5
5
  import 'zod';
6
6
  import '../image/index.js';
@@ -1,11 +1,11 @@
1
- export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile } from '../chunk-6TZ6WIM3.mjs';
2
- import '../chunk-XJUZ5X3W.mjs';
3
- import '../chunk-ALUIW3QO.mjs';
4
- import '../chunk-NNV3NYUE.mjs';
1
+ export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile } from '../chunk-DTE62ERL.mjs';
2
+ import '../chunk-ETI76MOK.mjs';
5
3
  import '../chunk-H6JUTF3U.mjs';
4
+ import '../chunk-BXTZ2EDE.mjs';
5
+ import '../chunk-YSEQMLV2.mjs';
6
6
  import '../chunk-WG4F6IRS.mjs';
7
- import '../chunk-UOOTUH6N.mjs';
8
- import '../chunk-TVXNRUJM.mjs';
7
+ import '../chunk-IHU6XTXS.mjs';
8
+ import '../chunk-MZ23K5W6.mjs';
9
9
  import '../chunk-QHELXPSL.mjs';
10
10
  import '../chunk-2LWYZOWB.mjs';
11
11
  import '../chunk-IJZ4XPO2.mjs';
@@ -0,0 +1,49 @@
1
+ import { R as ResolvedModel } from './index-D8FWHlom.js';
2
+ import { a as AppScope, b as AccessRule, A as AccessTarget } from './types-DMzMWJeJ.js';
3
+
4
+ /**
5
+ * Access evaluator — resolves whether a workspace can use a given model.
6
+ *
7
+ * Resolution order:
8
+ * 1. App scope — if the app opts out of the model's kind, deny.
9
+ * 2. Workspace explicit `model:<id>` rule — terminal allow or block.
10
+ * 3. Workspace tag / provider / priceTier / kind rules — most-specific
11
+ * band wins. Within a band, block wins. Specificity ladder:
12
+ * tag (4) > provider (3) > priceTier (2) > kind (1).
13
+ * Rationale: an explicit `allow tag:image:generate` should beat a
14
+ * blanket `block kind:llm`. The tag rule is the more specific
15
+ * intent and reflects the operator's allowlist.
16
+ * 4. Catalog defaults — `lifecycle=stable && agentVisible=true` → allow.
17
+ *
18
+ * BYOK relaxation: when `byokActive`, `priceTier=premium` blocks are
19
+ * bypassed (BYOK users pay providers directly). NSFW / compliance
20
+ * blocks NEVER bypass.
21
+ */
22
+
23
+ interface AccessEvalInput {
24
+ model: ResolvedModel;
25
+ appScope?: AppScope;
26
+ /** Workspace overrides; v1 callers pass `[]`. */
27
+ rules?: AccessRule[];
28
+ byokActive?: boolean;
29
+ }
30
+ interface AccessDecision {
31
+ allowed: boolean;
32
+ /** Stable token for logs/metrics. */
33
+ reason: string;
34
+ }
35
+ /**
36
+ * Returns true iff the target matches the resolved model.
37
+ *
38
+ * Tag and priceTier matching go through the enrichment layer
39
+ * (`@agentproto/model-catalog/enrichment`) — explicit per-model
40
+ * enrichment wins, heuristic fallback fills the rest.
41
+ *
42
+ * Exported as `modelMatchesTarget` so the model-list selector vocabulary can
43
+ * reuse the exact same matching semantics; `AccessTarget`, `AccessRule` and
44
+ * `evaluateAccess` stay unchanged.
45
+ */
46
+ declare function modelMatchesTarget(target: AccessTarget, model: ResolvedModel): boolean;
47
+ declare function evaluateAccess(input: AccessEvalInput): AccessDecision;
48
+
49
+ export { type AccessDecision as A, type AccessEvalInput as a, evaluateAccess as e, modelMatchesTarget as m };
@@ -1,4 +1,4 @@
1
- import { L as LLMPricing } from './catalog-DRGEICKV.js';
1
+ import { L as LLMPricing } from './catalog-BB0uDJh-.js';
2
2
  import { ImageModelDefinition } from './image/index.js';
3
3
  import { VideoModelDefinition } from './video/index.js';
4
4
  import { AudioModelDefinition } from './audio/index.js';
@@ -0,0 +1,78 @@
1
+ import { C as CatalogPriceTier, L as Lifecycle, M as ModelKind } from './base-BaiI72Da.js';
2
+ import { R as ResolvedModel } from './index-D8FWHlom.js';
3
+
4
+ /**
5
+ * Model enrichment — `catalogPriceTier` / `tags` / `lifecycle` / `actions`
6
+ * per model id.
7
+ *
8
+ * Bridge between the legacy data shape (`ImageModelDefinition`,
9
+ * `VideoModelDefinition`, `LLMPricing`) and the v2 access-rule
10
+ * primitives that target by tier, tag, and action. Without this, rules
11
+ * like `priceTier:premium` and `tag:nsfw` would never match anything.
12
+ *
13
+ * Two layers:
14
+ * 1. Explicit map for the curated set we know about (overrides win).
15
+ * 2. Heuristic inference for any model not in the explicit map
16
+ * (catalogPriceTier from creditCost / token rates; tags from kind +
17
+ * provider).
18
+ *
19
+ * Actions (`<kind>:<verb>` — e.g. `image:generate`, `llm:tool_use`) are
20
+ * computed from per-kind capability objects via `getActions` and merged
21
+ * into `tags` so existing tag-based access rules match action targets
22
+ * without any evaluator change. The reserved `<kind>:` prefix is enforced
23
+ * by `assertReservedPrefixDiscipline` at module load — free-form curation
24
+ * tags must NOT use it.
25
+ *
26
+ * Add an entry to `EXPLICIT_ENRICHMENT` when you want exact control;
27
+ * skip it when defaults are good enough.
28
+ */
29
+
30
+ interface ModelEnrichment {
31
+ catalogPriceTier: CatalogPriceTier;
32
+ /** Curation tags + action tags (`<kind>:<verb>`) merged. */
33
+ tags: readonly string[];
34
+ lifecycle: Lifecycle;
35
+ /** Action tags only — convenience subset of `tags`. */
36
+ actions: readonly string[];
37
+ }
38
+ /** The one zero-price rule: both base token prices are exactly 0 and every
39
+ * prompt-length tier is also 0/0. A tiered model whose base is free but whose
40
+ * long-prompt tier bills is NOT zero-priced. */
41
+ declare function isZeroPriced(pricing: {
42
+ inputPer1M: number;
43
+ outputPer1M: number;
44
+ tiers?: readonly {
45
+ aboveInputTokens?: number;
46
+ inputPer1M: number;
47
+ outputPer1M: number;
48
+ }[];
49
+ }): boolean;
50
+ /**
51
+ * Display price gauge level (1..5) for a model — the **visual** "price
52
+ * mostly" indicator (Low / Medium / High / Max / Ultra) the pickers and the
53
+ * estimator render as a bar. Distinct from {@link inferCatalogPriceTier}:
54
+ * that one drives 4-value *access* rules (`priceTier:premium`) and must stay a
55
+ * `CatalogPriceTier`; this is cosmetic and free to span 5 bands. Both bucket
56
+ * the same provider USD cost, so they move together by construction.
57
+ */
58
+ declare function priceTierForModel(model: ResolvedModel): number;
59
+ /**
60
+ * Resolve enrichment for any model. Explicit map wins; heuristic fallback
61
+ * fills the rest. Action tags (`<kind>:<verb>`) are derived from the
62
+ * model's capability fields and merged into `tags`. Always returns a
63
+ * value (never undefined).
64
+ */
65
+ declare function getEnrichment(model: ResolvedModel): ModelEnrichment;
66
+ declare function modelHasTag(model: ResolvedModel, tag: string): boolean;
67
+ declare function modelHasAction(model: ResolvedModel, action: string): boolean;
68
+ declare function modelMatchesCatalogPriceTier(model: ResolvedModel, tier: CatalogPriceTier): boolean;
69
+ /**
70
+ * @deprecated Use `modelMatchesCatalogPriceTier`. Kept for back-compat
71
+ * with the v1 evaluator's switch case which still uses the
72
+ * `priceTier` discriminator string. The function itself routes to the
73
+ * canonical name.
74
+ */
75
+ declare function modelMatchesPriceTier(model: ResolvedModel, tier: CatalogPriceTier): boolean;
76
+ declare function modelMatchesKind(model: ResolvedModel, kind: ModelKind): boolean;
77
+
78
+ export { type ModelEnrichment as M, modelHasTag as a, modelMatchesCatalogPriceTier as b, modelMatchesKind as c, modelMatchesPriceTier as d, getEnrichment as g, isZeroPriced as i, modelHasAction as m, priceTierForModel as p };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ImageAspectRatio, ImageAspectRatioSchema, ImageCapabilities, ImageCapabilitiesSchema, ImageEntry, ImageEntrySchema, ImagePricing, ImagePricingSchema, ImageReferenceImages, ImageReferenceImagesSchema, LLMEntry, LLMEntrySchema, LlmPricing, LlmPricingSchema, ModelEntry, ModelEntrySchema, VideoCapabilities, VideoCapabilitiesSchema, VideoCostMultipliers, VideoCostMultipliersSchema, VideoEntry, VideoEntrySchema, VideoPricing, VideoPricingSchema, VideoResolution, VideoResolutionSchema } from './schema/index.js';
2
- export { D as DEFAULT_PRICING, a as LLMCreditCostResult, L as LLMPricing, b as LLMPricingTier, c as LLMUsageBreakdown, d as LLM_PRICING_CATALOG, M as MODEL_ALIASES, e as calculateLLMCreditCost, r as resolvePricing, s as selectPricingTier } from './catalog-DRGEICKV.js';
2
+ export { D as DEFAULT_PRICING, a as LLMCreditCostResult, L as LLMPricing, b as LLMPricingTier, c as LLMUsageBreakdown, d as LLM_PRICING_CATALOG, M as MODEL_ALIASES, e as calculateLLMCreditCost, r as resolvePricing, s as selectPricingTier } from './catalog-BB0uDJh-.js';
3
3
  export { D as DEFAULT_ANTHROPIC_MODEL } from './defaults-BDkNRPK8.js';
4
4
  export { AGENT_EDITABLE_MODEL_IDS, AGENT_GENERATIVE_MODEL_IDS, AGENT_IMAGE_MODEL_IDS, IMAGE_MODEL_CATALOG, IMAGE_MODEL_IDS, ImageModelDefinition, generateImageModelTable } from './image/index.js';
5
5
  export { AGENT_VIDEO_MODEL_IDS, VIDEO_MODEL_CATALOG, VIDEO_MODEL_IDS, VideoModelDefinition, generateVideoModelTable } from './video/index.js';
@@ -10,12 +10,14 @@ export { ProviderGroup, SurfaceProfile, applyProfile, expandProviders, filterVoi
10
10
  export { CC_USD_RATE, CREDIT_USD_RATE, DEFAULT_PRICING_FLOORS, DEFAULT_PRICING_MARKUP, PricingCategory, PricingMarkup, computeCenticredits, pricingRegistry } from './pricing/index.js';
11
11
  export { CalculateCostOptions, CostResult, CostUsage, CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from './cost/index.js';
12
12
  export { ShouldDebitDecision, ShouldDebitInput, shouldDebit } from './byok/index.js';
13
- export { A as AccessDecision, a as AccessEffect, b as AccessEvalInput, c as AccessRule, d as AccessTarget, e as AppScope, f as evaluateAccess } from './evaluate-B-irutMW.js';
13
+ export { A as AccessDecision, a as AccessEvalInput, e as evaluateAccess, m as modelMatchesTarget } from './evaluate-BjSlZsJf.js';
14
14
  export { CatalogDefaultDecision, evaluateCatalogDefaults } from './access/index.js';
15
+ export { c as AccessEffect, b as AccessRule, A as AccessTarget, a as AppScope } from './types-DMzMWJeJ.js';
15
16
  export { CatalogOverlay, MergedOverlay, clearCatalogOverlays, getMergedOverlay, registerCatalogOverlay } from './overlay/index.js';
16
- import { R as ResolvedModel } from './index-VuUTv1ft.js';
17
- export { C as CatalogKind, L as ListModelsFilter, g as getModel, a as getModelsByProvider, b as getStaticModelProvider, i as isAgentVisible, l as listModels, r as resolveAlias } from './index-VuUTv1ft.js';
18
- export { A as AvailableConnector, a as AvailableModel, b as AvailableModelCapabilities, c as AvailableModelsActor, d as AvailableModelsResponse, L as ListAvailableModelsParams, M as ModelEnrichment, g as getEnrichment, m as modelHasAction, e as modelHasTag, f as modelMatchesCatalogPriceTier, h as modelMatchesKind, i as modelMatchesPriceTier, p as priceTierForModel } from './index-kbLggJk1.js';
17
+ import { R as ResolvedModel } from './index-D8FWHlom.js';
18
+ export { C as CatalogKind, L as ListModelsFilter, g as getModel, a as getModelsByProvider, b as getStaticModelProvider, i as isAgentVisible, l as listModels, r as resolveAlias } from './index-D8FWHlom.js';
19
+ export { M as ModelEnrichment, g as getEnrichment, i as isZeroPriced, m as modelHasAction, a as modelHasTag, b as modelMatchesCatalogPriceTier, c as modelMatchesKind, d as modelMatchesPriceTier, p as priceTierForModel } from './index-DetGJJ-F.js';
20
+ export { AvailableConnector, AvailableModel, AvailableModelCapabilities, AvailableModelsActor, AvailableModelsResponse, ListAvailableModelsParams } from './picker/index.js';
19
21
  export { A as AudioCapabilities, a as AudioCapabilitiesSchema, b as AudioEntry, c as AudioEntrySchema, d as AudioPricing, e as AudioPricingSchema } from './audio-Do2j3wDC.js';
20
22
  export { C as CatalogPriceTier, a as CatalogPriceTierSchema, b as CatalogProvider, c as CatalogProviderSchema, L as Lifecycle, d as LifecycleSchema, M as ModelKind, e as ModelKindSchema, N as NsfwPolicy, f as NsfwPolicySchema, P as PROVIDER_KEY_ENV, g as PROVIDER_KEY_ENV_ALIASES, h as baseEntryShape } from './base-BaiI72Da.js';
21
23
  import 'zod';
package/dist/index.mjs CHANGED
@@ -1,17 +1,18 @@
1
- export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile } from './chunk-6TZ6WIM3.mjs';
2
- export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from './chunk-5EX3V7QZ.mjs';
3
- import { getModel } from './chunk-XJUZ5X3W.mjs';
4
- export { getModel, getModelsByProvider, getStaticModelProvider, isAgentVisible, listModels, resolveAlias } from './chunk-XJUZ5X3W.mjs';
5
- import './chunk-ALUIW3QO.mjs';
1
+ export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile } from './chunk-DTE62ERL.mjs';
2
+ export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from './chunk-W7K6DGOK.mjs';
6
3
  export { shouldDebit } from './chunk-XFDXTFV3.mjs';
7
- export { evaluateAccess, evaluateCatalogDefaults } from './chunk-TZ5LNR5F.mjs';
8
- import { priceTierForModel } from './chunk-NNV3NYUE.mjs';
9
- export { assertReservedPrefixDiscipline, getActions, getEnrichment, isActionTag, modelHasAction, modelHasTag, modelMatchesCatalogPriceTier, modelMatchesKind, modelMatchesPriceTier, priceTierForModel } from './chunk-NNV3NYUE.mjs';
4
+ import './chunk-HFPX2DNR.mjs';
5
+ import { getModel } from './chunk-ETI76MOK.mjs';
6
+ export { getModel, getModelsByProvider, getStaticModelProvider, isAgentVisible, listModels, resolveAlias } from './chunk-ETI76MOK.mjs';
10
7
  export { clearCatalogOverlays, getMergedOverlay, registerCatalogOverlay } from './chunk-H6JUTF3U.mjs';
8
+ import './chunk-BXTZ2EDE.mjs';
9
+ export { evaluateAccess, evaluateCatalogDefaults, modelMatchesTarget } from './chunk-PVE3WQRH.mjs';
10
+ import { priceTierForModel } from './chunk-YSEQMLV2.mjs';
11
+ export { assertReservedPrefixDiscipline, getActions, getEnrichment, isActionTag, isZeroPriced, modelHasAction, modelHasTag, modelMatchesCatalogPriceTier, modelMatchesKind, modelMatchesPriceTier, priceTierForModel } from './chunk-YSEQMLV2.mjs';
11
12
  export { AudioCapabilitiesSchema, AudioEntrySchema, AudioPricingSchema, ImageAspectRatioSchema, ImageCapabilitiesSchema, ImageEntrySchema, ImagePricingSchema, ImageReferenceImagesSchema, LLMEntrySchema, LlmPricingSchema, ModelEntrySchema, VideoCapabilitiesSchema, VideoCostMultipliersSchema, VideoEntrySchema, VideoPricingSchema, VideoResolutionSchema } from './chunk-7U7XGVHP.mjs';
12
13
  export { CatalogPriceTierSchema, CatalogProviderSchema, LifecycleSchema, ModelKindSchema, NsfwPolicySchema, PROVIDER_KEY_ENV, PROVIDER_KEY_ENV_ALIASES, baseEntryShape } from './chunk-WG4F6IRS.mjs';
13
- export { DEFAULT_ANTHROPIC_MODEL } from './chunk-UOOTUH6N.mjs';
14
- export { DEFAULT_PRICING, LLM_PRICING_CATALOG, MODEL_ALIASES, calculateLLMCreditCost, resolvePricing, selectPricingTier } from './chunk-TVXNRUJM.mjs';
14
+ export { DEFAULT_ANTHROPIC_MODEL } from './chunk-IHU6XTXS.mjs';
15
+ export { DEFAULT_PRICING, LLM_PRICING_CATALOG, MODEL_ALIASES, calculateLLMCreditCost, resolvePricing, selectPricingTier } from './chunk-MZ23K5W6.mjs';
15
16
  export { CC_USD_RATE, CREDIT_USD_RATE, DEFAULT_PRICING_FLOORS, DEFAULT_PRICING_MARKUP, computeCenticredits, pricingRegistry } from './chunk-QHELXPSL.mjs';
16
17
  export { AGENT_EDITABLE_MODEL_IDS, AGENT_GENERATIVE_MODEL_IDS, AGENT_IMAGE_MODEL_IDS, IMAGE_MODEL_CATALOG, IMAGE_MODEL_IDS, generateImageModelTable } from './chunk-2LWYZOWB.mjs';
17
18
  export { AGENT_VIDEO_MODEL_IDS, VIDEO_MODEL_CATALOG, VIDEO_MODEL_IDS, generateVideoModelTable } from './chunk-IJZ4XPO2.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEO,SAAS,oBAAoB,EAAA,EAAoB;AACtD,EAAA,MAAM,KAAA,GAAQ,SAAS,EAAE,CAAA;AACzB,EAAA,OAAO,KAAA,GAAQ,iBAAA,CAA0B,KAAK,CAAA,GAAI,CAAA;AACpD","file":"index.mjs","sourcesContent":["/**\n * @agentproto/model-catalog — unified model catalog.\n *\n * Single source of truth for LLM, image, video, audio, and voice model\n * entries. Owns cost dispatch, BYOK policy, and access control evaluation.\n * Zod-only OSS core; @agentproto/model-catalog layers billing/access/BYOK\n * policy on top.\n *\n * Subpath imports for tree-shaking:\n * import { LLM_PRICING_CATALOG } from \"@agentproto/model-catalog/llm\"\n * import { calculateCost } from \"@agentproto/model-catalog/cost\"\n * import { shouldDebit } from \"@agentproto/model-catalog/byok\"\n * import { evaluateAccess } from \"@agentproto/model-catalog/access\"\n * import { VOICE_CATALOG } from \"@agentproto/model-catalog/voice\"\n * import { listSurfaced } from \"@agentproto/model-catalog/curation\"\n */\n\nexport * from \"./schema/index.js\"\n// LLM has its own `resolveAlias` (legacy back-compat for the app legacy pricing module).\n// At the top level we prefer the cross-kind `resolveAlias` from the registry.\nexport {\n LLM_PRICING_CATALOG,\n MODEL_ALIASES,\n DEFAULT_PRICING,\n DEFAULT_ANTHROPIC_MODEL,\n resolvePricing,\n calculateLLMCreditCost,\n selectPricingTier,\n} from \"./llm/index.js\"\nexport type {\n LLMPricing,\n LLMPricingTier,\n LLMUsageBreakdown,\n LLMCreditCostResult,\n} from \"./llm/index.js\"\nexport * from \"./image/index.js\"\nexport * from \"./video/index.js\"\nexport * from \"./audio/index.js\"\nexport * from \"./voice/index.js\"\nexport * from \"./curation/index.js\"\nexport * from \"./pricing/index.js\"\nexport * from \"./cost/index.js\"\nexport * from \"./byok/index.js\"\nexport * from \"./access/index.js\"\nexport * from \"./overlay/index.js\"\nexport * from \"./registry/index.js\"\nexport {\n getActions,\n isActionTag,\n assertReservedPrefixDiscipline,\n} from \"./registry/actions.js\"\nexport {\n getEnrichment,\n modelHasTag,\n modelHasAction,\n modelMatchesCatalogPriceTier,\n modelMatchesPriceTier,\n modelMatchesKind,\n priceTierForModel,\n type ModelEnrichment,\n} from \"./enrichment/index.js\"\n\nimport { getModel } from \"./registry/index.js\"\nimport { priceTierForModel as priceTierForModelInternal } from \"./enrichment/index.js\"\n\n/**\n * Display price gauge level (1..5) for a model id — resolves the catalog\n * entry then defers to {@link priceTierForModel}. 0 for an unknown id.\n * The id→level convenience used by the WhatsApp / slash pickers, which carry\n * a model id rather than a resolved model.\n */\nexport function priceTierForModelId(id: string): number {\n const model = getModel(id)\n return model ? priceTierForModelInternal(model) : 0\n}\nexport type {\n AvailableModel,\n AvailableModelCapabilities,\n AvailableConnector,\n AvailableModelsActor,\n AvailableModelsResponse,\n ListAvailableModelsParams,\n} from \"./picker/index.js\"\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEO,SAAS,oBAAoB,EAAA,EAAoB;AACtD,EAAA,MAAM,KAAA,GAAQ,SAAS,EAAE,CAAA;AACzB,EAAA,OAAO,KAAA,GAAQ,iBAAA,CAA0B,KAAK,CAAA,GAAI,CAAA;AACpD","file":"index.mjs","sourcesContent":["/**\n * @agentproto/model-catalog — unified model catalog.\n *\n * Single source of truth for LLM, image, video, audio, and voice model\n * entries. Owns cost dispatch, BYOK policy, and access control evaluation.\n * Zod-only OSS core; @agentproto/model-catalog layers billing/access/BYOK\n * policy on top.\n *\n * Subpath imports for tree-shaking:\n * import { LLM_PRICING_CATALOG } from \"@agentproto/model-catalog/llm\"\n * import { calculateCost } from \"@agentproto/model-catalog/cost\"\n * import { shouldDebit } from \"@agentproto/model-catalog/byok\"\n * import { evaluateAccess } from \"@agentproto/model-catalog/access\"\n * import { VOICE_CATALOG } from \"@agentproto/model-catalog/voice\"\n * import { listSurfaced } from \"@agentproto/model-catalog/curation\"\n */\n\nexport * from \"./schema/index.js\"\n// LLM has its own `resolveAlias` (legacy back-compat for the app legacy pricing module).\n// At the top level we prefer the cross-kind `resolveAlias` from the registry.\nexport {\n LLM_PRICING_CATALOG,\n MODEL_ALIASES,\n DEFAULT_PRICING,\n DEFAULT_ANTHROPIC_MODEL,\n resolvePricing,\n calculateLLMCreditCost,\n selectPricingTier,\n} from \"./llm/index.js\"\nexport type {\n LLMPricing,\n LLMPricingTier,\n LLMUsageBreakdown,\n LLMCreditCostResult,\n} from \"./llm/index.js\"\nexport * from \"./image/index.js\"\nexport * from \"./video/index.js\"\nexport * from \"./audio/index.js\"\nexport * from \"./voice/index.js\"\nexport * from \"./curation/index.js\"\nexport * from \"./pricing/index.js\"\nexport * from \"./cost/index.js\"\nexport * from \"./byok/index.js\"\nexport * from \"./access/index.js\"\nexport * from \"./overlay/index.js\"\nexport * from \"./registry/index.js\"\nexport {\n getActions,\n isActionTag,\n assertReservedPrefixDiscipline,\n} from \"./registry/actions.js\"\nexport {\n getEnrichment,\n isZeroPriced,\n modelHasTag,\n modelHasAction,\n modelMatchesCatalogPriceTier,\n modelMatchesPriceTier,\n modelMatchesKind,\n priceTierForModel,\n type ModelEnrichment,\n} from \"./enrichment/index.js\"\n\nimport { getModel } from \"./registry/index.js\"\nimport { priceTierForModel as priceTierForModelInternal } from \"./enrichment/index.js\"\n\n/**\n * Display price gauge level (1..5) for a model id — resolves the catalog\n * entry then defers to {@link priceTierForModel}. 0 for an unknown id.\n * The id→level convenience used by the WhatsApp / slash pickers, which carry\n * a model id rather than a resolved model.\n */\nexport function priceTierForModelId(id: string): number {\n const model = getModel(id)\n return model ? priceTierForModelInternal(model) : 0\n}\nexport type {\n AvailableModel,\n AvailableModelCapabilities,\n AvailableConnector,\n AvailableModelsActor,\n AvailableModelsResponse,\n ListAvailableModelsParams,\n} from \"./picker/index.js\"\n"]}