@cat-factory/spend 0.10.109 → 0.11.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/dist/SpendService.d.ts +71 -10
- package/dist/SpendService.d.ts.map +1 -1
- package/dist/SpendService.js +148 -11
- package/dist/SpendService.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pricing.d.ts +27 -0
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +31 -0
- package/dist/pricing.js.map +1 -1
- package/package.json +3 -3
package/dist/SpendService.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { OpenRouterModelMeta, SpendStatus } from '@cat-factory/contracts';
|
|
1
|
+
import type { BudgetCaps, OpenRouterModelMeta, SpendStatus } from '@cat-factory/contracts';
|
|
2
2
|
import type { AgentTokenUsage } from '@cat-factory/kernel';
|
|
3
3
|
import type { Clock, IdGenerator } from '@cat-factory/kernel';
|
|
4
|
-
import type { TokenUsageRepository, WorkspaceSettingsRepository } from '@cat-factory/kernel';
|
|
4
|
+
import type { AccountRepository, TokenUsageRepository, UserSettingsRepository, WorkspaceSettingsRepository } from '@cat-factory/kernel';
|
|
5
5
|
import { type SpendPricing } from './pricing.js';
|
|
6
6
|
export interface SpendServiceDependencies {
|
|
7
7
|
tokenUsageRepository: TokenUsageRepository;
|
|
8
8
|
idGenerator: IdGenerator;
|
|
9
9
|
clock: Clock;
|
|
10
|
-
/** The base (built-in) pricing table + the deployment fallback budget/currency. */
|
|
10
|
+
/** The base (built-in) pricing table + the deployment fallback budget/currency + env caps. */
|
|
11
11
|
pricing: SpendPricing;
|
|
12
12
|
/**
|
|
13
13
|
* Per-workspace budget overrides (currency / monthly limit / per-model prices),
|
|
@@ -16,6 +16,18 @@ export interface SpendServiceDependencies {
|
|
|
16
16
|
* base table; absent ⇒ every workspace uses the base table (tests/conformance).
|
|
17
17
|
*/
|
|
18
18
|
workspaceSettingsRepository?: WorkspaceSettingsRepository;
|
|
19
|
+
/**
|
|
20
|
+
* Account tenancy repository, read for the ACCOUNT budget tier (an account's
|
|
21
|
+
* configured `spendMonthlyLimit`). Absent ⇒ the account tier is inert unless the
|
|
22
|
+
* operator env cap alone activates it.
|
|
23
|
+
*/
|
|
24
|
+
accountRepository?: AccountRepository;
|
|
25
|
+
/**
|
|
26
|
+
* Per-user settings repository, read for the USER budget tier (a user's configured
|
|
27
|
+
* `spendMonthlyLimit`). Absent ⇒ the user tier is inert unless the operator env cap
|
|
28
|
+
* alone activates it.
|
|
29
|
+
*/
|
|
30
|
+
userSettingsRepository?: UserSettingsRepository;
|
|
19
31
|
/**
|
|
20
32
|
* Optional resolver for a workspace's dynamic gateway model prices (the enabled
|
|
21
33
|
* OpenRouter catalog). When wired, a metered `openrouter:<slug>` call is priced at the
|
|
@@ -28,12 +40,21 @@ export interface SpendServiceDependencies {
|
|
|
28
40
|
/** Details of a single metered LLM call, handed in by the execution engine. */
|
|
29
41
|
export interface RecordUsageInput {
|
|
30
42
|
workspaceId: string;
|
|
43
|
+
/** The owning account of `workspaceId` (denormalized for the account rollup). */
|
|
44
|
+
accountId?: string | null;
|
|
45
|
+
/** The user who initiated the run (denormalized for the user rollup). */
|
|
46
|
+
userId?: string | null;
|
|
31
47
|
executionId: string | null;
|
|
32
48
|
agentKind: string;
|
|
33
49
|
/** Model identifier as `provider:model` (as produced by AgentRunResult.model). */
|
|
34
50
|
model: string;
|
|
35
51
|
usage: AgentTokenUsage;
|
|
36
52
|
}
|
|
53
|
+
/** Which budget tiers to check when gating a run (the caller passes what ids it has). */
|
|
54
|
+
export interface BudgetTierScope {
|
|
55
|
+
accountId?: string | null;
|
|
56
|
+
userId?: string | null;
|
|
57
|
+
}
|
|
37
58
|
/**
|
|
38
59
|
* The spend safeguard. It meters token usage into a persistent ledger, prices
|
|
39
60
|
* each call into a single currency, and reports the current billing period's
|
|
@@ -41,9 +62,12 @@ export interface RecordUsageInput {
|
|
|
41
62
|
* {@link isOverBudget} before every agent step and pauses when the budget is
|
|
42
63
|
* exhausted; the worker surfaces {@link status} so the frontend can warn.
|
|
43
64
|
*
|
|
44
|
-
* Budgets are
|
|
45
|
-
*
|
|
46
|
-
*
|
|
65
|
+
* Budgets are tiered — workspace, account, and user. The workspace tier overlays the
|
|
66
|
+
* workspace's currency/monthly-limit overrides onto the built-in base table; the account
|
|
67
|
+
* and user tiers compare their own rollup against a configured limit clamped by the
|
|
68
|
+
* operator env cap. A run is over budget when ANY applicable tier is exhausted.
|
|
69
|
+
* Resolutions are cached briefly so the hot {@link isOverBudget} gate doesn't re-read
|
|
70
|
+
* settings per step.
|
|
47
71
|
*/
|
|
48
72
|
export declare class SpendService {
|
|
49
73
|
private readonly tokenUsageRepository;
|
|
@@ -51,9 +75,13 @@ export declare class SpendService {
|
|
|
51
75
|
private readonly clock;
|
|
52
76
|
private readonly pricing;
|
|
53
77
|
private readonly workspaceSettingsRepository?;
|
|
78
|
+
private readonly accountRepository?;
|
|
79
|
+
private readonly userSettingsRepository?;
|
|
54
80
|
private readonly dynamicPricesFor?;
|
|
55
81
|
private readonly pricingCache;
|
|
56
|
-
|
|
82
|
+
private readonly accountLimitCache;
|
|
83
|
+
private readonly userLimitCache;
|
|
84
|
+
constructor({ tokenUsageRepository, idGenerator, clock, pricing, workspaceSettingsRepository, accountRepository, userSettingsRepository, dynamicPricesFor, }: SpendServiceDependencies);
|
|
57
85
|
/** Parse a `provider:model` identifier into a {@link ModelRef}. */
|
|
58
86
|
private parseModel;
|
|
59
87
|
/**
|
|
@@ -64,11 +92,44 @@ export declare class SpendService {
|
|
|
64
92
|
private resolvePricing;
|
|
65
93
|
/** Invalidate a workspace's cached pricing (called after a budget edit). */
|
|
66
94
|
invalidatePricing(workspaceId: string): void;
|
|
95
|
+
/** Invalidate a cached account effective limit (called after an account-budget edit). */
|
|
96
|
+
invalidateAccountLimit(accountId: string): void;
|
|
97
|
+
/** Invalidate a cached user effective limit (called after a user-budget edit). */
|
|
98
|
+
invalidateUserLimit(userId: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* The account tier's effective monthly limit: the configured account limit clamped by
|
|
101
|
+
* the operator env cap. `Infinity` when the tier is inactive (neither set). Cached for
|
|
102
|
+
* {@link PRICING_CACHE_TTL_MS}.
|
|
103
|
+
*/
|
|
104
|
+
private resolveAccountLimit;
|
|
105
|
+
/** The user tier's effective monthly limit (configured user limit clamped by the env cap). */
|
|
106
|
+
private resolveUserLimit;
|
|
67
107
|
/** Meter and persist one LLM call; returns its estimated cost. */
|
|
68
108
|
record(input: RecordUsageInput): Promise<number>;
|
|
69
|
-
/** The current billing period's spend against the
|
|
109
|
+
/** The current billing period's spend against the WORKSPACE budget. */
|
|
70
110
|
status(workspaceId: string): Promise<SpendStatus>;
|
|
71
|
-
/**
|
|
72
|
-
|
|
111
|
+
/**
|
|
112
|
+
* The ACCOUNT tier's status, or null when the tier is inactive (no configured limit
|
|
113
|
+
* and no operator cap). `costLimit` is the effective limit (configured clamped by the
|
|
114
|
+
* env cap); costs are in the base pricing currency.
|
|
115
|
+
*/
|
|
116
|
+
accountStatus(accountId: string): Promise<SpendStatus | null>;
|
|
117
|
+
/**
|
|
118
|
+
* The USER tier's status, or null when the tier is inactive (no limit and no cap).
|
|
119
|
+
* `preloaded` lets a caller that already holds the user's settings (e.g. the snapshot
|
|
120
|
+
* assembly, which reads the same row for the editable `userSettings` field) pass the
|
|
121
|
+
* configured limit in, so this doesn't re-read the `user_settings` row.
|
|
122
|
+
*/
|
|
123
|
+
userStatus(userId: string, preloaded?: {
|
|
124
|
+
configuredLimit: number | null;
|
|
125
|
+
}): Promise<SpendStatus | null>;
|
|
126
|
+
/** The operator hard ceilings on the account/user tiers, for the SPA budget screens. */
|
|
127
|
+
budgetCaps(): BudgetCaps;
|
|
128
|
+
/**
|
|
129
|
+
* Whether this period's spend has reached ANY applicable budget tier (runs should
|
|
130
|
+
* pause). Always checks the workspace tier; also checks the account/user tiers when
|
|
131
|
+
* the caller supplies those ids (they resolve to inactive tiers cheaply otherwise).
|
|
132
|
+
*/
|
|
133
|
+
isOverBudget(workspaceId: string, scope?: BudgetTierScope): Promise<boolean>;
|
|
73
134
|
}
|
|
74
135
|
//# sourceMappingURL=SpendService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpendService.d.ts","sourceRoot":"","sources":["../src/SpendService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"SpendService.d.ts","sourceRoot":"","sources":["../src/SpendService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,KAAK,YAAY,EAMlB,MAAM,cAAc,CAAA;AAErB,MAAM,WAAW,wBAAwB;IACvC,oBAAoB,EAAE,oBAAoB,CAAA;IAC1C,WAAW,EAAE,WAAW,CAAA;IACxB,KAAK,EAAE,KAAK,CAAA;IACZ,8FAA8F;IAC9F,OAAO,EAAE,YAAY,CAAA;IACrB;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,2BAA2B,CAAA;IACzD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;IAC/C;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,K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,GACjB,EAAE,wBAAwB,EAS1B;IAED,mEAAmE;IACnE,OAAO,CAAC,UAAU;IAMlB;;;;OAIG;YACW,cAAc;IAW5B,4EAA4E;IAC5E,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE3C;IAED,yFAAyF;IACzF,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9C;IAED,kFAAkF;IAClF,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAExC;IAED;;;;OAIG;YACW,mBAAmB;IAmBjC,8FAA8F;YAChF,gBAAgB;IAgB9B,kEAAkE;IAC5D,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBrD;IAED,uEAAuE;IACjE,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAatD;IAED;;;;OAIG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAclE;IAED;;;;;OAKG;IACG,UAAU,CACd,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE;QAAE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAC7C,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAgB7B;IAED,wFAAwF;IACxF,UAAU,IAAI,UAAU,CAMvB;IAED;;;;OAIG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,GAAE,eAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrF;CACF"}
|
package/dist/SpendService.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { estimateCost, mergeSpendPricing, startOfMonthUtc, withDynamicPrices, } from './pricing.js';
|
|
1
|
+
import { effectiveTierLimit, estimateCost, mergeSpendPricing, startOfMonthUtc, withDynamicPrices, } from './pricing.js';
|
|
2
2
|
/** How long a workspace's resolved pricing is cached before reloading (ms). */
|
|
3
3
|
const PRICING_CACHE_TTL_MS = 30_000;
|
|
4
4
|
/**
|
|
@@ -8,9 +8,12 @@ const PRICING_CACHE_TTL_MS = 30_000;
|
|
|
8
8
|
* {@link isOverBudget} before every agent step and pauses when the budget is
|
|
9
9
|
* exhausted; the worker surfaces {@link status} so the frontend can warn.
|
|
10
10
|
*
|
|
11
|
-
* Budgets are
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Budgets are tiered — workspace, account, and user. The workspace tier overlays the
|
|
12
|
+
* workspace's currency/monthly-limit overrides onto the built-in base table; the account
|
|
13
|
+
* and user tiers compare their own rollup against a configured limit clamped by the
|
|
14
|
+
* operator env cap. A run is over budget when ANY applicable tier is exhausted.
|
|
15
|
+
* Resolutions are cached briefly so the hot {@link isOverBudget} gate doesn't re-read
|
|
16
|
+
* settings per step.
|
|
14
17
|
*/
|
|
15
18
|
export class SpendService {
|
|
16
19
|
tokenUsageRepository;
|
|
@@ -18,14 +21,20 @@ export class SpendService {
|
|
|
18
21
|
clock;
|
|
19
22
|
pricing;
|
|
20
23
|
workspaceSettingsRepository;
|
|
24
|
+
accountRepository;
|
|
25
|
+
userSettingsRepository;
|
|
21
26
|
dynamicPricesFor;
|
|
22
27
|
pricingCache = new Map();
|
|
23
|
-
|
|
28
|
+
accountLimitCache = new Map();
|
|
29
|
+
userLimitCache = new Map();
|
|
30
|
+
constructor({ tokenUsageRepository, idGenerator, clock, pricing, workspaceSettingsRepository, accountRepository, userSettingsRepository, dynamicPricesFor, }) {
|
|
24
31
|
this.tokenUsageRepository = tokenUsageRepository;
|
|
25
32
|
this.idGenerator = idGenerator;
|
|
26
33
|
this.clock = clock;
|
|
27
34
|
this.pricing = pricing;
|
|
28
35
|
this.workspaceSettingsRepository = workspaceSettingsRepository;
|
|
36
|
+
this.accountRepository = accountRepository;
|
|
37
|
+
this.userSettingsRepository = userSettingsRepository;
|
|
29
38
|
this.dynamicPricesFor = dynamicPricesFor;
|
|
30
39
|
}
|
|
31
40
|
/** Parse a `provider:model` identifier into a {@link ModelRef}. */
|
|
@@ -56,6 +65,57 @@ export class SpendService {
|
|
|
56
65
|
invalidatePricing(workspaceId) {
|
|
57
66
|
this.pricingCache.delete(workspaceId);
|
|
58
67
|
}
|
|
68
|
+
/** Invalidate a cached account effective limit (called after an account-budget edit). */
|
|
69
|
+
invalidateAccountLimit(accountId) {
|
|
70
|
+
this.accountLimitCache.delete(accountId);
|
|
71
|
+
}
|
|
72
|
+
/** Invalidate a cached user effective limit (called after a user-budget edit). */
|
|
73
|
+
invalidateUserLimit(userId) {
|
|
74
|
+
this.userLimitCache.delete(userId);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The account tier's effective monthly limit: the configured account limit clamped by
|
|
78
|
+
* the operator env cap. `Infinity` when the tier is inactive (neither set). Cached for
|
|
79
|
+
* {@link PRICING_CACHE_TTL_MS}.
|
|
80
|
+
*/
|
|
81
|
+
async resolveAccountLimit(accountId) {
|
|
82
|
+
const cap = this.pricing.accountMonthlyLimitCap;
|
|
83
|
+
if (!this.accountRepository)
|
|
84
|
+
return effectiveTierLimit(null, cap);
|
|
85
|
+
const now = this.clock.now();
|
|
86
|
+
const cached = this.accountLimitCache.get(accountId);
|
|
87
|
+
let configured;
|
|
88
|
+
if (cached && cached.expiresAt > now) {
|
|
89
|
+
configured = cached.value;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const account = await this.accountRepository.get(accountId);
|
|
93
|
+
configured = account?.spendMonthlyLimit ?? null;
|
|
94
|
+
this.accountLimitCache.set(accountId, {
|
|
95
|
+
value: configured,
|
|
96
|
+
expiresAt: now + PRICING_CACHE_TTL_MS,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return effectiveTierLimit(configured, cap);
|
|
100
|
+
}
|
|
101
|
+
/** The user tier's effective monthly limit (configured user limit clamped by the env cap). */
|
|
102
|
+
async resolveUserLimit(userId) {
|
|
103
|
+
const cap = this.pricing.userMonthlyLimitCap;
|
|
104
|
+
if (!this.userSettingsRepository)
|
|
105
|
+
return effectiveTierLimit(null, cap);
|
|
106
|
+
const now = this.clock.now();
|
|
107
|
+
const cached = this.userLimitCache.get(userId);
|
|
108
|
+
let configured;
|
|
109
|
+
if (cached && cached.expiresAt > now) {
|
|
110
|
+
configured = cached.value;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const settings = await this.userSettingsRepository.get(userId);
|
|
114
|
+
configured = settings?.spendMonthlyLimit ?? null;
|
|
115
|
+
this.userLimitCache.set(userId, { value: configured, expiresAt: now + PRICING_CACHE_TTL_MS });
|
|
116
|
+
}
|
|
117
|
+
return effectiveTierLimit(configured, cap);
|
|
118
|
+
}
|
|
59
119
|
/** Meter and persist one LLM call; returns its estimated cost. */
|
|
60
120
|
async record(input) {
|
|
61
121
|
const ref = this.parseModel(input.model);
|
|
@@ -69,6 +129,8 @@ export class SpendService {
|
|
|
69
129
|
await this.tokenUsageRepository.record({
|
|
70
130
|
id: this.idGenerator.next('tok'),
|
|
71
131
|
workspaceId: input.workspaceId,
|
|
132
|
+
accountId: input.accountId ?? null,
|
|
133
|
+
userId: input.userId ?? null,
|
|
72
134
|
executionId: input.executionId,
|
|
73
135
|
agentKind: input.agentKind,
|
|
74
136
|
provider: ref.provider,
|
|
@@ -80,7 +142,7 @@ export class SpendService {
|
|
|
80
142
|
});
|
|
81
143
|
return costEstimate;
|
|
82
144
|
}
|
|
83
|
-
/** The current billing period's spend against the
|
|
145
|
+
/** The current billing period's spend against the WORKSPACE budget. */
|
|
84
146
|
async status(workspaceId) {
|
|
85
147
|
const pricing = await this.resolvePricing(workspaceId);
|
|
86
148
|
const periodStart = startOfMonthUtc(this.clock.now());
|
|
@@ -95,12 +157,87 @@ export class SpendService {
|
|
|
95
157
|
exceeded: totals.costEstimate >= pricing.monthlyLimit,
|
|
96
158
|
};
|
|
97
159
|
}
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
160
|
+
/**
|
|
161
|
+
* The ACCOUNT tier's status, or null when the tier is inactive (no configured limit
|
|
162
|
+
* and no operator cap). `costLimit` is the effective limit (configured clamped by the
|
|
163
|
+
* env cap); costs are in the base pricing currency.
|
|
164
|
+
*/
|
|
165
|
+
async accountStatus(accountId) {
|
|
166
|
+
const limit = await this.resolveAccountLimit(accountId);
|
|
167
|
+
if (!Number.isFinite(limit))
|
|
168
|
+
return null;
|
|
101
169
|
const periodStart = startOfMonthUtc(this.clock.now());
|
|
102
|
-
const totals = await this.tokenUsageRepository.
|
|
103
|
-
return
|
|
170
|
+
const totals = await this.tokenUsageRepository.totalsSinceForAccount(accountId, periodStart);
|
|
171
|
+
return {
|
|
172
|
+
periodStart,
|
|
173
|
+
inputTokens: totals.inputTokens,
|
|
174
|
+
outputTokens: totals.outputTokens,
|
|
175
|
+
costSpent: totals.costEstimate,
|
|
176
|
+
costLimit: limit,
|
|
177
|
+
currency: this.pricing.currency,
|
|
178
|
+
exceeded: totals.costEstimate >= limit,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The USER tier's status, or null when the tier is inactive (no limit and no cap).
|
|
183
|
+
* `preloaded` lets a caller that already holds the user's settings (e.g. the snapshot
|
|
184
|
+
* assembly, which reads the same row for the editable `userSettings` field) pass the
|
|
185
|
+
* configured limit in, so this doesn't re-read the `user_settings` row.
|
|
186
|
+
*/
|
|
187
|
+
async userStatus(userId, preloaded) {
|
|
188
|
+
const limit = preloaded
|
|
189
|
+
? effectiveTierLimit(preloaded.configuredLimit, this.pricing.userMonthlyLimitCap)
|
|
190
|
+
: await this.resolveUserLimit(userId);
|
|
191
|
+
if (!Number.isFinite(limit))
|
|
192
|
+
return null;
|
|
193
|
+
const periodStart = startOfMonthUtc(this.clock.now());
|
|
194
|
+
const totals = await this.tokenUsageRepository.totalsSinceForUser(userId, periodStart);
|
|
195
|
+
return {
|
|
196
|
+
periodStart,
|
|
197
|
+
inputTokens: totals.inputTokens,
|
|
198
|
+
outputTokens: totals.outputTokens,
|
|
199
|
+
costSpent: totals.costEstimate,
|
|
200
|
+
costLimit: limit,
|
|
201
|
+
currency: this.pricing.currency,
|
|
202
|
+
exceeded: totals.costEstimate >= limit,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** The operator hard ceilings on the account/user tiers, for the SPA budget screens. */
|
|
206
|
+
budgetCaps() {
|
|
207
|
+
return {
|
|
208
|
+
accountMonthlyLimitMax: this.pricing.accountMonthlyLimitCap ?? null,
|
|
209
|
+
userMonthlyLimitMax: this.pricing.userMonthlyLimitCap ?? null,
|
|
210
|
+
currency: this.pricing.currency,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Whether this period's spend has reached ANY applicable budget tier (runs should
|
|
215
|
+
* pause). Always checks the workspace tier; also checks the account/user tiers when
|
|
216
|
+
* the caller supplies those ids (they resolve to inactive tiers cheaply otherwise).
|
|
217
|
+
*/
|
|
218
|
+
async isOverBudget(workspaceId, scope = {}) {
|
|
219
|
+
const periodStart = startOfMonthUtc(this.clock.now());
|
|
220
|
+
const pricing = await this.resolvePricing(workspaceId);
|
|
221
|
+
const workspaceTotals = await this.tokenUsageRepository.totalsSinceForWorkspace(workspaceId, periodStart);
|
|
222
|
+
if (workspaceTotals.costEstimate >= pricing.monthlyLimit)
|
|
223
|
+
return true;
|
|
224
|
+
if (scope.accountId) {
|
|
225
|
+
const limit = await this.resolveAccountLimit(scope.accountId);
|
|
226
|
+
if (Number.isFinite(limit)) {
|
|
227
|
+
const totals = await this.tokenUsageRepository.totalsSinceForAccount(scope.accountId, periodStart);
|
|
228
|
+
if (totals.costEstimate >= limit)
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (scope.userId) {
|
|
233
|
+
const limit = await this.resolveUserLimit(scope.userId);
|
|
234
|
+
if (Number.isFinite(limit)) {
|
|
235
|
+
const totals = await this.tokenUsageRepository.totalsSinceForUser(scope.userId, periodStart);
|
|
236
|
+
if (totals.costEstimate >= limit)
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return false;
|
|
104
241
|
}
|
|
105
242
|
}
|
|
106
243
|
//# sourceMappingURL=SpendService.js.map
|
package/dist/SpendService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpendService.js","sourceRoot":"","sources":["../src/SpendService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SpendService.js","sourceRoot":"","sources":["../src/SpendService.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAyDrB,+EAA+E;AAC/E,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAEnC;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,YAAY;IACN,oBAAoB,CAAsB;IAC1C,WAAW,CAAa;IACxB,KAAK,CAAO;IACZ,OAAO,CAAc;IACrB,2BAA2B,CAA8B;IACzD,iBAAiB,CAAoB;IACrC,sBAAsB,CAAyB;IAC/C,gBAAgB,CAA0D;IAC1E,YAAY,GAAG,IAAI,GAAG,EAAsD,CAAA;IAC5E,iBAAiB,GAAG,IAAI,GAAG,EAGzC,CAAA;IACc,cAAc,GAAG,IAAI,GAAG,EAAuD,CAAA;IAEhG,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,KAAK,EACL,OAAO,EACP,2BAA2B,EAC3B,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,GACS;QACzB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAA;QAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAA;QAC9D,IAAI,CAAC,iBAAiB,GAAG,iBA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C3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,CAClE,KAAK,CAAC,SAAS,EACf,WAAW,CACZ,CAAA;gBACD,IAAI,MAAM,CAAC,YAAY,IAAI,KAAK;oBAAE,OAAO,IAAI,CAAA;YAC/C,CAAC;QACH,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YACvD,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;gBAC5F,IAAI,MAAM,CAAC,YAAY,IAAI,KAAK;oBAAE,OAAO,IAAI,CAAA;YAC/C,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { SpendService, type SpendServiceDependencies, type RecordUsageInput, } from './SpendService.js';
|
|
2
|
-
export { type ModelPrice, type SpendPricing, DEFAULT_MODEL_PRICES, DEFAULT_MONTHLY_LIMIT_EUR, DEFAULT_SPEND_PRICING, priceFor, modelCostResolver, estimateCost, withDynamicPrices, startOfMonthUtc, } from './pricing.js';
|
|
1
|
+
export { SpendService, type SpendServiceDependencies, type RecordUsageInput, type BudgetTierScope, } from './SpendService.js';
|
|
2
|
+
export { type ModelPrice, type SpendPricing, DEFAULT_MODEL_PRICES, DEFAULT_MONTHLY_LIMIT_EUR, DEFAULT_SPEND_PRICING, budgetCapsOverlay, effectiveTierLimit, priceFor, modelCostResolver, estimateCost, withDynamicPrices, startOfMonthUtc, } from './pricing.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Pricing tables and spend metering/gating for @cat-factory.
|
|
2
2
|
export { SpendService, } from './SpendService.js';
|
|
3
|
-
export { DEFAULT_MODEL_PRICES, DEFAULT_MONTHLY_LIMIT_EUR, DEFAULT_SPEND_PRICING, priceFor, modelCostResolver, estimateCost, withDynamicPrices, startOfMonthUtc, } from './pricing.js';
|
|
3
|
+
export { DEFAULT_MODEL_PRICES, DEFAULT_MONTHLY_LIMIT_EUR, DEFAULT_SPEND_PRICING, budgetCapsOverlay, effectiveTierLimit, priceFor, modelCostResolver, estimateCost, withDynamicPrices, startOfMonthUtc, } from './pricing.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EACL,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EACL,YAAY,GAIb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAGL,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,MAAM,cAAc,CAAA"}
|
package/dist/pricing.d.ts
CHANGED
|
@@ -15,7 +15,27 @@ export interface SpendPricing {
|
|
|
15
15
|
prices: Record<string, ModelPrice>;
|
|
16
16
|
/** Fallback price for any model without a specific or provider-level entry. */
|
|
17
17
|
defaultPrice: ModelPrice;
|
|
18
|
+
/**
|
|
19
|
+
* Operator hard ceiling on the ACCOUNT-tier monthly budget, from the deployment env
|
|
20
|
+
* var `BUDGET_MAX_MONTHLY_PER_ACCOUNT`. Undefined ⇒ no operator ceiling. When set it
|
|
21
|
+
* caps whatever value the UI submits AND acts as the effective account budget when no
|
|
22
|
+
* account limit is configured. See the tiered-budgets initiative.
|
|
23
|
+
*/
|
|
24
|
+
accountMonthlyLimitCap?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Operator hard ceiling on the USER-tier monthly budget, from the deployment env var
|
|
27
|
+
* `BUDGET_MAX_MONTHLY_PER_USER`. Undefined ⇒ no operator ceiling. Same double duty as
|
|
28
|
+
* {@link accountMonthlyLimitCap}.
|
|
29
|
+
*/
|
|
30
|
+
userMonthlyLimitCap?: number;
|
|
18
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The effective monthly limit for a budget tier: the smaller of the tier's configured
|
|
34
|
+
* limit and the operator env cap, treating an absent value as "no constraint". Returns
|
|
35
|
+
* `Infinity` when neither is set — the tier is inactive and never gates. `0` is a real
|
|
36
|
+
* limit ("no paid spend"), not "absent", so it is respected.
|
|
37
|
+
*/
|
|
38
|
+
export declare function effectiveTierLimit(configured: number | null | undefined, cap: number | null | undefined): number;
|
|
19
39
|
/**
|
|
20
40
|
* Built-in approximate EUR prices per 1M tokens. Keys are matched most-specific
|
|
21
41
|
* first: exact `provider:model`, then the bare `provider`, then `defaultPrice`.
|
|
@@ -58,6 +78,13 @@ export declare function modelCostResolver(pricing: SpendPricing): (ref: ModelRef
|
|
|
58
78
|
};
|
|
59
79
|
/** Cost of a single call's token usage, in the pricing currency. */
|
|
60
80
|
export declare function estimateCost(pricing: SpendPricing, ref: ModelRef, usage: AgentTokenUsage): number;
|
|
81
|
+
/**
|
|
82
|
+
* Build the env-driven operator budget-cap overlay for a {@link SpendPricing}. Each cap
|
|
83
|
+
* is applied only when it is a non-negative number; a missing/invalid value leaves that
|
|
84
|
+
* tier uncapped. Shared by the Node and Cloudflare config loaders so both runtimes read
|
|
85
|
+
* `BUDGET_MAX_MONTHLY_PER_ACCOUNT` / `BUDGET_MAX_MONTHLY_PER_USER` identically.
|
|
86
|
+
*/
|
|
87
|
+
export declare function budgetCapsOverlay(accountCap: number | undefined, userCap: number | undefined): Partial<Pick<SpendPricing, 'accountMonthlyLimitCap' | 'userMonthlyLimitCap'>>;
|
|
61
88
|
/** Start of the calendar month containing `epochMs`, in UTC (epoch ms). */
|
|
62
89
|
export declare function startOfMonthUtc(epochMs: number): number;
|
|
63
90
|
//# sourceMappingURL=pricing.d.ts.map
|
package/dist/pricing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAWpF,sDAAsD;AACtD,MAAM,WAAW,UAAU;IACzB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,iEAA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O,MAAM,qBAAqB,EAAE,YAKnC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,mBAAmB,EAAE,GAC5B,YAAY,CAWd;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,GAAG,mBAAmB,CAAC,GAAG,IAAI,GAC/E,YAAY,CASd;AAED,gEAAgE;AAChE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,QAAQ,GAAG,UAAU,CAMzE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,YAAY,GACpB,CAAC,GAAG,EAAE,QAAQ,KAAK;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAS5F;AAED,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,GAAG,MAAM,CAMjG;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,wBAAwB,GAAG,qBAAqB,CAAC,CAAC,CAS/E;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGvD"}
|
package/dist/pricing.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The effective monthly limit for a budget tier: the smaller of the tier's configured
|
|
3
|
+
* limit and the operator env cap, treating an absent value as "no constraint". Returns
|
|
4
|
+
* `Infinity` when neither is set — the tier is inactive and never gates. `0` is a real
|
|
5
|
+
* limit ("no paid spend"), not "absent", so it is respected.
|
|
6
|
+
*/
|
|
7
|
+
export function effectiveTierLimit(configured, cap) {
|
|
8
|
+
const values = [];
|
|
9
|
+
if (configured != null)
|
|
10
|
+
values.push(configured);
|
|
11
|
+
if (cap != null)
|
|
12
|
+
values.push(cap);
|
|
13
|
+
return values.length > 0 ? Math.min(...values) : Number.POSITIVE_INFINITY;
|
|
14
|
+
}
|
|
1
15
|
/**
|
|
2
16
|
* Built-in approximate EUR prices per 1M tokens. Keys are matched most-specific
|
|
3
17
|
* first: exact `provider:model`, then the bare `provider`, then `defaultPrice`.
|
|
@@ -100,6 +114,7 @@ export function mergeSpendPricing(base, overrides) {
|
|
|
100
114
|
if (!overrides)
|
|
101
115
|
return base;
|
|
102
116
|
return {
|
|
117
|
+
...base,
|
|
103
118
|
currency: overrides.spendCurrency ?? base.currency,
|
|
104
119
|
monthlyLimit: overrides.spendMonthlyLimit ?? base.monthlyLimit,
|
|
105
120
|
prices: base.prices,
|
|
@@ -132,6 +147,22 @@ export function estimateCost(pricing, ref, usage) {
|
|
|
132
147
|
return ((usage.inputTokens / 1_000_000) * price.inputPerMillion +
|
|
133
148
|
(usage.outputTokens / 1_000_000) * price.outputPerMillion);
|
|
134
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Build the env-driven operator budget-cap overlay for a {@link SpendPricing}. Each cap
|
|
152
|
+
* is applied only when it is a non-negative number; a missing/invalid value leaves that
|
|
153
|
+
* tier uncapped. Shared by the Node and Cloudflare config loaders so both runtimes read
|
|
154
|
+
* `BUDGET_MAX_MONTHLY_PER_ACCOUNT` / `BUDGET_MAX_MONTHLY_PER_USER` identically.
|
|
155
|
+
*/
|
|
156
|
+
export function budgetCapsOverlay(accountCap, userCap) {
|
|
157
|
+
const overlay = {};
|
|
158
|
+
if (accountCap != null && Number.isFinite(accountCap) && accountCap >= 0) {
|
|
159
|
+
overlay.accountMonthlyLimitCap = accountCap;
|
|
160
|
+
}
|
|
161
|
+
if (userCap != null && Number.isFinite(userCap) && userCap >= 0) {
|
|
162
|
+
overlay.userMonthlyLimitCap = userCap;
|
|
163
|
+
}
|
|
164
|
+
return overlay;
|
|
165
|
+
}
|
|
135
166
|
/** Start of the calendar month containing `epochMs`, in UTC (epoch ms). */
|
|
136
167
|
export function startOfMonthUtc(epochMs) {
|
|
137
168
|
const d = new Date(epochMs);
|
package/dist/pricing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AA2CA;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAqC,EACrC,GAA8B;IAE9B,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,UAAU,IAAI,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC/C,IAAI,GAAG,IAAI,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAA;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA+B;IAC9D,wEAAwE;IACxE,2BAA2B,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC3E,6BAA6B,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE;IAChF,4BAA4B,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE;IAC9E,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI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C,WAAW,EAAE,EAAE,CAAC,CAAC,CAAA;AACzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cat-factory/spend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Pricing tables and spend metering for the Agent Architecture Board.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@cat-factory/contracts": "0.
|
|
28
|
-
"@cat-factory/kernel": "0.
|
|
27
|
+
"@cat-factory/contracts": "0.110.0",
|
|
28
|
+
"@cat-factory/kernel": "0.101.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "7.0.1-rc"
|