@memberjunction/ai-engine-base 6.1.0-edge.4 → 6.1.0-edge.6

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.
@@ -1,14 +1,103 @@
1
- import { MJAIModelCostEntity } from "@memberjunction/core-entities";
1
+ import { ModelUsageUnitKind } from "@memberjunction/ai";
2
+ import { MJAIModelCostEntity, MJAIModelPriceUnitTypeEntity } from "@memberjunction/core-entities";
3
+ /**
4
+ * The DriverClass a price unit type names to be priced from its own row rather than from code.
5
+ *
6
+ * Seeding a row with this driver, a `UsageTypeID` and a `UnitsPerBillingUnit` is all a new LINEAR
7
+ * billing unit needs — no class, no registration, no build. See {@link LinearPriceUnitType}.
8
+ */
9
+ export declare const LINEAR_PRICE_UNIT_DRIVER_CLASS = "Linear";
10
+ /**
11
+ * A run's billable quantities, already split into the buckets a price unit type prices
12
+ * separately. The numbers are in the driver's own {@link BasePriceUnitType.UnitKind} — tokens for
13
+ * the token drivers, seconds for the time drivers, images for the per-image driver — which is why
14
+ * the fields are named for their role rather than for tokens.
15
+ *
16
+ * The cache buckets are meaningful only for token pricing; continuous-media drivers ignore them.
17
+ */
18
+ export interface NormalizedUsage {
19
+ /** Uncached / net-new input quantity. */
20
+ input: number;
21
+ /** Output quantity. */
22
+ output: number;
23
+ /** Input quantity served from the provider's prompt cache. Token pricing only. */
24
+ cacheRead?: number;
25
+ /** Input quantity written to the provider's prompt cache. Token pricing only. */
26
+ cacheWrite?: number;
27
+ }
2
28
  /**
3
29
  * This class serves as the abstract base class for handling price unit
4
30
  * types and is used by different price unit types implementations.
31
+ *
32
+ * ## Why `@RequiresSubclass()`
33
+ * `CalculateNormalizedCost` is abstract, and `abstract` is erased at runtime — so without this
34
+ * marker `ClassFactory.CreateInstance(BasePriceUnitType, 'NoSuchDriver')` falls back to
35
+ * `new BasePriceUnitType()` and hands back a HOLLOW object whose only pricing method is
36
+ * `undefined`. Every `if (!calculator)` guard written against that call is a dead branch, and the
37
+ * failure surfaces as a `TypeError` inside cost math rather than as "this driver is not
38
+ * registered".
39
+ *
40
+ * The `UnitKind` default below makes the hollow instance especially convincing: it answers
41
+ * `'Tokens'`, so a token-billed run passes the kind check, proceeds, and only then throws. The
42
+ * marker turns all of that into an explicit resolution failure — `CreateInstance` throws with
43
+ * context, `TryCreateInstance` reports `{Resolved: false, Instance: null}`, and
44
+ * {@link AIEngineBase.GetPriceCalculator}'s null return becomes real.
5
45
  */
6
46
  export declare abstract class BasePriceUnitType {
7
47
  /**
8
- * Calculates normalized cost based on each sub-classes specific algorithm
48
+ * The `MJ: AI Model Price Unit Types` row this driver was resolved for, when the caller supplied
49
+ * it — {@link AIEngineBase.GetPriceCalculator} always does.
50
+ *
51
+ * Optional so any subclass outside this repo — which predates the parameter entirely — keeps
52
+ * working: extra constructor arguments are inert in JS. When present it is authoritative for
53
+ * {@link UnitsPerBillingUnit}, which is what makes that column mean something rather than
54
+ * decorate a form.
55
+ */
56
+ protected readonly PriceUnitType?: MJAIModelPriceUnitTypeEntity;
57
+ constructor(priceUnitType?: MJAIModelPriceUnitTypeEntity);
58
+ /**
59
+ * The base measure this driver prices. Callers must hand it quantities in this measure —
60
+ * a driver that prices audio never receives token counts, and vice versa.
61
+ *
62
+ * Defaults to `Tokens`, which is what every driver that predates continuous-media pricing
63
+ * measures, so existing subclasses need not declare it.
64
+ */
65
+ get UnitKind(): ModelUsageUnitKind;
66
+ /**
67
+ * The scale this driver compiles in, used ONLY when no catalog row was supplied.
68
+ *
69
+ * Defaults to 1 — "the quantity IS the number of billed units" — which is both the correct
70
+ * answer for a per-image rate and a safe default for any subclass outside this repo that
71
+ * predates this property.
72
+ */
73
+ protected get DeclaredUnitsPerBillingUnit(): number;
74
+ /**
75
+ * How many quantities in this driver's {@link UnitKind} make up ONE billed unit — 1,000,000 for
76
+ * a per-million-tokens rate, 3,600 for a per-hour rate, 1 for a per-image rate.
77
+ *
78
+ * **The catalog row wins when one was supplied**, and `GetPriceCalculator` always supplies it.
79
+ * The compiled-in literal is the fallback for a driver instantiated directly (tests, and any
80
+ * consumer that wants a scale without loading the engine).
81
+ *
82
+ * Reading the column rather than the literal is what makes `UnitsPerBillingUnit` mean something.
83
+ * With the literal authoritative, the column was decoration: an admin could edit `Per Hour` to
84
+ * 7200 through the generated form, save successfully, and change nothing about how anything
85
+ * priced — the mirror image of B60, where the data was present and the code ignored it. A
86
+ * non-positive or non-finite column value falls through to the literal rather than poisoning a
87
+ * cost with `Infinity`/`NaN`; the database's `CK_AIModelPriceUnitType_UnitsPerBillingUnit
88
+ * CHECK (> 0)` is the real guard, and reaching this fallback means something bypassed it.
89
+ */
90
+ get UnitsPerBillingUnit(): number;
91
+ /**
92
+ * Calculates normalized cost based on each sub-classes specific algorithm.
93
+ *
94
+ * The two quantities are expressed in this driver's {@link UnitKind}: token counts for the
95
+ * token drivers, seconds of audio for the time drivers, a count of images for the per-image
96
+ * driver. The parameter names are historical — they predate any non-token unit type.
97
+ *
9
98
  * @param activeCost The active cost configuration
10
- * @param inputTokens Number of input tokens
11
- * @param outputTokens Number of output tokens
99
+ * @param inputTokens Input quantity, in this driver's unit kind
100
+ * @param outputTokens Output quantity, in this driver's unit kind
12
101
  * @returns The calculated cost
13
102
  */
14
103
  abstract CalculateNormalizedCost(activeCost: MJAIModelCostEntity, inputTokens: number, outputTokens: number): number;
@@ -25,6 +114,18 @@ export declare abstract class BasePriceUnitType {
25
114
  * working unchanged. The built-in per-unit types below override it to apply per-bucket rates.
26
115
  */
27
116
  CalculateNormalizedCostWithCache(activeCost: MJAIModelCostEntity, uncachedInputTokens: number, cacheReadTokens: number, cacheWriteTokens: number, outputTokens: number): number;
117
+ /**
118
+ * Prices a run from its quantities, whatever measure those are in. **This is the entry point
119
+ * callers should use**: it is the only one that works uniformly across token and
120
+ * continuous-media pricing, so a caller need not branch on which kind of model it just ran.
121
+ *
122
+ * The default delegates to {@link CalculateNormalizedCostWithCache}, so every existing driver —
123
+ * including subclasses outside this repo — gets it for free with unchanged behavior.
124
+ *
125
+ * Callers are responsible for handing over quantities in this driver's {@link UnitKind};
126
+ * `AIEngineBase.CalculateModelCost` verifies that before calling.
127
+ */
128
+ CalculateCost(activeCost: MJAIModelCostEntity, usage: NormalizedUsage): number;
28
129
  /**
29
130
  * Per-bucket cost math shared by the built-in unit types. Cache rates fall back to the input
30
131
  * rate when not populated, so cost is unchanged until a model/vendor records a distinct cache
@@ -33,6 +134,7 @@ export declare abstract class BasePriceUnitType {
33
134
  protected InternalCalculateNormalizedCostWithCache(divisor: number, activeCost: MJAIModelCostEntity, uncachedInputTokens: number, cacheReadTokens: number, cacheWriteTokens: number, outputTokens: number): number;
34
135
  }
35
136
  export declare class PerMillionTokensPriceUnitType extends BasePriceUnitType {
137
+ protected get DeclaredUnitsPerBillingUnit(): number;
36
138
  /**
37
139
  * Calculates normalized cost for the Per Million Tokens unit type, and token counts
38
140
  * @param activeCost The active cost configuration
@@ -44,6 +146,7 @@ export declare class PerMillionTokensPriceUnitType extends BasePriceUnitType {
44
146
  CalculateNormalizedCostWithCache(activeCost: MJAIModelCostEntity, uncachedInputTokens: number, cacheReadTokens: number, cacheWriteTokens: number, outputTokens: number): number;
45
147
  }
46
148
  export declare class PerThousandTokensPriceUnitType extends BasePriceUnitType {
149
+ protected get DeclaredUnitsPerBillingUnit(): number;
47
150
  /**
48
151
  * Calculates normalized cost for the Per Thousand Tokens unit type, and token counts
49
152
  * @param activeCost The active cost configuration
@@ -55,6 +158,7 @@ export declare class PerThousandTokensPriceUnitType extends BasePriceUnitType {
55
158
  CalculateNormalizedCostWithCache(activeCost: MJAIModelCostEntity, uncachedInputTokens: number, cacheReadTokens: number, cacheWriteTokens: number, outputTokens: number): number;
56
159
  }
57
160
  export declare class PerHundredThousandTokensPriceUnitType extends BasePriceUnitType {
161
+ protected get DeclaredUnitsPerBillingUnit(): number;
58
162
  /**
59
163
  * Calculates normalized cost for the Per Hundred Thousand Tokens unit type, and token counts
60
164
  * @param activeCost The active cost configuration
@@ -65,4 +169,114 @@ export declare class PerHundredThousandTokensPriceUnitType extends BasePriceUnit
65
169
  CalculateNormalizedCost(activeCost: MJAIModelCostEntity, inputTokens: number, outputTokens: number): number;
66
170
  CalculateNormalizedCostWithCache(activeCost: MJAIModelCostEntity, uncachedInputTokens: number, cacheReadTokens: number, cacheWriteTokens: number, outputTokens: number): number;
67
171
  }
172
+ /**
173
+ * Base for the drivers that price audio by elapsed time.
174
+ *
175
+ * Quantities arrive in SECONDS regardless of the rate's period, and the subclass supplies the
176
+ * divisor that converts. Recording seconds rather than the vendor's billing period is what lets
177
+ * one measured duration be priced against a per-minute row from one vendor and a per-hour row from
178
+ * another without the run having to know which it will be billed by.
179
+ *
180
+ * The cache buckets play no part: no transcription or speech vendor caches audio, so the inherited
181
+ * {@link BasePriceUnitType.CalculateNormalizedCostWithCache} default — which folds them into input
182
+ * at the input rate — is both correct and inert here.
183
+ */
184
+ export declare abstract class BaseTimePriceUnitType extends BasePriceUnitType {
185
+ get UnitKind(): ModelUsageUnitKind;
186
+ /**
187
+ * Seconds per unit of the price row's period — 60 for a per-minute rate, 3600 for per-hour.
188
+ *
189
+ * Declared through the inherited {@link BasePriceUnitType.DeclaredUnitsPerBillingUnit} rather
190
+ * than a separate `SecondsPerUnit` hook, so a time driver's divisor is readable by the same
191
+ * generic accessor as every other driver's. Two names for one number is what let the exported
192
+ * divisor table drift from the drivers in the first place.
193
+ */
194
+ protected abstract get DeclaredUnitsPerBillingUnit(): number;
195
+ /**
196
+ * @param activeCost The active cost configuration
197
+ * @param inputSeconds Seconds of input audio (e.g. audio submitted for transcription)
198
+ * @param outputSeconds Seconds of output audio (e.g. synthesized speech)
199
+ */
200
+ CalculateNormalizedCost(activeCost: MJAIModelCostEntity, inputSeconds: number, outputSeconds: number): number;
201
+ }
202
+ export declare class TimePerMinutePriceUnitType extends BaseTimePriceUnitType {
203
+ protected get DeclaredUnitsPerBillingUnit(): number;
204
+ }
205
+ export declare class TimePerHourPriceUnitType extends BaseTimePriceUnitType {
206
+ protected get DeclaredUnitsPerBillingUnit(): number;
207
+ }
208
+ /**
209
+ * Prices image generation by the image.
210
+ *
211
+ * Divisor 1 — the quantity IS the number of billed units, so there is nothing to normalize. Image
212
+ * cost rows carry the rate in `OutputPricePerUnit` (generated images are the output), which is the
213
+ * convention the shipped rows already follow; callers pass the count as the output quantity.
214
+ */
215
+ export declare class PerImagePriceUnitType extends BasePriceUnitType {
216
+ get UnitKind(): ModelUsageUnitKind;
217
+ /**
218
+ * @param activeCost The active cost configuration
219
+ * @param inputImages Images supplied as input, for models that charge for them; normally 0
220
+ * @param outputImages Images generated
221
+ */
222
+ CalculateNormalizedCost(activeCost: MJAIModelCostEntity, inputImages: number, outputImages: number): number;
223
+ }
224
+ /**
225
+ * Prices any LINEAR billing unit entirely from its own `MJ: AI Model Price Unit Types` row.
226
+ *
227
+ * ## Why this exists — it closes B60's class, not just its instance
228
+ *
229
+ * The three continuous-media unit types that shipped uncosted (`Per Image`, `Per Minute`,
230
+ * `Per Hour`) were seeded as DATA by one person while the driver classes that price them were
231
+ * never written by another. The seam was silent for months. Every hardcoded driver below is a
232
+ * standing invitation to repeat that: seeding a row is not sufficient, so a row can always exist
233
+ * without the code that gives it meaning.
234
+ *
235
+ * With the measure (`UsageTypeID`) and the divisor (`UnitsPerBillingUnit`) held as columns, a linear
236
+ * unit type needs no code at all — it names this driver and states its own arithmetic. "Per 1,000
237
+ * Characters" becomes one seeded row rather than a row plus a class plus a registration plus a
238
+ * release.
239
+ *
240
+ * ## Why unregistered driver names still refuse
241
+ *
242
+ * This is opt-in via `DriverClass = 'Linear'` rather than a fallback for any unresolvable driver.
243
+ * `DriverClass` is NOT NULL, so every row names something, and an unrecognised name is ambiguous
244
+ * between "a new linear unit type" and "a genuinely non-linear driver whose code is missing". Pricing
245
+ * the second linearly would produce a confident wrong number, which is the one outcome this whole
246
+ * subsystem is built to avoid. So an unknown driver keeps refusing, and a row that WANTS data-driven
247
+ * pricing says so.
248
+ *
249
+ * `DriverClass` therefore remains the escape hatch for genuinely non-linear pricing: tiered rates,
250
+ * per-image-by-resolution, or minimum-billing increments such as the Groq 10-second floor.
251
+ */
252
+ export declare class LinearPriceUnitType extends BasePriceUnitType {
253
+ /**
254
+ * The measure named by the row's usage type. Falls back to `Tokens` only when this driver was
255
+ * constructed with no row at all, which `GetPriceCalculator` never does — a caller that
256
+ * instantiates it directly gets the same default every other driver has.
257
+ */
258
+ get UnitKind(): ModelUsageUnitKind;
259
+ CalculateNormalizedCost(activeCost: MJAIModelCostEntity, inputQuantity: number, outputQuantity: number): number;
260
+ CalculateNormalizedCostWithCache(activeCost: MJAIModelCostEntity, uncachedInputTokens: number, cacheReadTokens: number, cacheWriteTokens: number, outputTokens: number): number;
261
+ }
262
+ /**
263
+ * The divisor each TOKEN-measured price unit type normalizes by, keyed by DriverClass.
264
+ *
265
+ * Token-rate math — cache-savings figures, per-token cost splits — is meaningful only for these. A
266
+ * consumer doing that math must SKIP a cost row priced by audio duration or by the image rather than
267
+ * fall back to a token divisor, which would divide an hourly rate by a million and report noise.
268
+ * Restricting the map to the token drivers is what makes a missing key the correct signal to skip
269
+ * rather than something to paper over with a default.
270
+ *
271
+ * Keyed by **DriverClass**, never by the unit type's display name: the names are editable metadata
272
+ * (`Per 1M Tokens` today) while the driver class is the contract the ClassFactory resolves. The keys
273
+ * are written out rather than read from `constructor.name`, which minifiers rewrite — this map is
274
+ * consumed by the Explorer dashboards, where that would silently empty it.
275
+ *
276
+ * **The NUMBERS are derived from the driver instances, never restated here.** They live in exactly
277
+ * one place per driver — {@link BasePriceUnitType.UnitsPerBillingUnit} — because a hand-written copy
278
+ * of the arithmetic that prices every run is a second source of truth held together by nothing but a
279
+ * unit test. Deriving makes drift impossible instead of merely detectable.
280
+ */
281
+ export declare const TOKEN_PRICE_UNIT_TYPE_DIVISORS: Readonly<Record<string, number>>;
68
282
  //# sourceMappingURL=PriceUnitTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PriceUnitTypes.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qBACa,qBAAsB,SAAQ,iBAAiB;IACxD,IAAoB,QAAQ,IAAI,kBAAkB,CAEjD;IAED;;;;OAIG;IACH,uBAAuB,CACnB,UAAU,EAAE,mBAAmB,EAC/B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACrB,MAAM;CAIZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,mBAAoB,SAAQ,iBAAiB;IACtD;;;;OAIG;IACH,IAAoB,QAAQ,IAAI,kBAAkB,CAGjD;IAMD,uBAAuB,CACnB,UAAU,EAAE,mBAAmB,EAC/B,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACvB,MAAM;IAIA,gCAAgC,CACrC,UAAU,EAAE,mBAAmB,EAC/B,mBAAmB,EAAE,MAAM,EAC3B,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,GACrB,MAAM;CAQZ;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS3E,CAAC"}
@@ -4,12 +4,80 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { RegisterClass } from "@memberjunction/global";
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { MJAIModelPriceUnitTypeEntity } from "@memberjunction/core-entities";
11
+ import { RegisterClass, RequiresSubclass } from "@memberjunction/global";
12
+ /**
13
+ * The DriverClass a price unit type names to be priced from its own row rather than from code.
14
+ *
15
+ * Seeding a row with this driver, a `UsageTypeID` and a `UnitsPerBillingUnit` is all a new LINEAR
16
+ * billing unit needs — no class, no registration, no build. See {@link LinearPriceUnitType}.
17
+ */
18
+ export const LINEAR_PRICE_UNIT_DRIVER_CLASS = 'Linear';
8
19
  /**
9
20
  * This class serves as the abstract base class for handling price unit
10
21
  * types and is used by different price unit types implementations.
22
+ *
23
+ * ## Why `@RequiresSubclass()`
24
+ * `CalculateNormalizedCost` is abstract, and `abstract` is erased at runtime — so without this
25
+ * marker `ClassFactory.CreateInstance(BasePriceUnitType, 'NoSuchDriver')` falls back to
26
+ * `new BasePriceUnitType()` and hands back a HOLLOW object whose only pricing method is
27
+ * `undefined`. Every `if (!calculator)` guard written against that call is a dead branch, and the
28
+ * failure surfaces as a `TypeError` inside cost math rather than as "this driver is not
29
+ * registered".
30
+ *
31
+ * The `UnitKind` default below makes the hollow instance especially convincing: it answers
32
+ * `'Tokens'`, so a token-billed run passes the kind check, proceeds, and only then throws. The
33
+ * marker turns all of that into an explicit resolution failure — `CreateInstance` throws with
34
+ * context, `TryCreateInstance` reports `{Resolved: false, Instance: null}`, and
35
+ * {@link AIEngineBase.GetPriceCalculator}'s null return becomes real.
11
36
  */
12
- export class BasePriceUnitType {
37
+ let BasePriceUnitType = class BasePriceUnitType {
38
+ constructor(priceUnitType) {
39
+ this.PriceUnitType = priceUnitType;
40
+ }
41
+ /**
42
+ * The base measure this driver prices. Callers must hand it quantities in this measure —
43
+ * a driver that prices audio never receives token counts, and vice versa.
44
+ *
45
+ * Defaults to `Tokens`, which is what every driver that predates continuous-media pricing
46
+ * measures, so existing subclasses need not declare it.
47
+ */
48
+ get UnitKind() {
49
+ return 'Tokens';
50
+ }
51
+ /**
52
+ * The scale this driver compiles in, used ONLY when no catalog row was supplied.
53
+ *
54
+ * Defaults to 1 — "the quantity IS the number of billed units" — which is both the correct
55
+ * answer for a per-image rate and a safe default for any subclass outside this repo that
56
+ * predates this property.
57
+ */
58
+ get DeclaredUnitsPerBillingUnit() {
59
+ return 1;
60
+ }
61
+ /**
62
+ * How many quantities in this driver's {@link UnitKind} make up ONE billed unit — 1,000,000 for
63
+ * a per-million-tokens rate, 3,600 for a per-hour rate, 1 for a per-image rate.
64
+ *
65
+ * **The catalog row wins when one was supplied**, and `GetPriceCalculator` always supplies it.
66
+ * The compiled-in literal is the fallback for a driver instantiated directly (tests, and any
67
+ * consumer that wants a scale without loading the engine).
68
+ *
69
+ * Reading the column rather than the literal is what makes `UnitsPerBillingUnit` mean something.
70
+ * With the literal authoritative, the column was decoration: an admin could edit `Per Hour` to
71
+ * 7200 through the generated form, save successfully, and change nothing about how anything
72
+ * priced — the mirror image of B60, where the data was present and the code ignored it. A
73
+ * non-positive or non-finite column value falls through to the literal rather than poisoning a
74
+ * cost with `Infinity`/`NaN`; the database's `CK_AIModelPriceUnitType_UnitsPerBillingUnit
75
+ * CHECK (> 0)` is the real guard, and reaching this fallback means something bypassed it.
76
+ */
77
+ get UnitsPerBillingUnit() {
78
+ const fromRow = Number(this.PriceUnitType?.UnitsPerBillingUnit);
79
+ return Number.isFinite(fromRow) && fromRow > 0 ? fromRow : this.DeclaredUnitsPerBillingUnit;
80
+ }
13
81
  InternalCalculateNormalizedCost(divisor, activeCost, inputTokens, outputTokens) {
14
82
  // Calculate costs
15
83
  const inputCost = (inputTokens / divisor) * Number(activeCost.InputPricePerUnit);
@@ -31,6 +99,20 @@ export class BasePriceUnitType {
31
99
  const totalInput = (uncachedInputTokens || 0) + (cacheReadTokens || 0) + (cacheWriteTokens || 0);
32
100
  return this.CalculateNormalizedCost(activeCost, totalInput, outputTokens);
33
101
  }
102
+ /**
103
+ * Prices a run from its quantities, whatever measure those are in. **This is the entry point
104
+ * callers should use**: it is the only one that works uniformly across token and
105
+ * continuous-media pricing, so a caller need not branch on which kind of model it just ran.
106
+ *
107
+ * The default delegates to {@link CalculateNormalizedCostWithCache}, so every existing driver —
108
+ * including subclasses outside this repo — gets it for free with unchanged behavior.
109
+ *
110
+ * Callers are responsible for handing over quantities in this driver's {@link UnitKind};
111
+ * `AIEngineBase.CalculateModelCost` verifies that before calling.
112
+ */
113
+ CalculateCost(activeCost, usage) {
114
+ return this.CalculateNormalizedCostWithCache(activeCost, usage.input, usage.cacheRead ?? 0, usage.cacheWrite ?? 0, usage.output);
115
+ }
34
116
  /**
35
117
  * Per-bucket cost math shared by the built-in unit types. Cache rates fall back to the input
36
118
  * rate when not populated, so cost is unchanged until a model/vendor records a distinct cache
@@ -50,8 +132,16 @@ export class BasePriceUnitType {
50
132
  (cacheWriteTokens / divisor) * cacheWriteRate +
51
133
  (outputTokens / divisor) * outputRate);
52
134
  }
53
- }
135
+ };
136
+ BasePriceUnitType = __decorate([
137
+ RequiresSubclass(),
138
+ __metadata("design:paramtypes", [MJAIModelPriceUnitTypeEntity])
139
+ ], BasePriceUnitType);
140
+ export { BasePriceUnitType };
54
141
  let PerMillionTokensPriceUnitType = class PerMillionTokensPriceUnitType extends BasePriceUnitType {
142
+ get DeclaredUnitsPerBillingUnit() {
143
+ return 1_000_000;
144
+ }
55
145
  /**
56
146
  * Calculates normalized cost for the Per Million Tokens unit type, and token counts
57
147
  * @param activeCost The active cost configuration
@@ -60,11 +150,10 @@ let PerMillionTokensPriceUnitType = class PerMillionTokensPriceUnitType extends
60
150
  * @returns The calculated cost
61
151
  */
62
152
  CalculateNormalizedCost(activeCost, inputTokens, outputTokens) {
63
- const divisor = 1000000; // Prices are per million tokens
64
- return this.InternalCalculateNormalizedCost(divisor, activeCost, inputTokens, outputTokens);
153
+ return this.InternalCalculateNormalizedCost(this.UnitsPerBillingUnit, activeCost, inputTokens, outputTokens);
65
154
  }
66
155
  CalculateNormalizedCostWithCache(activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens) {
67
- return this.InternalCalculateNormalizedCostWithCache(1000000, activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens);
156
+ return this.InternalCalculateNormalizedCostWithCache(this.UnitsPerBillingUnit, activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens);
68
157
  }
69
158
  };
70
159
  PerMillionTokensPriceUnitType = __decorate([
@@ -72,6 +161,9 @@ PerMillionTokensPriceUnitType = __decorate([
72
161
  ], PerMillionTokensPriceUnitType);
73
162
  export { PerMillionTokensPriceUnitType };
74
163
  let PerThousandTokensPriceUnitType = class PerThousandTokensPriceUnitType extends BasePriceUnitType {
164
+ get DeclaredUnitsPerBillingUnit() {
165
+ return 1_000;
166
+ }
75
167
  /**
76
168
  * Calculates normalized cost for the Per Thousand Tokens unit type, and token counts
77
169
  * @param activeCost The active cost configuration
@@ -80,11 +172,10 @@ let PerThousandTokensPriceUnitType = class PerThousandTokensPriceUnitType extend
80
172
  * @returns The calculated cost
81
173
  */
82
174
  CalculateNormalizedCost(activeCost, inputTokens, outputTokens) {
83
- const divisor = 1000; // Prices are per thousand tokens
84
- return this.InternalCalculateNormalizedCost(divisor, activeCost, inputTokens, outputTokens);
175
+ return this.InternalCalculateNormalizedCost(this.UnitsPerBillingUnit, activeCost, inputTokens, outputTokens);
85
176
  }
86
177
  CalculateNormalizedCostWithCache(activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens) {
87
- return this.InternalCalculateNormalizedCostWithCache(1000, activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens);
178
+ return this.InternalCalculateNormalizedCostWithCache(this.UnitsPerBillingUnit, activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens);
88
179
  }
89
180
  };
90
181
  PerThousandTokensPriceUnitType = __decorate([
@@ -92,6 +183,9 @@ PerThousandTokensPriceUnitType = __decorate([
92
183
  ], PerThousandTokensPriceUnitType);
93
184
  export { PerThousandTokensPriceUnitType };
94
185
  let PerHundredThousandTokensPriceUnitType = class PerHundredThousandTokensPriceUnitType extends BasePriceUnitType {
186
+ get DeclaredUnitsPerBillingUnit() {
187
+ return 100_000;
188
+ }
95
189
  /**
96
190
  * Calculates normalized cost for the Per Hundred Thousand Tokens unit type, and token counts
97
191
  * @param activeCost The active cost configuration
@@ -100,15 +194,162 @@ let PerHundredThousandTokensPriceUnitType = class PerHundredThousandTokensPriceU
100
194
  * @returns The calculated cost
101
195
  */
102
196
  CalculateNormalizedCost(activeCost, inputTokens, outputTokens) {
103
- const divisor = 100000; // Prices are per hundred thousand tokens
104
- return this.InternalCalculateNormalizedCost(divisor, activeCost, inputTokens, outputTokens);
197
+ return this.InternalCalculateNormalizedCost(this.UnitsPerBillingUnit, activeCost, inputTokens, outputTokens);
105
198
  }
106
199
  CalculateNormalizedCostWithCache(activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens) {
107
- return this.InternalCalculateNormalizedCostWithCache(100000, activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens);
200
+ return this.InternalCalculateNormalizedCostWithCache(this.UnitsPerBillingUnit, activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens);
108
201
  }
109
202
  };
110
203
  PerHundredThousandTokensPriceUnitType = __decorate([
111
204
  RegisterClass(BasePriceUnitType, 'PerHundredThousandTokens')
112
205
  ], PerHundredThousandTokensPriceUnitType);
113
206
  export { PerHundredThousandTokensPriceUnitType };
207
+ /**
208
+ * Base for the drivers that price audio by elapsed time.
209
+ *
210
+ * Quantities arrive in SECONDS regardless of the rate's period, and the subclass supplies the
211
+ * divisor that converts. Recording seconds rather than the vendor's billing period is what lets
212
+ * one measured duration be priced against a per-minute row from one vendor and a per-hour row from
213
+ * another without the run having to know which it will be billed by.
214
+ *
215
+ * The cache buckets play no part: no transcription or speech vendor caches audio, so the inherited
216
+ * {@link BasePriceUnitType.CalculateNormalizedCostWithCache} default — which folds them into input
217
+ * at the input rate — is both correct and inert here.
218
+ */
219
+ export class BaseTimePriceUnitType extends BasePriceUnitType {
220
+ get UnitKind() {
221
+ return 'Seconds';
222
+ }
223
+ /**
224
+ * @param activeCost The active cost configuration
225
+ * @param inputSeconds Seconds of input audio (e.g. audio submitted for transcription)
226
+ * @param outputSeconds Seconds of output audio (e.g. synthesized speech)
227
+ */
228
+ CalculateNormalizedCost(activeCost, inputSeconds, outputSeconds) {
229
+ return this.InternalCalculateNormalizedCost(this.UnitsPerBillingUnit, activeCost, inputSeconds, outputSeconds);
230
+ }
231
+ }
232
+ let TimePerMinutePriceUnitType = class TimePerMinutePriceUnitType extends BaseTimePriceUnitType {
233
+ get DeclaredUnitsPerBillingUnit() {
234
+ return 60;
235
+ }
236
+ };
237
+ TimePerMinutePriceUnitType = __decorate([
238
+ RegisterClass(BasePriceUnitType, 'TimePerMinute')
239
+ ], TimePerMinutePriceUnitType);
240
+ export { TimePerMinutePriceUnitType };
241
+ let TimePerHourPriceUnitType = class TimePerHourPriceUnitType extends BaseTimePriceUnitType {
242
+ get DeclaredUnitsPerBillingUnit() {
243
+ return 3_600;
244
+ }
245
+ };
246
+ TimePerHourPriceUnitType = __decorate([
247
+ RegisterClass(BasePriceUnitType, 'TimePerHour')
248
+ ], TimePerHourPriceUnitType);
249
+ export { TimePerHourPriceUnitType };
250
+ /**
251
+ * Prices image generation by the image.
252
+ *
253
+ * Divisor 1 — the quantity IS the number of billed units, so there is nothing to normalize. Image
254
+ * cost rows carry the rate in `OutputPricePerUnit` (generated images are the output), which is the
255
+ * convention the shipped rows already follow; callers pass the count as the output quantity.
256
+ */
257
+ let PerImagePriceUnitType = class PerImagePriceUnitType extends BasePriceUnitType {
258
+ get UnitKind() {
259
+ return 'Images';
260
+ }
261
+ /**
262
+ * @param activeCost The active cost configuration
263
+ * @param inputImages Images supplied as input, for models that charge for them; normally 0
264
+ * @param outputImages Images generated
265
+ */
266
+ CalculateNormalizedCost(activeCost, inputImages, outputImages) {
267
+ // UnitsPerBillingUnit is the inherited default of 1 — an image IS the billed unit.
268
+ return this.InternalCalculateNormalizedCost(this.UnitsPerBillingUnit, activeCost, inputImages, outputImages);
269
+ }
270
+ };
271
+ PerImagePriceUnitType = __decorate([
272
+ RegisterClass(BasePriceUnitType, 'PerImage')
273
+ ], PerImagePriceUnitType);
274
+ export { PerImagePriceUnitType };
275
+ /**
276
+ * Prices any LINEAR billing unit entirely from its own `MJ: AI Model Price Unit Types` row.
277
+ *
278
+ * ## Why this exists — it closes B60's class, not just its instance
279
+ *
280
+ * The three continuous-media unit types that shipped uncosted (`Per Image`, `Per Minute`,
281
+ * `Per Hour`) were seeded as DATA by one person while the driver classes that price them were
282
+ * never written by another. The seam was silent for months. Every hardcoded driver below is a
283
+ * standing invitation to repeat that: seeding a row is not sufficient, so a row can always exist
284
+ * without the code that gives it meaning.
285
+ *
286
+ * With the measure (`UsageTypeID`) and the divisor (`UnitsPerBillingUnit`) held as columns, a linear
287
+ * unit type needs no code at all — it names this driver and states its own arithmetic. "Per 1,000
288
+ * Characters" becomes one seeded row rather than a row plus a class plus a registration plus a
289
+ * release.
290
+ *
291
+ * ## Why unregistered driver names still refuse
292
+ *
293
+ * This is opt-in via `DriverClass = 'Linear'` rather than a fallback for any unresolvable driver.
294
+ * `DriverClass` is NOT NULL, so every row names something, and an unrecognised name is ambiguous
295
+ * between "a new linear unit type" and "a genuinely non-linear driver whose code is missing". Pricing
296
+ * the second linearly would produce a confident wrong number, which is the one outcome this whole
297
+ * subsystem is built to avoid. So an unknown driver keeps refusing, and a row that WANTS data-driven
298
+ * pricing says so.
299
+ *
300
+ * `DriverClass` therefore remains the escape hatch for genuinely non-linear pricing: tiered rates,
301
+ * per-image-by-resolution, or minimum-billing increments such as the Groq 10-second floor.
302
+ */
303
+ let LinearPriceUnitType = class LinearPriceUnitType extends BasePriceUnitType {
304
+ /**
305
+ * The measure named by the row's usage type. Falls back to `Tokens` only when this driver was
306
+ * constructed with no row at all, which `GetPriceCalculator` never does — a caller that
307
+ * instantiates it directly gets the same default every other driver has.
308
+ */
309
+ get UnitKind() {
310
+ const name = this.PriceUnitType?.UsageType;
311
+ return name ?? 'Tokens';
312
+ }
313
+ // UnitsPerBillingUnit needs no override: the base reads the row and falls back to the inherited
314
+ // declared value of 1. That is the same accessor every built-in driver now uses, which is the
315
+ // point — `Linear` is not a special case, it is the driver with nothing compiled in.
316
+ CalculateNormalizedCost(activeCost, inputQuantity, outputQuantity) {
317
+ return this.InternalCalculateNormalizedCost(this.UnitsPerBillingUnit, activeCost, inputQuantity, outputQuantity);
318
+ }
319
+ CalculateNormalizedCostWithCache(activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens) {
320
+ // Per-bucket rates are meaningful for token measures and inert for the others (no vendor
321
+ // caches audio or images), so applying them uniformly is correct either way: with no cache
322
+ // quantities recorded, this reduces exactly to input + output at their own rates.
323
+ return this.InternalCalculateNormalizedCostWithCache(this.UnitsPerBillingUnit, activeCost, uncachedInputTokens, cacheReadTokens, cacheWriteTokens, outputTokens);
324
+ }
325
+ };
326
+ LinearPriceUnitType = __decorate([
327
+ RegisterClass(BasePriceUnitType, LINEAR_PRICE_UNIT_DRIVER_CLASS)
328
+ ], LinearPriceUnitType);
329
+ export { LinearPriceUnitType };
330
+ /**
331
+ * The divisor each TOKEN-measured price unit type normalizes by, keyed by DriverClass.
332
+ *
333
+ * Token-rate math — cache-savings figures, per-token cost splits — is meaningful only for these. A
334
+ * consumer doing that math must SKIP a cost row priced by audio duration or by the image rather than
335
+ * fall back to a token divisor, which would divide an hourly rate by a million and report noise.
336
+ * Restricting the map to the token drivers is what makes a missing key the correct signal to skip
337
+ * rather than something to paper over with a default.
338
+ *
339
+ * Keyed by **DriverClass**, never by the unit type's display name: the names are editable metadata
340
+ * (`Per 1M Tokens` today) while the driver class is the contract the ClassFactory resolves. The keys
341
+ * are written out rather than read from `constructor.name`, which minifiers rewrite — this map is
342
+ * consumed by the Explorer dashboards, where that would silently empty it.
343
+ *
344
+ * **The NUMBERS are derived from the driver instances, never restated here.** They live in exactly
345
+ * one place per driver — {@link BasePriceUnitType.UnitsPerBillingUnit} — because a hand-written copy
346
+ * of the arithmetic that prices every run is a second source of truth held together by nothing but a
347
+ * unit test. Deriving makes drift impossible instead of merely detectable.
348
+ */
349
+ export const TOKEN_PRICE_UNIT_TYPE_DIVISORS = Object.freeze(Object.fromEntries([
350
+ ['PerMillionTokens', new PerMillionTokensPriceUnitType()],
351
+ ['PerHundredThousandTokens', new PerHundredThousandTokensPriceUnitType()],
352
+ ['PerThousandTokens', new PerThousandTokensPriceUnitType()]
353
+ ]
354
+ .map(([driverClass, driver]) => [driverClass, driver.UnitsPerBillingUnit])));
114
355
  //# sourceMappingURL=PriceUnitTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PriceUnitTypes.js","sourceRoot":"","sources":["../src/PriceUnitTypes.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAgB,iBAAiB;IAczB,+BAA+B,CACrC,OAAe,EACf,UAA+B,EAC/B,WAAmB,EACnB,YAAoB;QAEpB,kBAAkB;QAClB,MAAM,SAAS,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;QACjF,MAAM,UAAU,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAEpF,OAAO,SAAS,GAAG,UAAU,CAAC;IAClC,CAAC;IAED;;;;;;;;;;OAUG;IACI,gCAAgC,CACnC,UAA+B,EAC/B,mBAA2B,EAC3B,eAAuB,EACvB,gBAAwB,EACxB,YAAoB;QAEpB,MAAM,UAAU,GAAG,CAAC,mBAAmB,IAAI,CAAC,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,CAAC,GAAG,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC,uBAAuB,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACO,wCAAwC,CAC9C,OAAe,EACf,UAA+B,EAC/B,mBAA2B,EAC3B,eAAuB,EAC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