@trazum/core 1.44.0 → 1.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -184,6 +184,16 @@ differ: no budget configured, nothing measured, or a model the catalogue
184
184
  cannot price. Pure and synchronous, because a function that reads a file
185
185
  cannot promise an answer in milliseconds.
186
186
 
187
+ ## The guard
188
+
189
+ `guardSpend(request, { catalogue })` wraps `answerCost` with what to do
190
+ instead. A refusal carries alternatives — route, batch, or both combined the
191
+ way `billLevers` combines them rather than summed — each priced for the single
192
+ call being decided, each carrying its typed assumption, and each filtered to
193
+ models whose context window the prompt actually fits. `cannot-tell` never
194
+ becomes `yes`: a guard that permits whatever it cannot judge permits
195
+ everything the moment its inputs go missing.
196
+
187
197
  ## Comparing two versions
188
198
 
189
199
  ```ts
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The thing spending the money can finally ask, and be told no.
3
+ *
4
+ * 1.44 gave an endpoint that *answers*. An agent may consult it and ignore it,
5
+ * which is fine — advice an implementation can skip is still advice worth
6
+ * having. What was missing is the shape of a refusal an agent can act on.
7
+ *
8
+ * **A guard that only says no teaches a caller to stop asking.** A model told
9
+ * "denied" with no alternative has exactly two moves: send it anyway, or fail
10
+ * the user's request. Both are worse than the call it wanted to make. So every
11
+ * refusal here arrives with the levers that exist — this work routes to a
12
+ * cheaper model that still fits, a batch window would halve it — each with
13
+ * what it is worth *for this call*, and the assumption it rests on.
14
+ *
15
+ * **The guard never spends to answer.** No provider call, no LLM pass, no
16
+ * pull. The answer comes from the store and the catalogue, or it says it
17
+ * cannot tell. A cost guard that costs money to consult is a joke with a bill
18
+ * attached.
19
+ *
20
+ * **An alternative the prompt does not fit in is not an alternative.** A
21
+ * cheaper model with a smaller context window does not make this call cheaper;
22
+ * it makes it impossible. Those are filtered out here rather than offered and
23
+ * blamed later.
24
+ */
25
+ import type { AnswerRequest, CostAnswer } from './answer.js';
26
+ import type { PricingCatalogue } from './pricing.js';
27
+ import type { PlanAssumption } from './plan.js';
28
+ export type GuardVerdict = 'yes' | 'no' | 'cannot-tell';
29
+ export interface GuardAlternative {
30
+ kind: 'route' | 'batch' | 'route+batch';
31
+ /** The model this moves to, when it moves. */
32
+ model: {
33
+ id: string;
34
+ displayName: string;
35
+ } | null;
36
+ /**
37
+ * What this alternative saves **on this call** — not per month.
38
+ *
39
+ * The caller is deciding one call, right now. A monthly figure would be the
40
+ * right number at the wrong moment, and an agent has no way to act on it.
41
+ */
42
+ savingUsd: number;
43
+ /** What the log cannot confirm, typed as everywhere since 1.38. */
44
+ assumes: PlanAssumption[];
45
+ /**
46
+ * Whether the described call fits this alternative's context window.
47
+ *
48
+ * Only `true` ever reaches a caller — the false ones are dropped before
49
+ * they are offered. The field exists so the rule is visible in the type
50
+ * rather than buried in a filter nobody reads.
51
+ */
52
+ fits: true;
53
+ }
54
+ export interface GuardAnswer {
55
+ schemaVersion: 1;
56
+ verdict: GuardVerdict;
57
+ /** The full cost answer, halves and provenance intact. */
58
+ cost: CostAnswer;
59
+ /**
60
+ * What to do instead, dearest saving first. Present on a refusal, and on a
61
+ * yes as well: an agent that can spend less while still being allowed to
62
+ * spend should be told so.
63
+ */
64
+ alternatives: GuardAlternative[];
65
+ /**
66
+ * A one-line reason a human will read in a log. The fields above are what a
67
+ * machine acts on; this is never the only place a fact appears.
68
+ */
69
+ because: string;
70
+ }
71
+ export interface GuardRequest extends AnswerRequest {
72
+ /** Whether the caller says this work can wait for a batch window. */
73
+ batchEligible?: boolean;
74
+ }
75
+ export declare function guardSpend(request: GuardRequest, options: {
76
+ catalogue: PricingCatalogue;
77
+ on?: Date;
78
+ }): GuardAnswer;
79
+ //# sourceMappingURL=guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,IAAI,GAAG,aAAa,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;IACxC,8CAA8C;IAC9C,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAClD;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;;;;OAMG;IACH,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,CAAC,CAAC;IACjB,OAAO,EAAE,YAAY,CAAC;IACtB,0DAA0D;IAC1D,IAAI,EAAE,UAAU,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAuBD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,qEAAqE;IACrE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,gBAAgB,CAAC;IAAC,EAAE,CAAC,EAAE,IAAI,CAAA;CAAE,GAClD,WAAW,CA8Eb"}
package/dist/guard.js ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * The thing spending the money can finally ask, and be told no.
3
+ *
4
+ * 1.44 gave an endpoint that *answers*. An agent may consult it and ignore it,
5
+ * which is fine — advice an implementation can skip is still advice worth
6
+ * having. What was missing is the shape of a refusal an agent can act on.
7
+ *
8
+ * **A guard that only says no teaches a caller to stop asking.** A model told
9
+ * "denied" with no alternative has exactly two moves: send it anyway, or fail
10
+ * the user's request. Both are worse than the call it wanted to make. So every
11
+ * refusal here arrives with the levers that exist — this work routes to a
12
+ * cheaper model that still fits, a batch window would halve it — each with
13
+ * what it is worth *for this call*, and the assumption it rests on.
14
+ *
15
+ * **The guard never spends to answer.** No provider call, no LLM pass, no
16
+ * pull. The answer comes from the store and the catalogue, or it says it
17
+ * cannot tell. A cost guard that costs money to consult is a joke with a bill
18
+ * attached.
19
+ *
20
+ * **An alternative the prompt does not fit in is not an alternative.** A
21
+ * cheaper model with a smaller context window does not make this call cheaper;
22
+ * it makes it impossible. Those are filtered out here rather than offered and
23
+ * blamed later.
24
+ */
25
+ import { answerCost } from './answer.js';
26
+ import { effectivePricing, multipliersFor } from './pricing.js';
27
+ /** Models cheaper than this one, in the same family, that the prompt fits in. */
28
+ function cheaperThan(model, catalogue, inputTokens, on) {
29
+ const here = effectivePricing(model, on);
30
+ return [...catalogue.byId.values()]
31
+ .filter((candidate) => {
32
+ if (candidate.id === model.id)
33
+ return false;
34
+ if (candidate.provider !== model.provider)
35
+ return false;
36
+ const there = effectivePricing(candidate, on);
37
+ if (there.inputPerMTok >= here.inputPerMTok)
38
+ return false;
39
+ // A model the prompt does not fit in is not a cheaper way to make this
40
+ // call; it is a way not to make it.
41
+ return candidate.contextWindow >= inputTokens;
42
+ })
43
+ .sort((a, b) => effectivePricing(b, on).inputPerMTok - effectivePricing(a, on).inputPerMTok);
44
+ }
45
+ export function guardSpend(request, options) {
46
+ const { catalogue, on = new Date() } = options;
47
+ const cost = answerCost(request, { catalogue, on });
48
+ const alternatives = [];
49
+ const model = request.model === undefined ? undefined : catalogue.byId.get(request.model);
50
+ if (model !== undefined && cost.call !== null) {
51
+ const inputTokens = cost.call.inputTokens;
52
+ const outputTokens = cost.call.outputTokens;
53
+ const here = effectivePricing(model, on);
54
+ const priceOf = (candidate) => {
55
+ const rates = effectivePricing(candidate, on);
56
+ return (inputTokens / 1_000_000) * rates.inputPerMTok + (outputTokens / 1_000_000) * rates.outputPerMTok;
57
+ };
58
+ const mine = (inputTokens / 1_000_000) * here.inputPerMTok + (outputTokens / 1_000_000) * here.outputPerMTok;
59
+ const batchRate = multipliersFor(model).batch;
60
+ for (const candidate of cheaperThan(model, catalogue, inputTokens, on)) {
61
+ const routed = priceOf(candidate);
62
+ const candidateBatch = multipliersFor(candidate).batch;
63
+ const both = candidateBatch === null ? null : routed * candidateBatch;
64
+ /**
65
+ * Route and batch on the same call combine the way `billLevers` has
66
+ * combined them since 1.23: the batch discount applies to the *cheaper*
67
+ * model's price, never as a second subtraction from this one. Adding the
68
+ * two savings is the arithmetic `plan` exists to kill.
69
+ */
70
+ if (request.batchEligible === true && both !== null) {
71
+ alternatives.push({
72
+ kind: 'route+batch',
73
+ model: { id: candidate.id, displayName: candidate.displayName },
74
+ savingUsd: mine - both,
75
+ assumes: [
76
+ { kind: 'model-capability', model: candidate.displayName },
77
+ { kind: 'batch-window' },
78
+ ],
79
+ fits: true,
80
+ });
81
+ }
82
+ alternatives.push({
83
+ kind: 'route',
84
+ model: { id: candidate.id, displayName: candidate.displayName },
85
+ savingUsd: mine - routed,
86
+ assumes: [{ kind: 'model-capability', model: candidate.displayName }],
87
+ fits: true,
88
+ });
89
+ }
90
+ if (request.batchEligible === true && batchRate !== null) {
91
+ alternatives.push({
92
+ kind: 'batch',
93
+ model: null,
94
+ savingUsd: mine - mine * batchRate,
95
+ assumes: [{ kind: 'batch-window' }],
96
+ fits: true,
97
+ });
98
+ }
99
+ }
100
+ alternatives.sort((a, b) => b.savingUsd - a.savingUsd);
101
+ /**
102
+ * The verdict maps the cost answer's three outcomes onto the three an agent
103
+ * can act on. `cannot-tell` stays `cannot-tell` rather than defaulting to
104
+ * yes: a guard that permits whatever it cannot judge is a guard that permits
105
+ * everything the moment its inputs go missing.
106
+ */
107
+ const verdict = cost.verdict === 'cannot-tell' ? 'cannot-tell' : cost.verdict === 'over' ? 'no' : 'yes';
108
+ return {
109
+ schemaVersion: 1,
110
+ verdict,
111
+ cost,
112
+ alternatives,
113
+ because: reasonFor(verdict, cost, alternatives),
114
+ };
115
+ }
116
+ function reasonFor(verdict, cost, alternatives) {
117
+ if (verdict === 'cannot-tell') {
118
+ return cost.reason === 'no-budget-configured'
119
+ ? 'No budget is configured, so there is nothing to judge this against.'
120
+ : cost.reason === 'nothing-measured'
121
+ ? 'Nothing has been measured yet, so how much of the budget is gone is unknown.'
122
+ : 'This model is not in the price catalogue, so the call cannot be priced.';
123
+ }
124
+ if (verdict === 'no') {
125
+ const lead = cost.restsOn === 'measured'
126
+ ? 'The budget is already spent, measured.'
127
+ : 'This call would take the budget past its limit, on an estimate of the call.';
128
+ return alternatives.length === 0
129
+ ? `${lead} No cheaper way to make this call exists in the catalogue.`
130
+ : `${lead} The cheapest alternative below saves the most.`;
131
+ }
132
+ return alternatives.length === 0
133
+ ? 'Within budget, and no cheaper way to make this call exists in the catalogue.'
134
+ : 'Within budget — and there is still a cheaper way to make this call.';
135
+ }
136
+ //# sourceMappingURL=guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAgDhE,iFAAiF;AACjF,SAAS,WAAW,CAClB,KAAmB,EACnB,SAA2B,EAC3B,WAAmB,EACnB,EAAQ;IAER,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;SAChC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;QACpB,IAAI,SAAS,CAAC,EAAE,KAAK,KAAK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AAC;AAED,SAAS,SAAS,CAAC,OAAqB,EAAE,IAAgB,EAAE,YAAgC;IAC1F,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM,KAAK,sBAAsB;YAC3C,CAAC,CAAC,qEAAqE;YACvE,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,kBAAkB;gBAClC,CAAC,CAAC,8EAA8E;gBAChF,CAAC,CAAC,yEAAyE,CAAC;IAClF,CAAC;IACD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,KAAK,UAAU;YACtC,CAAC,CAAC,wCAAwC;YAC1C,CAAC,CAAC,6EAA6E,CAAC;QAClF,OAAO,YAAY,CAAC,MAAM,KAAK,CAAC;YAC9B,CAAC,CAAC,GAAG,IAAI,4DAA4D;YACrE,CAAC,CAAC,GAAG,IAAI,iDAAiD,CAAC;IAC/D,CAAC;IACD,OAAO,YAAY,CAAC,MAAM,KAAK,CAAC;QAC9B,CAAC,CAAC,8EAA8E;QAChF,CAAC,CAAC,qEAAqE,CAAC;AAC5E,CAAC"}
package/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export type { PlanAction, PlanActionKind, PlanAssumption, PlanDocument } from '.
18
18
  export { verifyPlan } from './verify.js';
19
19
  export { buildHistory, storedReportFrom, MIN_RUN } from './history.js';
20
20
  export { answerCost } from './answer.js';
21
+ export { guardSpend } from './guard.js';
22
+ export type { GuardAlternative, GuardAnswer, GuardRequest, GuardVerdict } from './guard.js';
21
23
  export type { AnswerRequest, AnswerVerdict, BudgetPosition, CallEstimate, CannotTellReasonAnswer, CostAnswer, } from './answer.js';
22
24
  export { evaluateWatch, firedKey, COVERAGE_FLOOR, DAY_MS } from './watch.js';
23
25
  export type { NotJudgeable, WatchAbstention, WatchCrossing, WatchGate, WatchOptions, WatchResult, WatchThresholds, } from './watch.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","s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MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ export { buildPlan, planLabelName } from './plan.js';
22
22
  export { verifyPlan } from './verify.js';
23
23
  export { buildHistory, storedReportFrom, MIN_RUN } from './history.js';
24
24
  export { answerCost } from './answer.js';
25
+ export { guardSpend } from './guard.js';
25
26
  export { evaluateWatch, firedKey, COVERAGE_FLOOR, DAY_MS } from './watch.js';
26
27
  export { STORE_SCHEMA_VERSION, identityOf, resolveStore, recordsFromBuckets, bucketsFromRecords, storeInventory, pruneRecords, } from './store.js';
27
28
  export { CONNECTORS, connectorFor, normalizeAnthropicUsage, normalizeOpenAIUsage, bucketedProfile, bucketedCacheEconomics, } from './connector.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EACL,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,MAAM,YAAY,CAAC;AAWpB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAClF,gFAAgF;AAChF,4EAA4E;AAC5E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEtF,2EAA2E;AAC3E,+EAA+E;AAC/E,8EAA8E;AAC9E,0EAA0E;AAC1E,yCAAyC;AACzC,4EAA4E;AAC5E,qDAAqD;AACrD,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,YAAY,GACb,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,MAAM,c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trazum core: priced advisories for LLM prompts (caching, model tier, batching, schemas), plus deterministic trimming, token counting and pricing.",
5
5
  "license": "MIT",
6
6
  "author": "David Mu\u00f1oz Rey",
package/src/guard.ts ADDED
@@ -0,0 +1,204 @@
1
+ /**
2
+ * The thing spending the money can finally ask, and be told no.
3
+ *
4
+ * 1.44 gave an endpoint that *answers*. An agent may consult it and ignore it,
5
+ * which is fine — advice an implementation can skip is still advice worth
6
+ * having. What was missing is the shape of a refusal an agent can act on.
7
+ *
8
+ * **A guard that only says no teaches a caller to stop asking.** A model told
9
+ * "denied" with no alternative has exactly two moves: send it anyway, or fail
10
+ * the user's request. Both are worse than the call it wanted to make. So every
11
+ * refusal here arrives with the levers that exist — this work routes to a
12
+ * cheaper model that still fits, a batch window would halve it — each with
13
+ * what it is worth *for this call*, and the assumption it rests on.
14
+ *
15
+ * **The guard never spends to answer.** No provider call, no LLM pass, no
16
+ * pull. The answer comes from the store and the catalogue, or it says it
17
+ * cannot tell. A cost guard that costs money to consult is a joke with a bill
18
+ * attached.
19
+ *
20
+ * **An alternative the prompt does not fit in is not an alternative.** A
21
+ * cheaper model with a smaller context window does not make this call cheaper;
22
+ * it makes it impossible. Those are filtered out here rather than offered and
23
+ * blamed later.
24
+ */
25
+
26
+ import { answerCost } from './answer.js';
27
+ import type { AnswerRequest, CostAnswer } from './answer.js';
28
+ import { effectivePricing, multipliersFor } from './pricing.js';
29
+ import type { PricingCatalogue } from './pricing.js';
30
+ import type { ModelPricing } from './types.js';
31
+ import type { PlanAssumption } from './plan.js';
32
+
33
+ export type GuardVerdict = 'yes' | 'no' | 'cannot-tell';
34
+
35
+ export interface GuardAlternative {
36
+ kind: 'route' | 'batch' | 'route+batch';
37
+ /** The model this moves to, when it moves. */
38
+ model: { id: string; displayName: string } | null;
39
+ /**
40
+ * What this alternative saves **on this call** — not per month.
41
+ *
42
+ * The caller is deciding one call, right now. A monthly figure would be the
43
+ * right number at the wrong moment, and an agent has no way to act on it.
44
+ */
45
+ savingUsd: number;
46
+ /** What the log cannot confirm, typed as everywhere since 1.38. */
47
+ assumes: PlanAssumption[];
48
+ /**
49
+ * Whether the described call fits this alternative's context window.
50
+ *
51
+ * Only `true` ever reaches a caller — the false ones are dropped before
52
+ * they are offered. The field exists so the rule is visible in the type
53
+ * rather than buried in a filter nobody reads.
54
+ */
55
+ fits: true;
56
+ }
57
+
58
+ export interface GuardAnswer {
59
+ schemaVersion: 1;
60
+ verdict: GuardVerdict;
61
+ /** The full cost answer, halves and provenance intact. */
62
+ cost: CostAnswer;
63
+ /**
64
+ * What to do instead, dearest saving first. Present on a refusal, and on a
65
+ * yes as well: an agent that can spend less while still being allowed to
66
+ * spend should be told so.
67
+ */
68
+ alternatives: GuardAlternative[];
69
+ /**
70
+ * A one-line reason a human will read in a log. The fields above are what a
71
+ * machine acts on; this is never the only place a fact appears.
72
+ */
73
+ because: string;
74
+ }
75
+
76
+ /** Models cheaper than this one, in the same family, that the prompt fits in. */
77
+ function cheaperThan(
78
+ model: ModelPricing,
79
+ catalogue: PricingCatalogue,
80
+ inputTokens: number,
81
+ on: Date,
82
+ ): ModelPricing[] {
83
+ const here = effectivePricing(model, on);
84
+ return [...catalogue.byId.values()]
85
+ .filter((candidate) => {
86
+ if (candidate.id === model.id) return false;
87
+ if (candidate.provider !== model.provider) return false;
88
+ const there = effectivePricing(candidate, on);
89
+ if (there.inputPerMTok >= here.inputPerMTok) return false;
90
+ // A model the prompt does not fit in is not a cheaper way to make this
91
+ // call; it is a way not to make it.
92
+ return candidate.contextWindow >= inputTokens;
93
+ })
94
+ .sort((a, b) => effectivePricing(b, on).inputPerMTok - effectivePricing(a, on).inputPerMTok);
95
+ }
96
+
97
+ export interface GuardRequest extends AnswerRequest {
98
+ /** Whether the caller says this work can wait for a batch window. */
99
+ batchEligible?: boolean;
100
+ }
101
+
102
+ export function guardSpend(
103
+ request: GuardRequest,
104
+ options: { catalogue: PricingCatalogue; on?: Date },
105
+ ): GuardAnswer {
106
+ const { catalogue, on = new Date() } = options;
107
+ const cost = answerCost(request, { catalogue, on });
108
+
109
+ const alternatives: GuardAlternative[] = [];
110
+ const model = request.model === undefined ? undefined : catalogue.byId.get(request.model);
111
+
112
+ if (model !== undefined && cost.call !== null) {
113
+ const inputTokens = cost.call.inputTokens;
114
+ const outputTokens = cost.call.outputTokens;
115
+ const here = effectivePricing(model, on);
116
+ const priceOf = (candidate: ModelPricing): number => {
117
+ const rates = effectivePricing(candidate, on);
118
+ return (inputTokens / 1_000_000) * rates.inputPerMTok + (outputTokens / 1_000_000) * rates.outputPerMTok;
119
+ };
120
+ const mine = (inputTokens / 1_000_000) * here.inputPerMTok + (outputTokens / 1_000_000) * here.outputPerMTok;
121
+ const batchRate = multipliersFor(model).batch;
122
+
123
+ for (const candidate of cheaperThan(model, catalogue, inputTokens, on)) {
124
+ const routed = priceOf(candidate);
125
+ const candidateBatch = multipliersFor(candidate).batch;
126
+ const both = candidateBatch === null ? null : routed * candidateBatch;
127
+ /**
128
+ * Route and batch on the same call combine the way `billLevers` has
129
+ * combined them since 1.23: the batch discount applies to the *cheaper*
130
+ * model's price, never as a second subtraction from this one. Adding the
131
+ * two savings is the arithmetic `plan` exists to kill.
132
+ */
133
+ if (request.batchEligible === true && both !== null) {
134
+ alternatives.push({
135
+ kind: 'route+batch',
136
+ model: { id: candidate.id, displayName: candidate.displayName },
137
+ savingUsd: mine - both,
138
+ assumes: [
139
+ { kind: 'model-capability', model: candidate.displayName },
140
+ { kind: 'batch-window' },
141
+ ],
142
+ fits: true,
143
+ });
144
+ }
145
+ alternatives.push({
146
+ kind: 'route',
147
+ model: { id: candidate.id, displayName: candidate.displayName },
148
+ savingUsd: mine - routed,
149
+ assumes: [{ kind: 'model-capability', model: candidate.displayName }],
150
+ fits: true,
151
+ });
152
+ }
153
+
154
+ if (request.batchEligible === true && batchRate !== null) {
155
+ alternatives.push({
156
+ kind: 'batch',
157
+ model: null,
158
+ savingUsd: mine - mine * batchRate,
159
+ assumes: [{ kind: 'batch-window' }],
160
+ fits: true,
161
+ });
162
+ }
163
+ }
164
+
165
+ alternatives.sort((a, b) => b.savingUsd - a.savingUsd);
166
+
167
+ /**
168
+ * The verdict maps the cost answer's three outcomes onto the three an agent
169
+ * can act on. `cannot-tell` stays `cannot-tell` rather than defaulting to
170
+ * yes: a guard that permits whatever it cannot judge is a guard that permits
171
+ * everything the moment its inputs go missing.
172
+ */
173
+ const verdict: GuardVerdict =
174
+ cost.verdict === 'cannot-tell' ? 'cannot-tell' : cost.verdict === 'over' ? 'no' : 'yes';
175
+
176
+ return {
177
+ schemaVersion: 1,
178
+ verdict,
179
+ cost,
180
+ alternatives,
181
+ because: reasonFor(verdict, cost, alternatives),
182
+ };
183
+ }
184
+
185
+ function reasonFor(verdict: GuardVerdict, cost: CostAnswer, alternatives: GuardAlternative[]): string {
186
+ if (verdict === 'cannot-tell') {
187
+ return cost.reason === 'no-budget-configured'
188
+ ? 'No budget is configured, so there is nothing to judge this against.'
189
+ : cost.reason === 'nothing-measured'
190
+ ? 'Nothing has been measured yet, so how much of the budget is gone is unknown.'
191
+ : 'This model is not in the price catalogue, so the call cannot be priced.';
192
+ }
193
+ if (verdict === 'no') {
194
+ const lead = cost.restsOn === 'measured'
195
+ ? 'The budget is already spent, measured.'
196
+ : 'This call would take the budget past its limit, on an estimate of the call.';
197
+ return alternatives.length === 0
198
+ ? `${lead} No cheaper way to make this call exists in the catalogue.`
199
+ : `${lead} The cheapest alternative below saves the most.`;
200
+ }
201
+ return alternatives.length === 0
202
+ ? 'Within budget, and no cheaper way to make this call exists in the catalogue.'
203
+ : 'Within budget — and there is still a cheaper way to make this call.';
204
+ }
package/src/index.ts CHANGED
@@ -49,6 +49,8 @@ export type { PlanAction, PlanActionKind, PlanAssumption, PlanDocument } from '.
49
49
  export { verifyPlan } from './verify.js';
50
50
  export { buildHistory, storedReportFrom, MIN_RUN } from './history.js';
51
51
  export { answerCost } from './answer.js';
52
+ export { guardSpend } from './guard.js';
53
+ export type { GuardAlternative, GuardAnswer, GuardRequest, GuardVerdict } from './guard.js';
52
54
  export type {
53
55
  AnswerRequest,
54
56
  AnswerVerdict,