@x12i/ai-tools 1.0.4 → 2.0.1
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/CHANGELOG.md +23 -0
- package/README.md +146 -204
- package/dist/AiModelsCatalogClient-B5FMI9gj.d.cts +58 -0
- package/dist/AiModelsCatalogClient-CPPNI6Ry.d.ts +58 -0
- package/dist/aliases/index.cjs +4 -3
- package/dist/aliases/index.cjs.map +1 -1
- package/dist/aliases/index.d.cts +3 -5
- package/dist/aliases/index.d.ts +3 -5
- package/dist/aliases/index.js +2 -2
- package/dist/catalog/index.cjs +18 -9
- package/dist/catalog/index.cjs.map +1 -1
- package/dist/catalog/index.d.cts +13 -100
- package/dist/catalog/index.d.ts +13 -100
- package/dist/catalog/index.js +31 -23
- package/dist/{chunk-AJEKEWWB.js → chunk-2PTCWPHV.js} +17 -3
- package/dist/chunk-2PTCWPHV.js.map +1 -0
- package/dist/chunk-56R4XA2S.js +1 -0
- package/dist/chunk-5GUKLOEK.cjs +1 -0
- package/dist/chunk-5GUKLOEK.cjs.map +1 -0
- package/dist/chunk-5IZ7PLY2.cjs +51 -0
- package/dist/chunk-5IZ7PLY2.cjs.map +1 -0
- package/dist/chunk-5XAAMBDO.cjs +1988 -0
- package/dist/chunk-5XAAMBDO.cjs.map +1 -0
- package/dist/chunk-6BQBKROR.js +95 -0
- package/dist/chunk-6BQBKROR.js.map +1 -0
- package/dist/chunk-AB5GNXJ4.js +46 -0
- package/dist/chunk-AB5GNXJ4.js.map +1 -0
- package/dist/{chunk-O2A6OVEH.js → chunk-ANVONYJF.js} +2 -2
- package/dist/{chunk-O2A6OVEH.js.map → chunk-ANVONYJF.js.map} +1 -1
- package/dist/chunk-B3V2EHRY.js +225 -0
- package/dist/chunk-B3V2EHRY.js.map +1 -0
- package/dist/{chunk-QWAX7VQO.cjs → chunk-BAHBDADJ.cjs} +11 -11
- package/dist/{chunk-QWAX7VQO.cjs.map → chunk-BAHBDADJ.cjs.map} +1 -1
- package/dist/chunk-CTM35DMA.js +948 -0
- package/dist/chunk-CTM35DMA.js.map +1 -0
- package/dist/{chunk-TF4L2NEC.cjs → chunk-DXZOL3VN.cjs} +62 -313
- package/dist/chunk-DXZOL3VN.cjs.map +1 -0
- package/dist/chunk-EDMCKHO6.cjs +225 -0
- package/dist/chunk-EDMCKHO6.cjs.map +1 -0
- package/dist/{chunk-DJ5SWJDY.js → chunk-EYHMQVAL.js} +48 -299
- package/dist/chunk-EYHMQVAL.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs +8 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -0
- package/dist/chunk-OPN6BGNH.js +1985 -0
- package/dist/chunk-OPN6BGNH.js.map +1 -0
- package/dist/{chunk-7Q742NI3.cjs → chunk-PADNCGZB.cjs} +17 -3
- package/dist/chunk-PADNCGZB.cjs.map +1 -0
- package/dist/chunk-PRCICORG.cjs +95 -0
- package/dist/chunk-PRCICORG.cjs.map +1 -0
- package/dist/{chunk-6QGDZTGH.js → chunk-SIH4GPV4.js} +4 -29
- package/dist/chunk-SIH4GPV4.js.map +1 -0
- package/dist/{chunk-4NAY6HRP.js → chunk-VJHLO2R3.js} +7 -58
- package/dist/chunk-VJHLO2R3.js.map +1 -0
- package/dist/chunk-WOHMHXRZ.cjs +951 -0
- package/dist/chunk-WOHMHXRZ.cjs.map +1 -0
- package/dist/chunk-XAWBTX3N.cjs +46 -0
- package/dist/chunk-XAWBTX3N.cjs.map +1 -0
- package/dist/{chunk-AV6OE2YQ.cjs → chunk-XOKUDUUI.cjs} +14 -39
- package/dist/chunk-XOKUDUUI.cjs.map +1 -0
- package/dist/chunk-YQDSN6R6.cjs +86 -0
- package/dist/chunk-YQDSN6R6.cjs.map +1 -0
- package/dist/chunk-YQVY7CWT.js +51 -0
- package/dist/chunk-YQVY7CWT.js.map +1 -0
- package/dist/cli/index.cjs +59 -201
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +53 -198
- package/dist/cli/index.js.map +1 -1
- package/dist/cost/index.cjs +19 -3
- package/dist/cost/index.cjs.map +1 -1
- package/dist/cost/index.d.cts +10 -50
- package/dist/cost/index.d.ts +10 -50
- package/dist/cost/index.js +18 -3
- package/dist/index.cjs +36 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -13
- package/dist/index.d.ts +15 -13
- package/dist/index.js +56 -35
- package/dist/modelCache-BzRn6t_C.d.ts +113 -0
- package/dist/modelCache-CJftI-Ko.d.cts +113 -0
- package/dist/{modelNameResolver-DqFt7g6W.d.ts → modelNameResolver-5XkBMctP.d.ts} +2 -6
- package/dist/{modelNameResolver-D9V_GfUK.d.cts → modelNameResolver-C5CSTGFF.d.cts} +2 -6
- package/dist/models/index.cjs +9 -6
- package/dist/models/index.cjs.map +1 -1
- package/dist/models/index.d.cts +9 -31
- package/dist/models/index.d.ts +9 -31
- package/dist/models/index.js +9 -7
- package/dist/profiles/index.cjs +18 -0
- package/dist/profiles/index.cjs.map +1 -0
- package/dist/profiles/index.d.cts +40 -0
- package/dist/profiles/index.d.ts +40 -0
- package/dist/profiles/index.js +17 -0
- package/dist/resolveUsageModel-BFwf80Hz.d.ts +140 -0
- package/dist/resolveUsageModel-C_YmGR1M.d.cts +140 -0
- package/dist/sync/index.cjs +7 -9
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +3 -8
- package/dist/sync/index.d.ts +3 -8
- package/dist/sync/index.js +8 -11
- package/dist/toolbox/index.cjs +1 -0
- package/dist/toolbox/index.cjs.map +1 -1
- package/dist/types-BrzJWsTU.d.cts +277 -0
- package/dist/types-BrzJWsTU.d.ts +277 -0
- package/package.json +14 -20
- package/src/data/models-catalog.json +670 -0
- package/src/data/openrouter-models-catalog.json +857 -0
- package/dist/AiModelsCatalogClient-4RF5BCDL.cjs +0 -9
- package/dist/AiModelsCatalogClient-4RF5BCDL.cjs.map +0 -1
- package/dist/AiModelsCatalogClient-CNeqFiFs.d.cts +0 -30
- package/dist/AiModelsCatalogClient-NUF3CBLW.js +0 -9
- package/dist/AiModelsCatalogClient-nwFoEaqL.d.ts +0 -30
- package/dist/catalox/index.cjs +0 -21
- package/dist/catalox/index.cjs.map +0 -1
- package/dist/catalox/index.d.cts +0 -11
- package/dist/catalox/index.d.ts +0 -11
- package/dist/catalox/index.js +0 -21
- package/dist/chunk-4NAY6HRP.js.map +0 -1
- package/dist/chunk-6QGDZTGH.js.map +0 -1
- package/dist/chunk-7Q742NI3.cjs.map +0 -1
- package/dist/chunk-AJEKEWWB.js.map +0 -1
- package/dist/chunk-AV6OE2YQ.cjs.map +0 -1
- package/dist/chunk-C3H7RTFR.cjs +0 -1
- package/dist/chunk-C3H7RTFR.cjs.map +0 -1
- package/dist/chunk-DJ5SWJDY.js.map +0 -1
- package/dist/chunk-DKHGWHXP.cjs +0 -169
- package/dist/chunk-DKHGWHXP.cjs.map +0 -1
- package/dist/chunk-F2F4UEFD.cjs +0 -75
- package/dist/chunk-F2F4UEFD.cjs.map +0 -1
- package/dist/chunk-FGP3QXWL.cjs +0 -163
- package/dist/chunk-FGP3QXWL.cjs.map +0 -1
- package/dist/chunk-G2G4KSC5.js +0 -30
- package/dist/chunk-G2G4KSC5.js.map +0 -1
- package/dist/chunk-HN6UAQAE.cjs +0 -83
- package/dist/chunk-HN6UAQAE.cjs.map +0 -1
- package/dist/chunk-HS74X2OJ.cjs +0 -172
- package/dist/chunk-HS74X2OJ.cjs.map +0 -1
- package/dist/chunk-HYGXZY25.js +0 -163
- package/dist/chunk-HYGXZY25.js.map +0 -1
- package/dist/chunk-KQOALKKX.js +0 -75
- package/dist/chunk-KQOALKKX.js.map +0 -1
- package/dist/chunk-LYOU7CA2.cjs +0 -30
- package/dist/chunk-LYOU7CA2.cjs.map +0 -1
- package/dist/chunk-M5TMA73F.js +0 -1
- package/dist/chunk-M5TMA73F.js.map +0 -1
- package/dist/chunk-MX3AMQFC.js +0 -172
- package/dist/chunk-MX3AMQFC.js.map +0 -1
- package/dist/chunk-QCRLKVB3.cjs +0 -137
- package/dist/chunk-QCRLKVB3.cjs.map +0 -1
- package/dist/chunk-TF4L2NEC.cjs.map +0 -1
- package/dist/chunk-VRFVF5RH.js +0 -169
- package/dist/chunk-VRFVF5RH.js.map +0 -1
- package/dist/chunk-YHO57D2V.js +0 -83
- package/dist/chunk-YHO57D2V.js.map +0 -1
- package/dist/syncAiModelsCatalog-CnXRLm2c.d.cts +0 -32
- package/dist/syncAiModelsCatalog-DpkN_w7S.d.ts +0 -32
- package/dist/types-BYXnCvKx.d.cts +0 -137
- package/dist/types-BYXnCvKx.d.ts +0 -137
- package/dist/types-CX6QFNNy.d.cts +0 -144
- package/dist/types-CuiPDcVs.d.ts +0 -144
- package/dist/upsertAiModelRecord-C831wOIF.d.ts +0 -35
- package/dist/upsertAiModelRecord-CjY-sny0.d.cts +0 -35
- /package/dist/{AiModelsCatalogClient-NUF3CBLW.js.map → chunk-56R4XA2S.js.map} +0 -0
- /package/dist/{catalox → profiles}/index.js.map +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { A as AiModelPricing, d as AliasRegistry, l as ModelResolverOptions } from './types-BrzJWsTU.js';
|
|
2
|
+
import { A as AiModelsCatalogClient } from './AiModelsCatalogClient-CPPNI6Ry.js';
|
|
3
|
+
|
|
4
|
+
type AiUsageInput = {
|
|
5
|
+
tokens: {
|
|
6
|
+
prompt: number;
|
|
7
|
+
completion: number;
|
|
8
|
+
total: number;
|
|
9
|
+
cached?: number;
|
|
10
|
+
cacheWrite?: number;
|
|
11
|
+
reasoning?: number;
|
|
12
|
+
audio?: number;
|
|
13
|
+
image?: number;
|
|
14
|
+
};
|
|
15
|
+
provider: string;
|
|
16
|
+
/** Runtime model id from the provider response (highest priority). */
|
|
17
|
+
usedModel?: string;
|
|
18
|
+
/** Alias of `usedModel` (same priority). */
|
|
19
|
+
modelUsed?: string;
|
|
20
|
+
/** Requested / configured model id; used when runtime id fields are absent. */
|
|
21
|
+
model?: string;
|
|
22
|
+
};
|
|
23
|
+
type AiCostExtraction = {
|
|
24
|
+
model: {
|
|
25
|
+
field: string;
|
|
26
|
+
path: string;
|
|
27
|
+
};
|
|
28
|
+
modelUsed?: {
|
|
29
|
+
field: string;
|
|
30
|
+
path: string;
|
|
31
|
+
};
|
|
32
|
+
provider?: {
|
|
33
|
+
field: string;
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
tokens: {
|
|
37
|
+
source: string;
|
|
38
|
+
path: string;
|
|
39
|
+
estimated?: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type AiCostWarningCode = "UNKNOWN_MODEL" | "LOCAL_PROVIDER_NO_PRICING" | "AI_PROFILES_ESTIMATE" | "OPENROUTER_MARKUP_ESTIMATED" | "ESTIMATED_TOKEN_USAGE" | "VERSION_SUFFIX_PRICING";
|
|
43
|
+
type AiCostWarning = {
|
|
44
|
+
code: AiCostWarningCode;
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
type AiCostResult = {
|
|
48
|
+
cost: number;
|
|
49
|
+
/** Model id used for pricing (after resolution). */
|
|
50
|
+
resolvedModelId: string;
|
|
51
|
+
/** Runtime model id when present on input. */
|
|
52
|
+
usedModel?: string;
|
|
53
|
+
/** Requested model id when distinct from runtime. */
|
|
54
|
+
model?: string;
|
|
55
|
+
provider: string;
|
|
56
|
+
usage: AiUsageInput["tokens"];
|
|
57
|
+
extraction?: AiCostExtraction;
|
|
58
|
+
breakdown?: {
|
|
59
|
+
promptCostUsd: number;
|
|
60
|
+
completionCostUsd: number;
|
|
61
|
+
cachingCostUsd?: number;
|
|
62
|
+
reasoningCostUsd?: number;
|
|
63
|
+
audioCostUsd?: number;
|
|
64
|
+
imageCostUsd?: number;
|
|
65
|
+
requestFlatCostUsd?: number;
|
|
66
|
+
};
|
|
67
|
+
routedViaOpenRouter: boolean;
|
|
68
|
+
isAuthoritative: boolean;
|
|
69
|
+
pricingSnapshot: AiModelPricing;
|
|
70
|
+
source: "catalog" | "ai-profiles" | "local" | "estimate-fallback";
|
|
71
|
+
/** Present when pricing could not be resolved (zero-cost fallback). */
|
|
72
|
+
unknownModel?: boolean;
|
|
73
|
+
warnings?: AiCostWarning[];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Model id field priority (higher wins). Runtime ids beat request/config aliases. */
|
|
77
|
+
declare const MODEL_FIELD_PRIORITY: readonly {
|
|
78
|
+
key: string;
|
|
79
|
+
score: number;
|
|
80
|
+
}[];
|
|
81
|
+
type FieldProvenance = {
|
|
82
|
+
field: string;
|
|
83
|
+
path: string;
|
|
84
|
+
score: number;
|
|
85
|
+
};
|
|
86
|
+
type TokenExtractionProvenance = {
|
|
87
|
+
source: "usage" | "tokens" | "diagnostics" | "estimated";
|
|
88
|
+
path: string;
|
|
89
|
+
estimated?: boolean;
|
|
90
|
+
};
|
|
91
|
+
type ExtractUsageInputResult = {
|
|
92
|
+
input: AiUsageInput;
|
|
93
|
+
provenance: {
|
|
94
|
+
model: FieldProvenance;
|
|
95
|
+
modelUsed?: FieldProvenance;
|
|
96
|
+
provider?: FieldProvenance;
|
|
97
|
+
tokens: TokenExtractionProvenance;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
type ExtractUsageInputOptions = {
|
|
101
|
+
/** Default when no provider field is found (default: `openrouter`). */
|
|
102
|
+
defaultProvider?: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Extract {@link AiUsageInput} from activity logs, gateway records, MongoDB exports,
|
|
106
|
+
* or any nested JSON shape (e.g. `outer.input`, `config`, `metadata.diagnostics`).
|
|
107
|
+
*/
|
|
108
|
+
declare function extractUsageInput(record: unknown, options?: ExtractUsageInputOptions): ExtractUsageInputResult;
|
|
109
|
+
|
|
110
|
+
type CostCalculatorOptions = {
|
|
111
|
+
aliasRegistry?: AliasRegistry;
|
|
112
|
+
includeBreakdown?: boolean;
|
|
113
|
+
resolverOptions?: ModelResolverOptions;
|
|
114
|
+
/** When true, throw {@link UnknownModelCostError} instead of zero-cost fallback. */
|
|
115
|
+
throwOnUnknownModel?: boolean;
|
|
116
|
+
};
|
|
117
|
+
declare class CostCalculator {
|
|
118
|
+
private readonly catalog;
|
|
119
|
+
private readonly aliasRegistry?;
|
|
120
|
+
private readonly includeBreakdown;
|
|
121
|
+
private readonly resolverOptions?;
|
|
122
|
+
private readonly throwOnUnknownModel;
|
|
123
|
+
constructor(catalog: AiModelsCatalogClient, options?: CostCalculatorOptions);
|
|
124
|
+
/**
|
|
125
|
+
* Extract model, provider, and token usage from an activity / gateway record
|
|
126
|
+
* (MongoDB export, nested `outer`, `config`, `metadata.diagnostics`, etc.)
|
|
127
|
+
* then run {@link calculate}.
|
|
128
|
+
*/
|
|
129
|
+
calculateFromRecord(record: unknown, extractOptions?: ExtractUsageInputOptions): Promise<AiCostResult>;
|
|
130
|
+
calculate(input: AiUsageInput): Promise<AiCostResult>;
|
|
131
|
+
private versionSuffixWarnings;
|
|
132
|
+
private finish;
|
|
133
|
+
private localProviderResult;
|
|
134
|
+
private unknownModelResult;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Prefer runtime id (`usedModel` / `modelUsed`); fall back to `model`. */
|
|
138
|
+
declare function resolveUsageModel(input: AiUsageInput): string;
|
|
139
|
+
|
|
140
|
+
export { type AiCostExtraction as A, CostCalculator as C, type ExtractUsageInputOptions as E, type FieldProvenance as F, MODEL_FIELD_PRIORITY as M, type TokenExtractionProvenance as T, type AiCostResult as a, type AiCostWarning as b, type AiCostWarningCode as c, type AiUsageInput as d, type CostCalculatorOptions as e, type ExtractUsageInputResult as f, extractUsageInput as g, resolveUsageModel as r };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { A as AiModelPricing, d as AliasRegistry, l as ModelResolverOptions } from './types-BrzJWsTU.cjs';
|
|
2
|
+
import { A as AiModelsCatalogClient } from './AiModelsCatalogClient-B5FMI9gj.cjs';
|
|
3
|
+
|
|
4
|
+
type AiUsageInput = {
|
|
5
|
+
tokens: {
|
|
6
|
+
prompt: number;
|
|
7
|
+
completion: number;
|
|
8
|
+
total: number;
|
|
9
|
+
cached?: number;
|
|
10
|
+
cacheWrite?: number;
|
|
11
|
+
reasoning?: number;
|
|
12
|
+
audio?: number;
|
|
13
|
+
image?: number;
|
|
14
|
+
};
|
|
15
|
+
provider: string;
|
|
16
|
+
/** Runtime model id from the provider response (highest priority). */
|
|
17
|
+
usedModel?: string;
|
|
18
|
+
/** Alias of `usedModel` (same priority). */
|
|
19
|
+
modelUsed?: string;
|
|
20
|
+
/** Requested / configured model id; used when runtime id fields are absent. */
|
|
21
|
+
model?: string;
|
|
22
|
+
};
|
|
23
|
+
type AiCostExtraction = {
|
|
24
|
+
model: {
|
|
25
|
+
field: string;
|
|
26
|
+
path: string;
|
|
27
|
+
};
|
|
28
|
+
modelUsed?: {
|
|
29
|
+
field: string;
|
|
30
|
+
path: string;
|
|
31
|
+
};
|
|
32
|
+
provider?: {
|
|
33
|
+
field: string;
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
tokens: {
|
|
37
|
+
source: string;
|
|
38
|
+
path: string;
|
|
39
|
+
estimated?: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type AiCostWarningCode = "UNKNOWN_MODEL" | "LOCAL_PROVIDER_NO_PRICING" | "AI_PROFILES_ESTIMATE" | "OPENROUTER_MARKUP_ESTIMATED" | "ESTIMATED_TOKEN_USAGE" | "VERSION_SUFFIX_PRICING";
|
|
43
|
+
type AiCostWarning = {
|
|
44
|
+
code: AiCostWarningCode;
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
type AiCostResult = {
|
|
48
|
+
cost: number;
|
|
49
|
+
/** Model id used for pricing (after resolution). */
|
|
50
|
+
resolvedModelId: string;
|
|
51
|
+
/** Runtime model id when present on input. */
|
|
52
|
+
usedModel?: string;
|
|
53
|
+
/** Requested model id when distinct from runtime. */
|
|
54
|
+
model?: string;
|
|
55
|
+
provider: string;
|
|
56
|
+
usage: AiUsageInput["tokens"];
|
|
57
|
+
extraction?: AiCostExtraction;
|
|
58
|
+
breakdown?: {
|
|
59
|
+
promptCostUsd: number;
|
|
60
|
+
completionCostUsd: number;
|
|
61
|
+
cachingCostUsd?: number;
|
|
62
|
+
reasoningCostUsd?: number;
|
|
63
|
+
audioCostUsd?: number;
|
|
64
|
+
imageCostUsd?: number;
|
|
65
|
+
requestFlatCostUsd?: number;
|
|
66
|
+
};
|
|
67
|
+
routedViaOpenRouter: boolean;
|
|
68
|
+
isAuthoritative: boolean;
|
|
69
|
+
pricingSnapshot: AiModelPricing;
|
|
70
|
+
source: "catalog" | "ai-profiles" | "local" | "estimate-fallback";
|
|
71
|
+
/** Present when pricing could not be resolved (zero-cost fallback). */
|
|
72
|
+
unknownModel?: boolean;
|
|
73
|
+
warnings?: AiCostWarning[];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Model id field priority (higher wins). Runtime ids beat request/config aliases. */
|
|
77
|
+
declare const MODEL_FIELD_PRIORITY: readonly {
|
|
78
|
+
key: string;
|
|
79
|
+
score: number;
|
|
80
|
+
}[];
|
|
81
|
+
type FieldProvenance = {
|
|
82
|
+
field: string;
|
|
83
|
+
path: string;
|
|
84
|
+
score: number;
|
|
85
|
+
};
|
|
86
|
+
type TokenExtractionProvenance = {
|
|
87
|
+
source: "usage" | "tokens" | "diagnostics" | "estimated";
|
|
88
|
+
path: string;
|
|
89
|
+
estimated?: boolean;
|
|
90
|
+
};
|
|
91
|
+
type ExtractUsageInputResult = {
|
|
92
|
+
input: AiUsageInput;
|
|
93
|
+
provenance: {
|
|
94
|
+
model: FieldProvenance;
|
|
95
|
+
modelUsed?: FieldProvenance;
|
|
96
|
+
provider?: FieldProvenance;
|
|
97
|
+
tokens: TokenExtractionProvenance;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
type ExtractUsageInputOptions = {
|
|
101
|
+
/** Default when no provider field is found (default: `openrouter`). */
|
|
102
|
+
defaultProvider?: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Extract {@link AiUsageInput} from activity logs, gateway records, MongoDB exports,
|
|
106
|
+
* or any nested JSON shape (e.g. `outer.input`, `config`, `metadata.diagnostics`).
|
|
107
|
+
*/
|
|
108
|
+
declare function extractUsageInput(record: unknown, options?: ExtractUsageInputOptions): ExtractUsageInputResult;
|
|
109
|
+
|
|
110
|
+
type CostCalculatorOptions = {
|
|
111
|
+
aliasRegistry?: AliasRegistry;
|
|
112
|
+
includeBreakdown?: boolean;
|
|
113
|
+
resolverOptions?: ModelResolverOptions;
|
|
114
|
+
/** When true, throw {@link UnknownModelCostError} instead of zero-cost fallback. */
|
|
115
|
+
throwOnUnknownModel?: boolean;
|
|
116
|
+
};
|
|
117
|
+
declare class CostCalculator {
|
|
118
|
+
private readonly catalog;
|
|
119
|
+
private readonly aliasRegistry?;
|
|
120
|
+
private readonly includeBreakdown;
|
|
121
|
+
private readonly resolverOptions?;
|
|
122
|
+
private readonly throwOnUnknownModel;
|
|
123
|
+
constructor(catalog: AiModelsCatalogClient, options?: CostCalculatorOptions);
|
|
124
|
+
/**
|
|
125
|
+
* Extract model, provider, and token usage from an activity / gateway record
|
|
126
|
+
* (MongoDB export, nested `outer`, `config`, `metadata.diagnostics`, etc.)
|
|
127
|
+
* then run {@link calculate}.
|
|
128
|
+
*/
|
|
129
|
+
calculateFromRecord(record: unknown, extractOptions?: ExtractUsageInputOptions): Promise<AiCostResult>;
|
|
130
|
+
calculate(input: AiUsageInput): Promise<AiCostResult>;
|
|
131
|
+
private versionSuffixWarnings;
|
|
132
|
+
private finish;
|
|
133
|
+
private localProviderResult;
|
|
134
|
+
private unknownModelResult;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Prefer runtime id (`usedModel` / `modelUsed`); fall back to `model`. */
|
|
138
|
+
declare function resolveUsageModel(input: AiUsageInput): string;
|
|
139
|
+
|
|
140
|
+
export { type AiCostExtraction as A, CostCalculator as C, type ExtractUsageInputOptions as E, type FieldProvenance as F, MODEL_FIELD_PRIORITY as M, type TokenExtractionProvenance as T, type AiCostResult as a, type AiCostWarning as b, type AiCostWarningCode as c, type AiUsageInput as d, type CostCalculatorOptions as e, type ExtractUsageInputResult as f, extractUsageInput as g, resolveUsageModel as r };
|
package/dist/sync/index.cjs
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var _chunkLYOU7CA2cjs = require('../chunk-LYOU7CA2.cjs');
|
|
6
5
|
|
|
6
|
+
var _chunkPRCICORGcjs = require('../chunk-PRCICORG.cjs');
|
|
7
|
+
require('../chunk-XOKUDUUI.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
var _chunkDKHGWHXPcjs = require('../chunk-DKHGWHXP.cjs');
|
|
10
|
-
require('../chunk-FGP3QXWL.cjs');
|
|
11
|
-
require('../chunk-AV6OE2YQ.cjs');
|
|
12
10
|
|
|
11
|
+
var _chunkDXZOL3VNcjs = require('../chunk-DXZOL3VN.cjs');
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
|
|
@@ -17,9 +16,10 @@ require('../chunk-AV6OE2YQ.cjs');
|
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
|
|
19
|
+
var _chunkEDMCKHO6cjs = require('../chunk-EDMCKHO6.cjs');
|
|
20
|
+
require('../chunk-PADNCGZB.cjs');
|
|
21
|
+
require('../chunk-GS7T56RP.cjs');
|
|
20
22
|
|
|
21
|
-
var _chunkTF4L2NECcjs = require('../chunk-TF4L2NEC.cjs');
|
|
22
|
-
require('../chunk-7Q742NI3.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -32,7 +32,5 @@ require('../chunk-7Q742NI3.cjs');
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports.ModelNameResolver = _chunkTF4L2NECcjs.ModelNameResolver; exports.OpenRouterSyncProvider = _chunkDKHGWHXPcjs.OpenRouterSyncProvider; exports.buildCatalogIndexes = _chunkTF4L2NECcjs.buildCatalogIndexes; exports.createModelNameResolver = _chunkLYOU7CA2cjs.createModelNameResolver; exports.isRoutedViaOpenRouter = _chunkLYOU7CA2cjs.isRoutedViaOpenRouter; exports.loadOpenRouterRoutingEnv = _chunkTF4L2NECcjs.loadOpenRouterRoutingEnv; exports.normalizeProvider = _chunkTF4L2NECcjs.normalizeProvider; exports.normalizeString = _chunkTF4L2NECcjs.normalizeString; exports.providerIdToEnvKeyPrefix = _chunkTF4L2NECcjs.providerIdToEnvKeyPrefix; exports.resolveModel = _chunkLYOU7CA2cjs.resolveModel; exports.shouldDefaultRouteViaOpenRouter = _chunkTF4L2NECcjs.shouldDefaultRouteViaOpenRouter; exports.syncAiModelsCatalog = _chunkDKHGWHXPcjs.syncAiModelsCatalog; exports.vendorApiKeyEnvName = _chunkTF4L2NECcjs.vendorApiKeyEnvName;
|
|
35
|
+
exports.ModelNameResolver = _chunkDXZOL3VNcjs.ModelNameResolver; exports.OpenRouterSyncProvider = _chunkPRCICORGcjs.OpenRouterSyncProvider; exports.buildCatalogIndexes = _chunkDXZOL3VNcjs.buildCatalogIndexes; exports.createModelNameResolver = _chunkPRCICORGcjs.createModelNameResolver; exports.isRoutedViaOpenRouter = _chunkPRCICORGcjs.isRoutedViaOpenRouter; exports.loadOpenRouterRoutingEnv = _chunkEDMCKHO6cjs.loadOpenRouterRoutingEnv; exports.normalizeProvider = _chunkEDMCKHO6cjs.normalizeProvider; exports.normalizeString = _chunkEDMCKHO6cjs.normalizeString; exports.providerIdToEnvKeyPrefix = _chunkEDMCKHO6cjs.providerIdToEnvKeyPrefix; exports.resolveModel = _chunkPRCICORGcjs.resolveModel; exports.shouldDefaultRouteViaOpenRouter = _chunkEDMCKHO6cjs.shouldDefaultRouteViaOpenRouter; exports.vendorApiKeyEnvName = _chunkEDMCKHO6cjs.vendorApiKeyEnvName;
|
|
38
36
|
//# sourceMappingURL=index.cjs.map
|
package/dist/sync/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/sync/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/sync/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,21BAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/sync/index.cjs"}
|
package/dist/sync/index.d.cts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
export { M as ModelNameResolver, O as OpenRouterSyncProvider, a as OpenRouterSyncProviderOptions, c as createModelNameResolver, i as isRoutedViaOpenRouter, r as resolveModel } from '../modelNameResolver-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { M as ModelResolutionInput, f as ModelResolutionResult, g as ModelResolutionSuccess, h as ModelResolverOptions, O as OpenRouterRoutingConfig, R as ResolutionStrategy, i as ResolvedModel, l as loadOpenRouterRoutingEnv, p as providerIdToEnvKeyPrefix, s as shouldDefaultRouteViaOpenRouter, v as vendorApiKeyEnvName } from '../types-CX6QFNNy.cjs';
|
|
5
|
-
import { a as AiModelRecord } from '../types-BYXnCvKx.cjs';
|
|
6
|
-
import '@x12i/catalox';
|
|
7
|
-
import 'firebase-admin/firestore';
|
|
8
|
-
import '../upsertAiModelRecord-CjY-sny0.cjs';
|
|
1
|
+
export { M as ModelNameResolver, O as OpenRouterSyncProvider, a as OpenRouterSyncProviderOptions, c as createModelNameResolver, i as isRoutedViaOpenRouter, r as resolveModel } from '../modelNameResolver-C5CSTGFF.cjs';
|
|
2
|
+
import { a as AiModelRecord, C as CatalogIndexes } from '../types-BrzJWsTU.cjs';
|
|
3
|
+
export { h as ModelResolutionInput, j as ModelResolutionResult, k as ModelResolutionSuccess, l as ModelResolverOptions, r as OpenRouterRoutingConfig, R as ResolutionStrategy, t as ResolvedModel, v as loadOpenRouterRoutingEnv, w as providerIdToEnvKeyPrefix, x as shouldDefaultRouteViaOpenRouter, y as vendorApiKeyEnvName } from '../types-BrzJWsTU.cjs';
|
|
9
4
|
|
|
10
5
|
declare function buildCatalogIndexes(catalog: Map<string, AiModelRecord>): CatalogIndexes;
|
|
11
6
|
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
export { M as ModelNameResolver, O as OpenRouterSyncProvider, a as OpenRouterSyncProviderOptions, c as createModelNameResolver, i as isRoutedViaOpenRouter, r as resolveModel } from '../modelNameResolver-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { M as ModelResolutionInput, f as ModelResolutionResult, g as ModelResolutionSuccess, h as ModelResolverOptions, O as OpenRouterRoutingConfig, R as ResolutionStrategy, i as ResolvedModel, l as loadOpenRouterRoutingEnv, p as providerIdToEnvKeyPrefix, s as shouldDefaultRouteViaOpenRouter, v as vendorApiKeyEnvName } from '../types-CuiPDcVs.js';
|
|
5
|
-
import { a as AiModelRecord } from '../types-BYXnCvKx.js';
|
|
6
|
-
import '@x12i/catalox';
|
|
7
|
-
import 'firebase-admin/firestore';
|
|
8
|
-
import '../upsertAiModelRecord-C831wOIF.js';
|
|
1
|
+
export { M as ModelNameResolver, O as OpenRouterSyncProvider, a as OpenRouterSyncProviderOptions, c as createModelNameResolver, i as isRoutedViaOpenRouter, r as resolveModel } from '../modelNameResolver-5XkBMctP.js';
|
|
2
|
+
import { a as AiModelRecord, C as CatalogIndexes } from '../types-BrzJWsTU.js';
|
|
3
|
+
export { h as ModelResolutionInput, j as ModelResolutionResult, k as ModelResolutionSuccess, l as ModelResolverOptions, r as OpenRouterRoutingConfig, R as ResolutionStrategy, t as ResolvedModel, v as loadOpenRouterRoutingEnv, w as providerIdToEnvKeyPrefix, x as shouldDefaultRouteViaOpenRouter, y as vendorApiKeyEnvName } from '../types-BrzJWsTU.js';
|
|
9
4
|
|
|
10
5
|
declare function buildCatalogIndexes(catalog: Map<string, AiModelRecord>): CatalogIndexes;
|
|
11
6
|
|
package/dist/sync/index.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
+
OpenRouterSyncProvider,
|
|
2
3
|
createModelNameResolver,
|
|
3
4
|
isRoutedViaOpenRouter,
|
|
4
5
|
resolveModel
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import
|
|
7
|
-
OpenRouterSyncProvider,
|
|
8
|
-
syncAiModelsCatalog
|
|
9
|
-
} from "../chunk-VRFVF5RH.js";
|
|
10
|
-
import "../chunk-HYGXZY25.js";
|
|
11
|
-
import "../chunk-6QGDZTGH.js";
|
|
6
|
+
} from "../chunk-6BQBKROR.js";
|
|
7
|
+
import "../chunk-SIH4GPV4.js";
|
|
12
8
|
import {
|
|
13
9
|
ModelNameResolver,
|
|
14
|
-
buildCatalogIndexes
|
|
10
|
+
buildCatalogIndexes
|
|
11
|
+
} from "../chunk-EYHMQVAL.js";
|
|
12
|
+
import {
|
|
15
13
|
loadOpenRouterRoutingEnv,
|
|
16
14
|
normalizeProvider,
|
|
17
15
|
normalizeString,
|
|
18
16
|
providerIdToEnvKeyPrefix,
|
|
19
17
|
shouldDefaultRouteViaOpenRouter,
|
|
20
18
|
vendorApiKeyEnvName
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-B3V2EHRY.js";
|
|
20
|
+
import "../chunk-2PTCWPHV.js";
|
|
23
21
|
export {
|
|
24
22
|
ModelNameResolver,
|
|
25
23
|
OpenRouterSyncProvider,
|
|
@@ -32,7 +30,6 @@ export {
|
|
|
32
30
|
providerIdToEnvKeyPrefix,
|
|
33
31
|
resolveModel,
|
|
34
32
|
shouldDefaultRouteViaOpenRouter,
|
|
35
|
-
syncAiModelsCatalog,
|
|
36
33
|
vendorApiKeyEnvName
|
|
37
34
|
};
|
|
38
35
|
//# sourceMappingURL=index.js.map
|
package/dist/toolbox/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/toolbox/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,gDAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/toolbox/index.cjs"}
|
|
1
|
+
{"version":3,"sources":["/Users/ami/Documents/prometheus/x12i/ai-tools/dist/toolbox/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,gDAAC","file":"/Users/ami/Documents/prometheus/x12i/ai-tools/dist/toolbox/index.cjs"}
|