@agentproto/model-catalog 0.2.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.
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/access/index.d.ts +30 -0
- package/dist/access/index.mjs +4 -0
- package/dist/access/index.mjs.map +1 -0
- package/dist/audio/index.d.ts +84 -0
- package/dist/audio/index.mjs +3 -0
- package/dist/audio/index.mjs.map +1 -0
- package/dist/audio-BzVF_wke.d.ts +92 -0
- package/dist/base-BNHcMifc.d.ts +109 -0
- package/dist/byok/index.d.ts +33 -0
- package/dist/byok/index.mjs +3 -0
- package/dist/byok/index.mjs.map +1 -0
- package/dist/catalog-aQHd559b.d.ts +594 -0
- package/dist/chunk-2LWYZOWB.mjs +643 -0
- package/dist/chunk-2LWYZOWB.mjs.map +1 -0
- package/dist/chunk-CINXNTU3.mjs +134 -0
- package/dist/chunk-CINXNTU3.mjs.map +1 -0
- package/dist/chunk-F7OEHYUI.mjs +187 -0
- package/dist/chunk-F7OEHYUI.mjs.map +1 -0
- package/dist/chunk-GH7PB5FB.mjs +183 -0
- package/dist/chunk-GH7PB5FB.mjs.map +1 -0
- package/dist/chunk-H6JUTF3U.mjs +33 -0
- package/dist/chunk-H6JUTF3U.mjs.map +1 -0
- package/dist/chunk-HEDDSOZF.mjs +47 -0
- package/dist/chunk-HEDDSOZF.mjs.map +1 -0
- package/dist/chunk-HRRG2RZO.mjs +116 -0
- package/dist/chunk-HRRG2RZO.mjs.map +1 -0
- package/dist/chunk-IJZ4XPO2.mjs +606 -0
- package/dist/chunk-IJZ4XPO2.mjs.map +1 -0
- package/dist/chunk-IORIAFK2.mjs +227 -0
- package/dist/chunk-IORIAFK2.mjs.map +1 -0
- package/dist/chunk-OHAMH3ZE.mjs +2629 -0
- package/dist/chunk-OHAMH3ZE.mjs.map +1 -0
- package/dist/chunk-QHELXPSL.mjs +85 -0
- package/dist/chunk-QHELXPSL.mjs.map +1 -0
- package/dist/chunk-SGJR6ZQH.mjs +1230 -0
- package/dist/chunk-SGJR6ZQH.mjs.map +1 -0
- package/dist/chunk-WRUWNKDB.mjs +521 -0
- package/dist/chunk-WRUWNKDB.mjs.map +1 -0
- package/dist/chunk-WTHHXXIK.mjs +366 -0
- package/dist/chunk-WTHHXXIK.mjs.map +1 -0
- package/dist/chunk-XFDXTFV3.mjs +28 -0
- package/dist/chunk-XFDXTFV3.mjs.map +1 -0
- package/dist/cost/index.d.ts +114 -0
- package/dist/cost/index.mjs +13 -0
- package/dist/cost/index.mjs.map +1 -0
- package/dist/curation/index.d.ts +98 -0
- package/dist/curation/index.mjs +13 -0
- package/dist/curation/index.mjs.map +1 -0
- package/dist/evaluate-DisH3H7u.d.ts +84 -0
- package/dist/image/index.d.ts +79 -0
- package/dist/image/index.mjs +3 -0
- package/dist/image/index.mjs.map +1 -0
- package/dist/index-BICjPG8H.d.ts +132 -0
- package/dist/index-D8nL3fPZ.d.ts +171 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.mjs +33 -0
- package/dist/index.mjs.map +1 -0
- package/dist/llm/index.d.ts +48 -0
- package/dist/llm/index.mjs +4 -0
- package/dist/llm/index.mjs.map +1 -0
- package/dist/overlay/index.d.ts +67 -0
- package/dist/overlay/index.mjs +3 -0
- package/dist/overlay/index.mjs.map +1 -0
- package/dist/picker/index.d.ts +11 -0
- package/dist/picker/index.mjs +26 -0
- package/dist/picker/index.mjs.map +1 -0
- package/dist/pricing/index.d.ts +106 -0
- package/dist/pricing/index.mjs +3 -0
- package/dist/pricing/index.mjs.map +1 -0
- package/dist/providers/index.d.ts +78 -0
- package/dist/providers/index.mjs +237 -0
- package/dist/providers/index.mjs.map +1 -0
- package/dist/schema/index.d.ts +627 -0
- package/dist/schema/index.mjs +4 -0
- package/dist/schema/index.mjs.map +1 -0
- package/dist/schema/voice.d.ts +66 -0
- package/dist/schema/voice.mjs +3 -0
- package/dist/schema/voice.mjs.map +1 -0
- package/dist/video/index.d.ts +78 -0
- package/dist/video/index.mjs +3 -0
- package/dist/video/index.mjs.map +1 -0
- package/dist/voice/index.d.ts +1300 -0
- package/dist/voice/index.mjs +4 -0
- package/dist/voice/index.mjs.map +1 -0
- package/package.json +137 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { C as CatalogKind, R as ResolvedModel } from '../index-BICjPG8H.js';
|
|
2
|
+
import { CatalogVoice } from '../schema/voice.js';
|
|
3
|
+
import '../catalog-aQHd559b.js';
|
|
4
|
+
import '../base-BNHcMifc.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../image/index.js';
|
|
7
|
+
import '../video/index.js';
|
|
8
|
+
import '../audio/index.js';
|
|
9
|
+
import '../audio-BzVF_wke.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Curation — what an app SURFACES from the catalog, distinct from
|
|
13
|
+
* model-access (who MAY use a model: tier/scope policy). Curation is the
|
|
14
|
+
* "feature/provider catalog" layer: an app composes views over the one
|
|
15
|
+
* registry ("all s2s voices from OpenAI OR Google", "images only", …)
|
|
16
|
+
* without touching the underlying data.
|
|
17
|
+
*
|
|
18
|
+
* Two registries, both following the canonical profile-registry shape
|
|
19
|
+
* (`listX()` / `getX(id)` throwing with the known-id list):
|
|
20
|
+
*
|
|
21
|
+
* 1. PROVIDER GROUPS — a company (`openai`) maps to every provider tag
|
|
22
|
+
* it owns across kinds (`openai` for the LLM/audio company tag,
|
|
23
|
+
* `openai-realtime` for its voice engine). This is what reconciles
|
|
24
|
+
* the two provider vocabularies in the registry: audio MODELS are
|
|
25
|
+
* tagged by company, voices by engine. Curating by group spans both.
|
|
26
|
+
*
|
|
27
|
+
* 2. SURFACE PROFILES — named presets (`voice-s2s`, `images`, …) an app
|
|
28
|
+
* selects from. Permissive by default (`all`); apps narrow only when
|
|
29
|
+
* a picker should diverge.
|
|
30
|
+
*
|
|
31
|
+
* Selection precedence (caller's job): per-call arg → per-app/guild
|
|
32
|
+
* config → env → `all` fallback.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
interface ProviderGroup {
|
|
36
|
+
/** Canonical company id, e.g. "openai", "google". */
|
|
37
|
+
id: string;
|
|
38
|
+
/** Display label. */
|
|
39
|
+
label: string;
|
|
40
|
+
/**
|
|
41
|
+
* Every provider tag this company owns across kinds. Audio/image/LLM use
|
|
42
|
+
* the company tag (`openai`); the voice engine uses its own (`openai-realtime`).
|
|
43
|
+
*/
|
|
44
|
+
providers: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
declare function listProviderGroups(): readonly ProviderGroup[];
|
|
47
|
+
declare function getProviderGroup(id: string): ProviderGroup;
|
|
48
|
+
/** The group that owns a raw provider tag, if any. */
|
|
49
|
+
declare function groupForProvider(providerTag: string): ProviderGroup | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Expand a mixed list of provider-group ids and raw provider tags into the
|
|
52
|
+
* flat set of provider tags to match against. A token that is a known
|
|
53
|
+
* group id expands to its members; anything else passes through as a raw
|
|
54
|
+
* tag (so callers can target an engine directly, e.g. `gemini-live`).
|
|
55
|
+
*/
|
|
56
|
+
declare function expandProviders(tokens: readonly string[]): string[];
|
|
57
|
+
interface SurfaceProfile {
|
|
58
|
+
id: string;
|
|
59
|
+
description: string;
|
|
60
|
+
/** Restrict to these kinds. Undefined/empty = every kind. */
|
|
61
|
+
kinds?: readonly CatalogKind[];
|
|
62
|
+
/**
|
|
63
|
+
* Restrict to these provider GROUP ids or raw provider tags (OR-set).
|
|
64
|
+
* Expanded via `expandProviders`, so `["openai"]` covers both the
|
|
65
|
+
* `openai` company tag and the `openai-realtime` voice engine.
|
|
66
|
+
*/
|
|
67
|
+
providers?: readonly string[];
|
|
68
|
+
/** Require all of these capability tags (AND-set): `s2s`, `tts`, `edit`, … */
|
|
69
|
+
capabilities?: readonly string[];
|
|
70
|
+
/** Require all of these arbitrary tags (AND-set). */
|
|
71
|
+
tags?: readonly string[];
|
|
72
|
+
}
|
|
73
|
+
declare function listSurfaceProfiles(): readonly SurfaceProfile[];
|
|
74
|
+
declare function getSurfaceProfile(id: string): SurfaceProfile;
|
|
75
|
+
/**
|
|
76
|
+
* True iff a model passes a surface profile. Provider membership, like
|
|
77
|
+
* capability/tag membership, is checked against the enrichment tag
|
|
78
|
+
* vocabulary (every kind emits its provider as a tag), so this is uniform
|
|
79
|
+
* across kinds and naturally spans the company/engine provider split.
|
|
80
|
+
*/
|
|
81
|
+
declare function modelMatchesProfile(model: ResolvedModel, profile: SurfaceProfile): boolean;
|
|
82
|
+
/** Filter a model list down to what a surface profile exposes. */
|
|
83
|
+
declare function applyProfile(models: ResolvedModel[], profile: SurfaceProfile): ResolvedModel[];
|
|
84
|
+
/**
|
|
85
|
+
* The catalog as a surface profile exposes it — `applyProfile` over the
|
|
86
|
+
* full registry. The composable entry point for "show me this view".
|
|
87
|
+
*/
|
|
88
|
+
declare function listSurfaced(profile: SurfaceProfile): ResolvedModel[];
|
|
89
|
+
/**
|
|
90
|
+
* Voice-list curation. The merged voice catalog (curated + live
|
|
91
|
+
* ElevenLabs) is `CatalogVoice[]`, not `ResolvedModel[]`, so it gets its
|
|
92
|
+
* own provider filter — same group-expansion semantics. Only the provider
|
|
93
|
+
* facet of a profile applies to a raw voice list (kind is implicitly
|
|
94
|
+
* voice; capability/tag live on the registry projection).
|
|
95
|
+
*/
|
|
96
|
+
declare function filterVoicesByProviders(voices: CatalogVoice[], providerTokens: readonly string[]): CatalogVoice[];
|
|
97
|
+
|
|
98
|
+
export { type ProviderGroup, type SurfaceProfile, applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { applyProfile, expandProviders, filterVoicesByProviders, getProviderGroup, getSurfaceProfile, groupForProvider, listProviderGroups, listSurfaceProfiles, listSurfaced, modelMatchesProfile } from '../chunk-CINXNTU3.mjs';
|
|
2
|
+
import '../chunk-GH7PB5FB.mjs';
|
|
3
|
+
import '../chunk-WTHHXXIK.mjs';
|
|
4
|
+
import '../chunk-H6JUTF3U.mjs';
|
|
5
|
+
import '../chunk-OHAMH3ZE.mjs';
|
|
6
|
+
import '../chunk-QHELXPSL.mjs';
|
|
7
|
+
import '../chunk-2LWYZOWB.mjs';
|
|
8
|
+
import '../chunk-IJZ4XPO2.mjs';
|
|
9
|
+
import '../chunk-WRUWNKDB.mjs';
|
|
10
|
+
import '../chunk-SGJR6ZQH.mjs';
|
|
11
|
+
import '../chunk-HEDDSOZF.mjs';
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { R as ResolvedModel } from './index-BICjPG8H.js';
|
|
2
|
+
import { M as ModelKind } from './base-BNHcMifc.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Access control types — workspace-override rules + app scope.
|
|
6
|
+
*
|
|
7
|
+
* v1 ships the evaluator + types; the DB-backed `model_access_rules`
|
|
8
|
+
* table follows in v2 (the MCP gen layer reads rows and threads them
|
|
9
|
+
* through `evaluateAccess` per workspace).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type AccessEffect = "allow" | "block";
|
|
13
|
+
type AccessTarget = {
|
|
14
|
+
kind: "model";
|
|
15
|
+
id: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "tag";
|
|
18
|
+
value: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "provider";
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `kind: "priceTier"` is the persisted DB discriminator string for
|
|
25
|
+
* catalog-price-tier targets (`low | mid | high | premium`). The
|
|
26
|
+
* conceptual name is `catalogPriceTier`; the literal stays `priceTier`
|
|
27
|
+
* to avoid breaking existing rows in `*_model_access_rules` tables.
|
|
28
|
+
*/
|
|
29
|
+
| {
|
|
30
|
+
kind: "priceTier";
|
|
31
|
+
value: "low" | "mid" | "high" | "premium";
|
|
32
|
+
} | {
|
|
33
|
+
kind: "kind";
|
|
34
|
+
value: ModelKind;
|
|
35
|
+
};
|
|
36
|
+
interface AccessRule {
|
|
37
|
+
effect: AccessEffect;
|
|
38
|
+
target: AccessTarget;
|
|
39
|
+
/** Audit reason; surfaced in decision.reason. */
|
|
40
|
+
reason?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Per-product opt-in: the app declares which kinds it surfaces. Lets
|
|
44
|
+
* one app hide LLMs, another hide video, etc. Empty `kinds` means the app
|
|
45
|
+
* does not constrain by kind (admin / catalog-browser scope).
|
|
46
|
+
*/
|
|
47
|
+
interface AppScope {
|
|
48
|
+
kinds: ModelKind[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Access evaluator — resolves whether a workspace can use a given model.
|
|
53
|
+
*
|
|
54
|
+
* Resolution order:
|
|
55
|
+
* 1. App scope — if the app opts out of the model's kind, deny.
|
|
56
|
+
* 2. Workspace explicit `model:<id>` rule — terminal allow or block.
|
|
57
|
+
* 3. Workspace tag / provider / priceTier / kind rules — most-specific
|
|
58
|
+
* band wins. Within a band, block wins. Specificity ladder:
|
|
59
|
+
* tag (4) > provider (3) > priceTier (2) > kind (1).
|
|
60
|
+
* Rationale: an explicit `allow tag:image:generate` should beat a
|
|
61
|
+
* blanket `block kind:llm`. The tag rule is the more specific
|
|
62
|
+
* intent and reflects the operator's allowlist.
|
|
63
|
+
* 4. Catalog defaults — `lifecycle=stable && agentVisible=true` → allow.
|
|
64
|
+
*
|
|
65
|
+
* BYOK relaxation: when `byokActive`, `priceTier=premium` blocks are
|
|
66
|
+
* bypassed (BYOK users pay providers directly). NSFW / compliance
|
|
67
|
+
* blocks NEVER bypass.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
interface AccessEvalInput {
|
|
71
|
+
model: ResolvedModel;
|
|
72
|
+
appScope?: AppScope;
|
|
73
|
+
/** Workspace overrides; v1 callers pass `[]`. */
|
|
74
|
+
rules?: AccessRule[];
|
|
75
|
+
byokActive?: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface AccessDecision {
|
|
78
|
+
allowed: boolean;
|
|
79
|
+
/** Stable token for logs/metrics. */
|
|
80
|
+
reason: string;
|
|
81
|
+
}
|
|
82
|
+
declare function evaluateAccess(input: AccessEvalInput): AccessDecision;
|
|
83
|
+
|
|
84
|
+
export { type AccessDecision as A, type AccessEffect as a, type AccessEvalInput as b, type AccessRule as c, type AccessTarget as d, type AppScope as e, evaluateAccess as f };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Model Catalog — single source of truth for all image models.
|
|
3
|
+
*
|
|
4
|
+
* Migrated from `packages/integration/image/src/models/catalog.ts`. The
|
|
5
|
+
* original location now re-exports from here so every existing consumer
|
|
6
|
+
* (replicate-serializers, prompt blocks, an app UI) keeps working.
|
|
7
|
+
*
|
|
8
|
+
* Adding a model = 1 entry here + 1 serializer in
|
|
9
|
+
* `packages/integration/image/src/providers/replicate/replicate-serializers.ts`.
|
|
10
|
+
* Consumers import derived arrays (`AGENT_GENERATIVE_MODEL_IDS`, etc.)
|
|
11
|
+
* instead of hardcoding model names.
|
|
12
|
+
*/
|
|
13
|
+
interface ImageModelDefinition {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
/** Replicate model ID (e.g. "google/nano-banana-pro") */
|
|
17
|
+
providerId: string;
|
|
18
|
+
provider: string;
|
|
19
|
+
capabilities: {
|
|
20
|
+
generate: boolean;
|
|
21
|
+
edit: boolean;
|
|
22
|
+
upscale?: boolean;
|
|
23
|
+
};
|
|
24
|
+
referenceImages: {
|
|
25
|
+
supported: boolean;
|
|
26
|
+
/** Replicate input field name for reference images */
|
|
27
|
+
fieldName: "image_input" | "input_images" | "input_image" | "none";
|
|
28
|
+
maxCount: number;
|
|
29
|
+
/** true for models that accept a single URI string (not array) */
|
|
30
|
+
singular: boolean;
|
|
31
|
+
};
|
|
32
|
+
aspectRatio: {
|
|
33
|
+
supported: string[];
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
36
|
+
/** Response shape: "string" = single URI, "array" = array of URIs */
|
|
37
|
+
output: "string" | "array";
|
|
38
|
+
pricing: {
|
|
39
|
+
/** @deprecated Use billingUnit + baseCost instead */
|
|
40
|
+
costPerImage: number;
|
|
41
|
+
/** @deprecated Derived from baseCost */
|
|
42
|
+
costTier: "low" | "medium" | "high";
|
|
43
|
+
/** Always "per_image" for image models */
|
|
44
|
+
billingUnit: "per_image";
|
|
45
|
+
/** Our production cost in USD per image */
|
|
46
|
+
baseCost: number;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Credits are derived at call time via
|
|
49
|
+
* `computeCenticredits({ baseCostUsd, category: "image" })`. Field kept
|
|
50
|
+
* optional for back-compat with existing entries; new entries
|
|
51
|
+
* should omit it. Use `overrideCreditCost` for strategic opt-outs.
|
|
52
|
+
*/
|
|
53
|
+
creditCost?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Bypass the markup formula and charge exactly this many credits
|
|
56
|
+
* per image. Use sparingly — most pricing should flow through the
|
|
57
|
+
* category markup so a global tune is one config change.
|
|
58
|
+
*/
|
|
59
|
+
overrideCreditCost?: number;
|
|
60
|
+
};
|
|
61
|
+
description: string;
|
|
62
|
+
/** When false, model exists but isn't exposed in agent prompts/zod enums */
|
|
63
|
+
agentVisible: boolean;
|
|
64
|
+
/** Trigger word that must be included in the prompt to activate the fine-tune (e.g. "TOK") */
|
|
65
|
+
triggerWord?: string;
|
|
66
|
+
}
|
|
67
|
+
declare const IMAGE_MODEL_CATALOG: Record<string, ImageModelDefinition>;
|
|
68
|
+
/** All model IDs */
|
|
69
|
+
declare const IMAGE_MODEL_IDS: [string, ...string[]];
|
|
70
|
+
/** Only models visible to agents (for zod enums + prompts) */
|
|
71
|
+
declare const AGENT_IMAGE_MODEL_IDS: [string, ...string[]];
|
|
72
|
+
/** Agent-visible models supporting generation */
|
|
73
|
+
declare const AGENT_GENERATIVE_MODEL_IDS: [string, ...string[]];
|
|
74
|
+
/** Agent-visible models supporting editing */
|
|
75
|
+
declare const AGENT_EDITABLE_MODEL_IDS: [string, ...string[]];
|
|
76
|
+
/** Generate a markdown table of agent-visible image models for prompt blocks */
|
|
77
|
+
declare function generateImageModelTable(): string;
|
|
78
|
+
|
|
79
|
+
export { AGENT_EDITABLE_MODEL_IDS, AGENT_GENERATIVE_MODEL_IDS, AGENT_IMAGE_MODEL_IDS, IMAGE_MODEL_CATALOG, IMAGE_MODEL_IDS, type ImageModelDefinition, generateImageModelTable };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { b as LLMPricing } from './catalog-aQHd559b.js';
|
|
2
|
+
import { ImageModelDefinition } from './image/index.js';
|
|
3
|
+
import { VideoModelDefinition } from './video/index.js';
|
|
4
|
+
import { AudioModelDefinition } from './audio/index.js';
|
|
5
|
+
import { CatalogVoice } from './schema/voice.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Cross-kind registry. Resolves a model id against every catalog (LLM,
|
|
9
|
+
* image, video, audio) and returns a discriminated `ResolvedModel`.
|
|
10
|
+
*
|
|
11
|
+
* v1 returns the legacy per-kind data shapes verbatim — image/video keep
|
|
12
|
+
* `*ModelDefinition`, LLM keeps `LLMPricing`, audio surfaces voices.
|
|
13
|
+
* Callers (cost dispatcher, access evaluator) match on `.kind` and dig
|
|
14
|
+
* into the per-kind payload as needed.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `audio` resolves to either an audio MODEL (priced TTS/STT) or a
|
|
19
|
+
* voice (downstream metadata). Most call sites care about the model
|
|
20
|
+
* (pricing, capabilities); a few (voice pickers) want the voice. They
|
|
21
|
+
* share the resolver but discriminate on the inner payload.
|
|
22
|
+
*/
|
|
23
|
+
type ResolvedModel = {
|
|
24
|
+
kind: "llm";
|
|
25
|
+
id: string;
|
|
26
|
+
canonicalId: string;
|
|
27
|
+
pricing: LLMPricing;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "image";
|
|
30
|
+
id: string;
|
|
31
|
+
def: ImageModelDefinition;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "video";
|
|
34
|
+
id: string;
|
|
35
|
+
def: VideoModelDefinition;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "audio";
|
|
38
|
+
id: string;
|
|
39
|
+
def: AudioModelDefinition;
|
|
40
|
+
} | {
|
|
41
|
+
kind: "voice";
|
|
42
|
+
id: string;
|
|
43
|
+
voice: CatalogVoice;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Every kind the registry can resolve. Broader than the catalog
|
|
47
|
+
* `ModelKind` (llm/image/video/audio) because voices are a first-class
|
|
48
|
+
* registry kind but not a priced model family. Derived from
|
|
49
|
+
* `ResolvedModel` so it can never drift.
|
|
50
|
+
*/
|
|
51
|
+
type CatalogKind = ResolvedModel["kind"];
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a model id across every catalog.
|
|
54
|
+
*
|
|
55
|
+
* Lookup order: image → video → audio → LLM (last because LLM has the
|
|
56
|
+
* partial-prefix fallback that can match other strings if probed first).
|
|
57
|
+
*
|
|
58
|
+
* Returns `undefined` for unknown ids — callers decide whether to throw
|
|
59
|
+
* or fall back. LLM uses fallback pricing inside its own dispatcher
|
|
60
|
+
* (preserves existing behavior at the orchestrator).
|
|
61
|
+
*/
|
|
62
|
+
declare function getModel(id: string): ResolvedModel | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Returns true iff the id is exposed to agents.
|
|
65
|
+
*
|
|
66
|
+
* - LLM: every entry in `LLM_PRICING_CATALOG` is considered visible
|
|
67
|
+
* (legacy convention; refine in v2 with per-entry `agentVisible`).
|
|
68
|
+
* - Image / Video: respects the `agentVisible` flag.
|
|
69
|
+
* - Audio voices: all voices are visible (catalog itself is curated).
|
|
70
|
+
*/
|
|
71
|
+
declare function isAgentVisible(id: string): boolean;
|
|
72
|
+
interface ListModelsFilter {
|
|
73
|
+
kind?: CatalogKind;
|
|
74
|
+
/** Single provider (back-compat). Folded into `providers` internally. */
|
|
75
|
+
provider?: string;
|
|
76
|
+
/** Provider OR-set — a model matches if its provider is any of these. */
|
|
77
|
+
providers?: string[];
|
|
78
|
+
/**
|
|
79
|
+
* Capability tags a model must carry (ALL of them). Capabilities are
|
|
80
|
+
* emitted as tags by enrichment — audio `tts`/`stt`/`s2s`, image
|
|
81
|
+
* `edit`/`upscale`, video `i2v`/`t2v` — so this filters on the same
|
|
82
|
+
* vocabulary `listModels({capabilities:["s2s"]})` would expect.
|
|
83
|
+
*/
|
|
84
|
+
capabilities?: string[];
|
|
85
|
+
/** Arbitrary tags a model must carry (ALL of them). */
|
|
86
|
+
tags?: string[];
|
|
87
|
+
agentVisibleOnly?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Cross-kind listing. Useful for catalog browsers and capability search.
|
|
91
|
+
* Returns `ResolvedModel[]` (discriminated by kind).
|
|
92
|
+
*
|
|
93
|
+
* Provider is an OR-set (`providers` ∪ the singular `provider`); capability
|
|
94
|
+
* and tag filters are AND-sets (a model must carry every listed value).
|
|
95
|
+
* Composed: `listModels({ kind:"audio", capabilities:["s2s"],
|
|
96
|
+
* providers:["gemini-live","openai-realtime"] })` → all s2s models from
|
|
97
|
+
* Gemini OR OpenAI.
|
|
98
|
+
*/
|
|
99
|
+
declare function listModels(filter?: ListModelsFilter): ResolvedModel[];
|
|
100
|
+
/**
|
|
101
|
+
* Provider-centric view — every model a provider offers across all kinds
|
|
102
|
+
* (llm / image / video / audio incl. tts/stt/s2s). This is the "provider
|
|
103
|
+
* catalog" (openai, google, anthropic, replicate, openrouter, …): a
|
|
104
|
+
* derived query over the kind-organized catalogs, NOT a parallel store.
|
|
105
|
+
*/
|
|
106
|
+
declare function getModelsByProvider(provider: string): ResolvedModel[];
|
|
107
|
+
/**
|
|
108
|
+
* Returns the platform a model's adapter is **statically pinned** to,
|
|
109
|
+
* if known. ONLY meaningful for image / video / audio — those adapters
|
|
110
|
+
* are constructed per-platform (Replicate adapter, MiniMax adapter…),
|
|
111
|
+
* so the model's `def.provider` IS the runtime connector.
|
|
112
|
+
*
|
|
113
|
+
* For LLM, returns `undefined` — the runtime connector is determined
|
|
114
|
+
* at call time by `pickLlmConnector(connectors, parseModelId(id).provider)`
|
|
115
|
+
* against the guild's installed connectors, NOT by the model id alone.
|
|
116
|
+
* The same `anthropic/claude-sonnet-4-5` can route through OpenRouter
|
|
117
|
+
* OR direct Anthropic depending on which connectors the guild has
|
|
118
|
+
* installed. Recording call sites MUST pass the actual `connectorUsed`
|
|
119
|
+
* they invoked; do not infer from id.
|
|
120
|
+
*
|
|
121
|
+
* Use case: image/video workflow steps fetch `model.def.provider`
|
|
122
|
+
* directly (no ambiguity). LLM call sites use the runtime resolver.
|
|
123
|
+
*/
|
|
124
|
+
declare function getStaticModelProvider(model: ResolvedModel): string | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Resolves an id to its canonical catalog key across kinds. For ids that
|
|
127
|
+
* have no alias, returns the id unchanged. Used by callers that want to
|
|
128
|
+
* normalize before persisting (e.g., `byok_usage` rows).
|
|
129
|
+
*/
|
|
130
|
+
declare function resolveAlias(id: string): string;
|
|
131
|
+
|
|
132
|
+
export { type CatalogKind as C, type ListModelsFilter as L, type ResolvedModel as R, getModelsByProvider as a, getStaticModelProvider as b, getModel as g, isAgentVisible as i, listModels as l, resolveAlias as r };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { A as AccessDecision } from './evaluate-DisH3H7u.js';
|
|
2
|
+
import { a as CatalogPriceTier, L as Lifecycle, M as ModelKind } from './base-BNHcMifc.js';
|
|
3
|
+
import { R as ResolvedModel } from './index-BICjPG8H.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Model enrichment — `catalogPriceTier` / `tags` / `lifecycle` / `actions`
|
|
7
|
+
* per model id.
|
|
8
|
+
*
|
|
9
|
+
* Bridge between the legacy data shape (`ImageModelDefinition`,
|
|
10
|
+
* `VideoModelDefinition`, `LLMPricing`) and the v2 access-rule
|
|
11
|
+
* primitives that target by tier, tag, and action. Without this, rules
|
|
12
|
+
* like `priceTier:premium` and `tag:nsfw` would never match anything.
|
|
13
|
+
*
|
|
14
|
+
* Two layers:
|
|
15
|
+
* 1. Explicit map for the curated set we know about (overrides win).
|
|
16
|
+
* 2. Heuristic inference for any model not in the explicit map
|
|
17
|
+
* (catalogPriceTier from creditCost / token rates; tags from kind +
|
|
18
|
+
* provider).
|
|
19
|
+
*
|
|
20
|
+
* Actions (`<kind>:<verb>` — e.g. `image:generate`, `llm:tool_use`) are
|
|
21
|
+
* computed from per-kind capability objects via `getActions` and merged
|
|
22
|
+
* into `tags` so existing tag-based access rules match action targets
|
|
23
|
+
* without any evaluator change. The reserved `<kind>:` prefix is enforced
|
|
24
|
+
* by `assertReservedPrefixDiscipline` at module load — free-form curation
|
|
25
|
+
* tags must NOT use it.
|
|
26
|
+
*
|
|
27
|
+
* Add an entry to `EXPLICIT_ENRICHMENT` when you want exact control;
|
|
28
|
+
* skip it when defaults are good enough.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface ModelEnrichment {
|
|
32
|
+
catalogPriceTier: CatalogPriceTier;
|
|
33
|
+
/** Curation tags + action tags (`<kind>:<verb>`) merged. */
|
|
34
|
+
tags: readonly string[];
|
|
35
|
+
lifecycle: Lifecycle;
|
|
36
|
+
/** Action tags only — convenience subset of `tags`. */
|
|
37
|
+
actions: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Display price gauge level (1..5) for a model — the **visual** "price
|
|
41
|
+
* mostly" indicator (Low / Medium / High / Max / Ultra) the pickers and the
|
|
42
|
+
* estimator render as a bar. Distinct from {@link inferCatalogPriceTier}:
|
|
43
|
+
* that one drives 4-value *access* rules (`priceTier:premium`) and must stay a
|
|
44
|
+
* `CatalogPriceTier`; this is cosmetic and free to span 5 bands. Both bucket
|
|
45
|
+
* the same provider USD cost, so they move together by construction.
|
|
46
|
+
*/
|
|
47
|
+
declare function priceTierForModel(model: ResolvedModel): number;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve enrichment for any model. Explicit map wins; heuristic fallback
|
|
50
|
+
* fills the rest. Action tags (`<kind>:<verb>`) are derived from the
|
|
51
|
+
* model's capability fields and merged into `tags`. Always returns a
|
|
52
|
+
* value (never undefined).
|
|
53
|
+
*/
|
|
54
|
+
declare function getEnrichment(model: ResolvedModel): ModelEnrichment;
|
|
55
|
+
declare function modelHasTag(model: ResolvedModel, tag: string): boolean;
|
|
56
|
+
declare function modelHasAction(model: ResolvedModel, action: string): boolean;
|
|
57
|
+
declare function modelMatchesCatalogPriceTier(model: ResolvedModel, tier: CatalogPriceTier): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Use `modelMatchesCatalogPriceTier`. Kept for back-compat
|
|
60
|
+
* with the v1 evaluator's switch case which still uses the
|
|
61
|
+
* `priceTier` discriminator string. The function itself routes to the
|
|
62
|
+
* canonical name.
|
|
63
|
+
*/
|
|
64
|
+
declare function modelMatchesPriceTier(model: ResolvedModel, tier: CatalogPriceTier): boolean;
|
|
65
|
+
declare function modelMatchesKind(model: ResolvedModel, kind: ModelKind): boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Picker subpath — wire shapes returned by the per-app
|
|
69
|
+
* `GET /models/available` route. Single source of truth shared by:
|
|
70
|
+
* - the server-side helper (an app-side model-access helper)
|
|
71
|
+
* - the per-app SDK clients (e.g. an app SDK client)
|
|
72
|
+
* - the cross-app picker hook (an app picker hook)
|
|
73
|
+
*
|
|
74
|
+
* Without this single source the hook + SDK previously drifted from
|
|
75
|
+
* the API contract and a fetcher in the app silently kept calling
|
|
76
|
+
* with a stale auth pattern after the cookie-auth migration.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
interface AvailableModelCapabilities {
|
|
80
|
+
generate?: boolean;
|
|
81
|
+
edit?: boolean;
|
|
82
|
+
upscale?: boolean;
|
|
83
|
+
textToVideo?: boolean;
|
|
84
|
+
imageToVideo?: boolean;
|
|
85
|
+
audio?: boolean;
|
|
86
|
+
subjectReference?: boolean;
|
|
87
|
+
tts?: boolean;
|
|
88
|
+
stt?: boolean;
|
|
89
|
+
s2s?: boolean;
|
|
90
|
+
}
|
|
91
|
+
interface AvailableModel {
|
|
92
|
+
id: string;
|
|
93
|
+
/** Canonical model id (LLM aliases collapse here). */
|
|
94
|
+
canonicalId: string;
|
|
95
|
+
/**
|
|
96
|
+
* Priced model kind. Typed `ModelKind` (not `CatalogKind`) on purpose: the
|
|
97
|
+
* picker never surfaces `voice` rows as `AvailableModel` — voices reach the
|
|
98
|
+
* UI through a separate path — so `voice` is intentionally out of range here.
|
|
99
|
+
*/
|
|
100
|
+
kind: ModelKind;
|
|
101
|
+
displayName: string;
|
|
102
|
+
description: string;
|
|
103
|
+
enrichment: ModelEnrichment;
|
|
104
|
+
decision: AccessDecision;
|
|
105
|
+
capabilities: AvailableModelCapabilities;
|
|
106
|
+
/** Recommended pricing display (per provider unit). */
|
|
107
|
+
pricingHint?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Audio models only: cost normalized to **per minute of speech**, the
|
|
110
|
+
* intuitive unit for the voice picker. TTS (billed per 1k chars) is
|
|
111
|
+
* converted via an assumed speaking rate; per-minute models pass through.
|
|
112
|
+
*/
|
|
113
|
+
voiceHint?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Relative price gauge level (1..{@link PRICE_TIER_SLOTS}) from
|
|
116
|
+
* `priceTierForModel` — the visual "price mostly" indicator the picker
|
|
117
|
+
* renders as a segmented bar instead of a raw number. 0 when unknown.
|
|
118
|
+
*/
|
|
119
|
+
priceTier?: number;
|
|
120
|
+
/** Localized-agnostic tier name for `priceTier` (e.g. `"High"`). */
|
|
121
|
+
priceTierName?: string;
|
|
122
|
+
}
|
|
123
|
+
interface AvailableConnector {
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
/** Whether the actor's guild/workspace has a connected credential for this provider. */
|
|
127
|
+
byokAvailable: boolean;
|
|
128
|
+
models: AvailableModel[];
|
|
129
|
+
}
|
|
130
|
+
/** Number of segments in the price gauge. */
|
|
131
|
+
declare const PRICE_TIER_SLOTS = 5;
|
|
132
|
+
/**
|
|
133
|
+
* Display names for levels 1..{@link PRICE_TIER_SLOTS}, ascending price. Kept
|
|
134
|
+
* as brand tokens (not localized) so the gauge reads the same everywhere.
|
|
135
|
+
*/
|
|
136
|
+
declare const PRICE_TIER_NAMES: readonly ["Low", "Medium", "High", "Max", "Ultra"];
|
|
137
|
+
/** Name for a gauge level (1-based); empty string when out of range. */
|
|
138
|
+
declare function priceTierName(level: number): string;
|
|
139
|
+
/**
|
|
140
|
+
* Unicode price gauge (e.g. `▰▰▱▱▱`) for text-only surfaces (WhatsApp, logs).
|
|
141
|
+
* Rich UIs read {@link AvailableModel.priceTier} and render styled segments.
|
|
142
|
+
*/
|
|
143
|
+
declare function priceTierBar(level: number, slots?: number): string;
|
|
144
|
+
interface AvailableModelsActor {
|
|
145
|
+
appId: string;
|
|
146
|
+
userId: string;
|
|
147
|
+
tier?: string;
|
|
148
|
+
guildId?: string;
|
|
149
|
+
}
|
|
150
|
+
interface AvailableModelsResponse {
|
|
151
|
+
success: true;
|
|
152
|
+
actor: AvailableModelsActor;
|
|
153
|
+
connectors: AvailableConnector[];
|
|
154
|
+
}
|
|
155
|
+
interface ListAvailableModelsParams {
|
|
156
|
+
/** Restrict to one or more kinds. Empty = all kinds. */
|
|
157
|
+
kind?: ModelKind | ModelKind[];
|
|
158
|
+
/** Guild scope — joins guild-level connectors for BYOK badges. */
|
|
159
|
+
guildId?: string;
|
|
160
|
+
/** Include rules-blocked models (decision.allowed=false). Default true. */
|
|
161
|
+
includeBlocked?: boolean;
|
|
162
|
+
/** Include catalog entries with agentVisible=false. Default false. */
|
|
163
|
+
includeHidden?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Curation surface-profile id (`voice-s2s`, `images`, …) the app exposes.
|
|
166
|
+
* Resolved server-side via `getSurfaceProfile`. Omitted = full catalog.
|
|
167
|
+
*/
|
|
168
|
+
surface?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { type AvailableConnector as A, type ListAvailableModelsParams as L, type ModelEnrichment as M, PRICE_TIER_NAMES as P, type AvailableModel as a, type AvailableModelCapabilities as b, type AvailableModelsActor as c, type AvailableModelsResponse as d, modelHasTag as e, modelMatchesCatalogPriceTier as f, getEnrichment as g, modelMatchesKind as h, modelMatchesPriceTier as i, PRICE_TIER_SLOTS as j, priceTierBar as k, priceTierName as l, modelHasAction as m, priceTierForModel as p };
|