@agentproto/model-catalog 0.13.2 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/access/index.d.ts +4 -3
  2. package/dist/access/index.mjs +5 -4
  3. package/dist/{catalog-DLa4soLN.d.ts → catalog-B2eRnrWD.d.ts} +55 -37
  4. package/dist/{chunk-2P2R2XLK.mjs → chunk-562U2L7T.mjs} +5 -5
  5. package/dist/{chunk-2P2R2XLK.mjs.map → chunk-562U2L7T.mjs.map} +1 -1
  6. package/dist/{chunk-POKSD3S3.mjs → chunk-5LO27OWU.mjs} +8 -6
  7. package/dist/chunk-5LO27OWU.mjs.map +1 -0
  8. package/dist/{chunk-FPTLINCV.mjs → chunk-7CTQGUR2.mjs} +3 -3
  9. package/dist/{chunk-FPTLINCV.mjs.map → chunk-7CTQGUR2.mjs.map} +1 -1
  10. package/dist/{chunk-P5PQS3SJ.mjs → chunk-BQDTFJ4J.mjs} +221 -356
  11. package/dist/chunk-BQDTFJ4J.mjs.map +1 -0
  12. package/dist/{chunk-PKFRG2DA.mjs → chunk-F4BUE3N6.mjs} +14 -5
  13. package/dist/chunk-F4BUE3N6.mjs.map +1 -0
  14. package/dist/chunk-HFPX2DNR.mjs +3 -0
  15. package/dist/chunk-HFPX2DNR.mjs.map +1 -0
  16. package/dist/{chunk-ORWNAAFP.mjs → chunk-HUNAWSDP.mjs} +4 -4
  17. package/dist/{chunk-ORWNAAFP.mjs.map → chunk-HUNAWSDP.mjs.map} +1 -1
  18. package/dist/{chunk-5GIH3O6I.mjs → chunk-UWURA235.mjs} +4 -4
  19. package/dist/{chunk-5GIH3O6I.mjs.map → chunk-UWURA235.mjs.map} +1 -1
  20. package/dist/{chunk-5E34CLTH.mjs → chunk-Y2REI5QQ.mjs} +233 -253
  21. package/dist/chunk-Y2REI5QQ.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-CYQHJ4Jk.d.ts +49 -0
  26. package/dist/{index-BZlWH9br.d.ts → index-BvzrCBss.d.ts} +1 -1
  27. package/dist/index-Ipv-RcfT.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 +7 -2
  42. package/dist/chunk-5E34CLTH.mjs.map +0 -1
  43. package/dist/chunk-P5PQS3SJ.mjs.map +0 -1
  44. package/dist/chunk-PKFRG2DA.mjs.map +0 -1
  45. package/dist/chunk-POKSD3S3.mjs.map +0 -1
  46. package/dist/evaluate-DYz38I9t.d.ts +0 -84
  47. package/dist/index-CwIGbZai.d.ts +0 -171
@@ -1,11 +1,11 @@
1
- export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from '../chunk-5GIH3O6I.mjs';
2
- import '../chunk-2P2R2XLK.mjs';
3
- import '../chunk-P5PQS3SJ.mjs';
4
- import '../chunk-PKFRG2DA.mjs';
1
+ export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from '../chunk-UWURA235.mjs';
2
+ import '../chunk-562U2L7T.mjs';
5
3
  import '../chunk-H6JUTF3U.mjs';
4
+ import '../chunk-BQDTFJ4J.mjs';
5
+ import '../chunk-F4BUE3N6.mjs';
6
6
  import '../chunk-WG4F6IRS.mjs';
7
- import '../chunk-FPTLINCV.mjs';
8
- import '../chunk-5E34CLTH.mjs';
7
+ import '../chunk-7CTQGUR2.mjs';
8
+ import '../chunk-Y2REI5QQ.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-BZlWH9br.js';
1
+ import { C as CatalogKind, R as ResolvedModel } from '../index-BvzrCBss.js';
2
2
  import { CatalogVoice } from '../schema/voice.js';
3
- import '../catalog-DLa4soLN.js';
3
+ import '../catalog-B2eRnrWD.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-ORWNAAFP.mjs';
2
- import '../chunk-2P2R2XLK.mjs';
3
- import '../chunk-P5PQS3SJ.mjs';
4
- import '../chunk-PKFRG2DA.mjs';
1
+ export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile } from '../chunk-HUNAWSDP.mjs';
2
+ import '../chunk-562U2L7T.mjs';
5
3
  import '../chunk-H6JUTF3U.mjs';
4
+ import '../chunk-BQDTFJ4J.mjs';
5
+ import '../chunk-F4BUE3N6.mjs';
6
6
  import '../chunk-WG4F6IRS.mjs';
7
- import '../chunk-FPTLINCV.mjs';
8
- import '../chunk-5E34CLTH.mjs';
7
+ import '../chunk-7CTQGUR2.mjs';
8
+ import '../chunk-Y2REI5QQ.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-BvzrCBss.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-DLa4soLN.js';
1
+ import { L as LLMPricing } from './catalog-B2eRnrWD.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-BvzrCBss.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-DLa4soLN.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-B2eRnrWD.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-DYz38I9t.js';
13
+ export { A as AccessDecision, a as AccessEvalInput, e as evaluateAccess, m as modelMatchesTarget } from './evaluate-CYQHJ4Jk.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-BZlWH9br.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-BZlWH9br.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-CwIGbZai.js';
17
+ import { R as ResolvedModel } from './index-BvzrCBss.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-BvzrCBss.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-Ipv-RcfT.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-ORWNAAFP.mjs';
2
- export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from './chunk-5GIH3O6I.mjs';
3
- import { getModel } from './chunk-2P2R2XLK.mjs';
4
- export { getModel, getModelsByProvider, getStaticModelProvider, isAgentVisible, listModels, resolveAlias } from './chunk-2P2R2XLK.mjs';
5
- import './chunk-P5PQS3SJ.mjs';
1
+ export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile } from './chunk-HUNAWSDP.mjs';
2
+ export { CostUsageKindMismatchError, UnknownModelError, calculateAudioCost, calculateCost, calculateImageCost, calculateLLMCost, calculateVideoCost } from './chunk-UWURA235.mjs';
6
3
  export { shouldDebit } from './chunk-XFDXTFV3.mjs';
7
- export { evaluateAccess, evaluateCatalogDefaults } from './chunk-POKSD3S3.mjs';
8
- import { priceTierForModel } from './chunk-PKFRG2DA.mjs';
9
- export { assertReservedPrefixDiscipline, getActions, getEnrichment, isActionTag, modelHasAction, modelHasTag, modelMatchesCatalogPriceTier, modelMatchesKind, modelMatchesPriceTier, priceTierForModel } from './chunk-PKFRG2DA.mjs';
4
+ import './chunk-HFPX2DNR.mjs';
5
+ import { getModel } from './chunk-562U2L7T.mjs';
6
+ export { getModel, getModelsByProvider, getStaticModelProvider, isAgentVisible, listModels, resolveAlias } from './chunk-562U2L7T.mjs';
10
7
  export { clearCatalogOverlays, getMergedOverlay, registerCatalogOverlay } from './chunk-H6JUTF3U.mjs';
8
+ import './chunk-BQDTFJ4J.mjs';
9
+ export { evaluateAccess, evaluateCatalogDefaults, modelMatchesTarget } from './chunk-5LO27OWU.mjs';
10
+ import { priceTierForModel } from './chunk-F4BUE3N6.mjs';
11
+ export { assertReservedPrefixDiscipline, getActions, getEnrichment, isActionTag, isZeroPriced, modelHasAction, modelHasTag, modelMatchesCatalogPriceTier, modelMatchesKind, modelMatchesPriceTier, priceTierForModel } from './chunk-F4BUE3N6.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-FPTLINCV.mjs';
14
- export { DEFAULT_PRICING, LLM_PRICING_CATALOG, MODEL_ALIASES, calculateLLMCreditCost, resolvePricing, selectPricingTier } from './chunk-5E34CLTH.mjs';
14
+ export { DEFAULT_ANTHROPIC_MODEL } from './chunk-7CTQGUR2.mjs';
15
+ export { DEFAULT_PRICING, LLM_PRICING_CATALOG, MODEL_ALIASES, calculateLLMCreditCost, resolvePricing, selectPricingTier } from './chunk-Y2REI5QQ.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"]}
@@ -0,0 +1,70 @@
1
+ import { A as AccessTarget } from '../types-DMzMWJeJ.js';
2
+ export { i as isZeroPriced } from '../index-Ipv-RcfT.js';
3
+ import '../base-BaiI72Da.js';
4
+ import 'zod';
5
+ import '../index-BvzrCBss.js';
6
+ import '../catalog-B2eRnrWD.js';
7
+ import '../image/index.js';
8
+ import '../video/index.js';
9
+ import '../audio/index.js';
10
+ import '../audio-Do2j3wDC.js';
11
+ import '../schema/voice.js';
12
+
13
+ /**
14
+ * Model lists — named, user-editable selections over the model catalog.
15
+ *
16
+ * A list is data: a set of include selectors (OR), optional exclusions that
17
+ * always win, explicit id pins, and an ordering mode. The selector vocabulary
18
+ * is the existing `AccessTarget` matcher plus the catalog dimensions that have
19
+ * no access-rule target (price, context window, route variant) and list
20
+ * composition.
21
+ *
22
+ * `zero-cost` (the seed list) is the one way "free" is expressed in code now:
23
+ * `{ include: [{ kind: "tag", value: "price:zero" }] }`.
24
+ */
25
+
26
+ type ModelSelector = AccessTarget | {
27
+ kind: "price";
28
+ maxInPer1M?: number;
29
+ maxOutPer1M?: number;
30
+ } | {
31
+ kind: "context";
32
+ min: number;
33
+ } | {
34
+ kind: "variant";
35
+ value: string;
36
+ } | {
37
+ kind: "list";
38
+ id: string;
39
+ };
40
+ /** A named selection over the model catalog. An uncataloged `ids` pin is only
41
+ * removed by a `{ kind: "model" }` exclude; no other selector can match an id
42
+ * the catalog does not know. */
43
+ interface ModelList {
44
+ id: string;
45
+ label?: string;
46
+ include?: ModelSelector[];
47
+ exclude?: ModelSelector[];
48
+ ids?: string[];
49
+ order?: "listed" | "cheapest" | "largest-context" | "newest";
50
+ rotation?: "priority" | "round-robin" | "least-recently-limited";
51
+ }
52
+ interface ModelListSource {
53
+ get(id: string): ModelList | undefined;
54
+ }
55
+ declare class ModelListError extends Error {
56
+ readonly name = "ModelListError";
57
+ }
58
+ /** Test/consumer helper after an overlay or route registration changes. */
59
+ declare function clearModelListCache(): void;
60
+ /** Membership without full expansion; uncataloged ids match only via `ids`. */
61
+ declare function inModelList(model: string, id: string, src: ModelListSource): boolean;
62
+ /** Ordered, de-duplicated model ids. Throws ModelListError on unknown id or cycle. */
63
+ declare function resolveModelList(id: string, src: ModelListSource): string[];
64
+ /** Explain: per model, which selector or pin included it. */
65
+ declare function explainModelList(id: string, src: ModelListSource): Array<{
66
+ model: string;
67
+ via: string;
68
+ }>;
69
+
70
+ export { type ModelList, ModelListError, type ModelListSource, type ModelSelector, clearModelListCache, explainModelList, inModelList, resolveModelList };
@@ -0,0 +1,290 @@
1
+ import { getModel, resolveAlias, listModels } from '../chunk-562U2L7T.mjs';
2
+ import '../chunk-H6JUTF3U.mjs';
3
+ import { stripRouteSuffix, resolveLlmModelRoute, formatModelRef, listRouterLlmRoutes, tryParseModelRef } from '../chunk-BQDTFJ4J.mjs';
4
+ import { modelMatchesTarget } from '../chunk-5LO27OWU.mjs';
5
+ export { isZeroPriced } from '../chunk-F4BUE3N6.mjs';
6
+ import '../chunk-WG4F6IRS.mjs';
7
+ import '../chunk-7CTQGUR2.mjs';
8
+ import { resolveContextWindow } from '../chunk-Y2REI5QQ.mjs';
9
+ import '../chunk-QHELXPSL.mjs';
10
+ import '../chunk-2LWYZOWB.mjs';
11
+ import '../chunk-IJZ4XPO2.mjs';
12
+ import '../chunk-WRUWNKDB.mjs';
13
+ import '../chunk-SGJR6ZQH.mjs';
14
+ import '../chunk-HEDDSOZF.mjs';
15
+
16
+ /**
17
+ * @agentproto/model-catalog v0.1.0
18
+ * Unified model catalog: LLM, image, video, audio entries + cost dispatcher + picker.
19
+ * Zod-only OSS core; @agstudio/model-catalog layers billing/access/BYOK on top.
20
+ */
21
+
22
+ // src/lists/index.ts
23
+ var ModelListError = class extends Error {
24
+ name = "ModelListError";
25
+ };
26
+ var ROUTERS = [
27
+ "openrouter",
28
+ "requesty",
29
+ "huggingface",
30
+ "opencode",
31
+ "opencode-go"
32
+ ];
33
+ var candidateCache;
34
+ var candidateIndexCache;
35
+ var subjectIdsCache = /* @__PURE__ */ new Map();
36
+ function candidates() {
37
+ if (candidateCache) return candidateCache;
38
+ const out = listModels({ kind: "llm" });
39
+ const seen = new Set(out.map((model) => model.id));
40
+ for (const router of ROUTERS) {
41
+ for (const route of listRouterLlmRoutes(router)) {
42
+ const id = formatModelRef(route.ref);
43
+ if (seen.has(id)) continue;
44
+ seen.add(id);
45
+ out.push({
46
+ kind: "llm",
47
+ id,
48
+ canonicalId: route.canonicalProductId,
49
+ pricing: route.pricing,
50
+ provider: route.pricing.provider
51
+ });
52
+ }
53
+ }
54
+ candidateCache = out;
55
+ return out;
56
+ }
57
+ function clearModelListCache() {
58
+ candidateCache = void 0;
59
+ candidateIndexCache = void 0;
60
+ subjectIdsCache.clear();
61
+ }
62
+ function selectorLabel(selector) {
63
+ switch (selector.kind) {
64
+ case "model":
65
+ return `model:${selector.id}`;
66
+ case "price":
67
+ return `price:${selector.maxInPer1M ?? "*"}/${selector.maxOutPer1M ?? "*"}`;
68
+ case "context":
69
+ return `context:>=${selector.min}`;
70
+ case "variant":
71
+ return `variant:${selector.value}`;
72
+ case "list":
73
+ return `list:${selector.id}`;
74
+ default:
75
+ return `${selector.kind}:${selector.value}`;
76
+ }
77
+ }
78
+ function isListSelector(selector) {
79
+ return selector.kind === "list";
80
+ }
81
+ function contextWindowOf(model) {
82
+ if (model.kind !== "llm") return void 0;
83
+ return resolveContextWindow(model.id)?.contextWindow ?? resolveContextWindow(model.canonicalId)?.contextWindow;
84
+ }
85
+ function variantOf(id) {
86
+ const ref = tryParseModelRef(id);
87
+ return ref?.variant;
88
+ }
89
+ function selectorMatches(selector, model, rawId, src, stack) {
90
+ if (isListSelector(selector)) {
91
+ return inList(selector.id, rawId, src, stack);
92
+ }
93
+ switch (selector.kind) {
94
+ case "variant":
95
+ return variantOf(rawId) === selector.value || model !== void 0 && variantOf(model.id) === selector.value;
96
+ case "price": {
97
+ const pricing = model?.kind === "llm" ? model.pricing : void 0;
98
+ if (!pricing) return false;
99
+ if (selector.maxInPer1M !== void 0 && pricing.inputPer1M > selector.maxInPer1M) {
100
+ return false;
101
+ }
102
+ if (selector.maxOutPer1M !== void 0 && pricing.outputPer1M > selector.maxOutPer1M) {
103
+ return false;
104
+ }
105
+ return true;
106
+ }
107
+ case "context": {
108
+ if (!model) return false;
109
+ const window = contextWindowOf(model);
110
+ return window !== void 0 && window >= selector.min;
111
+ }
112
+ default:
113
+ return model !== void 0 && modelMatchesTarget(selector, model);
114
+ }
115
+ }
116
+ function excludeMatches(selector, model, rawId, src, stack) {
117
+ if (selector.kind === "model" && pinsMatch(selector.id, rawId)) {
118
+ return true;
119
+ }
120
+ return selectorMatches(selector, model, rawId, src, stack);
121
+ }
122
+ function candidateIndex() {
123
+ if (candidateIndexCache) return candidateIndexCache;
124
+ const index = /* @__PURE__ */ new Map();
125
+ for (const model of candidates()) index.set(model.id, model);
126
+ candidateIndexCache = index;
127
+ return index;
128
+ }
129
+ function subjectIds(raw) {
130
+ const cached = subjectIdsCache.get(raw);
131
+ if (cached) return cached;
132
+ const stripped = stripRouteSuffix(raw);
133
+ const out = /* @__PURE__ */ new Set([raw, stripped]);
134
+ const consider = (id) => {
135
+ out.add(id);
136
+ const model = getModel(id);
137
+ if (model) {
138
+ out.add(model.id);
139
+ if (model.kind === "llm") out.add(model.canonicalId);
140
+ }
141
+ out.add(resolveAlias(id));
142
+ try {
143
+ const route = resolveLlmModelRoute(id);
144
+ if (route) {
145
+ out.add(formatModelRef(route.ref));
146
+ out.add(`${route.vendor}/${route.product}`);
147
+ }
148
+ } catch {
149
+ }
150
+ };
151
+ consider(stripped);
152
+ if (!stripped.includes("/")) {
153
+ const bare = stripped.split(":")[0] ?? stripped;
154
+ for (const model of candidates()) {
155
+ const segment = model.id.split("/").pop()?.split(":")[0];
156
+ if (segment === bare) out.add(model.id);
157
+ }
158
+ }
159
+ const result = [...out];
160
+ subjectIdsCache.set(raw, result);
161
+ return result;
162
+ }
163
+ function pinsMatch(pin, id) {
164
+ if (pin === id) return true;
165
+ const pinStripped = stripRouteSuffix(pin);
166
+ const idStripped = stripRouteSuffix(id);
167
+ return pin === idStripped || pinStripped === id || pinStripped === idStripped;
168
+ }
169
+ function listContains(list, rawId, src, stack) {
170
+ const index = candidateIndex();
171
+ const model = index.get(rawId) ?? index.get(stripRouteSuffix(rawId));
172
+ for (const selector of list.exclude ?? []) {
173
+ if (excludeMatches(selector, model, rawId, src, stack)) return false;
174
+ }
175
+ if ((list.ids ?? []).some((pin) => pinsMatch(pin, rawId))) return true;
176
+ return (list.include ?? []).some(
177
+ (selector) => selectorMatches(selector, model, rawId, src, stack)
178
+ );
179
+ }
180
+ function inList(listId, rawId, src, stack) {
181
+ const list = src.get(listId);
182
+ if (!list) throw new ModelListError(`unknown model list "${listId}"`);
183
+ if (stack.includes(listId)) {
184
+ throw new ModelListError(
185
+ `model list cycle: ${[...stack, listId].join(" -> ")}`
186
+ );
187
+ }
188
+ return listContains(list, rawId, src, [...stack, listId]);
189
+ }
190
+ function inModelList(model, id, src) {
191
+ return subjectIds(model).some(
192
+ (candidate) => inList(id, candidate, src, [])
193
+ );
194
+ }
195
+ function insert(entries, model, via) {
196
+ if (!entries.has(model)) entries.set(model, { model, via });
197
+ }
198
+ function resolveEntries(id, src, stack) {
199
+ const list = src.get(id);
200
+ if (!list) throw new ModelListError(`unknown model list "${id}"`);
201
+ if (stack.includes(id)) {
202
+ throw new ModelListError(`model list cycle: ${[...stack, id].join(" -> ")}`);
203
+ }
204
+ const nextStack = [...stack, id];
205
+ const entries = /* @__PURE__ */ new Map();
206
+ const index = candidateIndex();
207
+ const all = candidates();
208
+ for (const selector of list.include ?? []) {
209
+ if (isListSelector(selector)) {
210
+ for (const entry of resolveEntries(selector.id, src, nextStack)) {
211
+ insert(entries, entry.model, `list:${selector.id}`);
212
+ }
213
+ continue;
214
+ }
215
+ for (const model of all) {
216
+ if (selectorMatches(selector, model, model.id, src, nextStack)) {
217
+ insert(entries, model.id, selectorLabel(selector));
218
+ }
219
+ }
220
+ }
221
+ for (const pin of list.ids ?? []) insert(entries, pin, "ids");
222
+ for (const selector of list.exclude ?? []) {
223
+ if (isListSelector(selector)) {
224
+ for (const entry of resolveEntries(selector.id, src, nextStack)) {
225
+ entries.delete(entry.model);
226
+ }
227
+ continue;
228
+ }
229
+ for (const model of all) {
230
+ if (selectorMatches(selector, model, model.id, src, nextStack)) {
231
+ entries.delete(model.id);
232
+ }
233
+ }
234
+ for (const key of [...entries.keys()]) {
235
+ if (excludeMatches(selector, index.get(key), key, src, nextStack)) {
236
+ entries.delete(key);
237
+ }
238
+ }
239
+ }
240
+ return [...entries.values()];
241
+ }
242
+ function applyOrder(entries, order, index) {
243
+ if (!order || order === "listed" || entries.length === 0) return entries;
244
+ const pricingOf = (entry) => {
245
+ const model = index.get(entry.model);
246
+ return model?.kind === "llm" ? model.pricing : void 0;
247
+ };
248
+ const sorted = [...entries];
249
+ sorted.sort((a, b) => {
250
+ const pa = pricingOf(a);
251
+ const pb = pricingOf(b);
252
+ if (order === "cheapest") {
253
+ const ca = pa ? pa.inputPer1M + pa.outputPer1M : Number.POSITIVE_INFINITY;
254
+ const cb = pb ? pb.inputPer1M + pb.outputPer1M : Number.POSITIVE_INFINITY;
255
+ return ca - cb;
256
+ }
257
+ if (order === "largest-context") {
258
+ const ma = index.get(a.model);
259
+ const mb = index.get(b.model);
260
+ const ca = ma ? contextWindowOf(ma) ?? Number.NEGATIVE_INFINITY : Number.NEGATIVE_INFINITY;
261
+ const cb = mb ? contextWindowOf(mb) ?? Number.NEGATIVE_INFINITY : Number.NEGATIVE_INFINITY;
262
+ return cb - ca;
263
+ }
264
+ const aa = pa?.addedAt ?? "";
265
+ const ab = pb?.addedAt ?? "";
266
+ return aa === ab ? 0 : aa < ab ? 1 : -1;
267
+ });
268
+ return sorted;
269
+ }
270
+ function resolveModelList(id, src) {
271
+ const list = src.get(id);
272
+ if (!list) throw new ModelListError(`unknown model list "${id}"`);
273
+ const entries = resolveEntries(id, src, []);
274
+ return applyOrder(entries, list.order, candidateIndex()).map(
275
+ (entry) => entry.model
276
+ );
277
+ }
278
+ function explainModelList(id, src) {
279
+ const list = src.get(id);
280
+ if (!list) throw new ModelListError(`unknown model list "${id}"`);
281
+ const entries = resolveEntries(id, src, []);
282
+ return applyOrder(entries, list.order, candidateIndex()).map((entry) => ({
283
+ model: entry.model,
284
+ via: entry.via
285
+ }));
286
+ }
287
+
288
+ export { ModelListError, clearModelListCache, explainModelList, inModelList, resolveModelList };
289
+ //# sourceMappingURL=index.mjs.map
290
+ //# sourceMappingURL=index.mjs.map