@x12i/ai-tools 2.1.0 → 2.1.2
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 +5 -5
- package/dist/catalog/index.js +4 -4
- package/dist/{chunk-VYVX46VO.js → chunk-4ILJWO64.js} +53 -33
- package/dist/chunk-4ILJWO64.js.map +1 -0
- package/dist/{chunk-WFRS32EQ.js → chunk-5RW5ARLO.js} +3 -3
- package/dist/{chunk-25O27USJ.js → chunk-7VGEQTJA.js} +2 -2
- package/dist/{chunk-4AIEM4AE.js → chunk-DSDN65JH.js} +3 -3
- package/dist/{chunk-TDO5SDQ3.cjs → chunk-GNOZFRKR.cjs} +45 -44
- package/dist/chunk-GNOZFRKR.cjs.map +1 -0
- package/dist/{chunk-2A6EUGR5.cjs → chunk-H6HDETJK.cjs} +19 -19
- package/dist/{chunk-2A6EUGR5.cjs.map → chunk-H6HDETJK.cjs.map} +1 -1
- package/dist/{chunk-JCMLIXIX.js → chunk-IA4HCHJV.js} +2 -2
- package/dist/{chunk-JCMLIXIX.js.map → chunk-IA4HCHJV.js.map} +1 -1
- package/dist/{chunk-GVFL2LRG.cjs → chunk-IJTDND4V.cjs} +5 -5
- package/dist/{chunk-GVFL2LRG.cjs.map → chunk-IJTDND4V.cjs.map} +1 -1
- package/dist/{chunk-R6P4AWOM.cjs → chunk-JDOFFZJA.cjs} +4 -4
- package/dist/{chunk-R6P4AWOM.cjs.map → chunk-JDOFFZJA.cjs.map} +1 -1
- package/dist/{chunk-SYHLDADG.js → chunk-OB44D7RG.js} +1 -2
- package/dist/{chunk-5XBMNY7Q.cjs → chunk-OZE336BL.cjs} +2 -3
- package/dist/chunk-OZE336BL.cjs.map +1 -0
- package/dist/{chunk-XMOALOYU.js → chunk-RNSXRGIA.js} +30 -26
- package/dist/chunk-RNSXRGIA.js.map +1 -0
- package/dist/{chunk-I6CDT2NG.cjs → chunk-RVQPQI63.cjs} +7 -7
- package/dist/{chunk-I6CDT2NG.cjs.map → chunk-RVQPQI63.cjs.map} +1 -1
- package/dist/chunk-SYDW33AL.cjs +143 -0
- package/dist/chunk-SYDW33AL.cjs.map +1 -0
- package/dist/{chunk-ET5LPVPT.js → chunk-TZHPZGDB.js} +3 -3
- package/dist/chunk-UQ4NSEXF.js +41 -0
- package/dist/chunk-UQ4NSEXF.js.map +1 -0
- package/dist/{chunk-SIR4LDHD.cjs → chunk-UY2VLJN6.cjs} +14 -14
- package/dist/{chunk-SIR4LDHD.cjs.map → chunk-UY2VLJN6.cjs.map} +1 -1
- package/dist/chunk-ZHRU337O.cjs +41 -0
- package/dist/chunk-ZHRU337O.cjs.map +1 -0
- package/dist/cli/index.cjs +17 -17
- package/dist/cli/index.js +8 -8
- package/dist/cost/index.cjs +12 -6
- package/dist/cost/index.cjs.map +1 -1
- package/dist/cost/index.d.cts +3 -3
- package/dist/cost/index.d.ts +3 -3
- package/dist/cost/index.js +11 -5
- package/dist/index.cjs +16 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -9
- package/dist/models/index.cjs +7 -7
- package/dist/models/index.d.cts +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +6 -6
- package/dist/resolveModelVendor-B0t5nq-v.d.cts +22 -0
- package/dist/{resolveModelVendor--2JdUZlR.d.ts → resolveModelVendor-DQpJpk0w.d.ts} +1 -1
- package/dist/{resolveModelVendor-BPPvzxE8.d.cts → resolveModelVendor-XvmXsVzo.d.cts} +1 -1
- package/dist/resolveModelVendor-uphYBFMY.d.ts +22 -0
- package/dist/sync/index.cjs +10 -4
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.js +9 -3
- package/package.json +2 -2
- package/dist/chunk-5XBMNY7Q.cjs.map +0 -1
- package/dist/chunk-EBBJCLJQ.js +0 -29
- package/dist/chunk-EBBJCLJQ.js.map +0 -1
- package/dist/chunk-FISSYP27.cjs +0 -29
- package/dist/chunk-FISSYP27.cjs.map +0 -1
- package/dist/chunk-TDO5SDQ3.cjs.map +0 -1
- package/dist/chunk-TMDWPWKB.cjs +0 -123
- package/dist/chunk-TMDWPWKB.cjs.map +0 -1
- package/dist/chunk-VYVX46VO.js.map +0 -1
- package/dist/chunk-XMOALOYU.js.map +0 -1
- package/dist/resolveModelVendor-Dd4N6Vds.d.cts +0 -16
- package/dist/resolveModelVendor-oKeiH9ig.d.ts +0 -16
- /package/dist/{chunk-WFRS32EQ.js.map → chunk-5RW5ARLO.js.map} +0 -0
- /package/dist/{chunk-25O27USJ.js.map → chunk-7VGEQTJA.js.map} +0 -0
- /package/dist/{chunk-4AIEM4AE.js.map → chunk-DSDN65JH.js.map} +0 -0
- /package/dist/{chunk-SYHLDADG.js.map → chunk-OB44D7RG.js.map} +0 -0
- /package/dist/{chunk-ET5LPVPT.js.map → chunk-TZHPZGDB.js.map} +0 -0
package/dist/catalog/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkRVQPQI63cjs = require('../chunk-RVQPQI63.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -15,10 +15,10 @@ var _chunkI6CDT2NGcjs = require('../chunk-I6CDT2NG.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
require('../chunk-
|
|
18
|
+
var _chunkUY2VLJN6cjs = require('../chunk-UY2VLJN6.cjs');
|
|
19
|
+
require('../chunk-GNOZFRKR.cjs');
|
|
20
20
|
require('../chunk-2KPWVOOT.cjs');
|
|
21
|
-
require('../chunk-
|
|
21
|
+
require('../chunk-OZE336BL.cjs');
|
|
22
22
|
require('../chunk-PADNCGZB.cjs');
|
|
23
23
|
require('../chunk-GS7T56RP.cjs');
|
|
24
24
|
|
|
@@ -36,5 +36,5 @@ require('../chunk-GS7T56RP.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
exports.AiModelsCatalogClient =
|
|
39
|
+
exports.AiModelsCatalogClient = _chunkUY2VLJN6cjs.AiModelsCatalogClient; exports.DEFAULT_CATALOG_CACHE_TTL_MS = _chunkUY2VLJN6cjs.DEFAULT_CATALOG_CACHE_TTL_MS; exports.DEFAULT_DIRECT_CATALOG_URL = _chunkUY2VLJN6cjs.DEFAULT_DIRECT_CATALOG_URL; exports.DEFAULT_OPENROUTER_CATALOG_URL = _chunkUY2VLJN6cjs.DEFAULT_OPENROUTER_CATALOG_URL; exports.canonicalCatalogModelId = _chunkUY2VLJN6cjs.canonicalCatalogModelId; exports.invalidateCatalogLoadCache = _chunkUY2VLJN6cjs.invalidateCatalogLoadCache; exports.loadCatalogSources = _chunkUY2VLJN6cjs.loadCatalogSources; exports.loadCatalogSourcesCached = _chunkUY2VLJN6cjs.loadCatalogSourcesCached; exports.modelsFromX12iCatalogFile = _chunkUY2VLJN6cjs.modelsFromX12iCatalogFile; exports.normalizeX12iCatalogModel = _chunkUY2VLJN6cjs.normalizeX12iCatalogModel; exports.readBundledCatalogFiles = _chunkUY2VLJN6cjs.readBundledCatalogFiles; exports.refreshAiModelsCatalog = _chunkRVQPQI63cjs.refreshAiModelsCatalog; exports.resolveCatalogCacheTtlMs = _chunkUY2VLJN6cjs.resolveCatalogCacheTtlMs; exports.verifyAiModelsCatalog = _chunkRVQPQI63cjs.verifyAiModelsCatalog;
|
|
40
40
|
//# sourceMappingURL=index.cjs.map
|
package/dist/catalog/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
refreshAiModelsCatalog,
|
|
3
3
|
verifyAiModelsCatalog
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-7VGEQTJA.js";
|
|
5
5
|
import {
|
|
6
6
|
AiModelsCatalogClient,
|
|
7
7
|
DEFAULT_CATALOG_CACHE_TTL_MS,
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
normalizeX12iCatalogModel,
|
|
16
16
|
readBundledCatalogFiles,
|
|
17
17
|
resolveCatalogCacheTtlMs
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-TZHPZGDB.js";
|
|
19
|
+
import "../chunk-RNSXRGIA.js";
|
|
20
20
|
import "../chunk-SQ6NOF4Z.js";
|
|
21
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-OB44D7RG.js";
|
|
22
22
|
import "../chunk-2PTCWPHV.js";
|
|
23
23
|
export {
|
|
24
24
|
AiModelsCatalogClient,
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ModelNameResolver,
|
|
3
3
|
PROVIDER_INFERENCE_MAP,
|
|
4
|
-
modelSlug,
|
|
5
4
|
normalizeProvider,
|
|
6
5
|
normalizeString
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OB44D7RG.js";
|
|
8
7
|
|
|
9
8
|
// src/sync/modelNameResolver/resolveModelVendor.ts
|
|
9
|
+
import {
|
|
10
|
+
buildModelInvocation,
|
|
11
|
+
buildOpenRouterModelId,
|
|
12
|
+
resolveModelIdentity
|
|
13
|
+
} from "@x12i/ai-profiles";
|
|
10
14
|
function isOpenRouterProvider(provider) {
|
|
11
15
|
return normalizeProvider(provider) === "openrouter";
|
|
12
16
|
}
|
|
@@ -30,6 +34,33 @@ function buildVendorResolveAttempts(model) {
|
|
|
30
34
|
add(model, "openrouter");
|
|
31
35
|
return attempts;
|
|
32
36
|
}
|
|
37
|
+
function endpointToRef(endpoint) {
|
|
38
|
+
return { provider: endpoint.provider, model: endpoint.modelId };
|
|
39
|
+
}
|
|
40
|
+
function invocationToRef(providerHint, modelId, options) {
|
|
41
|
+
const invocation = buildModelInvocation(providerHint, normalizeString(modelId));
|
|
42
|
+
if (options?.asOpenRouter) {
|
|
43
|
+
return endpointToRef(
|
|
44
|
+
invocation.openrouter ?? {
|
|
45
|
+
provider: "openrouter",
|
|
46
|
+
modelId: buildOpenRouterModelId(providerHint, modelId)
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return endpointToRef(invocation.direct);
|
|
51
|
+
}
|
|
52
|
+
function fromAiProfilesIdentity(ref) {
|
|
53
|
+
return { provider: ref.provider, model: ref.modelId };
|
|
54
|
+
}
|
|
55
|
+
function modelVendorRefFromIdentity(model, options) {
|
|
56
|
+
const identity = resolveModelIdentity(model, {
|
|
57
|
+
asOpenRouter: options?.asOpenRouter
|
|
58
|
+
});
|
|
59
|
+
return identity ? fromAiProfilesIdentity(identity) : null;
|
|
60
|
+
}
|
|
61
|
+
function modelVendorRefFromVendorAndSlug(providerHint, modelId, options) {
|
|
62
|
+
return invocationToRef(providerHint, modelId, options);
|
|
63
|
+
}
|
|
33
64
|
function inferProviderFromSlug(slug, options) {
|
|
34
65
|
const patterns = [
|
|
35
66
|
...options?.additionalProviderPatterns ?? [],
|
|
@@ -40,30 +71,29 @@ function inferProviderFromSlug(slug, options) {
|
|
|
40
71
|
}
|
|
41
72
|
return void 0;
|
|
42
73
|
}
|
|
43
|
-
function
|
|
74
|
+
function providerHintForModelId(modelId, record, options) {
|
|
44
75
|
if (record?.providerId) {
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
76
|
+
const vendor = normalizeProvider(record.providerId);
|
|
77
|
+
if (vendor && !isOpenRouterProvider(vendor)) return vendor;
|
|
47
78
|
}
|
|
48
79
|
const normalised = normalizeString(modelId);
|
|
49
80
|
if (normalised.includes("/")) {
|
|
50
81
|
const prefix = normalised.split("/")[0];
|
|
51
82
|
if (!isOpenRouterProvider(prefix)) {
|
|
52
|
-
return normalizeProvider(prefix);
|
|
83
|
+
return normalizeProvider(prefix) ?? prefix;
|
|
53
84
|
}
|
|
54
85
|
}
|
|
55
|
-
return inferProviderFromSlug(
|
|
86
|
+
return inferProviderFromSlug(normalised, options);
|
|
56
87
|
}
|
|
57
88
|
function formatModelVendorRef(modelId, record, options) {
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return { provider: vendor, model: slug };
|
|
89
|
+
const hint = providerHintForModelId(modelId, record, options);
|
|
90
|
+
if (!hint) return null;
|
|
91
|
+
return invocationToRef(hint, modelId, options);
|
|
92
|
+
}
|
|
93
|
+
function resolveModelVendorLastResort(model, options) {
|
|
94
|
+
const hint = providerHintForModelId(model, null, options);
|
|
95
|
+
if (!hint) return null;
|
|
96
|
+
return invocationToRef(hint, model, options);
|
|
67
97
|
}
|
|
68
98
|
function resolveModelVendorFromResolution(result, inputModel, options) {
|
|
69
99
|
if (result.found) {
|
|
@@ -74,24 +104,11 @@ function resolveModelVendorFromResolution(result, inputModel, options) {
|
|
|
74
104
|
const ref = formatModelVendorRef(result.bestRejectedCandidate.modelId, null, options);
|
|
75
105
|
if (ref) return ref;
|
|
76
106
|
}
|
|
77
|
-
|
|
78
|
-
let slug = normalised;
|
|
79
|
-
let vendor;
|
|
80
|
-
if (normalised.includes("/")) {
|
|
81
|
-
const [prefix, ...rest] = normalised.split("/");
|
|
82
|
-
if (!isOpenRouterProvider(prefix)) {
|
|
83
|
-
vendor = normalizeProvider(prefix);
|
|
84
|
-
slug = rest.join("/");
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
vendor ??= inferProviderFromSlug(slug, options);
|
|
88
|
-
if (!vendor) return null;
|
|
89
|
-
if (options?.asOpenRouter) {
|
|
90
|
-
return { provider: "openrouter", model: `${vendor}/${slug}` };
|
|
91
|
-
}
|
|
92
|
-
return { provider: vendor, model: slug };
|
|
107
|
+
return resolveModelVendorLastResort(inputModel, options);
|
|
93
108
|
}
|
|
94
109
|
function resolveModelVendorSync(model, catalog, options) {
|
|
110
|
+
const exact = modelVendorRefFromIdentity(model, options);
|
|
111
|
+
if (exact) return exact;
|
|
95
112
|
const resolver = new ModelNameResolver(catalog, options);
|
|
96
113
|
const attempts = buildVendorResolveAttempts(model);
|
|
97
114
|
let last = null;
|
|
@@ -117,7 +134,10 @@ function resolveModelVendorSync(model, catalog, options) {
|
|
|
117
134
|
}
|
|
118
135
|
|
|
119
136
|
export {
|
|
137
|
+
modelVendorRefFromIdentity,
|
|
138
|
+
modelVendorRefFromVendorAndSlug,
|
|
139
|
+
resolveModelVendorLastResort,
|
|
120
140
|
resolveModelVendorFromResolution,
|
|
121
141
|
resolveModelVendorSync
|
|
122
142
|
};
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
//# sourceMappingURL=chunk-4ILJWO64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sync/modelNameResolver/resolveModelVendor.ts"],"sourcesContent":["import {\n buildModelInvocation,\n buildOpenRouterModelId,\n resolveModelIdentity,\n} from \"@x12i/ai-profiles\";\nimport type { ModelInvocationEndpoint } from \"@x12i/ai-profiles\";\nimport type { AiModelRecord } from \"../../models/types.js\";\nimport { ModelNameResolver } from \"./ModelNameResolver.js\";\nimport { PROVIDER_INFERENCE_MAP } from \"./constants.js\";\nimport { normalizeProvider, normalizeString } from \"./normalize.js\";\nimport type {\n ModelResolutionInput,\n ModelResolutionResult,\n ModelResolverOptions,\n} from \"./types.js\";\n\nfunction isOpenRouterProvider(provider?: string): boolean {\n return normalizeProvider(provider) === \"openrouter\";\n}\n\nfunction buildVendorResolveAttempts(model: string): 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, undefined);\n\n const normalised = normalizeString(model);\n if (normalised.includes(\"/\")) {\n const prefix = normalised.split(\"/\")[0]!;\n if (!isOpenRouterProvider(prefix)) {\n add(model, normalizeProvider(prefix));\n }\n }\n\n add(model, \"openrouter\");\n return attempts;\n}\n\nexport type ModelVendorRef = {\n provider: string;\n model: string;\n};\n\nexport type ResolveModelVendorOptions = ModelResolverOptions & {\n /** Return OpenRouter transport shape: provider `openrouter`, model `vendor/slug`. */\n asOpenRouter?: boolean;\n};\n\nfunction endpointToRef(endpoint: ModelInvocationEndpoint): ModelVendorRef {\n return { provider: endpoint.provider, model: endpoint.modelId };\n}\n\nfunction invocationToRef(\n providerHint: string,\n modelId: string,\n options?: ResolveModelVendorOptions,\n): ModelVendorRef {\n const invocation = buildModelInvocation(providerHint, normalizeString(modelId));\n if (options?.asOpenRouter) {\n return endpointToRef(\n invocation.openrouter ?? {\n provider: \"openrouter\",\n modelId: buildOpenRouterModelId(providerHint, modelId),\n },\n );\n }\n return endpointToRef(invocation.direct);\n}\n\nfunction fromAiProfilesIdentity(\n ref: NonNullable<ReturnType<typeof resolveModelIdentity>>,\n): ModelVendorRef {\n return { provider: ref.provider, model: ref.modelId };\n}\n\n/** Exact registry / bundled-catalog lookup via @x12i/ai-profiles. */\nexport function modelVendorRefFromIdentity(\n model: string,\n options?: ResolveModelVendorOptions,\n): ModelVendorRef | null {\n const identity = resolveModelIdentity(model, {\n asOpenRouter: options?.asOpenRouter,\n });\n return identity ? fromAiProfilesIdentity(identity) : null;\n}\n\n/** Build `{ provider, model }` using @x12i/ai-profiles transport mapping. */\nexport function modelVendorRefFromVendorAndSlug(\n providerHint: string,\n modelId: string,\n options?: ResolveModelVendorOptions,\n): ModelVendorRef {\n return invocationToRef(providerHint, modelId, options);\n}\n\nfunction inferProviderFromSlug(\n slug: string,\n options?: ResolveModelVendorOptions,\n): string | undefined {\n const patterns = [\n ...(options?.additionalProviderPatterns ?? []),\n ...PROVIDER_INFERENCE_MAP,\n ];\n for (const { pattern, provider } of patterns) {\n if (pattern.test(slug)) return provider;\n }\n return undefined;\n}\n\nfunction providerHintForModelId(\n modelId: string,\n record: AiModelRecord | null | undefined,\n options?: ResolveModelVendorOptions,\n): string | undefined {\n if (record?.providerId) {\n const vendor = normalizeProvider(record.providerId);\n if (vendor && !isOpenRouterProvider(vendor)) return vendor;\n }\n\n const normalised = normalizeString(modelId);\n if (normalised.includes(\"/\")) {\n const prefix = normalised.split(\"/\")[0]!;\n if (!isOpenRouterProvider(prefix)) {\n return normalizeProvider(prefix) ?? prefix;\n }\n }\n\n return inferProviderFromSlug(normalised, options);\n}\n\nfunction formatModelVendorRef(\n modelId: string,\n record: AiModelRecord | null | undefined,\n options?: ResolveModelVendorOptions,\n): ModelVendorRef | null {\n const hint = providerHintForModelId(modelId, record, options);\n if (!hint) return null;\n return invocationToRef(hint, modelId, options);\n}\n\n/** Pattern inference when registry and catalog both miss. */\nexport function resolveModelVendorLastResort(\n model: string,\n options?: ResolveModelVendorOptions,\n): ModelVendorRef | null {\n const hint = providerHintForModelId(model, null, options);\n if (!hint) return null;\n return invocationToRef(hint, model, options);\n}\n\n/** Map a fuzzy catalog resolution result to `{ provider, model }`. */\nexport function resolveModelVendorFromResolution(\n result: ModelResolutionResult,\n inputModel: string,\n options?: ResolveModelVendorOptions,\n): ModelVendorRef | null {\n if (result.found) {\n const ref = formatModelVendorRef(result.modelId, result.record, options);\n if (ref) return ref;\n }\n\n if (!result.found && result.bestRejectedCandidate) {\n const ref = formatModelVendorRef(result.bestRejectedCandidate.modelId, null, options);\n if (ref) return ref;\n }\n\n return resolveModelVendorLastResort(inputModel, options);\n}\n\n/** Best-effort vendor lookup from a model name alone (sync, catalog map only). */\nexport function resolveModelVendorSync(\n model: string,\n catalog: Map<string, AiModelRecord>,\n options?: ResolveModelVendorOptions,\n): ModelVendorRef | null {\n const exact = modelVendorRefFromIdentity(model, options);\n if (exact) return exact;\n\n const resolver = new ModelNameResolver(catalog, options);\n const attempts = buildVendorResolveAttempts(model);\n let last: ModelResolutionResult | null = null;\n\n for (const attempt of attempts) {\n const result = resolver.resolve(attempt);\n last = result;\n if (result.found) {\n const ref = resolveModelVendorFromResolution(result, model, options);\n if (ref) return ref;\n }\n }\n\n return resolveModelVendorFromResolution(\n last ?? {\n found: false,\n modelId: null,\n record: null,\n attemptedStrategies: [],\n reason: \"Model not found in catalog\",\n },\n model,\n options,\n );\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveModelVendor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UQ4NSEXF.js";
|
|
4
4
|
import {
|
|
5
5
|
AiModelsCatalogClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TZHPZGDB.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-5RW5ARLO.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
DEFAULT_DIRECT_CATALOG_URL,
|
|
4
4
|
DEFAULT_OPENROUTER_CATALOG_URL,
|
|
5
5
|
loadCatalogSourcesCached
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TZHPZGDB.js";
|
|
7
7
|
|
|
8
8
|
// src/catalog/catalogMaintenance.ts
|
|
9
9
|
async function refreshAiModelsCatalog(options = {}) {
|
|
@@ -43,4 +43,4 @@ export {
|
|
|
43
43
|
refreshAiModelsCatalog,
|
|
44
44
|
verifyAiModelsCatalog
|
|
45
45
|
};
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-7VGEQTJA.js.map
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
matchModelInAiProfiles,
|
|
6
6
|
resolveFromCatalogAttempts,
|
|
7
7
|
resolveRoutedViaOpenRouter
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RNSXRGIA.js";
|
|
9
9
|
import {
|
|
10
10
|
normalizeString,
|
|
11
11
|
stripModelVersionSuffix
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OB44D7RG.js";
|
|
13
13
|
import {
|
|
14
14
|
UnknownModelCostError
|
|
15
15
|
} from "./chunk-2PTCWPHV.js";
|
|
@@ -702,4 +702,4 @@ export {
|
|
|
702
702
|
resolveUsageModel,
|
|
703
703
|
CostCalculator
|
|
704
704
|
};
|
|
705
|
-
//# sourceMappingURL=chunk-
|
|
705
|
+
//# sourceMappingURL=chunk-DSDN65JH.js.map
|
|
@@ -5,18 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
8
|
+
var _chunkOZE336BLcjs = require('./chunk-OZE336BL.cjs');
|
|
12
9
|
|
|
13
10
|
// src/cost/costModelResolution.ts
|
|
14
11
|
function isOpenRouterProvider(provider) {
|
|
15
|
-
return
|
|
12
|
+
return _chunkOZE336BLcjs.normalizeProvider.call(void 0, provider) === "openrouter";
|
|
16
13
|
}
|
|
17
14
|
function isLocalProvider(provider) {
|
|
18
|
-
const p = _nullishCoalesce(
|
|
19
|
-
return
|
|
15
|
+
const p = _nullishCoalesce(_chunkOZE336BLcjs.normalizeProvider.call(void 0, provider), () => ( _chunkOZE336BLcjs.normalizeString.call(void 0, _nullishCoalesce(provider, () => ( "")))));
|
|
16
|
+
return _chunkOZE336BLcjs.LOCAL_PROVIDERS.has(p);
|
|
20
17
|
}
|
|
21
18
|
function isLocalProviderResolution(resolved, inputProvider) {
|
|
22
19
|
if (!_optionalChain([resolved, 'optionalAccess', _ => _.found]) || resolved.record) return false;
|
|
@@ -24,13 +21,13 @@ function isLocalProviderResolution(resolved, inputProvider) {
|
|
|
24
21
|
return isLocalProvider(inputProvider);
|
|
25
22
|
}
|
|
26
23
|
function underlyingProviderFromModel(model, providerHint) {
|
|
27
|
-
const normalized =
|
|
24
|
+
const normalized = _chunkOZE336BLcjs.normalizeString.call(void 0, model);
|
|
28
25
|
if (normalized.includes("/")) {
|
|
29
26
|
const prefix = normalized.split("/")[0];
|
|
30
27
|
if (!isOpenRouterProvider(prefix)) return prefix;
|
|
31
28
|
}
|
|
32
29
|
if (providerHint && !isOpenRouterProvider(providerHint)) {
|
|
33
|
-
return
|
|
30
|
+
return _chunkOZE336BLcjs.normalizeProvider.call(void 0, providerHint);
|
|
34
31
|
}
|
|
35
32
|
return void 0;
|
|
36
33
|
}
|
|
@@ -38,13 +35,13 @@ function providerHintForProfiles(model, provider) {
|
|
|
38
35
|
if (isOpenRouterProvider(provider)) {
|
|
39
36
|
return underlyingProviderFromModel(model, provider);
|
|
40
37
|
}
|
|
41
|
-
return
|
|
38
|
+
return _chunkOZE336BLcjs.normalizeProvider.call(void 0, provider);
|
|
42
39
|
}
|
|
43
40
|
function buildCatalogResolveAttempts(model, provider) {
|
|
44
41
|
const attempts = [];
|
|
45
42
|
const seen = /* @__PURE__ */ new Set();
|
|
46
43
|
const add = (m, p) => {
|
|
47
|
-
const key = `${_nullishCoalesce(p, () => ( ""))}\0${
|
|
44
|
+
const key = `${_nullishCoalesce(p, () => ( ""))}\0${_chunkOZE336BLcjs.normalizeString.call(void 0, m)}`;
|
|
48
45
|
if (seen.has(key)) return;
|
|
49
46
|
seen.add(key);
|
|
50
47
|
attempts.push({ model: m, provider: p });
|
|
@@ -72,7 +69,7 @@ async function resolveFromCatalogAttempts(catalog, attempts, options) {
|
|
|
72
69
|
return _nullishCoalesce(localPassthrough, () => ( last));
|
|
73
70
|
}
|
|
74
71
|
function resolveRoutedViaOpenRouter(inputProvider, resolved, modelId, routingEnv) {
|
|
75
|
-
const env = _nullishCoalesce(routingEnv, () => (
|
|
72
|
+
const env = _nullishCoalesce(routingEnv, () => ( _chunkOZE336BLcjs.loadOpenRouterRoutingEnv.call(void 0, )));
|
|
76
73
|
if (isOpenRouterProvider(inputProvider)) return true;
|
|
77
74
|
if (_optionalChain([resolved, 'optionalAccess', _2 => _2.found])) {
|
|
78
75
|
return resolved.routedViaOpenRouter;
|
|
@@ -81,30 +78,29 @@ function resolveRoutedViaOpenRouter(inputProvider, resolved, modelId, routingEnv
|
|
|
81
78
|
_nullishCoalesce(_nullishCoalesce(modelId, () => ( (_optionalChain([resolved, 'optionalAccess', _3 => _3.found]) ? resolved.modelId : ""))), () => ( "")),
|
|
82
79
|
inputProvider
|
|
83
80
|
);
|
|
84
|
-
if (vendor &&
|
|
81
|
+
if (vendor && _chunkOZE336BLcjs.shouldDefaultRouteViaOpenRouter.call(void 0, vendor, env)) {
|
|
85
82
|
return true;
|
|
86
83
|
}
|
|
87
84
|
return false;
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
// src/cost/aiProfilesMatch.ts
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
93
96
|
var _aiprofiles = require('@x12i/ai-profiles');
|
|
94
|
-
var require2 = _module.createRequire.call(void 0, _chunkGS7T56RPcjs.importMetaUrl);
|
|
95
|
-
function loadProfilesRegistry() {
|
|
96
|
-
const entry = _path.dirname.call(void 0, require2.resolve("@x12i/ai-profiles"));
|
|
97
|
-
const loader = require2(_path.join.call(void 0, entry, "loader/loadAIProfilesRegistry.js"));
|
|
98
|
-
return loader.loadAIProfilesRegistry({ source: "auto" });
|
|
99
|
-
}
|
|
100
97
|
function profileKey(value) {
|
|
101
98
|
return value.trim().toLowerCase();
|
|
102
99
|
}
|
|
103
100
|
function canonicalModelId(provider, modelId) {
|
|
104
|
-
const normalized =
|
|
101
|
+
const normalized = _chunkOZE336BLcjs.normalizeString.call(void 0, modelId);
|
|
105
102
|
if (normalized.includes("/")) return normalized;
|
|
106
|
-
|
|
107
|
-
return `${p}/${normalized}`;
|
|
103
|
+
return _aiprofiles.buildOpenRouterModelId.call(void 0, provider, normalized);
|
|
108
104
|
}
|
|
109
105
|
var cachedIndex = null;
|
|
110
106
|
function indexRegistry(registry) {
|
|
@@ -124,25 +120,27 @@ function indexRegistry(registry) {
|
|
|
124
120
|
for (const profile of Object.values(registry.profiles)) {
|
|
125
121
|
for (const [choiceKey, choice] of Object.entries(profile.choices)) {
|
|
126
122
|
const entry = choiceEntry(choice, profile.profile, choiceKey);
|
|
127
|
-
add(
|
|
128
|
-
add(canonicalModelId(choice.provider, choice
|
|
123
|
+
add(_aiprofiles.getChoiceVendorModelId.call(void 0, choice), entry);
|
|
124
|
+
add(canonicalModelId(choice.provider, _aiprofiles.getChoiceVendorModelId.call(void 0, choice)), entry);
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
return byKey;
|
|
132
128
|
}
|
|
133
129
|
function choiceEntry(choice, profile, choiceKey) {
|
|
134
|
-
const
|
|
130
|
+
const vendorModelId = _aiprofiles.getChoiceVendorModelId.call(void 0, choice);
|
|
131
|
+
const provider = _nullishCoalesce(_chunkOZE336BLcjs.normalizeProvider.call(void 0, choice.provider), () => ( choice.provider));
|
|
132
|
+
const canonical = _nullishCoalesce(_aiprofiles.getChoiceOpenRouterModelId.call(void 0, choice), () => ( canonicalModelId(choice.provider, vendorModelId)));
|
|
135
133
|
return {
|
|
136
|
-
provider
|
|
137
|
-
modelId:
|
|
134
|
+
provider,
|
|
135
|
+
modelId: _chunkOZE336BLcjs.normalizeString.call(void 0, vendorModelId),
|
|
138
136
|
canonicalModelId: canonical,
|
|
139
|
-
pricing:
|
|
137
|
+
pricing: _aiprofiles.getChoicePricing.call(void 0, choice),
|
|
140
138
|
profile,
|
|
141
139
|
choice: choiceKey
|
|
142
140
|
};
|
|
143
141
|
}
|
|
144
142
|
async function getProfileIndex() {
|
|
145
|
-
const registry = await
|
|
143
|
+
const registry = await _aiprofiles.loadAIProfilesRegistry.call(void 0, { source: "auto" });
|
|
146
144
|
const cacheKey = `${registry.version}:${_nullishCoalesce(registry.generatedAt, () => ( ""))}:${registry.source}`;
|
|
147
145
|
if (_optionalChain([cachedIndex, 'optionalAccess', _4 => _4.cacheKey]) === cacheKey) {
|
|
148
146
|
return cachedIndex.byKey;
|
|
@@ -152,7 +150,7 @@ async function getProfileIndex() {
|
|
|
152
150
|
return byKey;
|
|
153
151
|
}
|
|
154
152
|
function scoreCandidate(entry, model, providerHint) {
|
|
155
|
-
const normalized =
|
|
153
|
+
const normalized = _chunkOZE336BLcjs.normalizeString.call(void 0, model);
|
|
156
154
|
let score = 0;
|
|
157
155
|
if (normalized === entry.canonicalModelId) score += 100;
|
|
158
156
|
if (normalized === entry.modelId) score += 80;
|
|
@@ -176,10 +174,12 @@ function pickBest(candidates, model, providerHint) {
|
|
|
176
174
|
return best;
|
|
177
175
|
}
|
|
178
176
|
function resolvedToMatch(resolved) {
|
|
177
|
+
const direct = resolved.invocation.direct;
|
|
178
|
+
const canonical = _nullishCoalesce(_optionalChain([resolved, 'access', _5 => _5.invocation, 'access', _6 => _6.openrouter, 'optionalAccess', _7 => _7.modelId]), () => ( _aiprofiles.buildOpenRouterModelId.call(void 0, direct.provider, direct.modelId)));
|
|
179
179
|
return {
|
|
180
|
-
provider: _nullishCoalesce(
|
|
181
|
-
modelId:
|
|
182
|
-
canonicalModelId:
|
|
180
|
+
provider: _nullishCoalesce(_chunkOZE336BLcjs.normalizeProvider.call(void 0, direct.provider), () => ( direct.provider)),
|
|
181
|
+
modelId: _chunkOZE336BLcjs.normalizeString.call(void 0, direct.modelId),
|
|
182
|
+
canonicalModelId: canonical,
|
|
183
183
|
pricing: resolved.pricing,
|
|
184
184
|
instructionTier: resolved.instructionTier,
|
|
185
185
|
backend: resolved.backend,
|
|
@@ -190,10 +190,11 @@ function resolvedToMatch(resolved) {
|
|
|
190
190
|
}
|
|
191
191
|
async function fromIndexed(entry) {
|
|
192
192
|
const resolved = await _aiprofiles.resolveAIProfile.call(void 0, entry.profile, { choice: entry.choice });
|
|
193
|
+
const direct = resolved.invocation.direct;
|
|
193
194
|
return {
|
|
194
|
-
provider: _nullishCoalesce(
|
|
195
|
-
modelId:
|
|
196
|
-
canonicalModelId:
|
|
195
|
+
provider: _nullishCoalesce(_chunkOZE336BLcjs.normalizeProvider.call(void 0, direct.provider), () => ( direct.provider)),
|
|
196
|
+
modelId: _chunkOZE336BLcjs.normalizeString.call(void 0, direct.modelId),
|
|
197
|
+
canonicalModelId: _nullishCoalesce(_optionalChain([resolved, 'access', _8 => _8.invocation, 'access', _9 => _9.openrouter, 'optionalAccess', _10 => _10.modelId]), () => ( _aiprofiles.buildOpenRouterModelId.call(void 0, direct.provider, direct.modelId))),
|
|
197
198
|
pricing: _nullishCoalesce(resolved.pricing, () => ( entry.pricing)),
|
|
198
199
|
instructionTier: resolved.instructionTier,
|
|
199
200
|
backend: resolved.backend,
|
|
@@ -203,10 +204,10 @@ async function fromIndexed(entry) {
|
|
|
203
204
|
};
|
|
204
205
|
}
|
|
205
206
|
async function lookupInIndex(index, model, provider) {
|
|
206
|
-
const providerHint = provider ?
|
|
207
|
+
const providerHint = provider ? _chunkOZE336BLcjs.normalizeProvider.call(void 0, provider) : void 0;
|
|
207
208
|
const keys = [
|
|
208
209
|
profileKey(model),
|
|
209
|
-
profileKey(
|
|
210
|
+
profileKey(_chunkOZE336BLcjs.normalizeString.call(void 0, model))
|
|
210
211
|
];
|
|
211
212
|
if (providerHint) {
|
|
212
213
|
keys.push(profileKey(canonicalModelId(providerHint, model)));
|
|
@@ -216,7 +217,7 @@ async function lookupInIndex(index, model, provider) {
|
|
|
216
217
|
const hits = index.get(key);
|
|
217
218
|
if (hits) pooled.push(...hits);
|
|
218
219
|
}
|
|
219
|
-
const bare =
|
|
220
|
+
const bare = _chunkOZE336BLcjs.normalizeString.call(void 0, model);
|
|
220
221
|
if (!bare.includes("/")) {
|
|
221
222
|
for (const list of index.values()) {
|
|
222
223
|
for (const entry of list) {
|
|
@@ -244,8 +245,8 @@ async function matchModelInAiProfiles(model, provider) {
|
|
|
244
245
|
const hint = providerHintForProfiles(model, provider);
|
|
245
246
|
const direct = await lookupInIndex(index, model, hint);
|
|
246
247
|
if (direct) return direct;
|
|
247
|
-
const stripped =
|
|
248
|
-
if (stripped && stripped !==
|
|
248
|
+
const stripped = _chunkOZE336BLcjs.stripModelVersionSuffix.call(void 0, model);
|
|
249
|
+
if (stripped && stripped !== _chunkOZE336BLcjs.normalizeString.call(void 0, model)) {
|
|
249
250
|
return lookupInIndex(
|
|
250
251
|
index,
|
|
251
252
|
stripped,
|
|
@@ -263,4 +264,4 @@ async function matchModelInAiProfiles(model, provider) {
|
|
|
263
264
|
|
|
264
265
|
|
|
265
266
|
exports.isLocalProvider = isLocalProvider; exports.isLocalProviderResolution = isLocalProviderResolution; exports.buildCatalogResolveAttempts = buildCatalogResolveAttempts; exports.resolveFromCatalogAttempts = resolveFromCatalogAttempts; exports.resolveRoutedViaOpenRouter = resolveRoutedViaOpenRouter; exports.matchModelInAiProfiles = matchModelInAiProfiles;
|
|
266
|
-
//# sourceMappingURL=chunk-
|
|
267
|
+
//# sourceMappingURL=chunk-GNOZFRKR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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":"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","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"]}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkGNOZFRKRcjs = require('./chunk-GNOZFRKR.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkOZE336BLcjs = require('./chunk-OZE336BL.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
var _chunkPADNCGZBcjs = require('./chunk-PADNCGZB.cjs');
|
|
@@ -497,29 +497,29 @@ var CostCalculator = class {
|
|
|
497
497
|
...this.resolverOptions,
|
|
498
498
|
aliasRegistry: _nullishCoalesce(this.aliasRegistry, () => ( _optionalChain([this, 'access', _11 => _11.resolverOptions, 'optionalAccess', _12 => _12.aliasRegistry])))
|
|
499
499
|
};
|
|
500
|
-
let resolved = await
|
|
500
|
+
let resolved = await _chunkGNOZFRKRcjs.resolveFromCatalogAttempts.call(void 0,
|
|
501
501
|
this.catalog,
|
|
502
|
-
|
|
502
|
+
_chunkGNOZFRKRcjs.buildCatalogResolveAttempts.call(void 0, modelInput, input.provider),
|
|
503
503
|
resolverOpts
|
|
504
504
|
);
|
|
505
|
-
if (
|
|
505
|
+
if (_chunkGNOZFRKRcjs.isLocalProviderResolution.call(void 0, resolved, input.provider)) {
|
|
506
506
|
return this.localProviderResult(modelInput, input, resolved);
|
|
507
507
|
}
|
|
508
508
|
let profileMatch = null;
|
|
509
509
|
const warnings = [];
|
|
510
510
|
if (!_optionalChain([resolved, 'optionalAccess', _13 => _13.found]) || !resolved.record) {
|
|
511
|
-
if (!
|
|
512
|
-
profileMatch = await
|
|
511
|
+
if (!_chunkGNOZFRKRcjs.isLocalProvider.call(void 0, input.provider)) {
|
|
512
|
+
profileMatch = await _chunkGNOZFRKRcjs.matchModelInAiProfiles.call(void 0, modelInput, input.provider);
|
|
513
513
|
}
|
|
514
514
|
if (profileMatch) {
|
|
515
|
-
resolved = await
|
|
515
|
+
resolved = await _chunkGNOZFRKRcjs.resolveFromCatalogAttempts.call(void 0,
|
|
516
516
|
this.catalog,
|
|
517
517
|
mergeAttempts(
|
|
518
|
-
|
|
518
|
+
_chunkGNOZFRKRcjs.buildCatalogResolveAttempts.call(void 0,
|
|
519
519
|
profileMatch.canonicalModelId,
|
|
520
520
|
_nullishCoalesce(input.provider, () => ( profileMatch.provider))
|
|
521
521
|
),
|
|
522
|
-
|
|
522
|
+
_chunkGNOZFRKRcjs.buildCatalogResolveAttempts.call(void 0,
|
|
523
523
|
profileMatch.canonicalModelId,
|
|
524
524
|
profileMatch.provider
|
|
525
525
|
)
|
|
@@ -527,11 +527,11 @@ var CostCalculator = class {
|
|
|
527
527
|
resolverOpts
|
|
528
528
|
);
|
|
529
529
|
}
|
|
530
|
-
if (
|
|
530
|
+
if (_chunkGNOZFRKRcjs.isLocalProviderResolution.call(void 0, resolved, input.provider)) {
|
|
531
531
|
return this.localProviderResult(modelInput, input, resolved);
|
|
532
532
|
}
|
|
533
533
|
if ((!_optionalChain([resolved, 'optionalAccess', _14 => _14.found]) || !resolved.record) && _optionalChain([profileMatch, 'optionalAccess', _15 => _15.pricing])) {
|
|
534
|
-
const routedViaOpenRouter2 =
|
|
534
|
+
const routedViaOpenRouter2 = _chunkGNOZFRKRcjs.resolveRoutedViaOpenRouter.call(void 0,
|
|
535
535
|
input.provider,
|
|
536
536
|
resolved,
|
|
537
537
|
profileMatch.canonicalModelId,
|
|
@@ -582,7 +582,7 @@ var CostCalculator = class {
|
|
|
582
582
|
return this.unknownModelResult(modelInput, input, resolved);
|
|
583
583
|
}
|
|
584
584
|
const { record, modelId } = resolved;
|
|
585
|
-
const routedViaOpenRouter =
|
|
585
|
+
const routedViaOpenRouter = _chunkGNOZFRKRcjs.resolveRoutedViaOpenRouter.call(void 0,
|
|
586
586
|
input.provider,
|
|
587
587
|
resolved,
|
|
588
588
|
modelId,
|
|
@@ -612,14 +612,14 @@ var CostCalculator = class {
|
|
|
612
612
|
versionSuffixWarnings(input, pricedModelId, resolved) {
|
|
613
613
|
const received = _nullishCoalesce(_nullishCoalesce(input.usedModel, () => ( input.modelUsed)), () => ( input.model));
|
|
614
614
|
if (!received) return [];
|
|
615
|
-
const normalizedReceived =
|
|
616
|
-
const normalizedPriced =
|
|
615
|
+
const normalizedReceived = _chunkOZE336BLcjs.normalizeString.call(void 0, received);
|
|
616
|
+
const normalizedPriced = _chunkOZE336BLcjs.normalizeString.call(void 0, pricedModelId);
|
|
617
617
|
if (normalizedReceived === normalizedPriced) return [];
|
|
618
|
-
const stripped =
|
|
618
|
+
const stripped = _chunkOZE336BLcjs.stripModelVersionSuffix.call(void 0, received);
|
|
619
619
|
const viaResolver = _optionalChain([resolved, 'optionalAccess', _19 => _19.found]) === true && resolved.resolvedVia.some(
|
|
620
620
|
(s) => s === "version-suffix-strip" || s === "date-suffix-strip"
|
|
621
621
|
);
|
|
622
|
-
const pricedViaStrip = stripped !== null &&
|
|
622
|
+
const pricedViaStrip = stripped !== null && _chunkOZE336BLcjs.normalizeString.call(void 0, stripped) === normalizedPriced;
|
|
623
623
|
if (!viaResolver && !pricedViaStrip) return [];
|
|
624
624
|
return [
|
|
625
625
|
{
|
|
@@ -676,7 +676,7 @@ var CostCalculator = class {
|
|
|
676
676
|
{
|
|
677
677
|
cost: 0,
|
|
678
678
|
resolvedModelId: modelInput,
|
|
679
|
-
routedViaOpenRouter:
|
|
679
|
+
routedViaOpenRouter: _chunkGNOZFRKRcjs.resolveRoutedViaOpenRouter.call(void 0,
|
|
680
680
|
input.provider,
|
|
681
681
|
resolved,
|
|
682
682
|
modelInput,
|
|
@@ -702,4 +702,4 @@ var CostCalculator = class {
|
|
|
702
702
|
|
|
703
703
|
|
|
704
704
|
exports.DEFAULT_OPENROUTER_MARKUP_RATE = DEFAULT_OPENROUTER_MARKUP_RATE; exports.toCostExtraction = toCostExtraction; exports.enrichCostResult = enrichCostResult; exports.MODEL_FIELD_PRIORITY = MODEL_FIELD_PRIORITY; exports.extractUsageInput = extractUsageInput; exports.resolveUsageModel = resolveUsageModel; exports.CostCalculator = CostCalculator;
|
|
705
|
-
//# sourceMappingURL=chunk-
|
|
705
|
+
//# sourceMappingURL=chunk-H6HDETJK.cjs.map
|