@x12i/ai-tools 2.1.3 → 2.1.5
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/dist/catalog/index.cjs +4 -4
- package/dist/catalog/index.js +3 -3
- package/dist/{chunk-H6HDETJK.cjs → chunk-4UA2V5R2.cjs} +14 -14
- package/dist/{chunk-H6HDETJK.cjs.map → chunk-4UA2V5R2.cjs.map} +1 -1
- package/dist/{chunk-GNOZFRKR.cjs → chunk-CM3GY62V.cjs} +28 -15
- package/dist/chunk-CM3GY62V.cjs.map +1 -0
- package/dist/{chunk-TZHPZGDB.js → chunk-DIVRTJUA.js} +2 -2
- package/dist/{chunk-7VGEQTJA.js → chunk-DYVCBK2C.js} +2 -2
- package/dist/{chunk-ZHRU337O.cjs → chunk-IYRZYLUP.cjs} +5 -5
- package/dist/{chunk-ZHRU337O.cjs.map → chunk-IYRZYLUP.cjs.map} +1 -1
- package/dist/{chunk-UQ4NSEXF.js → chunk-MN6K2YHF.js} +2 -2
- package/dist/{chunk-DSDN65JH.js → chunk-OZHZUMNR.js} +2 -2
- package/dist/{chunk-IJTDND4V.cjs → chunk-RK4QKTQ2.cjs} +5 -5
- package/dist/{chunk-IJTDND4V.cjs.map → chunk-RK4QKTQ2.cjs.map} +1 -1
- package/dist/{chunk-UY2VLJN6.cjs → chunk-U3BAEJ2C.cjs} +3 -3
- package/dist/{chunk-UY2VLJN6.cjs.map → chunk-U3BAEJ2C.cjs.map} +1 -1
- package/dist/{chunk-RNSXRGIA.js → chunk-WBHH3JEK.js} +25 -12
- package/dist/chunk-WBHH3JEK.js.map +1 -0
- package/dist/{chunk-5RW5ARLO.js → chunk-WJFOQS6I.js} +3 -3
- package/dist/{chunk-RVQPQI63.cjs → chunk-YY2AGHRV.cjs} +7 -7
- package/dist/{chunk-RVQPQI63.cjs.map → chunk-YY2AGHRV.cjs.map} +1 -1
- package/dist/cli/index.cjs +15 -15
- package/dist/cli/index.js +6 -6
- package/dist/cost/index.cjs +4 -4
- package/dist/cost/index.js +3 -3
- package/dist/index.cjs +7 -7
- package/dist/index.js +6 -6
- package/dist/models/index.cjs +5 -5
- package/dist/models/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-GNOZFRKR.cjs.map +0 -1
- package/dist/chunk-RNSXRGIA.js.map +0 -1
- /package/dist/{chunk-TZHPZGDB.js.map → chunk-DIVRTJUA.js.map} +0 -0
- /package/dist/{chunk-7VGEQTJA.js.map → chunk-DYVCBK2C.js.map} +0 -0
- /package/dist/{chunk-UQ4NSEXF.js.map → chunk-MN6K2YHF.js.map} +0 -0
- /package/dist/{chunk-DSDN65JH.js.map → chunk-OZHZUMNR.js.map} +0 -0
- /package/dist/{chunk-5RW5ARLO.js.map → chunk-WJFOQS6I.js.map} +0 -0
|
@@ -103,6 +103,13 @@ function canonicalModelId(provider, modelId) {
|
|
|
103
103
|
return buildOpenRouterModelId(provider, normalized);
|
|
104
104
|
}
|
|
105
105
|
var cachedIndex = null;
|
|
106
|
+
var registrySourceOverride;
|
|
107
|
+
function registrySource(options) {
|
|
108
|
+
return options?.source ?? registrySourceOverride ?? "auto";
|
|
109
|
+
}
|
|
110
|
+
function profileResolveOptions(source) {
|
|
111
|
+
return source === "auto" ? { source } : { source, refresh: true };
|
|
112
|
+
}
|
|
106
113
|
function indexRegistry(registry) {
|
|
107
114
|
const byKey = /* @__PURE__ */ new Map();
|
|
108
115
|
const add = (key, entry) => {
|
|
@@ -139,9 +146,9 @@ function choiceEntry(choice, profile, choiceKey) {
|
|
|
139
146
|
choice: choiceKey
|
|
140
147
|
};
|
|
141
148
|
}
|
|
142
|
-
async function getProfileIndex() {
|
|
143
|
-
const registry = await loadAIProfilesRegistry(
|
|
144
|
-
const cacheKey = `${registry.version}:${registry.generatedAt ?? ""}:${registry.source}`;
|
|
149
|
+
async function getProfileIndex(source) {
|
|
150
|
+
const registry = await loadAIProfilesRegistry(profileResolveOptions(source));
|
|
151
|
+
const cacheKey = `${source}:${registry.version}:${registry.generatedAt ?? ""}:${registry.source}`;
|
|
145
152
|
if (cachedIndex?.cacheKey === cacheKey) {
|
|
146
153
|
return cachedIndex.byKey;
|
|
147
154
|
}
|
|
@@ -188,8 +195,11 @@ function resolvedToMatch(resolved) {
|
|
|
188
195
|
choice: resolved.choice
|
|
189
196
|
};
|
|
190
197
|
}
|
|
191
|
-
async function fromIndexed(entry) {
|
|
192
|
-
const resolved = await resolveAIProfile(entry.profile, {
|
|
198
|
+
async function fromIndexed(entry, source) {
|
|
199
|
+
const resolved = await resolveAIProfile(entry.profile, {
|
|
200
|
+
choice: entry.choice,
|
|
201
|
+
...profileResolveOptions(source)
|
|
202
|
+
});
|
|
193
203
|
const direct = resolved.invocation.direct;
|
|
194
204
|
return {
|
|
195
205
|
provider: normalizeProvider(direct.provider) ?? direct.provider,
|
|
@@ -203,7 +213,7 @@ async function fromIndexed(entry) {
|
|
|
203
213
|
choice: resolved.choice
|
|
204
214
|
};
|
|
205
215
|
}
|
|
206
|
-
async function lookupInIndex(index, model, provider) {
|
|
216
|
+
async function lookupInIndex(index, model, source, provider) {
|
|
207
217
|
const providerHint = provider ? normalizeProvider(provider) : void 0;
|
|
208
218
|
const keys = [
|
|
209
219
|
profileKey(model),
|
|
@@ -230,26 +240,29 @@ async function lookupInIndex(index, model, provider) {
|
|
|
230
240
|
unique.set(`${e.profile}:${e.choice}:${e.canonicalModelId}`, e);
|
|
231
241
|
}
|
|
232
242
|
const best = pickBest([...unique.values()], model, providerHint);
|
|
233
|
-
return best ? fromIndexed(best) : null;
|
|
243
|
+
return best ? fromIndexed(best, source) : null;
|
|
234
244
|
}
|
|
235
|
-
async function matchModelInAiProfiles(model, provider) {
|
|
245
|
+
async function matchModelInAiProfiles(model, provider, options) {
|
|
246
|
+
const source = registrySource(options);
|
|
247
|
+
const resolveOpts = profileResolveOptions(source);
|
|
236
248
|
try {
|
|
237
|
-
const resolved = await resolveAIProfile(model);
|
|
249
|
+
const resolved = await resolveAIProfile(model, resolveOpts);
|
|
238
250
|
return resolvedToMatch(resolved);
|
|
239
251
|
} catch (err) {
|
|
240
252
|
if (!(err instanceof AIProfilesError) || err.code !== "UNKNOWN_PROFILE") {
|
|
241
253
|
throw err;
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
|
-
const index = await getProfileIndex();
|
|
256
|
+
const index = await getProfileIndex(source);
|
|
245
257
|
const hint = providerHintForProfiles(model, provider);
|
|
246
|
-
const direct = await lookupInIndex(index, model, hint);
|
|
258
|
+
const direct = await lookupInIndex(index, model, source, hint);
|
|
247
259
|
if (direct) return direct;
|
|
248
260
|
const stripped = stripModelVersionSuffix(model);
|
|
249
261
|
if (stripped && stripped !== normalizeString(model)) {
|
|
250
262
|
return lookupInIndex(
|
|
251
263
|
index,
|
|
252
264
|
stripped,
|
|
265
|
+
source,
|
|
253
266
|
providerHintForProfiles(stripped, provider)
|
|
254
267
|
);
|
|
255
268
|
}
|
|
@@ -264,4 +277,4 @@ export {
|
|
|
264
277
|
resolveRoutedViaOpenRouter,
|
|
265
278
|
matchModelInAiProfiles
|
|
266
279
|
};
|
|
267
|
-
//# sourceMappingURL=chunk-
|
|
280
|
+
//# sourceMappingURL=chunk-WBHH3JEK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cost/costModelResolution.ts","../src/cost/aiProfilesMatch.ts"],"sourcesContent":["import type { AiModelsCatalogClient } from \"../catalog/AiModelsCatalogClient.js\";\nimport { LOCAL_PROVIDERS } from \"../sync/modelNameResolver/constants.js\";\nimport {\n loadOpenRouterRoutingEnv,\n shouldDefaultRouteViaOpenRouter,\n} from \"../sync/openRouterRoutingEnv.js\";\nimport { normalizeProvider, normalizeString } from \"../sync/modelNameResolver/normalize.js\";\nimport type {\n ModelResolutionInput,\n ModelResolutionResult,\n ModelResolverOptions,\n} from \"../sync/modelNameResolver/types.js\";\nimport type { OpenRouterRoutingConfig } from \"../sync/openRouterRoutingEnv.js\";\n\nexport function isOpenRouterProvider(provider?: string): boolean {\n return normalizeProvider(provider) === \"openrouter\";\n}\n\nexport function isLocalProvider(provider?: string): boolean {\n const p = normalizeProvider(provider) ?? normalizeString(provider ?? \"\");\n return LOCAL_PROVIDERS.has(p);\n}\n\n/** Catalog resolver returned success without a priced record (Ollama, LM Studio, …). */\nexport function isLocalProviderResolution(\n resolved: ModelResolutionResult | null,\n inputProvider?: string,\n): boolean {\n if (!resolved?.found || resolved.record) return false;\n if (resolved.resolvedVia.includes(\"local-provider-passthrough\")) return true;\n return isLocalProvider(inputProvider);\n}\n\n/**\n * Vendor id for a model slug (`openai/gpt-4o` → `openai`).\n * Ignores `openrouter` as a provider hint — it is a routing layer, not the model owner.\n */\nexport function underlyingProviderFromModel(\n model: string,\n providerHint?: string,\n): string | undefined {\n const normalized = normalizeString(model);\n if (normalized.includes(\"/\")) {\n const prefix = normalized.split(\"/\")[0]!;\n if (!isOpenRouterProvider(prefix)) return prefix;\n }\n if (providerHint && !isOpenRouterProvider(providerHint)) {\n return normalizeProvider(providerHint);\n }\n return undefined;\n}\n\n/** Provider hint for ai-profiles index lookup (openrouter → underlying vendor). */\nexport function providerHintForProfiles(\n model: string,\n provider?: string,\n): string | undefined {\n if (isOpenRouterProvider(provider)) {\n return underlyingProviderFromModel(model, provider);\n }\n return normalizeProvider(provider);\n}\n\n/**\n * Catalog resolve attempts for direct API and OpenRouter usage.\n * Tries the caller hint, inferred vendor, no hint, and openrouter routing.\n */\nexport function buildCatalogResolveAttempts(\n model: string,\n provider?: string,\n): ModelResolutionInput[] {\n const attempts: ModelResolutionInput[] = [];\n const seen = new Set<string>();\n const add = (m: string, p?: string) => {\n const key = `${p ?? \"\"}\\0${normalizeString(m)}`;\n if (seen.has(key)) return;\n seen.add(key);\n attempts.push({ model: m, provider: p });\n };\n\n add(model, provider);\n\n const underlying = underlyingProviderFromModel(model, provider);\n if (provider) add(model, undefined);\n if (underlying) add(model, underlying);\n if (!isOpenRouterProvider(provider)) {\n add(model, \"openrouter\");\n }\n\n return attempts;\n}\n\nexport async function resolveFromCatalogAttempts(\n catalog: AiModelsCatalogClient,\n attempts: ModelResolutionInput[],\n options?: ModelResolverOptions,\n): Promise<ModelResolutionResult | null> {\n let last: ModelResolutionResult | null = null;\n let localPassthrough: ModelResolutionResult | null = null;\n\n for (const attempt of attempts) {\n const result = await catalog.resolveModel(attempt, options);\n last = result;\n if (result.found && result.record) return result;\n if (\n result.found &&\n !result.record &&\n isLocalProviderResolution(result, attempt.provider)\n ) {\n localPassthrough = result;\n }\n }\n\n return localPassthrough ?? last;\n}\n\nexport function resolveRoutedViaOpenRouter(\n inputProvider: string | undefined,\n resolved: ModelResolutionResult | null,\n modelId?: string,\n routingEnv?: OpenRouterRoutingConfig,\n): boolean {\n const env = routingEnv ?? loadOpenRouterRoutingEnv();\n\n if (isOpenRouterProvider(inputProvider)) return true;\n\n if (resolved?.found) {\n return resolved.routedViaOpenRouter;\n }\n\n const vendor = underlyingProviderFromModel(\n modelId ?? (resolved?.found ? resolved.modelId : \"\") ?? \"\",\n inputProvider,\n );\n if (vendor && shouldDefaultRouteViaOpenRouter(vendor, env)) {\n return true;\n }\n\n return false;\n}\n","import {\n AIProfilesError,\n buildOpenRouterModelId,\n getChoiceOpenRouterModelId,\n getChoicePricing,\n getChoiceVendorModelId,\n loadAIProfilesRegistry,\n resolveAIProfile,\n} from \"@x12i/ai-profiles\";\nimport type {\n AIProfileBackend,\n AIProfileChoice,\n AIModelPricing,\n AIProfilesRegistry,\n InstructionTier,\n RegistrySourceMode,\n ResolvedAIProfile,\n} from \"@x12i/ai-profiles\";\nimport { providerHintForProfiles } from \"./costModelResolution.js\";\nimport { normalizeProvider, normalizeString } from \"../sync/modelNameResolver/normalize.js\";\nimport { stripModelVersionSuffix } from \"../sync/modelNameResolver/stripVersionSuffix.js\";\n\nexport type AiProfilesModelMatch = {\n provider: string;\n modelId: string;\n canonicalModelId: string;\n pricing?: AIModelPricing;\n instructionTier: InstructionTier;\n backend: AIProfileBackend;\n matchedVia: \"profile\" | \"shortcut\" | \"profile-alias\" | \"model-id\";\n profile?: string;\n choice?: string;\n};\n\nfunction profileKey(value: string): string {\n return value.trim().toLowerCase();\n}\n\nfunction canonicalModelId(provider: string, modelId: string): string {\n const normalized = normalizeString(modelId);\n if (normalized.includes(\"/\")) return normalized;\n return buildOpenRouterModelId(provider, normalized);\n}\n\ntype IndexedChoice = {\n provider: string;\n modelId: string;\n canonicalModelId: string;\n pricing?: AIModelPricing;\n profile: string;\n choice: string;\n};\n\nlet cachedIndex: {\n cacheKey: string;\n byKey: Map<string, IndexedChoice[]>;\n} | null = null;\n\nexport type MatchModelInAiProfilesOptions = {\n source?: RegistrySourceMode;\n};\n\n/** When set (tests), overrides default `auto` registry/catalog source. */\nlet registrySourceOverride: RegistrySourceMode | undefined;\n\nfunction registrySource(options?: MatchModelInAiProfilesOptions): RegistrySourceMode {\n return options?.source ?? registrySourceOverride ?? \"auto\";\n}\n\n/** ai-profiles reuses catalog/registry memory cache regardless of requested source unless refresh is set. */\nfunction profileResolveOptions(source: RegistrySourceMode) {\n return source === \"auto\" ? { source } : { source, refresh: true as const };\n}\n\n/** Index bare model ids only — profile/shortcut names resolve via {@link resolveAIProfile}. */\nfunction indexRegistry(registry: AIProfilesRegistry): Map<string, IndexedChoice[]> {\n const byKey = new Map<string, IndexedChoice[]>();\n\n const add = (key: string, entry: IndexedChoice) => {\n const k = profileKey(key);\n if (!k) return;\n const list = byKey.get(k) ?? [];\n if (\n list.some(\n (e) =>\n e.canonicalModelId === entry.canonicalModelId &&\n e.choice === entry.choice &&\n e.profile === entry.profile,\n )\n ) {\n return;\n }\n list.push(entry);\n byKey.set(k, list);\n };\n\n for (const profile of Object.values(registry.profiles)) {\n for (const [choiceKey, choice] of Object.entries(profile.choices)) {\n const entry = choiceEntry(choice, profile.profile, choiceKey);\n add(getChoiceVendorModelId(choice), entry);\n add(canonicalModelId(choice.provider, getChoiceVendorModelId(choice)), entry);\n }\n }\n\n return byKey;\n}\n\nfunction choiceEntry(\n choice: AIProfileChoice,\n profile: string,\n choiceKey: string,\n): IndexedChoice {\n const vendorModelId = getChoiceVendorModelId(choice);\n const provider = normalizeProvider(choice.provider) ?? choice.provider;\n const canonical =\n getChoiceOpenRouterModelId(choice) ??\n canonicalModelId(choice.provider, vendorModelId);\n return {\n provider,\n modelId: normalizeString(vendorModelId),\n canonicalModelId: canonical,\n pricing: getChoicePricing(choice),\n profile,\n choice: choiceKey,\n };\n}\n\nasync function getProfileIndex(\n source: RegistrySourceMode,\n): Promise<Map<string, IndexedChoice[]>> {\n const registry = await loadAIProfilesRegistry(profileResolveOptions(source));\n const cacheKey = `${source}:${registry.version}:${registry.generatedAt ?? \"\"}:${registry.source}`;\n if (cachedIndex?.cacheKey === cacheKey) {\n return cachedIndex.byKey;\n }\n const byKey = indexRegistry(registry);\n cachedIndex = { cacheKey, byKey };\n return byKey;\n}\n\nfunction scoreCandidate(\n entry: IndexedChoice,\n model: string,\n providerHint?: string,\n): number {\n const normalized = normalizeString(model);\n let score = 0;\n\n if (normalized === entry.canonicalModelId) score += 100;\n if (normalized === entry.modelId) score += 80;\n if (providerHint && entry.provider === providerHint) score += 50;\n if (entry.pricing) score += 2;\n\n return score;\n}\n\nfunction pickBest(\n candidates: IndexedChoice[],\n model: string,\n providerHint?: string,\n): IndexedChoice | null {\n if (candidates.length === 0) return null;\n if (candidates.length === 1) return candidates[0]!;\n\n let best = candidates[0]!;\n let bestScore = scoreCandidate(best, model, providerHint);\n for (let i = 1; i < candidates.length; i++) {\n const c = candidates[i]!;\n const s = scoreCandidate(c, model, providerHint);\n if (s > bestScore) {\n best = c;\n bestScore = s;\n }\n }\n return best;\n}\n\nfunction resolvedToMatch(resolved: ResolvedAIProfile): AiProfilesModelMatch {\n const direct = resolved.invocation.direct;\n const canonical =\n resolved.invocation.openrouter?.modelId ??\n buildOpenRouterModelId(direct.provider, direct.modelId);\n return {\n provider: normalizeProvider(direct.provider) ?? direct.provider,\n modelId: normalizeString(direct.modelId),\n canonicalModelId: canonical,\n pricing: resolved.pricing,\n instructionTier: resolved.instructionTier,\n backend: resolved.backend,\n matchedVia: resolved.shortcut ? \"shortcut\" : \"profile\",\n profile: resolved.profile,\n choice: resolved.choice,\n };\n}\n\nasync function fromIndexed(\n entry: IndexedChoice,\n source: RegistrySourceMode,\n): Promise<AiProfilesModelMatch> {\n const resolved = await resolveAIProfile(entry.profile, {\n choice: entry.choice,\n ...profileResolveOptions(source),\n });\n const direct = resolved.invocation.direct;\n return {\n provider: normalizeProvider(direct.provider) ?? direct.provider,\n modelId: normalizeString(direct.modelId),\n canonicalModelId:\n resolved.invocation.openrouter?.modelId ??\n buildOpenRouterModelId(direct.provider, direct.modelId),\n pricing: resolved.pricing ?? entry.pricing,\n instructionTier: resolved.instructionTier,\n backend: resolved.backend,\n matchedVia: \"model-id\",\n profile: resolved.profile,\n choice: resolved.choice,\n };\n}\n\nasync function lookupInIndex(\n index: Map<string, IndexedChoice[]>,\n model: string,\n source: RegistrySourceMode,\n provider?: string,\n): Promise<AiProfilesModelMatch | null> {\n const providerHint = provider ? normalizeProvider(provider) : undefined;\n const keys = [\n profileKey(model),\n profileKey(normalizeString(model)),\n ];\n if (providerHint) {\n keys.push(profileKey(canonicalModelId(providerHint, model)));\n }\n\n const pooled: IndexedChoice[] = [];\n for (const key of keys) {\n const hits = index.get(key);\n if (hits) pooled.push(...hits);\n }\n\n const bare = normalizeString(model);\n if (!bare.includes(\"/\")) {\n for (const list of index.values()) {\n for (const entry of list) {\n if (entry.modelId === bare) pooled.push(entry);\n }\n }\n }\n\n const unique = new Map<string, IndexedChoice>();\n for (const e of pooled) {\n unique.set(`${e.profile}:${e.choice}:${e.canonicalModelId}`, e);\n }\n\n const best = pickBest([...unique.values()], model, providerHint);\n return best ? fromIndexed(best, source) : null;\n}\n\n/**\n * Resolve a model string via @x12i/ai-profiles — profile/shortcut names, aliases,\n * or a concrete model id that appears on a profile choice.\n */\nexport async function matchModelInAiProfiles(\n model: string,\n provider?: string,\n options?: MatchModelInAiProfilesOptions,\n): Promise<AiProfilesModelMatch | null> {\n const source = registrySource(options);\n const resolveOpts = profileResolveOptions(source);\n\n try {\n const resolved = await resolveAIProfile(model, resolveOpts);\n return resolvedToMatch(resolved);\n } catch (err) {\n if (!(err instanceof AIProfilesError) || err.code !== \"UNKNOWN_PROFILE\") {\n throw err;\n }\n }\n\n const index = await getProfileIndex(source);\n const hint = providerHintForProfiles(model, provider);\n const direct = await lookupInIndex(index, model, source, hint);\n if (direct) return direct;\n\n const stripped = stripModelVersionSuffix(model);\n if (stripped && stripped !== normalizeString(model)) {\n return lookupInIndex(\n index,\n stripped,\n source,\n providerHintForProfiles(stripped, provider),\n );\n }\n\n return null;\n}\n\n/** @internal Test-only — reset module cache between tests. */\nexport function resetAiProfilesMatchCacheForTests(\n options?: { source?: RegistrySourceMode },\n): void {\n cachedIndex = null;\n registrySourceOverride = options?.source ?? \"bundled\";\n}\n"],"mappings":";;;;;;;;;;AAcO,SAAS,qBAAqB,UAA4B;AAC/D,SAAO,kBAAkB,QAAQ,MAAM;AACzC;AAEO,SAAS,gBAAgB,UAA4B;AAC1D,QAAM,IAAI,kBAAkB,QAAQ,KAAK,gBAAgB,YAAY,EAAE;AACvE,SAAO,gBAAgB,IAAI,CAAC;AAC9B;AAGO,SAAS,0BACd,UACA,eACS;AACT,MAAI,CAAC,UAAU,SAAS,SAAS,OAAQ,QAAO;AAChD,MAAI,SAAS,YAAY,SAAS,4BAA4B,EAAG,QAAO;AACxE,SAAO,gBAAgB,aAAa;AACtC;AAMO,SAAS,4BACd,OACA,cACoB;AACpB,QAAM,aAAa,gBAAgB,KAAK;AACxC,MAAI,WAAW,SAAS,GAAG,GAAG;AAC5B,UAAM,SAAS,WAAW,MAAM,GAAG,EAAE,CAAC;AACtC,QAAI,CAAC,qBAAqB,MAAM,EAAG,QAAO;AAAA,EAC5C;AACA,MAAI,gBAAgB,CAAC,qBAAqB,YAAY,GAAG;AACvD,WAAO,kBAAkB,YAAY;AAAA,EACv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ACpD,QAAM,SAAS,MAAM,cAAc,OAAO,OAAO,QAAQ,IAAI;AAC7D,MAAI,OAAQ,QAAO;AAEnB,QAAM,WAAW,wBAAwB,KAAK;AAC9C,MAAI,YAAY,aAAa,gBAAgB,KAAK,GAAG;AACnD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB,UAAU,QAAQ;AAAA,IAC5C;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveModelVendor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MN6K2YHF.js";
|
|
4
4
|
import {
|
|
5
5
|
AiModelsCatalogClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DIVRTJUA.js";
|
|
7
7
|
|
|
8
8
|
// src/models/filterModels.ts
|
|
9
9
|
function matchesSearch(record, search) {
|
|
@@ -89,4 +89,4 @@ export {
|
|
|
89
89
|
AiModelsService,
|
|
90
90
|
getModelInfo
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
92
|
+
//# sourceMappingURL=chunk-WJFOQS6I.js.map
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkU3BAEJ2Ccjs = require('./chunk-U3BAEJ2C.cjs');
|
|
7
7
|
|
|
8
8
|
// src/catalog/catalogMaintenance.ts
|
|
9
9
|
async function refreshAiModelsCatalog(options = {}) {
|
|
10
|
-
const client = new (0,
|
|
10
|
+
const client = new (0, _chunkU3BAEJ2Ccjs.AiModelsCatalogClient)(options);
|
|
11
11
|
await client.refresh();
|
|
12
|
-
const loaded = await
|
|
12
|
+
const loaded = await _chunkU3BAEJ2Ccjs.loadCatalogSourcesCached.call(void 0, options, {
|
|
13
13
|
cacheKey: options.cacheKey,
|
|
14
14
|
ttlMs: options.cacheTtlMs,
|
|
15
15
|
forceRefresh: false
|
|
@@ -23,7 +23,7 @@ async function refreshAiModelsCatalog(options = {}) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
async function verifyAiModelsCatalog(options = {}) {
|
|
26
|
-
const loaded = await
|
|
26
|
+
const loaded = await _chunkU3BAEJ2Ccjs.loadCatalogSourcesCached.call(void 0, options, {
|
|
27
27
|
cacheKey: options.cacheKey,
|
|
28
28
|
ttlMs: options.cacheTtlMs,
|
|
29
29
|
forceRefresh: _nullishCoalesce(options.forceRefresh, () => ( options.bundledOnly === true))
|
|
@@ -34,8 +34,8 @@ async function verifyAiModelsCatalog(options = {}) {
|
|
|
34
34
|
openRouterCount: loaded.meta.openRouterCount,
|
|
35
35
|
directSource: loaded.meta.directSource,
|
|
36
36
|
openRouterSource: loaded.meta.openRouterSource,
|
|
37
|
-
directUrl: _nullishCoalesce(options.directCatalogUrl, () => (
|
|
38
|
-
openRouterUrl: _nullishCoalesce(options.openRouterCatalogUrl, () => (
|
|
37
|
+
directUrl: _nullishCoalesce(options.directCatalogUrl, () => ( _chunkU3BAEJ2Ccjs.DEFAULT_DIRECT_CATALOG_URL)),
|
|
38
|
+
openRouterUrl: _nullishCoalesce(options.openRouterCatalogUrl, () => ( _chunkU3BAEJ2Ccjs.DEFAULT_OPENROUTER_CATALOG_URL))
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -43,4 +43,4 @@ async function verifyAiModelsCatalog(options = {}) {
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
exports.refreshAiModelsCatalog = refreshAiModelsCatalog; exports.verifyAiModelsCatalog = verifyAiModelsCatalog;
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-YY2AGHRV.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/promethe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AA,EAAa,MAAA,CAAO,IAAA,CAAK,WAAA;AAAA,IACzB,eAAA,EAAiB,MAAA,CAAO,IAAA,CAAK,eAAA;AAAA,IAC7B,YAAA,EAAc,MAAA,CAAO,IAAA,CAAK,YAAA;AAAA,IAC1B,gBAAA,EAAkB,MAAA,CAAO,IAAA,CAAK,gBAAA;AAAA,IAC9B,SAAA,mBAAW,OAAA,CAAQ,gBAAA,UAAoB,8CAAA;AAAA,IACvC,aAAA,mBAAe,OAAA,CAAQ,oBAAA,UAAwB;AAAA,EACjD,CAAA;AACF;ADlCA;AACA;AACE;AACA;AACF,+GAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-YY2AGHRV.cjs","sourcesContent":[null,"import {\n DEFAULT_DIRECT_CATALOG_URL,\n DEFAULT_OPENROUTER_CATALOG_URL,\n type LoadCatalogOptions,\n} from \"./loadCatalogSources.js\";\nimport { loadCatalogSourcesCached } from \"./catalogLoadCache.js\";\nimport { AiModelsCatalogClient } from \"./AiModelsCatalogClient.js\";\n\nexport type CatalogRefreshOptions = LoadCatalogOptions & {\n cacheKey?: string;\n cacheTtlMs?: number;\n};\n\nexport type CatalogRefreshResult = {\n ok: true;\n directCount: number;\n openRouterCount: number;\n directSource: \"remote\" | \"bundled\";\n openRouterSource: \"remote\" | \"bundled\";\n};\n\n/** Fetch remote catalogs and warm the in-memory cache (forces a network load). */\nexport async function refreshAiModelsCatalog(\n options: CatalogRefreshOptions = {},\n): Promise<CatalogRefreshResult> {\n const client = new AiModelsCatalogClient(options);\n await client.refresh();\n const loaded = await loadCatalogSourcesCached(options, {\n cacheKey: options.cacheKey,\n ttlMs: options.cacheTtlMs,\n forceRefresh: false,\n });\n return {\n ok: true,\n directCount: loaded.meta.directCount,\n openRouterCount: loaded.meta.openRouterCount,\n directSource: loaded.meta.directSource,\n openRouterSource: loaded.meta.openRouterSource,\n };\n}\n\nexport type CatalogVerifyOptions = LoadCatalogOptions & {\n cacheKey?: string;\n cacheTtlMs?: number;\n};\n\nexport type CatalogVerifyReport = {\n ok: boolean;\n directCount: number;\n openRouterCount: number;\n directSource: \"remote\" | \"bundled\";\n openRouterSource: \"remote\" | \"bundled\";\n directUrl: string;\n openRouterUrl: string;\n};\n\n/** Load and validate both catalogs (uses cache unless `forceRefresh`). */\nexport async function verifyAiModelsCatalog(\n options: CatalogVerifyOptions & { forceRefresh?: boolean } = {},\n): Promise<CatalogVerifyReport> {\n const loaded = await loadCatalogSourcesCached(options, {\n cacheKey: options.cacheKey,\n ttlMs: options.cacheTtlMs,\n forceRefresh: options.forceRefresh ?? options.bundledOnly === true,\n });\n return {\n ok: loaded.direct.size > 0 && loaded.openrouter.size > 0,\n directCount: loaded.meta.directCount,\n openRouterCount: loaded.meta.openRouterCount,\n directSource: loaded.meta.directSource,\n openRouterSource: loaded.meta.openRouterSource,\n directUrl: options.directCatalogUrl ?? DEFAULT_DIRECT_CATALOG_URL,\n openRouterUrl: options.openRouterCatalogUrl ?? DEFAULT_OPENROUTER_CATALOG_URL,\n };\n}\n"]}
|
package/dist/cli/index.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk4UA2V5R2cjs = require('../chunk-4UA2V5R2.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunkBAHBDADJcjs = require('../chunk-BAHBDADJ.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
require('../chunk-
|
|
11
|
+
var _chunkRK4QKTQ2cjs = require('../chunk-RK4QKTQ2.cjs');
|
|
12
|
+
require('../chunk-IYRZYLUP.cjs');
|
|
13
13
|
require('../chunk-SYDW33AL.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkYY2AGHRVcjs = require('../chunk-YY2AGHRV.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
22
|
-
require('../chunk-
|
|
21
|
+
var _chunkU3BAEJ2Ccjs = require('../chunk-U3BAEJ2C.cjs');
|
|
22
|
+
require('../chunk-CM3GY62V.cjs');
|
|
23
23
|
require('../chunk-2KPWVOOT.cjs');
|
|
24
24
|
require('../chunk-OZE336BL.cjs');
|
|
25
25
|
require('../chunk-PADNCGZB.cjs');
|
|
@@ -38,8 +38,8 @@ function registry(path) {
|
|
|
38
38
|
function resolver(path) {
|
|
39
39
|
return new (0, _chunkBAHBDADJcjs.AliasResolver)({
|
|
40
40
|
registry: registry(path),
|
|
41
|
-
catalogClient: new (0,
|
|
42
|
-
cacheTtlMs:
|
|
41
|
+
catalogClient: new (0, _chunkU3BAEJ2Ccjs.AiModelsCatalogClient)({
|
|
42
|
+
cacheTtlMs: _chunkU3BAEJ2Ccjs.resolveCatalogCacheTtlMs.call(void 0, )
|
|
43
43
|
})
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -164,7 +164,7 @@ function emitHuman(lines) {
|
|
|
164
164
|
function registerCatalogCommand(program2) {
|
|
165
165
|
const catalog = program2.command("catalog").description("Model catalog load and health commands");
|
|
166
166
|
catalog.command("refresh").description("Fetch catalogs from open-assets.x12i.com and warm the cache").option("--bundled-only", "Use bundled src/data catalogs only (no HTTP)").option("--json", "Machine-readable JSON on stdout").action(async (opts) => {
|
|
167
|
-
const result = await
|
|
167
|
+
const result = await _chunkYY2AGHRVcjs.refreshAiModelsCatalog.call(void 0, { bundledOnly: opts.bundledOnly });
|
|
168
168
|
if (opts.json) {
|
|
169
169
|
emitJson(result);
|
|
170
170
|
} else {
|
|
@@ -176,7 +176,7 @@ function registerCatalogCommand(program2) {
|
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
178
|
catalog.command("verify").description("Validate direct + OpenRouter catalogs load successfully").option("--bundled-only", "Use bundled src/data catalogs only (no HTTP)").option("--json", "Machine-readable JSON on stdout").action(async (opts) => {
|
|
179
|
-
const report = await
|
|
179
|
+
const report = await _chunkYY2AGHRVcjs.verifyAiModelsCatalog.call(void 0, { bundledOnly: opts.bundledOnly });
|
|
180
180
|
if (opts.json) {
|
|
181
181
|
emitJson(report);
|
|
182
182
|
} else {
|
|
@@ -204,11 +204,11 @@ function registerCostCommand(program2) {
|
|
|
204
204
|
"Completion token count",
|
|
205
205
|
(v) => Number.parseInt(v, 10)
|
|
206
206
|
).option("--cached-tokens <n>", "Cached token count", (v) => Number.parseInt(v, 10)).option("--reasoning-tokens <n>", "Reasoning token count", (v) => Number.parseInt(v, 10)).option("--provider <id>", "Provider for pricing selection", "openrouter").option("--json", "Output raw AiCostResult JSON").option("--bundled-only", "Use src/data catalogs only (no HTTP)").action(async (opts) => {
|
|
207
|
-
const catalogClient = new (0,
|
|
208
|
-
cacheTtlMs:
|
|
207
|
+
const catalogClient = new (0, _chunkU3BAEJ2Ccjs.AiModelsCatalogClient)({
|
|
208
|
+
cacheTtlMs: _chunkU3BAEJ2Ccjs.resolveCatalogCacheTtlMs.call(void 0, ),
|
|
209
209
|
bundledOnly: opts.bundledOnly
|
|
210
210
|
});
|
|
211
|
-
const calculator = new (0,
|
|
211
|
+
const calculator = new (0, _chunk4UA2V5R2cjs.CostCalculator)(catalogClient, {
|
|
212
212
|
aliasRegistry: new (0, _chunkBAHBDADJcjs.AliasRegistry)()
|
|
213
213
|
});
|
|
214
214
|
const result = await calculator.calculate({
|
|
@@ -250,8 +250,8 @@ function registerCostCommand(program2) {
|
|
|
250
250
|
|
|
251
251
|
// src/cli/commands/models.ts
|
|
252
252
|
function service(opts) {
|
|
253
|
-
return new (0,
|
|
254
|
-
cacheTtlMs:
|
|
253
|
+
return new (0, _chunkRK4QKTQ2cjs.AiModelsService)({
|
|
254
|
+
cacheTtlMs: _chunkU3BAEJ2Ccjs.resolveCatalogCacheTtlMs.call(void 0, ),
|
|
255
255
|
bundledOnly: opts.bundledOnly
|
|
256
256
|
});
|
|
257
257
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CostCalculator
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-OZHZUMNR.js";
|
|
5
5
|
import {
|
|
6
6
|
AliasRegistry,
|
|
7
7
|
AliasResolver
|
|
8
8
|
} from "../chunk-ANVONYJF.js";
|
|
9
9
|
import {
|
|
10
10
|
AiModelsService
|
|
11
|
-
} from "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-WJFOQS6I.js";
|
|
12
|
+
import "../chunk-MN6K2YHF.js";
|
|
13
13
|
import "../chunk-4ILJWO64.js";
|
|
14
14
|
import {
|
|
15
15
|
refreshAiModelsCatalog,
|
|
16
16
|
verifyAiModelsCatalog
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-DYVCBK2C.js";
|
|
18
18
|
import {
|
|
19
19
|
AiModelsCatalogClient,
|
|
20
20
|
resolveCatalogCacheTtlMs
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-DIVRTJUA.js";
|
|
22
|
+
import "../chunk-WBHH3JEK.js";
|
|
23
23
|
import "../chunk-SQ6NOF4Z.js";
|
|
24
24
|
import "../chunk-OB44D7RG.js";
|
|
25
25
|
import "../chunk-2PTCWPHV.js";
|
package/dist/cost/index.cjs
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk4UA2V5R2cjs = require('../chunk-4UA2V5R2.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkIYRZYLUPcjs = require('../chunk-IYRZYLUP.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ var _chunkZHRU337Ocjs = require('../chunk-ZHRU337O.cjs');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
var _chunkSYDW33ALcjs = require('../chunk-SYDW33AL.cjs');
|
|
21
|
-
require('../chunk-
|
|
21
|
+
require('../chunk-CM3GY62V.cjs');
|
|
22
22
|
require('../chunk-OZE336BL.cjs');
|
|
23
23
|
require('../chunk-PADNCGZB.cjs');
|
|
24
24
|
require('../chunk-GS7T56RP.cjs');
|
|
@@ -36,5 +36,5 @@ require('../chunk-GS7T56RP.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
exports.CostCalculator =
|
|
39
|
+
exports.CostCalculator = _chunk4UA2V5R2cjs.CostCalculator; exports.DEFAULT_OPENROUTER_MARKUP_RATE = _chunk4UA2V5R2cjs.DEFAULT_OPENROUTER_MARKUP_RATE; exports.MODEL_FIELD_PRIORITY = _chunk4UA2V5R2cjs.MODEL_FIELD_PRIORITY; exports.enrichCostResult = _chunk4UA2V5R2cjs.enrichCostResult; exports.extractUsageInput = _chunk4UA2V5R2cjs.extractUsageInput; exports.modelVendorRefFromIdentity = _chunkSYDW33ALcjs.modelVendorRefFromIdentity; exports.modelVendorRefFromVendorAndSlug = _chunkSYDW33ALcjs.modelVendorRefFromVendorAndSlug; exports.resolveModelVendor = _chunkIYRZYLUPcjs.resolveModelVendor; exports.resolveModelVendorFromResolution = _chunkSYDW33ALcjs.resolveModelVendorFromResolution; exports.resolveModelVendorLastResort = _chunkSYDW33ALcjs.resolveModelVendorLastResort; exports.resolveModelVendorSync = _chunkSYDW33ALcjs.resolveModelVendorSync; exports.resolveUsageModel = _chunk4UA2V5R2cjs.resolveUsageModel; exports.toCostExtraction = _chunk4UA2V5R2cjs.toCostExtraction;
|
|
40
40
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cost/index.js
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
extractUsageInput,
|
|
8
8
|
resolveUsageModel,
|
|
9
9
|
toCostExtraction
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-OZHZUMNR.js";
|
|
11
11
|
import {
|
|
12
12
|
resolveModelVendor
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-MN6K2YHF.js";
|
|
14
14
|
import {
|
|
15
15
|
modelVendorRefFromIdentity,
|
|
16
16
|
modelVendorRefFromVendorAndSlug,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
resolveModelVendorLastResort,
|
|
19
19
|
resolveModelVendorSync
|
|
20
20
|
} from "../chunk-4ILJWO64.js";
|
|
21
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-WBHH3JEK.js";
|
|
22
22
|
import "../chunk-OB44D7RG.js";
|
|
23
23
|
import "../chunk-2PTCWPHV.js";
|
|
24
24
|
export {
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk4UA2V5R2cjs = require('./chunk-4UA2V5R2.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunk5HNFAYTOcjs = require('./chunk-5HNFAYTO.cjs');
|
|
@@ -25,10 +25,10 @@ require('./chunk-2PYACSZ5.cjs');
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _chunkRK4QKTQ2cjs = require('./chunk-RK4QKTQ2.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var _chunkIYRZYLUPcjs = require('./chunk-IYRZYLUP.cjs');
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
var _chunkYO7AJ5Z3cjs = require('./chunk-YO7AJ5Z3.cjs');
|
|
@@ -42,7 +42,7 @@ var _chunkSYDW33ALcjs = require('./chunk-SYDW33AL.cjs');
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
var
|
|
45
|
+
var _chunkYY2AGHRVcjs = require('./chunk-YY2AGHRV.cjs');
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
|
|
@@ -52,8 +52,8 @@ var _chunkRVQPQI63cjs = require('./chunk-RVQPQI63.cjs');
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
var
|
|
56
|
-
require('./chunk-
|
|
55
|
+
var _chunkU3BAEJ2Ccjs = require('./chunk-U3BAEJ2C.cjs');
|
|
56
|
+
require('./chunk-CM3GY62V.cjs');
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
@@ -152,5 +152,5 @@ require('./chunk-GS7T56RP.cjs');
|
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
exports.AIToolbox = _chunk5HNFAYTOcjs.AIToolbox; exports.AiModelsCatalogClient =
|
|
155
|
+
exports.AIToolbox = _chunk5HNFAYTOcjs.AIToolbox; exports.AiModelsCatalogClient = _chunkU3BAEJ2Ccjs.AiModelsCatalogClient; exports.AiModelsService = _chunkRK4QKTQ2cjs.AiModelsService; exports.AiToolsError = _chunkPADNCGZBcjs.AiToolsError; exports.AliasConflictError = _chunkPADNCGZBcjs.AliasConflictError; exports.AliasFileParseError = _chunkPADNCGZBcjs.AliasFileParseError; exports.AliasFileWriteError = _chunkPADNCGZBcjs.AliasFileWriteError; exports.AliasInvalidNameError = _chunkPADNCGZBcjs.AliasInvalidNameError; exports.AliasNotFoundError = _chunkPADNCGZBcjs.AliasNotFoundError; exports.AliasRegistry = _chunkBAHBDADJcjs.AliasRegistry; exports.AliasResolver = _chunkBAHBDADJcjs.AliasResolver; exports.CostCalculationError = _chunkPADNCGZBcjs.CostCalculationError; exports.CostCalculator = _chunk4UA2V5R2cjs.CostCalculator; exports.DEFAULT_CATALOG_CACHE_TTL_MS = _chunkU3BAEJ2Ccjs.DEFAULT_CATALOG_CACHE_TTL_MS; exports.DEFAULT_DIRECT_CATALOG_URL = _chunkU3BAEJ2Ccjs.DEFAULT_DIRECT_CATALOG_URL; exports.DEFAULT_OPENROUTER_CATALOG_URL = _chunkU3BAEJ2Ccjs.DEFAULT_OPENROUTER_CATALOG_URL; exports.MODEL_FIELD_PRIORITY = _chunk4UA2V5R2cjs.MODEL_FIELD_PRIORITY; exports.ModelNameResolver = _chunkOZE336BLcjs.ModelNameResolver; exports.ModelNotFoundError = _chunkPADNCGZBcjs.ModelNotFoundError; exports.ModelResolutionError = _chunkPADNCGZBcjs.ModelResolutionError; exports.OpenRouterSyncProvider = _chunkJDOFFZJAcjs.OpenRouterSyncProvider; exports.REASONING_SUPPORTED_PARAMETERS = _chunk2KPWVOOTcjs.REASONING_SUPPORTED_PARAMETERS; exports.SyncError = _chunkPADNCGZBcjs.SyncError; exports.UnknownModelCostError = _chunkPADNCGZBcjs.UnknownModelCostError; exports.computeSupportsReasoning = _chunk2KPWVOOTcjs.computeSupportsReasoning; exports.countModels = _chunkRK4QKTQ2cjs.countModels; exports.createModelNameResolver = _chunkJDOFFZJAcjs.createModelNameResolver; exports.extractUsageInput = _chunk4UA2V5R2cjs.extractUsageInput; exports.filterModels = _chunkRK4QKTQ2cjs.filterModels; exports.getModelInfo = _chunkRK4QKTQ2cjs.getModelInfo; exports.hasReasoningPricing = _chunk2KPWVOOTcjs.hasReasoningPricing; exports.invalidateCatalogLoadCache = _chunkU3BAEJ2Ccjs.invalidateCatalogLoadCache; exports.isEffectiveOpenRouterTransport = _chunkOZE336BLcjs.isEffectiveOpenRouterTransport; exports.isKnownProfileOrShortcut = _chunk5IZ7PLY2cjs.isKnownProfileOrShortcut; exports.isReasoningModel = _chunk2KPWVOOTcjs.isReasoningModel; exports.isRoutedViaOpenRouter = _chunkJDOFFZJAcjs.isRoutedViaOpenRouter; exports.listAIProfiles = _chunk5IZ7PLY2cjs.listAIProfiles; exports.listAIShortcuts = _chunk5IZ7PLY2cjs.listAIShortcuts; exports.loadCatalogSources = _chunkU3BAEJ2Ccjs.loadCatalogSources; exports.loadCatalogSourcesCached = _chunkU3BAEJ2Ccjs.loadCatalogSourcesCached; exports.loadOpenRouterRoutingEnv = _chunkOZE336BLcjs.loadOpenRouterRoutingEnv; exports.modelVendorRefFromIdentity = _chunkSYDW33ALcjs.modelVendorRefFromIdentity; exports.modelVendorRefFromVendorAndSlug = _chunkSYDW33ALcjs.modelVendorRefFromVendorAndSlug; exports.normalizeOpenRouterModel = _chunkYO7AJ5Z3cjs.normalizeOpenRouterModel; exports.profileConfigFromResolved = _chunk5IZ7PLY2cjs.profileConfigFromResolved; exports.providerIdToEnvKeyPrefix = _chunkOZE336BLcjs.providerIdToEnvKeyPrefix; exports.refreshAiModelsCatalog = _chunkYY2AGHRVcjs.refreshAiModelsCatalog; exports.resolveAIProfile = _chunk5IZ7PLY2cjs.resolveAIProfile; exports.resolveCatalogCacheTtlMs = _chunkU3BAEJ2Ccjs.resolveCatalogCacheTtlMs; exports.resolveModel = _chunkJDOFFZJAcjs.resolveModel; exports.resolveModelVendor = _chunkIYRZYLUPcjs.resolveModelVendor; exports.resolveModelVendorFromResolution = _chunkSYDW33ALcjs.resolveModelVendorFromResolution; exports.resolveModelVendorLastResort = _chunkSYDW33ALcjs.resolveModelVendorLastResort; exports.resolveModelVendorSync = _chunkSYDW33ALcjs.resolveModelVendorSync; exports.resolveProfileForAsk = _chunk5IZ7PLY2cjs.resolveProfileForAsk; exports.resolveUsageModel = _chunk4UA2V5R2cjs.resolveUsageModel; exports.shouldDefaultRouteViaOpenRouter = _chunkOZE336BLcjs.shouldDefaultRouteViaOpenRouter; exports.supportsReasoningParameter = _chunk2KPWVOOTcjs.supportsReasoningParameter; exports.vendorApiKeyEnvName = _chunkOZE336BLcjs.vendorApiKeyEnvName; exports.verifyAiModelsCatalog = _chunkYY2AGHRVcjs.verifyAiModelsCatalog;
|
|
156
156
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
MODEL_FIELD_PRIORITY,
|
|
5
5
|
extractUsageInput,
|
|
6
6
|
resolveUsageModel
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OZHZUMNR.js";
|
|
8
8
|
import {
|
|
9
9
|
AIToolbox
|
|
10
10
|
} from "./chunk-XRBZQQQU.js";
|
|
@@ -25,10 +25,10 @@ import {
|
|
|
25
25
|
countModels,
|
|
26
26
|
filterModels,
|
|
27
27
|
getModelInfo
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-WJFOQS6I.js";
|
|
29
29
|
import {
|
|
30
30
|
resolveModelVendor
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-MN6K2YHF.js";
|
|
32
32
|
import {
|
|
33
33
|
normalizeOpenRouterModel
|
|
34
34
|
} from "./chunk-VDNKQRDG.js";
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
import {
|
|
43
43
|
refreshAiModelsCatalog,
|
|
44
44
|
verifyAiModelsCatalog
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-DYVCBK2C.js";
|
|
46
46
|
import {
|
|
47
47
|
AiModelsCatalogClient,
|
|
48
48
|
DEFAULT_CATALOG_CACHE_TTL_MS,
|
|
@@ -52,8 +52,8 @@ import {
|
|
|
52
52
|
loadCatalogSources,
|
|
53
53
|
loadCatalogSourcesCached,
|
|
54
54
|
resolveCatalogCacheTtlMs
|
|
55
|
-
} from "./chunk-
|
|
56
|
-
import "./chunk-
|
|
55
|
+
} from "./chunk-DIVRTJUA.js";
|
|
56
|
+
import "./chunk-WBHH3JEK.js";
|
|
57
57
|
import {
|
|
58
58
|
REASONING_SUPPORTED_PARAMETERS,
|
|
59
59
|
computeSupportsReasoning,
|
package/dist/models/index.cjs
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('../chunk-
|
|
7
|
+
var _chunkRK4QKTQ2cjs = require('../chunk-RK4QKTQ2.cjs');
|
|
8
|
+
require('../chunk-IYRZYLUP.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkYO7AJ5Z3cjs = require('../chunk-YO7AJ5Z3.cjs');
|
|
13
13
|
require('../chunk-SYDW33AL.cjs');
|
|
14
|
-
require('../chunk-
|
|
15
|
-
require('../chunk-
|
|
14
|
+
require('../chunk-U3BAEJ2C.cjs');
|
|
15
|
+
require('../chunk-CM3GY62V.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -35,5 +35,5 @@ require('../chunk-GS7T56RP.cjs');
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
exports.AiModelsService =
|
|
38
|
+
exports.AiModelsService = _chunkRK4QKTQ2cjs.AiModelsService; exports.REASONING_SUPPORTED_PARAMETERS = _chunk2KPWVOOTcjs.REASONING_SUPPORTED_PARAMETERS; exports.computeSupportsReasoning = _chunk2KPWVOOTcjs.computeSupportsReasoning; exports.countModels = _chunkRK4QKTQ2cjs.countModels; exports.extractProviderId = _chunkYO7AJ5Z3cjs.extractProviderId; exports.filterModels = _chunkRK4QKTQ2cjs.filterModels; exports.getModelInfo = _chunkRK4QKTQ2cjs.getModelInfo; exports.hasReasoningPricing = _chunk2KPWVOOTcjs.hasReasoningPricing; exports.isReasoningModel = _chunk2KPWVOOTcjs.isReasoningModel; exports.normalizeOpenRouterModel = _chunkYO7AJ5Z3cjs.normalizeOpenRouterModel; exports.supportsReasoningParameter = _chunk2KPWVOOTcjs.supportsReasoningParameter;
|
|
39
39
|
//# sourceMappingURL=index.cjs.map
|
package/dist/models/index.js
CHANGED
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
countModels,
|
|
5
5
|
filterModels,
|
|
6
6
|
getModelInfo
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-WJFOQS6I.js";
|
|
8
|
+
import "../chunk-MN6K2YHF.js";
|
|
9
9
|
import {
|
|
10
10
|
extractProviderId,
|
|
11
11
|
normalizeOpenRouterModel
|
|
12
12
|
} from "../chunk-VDNKQRDG.js";
|
|
13
13
|
import "../chunk-4ILJWO64.js";
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
14
|
+
import "../chunk-DIVRTJUA.js";
|
|
15
|
+
import "../chunk-WBHH3JEK.js";
|
|
16
16
|
import {
|
|
17
17
|
REASONING_SUPPORTED_PARAMETERS,
|
|
18
18
|
computeSupportsReasoning,
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-GNOZFRKR.cjs","../src/cost/costModelResolution.ts","../src/cost/aiProfilesMatch.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACKO,SAAS,oBAAA,CAAqB,QAAA,EAA4B;AAC/D,EAAA,OAAO,iDAAA,QAA0B,EAAA,IAAM,YAAA;AACzC;AAEO,SAAS,eAAA,CAAgB,QAAA,EAA4B;AAC1D,EAAA,MAAM,EAAA,mBAAI,iDAAA,QAA0B,CAAA,UAAK,+CAAA,iBAAgB,QAAA,UAAY,IAAE,GAAA;AACvE,EAAA,OAAO,iCAAA,CAAgB,GAAA,CAAI,CAAC,CAAA;AAC9B;AAGO,SAAS,yBAAA,CACd,QAAA,EACA,aAAA,EACS;AACT,EAAA,GAAA,CAAI,iBA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AACT;AAES;AACQ,EAAA;AACT,EAAA;AAGC,EAAA;AACK,IAAA;AACD,IAAA;AACT,IAAA;AACS,IAAA;AACT,IAAA;AACS,IAAA;AACG,IAAA;AACH,IAAA;AACD,IAAA;AACV,EAAA;AACF;AAEe;AACP,EAAA;AACS,EAAA;AACR,EAAA;AACK,IAAA;AACD,IAAA;AACT,IAAA;AAGS,IAAA;AACT,IAAA;AACS,IAAA;AACG,IAAA;AACH,IAAA;AACD,IAAA;AACV,EAAA;AACF;AAEe;AAKP,EAAA;AACO,EAAA;AACA,IAAA;AACA,IAAA;AACb,EAAA;AACI,EAAA;AACQ,IAAA;AACZ,EAAA;AAEgC,EAAA;AACrB,EAAA;AACI,IAAA;AACH,IAAA;AACZ,EAAA;AAEa,EAAA;AACH,EAAA;AACG,IAAA;AACE,MAAA;AACL,QAAA;AACN,MAAA;AACF,IAAA;AACF,EAAA;AAEe,EAAA;AACJ,EAAA;AACE,IAAA;AACb,EAAA;AAEa,EAAA;AACC,EAAA;AAChB;AAMsB;AAIhB,EAAA;AACI,IAAA;AACC,IAAA;AACK,EAAA;AACN,IAAA;AACE,MAAA;AACR,IAAA;AACF,EAAA;AAEc,EAAA;AACD,EAAA;AACE,EAAA;AACH,EAAA;AAEN,EAAA;AACF,EAAA;AACK,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAEO,EAAA;AACT;AFPiB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-GNOZFRKR.cjs","sourcesContent":[null,"import type { AiModelsCatalogClient } from \"../catalog/AiModelsCatalogClient.js\";\nimport { LOCAL_PROVIDERS } from \"../sync/modelNameResolver/constants.js\";\nimport {\n loadOpenRouterRoutingEnv,\n shouldDefaultRouteViaOpenRouter,\n} from \"../sync/openRouterRoutingEnv.js\";\nimport { normalizeProvider, normalizeString } from \"../sync/modelNameResolver/normalize.js\";\nimport type {\n ModelResolutionInput,\n ModelResolutionResult,\n ModelResolverOptions,\n} from \"../sync/modelNameResolver/types.js\";\nimport type { OpenRouterRoutingConfig } from \"../sync/openRouterRoutingEnv.js\";\n\nexport function isOpenRouterProvider(provider?: string): boolean {\n return normalizeProvider(provider) === \"openrouter\";\n}\n\nexport function isLocalProvider(provider?: string): boolean {\n const p = normalizeProvider(provider) ?? normalizeString(provider ?? \"\");\n return LOCAL_PROVIDERS.has(p);\n}\n\n/** Catalog resolver returned success without a priced record (Ollama, LM Studio, …). */\nexport function isLocalProviderResolution(\n resolved: ModelResolutionResult | null,\n inputProvider?: string,\n): boolean {\n if (!resolved?.found || resolved.record) return false;\n if (resolved.resolvedVia.includes(\"local-provider-passthrough\")) return true;\n return isLocalProvider(inputProvider);\n}\n\n/**\n * Vendor id for a model slug (`openai/gpt-4o` → `openai`).\n * Ignores `openrouter` as a provider hint — it is a routing layer, not the model owner.\n */\nexport function underlyingProviderFromModel(\n model: string,\n providerHint?: string,\n): string | undefined {\n const normalized = normalizeString(model);\n if (normalized.includes(\"/\")) {\n const prefix = normalized.split(\"/\")[0]!;\n if (!isOpenRouterProvider(prefix)) return prefix;\n }\n if (providerHint && !isOpenRouterProvider(providerHint)) {\n return normalizeProvider(providerHint);\n }\n return undefined;\n}\n\n/** Provider hint for ai-profiles index lookup (openrouter → underlying vendor). */\nexport function providerHintForProfiles(\n model: string,\n provider?: string,\n): string | undefined {\n if (isOpenRouterProvider(provider)) {\n return underlyingProviderFromModel(model, provider);\n }\n return normalizeProvider(provider);\n}\n\n/**\n * Catalog resolve attempts for direct API and OpenRouter usage.\n * Tries the caller hint, inferred vendor, no hint, and openrouter routing.\n */\nexport function buildCatalogResolveAttempts(\n model: string,\n provider?: string,\n): ModelResolutionInput[] {\n const attempts: ModelResolutionInput[] = [];\n const seen = new Set<string>();\n const add = (m: string, p?: string) => {\n const key = `${p ?? \"\"}\\0${normalizeString(m)}`;\n if (seen.has(key)) return;\n seen.add(key);\n attempts.push({ model: m, provider: p });\n };\n\n add(model, provider);\n\n const underlying = underlyingProviderFromModel(model, provider);\n if (provider) add(model, undefined);\n if (underlying) add(model, underlying);\n if (!isOpenRouterProvider(provider)) {\n add(model, \"openrouter\");\n }\n\n return attempts;\n}\n\nexport async function resolveFromCatalogAttempts(\n catalog: AiModelsCatalogClient,\n attempts: ModelResolutionInput[],\n options?: ModelResolverOptions,\n): Promise<ModelResolutionResult | null> {\n let last: ModelResolutionResult | null = null;\n let localPassthrough: ModelResolutionResult | null = null;\n\n for (const attempt of attempts) {\n const result = await catalog.resolveModel(attempt, options);\n last = result;\n if (result.found && result.record) return result;\n if (\n result.found &&\n !result.record &&\n isLocalProviderResolution(result, attempt.provider)\n ) {\n localPassthrough = result;\n }\n }\n\n return localPassthrough ?? last;\n}\n\nexport function resolveRoutedViaOpenRouter(\n inputProvider: string | undefined,\n resolved: ModelResolutionResult | null,\n modelId?: string,\n routingEnv?: OpenRouterRoutingConfig,\n): boolean {\n const env = routingEnv ?? loadOpenRouterRoutingEnv();\n\n if (isOpenRouterProvider(inputProvider)) return true;\n\n if (resolved?.found) {\n return resolved.routedViaOpenRouter;\n }\n\n const vendor = underlyingProviderFromModel(\n modelId ?? (resolved?.found ? resolved.modelId : \"\") ?? \"\",\n inputProvider,\n );\n if (vendor && shouldDefaultRouteViaOpenRouter(vendor, env)) {\n return true;\n }\n\n return false;\n}\n","import {\n AIProfilesError,\n buildOpenRouterModelId,\n getChoiceOpenRouterModelId,\n getChoicePricing,\n getChoiceVendorModelId,\n loadAIProfilesRegistry,\n resolveAIProfile,\n} from \"@x12i/ai-profiles\";\nimport type {\n AIProfileBackend,\n AIProfileChoice,\n AIModelPricing,\n AIProfilesRegistry,\n InstructionTier,\n ResolvedAIProfile,\n} from \"@x12i/ai-profiles\";\nimport { providerHintForProfiles } from \"./costModelResolution.js\";\nimport { normalizeProvider, normalizeString } from \"../sync/modelNameResolver/normalize.js\";\nimport { stripModelVersionSuffix } from \"../sync/modelNameResolver/stripVersionSuffix.js\";\n\nexport type AiProfilesModelMatch = {\n provider: string;\n modelId: string;\n canonicalModelId: string;\n pricing?: AIModelPricing;\n instructionTier: InstructionTier;\n backend: AIProfileBackend;\n matchedVia: \"profile\" | \"shortcut\" | \"profile-alias\" | \"model-id\";\n profile?: string;\n choice?: string;\n};\n\nfunction profileKey(value: string): string {\n return value.trim().toLowerCase();\n}\n\nfunction canonicalModelId(provider: string, modelId: string): string {\n const normalized = normalizeString(modelId);\n if (normalized.includes(\"/\")) return normalized;\n return buildOpenRouterModelId(provider, normalized);\n}\n\ntype IndexedChoice = {\n provider: string;\n modelId: string;\n canonicalModelId: string;\n pricing?: AIModelPricing;\n profile: string;\n choice: string;\n};\n\nlet cachedIndex: {\n cacheKey: string;\n byKey: Map<string, IndexedChoice[]>;\n} | null = null;\n\n/** Index bare model ids only — profile/shortcut names resolve via {@link resolveAIProfile}. */\nfunction indexRegistry(registry: AIProfilesRegistry): Map<string, IndexedChoice[]> {\n const byKey = new Map<string, IndexedChoice[]>();\n\n const add = (key: string, entry: IndexedChoice) => {\n const k = profileKey(key);\n if (!k) return;\n const list = byKey.get(k) ?? [];\n if (\n list.some(\n (e) =>\n e.canonicalModelId === entry.canonicalModelId &&\n e.choice === entry.choice &&\n e.profile === entry.profile,\n )\n ) {\n return;\n }\n list.push(entry);\n byKey.set(k, list);\n };\n\n for (const profile of Object.values(registry.profiles)) {\n for (const [choiceKey, choice] of Object.entries(profile.choices)) {\n const entry = choiceEntry(choice, profile.profile, choiceKey);\n add(getChoiceVendorModelId(choice), entry);\n add(canonicalModelId(choice.provider, getChoiceVendorModelId(choice)), entry);\n }\n }\n\n return byKey;\n}\n\nfunction choiceEntry(\n choice: AIProfileChoice,\n profile: string,\n choiceKey: string,\n): IndexedChoice {\n const vendorModelId = getChoiceVendorModelId(choice);\n const provider = normalizeProvider(choice.provider) ?? choice.provider;\n const canonical =\n getChoiceOpenRouterModelId(choice) ??\n canonicalModelId(choice.provider, vendorModelId);\n return {\n provider,\n modelId: normalizeString(vendorModelId),\n canonicalModelId: canonical,\n pricing: getChoicePricing(choice),\n profile,\n choice: choiceKey,\n };\n}\n\nasync function getProfileIndex(): Promise<Map<string, IndexedChoice[]>> {\n const registry = await loadAIProfilesRegistry({ source: \"auto\" });\n const cacheKey = `${registry.version}:${registry.generatedAt ?? \"\"}:${registry.source}`;\n if (cachedIndex?.cacheKey === cacheKey) {\n return cachedIndex.byKey;\n }\n const byKey = indexRegistry(registry);\n cachedIndex = { cacheKey, byKey };\n return byKey;\n}\n\nfunction scoreCandidate(\n entry: IndexedChoice,\n model: string,\n providerHint?: string,\n): number {\n const normalized = normalizeString(model);\n let score = 0;\n\n if (normalized === entry.canonicalModelId) score += 100;\n if (normalized === entry.modelId) score += 80;\n if (providerHint && entry.provider === providerHint) score += 50;\n if (entry.pricing) score += 2;\n\n return score;\n}\n\nfunction pickBest(\n candidates: IndexedChoice[],\n model: string,\n providerHint?: string,\n): IndexedChoice | null {\n if (candidates.length === 0) return null;\n if (candidates.length === 1) return candidates[0]!;\n\n let best = candidates[0]!;\n let bestScore = scoreCandidate(best, model, providerHint);\n for (let i = 1; i < candidates.length; i++) {\n const c = candidates[i]!;\n const s = scoreCandidate(c, model, providerHint);\n if (s > bestScore) {\n best = c;\n bestScore = s;\n }\n }\n return best;\n}\n\nfunction resolvedToMatch(resolved: ResolvedAIProfile): AiProfilesModelMatch {\n const direct = resolved.invocation.direct;\n const canonical =\n resolved.invocation.openrouter?.modelId ??\n buildOpenRouterModelId(direct.provider, direct.modelId);\n return {\n provider: normalizeProvider(direct.provider) ?? direct.provider,\n modelId: normalizeString(direct.modelId),\n canonicalModelId: canonical,\n pricing: resolved.pricing,\n instructionTier: resolved.instructionTier,\n backend: resolved.backend,\n matchedVia: resolved.shortcut ? \"shortcut\" : \"profile\",\n profile: resolved.profile,\n choice: resolved.choice,\n };\n}\n\nasync function fromIndexed(entry: IndexedChoice): Promise<AiProfilesModelMatch> {\n const resolved = await resolveAIProfile(entry.profile, { choice: entry.choice });\n const direct = resolved.invocation.direct;\n return {\n provider: normalizeProvider(direct.provider) ?? direct.provider,\n modelId: normalizeString(direct.modelId),\n canonicalModelId:\n resolved.invocation.openrouter?.modelId ??\n buildOpenRouterModelId(direct.provider, direct.modelId),\n pricing: resolved.pricing ?? entry.pricing,\n instructionTier: resolved.instructionTier,\n backend: resolved.backend,\n matchedVia: \"model-id\",\n profile: resolved.profile,\n choice: resolved.choice,\n };\n}\n\nasync function lookupInIndex(\n index: Map<string, IndexedChoice[]>,\n model: string,\n provider?: string,\n): Promise<AiProfilesModelMatch | null> {\n const providerHint = provider ? normalizeProvider(provider) : undefined;\n const keys = [\n profileKey(model),\n profileKey(normalizeString(model)),\n ];\n if (providerHint) {\n keys.push(profileKey(canonicalModelId(providerHint, model)));\n }\n\n const pooled: IndexedChoice[] = [];\n for (const key of keys) {\n const hits = index.get(key);\n if (hits) pooled.push(...hits);\n }\n\n const bare = normalizeString(model);\n if (!bare.includes(\"/\")) {\n for (const list of index.values()) {\n for (const entry of list) {\n if (entry.modelId === bare) pooled.push(entry);\n }\n }\n }\n\n const unique = new Map<string, IndexedChoice>();\n for (const e of pooled) {\n unique.set(`${e.profile}:${e.choice}:${e.canonicalModelId}`, e);\n }\n\n const best = pickBest([...unique.values()], model, providerHint);\n return best ? fromIndexed(best) : null;\n}\n\n/**\n * Resolve a model string via @x12i/ai-profiles — profile/shortcut names, aliases,\n * or a concrete model id that appears on a profile choice.\n */\nexport async function matchModelInAiProfiles(\n model: string,\n provider?: string,\n): Promise<AiProfilesModelMatch | null> {\n try {\n const resolved = await resolveAIProfile(model);\n return resolvedToMatch(resolved);\n } catch (err) {\n if (!(err instanceof AIProfilesError) || err.code !== \"UNKNOWN_PROFILE\") {\n throw err;\n }\n }\n\n const index = await getProfileIndex();\n const hint = providerHintForProfiles(model, provider);\n const direct = await lookupInIndex(index, model, hint);\n if (direct) return direct;\n\n const stripped = stripModelVersionSuffix(model);\n if (stripped && stripped !== normalizeString(model)) {\n return lookupInIndex(\n index,\n stripped,\n providerHintForProfiles(stripped, provider),\n );\n }\n\n return null;\n}\n\n/** @internal Test-only — reset module cache between tests. */\nexport function resetAiProfilesMatchCacheForTests(): void {\n cachedIndex = null;\n}\n"]}
|