@agentproto/model-catalog 0.5.0 → 0.7.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 (38) hide show
  1. package/dist/access/index.d.ts +5 -5
  2. package/dist/audio/index.d.ts +1 -1
  3. package/dist/{audio-BbeLA_4x.d.ts → audio-DR0g_ZH_.d.ts} +1 -0
  4. package/dist/{base-C4kz9Dxc.d.ts → base-B8IIoaqg.d.ts} +2 -0
  5. package/dist/{catalog-BPDMuxzf.d.ts → catalog-BbfjJxKT.d.ts} +31 -2
  6. package/dist/{chunk-VIVKDMAT.mjs → chunk-6AXCZGQY.mjs} +3 -3
  7. package/dist/{chunk-VIVKDMAT.mjs.map → chunk-6AXCZGQY.mjs.map} +1 -1
  8. package/dist/{chunk-FCPS2VGK.mjs → chunk-6VDWPE62.mjs} +735 -525
  9. package/dist/chunk-6VDWPE62.mjs.map +1 -0
  10. package/dist/chunk-DW45X6XT.mjs +70 -0
  11. package/dist/chunk-DW45X6XT.mjs.map +1 -0
  12. package/dist/{chunk-TQSSXYY5.mjs → chunk-HL2G36MT.mjs} +4 -62
  13. package/dist/chunk-HL2G36MT.mjs.map +1 -0
  14. package/dist/{chunk-S74S3Q7Z.mjs → chunk-OWNEHUFQ.mjs} +3 -3
  15. package/dist/{chunk-S74S3Q7Z.mjs.map → chunk-OWNEHUFQ.mjs.map} +1 -1
  16. package/dist/{chunk-GCDMRPDR.mjs → chunk-QLFNCLH2.mjs} +4 -4
  17. package/dist/{chunk-GCDMRPDR.mjs.map → chunk-QLFNCLH2.mjs.map} +1 -1
  18. package/dist/cost/index.mjs +3 -3
  19. package/dist/curation/index.d.ts +4 -4
  20. package/dist/curation/index.mjs +3 -3
  21. package/dist/{evaluate-CVzfLCd0.d.ts → evaluate-BKCR5Huz.d.ts} +2 -2
  22. package/dist/{index-CgOxudo5.d.ts → index-DpeiyVjg.d.ts} +3 -3
  23. package/dist/{index-DSgqNd3Z.d.ts → index-avZZsCtQ.d.ts} +1 -1
  24. package/dist/index.d.ts +7 -7
  25. package/dist/index.mjs +7 -6
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/llm/index.d.ts +2 -2
  28. package/dist/llm/index.mjs +1 -1
  29. package/dist/overlay/index.d.ts +3 -3
  30. package/dist/picker/index.d.ts +6 -6
  31. package/dist/route-identity/index.d.ts +153 -14
  32. package/dist/route-identity/index.mjs +3078 -28
  33. package/dist/route-identity/index.mjs.map +1 -1
  34. package/dist/schema/index.d.ts +9 -2
  35. package/dist/schema/index.mjs +2 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-FCPS2VGK.mjs.map +0 -1
  38. package/dist/chunk-TQSSXYY5.mjs.map +0 -1
@@ -1,32 +1,62 @@
1
- import { c as LLMPricing } from '../catalog-BPDMuxzf.js';
2
- import '../base-C4kz9Dxc.js';
1
+ import { c as LLMPricing } from '../catalog-BbfjJxKT.js';
2
+ import '../base-B8IIoaqg.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
6
6
  * Route-aware model identity.
7
7
  *
8
8
  * Canonical reference syntax:
9
- * vendor/product[@route]
9
+ * [route:]vendor/product[:pin][@route]
10
10
  *
11
11
  * A model product (who built it + what product) is separate from its serving
12
- * route (how we reach it / how we are billed).
12
+ * route (how we reach it / how we are billed) and from an optional `:pin` —
13
+ * an OpenRouter routing variant or an inference-provider selector.
14
+ *
15
+ * Three axes:
16
+ *
17
+ * | Axis | Question it answers | Example value |
18
+ * |---------------------|------------------------------|---------------------------|
19
+ * | `vendor` | who built the model | `openai`, `anthropic` |
20
+ * | `route` | how we reach it / are billed | `openrouter`, `huggingface`, `openai` (direct) |
21
+ * | `inferenceProvider` / `variant` | who runs the GPUs behind a router, or which routing mode | `cerebras`, `groq` (provider); `free`, `nitro` (variant) |
13
22
  *
14
23
  * Examples:
15
- * openai/gpt-4o → vendor openai, product gpt-4o, route openai (direct)
16
- * openai/gpt-4o@openrouter → same product, routed through OpenRouter
17
- * openai/gpt-4o@agentik-proxy → same product, operator-configured proxy route
24
+ * openai/gpt-4o → vendor openai, product gpt-4o, route openai (direct)
25
+ * openai/gpt-4o@openrouter → same product, routed through OpenRouter
26
+ * openai/gpt-4o@agentik-proxy → same product, operator-configured proxy route
27
+ * deepseek/deepseek-chat:free@openrouter → OpenRouter, variant "free"
28
+ * openrouter:deepseek/deepseek-chat:free → legacy PREFIX form, same result
29
+ * meta-llama/Llama-3.1-8B:cerebras@huggingface → HuggingFace, inference-provider pin "cerebras"
30
+ *
31
+ * `:pin` classification (per the resolved route):
32
+ * - `openrouter` (or no explicit route) + pin ∈ {free, nitro, floor, online,
33
+ * exacto} → `variant` (a routing mode, not a provider).
34
+ * - anything else → `inferenceProvider` (HF inference provider / OpenRouter
35
+ * provider pin).
18
36
  *
19
37
  * Design invariants:
20
38
  * - `vendor` is who built the model; `route` is how we reach it.
21
39
  * - `provider/model` strings parse as vendor/product with implicit route = vendor
22
40
  * (backward-compatible reference form).
23
- * - Unscoped `xx@yy` is rejected.
41
+ * - Unscoped `xx@yy` is rejected; bare ids without a slash are rejected
42
+ * (lenient handling belongs in consumers — see `tryParseModelRef`).
43
+ * - The legacy `route:` PREFIX (colon before the first `/`, prefix must be a
44
+ * known route name) parses; an explicit `@route` suffix wins on conflict.
45
+ * `formatModelRef` always emits the canonical suffix form.
24
46
  * - Route metadata (pricing, limits, transport, availability) is separate from
25
47
  * product metadata and computed at resolution time.
26
48
  * - The abstraction is generic across model kinds; only LLM has a concrete
27
49
  * resolver today.
28
50
  */
29
51
 
52
+ /**
53
+ * OpenRouter variant suffixes — a CLOSED list. A `:pin` matching one of
54
+ * these on the OpenRouter route (or on a route-less/implicit-route id) is a
55
+ * routing *variant*, never an inference-provider pin.
56
+ * @see https://openrouter.ai/docs/features/provider-routing
57
+ */
58
+ declare const OPENROUTER_VARIANTS: readonly ["free", "nitro", "floor", "online", "exacto"];
59
+ type OpenRouterVariant = (typeof OPENROUTER_VARIANTS)[number];
30
60
  interface ModelRef {
31
61
  /** The original, trimmed string. */
32
62
  raw: string;
@@ -36,6 +66,14 @@ interface ModelRef {
36
66
  product: string;
37
67
  /** Routing target — defaults to vendor for direct vendor access. */
38
68
  route: string;
69
+ /**
70
+ * Explicit `:pin` classified as an inference-provider selector (HF
71
+ * inference provider, or an OpenRouter provider pin outside the closed
72
+ * variant list) rather than a routing variant.
73
+ */
74
+ inferenceProvider?: string;
75
+ /** OpenRouter routing variant (`free`, `nitro`, `floor`, `online`, `exacto`) — a closed list, never a provider. */
76
+ variant?: string;
39
77
  }
40
78
  declare class InvalidModelRefError extends Error {
41
79
  readonly raw: string;
@@ -43,20 +81,120 @@ declare class InvalidModelRefError extends Error {
43
81
  constructor(raw: string, message: string);
44
82
  }
45
83
  /**
46
- * Parse a model reference in `vendor/product[@route]` form.
84
+ * Parse a model reference in `[route:]vendor/product[:pin][@route]` form.
47
85
  *
48
86
  * - `openai/gpt-4o` → `{ vendor: "openai", product: "gpt-4o", route: "openai" }`
49
87
  * - `openai/gpt-4o@openrouter` → route "openrouter"
88
+ * - `deepseek/deepseek-chat:free@openrouter` → route "openrouter", variant "free"
89
+ * - `meta-llama/Llama-3.1-8B:cerebras@huggingface` → route "huggingface", inferenceProvider "cerebras"
90
+ * - `openrouter:anthropic/claude-sonnet-4.5` → legacy prefix, route "openrouter"
50
91
  *
51
- * Rejects empty strings, unscoped `@` refs, missing segments, and segments
52
- * containing `/` or `@`.
92
+ * Rejects empty strings, unscoped `@` refs, bare ids without a slash, missing
93
+ * segments, and segments containing `/` or `@`. `@route` wins over the
94
+ * legacy prefix when both are present.
53
95
  */
54
96
  declare function parseModelRef(raw: string): ModelRef;
55
97
  /**
56
- * Format a {@link ModelRef} back to its canonical string.
57
- * Implicit direct routes omit the `@route` suffix.
98
+ * {@link parseModelRef}, but never throws — returns `undefined` for any
99
+ * input the strict grammar rejects (bare ids, malformed refs, …). Lenient
100
+ * handling of non-canonical ids belongs in callers; this just makes the
101
+ * strict parser safe to probe.
102
+ */
103
+ declare function tryParseModelRef(raw: string): ModelRef | undefined;
104
+ /**
105
+ * Format a {@link ModelRef} back to its canonical string
106
+ * `vendor/product[:pin][@route]`. Implicit direct routes omit the `@route`
107
+ * suffix. Always emits the canonical suffix form — never the legacy
108
+ * `route:` prefix — so `formatModelRef(parseModelRef(x))` is stable
109
+ * (idempotent under re-parse). Prefers `variant` over `inferenceProvider`
110
+ * when (implausibly) both are set, since parse only ever produces one.
58
111
  */
59
112
  declare function formatModelRef(ref: ModelRef): string;
113
+ /**
114
+ * Strip a route-identity `@route` SUFFIX from a model id, returning the bare
115
+ * id that an UPSTREAM (the provider/gateway, via `ANTHROPIC_MODEL` or the wire
116
+ * `model`) actually understands. The `@route` suffix is a catalog-join
117
+ * annotation used to pin which serving route a picked model uses — the gateway
118
+ * itself never sees it (OpenRouter/Requesty/the llm-endpoint proxy don't
119
+ * recognise `z-ai/glm-5.2@openrouter`, only `z-ai/glm-5.2`). At spawn the route
120
+ * is already carried separately (`route.gateway` → base_url), so the suffix is
121
+ * redundant metadata that must not leak to the wire.
122
+ *
123
+ * - `z-ai/glm-5.2@openrouter` → `z-ai/glm-5.2`
124
+ * - `deepseek/deepseek-chat:free@openrouter` → `deepseek/deepseek-chat:free` (variant kept)
125
+ * - `glm-5.2@llm-endpoint` → `glm-5.2` (routeless proxy alias)
126
+ * - `claude-opus-4-8` → `claude-opus-4-8` (no route, unchanged)
127
+ * - `openai/gpt-4o` → `openai/gpt-4o` (direct route, unchanged)
128
+ *
129
+ * Prefers the strict parser so an id is only altered when the trailing token is
130
+ * a genuine explicit route (`route !== vendor`); the pin (`:variant` /
131
+ * `:inferenceProvider`) is preserved because gateways accept it. Falls back to
132
+ * removing only a trailing `@…` for ids the strict grammar rejects (e.g. the
133
+ * vendor-less `glm-5.2@llm-endpoint`): the SEGMENT grammar forbids `@`
134
+ * anywhere but the route separator, so the last `@` can only be that.
135
+ */
136
+ declare function stripRouteSuffix(raw: string): string;
137
+ /**
138
+ * Reduce a DIRECT-anthropic catalog ref to the BARE product id the native
139
+ * Anthropic wire expects (the `claude` ACP wrapper's `session/set_config_option`
140
+ * model selector, and claude-sdk's `env.ANTHROPIC_MODEL`) — both resolve only
141
+ * bare Anthropic ids (`claude-sonnet-4-5`), never the catalog's canonical
142
+ * `anthropic/claude-sonnet-4-5` route form. {@link stripRouteSuffix} only peels
143
+ * the `@route` SUFFIX and deliberately keeps `vendor/product`, so a
144
+ * direct-anthropic ref survives it prefixed and the wrapper mis-resolves it.
145
+ *
146
+ * ONLY a `anthropic/<product>` ref in DIRECT form (route === vendor, i.e. no
147
+ * gateway `@route`) collapses to `<product>`. Everything else falls through to
148
+ * {@link stripRouteSuffix} untouched:
149
+ * - a GATEWAY-routed anthropic ref (`anthropic/claude-x@openrouter`) keeps its
150
+ * `vendor/product` because the gateway needs it,
151
+ * - other vendors (`z-ai/glm-5.2@openrouter`, `moonshot/kimi-k2.7-code@llm-endpoint`)
152
+ * keep `vendor/product` — those same claude-code/claude-sdk adapters route
153
+ * them through `base_url`, where the gateway rejects a bare product,
154
+ * - already-bare ids (`claude-sonnet-5`) are unchanged.
155
+ *
156
+ * Callers MUST gate this on the adapter being Anthropic-NATIVE (claude-code /
157
+ * claude-sdk, `provider: "anthropic"`); a `derived-from-model` adapter (hermes,
158
+ * opencode, …) derives its route FROM the vendor prefix and needs it kept.
159
+ *
160
+ * - `anthropic/claude-sonnet-4-5` → `claude-sonnet-4-5`
161
+ * - `anthropic/claude-sonnet-4-5@openrouter` → `anthropic/claude-sonnet-4-5`
162
+ * - `z-ai/glm-5.2@openrouter` → `z-ai/glm-5.2`
163
+ * - `claude-sonnet-5` → `claude-sonnet-5`
164
+ */
165
+ declare function stripAnthropicNativeVendor(raw: string): string;
166
+ /**
167
+ * Generalized form of {@link stripAnthropicNativeVendor} — reduce a
168
+ * DIRECT-`vendor` catalog ref to the BARE product id a fixed-single-provider
169
+ * adapter's own wire expects, for ANY vendor, not just Anthropic. Every
170
+ * adapter whose manifest declares a FIXED `provider` and takes bare model ids
171
+ * on its native route (claude-code/claude-sdk → anthropic, codex → openai,
172
+ * gemini → google, …) hits this same class of bug: the catalog's canonical
173
+ * `vendor/product` form survives onto the wire and the adapter's own
174
+ * `models.allowed` enum — which declares bare ids — rejects it
175
+ * (`option_enum_violation`).
176
+ *
177
+ * ONLY a `<vendor>/<product>` ref in DIRECT form (route === vendor, i.e. no
178
+ * gateway `@route`) AND matching the given `vendor` collapses to `<product>`.
179
+ * Everything else falls through to {@link stripRouteSuffix} untouched:
180
+ * - a GATEWAY-routed ref (`openai/gpt-5@openrouter`) keeps its
181
+ * `vendor/product` because the gateway needs it,
182
+ * - a ref for a DIFFERENT vendor (`z-ai/glm-5.2` handed to an
183
+ * `openai`-fixed adapter) keeps `vendor/product` — stripping would
184
+ * invent a wrong bare id for a model this adapter doesn't natively serve,
185
+ * - already-bare ids (`gpt-5`) are unchanged.
186
+ *
187
+ * Callers MUST gate this on the adapter being a FIXED-single-provider,
188
+ * non-derived-from-model adapter (`routeSelection !== "derived-from-model"`
189
+ * AND a fixed `provider`); a `derived-from-model` adapter (hermes, pi,
190
+ * opencode, …) derives its route FROM the vendor prefix and needs it kept.
191
+ *
192
+ * - `openai/gpt-5` (vendor "openai") → `gpt-5`
193
+ * - `openai/gpt-5@openrouter` (vendor "openai") → `openai/gpt-5`
194
+ * - `z-ai/glm-5.2` (vendor "openai") → `z-ai/glm-5.2` (mismatch, unchanged)
195
+ * - `gpt-5` (vendor "openai") → `gpt-5` (already bare)
196
+ */
197
+ declare function stripFixedNativeVendor(raw: string, vendor: string): string;
60
198
  /** True when `raw` matches the `vendor/product[@route]` shape. */
61
199
  declare function isModelRefString(raw: string): boolean;
62
200
  interface ModelRouteLimits {
@@ -124,6 +262,7 @@ declare function clearCustomRoutes(): void;
124
262
  * openai/gpt-4o → direct OpenAI pricing / transport
125
263
  * openai/gpt-4o@openrouter → OpenRouter route pricing / transport
126
264
  * openai/gpt-4o@requesty → Requesty route pricing / transport
265
+ * meta-llama/Llama-3.1-8B:cerebras@huggingface → HuggingFace, pinned to the "cerebras" inference provider
127
266
  * openai/gpt-4o@agentik-proxy → custom route config (if registered)
128
267
  *
129
268
  * Bare legacy ids (e.g. `gpt-4o`, `claude-sonnet-4-5`) are also accepted and
@@ -155,4 +294,4 @@ interface ModelRefDiagnostic {
155
294
  */
156
295
  declare function diagnoseModelRef(input: string | ModelRef): ModelRefDiagnostic | undefined;
157
296
 
158
- export { type CustomRouteConfig, InvalidModelRefError, type ModelProductMeta, type ModelRef, type ModelRefDiagnostic, type ModelRouteAvailability, type ModelRouteLimits, type ModelRouteMeta, type ModelRouteTransport, type ResolvedLlmModelRoute, type ResolvedModelRoute, clearCustomRoutes, diagnoseModelRef, formatModelRef, isModelRefString, parseModelRef, registerCustomRoute, resolveCustomRoute, resolveLlmModelRoute };
297
+ export { type CustomRouteConfig, InvalidModelRefError, type ModelProductMeta, type ModelRef, type ModelRefDiagnostic, type ModelRouteAvailability, type ModelRouteLimits, type ModelRouteMeta, type ModelRouteTransport, OPENROUTER_VARIANTS, type OpenRouterVariant, type ResolvedLlmModelRoute, type ResolvedModelRoute, clearCustomRoutes, diagnoseModelRef, formatModelRef, isModelRefString, parseModelRef, registerCustomRoute, resolveCustomRoute, resolveLlmModelRoute, stripAnthropicNativeVendor, stripFixedNativeVendor, stripRouteSuffix, tryParseModelRef };