@x12i/ai-profiles 1.7.2 → 2.0.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 (71) hide show
  1. package/README.md +41 -5
  2. package/dist/buildResolvedProfile.d.ts.map +1 -1
  3. package/dist/buildResolvedProfile.js +2 -0
  4. package/dist/buildResolvedProfile.js.map +1 -1
  5. package/dist/constants.d.ts +2 -3
  6. package/dist/constants.d.ts.map +1 -1
  7. package/dist/constants.js +2 -7
  8. package/dist/constants.js.map +1 -1
  9. package/dist/data/models-catalog.json +3 -3
  10. package/dist/data/models-profiles.json +514 -133
  11. package/dist/data/models-profiles.schema.json +58 -4
  12. package/dist/data/models-registry.json +71 -41
  13. package/dist/data/profiles-shortcuts.json +48 -42
  14. package/dist/errors.d.ts +1 -1
  15. package/dist/errors.d.ts.map +1 -1
  16. package/dist/errors.js.map +1 -1
  17. package/dist/index.d.ts +10 -3
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +7 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/listAIProfiles.d.ts.map +1 -1
  22. package/dist/listAIProfiles.js +34 -4
  23. package/dist/listAIProfiles.js.map +1 -1
  24. package/dist/logger.d.ts +2 -0
  25. package/dist/logger.d.ts.map +1 -0
  26. package/dist/logger.js +7 -0
  27. package/dist/logger.js.map +1 -0
  28. package/dist/modelInputFallback.d.ts +20 -0
  29. package/dist/modelInputFallback.d.ts.map +1 -0
  30. package/dist/modelInputFallback.js +265 -0
  31. package/dist/modelInputFallback.js.map +1 -0
  32. package/dist/profileCatalogLane.d.ts +22 -0
  33. package/dist/profileCatalogLane.d.ts.map +1 -0
  34. package/dist/profileCatalogLane.js +83 -0
  35. package/dist/profileCatalogLane.js.map +1 -0
  36. package/dist/profileDiscovery.d.ts +43 -0
  37. package/dist/profileDiscovery.d.ts.map +1 -0
  38. package/dist/profileDiscovery.js +129 -0
  39. package/dist/profileDiscovery.js.map +1 -0
  40. package/dist/profileModelFallback.d.ts +13 -0
  41. package/dist/profileModelFallback.d.ts.map +1 -0
  42. package/dist/profileModelFallback.js +180 -0
  43. package/dist/profileModelFallback.js.map +1 -0
  44. package/dist/profileRegistryV3.d.ts.map +1 -1
  45. package/dist/profileRegistryV3.js +6 -4
  46. package/dist/profileRegistryV3.js.map +1 -1
  47. package/dist/resolveAIProfile.d.ts +1 -1
  48. package/dist/resolveAIProfile.d.ts.map +1 -1
  49. package/dist/resolveAIProfile.js +66 -1
  50. package/dist/resolveAIProfile.js.map +1 -1
  51. package/dist/resolveAIProfileByTags.d.ts +11 -0
  52. package/dist/resolveAIProfileByTags.d.ts.map +1 -0
  53. package/dist/resolveAIProfileByTags.js +33 -0
  54. package/dist/resolveAIProfileByTags.js.map +1 -0
  55. package/dist/resolveModelIdentity.d.ts.map +1 -1
  56. package/dist/resolveModelIdentity.js +16 -0
  57. package/dist/resolveModelIdentity.js.map +1 -1
  58. package/dist/types.d.ts +35 -1
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/validateProfileCatalogLinkage.d.ts.map +1 -1
  61. package/dist/validateProfileCatalogLinkage.js +1 -0
  62. package/dist/validateProfileCatalogLinkage.js.map +1 -1
  63. package/dist/validation/profileIntentPolicy.d.ts +8 -0
  64. package/dist/validation/profileIntentPolicy.d.ts.map +1 -0
  65. package/dist/validation/profileIntentPolicy.js +60 -0
  66. package/dist/validation/profileIntentPolicy.js.map +1 -0
  67. package/dist/validation/validateModelsProfilesJson.d.ts +1 -0
  68. package/dist/validation/validateModelsProfilesJson.d.ts.map +1 -1
  69. package/dist/validation/validateModelsProfilesJson.js +65 -15
  70. package/dist/validation/validateModelsProfilesJson.js.map +1 -1
  71. package/package.json +3 -5
package/dist/logger.js ADDED
@@ -0,0 +1,7 @@
1
+ import { createLogxer } from "@x12i/logxer";
2
+ export const logxer = createLogxer({
3
+ packageName: "@x12i/ai-profiles",
4
+ envPrefix: "AI_PROFILES",
5
+ debugNamespace: "ai-profiles",
6
+ });
7
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;IACjC,WAAW,EAAE,mBAAmB;IAChC,SAAS,EAAE,aAAa;IACxB,cAAc,EAAE,aAAa;CAC9B,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { AIProfileWarning, CatalogModelEntry, ModelInvocation, ModelsCatalogJson, ResolvedAIProfile, AIProfilesRegistry } from "./types.js";
2
+ export type ModelInputMatchConfidence = "exact" | "high" | "low";
3
+ export interface ModelInputFallbackMatch {
4
+ entry?: CatalogModelEntry;
5
+ invocation: ModelInvocation;
6
+ confidence: ModelInputMatchConfidence;
7
+ score: number;
8
+ matchedBy: string;
9
+ warning?: string;
10
+ }
11
+ export declare function resolveModelFromInput(input: string, catalog: ModelsCatalogJson): ModelInputFallbackMatch | undefined;
12
+ export declare function modelInputLogMeta(input: string, match: ModelInputFallbackMatch): Record<string, unknown>;
13
+ export declare function buildResolvedModelInput(params: {
14
+ input: string;
15
+ match: ModelInputFallbackMatch;
16
+ registry: AIProfilesRegistry;
17
+ loaderWarnings?: AIProfileWarning[];
18
+ useOpenRouter?: boolean;
19
+ }): ResolvedAIProfile;
20
+ //# sourceMappingURL=modelInputFallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelInputFallback.d.ts","sourceRoot":"","sources":["../src/modelInputFallback.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjE,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,yBAAyB,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAwLD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,iBAAiB,GACzB,uBAAuB,GAAG,SAAS,CAiDrC;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,uBAAuB,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAczB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,uBAAuB,CAAC;IAC/B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,cAAc,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,iBAAiB,CAuEpB"}
@@ -0,0 +1,265 @@
1
+ import { DebugLogAbstract } from "@x12i/logxer";
2
+ import { capabilitiesFromCatalogEntry, limitsFromCatalogEntry, pricingFromCatalogEntry, } from "./catalogEnrichment.js";
3
+ import { DEFAULT_CACHE_TTL_MS, DEFAULT_RUNTIME_DEFAULTS } from "./constants.js";
4
+ import { getMemoryCache } from "./loader/memoryCache.js";
5
+ import { buildModelInvocation } from "./modelIdentity.js";
6
+ import { normalizeKey } from "./normalizeKey.js";
7
+ import { inferCatalogLaneFromEntry } from "./profileCatalogLane.js";
8
+ import { normalizeModalityContract } from "./modalityPolicy.js";
9
+ import { resolveUseOpenRouter } from "./resolveModelRouting.js";
10
+ const HIGH_CONFIDENCE_SCORE = 0.72;
11
+ const AMBIGUOUS_SCORE_GAP = 0.12;
12
+ function canonicalIdentifier(value) {
13
+ return normalizeKey(value).replace(/^x-ai\//, "xai/");
14
+ }
15
+ function compactIdentifier(value) {
16
+ return canonicalIdentifier(value).replace(/[^a-z0-9]/g, "");
17
+ }
18
+ function tokenize(value) {
19
+ return canonicalIdentifier(value)
20
+ .split(/[^a-z0-9]+/g)
21
+ .filter(Boolean);
22
+ }
23
+ function uniqueValues(values) {
24
+ return [...new Set(values.filter((value) => Boolean(value)))];
25
+ }
26
+ function entryIdentities(entry) {
27
+ return uniqueValues([
28
+ entry.direct.modelId,
29
+ `${entry.direct.provider}/${entry.direct.modelId}`,
30
+ entry.openrouter.modelId,
31
+ entry.openrouter.canonicalSlug,
32
+ entry.displayName,
33
+ ]);
34
+ }
35
+ function buildCatalogCandidates(catalog) {
36
+ return catalog.models.map((entry) => ({
37
+ entry,
38
+ identities: entryIdentities(entry),
39
+ }));
40
+ }
41
+ function invocationFromCatalogEntry(entry) {
42
+ return {
43
+ direct: {
44
+ provider: entry.direct.provider,
45
+ modelId: entry.direct.modelId,
46
+ },
47
+ openrouter: {
48
+ provider: entry.openrouter.provider,
49
+ modelId: entry.openrouter.modelId,
50
+ },
51
+ };
52
+ }
53
+ function modelLikeFallbackInvocation(input) {
54
+ if (!input.includes("/")) {
55
+ return undefined;
56
+ }
57
+ const slash = input.indexOf("/");
58
+ const providerHint = input.slice(0, slash).trim();
59
+ const modelId = input.slice(slash + 1).trim();
60
+ if (!providerHint || !modelId) {
61
+ return undefined;
62
+ }
63
+ return buildModelInvocation(providerHint, input);
64
+ }
65
+ function findExactCatalogCandidate(candidates, input) {
66
+ const normalizedInput = canonicalIdentifier(input);
67
+ const compactInput = compactIdentifier(input);
68
+ for (const candidate of candidates) {
69
+ for (const identity of candidate.identities) {
70
+ if (canonicalIdentifier(identity) === normalizedInput ||
71
+ compactIdentifier(identity) === compactInput) {
72
+ return {
73
+ entry: candidate.entry,
74
+ invocation: invocationFromCatalogEntry(candidate.entry),
75
+ confidence: "exact",
76
+ score: 1,
77
+ matchedBy: identity,
78
+ };
79
+ }
80
+ }
81
+ }
82
+ return undefined;
83
+ }
84
+ function slashSearchParts(input) {
85
+ const parts = input
86
+ .split("/")
87
+ .map((part) => part.trim())
88
+ .filter(Boolean);
89
+ return uniqueValues([input, ...parts]).sort((a, b) => b.length - a.length);
90
+ }
91
+ function scoreIdentity(input, identity) {
92
+ const inputCompact = compactIdentifier(input);
93
+ const identityCompact = compactIdentifier(identity);
94
+ if (!inputCompact || !identityCompact) {
95
+ return { score: 0, matchedBy: identity };
96
+ }
97
+ if (inputCompact === identityCompact) {
98
+ return { score: 1, matchedBy: identity };
99
+ }
100
+ let substringScore = 0;
101
+ if (inputCompact.includes(identityCompact)) {
102
+ substringScore = Math.min(0.9, identityCompact.length / inputCompact.length);
103
+ }
104
+ else if (identityCompact.includes(inputCompact)) {
105
+ substringScore = Math.min(0.82, inputCompact.length / identityCompact.length);
106
+ }
107
+ const inputTokens = new Set(tokenize(input));
108
+ const identityTokens = new Set(tokenize(identity));
109
+ const sharedTokens = [...inputTokens].filter((token) => identityTokens.has(token));
110
+ const inputCoverage = inputTokens.size > 0 ? sharedTokens.length / inputTokens.size : 0;
111
+ const identityCoverage = identityTokens.size > 0 ? sharedTokens.length / identityTokens.size : 0;
112
+ const tokenScore = inputCoverage * 0.55 + identityCoverage * 0.35;
113
+ return {
114
+ score: Math.max(substringScore, tokenScore),
115
+ matchedBy: identity,
116
+ };
117
+ }
118
+ function scoreCatalogCandidate(input, candidate) {
119
+ const parts = slashSearchParts(input);
120
+ let best = {
121
+ score: 0,
122
+ matchedBy: candidate.identities[0] ?? candidate.entry.direct.modelId,
123
+ };
124
+ for (const part of parts) {
125
+ for (const identity of candidate.identities) {
126
+ const scored = scoreIdentity(part, identity);
127
+ if (scored.score > best.score) {
128
+ best = scored;
129
+ }
130
+ }
131
+ }
132
+ const providerHint = input.includes("/") ? canonicalIdentifier(input.split("/")[0]) : "";
133
+ const providerBonus = providerHint && providerHint === canonicalIdentifier(candidate.entry.direct.provider)
134
+ ? 0.12
135
+ : 0;
136
+ return {
137
+ ...candidate,
138
+ score: Math.min(1, best.score + providerBonus),
139
+ matchedBy: best.matchedBy,
140
+ };
141
+ }
142
+ function isModelLikeInput(input) {
143
+ return input.includes("/");
144
+ }
145
+ export function resolveModelFromInput(input, catalog) {
146
+ const candidates = buildCatalogCandidates(catalog);
147
+ const exact = findExactCatalogCandidate(candidates, input);
148
+ if (exact) {
149
+ return exact;
150
+ }
151
+ if (!isModelLikeInput(input)) {
152
+ return undefined;
153
+ }
154
+ const [best, runnerUp] = candidates
155
+ .map((candidate) => scoreCatalogCandidate(input, candidate))
156
+ .sort((a, b) => b.score - a.score);
157
+ if (!best) {
158
+ const invocation = modelLikeFallbackInvocation(input);
159
+ return invocation
160
+ ? {
161
+ invocation,
162
+ confidence: "low",
163
+ score: 0,
164
+ matchedBy: input,
165
+ warning: `Model-like input '${input}' did not match the models catalog; returning parsed model identity as a low-confidence fallback.`,
166
+ }
167
+ : undefined;
168
+ }
169
+ const ambiguous = runnerUp !== undefined &&
170
+ canonicalIdentifier(runnerUp.entry.openrouter.modelId) !==
171
+ canonicalIdentifier(best.entry.openrouter.modelId) &&
172
+ best.score - runnerUp.score < AMBIGUOUS_SCORE_GAP;
173
+ const confidence = best.score >= HIGH_CONFIDENCE_SCORE && !ambiguous ? "high" : "low";
174
+ const warning = confidence === "low"
175
+ ? `Model-like input '${input}' did not match the models catalog exactly; using best-effort catalog model '${best.entry.openrouter.modelId}' from '${best.matchedBy}'.`
176
+ : undefined;
177
+ return {
178
+ entry: best.entry,
179
+ invocation: invocationFromCatalogEntry(best.entry),
180
+ confidence,
181
+ score: Number(best.score.toFixed(3)),
182
+ matchedBy: best.matchedBy,
183
+ ...(warning ? { warning } : {}),
184
+ };
185
+ }
186
+ export function modelInputLogMeta(input, match) {
187
+ return {
188
+ debugKind: match.confidence === "low"
189
+ ? DebugLogAbstract.ANOMALY
190
+ : DebugLogAbstract.EVENT,
191
+ input,
192
+ provider: match.invocation.direct.provider,
193
+ modelId: match.invocation.direct.modelId,
194
+ openRouterModelId: match.invocation.openrouter?.modelId,
195
+ confidence: match.confidence,
196
+ score: match.score,
197
+ matchedBy: match.matchedBy,
198
+ };
199
+ }
200
+ export function buildResolvedModelInput(params) {
201
+ const { input, match, registry, loaderWarnings = [] } = params;
202
+ const cache = getMemoryCache();
203
+ const cacheLoadedAt = cache?.loadedAt ?? Date.parse(registry.loadedAt);
204
+ const expiresAt = new Date((cache?.expiresAt ?? cacheLoadedAt + DEFAULT_CACHE_TTL_MS)).toISOString();
205
+ const useOpenRouter = resolveUseOpenRouter(params.useOpenRouter);
206
+ const endpoint = useOpenRouter && match.invocation.openrouter
207
+ ? match.invocation.openrouter
208
+ : match.invocation.direct;
209
+ const routing = endpoint.provider === "openrouter" ? "openrouter" : "direct";
210
+ const catalogEntry = match.entry;
211
+ const rawModalities = catalogEntry?.modalities ?? catalogEntry?.openrouter.modalities ?? undefined;
212
+ const modalities = normalizeModalityContract(rawModalities);
213
+ const pricingBase = catalogEntry ? pricingFromCatalogEntry(catalogEntry) : undefined;
214
+ const pricing = pricingBase
215
+ ? {
216
+ ...pricingBase,
217
+ currency: registry.currency,
218
+ unit: registry.pricingUnit,
219
+ }
220
+ : undefined;
221
+ const warnings = [...loaderWarnings];
222
+ if (match.warning) {
223
+ warnings.push({
224
+ code: "MODEL_INPUT_FALLBACK_GUESS",
225
+ message: match.warning,
226
+ });
227
+ }
228
+ return {
229
+ input,
230
+ resolutionKind: "model",
231
+ profile: "model",
232
+ profileDisplayName: "Direct Model",
233
+ profileDescription: "Direct model input resolved from the models catalog.",
234
+ category: "model",
235
+ catalogLane: catalogEntry
236
+ ? inferCatalogLaneFromEntry(catalogEntry)
237
+ : "text",
238
+ choice: catalogEntry?.openrouter.modelId ?? input,
239
+ choiceDisplayName: catalogEntry?.displayName ??
240
+ `${match.invocation.direct.provider}/${match.invocation.direct.modelId}`,
241
+ choiceDescription: "Direct model input resolved without mapping to an AI profile.",
242
+ provider: endpoint.provider,
243
+ modelId: endpoint.modelId,
244
+ routing,
245
+ instructionTier: DEFAULT_RUNTIME_DEFAULTS.instructionTier,
246
+ backend: routing === "openrouter" ? "openrouter" : "custom",
247
+ pricing,
248
+ ...(catalogEntry?.status === "active" ? { modelStatus: "verified" } : {}),
249
+ ...(catalogEntry ? { limits: limitsFromCatalogEntry(catalogEntry) } : {}),
250
+ ...(catalogEntry ? { capabilities: capabilitiesFromCatalogEntry(catalogEntry) } : {}),
251
+ modalities,
252
+ requiredModalities: modalities,
253
+ runtime: {
254
+ ...DEFAULT_RUNTIME_DEFAULTS,
255
+ backend: routing === "openrouter" ? "openrouter" : "custom",
256
+ },
257
+ source: registry.source,
258
+ ...(registry.version !== undefined ? { registryVersion: registry.version } : {}),
259
+ loadedAt: registry.loadedAt,
260
+ expiresAt,
261
+ invocation: match.invocation,
262
+ ...(warnings.length > 0 ? { warnings } : {}),
263
+ };
264
+ }
265
+ //# sourceMappingURL=modelInputFallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelInputFallback.js","sourceRoot":"","sources":["../src/modelInputFallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAgChE,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,mBAAmB,GAAG,IA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QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,SAAS;QACT,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { AIProfileChoice, AIProfileDefinition, CatalogModelEntry, ModelsCatalogJson, ProfileCatalogLane } from "./types.js";
2
+ /** OpenRouter model-browser lanes (Text, Image, Embeddings, …). */
3
+ export declare const PROFILE_CATALOG_LANES: readonly ProfileCatalogLane[];
4
+ /**
5
+ * Infer OpenRouter catalog lane from architecture modalities (best-effort).
6
+ */
7
+ export declare function inferCatalogLaneFromEntry(entry: CatalogModelEntry): ProfileCatalogLane;
8
+ export declare function profileCatalogLane(profile: AIProfileDefinition): ProfileCatalogLane;
9
+ export declare function profileMatchesCatalogLane(profile: AIProfileDefinition, lane: ProfileCatalogLane): boolean;
10
+ export declare function choiceHasOpenRouterCatalog(choice: AIProfileChoice, catalog: ModelsCatalogJson): boolean;
11
+ export declare function assertOpenRouterCatalogCoverage(params: {
12
+ profileKey: string;
13
+ choiceKey: string;
14
+ choice: AIProfileChoice;
15
+ catalog: ModelsCatalogJson;
16
+ }): CatalogModelEntry;
17
+ export declare function assertProfileCatalogLane(params: {
18
+ profileKey: string;
19
+ profile: AIProfileDefinition;
20
+ requestedLane: ProfileCatalogLane;
21
+ }): void;
22
+ //# sourceMappingURL=profileCatalogLane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileCatalogLane.d.ts","sourceRoot":"","sources":["../src/profileCatalogLane.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EASrD,CAAC;AAEX;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,iBAAiB,GACvB,kBAAkB,CA4BpB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CAEpB;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAET;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAOT;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,iBAAiB,CAAC;CAC5B,GAAG,iBAAiB,CA4BpB;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,aAAa,EAAE,kBAAkB,CAAC;CACnC,GAAG,IAAI,CAOP"}
@@ -0,0 +1,83 @@
1
+ import { findCatalogModelEntry } from "./catalogEnrichment.js";
2
+ import { isCpuLocalChoice } from "./validateProfileTransportPolicy.js";
3
+ import { isOpenRouterModelAvailable } from "./modelIdentity.js";
4
+ import { buildModelsCatalogIndex } from "./modelsCatalog.js";
5
+ /** OpenRouter model-browser lanes (Text, Image, Embeddings, …). */
6
+ export const PROFILE_CATALOG_LANES = [
7
+ "text",
8
+ "image",
9
+ "embeddings",
10
+ "audio",
11
+ "video",
12
+ "rerank",
13
+ "speech",
14
+ "transcription",
15
+ ];
16
+ /**
17
+ * Infer OpenRouter catalog lane from architecture modalities (best-effort).
18
+ */
19
+ export function inferCatalogLaneFromEntry(entry) {
20
+ const output = entry.openrouter.modalities?.output ?? entry.modalities?.output ?? [];
21
+ const input = entry.openrouter.modalities?.input ?? entry.modalities?.input ?? [];
22
+ const combined = [...output, ...input].map((m) => m.toLowerCase());
23
+ if (combined.some((m) => m.includes("embed"))) {
24
+ return "embeddings";
25
+ }
26
+ if (output.some((m) => m.includes("transcri"))) {
27
+ return "transcription";
28
+ }
29
+ if (output.some((m) => m.includes("speech") || m.includes("audio"))) {
30
+ return "speech";
31
+ }
32
+ if (combined.some((m) => m.includes("rerank"))) {
33
+ return "rerank";
34
+ }
35
+ if (combined.some((m) => m.includes("video"))) {
36
+ return "video";
37
+ }
38
+ if (combined.some((m) => m.includes("audio"))) {
39
+ return "audio";
40
+ }
41
+ if (input.some((m) => m.includes("image")) || output.some((m) => m.includes("image"))) {
42
+ return "image";
43
+ }
44
+ return "text";
45
+ }
46
+ export function profileCatalogLane(profile) {
47
+ return profile.catalogLane;
48
+ }
49
+ export function profileMatchesCatalogLane(profile, lane) {
50
+ return profileCatalogLane(profile) === lane;
51
+ }
52
+ export function choiceHasOpenRouterCatalog(choice, catalog) {
53
+ if (isCpuLocalChoice(choice)) {
54
+ return false;
55
+ }
56
+ const index = buildModelsCatalogIndex(catalog);
57
+ return isOpenRouterModelAvailable(choice.provider, choice.modelId, index);
58
+ }
59
+ export function assertOpenRouterCatalogCoverage(params) {
60
+ const { profileKey, choiceKey, choice, catalog } = params;
61
+ if (isCpuLocalChoice(choice)) {
62
+ throw new Error(`Profile '${profileKey}' choice '${choiceKey}' is CPU-local and has no OpenRouter catalog entry`);
63
+ }
64
+ const entry = findCatalogModelEntry(catalog, {
65
+ provider: choice.provider,
66
+ modelId: choice.modelId,
67
+ });
68
+ if (!entry) {
69
+ throw new Error(`No OpenRouter catalog entry for ${choice.provider}/${choice.modelId}`);
70
+ }
71
+ const status = entry.openrouter.status ?? entry.status;
72
+ if (status && status !== "active") {
73
+ throw new Error(`OpenRouter catalog entry ${entry.openrouter.modelId} is not active (status: ${status})`);
74
+ }
75
+ return entry;
76
+ }
77
+ export function assertProfileCatalogLane(params) {
78
+ const lane = profileCatalogLane(params.profile);
79
+ if (lane !== params.requestedLane) {
80
+ throw new Error(`Profile '${params.profileKey}' is a '${lane}' lane profile, not '${params.requestedLane}'`);
81
+ }
82
+ }
83
+ //# sourceMappingURL=profileCatalogLane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileCatalogLane.js","sourceRoot":"","sources":["../src/profileCatalogLane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAS7D,mEAAmE;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAkC;IAClE,MAAM;IACN,OAAO;IACP,YAAY;IACZ,OAAO;IACP,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,eAAe;CACP,CAAC;AAEX;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAwB;IAExB,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,IAAI,EAAE,CAAC;IACrF,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,IAAI,KAAK,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC;IAClF,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAEnE,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAC9C,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,MAAM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;AAED,MAAM,UAAU,wBAAwB,CAAC,MAIxC;IACC,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,IAAI,KAAK,MAAM,CAAC,aAAa,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,YAAY,MAAM,CAAC,UAAU,WAAW,IAAI,wBAAwB,MAAM,CAAC,aAAa,GAAG,CAC5F,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { AIProfileDefinition, AIProfileTag, ProfileTagMatchMode } from "./types.js";
2
+ export type { ProfileTagMatchMode };
3
+ export interface ProfileTagScore {
4
+ profileKey: string;
5
+ profile: AIProfileDefinition;
6
+ score: number;
7
+ matchedTags: AIProfileTag[];
8
+ }
9
+ /**
10
+ * Count of requested tags present on the profile (partial match OK).
11
+ */
12
+ export declare function scoreProfileTags(profile: AIProfileDefinition, tags: AIProfileTag[]): {
13
+ score: number;
14
+ matchedTags: AIProfileTag[];
15
+ };
16
+ /**
17
+ * Rank profiles by tag overlap (highest score first).
18
+ * Tie-break: fewer total profile tags (more specific), then profile key lexicographically.
19
+ */
20
+ export declare function rankProfilesByTags(profiles: Record<string, AIProfileDefinition>, tags: AIProfileTag[]): ProfileTagScore[];
21
+ /**
22
+ * Best profile for a tag set, or undefined when no tag matches.
23
+ */
24
+ export declare function pickBestProfileByTags(profiles: Record<string, AIProfileDefinition>, tags: AIProfileTag[]): ProfileTagScore | undefined;
25
+ /**
26
+ * Returns true when the profile matches all requested tags (mode `all`)
27
+ * or at least one (mode `any`, default).
28
+ */
29
+ export declare function profileMatchesTags(profile: AIProfileDefinition, tags: AIProfileTag[], mode?: ProfileTagMatchMode): boolean;
30
+ /**
31
+ * Free-text discovery across profile metadata, aliases, tags, and choice labels.
32
+ */
33
+ export declare function profileMatchesSearch(profile: AIProfileDefinition, search: string): boolean;
34
+ export declare function profileMatchesDiscovery(profile: AIProfileDefinition, options: {
35
+ tags?: AIProfileTag[];
36
+ tagMatch?: ProfileTagMatchMode;
37
+ search?: string;
38
+ }): boolean;
39
+ /** Collect every tag used across profiles (sorted). */
40
+ export declare function collectProfileTags(profiles: Record<string, AIProfileDefinition>): AIProfileTag[];
41
+ /** Stable signature for a profile tag set (sorted, comma-joined). */
42
+ export declare function profileTagSetSignature(tags: AIProfileTag[]): string;
43
+ //# sourceMappingURL=profileDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileDiscovery.d.ts","sourceRoot":"","sources":["../src/profileDiscovery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,YAAY,EAAE,CAAC;CAC7B;AAgCD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,YAAY,EAAE,GACnB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,YAAY,EAAE,CAAA;CAAE,CAQhD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC7C,IAAI,EAAE,YAAY,EAAE,GACnB,eAAe,EAAE,CAuBnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC7C,IAAI,EAAE,YAAY,EAAE,GACnB,eAAe,GAAG,SAAS,CAE7B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,YAAY,EAAE,EACpB,IAAI,GAAE,mBAA2B,GAChC,OAAO,CAWT;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,MAAM,GACb,OAAO,CAqBT;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE;IACP,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAUT;AAED,uDAAuD;AACvD,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAC5C,YAAY,EAAE,CAQhB;AAED,qEAAqE;AACrE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,CAEnE"}
@@ -0,0 +1,129 @@
1
+ import { normalizeKey } from "./normalizeKey.js";
2
+ function tokenizeSearch(value) {
3
+ return normalizeKey(value)
4
+ .split(/[^a-z0-9]+/g)
5
+ .filter((token) => token.length > 0);
6
+ }
7
+ function profileSearchHaystack(profile) {
8
+ const choiceText = Object.values(profile.choices).flatMap((choice) => [
9
+ choice.choice,
10
+ choice.displayName,
11
+ choice.description,
12
+ choice.provider,
13
+ choice.modelId,
14
+ choice.reason ?? "",
15
+ ]);
16
+ return [
17
+ profile.profile,
18
+ profile.displayName,
19
+ profile.description,
20
+ profile.category,
21
+ ...(profile.aliases ?? []),
22
+ ...(profile.tags ?? []),
23
+ ...(profile.intendedUseCases ?? []),
24
+ ...choiceText,
25
+ ]
26
+ .map(normalizeKey)
27
+ .join(" ");
28
+ }
29
+ /**
30
+ * Count of requested tags present on the profile (partial match OK).
31
+ */
32
+ export function scoreProfileTags(profile, tags) {
33
+ if (tags.length === 0) {
34
+ return { score: 0, matchedTags: [] };
35
+ }
36
+ const profileTags = new Set(profile.tags ?? []);
37
+ const matchedTags = tags.filter((tag) => profileTags.has(tag));
38
+ return { score: matchedTags.length, matchedTags };
39
+ }
40
+ /**
41
+ * Rank profiles by tag overlap (highest score first).
42
+ * Tie-break: fewer total profile tags (more specific), then profile key lexicographically.
43
+ */
44
+ export function rankProfilesByTags(profiles, tags) {
45
+ const ranked = [];
46
+ for (const [profileKey, profile] of Object.entries(profiles)) {
47
+ const { score, matchedTags } = scoreProfileTags(profile, tags);
48
+ if (score > 0) {
49
+ ranked.push({ profileKey, profile, score, matchedTags });
50
+ }
51
+ }
52
+ ranked.sort((a, b) => {
53
+ if (b.score !== a.score) {
54
+ return b.score - a.score;
55
+ }
56
+ const aLen = a.profile.tags?.length ?? 0;
57
+ const bLen = b.profile.tags?.length ?? 0;
58
+ if (aLen !== bLen) {
59
+ return aLen - bLen;
60
+ }
61
+ return a.profileKey.localeCompare(b.profileKey);
62
+ });
63
+ return ranked;
64
+ }
65
+ /**
66
+ * Best profile for a tag set, or undefined when no tag matches.
67
+ */
68
+ export function pickBestProfileByTags(profiles, tags) {
69
+ return rankProfilesByTags(profiles, tags)[0];
70
+ }
71
+ /**
72
+ * Returns true when the profile matches all requested tags (mode `all`)
73
+ * or at least one (mode `any`, default).
74
+ */
75
+ export function profileMatchesTags(profile, tags, mode = "any") {
76
+ if (tags.length === 0) {
77
+ return true;
78
+ }
79
+ const { score, matchedTags } = scoreProfileTags(profile, tags);
80
+ if (mode === "all") {
81
+ return matchedTags.length === tags.length;
82
+ }
83
+ return score > 0;
84
+ }
85
+ /**
86
+ * Free-text discovery across profile metadata, aliases, tags, and choice labels.
87
+ */
88
+ export function profileMatchesSearch(profile, search) {
89
+ const trimmed = search.trim();
90
+ if (!trimmed) {
91
+ return true;
92
+ }
93
+ const haystack = profileSearchHaystack(profile);
94
+ const compactHaystack = haystack.replace(/[^a-z0-9]/g, "");
95
+ const normalizedQuery = normalizeKey(trimmed);
96
+ const compactQuery = normalizedQuery.replace(/[^a-z0-9]/g, "");
97
+ if (haystack.includes(normalizedQuery) || compactHaystack.includes(compactQuery)) {
98
+ return true;
99
+ }
100
+ const tokens = tokenizeSearch(trimmed);
101
+ if (tokens.length === 0) {
102
+ return true;
103
+ }
104
+ return tokens.every((token) => haystack.includes(token));
105
+ }
106
+ export function profileMatchesDiscovery(profile, options) {
107
+ if (options.tags?.length && !profileMatchesTags(profile, options.tags, options.tagMatch)) {
108
+ return false;
109
+ }
110
+ if (options.search && !profileMatchesSearch(profile, options.search)) {
111
+ return false;
112
+ }
113
+ return true;
114
+ }
115
+ /** Collect every tag used across profiles (sorted). */
116
+ export function collectProfileTags(profiles) {
117
+ const tags = new Set();
118
+ for (const profile of Object.values(profiles)) {
119
+ for (const tag of profile.tags ?? []) {
120
+ tags.add(tag);
121
+ }
122
+ }
123
+ return [...tags].sort();
124
+ }
125
+ /** Stable signature for a profile tag set (sorted, comma-joined). */
126
+ export function profileTagSetSignature(tags) {
127
+ return [...tags].sort().join(",");
128
+ }
129
+ //# sourceMappingURL=profileDiscovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileDiscovery.js","sourceRoot":"","sources":["../src/profileDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAgBjD,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,YAAY,CAAC,KAAK,CAAC;SACvB,KAAK,CAAC,aAAa,CAAC;SACpB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,qBAAqB,CAAC,OAA4B;IACzD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QACpE,MAAM,CAAC,MAAM;QACb,MAAM,CAAC,WAAW;QAClB,MAAM,CAAC,WAAW;QAClB,MAAM,CAAC,QAAQ;QACf,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,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C,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,kBAAkB,CAChC,QAA6C;IAE7C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAgB,CAAC;IACrC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;YACrC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1B,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,IAAoB;IACzD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { AIProfilesRegistry, ModelsCatalogJson } from "./types.js";
2
+ export type ModelProfileMatchConfidence = "exact" | "high" | "low";
3
+ export interface ModelProfileFallbackMatch {
4
+ profileKey: string;
5
+ choiceKey: string;
6
+ confidence: ModelProfileMatchConfidence;
7
+ score: number;
8
+ matchedBy: string;
9
+ warning?: string;
10
+ }
11
+ export declare function resolveProfileFromModelInput(registry: Pick<AIProfilesRegistry, "profiles">, input: string, catalog?: ModelsCatalogJson): ModelProfileFallbackMatch | undefined;
12
+ export declare function modelFallbackLogMeta(input: string, match: ModelProfileFallbackMatch): Record<string, unknown>;
13
+ //# sourceMappingURL=profileModelFallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileModelFallback.d.ts","sourceRoot":"","sources":["../src/profileModelFallback.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,2BAA2B,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEnE,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,2BAA2B,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA0LD,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAC9C,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,iBAAiB,GAC1B,yBAAyB,GAAG,SAAS,CAuCvC;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,yBAAyB,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}