@x12i/ai-tools 1.0.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +146 -204
  3. package/dist/AiModelsCatalogClient-B5FMI9gj.d.cts +58 -0
  4. package/dist/AiModelsCatalogClient-CPPNI6Ry.d.ts +58 -0
  5. package/dist/aliases/index.cjs +4 -3
  6. package/dist/aliases/index.cjs.map +1 -1
  7. package/dist/aliases/index.d.cts +3 -5
  8. package/dist/aliases/index.d.ts +3 -5
  9. package/dist/aliases/index.js +2 -2
  10. package/dist/catalog/index.cjs +18 -9
  11. package/dist/catalog/index.cjs.map +1 -1
  12. package/dist/catalog/index.d.cts +13 -100
  13. package/dist/catalog/index.d.ts +13 -100
  14. package/dist/catalog/index.js +31 -23
  15. package/dist/{chunk-AJEKEWWB.js → chunk-2PTCWPHV.js} +17 -3
  16. package/dist/chunk-2PTCWPHV.js.map +1 -0
  17. package/dist/chunk-56R4XA2S.js +1 -0
  18. package/dist/chunk-5GUKLOEK.cjs +1 -0
  19. package/dist/chunk-5GUKLOEK.cjs.map +1 -0
  20. package/dist/chunk-5XAAMBDO.cjs +1988 -0
  21. package/dist/chunk-5XAAMBDO.cjs.map +1 -0
  22. package/dist/chunk-6BQBKROR.js +95 -0
  23. package/dist/chunk-6BQBKROR.js.map +1 -0
  24. package/dist/chunk-AB5GNXJ4.js +46 -0
  25. package/dist/chunk-AB5GNXJ4.js.map +1 -0
  26. package/dist/{chunk-O2A6OVEH.js → chunk-ANVONYJF.js} +2 -2
  27. package/dist/{chunk-O2A6OVEH.js.map → chunk-ANVONYJF.js.map} +1 -1
  28. package/dist/chunk-B3V2EHRY.js +225 -0
  29. package/dist/chunk-B3V2EHRY.js.map +1 -0
  30. package/dist/{chunk-QWAX7VQO.cjs → chunk-BAHBDADJ.cjs} +11 -11
  31. package/dist/{chunk-QWAX7VQO.cjs.map → chunk-BAHBDADJ.cjs.map} +1 -1
  32. package/dist/{chunk-TF4L2NEC.cjs → chunk-DXZOL3VN.cjs} +62 -313
  33. package/dist/chunk-DXZOL3VN.cjs.map +1 -0
  34. package/dist/chunk-EDMCKHO6.cjs +225 -0
  35. package/dist/chunk-EDMCKHO6.cjs.map +1 -0
  36. package/dist/{chunk-DJ5SWJDY.js → chunk-EYHMQVAL.js} +48 -299
  37. package/dist/chunk-EYHMQVAL.js.map +1 -0
  38. package/dist/chunk-GS7T56RP.cjs +8 -0
  39. package/dist/chunk-GS7T56RP.cjs.map +1 -0
  40. package/dist/chunk-NF2SKQR7.cjs +973 -0
  41. package/dist/chunk-NF2SKQR7.cjs.map +1 -0
  42. package/dist/chunk-OPN6BGNH.js +1985 -0
  43. package/dist/chunk-OPN6BGNH.js.map +1 -0
  44. package/dist/{chunk-7Q742NI3.cjs → chunk-PADNCGZB.cjs} +17 -3
  45. package/dist/chunk-PADNCGZB.cjs.map +1 -0
  46. package/dist/chunk-PRCICORG.cjs +95 -0
  47. package/dist/chunk-PRCICORG.cjs.map +1 -0
  48. package/dist/{chunk-6QGDZTGH.js → chunk-SIH4GPV4.js} +4 -29
  49. package/dist/chunk-SIH4GPV4.js.map +1 -0
  50. package/dist/chunk-U2YDDUVP.js +970 -0
  51. package/dist/chunk-U2YDDUVP.js.map +1 -0
  52. package/dist/{chunk-4NAY6HRP.js → chunk-VJHLO2R3.js} +7 -58
  53. package/dist/chunk-VJHLO2R3.js.map +1 -0
  54. package/dist/chunk-XAWBTX3N.cjs +46 -0
  55. package/dist/chunk-XAWBTX3N.cjs.map +1 -0
  56. package/dist/{chunk-AV6OE2YQ.cjs → chunk-XOKUDUUI.cjs} +14 -39
  57. package/dist/chunk-XOKUDUUI.cjs.map +1 -0
  58. package/dist/chunk-YQDSN6R6.cjs +86 -0
  59. package/dist/chunk-YQDSN6R6.cjs.map +1 -0
  60. package/dist/cli/index.cjs +59 -201
  61. package/dist/cli/index.cjs.map +1 -1
  62. package/dist/cli/index.js +53 -198
  63. package/dist/cli/index.js.map +1 -1
  64. package/dist/cost/index.cjs +19 -3
  65. package/dist/cost/index.cjs.map +1 -1
  66. package/dist/cost/index.d.cts +10 -50
  67. package/dist/cost/index.d.ts +10 -50
  68. package/dist/cost/index.js +18 -3
  69. package/dist/index.cjs +24 -16
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.d.cts +13 -13
  72. package/dist/index.d.ts +13 -13
  73. package/dist/index.js +44 -37
  74. package/dist/modelCache-BzRn6t_C.d.ts +113 -0
  75. package/dist/modelCache-CJftI-Ko.d.cts +113 -0
  76. package/dist/{modelNameResolver-DqFt7g6W.d.ts → modelNameResolver-5XkBMctP.d.ts} +2 -6
  77. package/dist/{modelNameResolver-D9V_GfUK.d.cts → modelNameResolver-C5CSTGFF.d.cts} +2 -6
  78. package/dist/models/index.cjs +9 -6
  79. package/dist/models/index.cjs.map +1 -1
  80. package/dist/models/index.d.cts +9 -31
  81. package/dist/models/index.d.ts +9 -31
  82. package/dist/models/index.js +9 -7
  83. package/dist/resolveUsageModel-BFwf80Hz.d.ts +140 -0
  84. package/dist/resolveUsageModel-C_YmGR1M.d.cts +140 -0
  85. package/dist/sync/index.cjs +7 -9
  86. package/dist/sync/index.cjs.map +1 -1
  87. package/dist/sync/index.d.cts +3 -8
  88. package/dist/sync/index.d.ts +3 -8
  89. package/dist/sync/index.js +8 -11
  90. package/dist/toolbox/index.cjs +1 -0
  91. package/dist/toolbox/index.cjs.map +1 -1
  92. package/dist/types-BrzJWsTU.d.cts +277 -0
  93. package/dist/types-BrzJWsTU.d.ts +277 -0
  94. package/package.json +9 -20
  95. package/src/data/models-catalog.json +670 -0
  96. package/src/data/openrouter-models-catalog.json +857 -0
  97. package/dist/AiModelsCatalogClient-4RF5BCDL.cjs +0 -9
  98. package/dist/AiModelsCatalogClient-4RF5BCDL.cjs.map +0 -1
  99. package/dist/AiModelsCatalogClient-CNeqFiFs.d.cts +0 -30
  100. package/dist/AiModelsCatalogClient-NUF3CBLW.js +0 -9
  101. package/dist/AiModelsCatalogClient-nwFoEaqL.d.ts +0 -30
  102. package/dist/catalox/index.cjs +0 -21
  103. package/dist/catalox/index.cjs.map +0 -1
  104. package/dist/catalox/index.d.cts +0 -11
  105. package/dist/catalox/index.d.ts +0 -11
  106. package/dist/catalox/index.js +0 -21
  107. package/dist/catalox/index.js.map +0 -1
  108. package/dist/chunk-4NAY6HRP.js.map +0 -1
  109. package/dist/chunk-6QGDZTGH.js.map +0 -1
  110. package/dist/chunk-7Q742NI3.cjs.map +0 -1
  111. package/dist/chunk-AJEKEWWB.js.map +0 -1
  112. package/dist/chunk-AV6OE2YQ.cjs.map +0 -1
  113. package/dist/chunk-C3H7RTFR.cjs +0 -1
  114. package/dist/chunk-C3H7RTFR.cjs.map +0 -1
  115. package/dist/chunk-DJ5SWJDY.js.map +0 -1
  116. package/dist/chunk-DKHGWHXP.cjs +0 -169
  117. package/dist/chunk-DKHGWHXP.cjs.map +0 -1
  118. package/dist/chunk-F2F4UEFD.cjs +0 -75
  119. package/dist/chunk-F2F4UEFD.cjs.map +0 -1
  120. package/dist/chunk-FGP3QXWL.cjs +0 -163
  121. package/dist/chunk-FGP3QXWL.cjs.map +0 -1
  122. package/dist/chunk-G2G4KSC5.js +0 -30
  123. package/dist/chunk-G2G4KSC5.js.map +0 -1
  124. package/dist/chunk-HN6UAQAE.cjs +0 -83
  125. package/dist/chunk-HN6UAQAE.cjs.map +0 -1
  126. package/dist/chunk-HS74X2OJ.cjs +0 -172
  127. package/dist/chunk-HS74X2OJ.cjs.map +0 -1
  128. package/dist/chunk-HYGXZY25.js +0 -163
  129. package/dist/chunk-HYGXZY25.js.map +0 -1
  130. package/dist/chunk-KQOALKKX.js +0 -75
  131. package/dist/chunk-KQOALKKX.js.map +0 -1
  132. package/dist/chunk-LYOU7CA2.cjs +0 -30
  133. package/dist/chunk-LYOU7CA2.cjs.map +0 -1
  134. package/dist/chunk-M5TMA73F.js +0 -1
  135. package/dist/chunk-M5TMA73F.js.map +0 -1
  136. package/dist/chunk-MX3AMQFC.js +0 -172
  137. package/dist/chunk-MX3AMQFC.js.map +0 -1
  138. package/dist/chunk-QCRLKVB3.cjs +0 -137
  139. package/dist/chunk-QCRLKVB3.cjs.map +0 -1
  140. package/dist/chunk-TF4L2NEC.cjs.map +0 -1
  141. package/dist/chunk-VRFVF5RH.js +0 -169
  142. package/dist/chunk-VRFVF5RH.js.map +0 -1
  143. package/dist/chunk-YHO57D2V.js +0 -83
  144. package/dist/chunk-YHO57D2V.js.map +0 -1
  145. package/dist/syncAiModelsCatalog-CnXRLm2c.d.cts +0 -32
  146. package/dist/syncAiModelsCatalog-DpkN_w7S.d.ts +0 -32
  147. package/dist/types-BYXnCvKx.d.cts +0 -137
  148. package/dist/types-BYXnCvKx.d.ts +0 -137
  149. package/dist/types-CX6QFNNy.d.cts +0 -144
  150. package/dist/types-CuiPDcVs.d.ts +0 -144
  151. package/dist/upsertAiModelRecord-C831wOIF.d.ts +0 -35
  152. package/dist/upsertAiModelRecord-CjY-sny0.d.cts +0 -35
  153. /package/dist/{AiModelsCatalogClient-NUF3CBLW.js.map → chunk-56R4XA2S.js.map} +0 -0
@@ -1,137 +0,0 @@
1
- /** OpenRouter Models API — https://openrouter.ai/api/v1/models */
2
- type OpenRouterOutputModality = "text" | "image" | "audio" | "embeddings" | "video" | "speech" | "transcription" | "all";
3
- type OpenRouterModelsQuery = {
4
- /** Comma-separated or "all" — default on our sync is "all". */
5
- output_modalities?: string;
6
- supported_parameters?: string;
7
- };
8
- type OpenRouterPricingApi = {
9
- prompt: string;
10
- completion: string;
11
- request: string;
12
- image: string;
13
- web_search?: string;
14
- internal_reasoning?: string;
15
- input_cache_read?: string;
16
- input_cache_write?: string;
17
- };
18
- type OpenRouterArchitectureApi = {
19
- modality?: string;
20
- input_modalities: string[];
21
- output_modalities: string[];
22
- tokenizer: string;
23
- instruct_type: string | null;
24
- };
25
- type OpenRouterTopProviderApi = {
26
- context_length: number;
27
- max_completion_tokens: number | null;
28
- is_moderated: boolean;
29
- };
30
- type OpenRouterDefaultParametersApi = {
31
- temperature?: number | null;
32
- top_p?: number | null;
33
- top_k?: number | null;
34
- frequency_penalty?: number | null;
35
- presence_penalty?: number | null;
36
- repetition_penalty?: number | null;
37
- };
38
- type OpenRouterModelApi = {
39
- id: string;
40
- canonical_slug: string;
41
- hugging_face_id?: string | null;
42
- name: string;
43
- created: number;
44
- description: string;
45
- context_length: number;
46
- architecture: OpenRouterArchitectureApi;
47
- pricing: OpenRouterPricingApi;
48
- top_provider: OpenRouterTopProviderApi;
49
- per_request_limits: unknown | null;
50
- supported_parameters: string[];
51
- default_parameters: OpenRouterDefaultParametersApi | null;
52
- supported_voices?: unknown | null;
53
- knowledge_cutoff?: string | null;
54
- expiration_date?: string | null;
55
- links?: {
56
- details?: string;
57
- } | null;
58
- };
59
- type OpenRouterModelsResponse = {
60
- data: OpenRouterModelApi[];
61
- };
62
-
63
- type AiModelPricing = {
64
- promptUsdPerToken: number;
65
- completionUsdPerToken: number;
66
- imageUsdPerUnit: number;
67
- requestUsdPerRequest: number;
68
- cacheReadUsdPerToken?: number;
69
- cacheWriteUsdPerToken?: number;
70
- reasoningUsdPerToken?: number;
71
- webSearchUsdPerRequest?: number;
72
- openRouterMarkupUsdPerInputToken?: number;
73
- openRouterMarkupUsdPerOutputToken?: number;
74
- pricedAt: string;
75
- source: "openrouter" | "direct" | "manual";
76
- };
77
- /**
78
- * Canonical catalog record — mirrors OpenRouter Models API fields plus normalized pricing.
79
- * Stored as-is in Catalox `data`; scalar fields duplicated in `indexed` for queries.
80
- */
81
- type AiModelRecord = {
82
- modelId: string;
83
- name: string;
84
- providerId: string;
85
- canonicalSlug: string;
86
- status: "active" | "deprecated" | "unknown";
87
- description: string;
88
- created: number;
89
- expirationDate: string | null;
90
- contextLength: number;
91
- maxCompletionTokens: number | null;
92
- isModerated: boolean;
93
- modality: string;
94
- inputModalities: string[];
95
- outputModalities: string[];
96
- tokenizer: string;
97
- instructType: string | null;
98
- supportedParameters: string[];
99
- defaultParameters: OpenRouterDefaultParametersApi | null;
100
- perRequestLimits: unknown | null;
101
- pricing: AiModelPricing;
102
- /** Raw OpenRouter pricing strings (USD per token/request/unit). */
103
- openRouterPricing: OpenRouterPricingApi;
104
- architecture: OpenRouterArchitectureApi;
105
- topProvider: OpenRouterTopProviderApi;
106
- /** Full OpenRouter API object — complete mirror for forward compatibility. */
107
- openRouter: OpenRouterModelApi;
108
- aliases: string[];
109
- availableOnOpenRouter: boolean;
110
- supportsStreaming: boolean;
111
- supportsTools: boolean;
112
- /** Exposes reasoning/thinking tokens (OpenRouter `reasoning` param and/or `internal_reasoning` pricing). */
113
- supportsReasoning: boolean;
114
- primaryOutputModality: string;
115
- syncedAt: string;
116
- syncSource: "openrouter" | "manual";
117
- };
118
- type ModelListFilters = {
119
- providerId?: string;
120
- status?: AiModelRecord["status"];
121
- outputModality?: string;
122
- inputModality?: string;
123
- supportedParameter?: string;
124
- supportsTools?: boolean;
125
- supportsReasoning?: boolean;
126
- search?: string;
127
- limit?: number;
128
- offset?: number;
129
- };
130
- type ModelListResult = {
131
- models: AiModelRecord[];
132
- total: number;
133
- limit: number;
134
- offset: number;
135
- };
136
-
137
- export type { AiModelPricing as A, ModelListFilters as M, OpenRouterArchitectureApi as O, AiModelRecord as a, ModelListResult as b, OpenRouterModelApi as c, OpenRouterModelsQuery as d, OpenRouterModelsResponse as e, OpenRouterOutputModality as f, OpenRouterPricingApi as g, OpenRouterTopProviderApi as h };
@@ -1,144 +0,0 @@
1
- import { a as AiModelRecord } from './types-BYXnCvKx.cjs';
2
-
3
- type AliasEntry = {
4
- modelId: string;
5
- provider: string;
6
- description?: string;
7
- tags?: string[];
8
- addedAt: string;
9
- updatedAt: string;
10
- };
11
- type AliasFileSchema = {
12
- $schema?: string;
13
- version: 1;
14
- updatedAt: string;
15
- aliases: Record<string, AliasEntry>;
16
- };
17
- type ResolvedModelRef = {
18
- alias: string;
19
- entry: AliasEntry;
20
- modelRecord: AiModelRecord | null;
21
- modelId: string;
22
- provider: string;
23
- name: string;
24
- };
25
- type AliasValidationReport = {
26
- total: number;
27
- ok: number;
28
- unknown: number;
29
- broken: number;
30
- entries: Array<{
31
- name: string;
32
- status: "ok" | "unknown" | "broken";
33
- modelId: string;
34
- resolvedName?: string;
35
- issue?: string;
36
- }>;
37
- };
38
-
39
- type AliasRegistryOptions = {
40
- aliasesPath?: string;
41
- };
42
- declare class AliasRegistry {
43
- private readonly aliasesPath;
44
- constructor(options?: AliasRegistryOptions);
45
- get path(): string;
46
- exists(): boolean;
47
- init(): void;
48
- load(): AliasFileSchema;
49
- get(aliasName: string): AliasEntry | null;
50
- list(filter?: {
51
- tag?: string;
52
- }): Array<{
53
- name: string;
54
- } & AliasEntry>;
55
- set(aliasName: string, entry: Omit<AliasEntry, "addedAt" | "updatedAt">): AliasEntry;
56
- remove(aliasName: string): boolean;
57
- rename(from: string, to: string, options?: {
58
- force?: boolean;
59
- }): void;
60
- private writeFile;
61
- }
62
-
63
- /**
64
- * Env naming for vendor direct API keys: `{VENDOR}_API_KEY`
65
- * where VENDOR is the provider id in UPPER_SNAKE (hyphens → underscores).
66
- *
67
- * Examples: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `META_LLAMA_API_KEY`, `X_AI_API_KEY`
68
- */
69
- declare function providerIdToEnvKeyPrefix(providerId: string): string;
70
- declare function vendorApiKeyEnvName(providerId: string): string;
71
- type OpenRouterRoutingConfig = {
72
- /** OPENROUTER_API_KEY is set and non-empty */
73
- hasOpenRouterKey: boolean;
74
- /** USE_OPENROUTER=true or USE_OPENROUTER=1 */
75
- useOpenRouterExplicit: boolean;
76
- /** Read `{PROVIDER}_API_KEY` for a catalog provider id */
77
- getVendorApiKey(providerId: string): string | undefined;
78
- };
79
- /**
80
- * Load routing hints from process env and optional `.env` (via @x12/env).
81
- */
82
- declare function loadOpenRouterRoutingEnv(env?: Record<string, string | undefined>): OpenRouterRoutingConfig;
83
- /**
84
- * Default route via OpenRouter when:
85
- * 1. OPENROUTER_API_KEY is set AND USE_OPENROUTER=true|1, or
86
- * 2. OPENROUTER_API_KEY is set AND the vendor's `{VENDOR}_API_KEY` is missing.
87
- */
88
- declare function shouldDefaultRouteViaOpenRouter(providerId: string | undefined, config: OpenRouterRoutingConfig): boolean;
89
-
90
- type ModelResolutionInput = {
91
- /** Provider hint (openrouter, openai, anthropic, …). May be omitted. */
92
- provider?: string;
93
- /** Model id, alias, shorthand, or partial name. Required. */
94
- model: string;
95
- };
96
- type ResolutionStrategy = "alias-registry" | "alias-as-provider-correction" | "exact-match" | "catalog-alias-match" | "canonical-slug-match" | "provider-prefix-injection" | "cross-provider-correction" | "version-suffix-strip" | "date-suffix-strip" | "shorthand-expansion" | "partial-name-match" | "local-provider-passthrough";
97
- type ModelResolutionSuccess = {
98
- found: true;
99
- modelId: string;
100
- record: AiModelRecord | null;
101
- routedViaOpenRouter: boolean;
102
- confidence: number;
103
- resolvedVia: ResolutionStrategy[];
104
- resolvedReason: string;
105
- normalisedInput: string;
106
- };
107
- type ModelResolutionNotFound = {
108
- found: false;
109
- modelId: null;
110
- record: null;
111
- attemptedStrategies: ResolutionStrategy[];
112
- bestRejectedCandidate?: {
113
- modelId: string;
114
- confidence: number;
115
- reason: string;
116
- };
117
- reason: string;
118
- };
119
- type ModelResolutionResult = ModelResolutionSuccess | ModelResolutionNotFound;
120
- type ModelResolverOptions = {
121
- confidenceThreshold?: number;
122
- aliasRegistry?: AliasRegistry;
123
- additionalShorthands?: Record<string, string>;
124
- additionalProviderPatterns?: Array<{
125
- pattern: RegExp;
126
- provider: string;
127
- }>;
128
- additionalLocalProviders?: string[];
129
- /** Env-based OpenRouter vs direct routing. Defaults to loadOpenRouterRoutingEnv(). */
130
- routingEnv?: OpenRouterRoutingConfig;
131
- };
132
- type CatalogIndexes = {
133
- aliasIndex: Map<string, string>;
134
- slugIndex: Map<string, string>;
135
- providerPrefixesBySize: string[];
136
- };
137
- /** @deprecated Use ModelResolutionSuccess via ModelNameResolver */
138
- type ResolvedModel = {
139
- catalogModel: AiModelRecord;
140
- matchedAlias: string;
141
- routedViaOpenRouter: boolean;
142
- };
143
-
144
- export { type AliasEntry as A, type CatalogIndexes as C, type ModelResolutionInput as M, type OpenRouterRoutingConfig as O, type ResolutionStrategy as R, type AliasFileSchema as a, AliasRegistry as b, type AliasRegistryOptions as c, type AliasValidationReport as d, type ModelResolutionNotFound as e, type ModelResolutionResult as f, type ModelResolutionSuccess as g, type ModelResolverOptions as h, type ResolvedModel as i, type ResolvedModelRef as j, loadOpenRouterRoutingEnv as l, providerIdToEnvKeyPrefix as p, shouldDefaultRouteViaOpenRouter as s, vendorApiKeyEnvName as v };
@@ -1,144 +0,0 @@
1
- import { a as AiModelRecord } from './types-BYXnCvKx.js';
2
-
3
- type AliasEntry = {
4
- modelId: string;
5
- provider: string;
6
- description?: string;
7
- tags?: string[];
8
- addedAt: string;
9
- updatedAt: string;
10
- };
11
- type AliasFileSchema = {
12
- $schema?: string;
13
- version: 1;
14
- updatedAt: string;
15
- aliases: Record<string, AliasEntry>;
16
- };
17
- type ResolvedModelRef = {
18
- alias: string;
19
- entry: AliasEntry;
20
- modelRecord: AiModelRecord | null;
21
- modelId: string;
22
- provider: string;
23
- name: string;
24
- };
25
- type AliasValidationReport = {
26
- total: number;
27
- ok: number;
28
- unknown: number;
29
- broken: number;
30
- entries: Array<{
31
- name: string;
32
- status: "ok" | "unknown" | "broken";
33
- modelId: string;
34
- resolvedName?: string;
35
- issue?: string;
36
- }>;
37
- };
38
-
39
- type AliasRegistryOptions = {
40
- aliasesPath?: string;
41
- };
42
- declare class AliasRegistry {
43
- private readonly aliasesPath;
44
- constructor(options?: AliasRegistryOptions);
45
- get path(): string;
46
- exists(): boolean;
47
- init(): void;
48
- load(): AliasFileSchema;
49
- get(aliasName: string): AliasEntry | null;
50
- list(filter?: {
51
- tag?: string;
52
- }): Array<{
53
- name: string;
54
- } & AliasEntry>;
55
- set(aliasName: string, entry: Omit<AliasEntry, "addedAt" | "updatedAt">): AliasEntry;
56
- remove(aliasName: string): boolean;
57
- rename(from: string, to: string, options?: {
58
- force?: boolean;
59
- }): void;
60
- private writeFile;
61
- }
62
-
63
- /**
64
- * Env naming for vendor direct API keys: `{VENDOR}_API_KEY`
65
- * where VENDOR is the provider id in UPPER_SNAKE (hyphens → underscores).
66
- *
67
- * Examples: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `META_LLAMA_API_KEY`, `X_AI_API_KEY`
68
- */
69
- declare function providerIdToEnvKeyPrefix(providerId: string): string;
70
- declare function vendorApiKeyEnvName(providerId: string): string;
71
- type OpenRouterRoutingConfig = {
72
- /** OPENROUTER_API_KEY is set and non-empty */
73
- hasOpenRouterKey: boolean;
74
- /** USE_OPENROUTER=true or USE_OPENROUTER=1 */
75
- useOpenRouterExplicit: boolean;
76
- /** Read `{PROVIDER}_API_KEY` for a catalog provider id */
77
- getVendorApiKey(providerId: string): string | undefined;
78
- };
79
- /**
80
- * Load routing hints from process env and optional `.env` (via @x12/env).
81
- */
82
- declare function loadOpenRouterRoutingEnv(env?: Record<string, string | undefined>): OpenRouterRoutingConfig;
83
- /**
84
- * Default route via OpenRouter when:
85
- * 1. OPENROUTER_API_KEY is set AND USE_OPENROUTER=true|1, or
86
- * 2. OPENROUTER_API_KEY is set AND the vendor's `{VENDOR}_API_KEY` is missing.
87
- */
88
- declare function shouldDefaultRouteViaOpenRouter(providerId: string | undefined, config: OpenRouterRoutingConfig): boolean;
89
-
90
- type ModelResolutionInput = {
91
- /** Provider hint (openrouter, openai, anthropic, …). May be omitted. */
92
- provider?: string;
93
- /** Model id, alias, shorthand, or partial name. Required. */
94
- model: string;
95
- };
96
- type ResolutionStrategy = "alias-registry" | "alias-as-provider-correction" | "exact-match" | "catalog-alias-match" | "canonical-slug-match" | "provider-prefix-injection" | "cross-provider-correction" | "version-suffix-strip" | "date-suffix-strip" | "shorthand-expansion" | "partial-name-match" | "local-provider-passthrough";
97
- type ModelResolutionSuccess = {
98
- found: true;
99
- modelId: string;
100
- record: AiModelRecord | null;
101
- routedViaOpenRouter: boolean;
102
- confidence: number;
103
- resolvedVia: ResolutionStrategy[];
104
- resolvedReason: string;
105
- normalisedInput: string;
106
- };
107
- type ModelResolutionNotFound = {
108
- found: false;
109
- modelId: null;
110
- record: null;
111
- attemptedStrategies: ResolutionStrategy[];
112
- bestRejectedCandidate?: {
113
- modelId: string;
114
- confidence: number;
115
- reason: string;
116
- };
117
- reason: string;
118
- };
119
- type ModelResolutionResult = ModelResolutionSuccess | ModelResolutionNotFound;
120
- type ModelResolverOptions = {
121
- confidenceThreshold?: number;
122
- aliasRegistry?: AliasRegistry;
123
- additionalShorthands?: Record<string, string>;
124
- additionalProviderPatterns?: Array<{
125
- pattern: RegExp;
126
- provider: string;
127
- }>;
128
- additionalLocalProviders?: string[];
129
- /** Env-based OpenRouter vs direct routing. Defaults to loadOpenRouterRoutingEnv(). */
130
- routingEnv?: OpenRouterRoutingConfig;
131
- };
132
- type CatalogIndexes = {
133
- aliasIndex: Map<string, string>;
134
- slugIndex: Map<string, string>;
135
- providerPrefixesBySize: string[];
136
- };
137
- /** @deprecated Use ModelResolutionSuccess via ModelNameResolver */
138
- type ResolvedModel = {
139
- catalogModel: AiModelRecord;
140
- matchedAlias: string;
141
- routedViaOpenRouter: boolean;
142
- };
143
-
144
- export { type AliasEntry as A, type CatalogIndexes as C, type ModelResolutionInput as M, type OpenRouterRoutingConfig as O, type ResolutionStrategy as R, type AliasFileSchema as a, AliasRegistry as b, type AliasRegistryOptions as c, type AliasValidationReport as d, type ModelResolutionNotFound as e, type ModelResolutionResult as f, type ModelResolutionSuccess as g, type ModelResolverOptions as h, type ResolvedModel as i, type ResolvedModelRef as j, loadOpenRouterRoutingEnv as l, providerIdToEnvKeyPrefix as p, shouldDefaultRouteViaOpenRouter as s, vendorApiKeyEnvName as v };
@@ -1,35 +0,0 @@
1
- import { Firestore } from 'firebase-admin/firestore';
2
- import { CataloxContext } from '@x12i/catalox';
3
- import { a as AiModelRecord } from './types-BYXnCvKx.js';
4
-
5
- /** Firestore rejects `undefined` — strip before write. */
6
- declare function sanitizeForFirestore<T>(value: T): T;
7
- type UpsertAiModelRecordOptions = {
8
- firestore: Firestore;
9
- context: CataloxContext;
10
- catalogId: string;
11
- record: AiModelRecord;
12
- };
13
- /**
14
- * Upserts one ai-models row via Firestore (safe doc ids for `provider/model` ids).
15
- */
16
- declare function upsertAiModelRecord(options: UpsertAiModelRecordOptions): Promise<void>;
17
- type BatchUpsertProgress = {
18
- completed: number;
19
- total: number;
20
- phase: "loading-existing" | "writing";
21
- };
22
- type BatchUpsertAiModelRecordsOptions = {
23
- onProgress?: (progress: BatchUpsertProgress) => void;
24
- maxChunkRetries?: number;
25
- };
26
- type BatchUpsertResult = {
27
- upserted: number;
28
- failed: Array<{
29
- modelId: string;
30
- error: string;
31
- }>;
32
- };
33
- declare function batchUpsertAiModelRecords(firestore: Firestore, catalogId: string, context: CataloxContext, records: AiModelRecord[], batchOptions?: BatchUpsertAiModelRecordsOptions): Promise<BatchUpsertResult>;
34
-
35
- export { type BatchUpsertProgress as B, batchUpsertAiModelRecords as b, sanitizeForFirestore as s, upsertAiModelRecord as u };
@@ -1,35 +0,0 @@
1
- import { Firestore } from 'firebase-admin/firestore';
2
- import { CataloxContext } from '@x12i/catalox';
3
- import { a as AiModelRecord } from './types-BYXnCvKx.cjs';
4
-
5
- /** Firestore rejects `undefined` — strip before write. */
6
- declare function sanitizeForFirestore<T>(value: T): T;
7
- type UpsertAiModelRecordOptions = {
8
- firestore: Firestore;
9
- context: CataloxContext;
10
- catalogId: string;
11
- record: AiModelRecord;
12
- };
13
- /**
14
- * Upserts one ai-models row via Firestore (safe doc ids for `provider/model` ids).
15
- */
16
- declare function upsertAiModelRecord(options: UpsertAiModelRecordOptions): Promise<void>;
17
- type BatchUpsertProgress = {
18
- completed: number;
19
- total: number;
20
- phase: "loading-existing" | "writing";
21
- };
22
- type BatchUpsertAiModelRecordsOptions = {
23
- onProgress?: (progress: BatchUpsertProgress) => void;
24
- maxChunkRetries?: number;
25
- };
26
- type BatchUpsertResult = {
27
- upserted: number;
28
- failed: Array<{
29
- modelId: string;
30
- error: string;
31
- }>;
32
- };
33
- declare function batchUpsertAiModelRecords(firestore: Firestore, catalogId: string, context: CataloxContext, records: AiModelRecord[], batchOptions?: BatchUpsertAiModelRecordsOptions): Promise<BatchUpsertResult>;
34
-
35
- export { type BatchUpsertProgress as B, batchUpsertAiModelRecords as b, sanitizeForFirestore as s, upsertAiModelRecord as u };