@x12i/ai-tools 2.0.0 → 2.0.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/{AiModelsCatalogClient-B5FMI9gj.d.cts → AiModelsCatalogClient-C9ZJHhv3.d.ts} +4 -1
- package/dist/{AiModelsCatalogClient-CPPNI6Ry.d.ts → AiModelsCatalogClient-DgBdVFk-.d.cts} +4 -1
- package/dist/aliases/index.d.cts +3 -3
- package/dist/aliases/index.d.ts +3 -3
- package/dist/catalog/index.cjs +6 -5
- package/dist/catalog/index.cjs.map +1 -1
- package/dist/catalog/index.d.cts +4 -4
- package/dist/catalog/index.d.ts +4 -4
- package/dist/catalog/index.js +5 -4
- package/dist/{chunk-EYHMQVAL.js → chunk-54GKLIDW.js} +22 -10
- package/dist/chunk-54GKLIDW.js.map +1 -0
- package/dist/chunk-5IZ7PLY2.cjs +51 -0
- package/dist/chunk-5IZ7PLY2.cjs.map +1 -0
- package/dist/{chunk-XAWBTX3N.cjs → chunk-75ZVXZAV.cjs} +7 -7
- package/dist/{chunk-XAWBTX3N.cjs.map → chunk-75ZVXZAV.cjs.map} +1 -1
- package/dist/{chunk-YQDSN6R6.cjs → chunk-76FHWQH3.cjs} +3 -3
- package/dist/{chunk-YQDSN6R6.cjs.map → chunk-76FHWQH3.cjs.map} +1 -1
- package/dist/{chunk-EDMCKHO6.cjs → chunk-BCX5CLJJ.cjs} +15 -2
- package/dist/chunk-BCX5CLJJ.cjs.map +1 -0
- package/dist/{chunk-OPN6BGNH.js → chunk-D6OIUYNC.js} +117 -5
- package/dist/{chunk-OPN6BGNH.js.map → chunk-D6OIUYNC.js.map} +1 -1
- package/dist/{chunk-NF2SKQR7.cjs → chunk-DDRWORUU.cjs} +30 -298
- package/dist/chunk-DDRWORUU.cjs.map +1 -0
- package/dist/{chunk-5XAAMBDO.cjs → chunk-HBNYVRLZ.cjs} +123 -11
- package/dist/chunk-HBNYVRLZ.cjs.map +1 -0
- package/dist/chunk-HEB73GKJ.js +263 -0
- package/dist/chunk-HEB73GKJ.js.map +1 -0
- package/dist/{chunk-VJHLO2R3.js → chunk-KSJSLKYI.js} +2 -2
- package/dist/{chunk-SIH4GPV4.js → chunk-MOLWV5LV.js} +2 -2
- package/dist/{chunk-U2YDDUVP.js → chunk-PN4FF6YF.js} +10 -275
- package/dist/chunk-PN4FF6YF.js.map +1 -0
- package/dist/{chunk-DXZOL3VN.cjs → chunk-RSHI4OOY.cjs} +46 -34
- package/dist/chunk-RSHI4OOY.cjs.map +1 -0
- package/dist/{chunk-B3V2EHRY.js → chunk-SLSKQRMI.js} +15 -2
- package/dist/{chunk-B3V2EHRY.js.map → chunk-SLSKQRMI.js.map} +1 -1
- package/dist/{chunk-XOKUDUUI.cjs → chunk-TMA6QSNH.cjs} +3 -3
- package/dist/{chunk-XOKUDUUI.cjs.map → chunk-TMA6QSNH.cjs.map} +1 -1
- package/dist/{chunk-6BQBKROR.js → chunk-VBROBIVI.js} +3 -3
- package/dist/{chunk-6BQBKROR.js.map → chunk-VBROBIVI.js.map} +1 -1
- package/dist/chunk-WSUFQR3D.cjs +266 -0
- package/dist/chunk-WSUFQR3D.cjs.map +1 -0
- package/dist/{chunk-PRCICORG.cjs → chunk-X42KFOUO.cjs} +6 -6
- package/dist/{chunk-PRCICORG.cjs.map → chunk-X42KFOUO.cjs.map} +1 -1
- package/dist/chunk-YQVY7CWT.js +51 -0
- package/dist/chunk-YQVY7CWT.js.map +1 -0
- package/dist/{chunk-AB5GNXJ4.js → chunk-ZPUZ7DBO.js} +2 -2
- package/dist/cli/index.cjs +16 -15
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +7 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cost/index.cjs +4 -3
- package/dist/cost/index.cjs.map +1 -1
- package/dist/cost/index.d.cts +4 -4
- package/dist/cost/index.d.ts +4 -4
- package/dist/cost/index.js +3 -2
- package/dist/index.cjs +28 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +33 -16
- package/dist/{modelCache-CJftI-Ko.d.cts → modelCache-sL3dBfRM.d.cts} +1 -1
- package/dist/{modelCache-BzRn6t_C.d.ts → modelCache-xzoTUue2.d.ts} +1 -1
- package/dist/{modelNameResolver-5XkBMctP.d.ts → modelNameResolver-2WroQlqt.d.ts} +2 -1
- package/dist/{modelNameResolver-C5CSTGFF.d.cts → modelNameResolver-Bxlehrbp.d.cts} +2 -1
- package/dist/models/index.cjs +7 -6
- package/dist/models/index.cjs.map +1 -1
- package/dist/models/index.d.cts +3 -3
- package/dist/models/index.d.ts +3 -3
- package/dist/models/index.js +9 -8
- package/dist/profiles/index.cjs +18 -0
- package/dist/profiles/index.cjs.map +1 -0
- package/dist/profiles/index.d.cts +40 -0
- package/dist/profiles/index.d.ts +40 -0
- package/dist/profiles/index.js +17 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/{resolveUsageModel-BFwf80Hz.d.ts → resolveUsageModel-DrFuiuIW.d.ts} +2 -2
- package/dist/{resolveUsageModel-C_YmGR1M.d.cts → resolveUsageModel-xKZ2QpHy.d.cts} +2 -2
- package/dist/sync/index.cjs +7 -5
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +3 -3
- package/dist/sync/index.d.ts +3 -3
- package/dist/sync/index.js +6 -4
- package/dist/{types-BrzJWsTU.d.ts → types-BZYGjN2O.d.cts} +21 -2
- package/dist/{types-BrzJWsTU.d.cts → types-BZYGjN2O.d.ts} +21 -2
- package/package.json +7 -2
- package/dist/chunk-5XAAMBDO.cjs.map +0 -1
- package/dist/chunk-DXZOL3VN.cjs.map +0 -1
- package/dist/chunk-EDMCKHO6.cjs.map +0 -1
- package/dist/chunk-EYHMQVAL.js.map +0 -1
- package/dist/chunk-NF2SKQR7.cjs.map +0 -1
- package/dist/chunk-U2YDDUVP.js.map +0 -1
- /package/dist/{chunk-VJHLO2R3.js.map → chunk-KSJSLKYI.js.map} +0 -0
- /package/dist/{chunk-SIH4GPV4.js.map → chunk-MOLWV5LV.js.map} +0 -0
- /package/dist/{chunk-AB5GNXJ4.js.map → chunk-ZPUZ7DBO.js.map} +0 -0
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
matchModelInAiProfiles
|
|
3
|
+
} from "./chunk-HEB73GKJ.js";
|
|
1
4
|
import {
|
|
2
5
|
ModelNameResolver,
|
|
3
6
|
computeSupportsReasoning
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-54GKLIDW.js";
|
|
5
8
|
import {
|
|
9
|
+
isEffectiveOpenRouterTransport,
|
|
10
|
+
loadOpenRouterRoutingEnv,
|
|
6
11
|
normalizeProvider,
|
|
7
12
|
normalizeString
|
|
8
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-SLSKQRMI.js";
|
|
9
14
|
|
|
10
15
|
// src/cache/modelCache.ts
|
|
11
16
|
import { createNxCache } from "nx-cache";
|
|
@@ -1861,6 +1866,17 @@ async function loadCatalogSourcesCached(options = {}, cacheOptions = {}) {
|
|
|
1861
1866
|
function isOpenRouterProvider(provider) {
|
|
1862
1867
|
return normalizeProvider(provider) === "openrouter";
|
|
1863
1868
|
}
|
|
1869
|
+
function profileResolutionStrategy(matchedVia) {
|
|
1870
|
+
switch (matchedVia) {
|
|
1871
|
+
case "shortcut":
|
|
1872
|
+
return "ai-profiles-shortcut";
|
|
1873
|
+
case "profile":
|
|
1874
|
+
case "profile-alias":
|
|
1875
|
+
return "ai-profiles-profile";
|
|
1876
|
+
default:
|
|
1877
|
+
return "ai-profiles-model-id";
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1864
1880
|
var AiModelsCatalogClient = class {
|
|
1865
1881
|
cacheTtlMs;
|
|
1866
1882
|
cacheKey;
|
|
@@ -1939,20 +1955,116 @@ var AiModelsCatalogClient = class {
|
|
|
1939
1955
|
}
|
|
1940
1956
|
async resolveModel(input, options) {
|
|
1941
1957
|
await this.ensureLoaded();
|
|
1958
|
+
const mergedOptions = { ...this.resolverOptions, ...options };
|
|
1959
|
+
let result = this.resolveFromCatalogMaps(input, mergedOptions);
|
|
1960
|
+
if (!result.found) {
|
|
1961
|
+
const viaProfile = await this.resolveViaProfile(input, mergedOptions);
|
|
1962
|
+
if (viaProfile) return viaProfile;
|
|
1963
|
+
return result;
|
|
1964
|
+
}
|
|
1965
|
+
return this.alignForOpenRouterTransport(result, input);
|
|
1966
|
+
}
|
|
1967
|
+
resolveFromCatalogMaps(input, options) {
|
|
1942
1968
|
const primary = this.catalogForProvider(input.provider);
|
|
1943
1969
|
const secondary = isOpenRouterProvider(input.provider) ? this.directModels ?? /* @__PURE__ */ new Map() : this.openRouterModels ?? /* @__PURE__ */ new Map();
|
|
1944
1970
|
let result = this.resolver(primary, options).resolve(input);
|
|
1945
|
-
if (result.found && result.record)
|
|
1971
|
+
if (result.found && result.record) {
|
|
1972
|
+
return this.alignForOpenRouterTransport(result, input);
|
|
1973
|
+
}
|
|
1946
1974
|
if (secondary.size > 0) {
|
|
1947
1975
|
const fallback = this.resolver(secondary, options).resolve(input);
|
|
1948
|
-
if (fallback.found && fallback.record)
|
|
1976
|
+
if (fallback.found && fallback.record) {
|
|
1977
|
+
return this.alignForOpenRouterTransport(fallback, input);
|
|
1978
|
+
}
|
|
1949
1979
|
if (!result.found && fallback.found) result = fallback;
|
|
1950
1980
|
}
|
|
1951
1981
|
if (!result.found) {
|
|
1952
1982
|
result = this.resolver(this.mergedModels(), options).resolve(input);
|
|
1953
1983
|
}
|
|
1984
|
+
if (result.found) {
|
|
1985
|
+
return this.alignForOpenRouterTransport(result, input);
|
|
1986
|
+
}
|
|
1954
1987
|
return result;
|
|
1955
1988
|
}
|
|
1989
|
+
alignForOpenRouterTransport(result, input) {
|
|
1990
|
+
if (!result.routedViaOpenRouter) return result;
|
|
1991
|
+
let { modelId, record } = result;
|
|
1992
|
+
if (!modelId.includes("/")) {
|
|
1993
|
+
const vendor = record?.providerId ?? normalizeProvider(input.provider) ?? void 0;
|
|
1994
|
+
if (vendor && vendor !== "openrouter") {
|
|
1995
|
+
modelId = `${vendor}/${modelId}`;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
const orRecord = this.openRouterModels?.get(modelId);
|
|
1999
|
+
if (orRecord) {
|
|
2000
|
+
record = orRecord;
|
|
2001
|
+
}
|
|
2002
|
+
if (modelId === result.modelId && record === result.record) return result;
|
|
2003
|
+
return { ...result, modelId, record };
|
|
2004
|
+
}
|
|
2005
|
+
async resolveViaProfile(input, options) {
|
|
2006
|
+
const profileMatch = await matchModelInAiProfiles(input.model, input.provider);
|
|
2007
|
+
if (!profileMatch) return null;
|
|
2008
|
+
const strategy = profileResolutionStrategy(profileMatch.matchedVia);
|
|
2009
|
+
const attempts = [];
|
|
2010
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2011
|
+
const add = (model, provider) => {
|
|
2012
|
+
const key = `${provider ?? ""}\0${normalizeString(model)}`;
|
|
2013
|
+
if (seen.has(key)) return;
|
|
2014
|
+
seen.add(key);
|
|
2015
|
+
attempts.push({ model, provider });
|
|
2016
|
+
};
|
|
2017
|
+
add(profileMatch.canonicalModelId, input.provider ?? profileMatch.provider);
|
|
2018
|
+
add(profileMatch.canonicalModelId, profileMatch.provider);
|
|
2019
|
+
if (!isOpenRouterProvider(input.provider)) {
|
|
2020
|
+
add(profileMatch.canonicalModelId, "openrouter");
|
|
2021
|
+
}
|
|
2022
|
+
let catalogResult = null;
|
|
2023
|
+
for (const attempt of attempts) {
|
|
2024
|
+
const result = this.resolveFromCatalogMaps(attempt, options);
|
|
2025
|
+
catalogResult = result;
|
|
2026
|
+
if (result.found && result.record) break;
|
|
2027
|
+
}
|
|
2028
|
+
const normalisedInput = normalizeString(input.model);
|
|
2029
|
+
if (!catalogResult?.found) {
|
|
2030
|
+
const routingEnv = options?.routingEnv ?? loadOpenRouterRoutingEnv();
|
|
2031
|
+
const routedViaOpenRouter = isEffectiveOpenRouterTransport(routingEnv, {
|
|
2032
|
+
provider: input.provider ?? profileMatch.provider,
|
|
2033
|
+
modelId: profileMatch.canonicalModelId,
|
|
2034
|
+
routeViaOpenRouter: options?.routeViaOpenRouter
|
|
2035
|
+
});
|
|
2036
|
+
const aligned = this.alignForOpenRouterTransport(
|
|
2037
|
+
{
|
|
2038
|
+
found: true,
|
|
2039
|
+
modelId: profileMatch.canonicalModelId,
|
|
2040
|
+
record: null,
|
|
2041
|
+
routedViaOpenRouter,
|
|
2042
|
+
confidence: 0.85,
|
|
2043
|
+
resolvedVia: [strategy],
|
|
2044
|
+
resolvedReason: `Resolved profile "${input.model}" \u2192 ${profileMatch.canonicalModelId} via ai-profiles (${profileMatch.matchedVia})`,
|
|
2045
|
+
normalisedInput,
|
|
2046
|
+
profile: profileMatch.profile,
|
|
2047
|
+
choice: profileMatch.choice
|
|
2048
|
+
},
|
|
2049
|
+
{ model: profileMatch.canonicalModelId, provider: profileMatch.provider }
|
|
2050
|
+
);
|
|
2051
|
+
return {
|
|
2052
|
+
...aligned,
|
|
2053
|
+
resolvedVia: [strategy],
|
|
2054
|
+
profile: profileMatch.profile,
|
|
2055
|
+
choice: profileMatch.choice
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
const viaProfile = catalogResult;
|
|
2059
|
+
return {
|
|
2060
|
+
...viaProfile,
|
|
2061
|
+
resolvedVia: [strategy, ...viaProfile.resolvedVia],
|
|
2062
|
+
resolvedReason: `Resolved profile "${input.model}" \u2192 ${viaProfile.modelId} via ai-profiles (${profileMatch.matchedVia})`,
|
|
2063
|
+
normalisedInput,
|
|
2064
|
+
profile: profileMatch.profile,
|
|
2065
|
+
choice: profileMatch.choice
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
1956
2068
|
async getModel(modelId, provider, options) {
|
|
1957
2069
|
const result = await this.resolveModel({ model: modelId, provider }, options);
|
|
1958
2070
|
return result.found ? result.record : null;
|
|
@@ -1982,4 +2094,4 @@ export {
|
|
|
1982
2094
|
loadCatalogSourcesCached,
|
|
1983
2095
|
AiModelsCatalogClient
|
|
1984
2096
|
};
|
|
1985
|
-
//# sourceMappingURL=chunk-
|
|
2097
|
+
//# sourceMappingURL=chunk-D6OIUYNC.js.map
|