@x12i/ai-tools 2.0.1 → 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-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-WOHMHXRZ.cjs → chunk-DDRWORUU.cjs} +30 -276
- 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-CTM35DMA.js → chunk-PN4FF6YF.js} +10 -253
- 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-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 +12 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +11 -8
- 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 +6 -5
- 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 +1 -1
- package/dist/chunk-5XAAMBDO.cjs.map +0 -1
- package/dist/chunk-CTM35DMA.js.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-WOHMHXRZ.cjs.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,4 +1,4 @@
|
|
|
1
|
-
import { a as AiModelRecord, l as ModelResolverOptions, h as ModelResolutionInput, j as ModelResolutionResult } from './types-
|
|
1
|
+
import { a as AiModelRecord, l as ModelResolverOptions, h as ModelResolutionInput, j as ModelResolutionResult } from './types-BZYGjN2O.js';
|
|
2
2
|
|
|
3
3
|
type LoadCatalogOptions = {
|
|
4
4
|
directCatalogUrl?: string;
|
|
@@ -50,6 +50,9 @@ declare class AiModelsCatalogClient {
|
|
|
50
50
|
getDirectModels(): Promise<Map<string, AiModelRecord>>;
|
|
51
51
|
getOpenRouterModels(): Promise<Map<string, AiModelRecord>>;
|
|
52
52
|
resolveModel(input: ModelResolutionInput, options?: ModelResolverOptions): Promise<ModelResolutionResult>;
|
|
53
|
+
private resolveFromCatalogMaps;
|
|
54
|
+
private alignForOpenRouterTransport;
|
|
55
|
+
private resolveViaProfile;
|
|
53
56
|
getModel(modelId: string, provider?: string, options?: ModelResolverOptions): Promise<AiModelRecord | null>;
|
|
54
57
|
/** Clear caches and fetch catalogs again immediately. */
|
|
55
58
|
refresh(): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AiModelRecord, l as ModelResolverOptions, h as ModelResolutionInput, j as ModelResolutionResult } from './types-
|
|
1
|
+
import { a as AiModelRecord, l as ModelResolverOptions, h as ModelResolutionInput, j as ModelResolutionResult } from './types-BZYGjN2O.cjs';
|
|
2
2
|
|
|
3
3
|
type LoadCatalogOptions = {
|
|
4
4
|
directCatalogUrl?: string;
|
|
@@ -50,6 +50,9 @@ declare class AiModelsCatalogClient {
|
|
|
50
50
|
getDirectModels(): Promise<Map<string, AiModelRecord>>;
|
|
51
51
|
getOpenRouterModels(): Promise<Map<string, AiModelRecord>>;
|
|
52
52
|
resolveModel(input: ModelResolutionInput, options?: ModelResolverOptions): Promise<ModelResolutionResult>;
|
|
53
|
+
private resolveFromCatalogMaps;
|
|
54
|
+
private alignForOpenRouterTransport;
|
|
55
|
+
private resolveViaProfile;
|
|
53
56
|
getModel(modelId: string, provider?: string, options?: ModelResolverOptions): Promise<AiModelRecord | null>;
|
|
54
57
|
/** Clear caches and fetch catalogs again immediately. */
|
|
55
58
|
refresh(): Promise<void>;
|
package/dist/aliases/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as AliasRegistry, u as ResolvedModelRef, f as AliasValidationReport } from '../types-
|
|
2
|
-
export { b as AliasEntry, c as AliasFileSchema, e as AliasRegistryOptions } from '../types-
|
|
3
|
-
import { A as AiModelsCatalogClient } from '../AiModelsCatalogClient-
|
|
1
|
+
import { d as AliasRegistry, u as ResolvedModelRef, f as AliasValidationReport } from '../types-BZYGjN2O.cjs';
|
|
2
|
+
export { b as AliasEntry, c as AliasFileSchema, e as AliasRegistryOptions } from '../types-BZYGjN2O.cjs';
|
|
3
|
+
import { A as AiModelsCatalogClient } from '../AiModelsCatalogClient-DgBdVFk-.cjs';
|
|
4
4
|
|
|
5
5
|
type AliasResolverOptions = {
|
|
6
6
|
registry: AliasRegistry;
|
package/dist/aliases/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as AliasRegistry, u as ResolvedModelRef, f as AliasValidationReport } from '../types-
|
|
2
|
-
export { b as AliasEntry, c as AliasFileSchema, e as AliasRegistryOptions } from '../types-
|
|
3
|
-
import { A as AiModelsCatalogClient } from '../AiModelsCatalogClient-
|
|
1
|
+
import { d as AliasRegistry, u as ResolvedModelRef, f as AliasValidationReport } from '../types-BZYGjN2O.js';
|
|
2
|
+
export { b as AliasEntry, c as AliasFileSchema, e as AliasRegistryOptions } from '../types-BZYGjN2O.js';
|
|
3
|
+
import { A as AiModelsCatalogClient } from '../AiModelsCatalogClient-C9ZJHhv3.js';
|
|
4
4
|
|
|
5
5
|
type AliasResolverOptions = {
|
|
6
6
|
registry: AliasRegistry;
|
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 _chunk75ZVXZAVcjs = require('../chunk-75ZVXZAV.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -15,9 +15,10 @@ var _chunkXAWBTX3Ncjs = require('../chunk-XAWBTX3N.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
require('../chunk-
|
|
20
|
-
require('../chunk-
|
|
18
|
+
var _chunkHBNYVRLZcjs = require('../chunk-HBNYVRLZ.cjs');
|
|
19
|
+
require('../chunk-WSUFQR3D.cjs');
|
|
20
|
+
require('../chunk-RSHI4OOY.cjs');
|
|
21
|
+
require('../chunk-BCX5CLJJ.cjs');
|
|
21
22
|
require('../chunk-PADNCGZB.cjs');
|
|
22
23
|
require('../chunk-GS7T56RP.cjs');
|
|
23
24
|
|
|
@@ -35,5 +36,5 @@ require('../chunk-GS7T56RP.cjs');
|
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
|
|
38
|
-
exports.AiModelsCatalogClient =
|
|
39
|
+
exports.AiModelsCatalogClient = _chunkHBNYVRLZcjs.AiModelsCatalogClient; exports.DEFAULT_CATALOG_CACHE_TTL_MS = _chunkHBNYVRLZcjs.DEFAULT_CATALOG_CACHE_TTL_MS; exports.DEFAULT_DIRECT_CATALOG_URL = _chunkHBNYVRLZcjs.DEFAULT_DIRECT_CATALOG_URL; exports.DEFAULT_OPENROUTER_CATALOG_URL = _chunkHBNYVRLZcjs.DEFAULT_OPENROUTER_CATALOG_URL; exports.canonicalCatalogModelId = _chunkHBNYVRLZcjs.canonicalCatalogModelId; exports.invalidateCatalogLoadCache = _chunkHBNYVRLZcjs.invalidateCatalogLoadCache; exports.loadCatalogSources = _chunkHBNYVRLZcjs.loadCatalogSources; exports.loadCatalogSourcesCached = _chunkHBNYVRLZcjs.loadCatalogSourcesCached; exports.modelsFromX12iCatalogFile = _chunkHBNYVRLZcjs.modelsFromX12iCatalogFile; exports.normalizeX12iCatalogModel = _chunkHBNYVRLZcjs.normalizeX12iCatalogModel; exports.readBundledCatalogFiles = _chunkHBNYVRLZcjs.readBundledCatalogFiles; exports.refreshAiModelsCatalog = _chunk75ZVXZAVcjs.refreshAiModelsCatalog; exports.resolveCatalogCacheTtlMs = _chunkHBNYVRLZcjs.resolveCatalogCacheTtlMs; exports.verifyAiModelsCatalog = _chunk75ZVXZAVcjs.verifyAiModelsCatalog;
|
|
39
40
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/catalog/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ilCAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/catalog/index.cjs"}
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/catalog/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ilCAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/catalog/index.cjs"}
|
package/dist/catalog/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AiModelsCatalogClient, a as AiModelsCatalogClientOptions, L as LoadCatalogOptions, b as LoadedCatalogs, l as loadCatalogSources, r as readBundledCatalogFiles } from '../AiModelsCatalogClient-
|
|
2
|
-
import { a as AiModelRecord } from '../types-
|
|
3
|
-
import { X as X12iCatalogModelEntry, b as CatalogSourceKind } from '../modelCache-
|
|
4
|
-
export { C as CatalogRefreshOptions, a as CatalogRefreshResult, c as CatalogVerifyOptions, d as CatalogVerifyReport, D as DEFAULT_CATALOG_CACHE_TTL_MS, e as DEFAULT_DIRECT_CATALOG_URL, f as DEFAULT_OPENROUTER_CATALOG_URL, L as LoadCatalogCachedOptions, g as X12iModelsCatalogFile, i as invalidateCatalogLoadCache, l as loadCatalogSourcesCached, r as refreshAiModelsCatalog, h as resolveCatalogCacheTtlMs, v as verifyAiModelsCatalog } from '../modelCache-
|
|
1
|
+
export { A as AiModelsCatalogClient, a as AiModelsCatalogClientOptions, L as LoadCatalogOptions, b as LoadedCatalogs, l as loadCatalogSources, r as readBundledCatalogFiles } from '../AiModelsCatalogClient-DgBdVFk-.cjs';
|
|
2
|
+
import { a as AiModelRecord } from '../types-BZYGjN2O.cjs';
|
|
3
|
+
import { X as X12iCatalogModelEntry, b as CatalogSourceKind } from '../modelCache-sL3dBfRM.cjs';
|
|
4
|
+
export { C as CatalogRefreshOptions, a as CatalogRefreshResult, c as CatalogVerifyOptions, d as CatalogVerifyReport, D as DEFAULT_CATALOG_CACHE_TTL_MS, e as DEFAULT_DIRECT_CATALOG_URL, f as DEFAULT_OPENROUTER_CATALOG_URL, L as LoadCatalogCachedOptions, g as X12iModelsCatalogFile, i as invalidateCatalogLoadCache, l as loadCatalogSourcesCached, r as refreshAiModelsCatalog, h as resolveCatalogCacheTtlMs, v as verifyAiModelsCatalog } from '../modelCache-sL3dBfRM.cjs';
|
|
5
5
|
|
|
6
6
|
declare function canonicalCatalogModelId(provider: string, modelId: string): string;
|
|
7
7
|
declare function normalizeX12iCatalogModel(entry: X12iCatalogModelEntry, kind: CatalogSourceKind, verifiedAt: string): AiModelRecord | null;
|
package/dist/catalog/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AiModelsCatalogClient, a as AiModelsCatalogClientOptions, L as LoadCatalogOptions, b as LoadedCatalogs, l as loadCatalogSources, r as readBundledCatalogFiles } from '../AiModelsCatalogClient-
|
|
2
|
-
import { a as AiModelRecord } from '../types-
|
|
3
|
-
import { X as X12iCatalogModelEntry, b as CatalogSourceKind } from '../modelCache-
|
|
4
|
-
export { C as CatalogRefreshOptions, a as CatalogRefreshResult, c as CatalogVerifyOptions, d as CatalogVerifyReport, D as DEFAULT_CATALOG_CACHE_TTL_MS, e as DEFAULT_DIRECT_CATALOG_URL, f as DEFAULT_OPENROUTER_CATALOG_URL, L as LoadCatalogCachedOptions, g as X12iModelsCatalogFile, i as invalidateCatalogLoadCache, l as loadCatalogSourcesCached, r as refreshAiModelsCatalog, h as resolveCatalogCacheTtlMs, v as verifyAiModelsCatalog } from '../modelCache-
|
|
1
|
+
export { A as AiModelsCatalogClient, a as AiModelsCatalogClientOptions, L as LoadCatalogOptions, b as LoadedCatalogs, l as loadCatalogSources, r as readBundledCatalogFiles } from '../AiModelsCatalogClient-C9ZJHhv3.js';
|
|
2
|
+
import { a as AiModelRecord } from '../types-BZYGjN2O.js';
|
|
3
|
+
import { X as X12iCatalogModelEntry, b as CatalogSourceKind } from '../modelCache-xzoTUue2.js';
|
|
4
|
+
export { C as CatalogRefreshOptions, a as CatalogRefreshResult, c as CatalogVerifyOptions, d as CatalogVerifyReport, D as DEFAULT_CATALOG_CACHE_TTL_MS, e as DEFAULT_DIRECT_CATALOG_URL, f as DEFAULT_OPENROUTER_CATALOG_URL, L as LoadCatalogCachedOptions, g as X12iModelsCatalogFile, i as invalidateCatalogLoadCache, l as loadCatalogSourcesCached, r as refreshAiModelsCatalog, h as resolveCatalogCacheTtlMs, v as verifyAiModelsCatalog } from '../modelCache-xzoTUue2.js';
|
|
5
5
|
|
|
6
6
|
declare function canonicalCatalogModelId(provider: string, modelId: string): string;
|
|
7
7
|
declare function normalizeX12iCatalogModel(entry: X12iCatalogModelEntry, kind: CatalogSourceKind, verifiedAt: string): AiModelRecord | null;
|
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-ZPUZ7DBO.js";
|
|
5
5
|
import {
|
|
6
6
|
AiModelsCatalogClient,
|
|
7
7
|
DEFAULT_CATALOG_CACHE_TTL_MS,
|
|
@@ -15,9 +15,10 @@ import {
|
|
|
15
15
|
normalizeX12iCatalogModel,
|
|
16
16
|
readBundledCatalogFiles,
|
|
17
17
|
resolveCatalogCacheTtlMs
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-D6OIUYNC.js";
|
|
19
|
+
import "../chunk-HEB73GKJ.js";
|
|
20
|
+
import "../chunk-54GKLIDW.js";
|
|
21
|
+
import "../chunk-SLSKQRMI.js";
|
|
21
22
|
import "../chunk-2PTCWPHV.js";
|
|
22
23
|
export {
|
|
23
24
|
AiModelsCatalogClient,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
stripModelSlugSuffix,
|
|
12
12
|
stripModelVersionSuffix,
|
|
13
13
|
tokenise
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-SLSKQRMI.js";
|
|
15
15
|
import {
|
|
16
16
|
ModelResolutionError
|
|
17
17
|
} from "./chunk-2PTCWPHV.js";
|
|
@@ -52,7 +52,8 @@ var ModelNameResolver = class {
|
|
|
52
52
|
additionalShorthands: options.additionalShorthands ?? {},
|
|
53
53
|
additionalProviderPatterns: options.additionalProviderPatterns ?? [],
|
|
54
54
|
additionalLocalProviders: options.additionalLocalProviders ?? [],
|
|
55
|
-
routingEnv: options.routingEnv ?? loadOpenRouterRoutingEnv()
|
|
55
|
+
routingEnv: options.routingEnv ?? loadOpenRouterRoutingEnv(),
|
|
56
|
+
routeViaOpenRouter: options.routeViaOpenRouter
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
59
|
}
|
|
@@ -410,6 +411,9 @@ var ModelNameResolver = class {
|
|
|
410
411
|
};
|
|
411
412
|
}
|
|
412
413
|
computeRoutedViaOpenRouter(modelId, record, provider, originalProvider) {
|
|
414
|
+
const override = this.ctx.options.routeViaOpenRouter;
|
|
415
|
+
if (override === true) return true;
|
|
416
|
+
if (override === false) return false;
|
|
413
417
|
const norm = normalizeProvider(originalProvider) ?? provider;
|
|
414
418
|
if (norm === "openrouter") return true;
|
|
415
419
|
if (norm && norm !== "openrouter") {
|
|
@@ -423,17 +427,25 @@ var ModelNameResolver = class {
|
|
|
423
427
|
if (record?.availableOnOpenRouter && modelId.includes("/")) return true;
|
|
424
428
|
return false;
|
|
425
429
|
}
|
|
430
|
+
toOpenRouterSlug(modelId, provider, record) {
|
|
431
|
+
if (modelId.includes("/")) return modelId;
|
|
432
|
+
const vendor = record?.providerId ?? (provider && provider !== "openrouter" ? provider : void 0);
|
|
433
|
+
if (!vendor || vendor === "openrouter") return modelId;
|
|
434
|
+
return `${vendor}/${modelId}`;
|
|
435
|
+
}
|
|
426
436
|
success(args) {
|
|
437
|
+
const routedViaOpenRouter = this.computeRoutedViaOpenRouter(
|
|
438
|
+
args.modelId,
|
|
439
|
+
args.record,
|
|
440
|
+
args.provider,
|
|
441
|
+
args.originalProvider
|
|
442
|
+
);
|
|
443
|
+
const modelId = routedViaOpenRouter ? this.toOpenRouterSlug(args.modelId, args.provider, args.record) : args.modelId;
|
|
427
444
|
return {
|
|
428
445
|
found: true,
|
|
429
|
-
modelId
|
|
446
|
+
modelId,
|
|
430
447
|
record: args.record,
|
|
431
|
-
routedViaOpenRouter
|
|
432
|
-
args.modelId,
|
|
433
|
-
args.record,
|
|
434
|
-
args.provider,
|
|
435
|
-
args.originalProvider
|
|
436
|
-
),
|
|
448
|
+
routedViaOpenRouter,
|
|
437
449
|
confidence: args.confidence,
|
|
438
450
|
resolvedVia: args.resolvedVia,
|
|
439
451
|
resolvedReason: args.reason,
|
|
@@ -475,4 +487,4 @@ export {
|
|
|
475
487
|
computeSupportsReasoning,
|
|
476
488
|
isReasoningModel
|
|
477
489
|
};
|
|
478
|
-
//# sourceMappingURL=chunk-
|
|
490
|
+
//# sourceMappingURL=chunk-54GKLIDW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sync/modelNameResolver/catalogIndexes.ts","../src/sync/modelNameResolver/ModelNameResolver.ts","../src/models/reasoningModel.ts"],"sourcesContent":["import type { AiModelRecord } from \"../../models/types.js\";\nimport { normalizeString } from \"./normalize.js\";\nimport type { CatalogIndexes } from \"./types.js\";\n\nexport function buildCatalogIndexes(catalog: Map<string, AiModelRecord>): CatalogIndexes {\n const aliasIndex = new Map<string, string>();\n const slugIndex = new Map<string, string>();\n const prefixCounts = new Map<string, number>();\n\n for (const record of catalog.values()) {\n for (const alias of record.aliases) {\n aliasIndex.set(normalizeString(alias), record.modelId);\n }\n if (record.canonicalSlug) {\n slugIndex.set(normalizeString(record.canonicalSlug), record.modelId);\n }\n const pid = record.providerId;\n prefixCounts.set(pid, (prefixCounts.get(pid) ?? 0) + 1);\n }\n\n const providerPrefixesBySize = [...prefixCounts.entries()]\n .sort((a, b) => b[1] - a[1])\n .map(([p]) => p);\n\n return { aliasIndex, slugIndex, providerPrefixesBySize };\n}\n","import { ModelResolutionError } from \"../../errors.js\";\nimport type { AiModelRecord } from \"../../models/types.js\";\nimport {\n loadOpenRouterRoutingEnv,\n shouldDefaultRouteViaOpenRouter,\n} from \"../openRouterRoutingEnv.js\";\nimport { buildCatalogIndexes } from \"./catalogIndexes.js\";\nimport {\n DEFAULT_CONFIDENCE_THRESHOLD,\n LOCAL_PROVIDERS,\n PROVIDER_INFERENCE_MAP,\n SHORTHAND_MAP,\n} from \"./constants.js\";\nimport { modelSlug, normalizeProvider, normalizeString, tokenise } from \"./normalize.js\";\nimport { stripModelSlugSuffix, stripModelVersionSuffix } from \"./stripVersionSuffix.js\";\nimport type {\n CatalogIndexes,\n ModelResolutionInput,\n ModelResolutionNotFound,\n ModelResolutionResult,\n ModelResolutionSuccess,\n ModelResolverOptions,\n ResolutionStrategy,\n ResolverContext,\n} from \"./types.js\";\n\ntype MatchCandidate = {\n modelId: string;\n record: AiModelRecord | null;\n confidence: number;\n strategy: ResolutionStrategy;\n reason: string;\n};\n\nexport class ModelNameResolver {\n private readonly catalog: Map<string, AiModelRecord>;\n private readonly indexes: CatalogIndexes;\n private readonly ctx: ResolverContext;\n\n constructor(\n catalog: Map<string, AiModelRecord>,\n options: ModelResolverOptions = {},\n ) {\n this.catalog = catalog;\n this.indexes = buildCatalogIndexes(catalog);\n this.ctx = {\n catalog,\n indexes: this.indexes,\n options: {\n confidenceThreshold: options.confidenceThreshold ?? DEFAULT_CONFIDENCE_THRESHOLD,\n aliasRegistry: options.aliasRegistry,\n additionalShorthands: options.additionalShorthands ?? {},\n additionalProviderPatterns: options.additionalProviderPatterns ?? [],\n additionalLocalProviders: options.additionalLocalProviders ?? [],\n routingEnv: options.routingEnv ?? loadOpenRouterRoutingEnv(),\n routeViaOpenRouter: options.routeViaOpenRouter,\n },\n };\n }\n\n resolve(input: ModelResolutionInput): ModelResolutionResult {\n const attempted: ResolutionStrategy[] = [];\n const threshold = this.ctx.options.confidenceThreshold;\n\n let provider = normalizeProvider(input.provider);\n let model = normalizeString(input.model);\n const normalisedInput = model;\n\n // S0 — alias registry on model string\n if (this.ctx.options.aliasRegistry) {\n attempted.push(\"alias-registry\");\n const entry = this.ctx.options.aliasRegistry.get(model);\n if (entry) {\n model = normalizeString(entry.modelId);\n provider = normalizeProvider(entry.provider) ?? provider;\n }\n }\n\n // Alias used as provider name (e.g. provider=\"best\")\n if (this.ctx.options.aliasRegistry && provider) {\n const aliasAsProvider = this.ctx.options.aliasRegistry.get(provider);\n if (aliasAsProvider) {\n attempted.push(\"alias-as-provider-correction\");\n model = normalizeString(aliasAsProvider.modelId);\n provider = normalizeProvider(aliasAsProvider.provider) ?? provider;\n }\n }\n\n // S10 — local provider (before catalog strategies)\n const localProviders = new Set([\n ...LOCAL_PROVIDERS,\n ...this.ctx.options.additionalLocalProviders.map((p) => normalizeString(p)),\n ]);\n if (provider && localProviders.has(provider)) {\n attempted.push(\"local-provider-passthrough\");\n return this.success({\n modelId: model,\n record: null,\n confidence: 0.99,\n strategy: \"local-provider-passthrough\",\n reason: `Local provider \"${provider}\" — model not looked up in catalog`,\n resolvedVia: attempted,\n normalisedInput,\n provider,\n originalProvider: input.provider,\n });\n }\n\n const preCorrection = [...attempted];\n\n const { match, rejected } = this.runPipeline(model, provider, attempted, threshold, []);\n if (match) {\n const via = [\n ...preCorrection.filter((s) => !match.resolvedVia.includes(s)),\n ...match.resolvedVia,\n ];\n return this.success({\n modelId: match.modelId,\n record: match.record,\n confidence: match.confidence,\n strategy: match.strategy,\n reason: match.reason,\n resolvedVia: via,\n normalisedInput,\n provider,\n originalProvider: input.provider,\n });\n }\n\n const notFound: ModelResolutionNotFound = {\n found: false,\n modelId: null,\n record: null,\n attemptedStrategies: attempted,\n reason: \"No catalog entry matched after all strategies.\",\n bestRejectedCandidate: rejected,\n };\n return notFound;\n }\n\n resolveMany(inputs: ModelResolutionInput[]): ModelResolutionResult[] {\n return inputs.map((i) => this.resolve(i));\n }\n\n resolveOrThrow(input: ModelResolutionInput): ModelResolutionSuccess {\n const result = this.resolve(input);\n if (result.found) return result;\n throw new ModelResolutionError(input, result);\n }\n\n private runPipeline(\n model: string,\n provider: string | undefined,\n attempted: ResolutionStrategy[],\n threshold: number,\n resolvedVia: ResolutionStrategy[],\n depth = 0,\n ): {\n match: (MatchCandidate & { resolvedVia: ResolutionStrategy[] }) | null;\n rejected?: ModelResolutionNotFound[\"bestRejectedCandidate\"];\n } {\n if (depth > 12) return { match: null };\n\n const tryMatch = (\n strategy: ResolutionStrategy,\n fn: () => MatchCandidate | null,\n ): (MatchCandidate & { resolvedVia: ResolutionStrategy[] }) | null => {\n if (!attempted.includes(strategy)) attempted.push(strategy);\n const m = fn();\n if (m && m.confidence >= threshold) {\n return { ...m, resolvedVia: [...resolvedVia, strategy] };\n }\n return null;\n };\n\n let hit = tryMatch(\"exact-match\", () => this.exactMatch(model));\n if (hit) return { match: hit };\n\n hit = tryMatch(\"catalog-alias-match\", () => this.catalogAliasMatch(model));\n if (hit) return { match: hit };\n\n hit = tryMatch(\"canonical-slug-match\", () => this.slugMatch(model));\n if (hit) return { match: hit };\n\n hit = tryMatch(\"provider-prefix-injection\", () =>\n this.providerPrefixInjection(model, provider),\n );\n if (hit) return { match: hit };\n\n hit = tryMatch(\"cross-provider-correction\", () => this.crossProviderCorrection(model));\n if (hit) return { match: hit };\n\n const stripped = stripModelVersionSuffix(model);\n if (stripped && stripped !== model) {\n if (!attempted.includes(\"version-suffix-strip\")) attempted.push(\"version-suffix-strip\");\n const inner = this.runPipeline(\n stripped,\n provider,\n attempted,\n threshold,\n [...resolvedVia, \"version-suffix-strip\"],\n depth + 1,\n );\n if (inner.match) {\n return {\n match: {\n ...inner.match,\n confidence: 0.85,\n strategy: \"version-suffix-strip\",\n reason: `Stripped version suffix from \"${model}\" → \"${stripped}\" then ${inner.match.reason}`,\n resolvedVia: [...resolvedVia, \"version-suffix-strip\", ...inner.match.resolvedVia],\n },\n };\n }\n }\n\n hit = tryMatch(\"date-suffix-strip\", () => this.dateSuffixMatch(model));\n if (hit) return { match: hit };\n\n const shorthand = this.shorthandMap()[model];\n if (shorthand) {\n if (!attempted.includes(\"shorthand-expansion\")) attempted.push(\"shorthand-expansion\");\n const inner = this.runPipeline(\n normalizeString(shorthand),\n provider,\n attempted,\n threshold,\n [...resolvedVia, \"shorthand-expansion\"],\n depth + 1,\n );\n if (inner.match) {\n return {\n match: {\n ...inner.match,\n confidence: 0.8,\n strategy: \"shorthand-expansion\",\n reason: `Expanded shorthand \"${model}\" → \"${shorthand}\" then ${inner.match.reason}`,\n resolvedVia: [...resolvedVia, \"shorthand-expansion\", ...inner.match.resolvedVia],\n },\n };\n }\n }\n\n const partial = this.partialMatch(model, provider);\n if (partial) {\n if (!attempted.includes(\"partial-name-match\")) attempted.push(\"partial-name-match\");\n if (partial.confidence >= threshold) {\n return {\n match: { ...partial, resolvedVia: [...resolvedVia, \"partial-name-match\"] },\n };\n }\n return {\n match: null,\n rejected: {\n modelId: partial.modelId,\n confidence: partial.confidence,\n reason: partial.reason,\n },\n };\n }\n\n return { match: null };\n }\n\n private exactMatch(model: string): MatchCandidate | null {\n const record = this.catalog.get(model);\n if (!record) return null;\n return {\n modelId: model,\n record,\n confidence: 1,\n strategy: \"exact-match\",\n reason: `Exact catalog match for \"${model}\"`,\n };\n }\n\n private catalogAliasMatch(model: string): MatchCandidate | null {\n const modelId = this.indexes.aliasIndex.get(model);\n if (!modelId) return null;\n const record = this.catalog.get(modelId);\n if (!record) return null;\n return {\n modelId,\n record,\n confidence: 1,\n strategy: \"catalog-alias-match\",\n reason: `Catalog alias \"${model}\" → \"${modelId}\"`,\n };\n }\n\n private slugMatch(model: string): MatchCandidate | null {\n const modelId = this.indexes.slugIndex.get(model);\n if (!modelId) return null;\n const record = this.catalog.get(modelId);\n if (!record) return null;\n return {\n modelId,\n record,\n confidence: 0.95,\n strategy: \"canonical-slug-match\",\n reason: `Canonical slug match \"${model}\" → \"${modelId}\"`,\n };\n }\n\n private inferProviderFromSlug(slug: string): string | undefined {\n const patterns = [\n ...this.ctx.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\n private providerPrefixInjection(\n model: string,\n provider: string | undefined,\n ): MatchCandidate | null {\n if (model.includes(\"/\")) return null;\n\n const prefixes: string[] = [];\n if (provider && provider !== \"openrouter\") {\n prefixes.push(provider);\n }\n const inferred = this.inferProviderFromSlug(model);\n if (inferred && !prefixes.includes(inferred)) prefixes.push(inferred);\n for (const p of this.indexes.providerPrefixesBySize) {\n if (!prefixes.includes(p)) prefixes.push(p);\n }\n\n for (const prefix of prefixes) {\n const candidate = `${prefix}/${model}`;\n let record = this.catalog.get(candidate);\n let modelId = candidate;\n if (!record) {\n const latest = this.findLatestVersioned(candidate);\n if (latest) {\n record = latest.record;\n modelId = latest.modelId;\n }\n }\n if (record) {\n const viaInference = inferred === prefix;\n return {\n modelId,\n record,\n confidence: 0.95,\n strategy: \"provider-prefix-injection\",\n reason: viaInference\n ? `Injected provider prefix \"${prefix}/\" inferred from model name pattern`\n : `Injected provider prefix \"${prefix}/\"`,\n };\n }\n }\n return null;\n }\n\n private crossProviderCorrection(model: string): MatchCandidate | null {\n if (!model.includes(\"/\")) return null;\n const [wrongPrefix, ...rest] = model.split(\"/\");\n const slug = rest.join(\"/\");\n const inferred = this.inferProviderFromSlug(slug);\n if (!inferred || inferred === wrongPrefix) return null;\n const candidate = `${inferred}/${slug}`;\n let record = this.catalog.get(candidate);\n let modelId = candidate;\n if (!record) {\n const latest = this.findLatestVersioned(candidate);\n if (!latest) return null;\n record = latest.record;\n modelId = latest.modelId;\n }\n return {\n modelId,\n record,\n confidence: 0.9,\n strategy: \"cross-provider-correction\",\n reason: `Corrected provider prefix from \"${wrongPrefix}\" to \"${inferred}\" based on model name pattern`,\n };\n }\n\n private dateSuffixMatch(model: string): MatchCandidate | null {\n if (model.includes(\"/\")) {\n const [prefix, slug] = model.split(\"/\", 2);\n const stripped = stripModelSlugSuffix(slug);\n if (stripped && stripped !== slug) {\n const candidate = `${prefix}/${stripped}`;\n const record = this.catalog.get(candidate);\n if (record) {\n return {\n modelId: candidate,\n record,\n confidence: 0.85,\n strategy: \"date-suffix-strip\",\n reason: `Stripped date from slug \"${slug}\" → \"${stripped}\"`,\n };\n }\n }\n }\n\n const latest = this.findLatestVersioned(model);\n if (latest) {\n return {\n modelId: latest.modelId,\n record: latest.record,\n confidence: 0.85,\n strategy: \"date-suffix-strip\",\n reason: `Matched \"${model}\" to versioned catalog entry \"${latest.modelId}\" (latest)`,\n };\n }\n return null;\n }\n\n private findLatestVersioned(\n baseModelId: string,\n ): { modelId: string; record: AiModelRecord } | null {\n const candidates: Array<{ modelId: string; record: AiModelRecord; suffix: string }> = [];\n for (const [modelId, record] of this.catalog) {\n if (modelId === baseModelId) continue;\n if (modelId.startsWith(`${baseModelId}-`)) {\n candidates.push({\n modelId,\n record,\n suffix: modelId.slice(baseModelId.length + 1),\n });\n }\n }\n if (candidates.length === 0) return null;\n candidates.sort((a, b) => b.suffix.localeCompare(a.suffix));\n const best = candidates[0]!;\n return { modelId: best.modelId, record: best.record };\n }\n\n private shorthandMap(): Record<string, string> {\n return { ...SHORTHAND_MAP, ...this.ctx.options.additionalShorthands };\n }\n\n private partialMatch(\n model: string,\n provider: string | undefined,\n ): (MatchCandidate & { resolvedVia?: ResolutionStrategy[] }) | null {\n let best: { modelId: string; record: AiModelRecord; score: number } | null = null;\n const inputTokens = tokenise(model);\n if (inputTokens.length === 0) return null;\n\n for (const record of this.catalog.values()) {\n const recordTokens = new Set([\n ...tokenise(record.modelId),\n ...tokenise(record.name ?? \"\"),\n ]);\n const intersection = inputTokens.filter((t) => recordTokens.has(t));\n const overlapRatio = intersection.length / inputTokens.length;\n let score = overlapRatio * 0.6;\n\n if (record.modelId.includes(model)) score += 0.3;\n const slug = modelSlug(record.modelId);\n if (model.includes(slug)) score += 0.2;\n\n if (provider && provider === record.providerId) score += 0.15;\n\n const lenPenalty =\n (Math.abs(model.length - slug.length) / Math.max(model.length, slug.length, 1)) * 0.1;\n score -= lenPenalty;\n\n if (!best || score > best.score) {\n best = { modelId: record.modelId, record, score };\n }\n }\n\n if (!best || best.score < 0.65) return null;\n return {\n modelId: best.modelId,\n record: best.record,\n confidence: 0.65,\n strategy: \"partial-name-match\",\n reason: `Partial token match (score ${best.score.toFixed(2)})`,\n };\n }\n\n private computeRoutedViaOpenRouter(\n modelId: string,\n record: AiModelRecord | null,\n provider: string | undefined,\n originalProvider: string | undefined,\n ): boolean {\n const override = this.ctx.options.routeViaOpenRouter;\n if (override === true) return true;\n if (override === false) return false;\n\n const norm = normalizeProvider(originalProvider) ?? provider;\n if (norm === \"openrouter\") return true;\n if (norm && norm !== \"openrouter\") {\n if (shouldDefaultRouteViaOpenRouter(norm, this.ctx.options.routingEnv)) return true;\n return false;\n }\n\n const recordProvider = record?.providerId;\n if (recordProvider && shouldDefaultRouteViaOpenRouter(recordProvider, this.ctx.options.routingEnv)) {\n return true;\n }\n\n if (record?.availableOnOpenRouter && modelId.includes(\"/\")) return true;\n return false;\n }\n\n private toOpenRouterSlug(\n modelId: string,\n provider: string | undefined,\n record: AiModelRecord | null,\n ): string {\n if (modelId.includes(\"/\")) return modelId;\n const vendor =\n record?.providerId ??\n (provider && provider !== \"openrouter\" ? provider : undefined);\n if (!vendor || vendor === \"openrouter\") return modelId;\n return `${vendor}/${modelId}`;\n }\n\n private success(args: {\n modelId: string;\n record: AiModelRecord | null;\n confidence: number;\n strategy: ResolutionStrategy;\n reason: string;\n resolvedVia: ResolutionStrategy[];\n normalisedInput: string;\n provider?: string;\n originalProvider?: string;\n }): ModelResolutionSuccess {\n const routedViaOpenRouter = this.computeRoutedViaOpenRouter(\n args.modelId,\n args.record,\n args.provider,\n args.originalProvider,\n );\n const modelId = routedViaOpenRouter\n ? this.toOpenRouterSlug(args.modelId, args.provider, args.record)\n : args.modelId;\n\n return {\n found: true,\n modelId,\n record: args.record,\n routedViaOpenRouter,\n confidence: args.confidence,\n resolvedVia: args.resolvedVia,\n resolvedReason: args.reason,\n normalisedInput: args.normalisedInput,\n };\n }\n}\n","import type { AiModelRecord } from \"./types.js\";\n\n/** OpenRouter `supported_parameters` values that indicate reasoning API support. */\nexport const REASONING_SUPPORTED_PARAMETERS = [\"reasoning\", \"include_reasoning\"] as const;\n\nexport type ReasoningModelInput = Pick<\n AiModelRecord,\n \"supportedParameters\" | \"pricing\" | \"openRouterPricing\"\n> & {\n supportsReasoning?: boolean;\n};\n\n/**\n * Whether the model accepts OpenRouter's `reasoning` request parameter\n * (effort, max_tokens, exclude, enabled).\n */\nexport function supportsReasoningParameter(model: Pick<AiModelRecord, \"supportedParameters\">): boolean {\n return model.supportedParameters.some((p) =>\n (REASONING_SUPPORTED_PARAMETERS as readonly string[]).includes(p),\n );\n}\n\n/**\n * Whether the model bills separate reasoning / thinking tokens\n * (`internal_reasoning` in OpenRouter pricing).\n */\nexport function hasReasoningPricing(\n model: Pick<AiModelRecord, \"pricing\" | \"openRouterPricing\">,\n): boolean {\n const raw = model.openRouterPricing?.internal_reasoning;\n if (raw !== undefined && raw !== null && String(raw).trim() !== \"\") {\n return true;\n }\n return model.pricing.reasoningUsdPerToken !== undefined;\n}\n\n/**\n * Compute `supportsReasoning` from catalog fields (used when normalizing catalog entries).\n */\nexport function computeSupportsReasoning(model: ReasoningModelInput): boolean {\n return supportsReasoningParameter(model) || hasReasoningPricing(model);\n}\n\n/**\n * True when the model supports reasoning tokens (API param and/or separate reasoning pricing).\n *\n * Prefer `model.supportsReasoning` on {@link AiModelRecord} after catalog load;\n * this helper also works when only partial fields are available.\n */\nexport function isReasoningModel(model: ReasoningModelInput): boolean {\n if (model.supportsReasoning !== undefined) {\n return model.supportsReasoning;\n }\n return computeSupportsReasoning(model);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAIO,SAAS,oBAAoB,SAAqD;AACvF,QAAM,aAAa,oBAAI,IAAoB;AAC3C,QAAM,YAAY,oBAAI,IAAoB;AAC1C,QAAM,eAAe,oBAAI,IAAoB;AAE7C,aAAW,UAAU,QAAQ,OAAO,GAAG;AACrC,eAAW,SAAS,OAAO,SAAS;AAClC,iBAAW,IAAI,gBAAgB,KAAK,GAAG,OAAO,OAAO;AAAA,IACvD;AACA,QAAI,OAAO,eAAe;AACxB,gBAAU,IAAI,gBAAgB,OAAO,aAAa,GAAG,OAAO,OAAO;AAAA,IACrE;AACA,UAAM,MAAM,OAAO;AACnB,iBAAa,IAAI,MAAM,aAAa,IAAI,GAAG,KAAK,KAAK,CAAC;AAAA,EACxD;AAEA,QAAM,yBA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M,IAAI,OAAO;AAAA,EAC7B;AAAA,EAEQ,QAAQ,MAUW;AACzB,UAAM,sBAAsB,KAAK;AAAA,MAC/B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AACA,UAAM,UAAU,sBACZ,KAAK,iBAAiB,KAAK,SAAS,KAAK,UAAU,KAAK,MAAM,IAC9D,KAAK;AAET,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,QAAQ,KAAK;AAAA,MACb;AAAA,MACA,YAAY,KAAK;AAAA,MACjB,aAAa,KAAK;AAAA,MAClB,gBAAgB,KAAK;AAAA,MACrB,iBAAiB,KAAK;AAAA,IACxB;AAAA,EACF;AACF;;;ACpiBO,IAAM,iCAAiC,CAAC,aAAa,mBAAmB;AAaxE,SAAS,2BAA2B,OAA4D;AACrG,SAAO,MAAM,oBAAoB;AAAA,IAAK,CAAC,MACpC,+BAAqD,SAAS,CAAC;AAAA,EAClE;AACF;AAMO,SAAS,oBACd,OACS;AACT,QAAM,MAAM,MAAM,mBAAmB;AACrC,MAAI,QAAQ,UAAa,QAAQ,QAAQ,OAAO,GAAG,EAAE,KAAK,MAAM,IAAI;AAClE,WAAO;AAAA,EACT;AACA,SAAO,MAAM,QAAQ,yBAAyB;AAChD;AAKO,SAAS,yBAAyB,OAAqC;AAC5E,SAAO,2BAA2B,KAAK,KAAK,oBAAoB,KAAK;AACvE;AAQO,SAAS,iBAAiB,OAAqC;AACpE,MAAI,MAAM,sBAAsB,QAAW;AACzC,WAAO,MAAM;AAAA,EACf;AACA,SAAO,yBAAyB,KAAK;AACvC;","names":[]}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkHBNYVRLZcjs = require('./chunk-HBNYVRLZ.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, _chunkHBNYVRLZcjs.AiModelsCatalogClient)(options);
|
|
11
11
|
await client.refresh();
|
|
12
|
-
const loaded = await
|
|
12
|
+
const loaded = await _chunkHBNYVRLZcjs.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 _chunkHBNYVRLZcjs.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, () => ( _chunkHBNYVRLZcjs.DEFAULT_DIRECT_CATALOG_URL)),
|
|
38
|
+
openRouterUrl: _nullishCoalesce(options.openRouterCatalogUrl, () => ( _chunkHBNYVRLZcjs.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-75ZVXZAV.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-75ZVXZAV.cjs","../src/catalog/catalogMaintenance.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACeA,MAAA,SAAsB,sBAAA,CACpB,QAAA,EAAiC,CAAC,CAAA,EACH;AAC/B,EAAA,MAAM,OAAA,EAAS,IAAI,4CAAA,CAAsB,OAAO,CAAA;AAChD,EAAA,MAAM,MAAA,CAAO,OAAA,CAAQ,CAAA;AACrB,EAAA,MAAM,OAAA,EAAS,MAAM,wDAAA,OAAyB,EAAS;AAAA,IACrD,QAAA,EAAU,OAAA,CAAQ,QAAA;AAAA,IAClB,KAAA,EAAO,OAAA,CAAQ,UAAA;AAAA,IACf,YAAA,EAAc;AAAA,EAChB,CAAC,CAAA;AACD,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,IAAA;AAAA,IACJ,WAAA,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;AAAA,EAChC,CAAA;AACF;AAkBA,MAAA,SAAsB,qBAAA,CACpB,QAAA,EAA6D,CAAC,CAAA,EAChC;AAC9B,EAAA,MAAM,OAAA,EAAS,MAAM,wDAAA,OAAyB,EAAS;AAAA,IACrD,QAAA,EAAU,OAAA,CAAQ,QAAA;AAAA,IAClB,KAAA,EAAO,OAAA,CAAQ,UAAA;AAAA,IACf,YAAA,mBAAc,OAAA,CAAQ,YAAA,UAAgB,OAAA,CAAQ,YAAA,IAAgB;AAAA,EAChE,CAAC,CAAA;AACD,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,MAAA,CAAO,MAAA,CAAO,KAAA,EAAO,EAAA,GAAK,MAAA,CAAO,UAAA,CAAW,KAAA,EAAO,CAAA;AAAA,IACvD,WAAA,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-75ZVXZAV.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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHBNYVRLZcjs = require('./chunk-HBNYVRLZ.cjs');
|
|
4
4
|
|
|
5
5
|
// src/models/filterModels.ts
|
|
6
6
|
function matchesSearch(record, search) {
|
|
@@ -46,7 +46,7 @@ function countModels(models, filters = {}) {
|
|
|
46
46
|
var AiModelsService = class {
|
|
47
47
|
|
|
48
48
|
constructor(options = {}) {
|
|
49
|
-
this.client = new (0,
|
|
49
|
+
this.client = new (0, _chunkHBNYVRLZcjs.AiModelsCatalogClient)(options);
|
|
50
50
|
}
|
|
51
51
|
async getAllModels() {
|
|
52
52
|
return this.client.getAllModels();
|
|
@@ -83,4 +83,4 @@ async function getModelInfo(modelIdOrAlias, options = {}, provider) {
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
exports.filterModels = filterModels; exports.countModels = countModels; exports.AiModelsService = AiModelsService; exports.getModelInfo = getModelInfo;
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
86
|
+
//# sourceMappingURL=chunk-76FHWQH3.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-76FHWQH3.cjs","../src/models/filterModels.ts","../src/models/AiModelsService.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACFA,SAAS,aAAA,CAAc,MAAA,EAAuB,MAAA,EAAyB;AACrE,EAAA,MAAM,EAAA,EAAI,MAAA,CAAO,WAAA,CAAY,CAAA;AAC7B,EAAA,OACE,MAAA,CAAO,OAAA,CAAQ,WAAA,CAAY,CAAA,CAAE,QAAA,CAAS,CAAC,EAAA,GACvC,MAAA,CAAO,IAAA,CAAK,WAAA,CAAY,CAAA,CAAE,QAAA,CAAS,CAAC,EAAA,GACpC,MAAA,CAAO,WAAA,CAAY,WAAA,CAAY,CAAA,CAAE,QAAA,CAAS,CAAC,EAAA,GAC3C,MAAA,CAAO,aAAA,CAAc,WAAA,CAAY,CAAA,CAAE,QAAA,CAAS,CAAC,EAAA,GAC7C,MAAA,CAAO,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,EAAA,GAAM,CAAA,CAAE,WAAA,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,KAAA,EAAO,cAAA,EAAgB,SAAS,CAAC,CAAA;AAAA,EACrE;AAAA,EAEA,MAAM,OAAA,CAAA,EAAyB;AAC7B,IAAA,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ,CAAA;AAAA,EAC5B;AACF,CAAA;AAEA,MAAA,SAAsB,YAAA,CACpB,cAAA,EACA,QAAA,EAAkC,CAAC,CAAA,EACnC,QAAA,EAC+B;AAC/B,EAAA,OAAO,IAAI,eAAA,CAAgB,OAAO,CAAA,CAAE,YAAA,CAAa,cAAA,EAAgB,QAAQ,CAAA;AAC3E;AFqBA;AACA;AACE;AACA;AACA;AACA;AACF,uJAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-76FHWQH3.cjs","sourcesContent":[null,"import type { AiModelRecord, ModelListFilters } from \"./types.js\";\n\nfunction matchesSearch(record: AiModelRecord, search: string): boolean {\n const q = search.toLowerCase();\n return (\n record.modelId.toLowerCase().includes(q) ||\n record.name.toLowerCase().includes(q) ||\n record.description.toLowerCase().includes(q) ||\n record.canonicalSlug.toLowerCase().includes(q) ||\n record.aliases.some((a) => a.toLowerCase().includes(q))\n );\n}\n\nexport function filterModels(\n models: Iterable<AiModelRecord>,\n filters: ModelListFilters = {},\n): AiModelRecord[] {\n let list = [...models];\n\n if (filters.providerId) {\n list = list.filter((m) => m.providerId === filters.providerId);\n }\n if (filters.status) {\n list = list.filter((m) => m.status === filters.status);\n }\n if (filters.outputModality) {\n list = list.filter((m) => m.outputModalities.includes(filters.outputModality!));\n }\n if (filters.inputModality) {\n list = list.filter((m) => m.inputModalities.includes(filters.inputModality!));\n }\n if (filters.supportedParameter) {\n list = list.filter((m) => m.supportedParameters.includes(filters.supportedParameter!));\n }\n if (filters.supportsTools !== undefined) {\n list = list.filter((m) => m.supportsTools === filters.supportsTools);\n }\n if (filters.supportsReasoning !== undefined) {\n list = list.filter((m) => m.supportsReasoning === filters.supportsReasoning);\n }\n if (filters.search) {\n list = list.filter((m) => matchesSearch(m, filters.search!));\n }\n\n list.sort((a, b) => a.name.localeCompare(b.name));\n\n const offset = filters.offset ?? 0;\n const limit = filters.limit ?? list.length;\n return list.slice(offset, offset + limit);\n}\n\nexport function countModels(\n models: Iterable<AiModelRecord>,\n filters: Omit<ModelListFilters, \"limit\" | \"offset\"> = {},\n): number {\n return filterModels(models, { ...filters, limit: Number.MAX_SAFE_INTEGER, offset: 0 }).length;\n}\n","import { AiModelsCatalogClient } from \"../catalog/AiModelsCatalogClient.js\";\nimport type { AiModelsCatalogClientOptions } from \"../catalog/AiModelsCatalogClient.js\";\nimport { countModels, filterModels } from \"./filterModels.js\";\nimport type { AiModelRecord, ModelListFilters, ModelListResult } from \"./types.js\";\n\nexport type AiModelsServiceOptions = AiModelsCatalogClientOptions;\n\n/**\n * High-level model catalog API — list, filter, count, and get full model info.\n */\nexport class AiModelsService {\n private readonly client: AiModelsCatalogClient;\n\n constructor(options: AiModelsServiceOptions = {}) {\n this.client = new AiModelsCatalogClient(options);\n }\n\n async getAllModels(): Promise<Map<string, AiModelRecord>> {\n return this.client.getAllModels();\n }\n\n async listModels(filters: ModelListFilters = {}): Promise<ModelListResult> {\n const all = await this.getAllModels();\n const total = countModels(all.values(), filters);\n const limit = filters.limit ?? 50;\n const offset = filters.offset ?? 0;\n const models = filterModels(all.values(), { ...filters, limit, offset });\n return { models, total, limit, offset };\n }\n\n async countModels(filters: Omit<ModelListFilters, \"limit\" | \"offset\"> = {}): Promise<number> {\n const all = await this.getAllModels();\n return countModels(all.values(), filters);\n }\n\n async getModelInfo(modelIdOrAlias: string, provider?: string): Promise<AiModelRecord | null> {\n return this.client.getModel(modelIdOrAlias, provider);\n }\n\n async resolve(\n modelIdOrAlias: string,\n provider?: string,\n ): Promise<import(\"../sync/modelNameResolver/types.js\").ModelResolutionResult> {\n return this.client.resolveModel({ model: modelIdOrAlias, provider });\n }\n\n async refresh(): Promise<void> {\n await this.client.refresh();\n }\n}\n\nexport async function getModelInfo(\n modelIdOrAlias: string,\n options: AiModelsServiceOptions = {},\n provider?: string,\n): Promise<AiModelRecord | null> {\n return new AiModelsService(options).getModelInfo(modelIdOrAlias, provider);\n}\n"]}
|
|
@@ -170,6 +170,18 @@ function shouldDefaultRouteViaOpenRouter(providerId, config) {
|
|
|
170
170
|
}
|
|
171
171
|
return false;
|
|
172
172
|
}
|
|
173
|
+
function isEffectiveOpenRouterTransport(config, input = {}) {
|
|
174
|
+
if (input.routeViaOpenRouter === true) return true;
|
|
175
|
+
if (input.routeViaOpenRouter === false) return false;
|
|
176
|
+
const provider = _optionalChain([input, 'access', _12 => _12.provider, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14(), 'access', _15 => _15.toLowerCase, 'call', _16 => _16()]);
|
|
177
|
+
if (provider === "openrouter") return true;
|
|
178
|
+
const vendor = _optionalChain([input, 'access', _17 => _17.modelId, 'optionalAccess', _18 => _18.includes, 'call', _19 => _19("/")]) === true ? input.modelId.split("/")[0].trim().toLowerCase() : provider;
|
|
179
|
+
if (vendor && vendor !== "openrouter") {
|
|
180
|
+
return shouldDefaultRouteViaOpenRouter(vendor, config);
|
|
181
|
+
}
|
|
182
|
+
if (config.hasOpenRouterKey && config.useOpenRouterExplicit) return true;
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
173
185
|
|
|
174
186
|
// src/sync/modelNameResolver/stripVersionSuffix.ts
|
|
175
187
|
var VERSION_STRIP_PATTERNS = [
|
|
@@ -221,5 +233,6 @@ function stripModelVersionSuffix(model) {
|
|
|
221
233
|
|
|
222
234
|
|
|
223
235
|
|
|
224
|
-
|
|
225
|
-
|
|
236
|
+
|
|
237
|
+
exports.DEFAULT_CONFIDENCE_THRESHOLD = DEFAULT_CONFIDENCE_THRESHOLD; exports.LOCAL_PROVIDERS = LOCAL_PROVIDERS; exports.PROVIDER_INFERENCE_MAP = PROVIDER_INFERENCE_MAP; exports.SHORTHAND_MAP = SHORTHAND_MAP; exports.normalizeString = normalizeString; exports.normalizeProvider = normalizeProvider; exports.tokenise = tokenise; exports.modelSlug = modelSlug; exports.stripModelSlugSuffix = stripModelSlugSuffix; exports.stripModelVersionSuffix = stripModelVersionSuffix; exports.providerIdToEnvKeyPrefix = providerIdToEnvKeyPrefix; exports.vendorApiKeyEnvName = vendorApiKeyEnvName; exports.loadOpenRouterRoutingEnv = loadOpenRouterRoutingEnv; exports.shouldDefaultRouteViaOpenRouter = shouldDefaultRouteViaOpenRouter; exports.isEffectiveOpenRouterTransport = isEffectiveOpenRouterTransport;
|
|
238
|
+
//# sourceMappingURL=chunk-BCX5CLJJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-BCX5CLJJ.cjs","../src/sync/modelNameResolver/constants.ts","../src/sync/modelNameResolver/normalize.ts","../src/sync/openRouterRoutingEnv.ts","../src/sync/modelNameResolver/stripVersionSuffix.ts"],"names":["stripped"],"mappings":"AAAA;ACAO,IAAM,6BAAA,EAA+B,GAAA;AAErC,IAAM,2BAAA,EAAqD;AAAA,EAChE,aAAA,EAAe,YAAA;AAAA,EACf,EAAA,EAAI,YAAA;AAAA,EACJ,GAAA,EAAK,QAAA;AAAA,EACL,SAAA,EAAW,QAAA;AAAA,EACX,MAAA,EAAQ,WAAA;AAAA,EACR,GAAA,EAAK,WAAA;AAAA,EACL,MAAA,EAAQ,QAAA;AAAA,EACR,GAAA,EAAK,QAAA;AAAA,EACL,WAAA,EAAa,QAAA;AAAA,EACb,MAAA,EAAQ,QAAA;AAAA,EACR,IAAA,EAAM,YAAA;AAAA,EACN,KAAA,EAAO,YAAA;AAAA,EACP,YAAA,EAAc,SAAA;AAAA,EACd,WAAA,EAAa;AACf,CAAA;AAEO,IAAM,gBAAA,kBAAkB,IAAI,GAAA,CAAI;AAAA,EACrC,QAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA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,IAAA,CAAK,CAAA,CACL,WAAA,CAAY,CAAA,CACZ,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CACjB,WAAA,CAAY,CAAA;AACjB;AAEO,SAAS,mBAAA,CAAoB,UAAA,EAA4B;AAC9D,EAAA,OAAO,CAAA,EAAA;AACT;AAcgB;AAGR,EAAA;AACA,EAAA;AACN,EAAA;AACM,IAAA;AACN,EAAA;AACA,EAAA;AACM,IAAA;AACN,EAAA;AAEM,EAAA;AACA,EAAA;AACA,EAAA;AAEC,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AACF;AAOgB;AAIT,EAAA;AACD,EAAA;AACA,EAAA;AACF,IAAA;AACF,EAAA;AACO,EAAA;AACT;AAYgB;AAIV,EAAA;AACA,EAAA;AAEE,EAAA;AACF,EAAA;AAEE,EAAA;AAKF,EAAA;AACF,IAAA;AACF,EAAA;AAEI,EAAA;AACG,EAAA;AACT;AH6EU;AACA;AItLG;AACL,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACR;AAGgB;AACd,EAAA;AACM,IAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACO,EAAA;AACT;AAMgB;AACR,EAAA;AACD,EAAA;AAED,EAAA;AACI,IAAA;AACA,IAAA;AACA,IAAA;AACAA,IAAAA;AACFA,IAAAA;AACF,MAAA;AACF,IAAA;AACA,IAAA;AACF,EAAA;AAEM,EAAA;AACC,EAAA;AACT;AJ+KU;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/chunk-BCX5CLJJ.cjs","sourcesContent":[null,"export const DEFAULT_CONFIDENCE_THRESHOLD = 0.6;\n\nexport const PROVIDER_NORMALISATION_MAP: Record<string, string> = {\n \"open-router\": \"openrouter\",\n or: \"openrouter\",\n oai: \"openai\",\n \"open-ai\": \"openai\",\n claude: \"anthropic\",\n ant: \"anthropic\",\n gemini: \"google\",\n gcp: \"google\",\n \"google-ai\": \"google\",\n vertex: \"google\",\n meta: \"meta-llama\",\n llama: \"meta-llama\",\n \"mistral-ai\": \"mistral\",\n \"cohere-ai\": \"cohere\",\n};\n\nexport const LOCAL_PROVIDERS = new Set([\n \"ollama\",\n \"lmstudio\",\n \"lm-studio\",\n \"localai\",\n \"local-ai\",\n \"llamacpp\",\n \"llama.cpp\",\n \"llamafile\",\n \"jan\",\n \"koboldcpp\",\n]);\n\nexport const PROVIDER_INFERENCE_MAP: Array<{\n pattern: RegExp;\n provider: string;\n notes?: string;\n}> = [\n { pattern: /^gpt-/, provider: \"openai\" },\n { pattern: /^o1($|-)/, provider: \"openai\" },\n { pattern: /^o3($|-)/, provider: \"openai\" },\n { pattern: /^o4($|-)/, provider: \"openai\" },\n { pattern: /^chatgpt-/, provider: \"openai\" },\n { pattern: /^text-davinci/, provider: \"openai\" },\n { pattern: /^dall-e/, provider: \"openai\" },\n { pattern: /^whisper/, provider: \"openai\" },\n { pattern: /^tts-/, provider: \"openai\" },\n { pattern: /^claude-/, provider: \"anthropic\" },\n { pattern: /^gemini-/, provider: \"google\" },\n { pattern: /^palm-/, provider: \"google\" },\n { pattern: /^bison/, provider: \"google\" },\n { pattern: /^llama-?[23]/, provider: \"meta-llama\" },\n { pattern: /^llama/, provider: \"meta-llama\" },\n { pattern: /^codellama/, provider: \"meta-llama\" },\n { pattern: /^mistral-/, provider: \"mistral\" },\n { pattern: /^mixtral-/, provider: \"mistral\" },\n { pattern: /^codestral/, provider: \"mistral\" },\n { pattern: /^ministral/, provider: \"mistral\" },\n { pattern: /^command-/, provider: \"cohere\" },\n { pattern: /^c4ai-/, provider: \"cohere\" },\n { pattern: /^deepseek-/, provider: \"deepseek\" },\n { pattern: /^grok-/, provider: \"x-ai\" },\n { pattern: /^qwen/, provider: \"qwen\" },\n { pattern: /^yi-/, provider: \"01-ai\" },\n { pattern: /^sonar/, provider: \"perplexity\" },\n { pattern: /^pplx-/, provider: \"perplexity\" },\n { pattern: /^titan-/, provider: \"amazon\" },\n { pattern: /^nova-/, provider: \"amazon\" },\n];\n\nexport const SHORTHAND_MAP: Record<string, string> = {\n gpt4: \"openai/gpt-4\",\n gpt4o: \"openai/gpt-4o\",\n \"gpt-4-omni\": \"openai/gpt-4o\",\n gpt4omni: \"openai/gpt-4o\",\n \"gpt4-turbo\": \"openai/gpt-4-turbo\",\n gpt4turbo: \"openai/gpt-4-turbo\",\n \"gpt4-mini\": \"openai/gpt-4o-mini\",\n \"gpt-4o-mini\": \"openai/gpt-4o-mini\",\n o1: \"openai/o1\",\n \"o1-mini\": \"openai/o1-mini\",\n o3: \"openai/o3\",\n \"o3-mini\": \"openai/o3-mini\",\n \"o4-mini\": \"openai/o4-mini\",\n \"3.5-turbo\": \"openai/gpt-3.5-turbo\",\n gpt35: \"openai/gpt-3.5-turbo\",\n gpt3: \"openai/gpt-3.5-turbo\",\n claude3: \"anthropic/claude-3-5-sonnet-20241022\",\n \"claude-3\": \"anthropic/claude-3-5-sonnet-20241022\",\n \"claude3-sonnet\": \"anthropic/claude-3-5-sonnet-20241022\",\n \"claude-sonnet\": \"anthropic/claude-3-5-sonnet-20241022\",\n \"claude-haiku\": \"anthropic/claude-3-5-haiku-20241022\",\n \"claude3-haiku\": \"anthropic/claude-3-5-haiku-20241022\",\n \"claude-opus\": \"anthropic/claude-opus-4\",\n \"claude3-opus\": \"anthropic/claude-3-opus-20240229\",\n claude4: \"anthropic/claude-opus-4\",\n \"claude4-sonnet\": \"anthropic/claude-sonnet-4\",\n \"claude4-opus\": \"anthropic/claude-opus-4\",\n sonnet: \"anthropic/claude-3-5-sonnet-20241022\",\n haiku: \"anthropic/claude-3-5-haiku-20241022\",\n opus: \"anthropic/claude-opus-4\",\n gemini: \"google/gemini-pro\",\n \"gemini-pro\": \"google/gemini-pro\",\n \"gemini-flash\": \"google/gemini-flash-1.5\",\n gemini2: \"google/gemini-2.0-flash-001\",\n \"gemini-2\": \"google/gemini-2.0-flash-001\",\n llama3: \"meta-llama/llama-3.1-8b-instruct\",\n \"llama-3\": \"meta-llama/llama-3.1-8b-instruct\",\n llama2: \"meta-llama/llama-2-13b-chat\",\n \"llama-2\": \"meta-llama/llama-2-13b-chat\",\n mistral: \"mistral/mistral-7b-instruct\",\n \"mistral-large\": \"mistral/mistral-large-latest\",\n mixtral: \"mistral/mixtral-8x7b-instruct\",\n deepseek: \"deepseek/deepseek-chat\",\n \"deepseek-r1\": \"deepseek/deepseek-r1\",\n};\n","import { PROVIDER_NORMALISATION_MAP } from \"./constants.js\";\n\nexport function normalizeString(input: string): string {\n let s = input.trim();\n s = s.replace(/\\s+/g, \" \").replace(/ /g, \"-\");\n s = s.toLowerCase();\n s = s.replace(/^\\/+|\\/+$/g, \"\");\n s = s.replace(/\\/+/g, \"/\");\n if (\n (s.startsWith('\"') && s.endsWith('\"')) ||\n (s.startsWith(\"'\") && s.endsWith(\"'\"))\n ) {\n s = s.slice(1, -1);\n }\n return s;\n}\n\nexport function normalizeProvider(provider: string | undefined): string | undefined {\n if (provider === undefined || provider === \"\") return undefined;\n const n = normalizeString(provider);\n return PROVIDER_NORMALISATION_MAP[n] ?? n;\n}\n\nexport function tokenise(s: string): string[] {\n return s.split(/[-_./]+/).filter(Boolean);\n}\n\nexport function modelSlug(modelId: string): string {\n const slash = modelId.indexOf(\"/\");\n return slash >= 0 ? modelId.slice(slash + 1) : modelId;\n}\n","import { loadDotenv } from \"@x12i/env\";\n\n/**\n * Env naming for vendor direct API keys: `{VENDOR}_API_KEY`\n * where VENDOR is the provider id in UPPER_SNAKE (hyphens → underscores).\n *\n * Examples: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `META_LLAMA_API_KEY`, `X_AI_API_KEY`\n */\nexport function providerIdToEnvKeyPrefix(providerId: string): string {\n return providerId\n .trim()\n .toLowerCase()\n .replace(/-/g, \"_\")\n .toUpperCase();\n}\n\nexport function vendorApiKeyEnvName(providerId: string): string {\n return `${providerIdToEnvKeyPrefix(providerId)}_API_KEY`;\n}\n\nexport type OpenRouterRoutingConfig = {\n /** OPENROUTER_API_KEY is set and non-empty */\n hasOpenRouterKey: boolean;\n /** USE_OPENROUTER=true or USE_OPENROUTER=1 */\n useOpenRouterExplicit: boolean;\n /** Read `{PROVIDER}_API_KEY` for a catalog provider id */\n getVendorApiKey(providerId: string): string | undefined;\n};\n\n/**\n * Load routing hints from process env and optional `.env` (via @x12/env).\n */\nexport function loadOpenRouterRoutingEnv(\n env: Record<string, string | undefined> = process.env,\n): OpenRouterRoutingConfig {\n const dotenv = loadDotenv();\n const merged: Record<string, string> = {};\n for (const [k, v] of Object.entries(dotenv)) {\n if (v !== undefined) merged[k] = v;\n }\n for (const [k, v] of Object.entries(env)) {\n if (v !== undefined) merged[k] = v;\n }\n\n const openRouterKey = merged.OPENROUTER_API_KEY?.trim();\n const useRaw = merged.USE_OPENROUTER?.trim().toLowerCase();\n const useOpenRouterExplicit = useRaw === \"true\" || useRaw === \"1\";\n\n return {\n hasOpenRouterKey: Boolean(openRouterKey),\n useOpenRouterExplicit,\n getVendorApiKey(providerId: string) {\n const name = vendorApiKeyEnvName(providerId);\n const val = merged[name]?.trim();\n return val || undefined;\n },\n };\n}\n\n/**\n * Default route via OpenRouter when:\n * 1. OPENROUTER_API_KEY is set AND USE_OPENROUTER=true|1, or\n * 2. OPENROUTER_API_KEY is set AND the vendor's `{VENDOR}_API_KEY` is missing.\n */\nexport function shouldDefaultRouteViaOpenRouter(\n providerId: string | undefined,\n config: OpenRouterRoutingConfig,\n): boolean {\n if (!config.hasOpenRouterKey) return false;\n if (config.useOpenRouterExplicit) return true;\n if (providerId && providerId !== \"openrouter\") {\n return !config.getVendorApiKey(providerId);\n }\n return false;\n}\n\nexport type EffectiveOpenRouterTransportInput = {\n provider?: string;\n modelId?: string;\n routeViaOpenRouter?: boolean;\n};\n\n/**\n * Whether the effective runtime transport is OpenRouter.\n * Honors explicit gateway override, then env defaults from {@link loadOpenRouterRoutingEnv}.\n */\nexport function isEffectiveOpenRouterTransport(\n config: OpenRouterRoutingConfig,\n input: EffectiveOpenRouterTransportInput = {},\n): boolean {\n if (input.routeViaOpenRouter === true) return true;\n if (input.routeViaOpenRouter === false) return false;\n\n const provider = input.provider?.trim().toLowerCase();\n if (provider === \"openrouter\") return true;\n\n const vendor =\n input.modelId?.includes(\"/\") === true\n ? input.modelId.split(\"/\")[0]!.trim().toLowerCase()\n : provider;\n\n if (vendor && vendor !== \"openrouter\") {\n return shouldDefaultRouteViaOpenRouter(vendor, config);\n }\n\n if (config.hasOpenRouterKey && config.useOpenRouterExplicit) return true;\n return false;\n}\n","import { normalizeString } from \"./normalize.js\";\n\n/** Patterns stripped when resolving versioned runtime model ids to catalog entries. */\nexport const VERSION_STRIP_PATTERNS: ReadonlyArray<{ re: RegExp; label: string }> = [\n { re: /-\\d{4}-\\d{2}-\\d{2}$/, label: \"date YYYY-MM-DD\" },\n { re: /-\\d{8}$/, label: \"date YYYYMMDD\" },\n { re: /-v\\d+$/, label: \"version -vN\" },\n { re: /-\\d+\\.\\d+\\.\\d+$/, label: \"semver\" },\n { re: /:\\d+[a-z]?$/i, label: \"colon version\" },\n { re: /-\\d{4,}$/, label: \"build number\" },\n { re: /@\\d+$/, label: \"epoch @NNNN\" },\n];\n\n/** Strip version/date suffix from a bare slug (no `provider/` prefix). */\nexport function stripModelSlugSuffix(slug: string): string | null {\n for (const { re } of VERSION_STRIP_PATTERNS) {\n if (re.test(slug)) {\n return slug.replace(re, \"\");\n }\n }\n return null;\n}\n\n/**\n * Strip a version/date suffix from a model id (`gpt-5.5-2026-04-23` → `gpt-5.5`,\n * `openai/gpt-4o-2024-08-06` → `openai/gpt-4o`). Returns null when nothing was stripped.\n */\nexport function stripModelVersionSuffix(model: string): string | null {\n const normalized = normalizeString(model);\n if (!normalized) return null;\n\n if (normalized.includes(\"/\")) {\n const slash = normalized.indexOf(\"/\");\n const prefix = normalized.slice(0, slash);\n const slug = normalized.slice(slash + 1);\n const stripped = stripModelSlugSuffix(slug);\n if (stripped && stripped !== slug) {\n return `${prefix}/${stripped}`;\n }\n return null;\n }\n\n const stripped = stripModelSlugSuffix(normalized);\n return stripped && stripped !== normalized ? stripped : null;\n}\n"]}
|