@namzu/sdk 21.0.0 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +134 -0
- package/dist/advisory/executor.d.ts +9 -4
- package/dist/advisory/executor.d.ts.map +1 -1
- package/dist/advisory/executor.js +16 -9
- package/dist/advisory/executor.js.map +1 -1
- package/dist/constants/limits.d.ts +13 -0
- package/dist/constants/limits.d.ts.map +1 -1
- package/dist/constants/limits.js +14 -2
- package/dist/constants/limits.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +2 -2
- package/dist/manager/run/persistence.d.ts +37 -2
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +48 -7
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts +15 -0
- package/dist/pricing/catalogue.generated.d.ts.map +1 -0
- package/dist/pricing/catalogue.generated.js +293 -0
- package/dist/pricing/catalogue.generated.js.map +1 -0
- package/dist/pricing/index.d.ts +46 -0
- package/dist/pricing/index.d.ts.map +1 -0
- package/dist/pricing/index.js +70 -0
- package/dist/pricing/index.js.map +1 -0
- package/dist/public-runtime.d.ts +6 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +21 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +3 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/run/LimitChecker.d.ts +10 -0
- package/dist/run/LimitChecker.d.ts.map +1 -1
- package/dist/run/LimitChecker.js +14 -2
- package/dist/run/LimitChecker.js.map +1 -1
- package/dist/run/command-gate.d.ts +107 -0
- package/dist/run/command-gate.d.ts.map +1 -0
- package/dist/run/command-gate.js +157 -0
- package/dist/run/command-gate.js.map +1 -0
- package/dist/run/index.d.ts +6 -0
- package/dist/run/index.d.ts.map +1 -1
- package/dist/run/index.js +3 -0
- package/dist/run/index.js.map +1 -1
- package/dist/run/memory-promoter.d.ts +70 -0
- package/dist/run/memory-promoter.d.ts.map +1 -0
- package/dist/run/memory-promoter.js +117 -0
- package/dist/run/memory-promoter.js.map +1 -0
- package/dist/run/workspace-fingerprint.d.ts +105 -0
- package/dist/run/workspace-fingerprint.d.ts.map +1 -0
- package/dist/run/workspace-fingerprint.js +147 -0
- package/dist/run/workspace-fingerprint.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +23 -2
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +24 -3
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +1 -0
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +42 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +15 -2
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +9 -1
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +11 -2
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/store/run/conformance.d.ts.map +1 -1
- package/dist/store/run/conformance.js +8 -2
- package/dist/store/run/conformance.js.map +1 -1
- package/dist/types/common/index.d.ts +38 -2
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/run/stop-reason.d.ts +31 -1
- package/dist/types/run/stop-reason.d.ts.map +1 -1
- package/dist/utils/cost.d.ts +60 -2
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +126 -11
- package/dist/utils/cost.js.map +1 -1
- package/package.json +1 -1
- package/src/advisory/executor.ts +16 -9
- package/src/constants/limits.ts +14 -2
- package/src/manager/agent/lifecycle.ts +2 -2
- package/src/manager/run/persistence.ts +67 -7
- package/src/pricing/catalogue.generated.ts +308 -0
- package/src/pricing/index.ts +78 -0
- package/src/pricing/rates.source.json +206 -0
- package/src/public-runtime.ts +39 -0
- package/src/public-types.ts +3 -1
- package/src/run/LimitChecker.ts +24 -2
- package/src/run/command-gate.ts +234 -0
- package/src/run/index.ts +17 -0
- package/src/run/memory-promoter.ts +155 -0
- package/src/run/workspace-fingerprint.ts +193 -0
- package/src/runtime/query/checkpoint.ts +24 -3
- package/src/runtime/query/guard.ts +1 -0
- package/src/runtime/query/index.ts +42 -0
- package/src/runtime/query/iteration/index.ts +15 -2
- package/src/runtime/query/iteration/phases/advisory.ts +9 -1
- package/src/runtime/query/iteration/phases/compaction.ts +12 -2
- package/src/store/run/conformance.ts +8 -2
- package/src/types/common/index.ts +38 -2
- package/src/types/run/stop-reason.ts +30 -0
- package/src/utils/cost.ts +186 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,139 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 22.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- a4bcbc9: Runs report what they cost, and a cost limit that cannot be measured is refused
|
|
8
|
+
|
|
9
|
+
Every run reported `$0.00`. `calculateCost` existed and `CostInfo` was carried on
|
|
10
|
+
the run, the step, the checkpoint and the `token_usage_updated` event — but a
|
|
11
|
+
turn was only priced when the host passed `pricing` to `query()`, and no shipped
|
|
12
|
+
surface passed one. The accumulation branch was dead everywhere.
|
|
13
|
+
|
|
14
|
+
`runConfig.costLimitUsd` is enforced against that same total, so a host that set
|
|
15
|
+
a cost cap did not have one, and nothing said so.
|
|
16
|
+
|
|
17
|
+
**`@namzu/sdk` now ships a price catalogue** — `packages/sdk/src/pricing/`, a
|
|
18
|
+
module generated from a reviewed in-tree source table and checked in, so a cost
|
|
19
|
+
number is reproducible from a commit and an offline run still prices correctly.
|
|
20
|
+
Rates are looked up per turn against the driver and model that actually served
|
|
21
|
+
it. No configuration is needed to get a real number.
|
|
22
|
+
|
|
23
|
+
## What every caller sees change
|
|
24
|
+
|
|
25
|
+
**A run that reported zero now reports a real number.** If you compare, store,
|
|
26
|
+
bill from, or assert on `Run.costInfo.totalCost`, the value moves on the same
|
|
27
|
+
inputs. Nothing about your code has to change for this — but nothing warns you
|
|
28
|
+
either, so check anywhere a zero was being relied upon.
|
|
29
|
+
|
|
30
|
+
**A `costLimitUsd` that was inert now enforces, or refuses.** This is the change
|
|
31
|
+
most likely to break a working deployment, and it can do so at two moments:
|
|
32
|
+
|
|
33
|
+
- `query()` throws `invalid_config` at the start of a run when `costLimitUsd` is
|
|
34
|
+
set, no `pricing` is supplied, and the configured model has no rate. Same
|
|
35
|
+
config, same model, previously-completing run — now a startup failure.
|
|
36
|
+
- A run stops with the new `cost_unmeasurable` stop reason when a step or a
|
|
37
|
+
provider-chain member swaps to a model with no rate mid-run.
|
|
38
|
+
|
|
39
|
+
To keep a run working, do one of: pass `pricing` to declare the rate yourself;
|
|
40
|
+
add the model to `packages/sdk/src/pricing/rates.source.json` and regenerate;
|
|
41
|
+
or drop `costLimitUsd` and bound the run with `tokenBudget`, which is always
|
|
42
|
+
measurable. Removing the limit is the honest option if the model cannot be
|
|
43
|
+
priced — a budget you cannot measure was never enforcing anything.
|
|
44
|
+
|
|
45
|
+
## Breaking API changes
|
|
46
|
+
|
|
47
|
+
- **`CostInfo.inputCostPer1M` and `CostInfo.outputCostPer1M` are now optional.**
|
|
48
|
+
Absent means no single rate card describes the total — the run spanned two
|
|
49
|
+
models, or part of it ran at no known rate. Readers that treated these as
|
|
50
|
+
`number` need a `?? ` or a branch. They were previously required and reported
|
|
51
|
+
whichever card was applied last, which was a claim about the whole total that
|
|
52
|
+
was true of only part of it.
|
|
53
|
+
- **`CostInfo` gains a required `unpricedTokens: number`.** Any code that
|
|
54
|
+
constructs a `CostInfo` must supply it. Zero means nothing is unaccounted for.
|
|
55
|
+
This is what lets a consumer tell "this run cost nothing" from "nobody knows
|
|
56
|
+
what this run cost" — previously both were `totalCost: 0`.
|
|
57
|
+
- **`calculateCost` and `accumulateCost` lost their trailing `cacheDiscount`
|
|
58
|
+
parameter.** It defaulted to `0`, no caller in the tree ever passed it, and
|
|
59
|
+
the value it produced was subtracted from the total. `cacheDiscount` is now
|
|
60
|
+
computed from the rate card and _reported_ rather than subtracted — it is what
|
|
61
|
+
the cache reads saved against the full input rate, and the saving is already
|
|
62
|
+
inside `totalCost`. Callers passing a fourth argument get a compile error;
|
|
63
|
+
drop it.
|
|
64
|
+
- **`StopReason` gains `cost_unmeasurable`.** Exhaustive switches over
|
|
65
|
+
`StopReason` will not compile until they handle it.
|
|
66
|
+
- **`RunPersistence.accumulateUsage` and `recordTurnUsage` take a second
|
|
67
|
+
required argument** naming who served the tokens. Required so a call site
|
|
68
|
+
cannot silently misattribute; pass `{ providerId, model }`.
|
|
69
|
+
- **`projectEmergencyToCheckpoint` no longer reports zero cost.** A dump
|
|
70
|
+
preserves a real `tokenUsage` and records no cost, so the projection now
|
|
71
|
+
states that those tokens are unpriced rather than that they were free.
|
|
72
|
+
|
|
73
|
+
## Also fixed
|
|
74
|
+
|
|
75
|
+
- The advisory executor reported `totalCost: 0` for an advisor with no pricing
|
|
76
|
+
table — zero-as-unknown, the same defect one file over. It now reports the
|
|
77
|
+
tokens as unpriced, and falls back to the catalogue before giving up.
|
|
78
|
+
- Cache tokens are priced. The drivers in this repository disagree about whether
|
|
79
|
+
the prompt-token count already contains cache reads (two exclude them, one
|
|
80
|
+
includes them), so that fact is declared per driver in the rate source and the
|
|
81
|
+
arithmetic reads it. Previously cache reads were charged at the full input
|
|
82
|
+
rate or not at all, depending on the driver, and `cacheDiscount` was dead.
|
|
83
|
+
|
|
84
|
+
## `@namzu/anthropic`
|
|
85
|
+
|
|
86
|
+
The driver's offline model menu moves to an exported `OFFLINE_MODEL_CATALOGUE`
|
|
87
|
+
so a test can read it without a client. Two of the three models it offers had no
|
|
88
|
+
rate in the catalogue — a lookup-key mismatch that reads as "cost unknown" and
|
|
89
|
+
that the generator's own regeneration check is structurally blind to. Both rates
|
|
90
|
+
are added and a conformance test now holds the two lists together. No behaviour
|
|
91
|
+
change for callers.
|
|
92
|
+
|
|
93
|
+
## 21.1.0
|
|
94
|
+
|
|
95
|
+
### Minor Changes
|
|
96
|
+
|
|
97
|
+
- f59a8b0: `--gate '<command>'` — a run that is not allowed to finish on a red build
|
|
98
|
+
|
|
99
|
+
`reviewAnswer` shipped complete: consulted only when the model stops calling tools, never on the forced-final turn, bounded by a rejection budget, with its own terminal state `answer_rejected` so a stop is not mistaken for a token budget running out. **No shipped app supplied one**, so an operator could not use any of it without writing TypeScript.
|
|
100
|
+
|
|
101
|
+
New in `@namzu/sdk`: `createCommandGate({ commands, cwd, maxRetries?, timeoutMs?, exec?, maxOutputChars?, fingerprint? }): ReviewAnswer`. It runs shell command lines in order, stops at the first failure, and hands the failure back as the next user turn naming the command, the attempt, the exit code and a head-and-tail clip of the output.
|
|
102
|
+
|
|
103
|
+
New in `@namzu/cli`: a repeatable `--gate '<command>'` on `run` and `run-stream`, plus `--gate-retries <n>`. Repeating the flag appends rather than replaces — `--gate 'pnpm typecheck' --gate 'pnpm test'` means both, in that order.
|
|
104
|
+
|
|
105
|
+
**The part that makes it a bounded loop rather than one that burns its budget.** Before re-running a command that already failed, the workspace is fingerprinted; if it is byte-for-byte identical to the snapshot taken when that command last failed, the command is **not run**. The attempt still advances and the model is told the workspace has not changed and must edit something before trying to finish — cheaper than a full test run, and a _different_ instruction from repeating a failure it has already been shown.
|
|
106
|
+
|
|
107
|
+
Also new and exported: `fingerprintWorkspace({ cwd, exec, timeoutMs?, maxBytes?, fs? })`. It hashes `git status --porcelain`, `git diff --binary HEAD` and the contents of every untracked file, **recording a symlink as its target rather than reading through it** — a link repointed to a different file with identical bytes is a change, and following it would hash the two the same.
|
|
108
|
+
|
|
109
|
+
It returns `null` — meaning _no fingerprint_ — for a non-zero git exit, a tree with no commits, a timeout, or output past the size cap, and a caller that cannot fingerprint re-runs its command. That direction is deliberate: a wrong `null` costs one execution, while a wrong match is a verification that silently did not happen.
|
|
110
|
+
|
|
111
|
+
A run with no `--gate` is byte-identical to one from before this existed: the option is spread in only when gates were asked for.
|
|
112
|
+
|
|
113
|
+
- 1be00a7: A run now remembers what it worked out, instead of dropping it at settle
|
|
114
|
+
|
|
115
|
+
`promoteMemory` is invoked once when a run settles, with the compaction extractor's already-structured output — decisions, discoveries, user requirements, failures, environment facts, with eviction counts carried rather than hidden. **No shipped app supplied the hook.** So that structure, which the compaction pass spent tokens producing, was serialized into one system message and dropped on the floor when the run ended; the only way into namzu's memory store was the model deciding to call `save_memory`.
|
|
116
|
+
|
|
117
|
+
New in `@namzu/sdk`: `createMemoryPromoter({ store, tags?, maxPerCategory? }): PromoteMemory`, plus `RUN_MEMORY_TAG`. `@namzu/cli` supplies it over the very store its memory tools already use, so what a run learns is what `search_memory` finds on the next one.
|
|
118
|
+
|
|
119
|
+
## What changes for you without asking
|
|
120
|
+
|
|
121
|
+
**This is on by default, and it applies to the interactive TUI as well as to `namzu run` and `namzu run-stream`.** The promoter is supplied from the session every surface is built on, so an ordinary chat session that works something out now leaves a markdown record under `<cwd>/.namzu/memory` when the run settles — a directory that previously only ever grew when the model chose to call `save_memory`. The next session's `search_memory` will find those records, which is the point, and it is also the part you will notice.
|
|
122
|
+
|
|
123
|
+
It is not opt-in because the alternative it replaces is not neutral: a run's extracted knowledge was being discarded at settle, and a flag would mean the default stays the lossy one. What keeps it from being noisy is the filter below — a session that answered a question without deciding, discovering, failing at or being told anything durable writes nothing at all.
|
|
124
|
+
|
|
125
|
+
An SDK embedder can replace or disable it by passing its own `promoteMemory` to `query` — a function that does nothing writes nothing. **The CLI has no flag for it in this release**, which is worth knowing before you upgrade if a written-to `.namzu/memory` is a problem for your setup; say so and it becomes one.
|
|
126
|
+
|
|
127
|
+
**The filter is the whole decision, and it is strict.** A run that learned nothing leaves **no record at all** — not an empty one, not one whose body says "no decisions". Only the five knowledge categories count: user requirements, decisions, discoveries, failures, environment. Not `task`, which every run has because it is the prompt restated; not `files`, which every run that opened anything has and which says what was _touched_ rather than what was _learned_. The model reads this store on later runs, so a record per run is not merely wasted disk — it is context spent on runs that discovered nothing.
|
|
128
|
+
|
|
129
|
+
Records are markdown, tagged `run-memory`, and carry the forming run's id in their metadata so a surprising memory can be checked against what actually happened. Eviction counts are rendered, because somebody reading the record should know they are reading a truncated account of the run.
|
|
130
|
+
|
|
131
|
+
The promoter deliberately does **not** catch its own failures: the runtime already catches and logs a promoter throw at settle without touching the answer, and catching here as well would hide a broken store from the one place that reports it.
|
|
132
|
+
|
|
133
|
+
It also does not deduplicate, merge with a previous run's record, or expire anything. Each is a policy with real trade-offs, and `promoteMemory` is a callback precisely so the runtime does not decide them — this is the obvious default, not the only possible one. Pass your own `PromoteMemory` to `query` to replace it.
|
|
134
|
+
|
|
135
|
+
Sub-agents do not promote. A parent that delegated six times would otherwise leave seven accounts of one piece of work for the next run to read; the parent's settle speaks for the whole task.
|
|
136
|
+
|
|
3
137
|
## 21.0.0
|
|
4
138
|
|
|
5
139
|
### Major Changes
|
|
@@ -32,11 +32,16 @@ export declare class AdvisoryExecutor {
|
|
|
32
32
|
private buildContext;
|
|
33
33
|
private truncateMessages;
|
|
34
34
|
/**
|
|
35
|
-
* Cost for one call, from the advisor's own pricing.
|
|
35
|
+
* Cost for one call, from the advisor's own pricing, then the catalogue.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* When neither has a rate this reports the tokens as UNPRICED rather than
|
|
38
|
+
* as a cost of zero. The previous version returned a zero rate card and a
|
|
39
|
+
* zero total, defended on the grounds that a cost CAP over unpriced
|
|
40
|
+
* advisors is refused at construction so nothing enforces against it — true
|
|
41
|
+
* of the cap, and beside the point for the reader. `AdvisoryResult.cost` is
|
|
42
|
+
* reported to the host, and `$0.00` for a call that cost real money is the
|
|
43
|
+
* exact defect this change exists to remove; it does not become acceptable
|
|
44
|
+
* because the number happens to be unenforced.
|
|
40
45
|
*/
|
|
41
46
|
private computeCost;
|
|
42
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/advisory/executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/advisory/executor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAE,KAAK,OAAO,EAA0C,MAAM,2BAA2B,CAAA;AAChG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3D,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,oBAAoB,CAAA;AAgB/D,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;IAC5B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,EAAE,CAAA;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC3B;AAED,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;gBAEvC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc;IAKpD;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAOtB,OAAO,CACZ,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,mBAAmB,GAC1B,OAAO,CAAC,uBAAuB,CAAC;IAkDnC,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,YAAY;IA6CpB,OAAO,CAAC,gBAAgB;IAqBxB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,WAAW;CAOnB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { CHARS_PER_TOKEN } from '../constants/limits.js';
|
|
1
|
+
import { CHARS_PER_TOKEN, ZERO_COST } from '../constants/limits.js';
|
|
2
2
|
import { assembleSystemPrompt } from '../persona/assembler.js';
|
|
3
|
+
import { resolveModelPricing } from '../pricing/index.js';
|
|
3
4
|
import { collect } from '../provider/collect.js';
|
|
4
5
|
import { createSystemMessage, createUserMessage } from '../types/message/index.js';
|
|
5
|
-
import { calculateCost } from '../utils/cost.js';
|
|
6
|
+
import { accumulateUnpricedCost, calculateCost } from '../utils/cost.js';
|
|
6
7
|
import { getRootLogger } from '../utils/logger.js';
|
|
7
8
|
import { ADVISORY_RESPONSE_CONTRACT, parseAdvisoryResponse } from './parse.js';
|
|
8
9
|
/**
|
|
@@ -158,17 +159,23 @@ export class AdvisoryExecutor {
|
|
|
158
159
|
return result;
|
|
159
160
|
}
|
|
160
161
|
/**
|
|
161
|
-
* Cost for one call, from the advisor's own pricing.
|
|
162
|
+
* Cost for one call, from the advisor's own pricing, then the catalogue.
|
|
162
163
|
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
164
|
+
* When neither has a rate this reports the tokens as UNPRICED rather than
|
|
165
|
+
* as a cost of zero. The previous version returned a zero rate card and a
|
|
166
|
+
* zero total, defended on the grounds that a cost CAP over unpriced
|
|
167
|
+
* advisors is refused at construction so nothing enforces against it — true
|
|
168
|
+
* of the cap, and beside the point for the reader. `AdvisoryResult.cost` is
|
|
169
|
+
* reported to the host, and `$0.00` for a call that cost real money is the
|
|
170
|
+
* exact defect this change exists to remove; it does not become acceptable
|
|
171
|
+
* because the number happens to be unenforced.
|
|
166
172
|
*/
|
|
167
173
|
computeCost(advisor, usage) {
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
const pricing = advisor.pricing ?? resolveModelPricing(advisor.provider.id, advisor.model);
|
|
175
|
+
if (!pricing) {
|
|
176
|
+
return accumulateUnpricedCost(ZERO_COST, usage);
|
|
170
177
|
}
|
|
171
|
-
return calculateCost(usage,
|
|
178
|
+
return calculateCost(usage, pricing);
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/advisory/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/advisory/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAKhD,OAAO,EAAgB,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAEhG,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAe,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE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QAAQ,CAAA;QAChB,CAAC;QAED,MAAM,UAAU,GAAG,SAAS,GAAG,eAAe,CAAA;QAC9C,IAAI,UAAU,GAAG,CAAC,CAAA;QAClB,MAAM,MAAM,GAAc,EAAE,CAAA;QAE5B,qEAAqE;QACrE,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAY,CAAA;YAClC,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAA;YAC3C,IAAI,UAAU,GAAG,QAAQ,GAAG,UAAU;gBAAE,MAAK;YAC7C,UAAU,IAAI,QAAQ,CAAA;YACtB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACpB,CAAC;QAED,OAAO,MAAM,CAAA;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACK,WAAW,CAAC,OAA0B,EAAE,KAAiB;QAChE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1F,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,sBAAsB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAChD,CAAC;QACD,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC;CACD"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { CostInfo, TokenUsage } from '../types/common/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The starting value for a run: nothing accumulated, nothing unpriced.
|
|
4
|
+
*
|
|
5
|
+
* Carries NO rate fields, and that is load-bearing rather than tidy. It is what
|
|
6
|
+
* lets {@link import('../utils/cost.js').accumulateCost} tell "fresh" from
|
|
7
|
+
* "already spans two rate cards" without a separate marker: a fresh total has
|
|
8
|
+
* no rates AND no unpriced tokens AND a zero total, and no accumulated one can
|
|
9
|
+
* have all three.
|
|
10
|
+
*
|
|
11
|
+
* It also stops reading as a rate card of zero. `inputCostPer1M: 0` on a run
|
|
12
|
+
* nobody has priced says the model is free, which was exactly the confusion
|
|
13
|
+
* `unpricedTokens` was added to end.
|
|
14
|
+
*/
|
|
2
15
|
export declare const ZERO_COST: CostInfo;
|
|
3
16
|
export declare const CHARS_PER_TOKEN = 4;
|
|
4
17
|
export declare const EMPTY_TOKEN_USAGE: TokenUsage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/constants/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAEpE,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/constants/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAEpE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,EAAE,QAIvB,CAAA;AAED,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC,eAAO,MAAM,iBAAiB,EAAE,UAM/B,CAAA"}
|
package/dist/constants/limits.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The starting value for a run: nothing accumulated, nothing unpriced.
|
|
3
|
+
*
|
|
4
|
+
* Carries NO rate fields, and that is load-bearing rather than tidy. It is what
|
|
5
|
+
* lets {@link import('../utils/cost.js').accumulateCost} tell "fresh" from
|
|
6
|
+
* "already spans two rate cards" without a separate marker: a fresh total has
|
|
7
|
+
* no rates AND no unpriced tokens AND a zero total, and no accumulated one can
|
|
8
|
+
* have all three.
|
|
9
|
+
*
|
|
10
|
+
* It also stops reading as a rate card of zero. `inputCostPer1M: 0` on a run
|
|
11
|
+
* nobody has priced says the model is free, which was exactly the confusion
|
|
12
|
+
* `unpricedTokens` was added to end.
|
|
13
|
+
*/
|
|
1
14
|
export const ZERO_COST = {
|
|
2
|
-
inputCostPer1M: 0,
|
|
3
|
-
outputCostPer1M: 0,
|
|
4
15
|
totalCost: 0,
|
|
5
16
|
cacheDiscount: 0,
|
|
17
|
+
unpricedTokens: 0,
|
|
6
18
|
};
|
|
7
19
|
export const CHARS_PER_TOKEN = 4;
|
|
8
20
|
export const EMPTY_TOKEN_USAGE = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/constants/limits.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAa;IAClC,
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/constants/limits.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,SAAS,GAAa;IAClC,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,CAAC;CACjB,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AAEhC,MAAM,CAAC,MAAM,iBAAiB,GAAe;IAC5C,YAAY,EAAE,CAAC;IACf,gBAAgB,EAAE,CAAC;IACnB,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IACf,gBAAgB,EAAE,CAAC;CACnB,CAAA"}
|
|
@@ -20,8 +20,8 @@ import type { ThreadManager } from '../thread/lifecycle.js';
|
|
|
20
20
|
*
|
|
21
21
|
* Phase 9 Known Delta #5: fields are now unconditional required. The legacy
|
|
22
22
|
* "run without deps" compat branch was removed; every `AgentManager` consumer
|
|
23
|
-
* (SDK internals
|
|
24
|
-
* full set before instantiating. Convention #0 (no workarounds): the
|
|
23
|
+
* (SDK internals and `@namzu/cli`; the list here once also named two packages
|
|
24
|
+
* that do not exist) MUST wire the full set before instantiating. Convention #0 (no workarounds): the
|
|
25
25
|
* partially-wired mode was a migration-window bridge; 0.2.0 closes it.
|
|
26
26
|
*
|
|
27
27
|
* `workspaceRegistry` is required but may be empty — spawns without a
|
|
@@ -7,6 +7,18 @@ import type { EmergencySaveData } from '../../types/run/emergency.js';
|
|
|
7
7
|
import type { Run, RunPersistenceConfig, StepResult, StopReason } from '../../types/run/index.js';
|
|
8
8
|
import type { RunStore } from '../../types/run/store.js';
|
|
9
9
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js';
|
|
10
|
+
/**
|
|
11
|
+
* The pair a rate lookup needs: which driver, running which model.
|
|
12
|
+
*
|
|
13
|
+
* `model` may be absent because a driver can be pointed at whatever the host
|
|
14
|
+
* configured and some report nothing back. Absent resolves to no rate, which
|
|
15
|
+
* is the honest answer, EXCEPT for a driver that bills nothing whatever it
|
|
16
|
+
* runs — see `resolveModelPricing`.
|
|
17
|
+
*/
|
|
18
|
+
export interface PricingSubject {
|
|
19
|
+
readonly providerId: string;
|
|
20
|
+
readonly model: string | undefined;
|
|
21
|
+
}
|
|
10
22
|
export declare class RunPersistence {
|
|
11
23
|
private run;
|
|
12
24
|
private runStore;
|
|
@@ -81,7 +93,18 @@ export declare class RunPersistence {
|
|
|
81
93
|
setLastError(error: string): void;
|
|
82
94
|
incrementIteration(): number;
|
|
83
95
|
pushMessage(message: Message): void;
|
|
84
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Who served the tokens being accumulated, so a rate can be found for them.
|
|
98
|
+
*
|
|
99
|
+
* Both fields are required. The previous signature took usage alone and
|
|
100
|
+
* priced it from one table the run was constructed with, which is why the
|
|
101
|
+
* only way to get a non-zero cost was for a host to pass that table — and
|
|
102
|
+
* no shipped surface did. Naming the subject at every call site is what
|
|
103
|
+
* lets the catalogue answer, and it makes a site that cannot say who served
|
|
104
|
+
* a compile error rather than a silent misattribution.
|
|
105
|
+
*/
|
|
106
|
+
private resolvePricing;
|
|
107
|
+
accumulateUsage(usage: TokenUsage, servedBy: PricingSubject): void;
|
|
85
108
|
/**
|
|
86
109
|
* Accumulate usage from a MAIN-LOOP turn, and remember its prompt size.
|
|
87
110
|
*
|
|
@@ -95,7 +118,7 @@ export declare class RunPersistence {
|
|
|
95
118
|
* plain {@link accumulateUsage} instead: their prompts are not the
|
|
96
119
|
* run's context, and letting them write here would corrupt the signal.
|
|
97
120
|
*/
|
|
98
|
-
recordTurnUsage(usage: TokenUsage): void;
|
|
121
|
+
recordTurnUsage(usage: TokenUsage, servedBy: PricingSubject): void;
|
|
99
122
|
/**
|
|
100
123
|
* Forget the last prompt measurement. Called after compaction: the
|
|
101
124
|
* reading described the context that was just replaced, so leaving it
|
|
@@ -174,6 +197,18 @@ export declare class RunPersistence {
|
|
|
174
197
|
* `steps[].servedBy`.
|
|
175
198
|
*/
|
|
176
199
|
setServingProvider(providerId: string): void;
|
|
200
|
+
/**
|
|
201
|
+
* Who is serving right now, for a side-channel call that has no provenance
|
|
202
|
+
* of its own.
|
|
203
|
+
*
|
|
204
|
+
* The main loop does not use this — it reads `servedBy` off the turn, which
|
|
205
|
+
* is exact. Compaction and the closing summary go through the same wrapped
|
|
206
|
+
* provider without recording who answered, and this is the best available
|
|
207
|
+
* answer for them: the fallback decorator reports the head member's id
|
|
208
|
+
* whoever is actually serving, so asking the provider would hand back the
|
|
209
|
+
* declaration rather than the fact.
|
|
210
|
+
*/
|
|
211
|
+
get servingProviderId(): string;
|
|
177
212
|
clearLastPromptTokens(): void;
|
|
178
213
|
/**
|
|
179
214
|
* Provider-reported size of the most recent main-loop prompt, or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/manager/run/persistence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/manager/run/persistence.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,U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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AUTO_CONTINUATION_USER_MESSAGE } from '../../constants/continuation.js';
|
|
2
2
|
import { EMPTY_TOKEN_USAGE } from '../../constants/limits.js';
|
|
3
|
+
import { resolveModelPricing } from '../../pricing/index.js';
|
|
3
4
|
import { DiskCheckpointStore } from '../../store/run/checkpoint-disk.js';
|
|
4
5
|
import { RunDiskStore } from '../../store/run/disk.js';
|
|
5
6
|
import { accumulateTokenUsage } from '../../types/common/index.js';
|
|
6
|
-
import { ZERO_COST, accumulateCost } from '../../utils/cost.js';
|
|
7
|
+
import { ZERO_COST, accumulateCost, accumulateUnpricedCost, } from '../../utils/cost.js';
|
|
7
8
|
import { generateEmergencySaveId } from '../../utils/id.js';
|
|
8
9
|
export class RunPersistence {
|
|
9
10
|
run;
|
|
@@ -219,11 +220,37 @@ export class RunPersistence {
|
|
|
219
220
|
pushMessage(message) {
|
|
220
221
|
this.run.messages.push(message);
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Who served the tokens being accumulated, so a rate can be found for them.
|
|
225
|
+
*
|
|
226
|
+
* Both fields are required. The previous signature took usage alone and
|
|
227
|
+
* priced it from one table the run was constructed with, which is why the
|
|
228
|
+
* only way to get a non-zero cost was for a host to pass that table — and
|
|
229
|
+
* no shipped surface did. Naming the subject at every call site is what
|
|
230
|
+
* lets the catalogue answer, and it makes a site that cannot say who served
|
|
231
|
+
* a compile error rather than a silent misattribution.
|
|
232
|
+
*/
|
|
233
|
+
resolvePricing(servedBy) {
|
|
234
|
+
// A host-supplied table wins. It is a deliberate declaration about this
|
|
235
|
+
// run, and `query()` already refuses to accept one alongside a provider
|
|
236
|
+
// chain of more than one member, so it cannot be silently spread across
|
|
237
|
+
// two rate cards here.
|
|
238
|
+
if (this.pricing)
|
|
239
|
+
return this.pricing;
|
|
240
|
+
return resolveModelPricing(servedBy.providerId, servedBy.model);
|
|
241
|
+
}
|
|
242
|
+
accumulateUsage(usage, servedBy) {
|
|
223
243
|
this.run.tokenUsage = accumulateTokenUsage(this.run.tokenUsage, usage);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
244
|
+
const pricing = this.resolvePricing(servedBy);
|
|
245
|
+
// No rate is not the same as a rate of zero, and the difference is the
|
|
246
|
+
// whole point of this change. Tokens nobody can price are counted as
|
|
247
|
+
// such, so `costInfo.unpricedTokens` distinguishes "this cost nothing"
|
|
248
|
+
// from "nobody knows what this cost" — and so the budget guard can
|
|
249
|
+
// refuse rather than pass a limit it cannot measure.
|
|
250
|
+
this.run.costInfo =
|
|
251
|
+
pricing === undefined
|
|
252
|
+
? accumulateUnpricedCost(this.run.costInfo, usage)
|
|
253
|
+
: accumulateCost(this.run.costInfo, usage, pricing);
|
|
227
254
|
}
|
|
228
255
|
/**
|
|
229
256
|
* Accumulate usage from a MAIN-LOOP turn, and remember its prompt size.
|
|
@@ -238,8 +265,8 @@ export class RunPersistence {
|
|
|
238
265
|
* plain {@link accumulateUsage} instead: their prompts are not the
|
|
239
266
|
* run's context, and letting them write here would corrupt the signal.
|
|
240
267
|
*/
|
|
241
|
-
recordTurnUsage(usage) {
|
|
242
|
-
this.accumulateUsage(usage);
|
|
268
|
+
recordTurnUsage(usage, servedBy) {
|
|
269
|
+
this.accumulateUsage(usage, servedBy);
|
|
243
270
|
this._lastPromptTokens = usage.promptTokens;
|
|
244
271
|
// How much of the history that number covers. The loop pushes the
|
|
245
272
|
// assistant message and its tool results AFTER this call, so without
|
|
@@ -339,6 +366,20 @@ export class RunPersistence {
|
|
|
339
366
|
setServingProvider(providerId) {
|
|
340
367
|
this.run.metadata.servingProvider = providerId;
|
|
341
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Who is serving right now, for a side-channel call that has no provenance
|
|
371
|
+
* of its own.
|
|
372
|
+
*
|
|
373
|
+
* The main loop does not use this — it reads `servedBy` off the turn, which
|
|
374
|
+
* is exact. Compaction and the closing summary go through the same wrapped
|
|
375
|
+
* provider without recording who answered, and this is the best available
|
|
376
|
+
* answer for them: the fallback decorator reports the head member's id
|
|
377
|
+
* whoever is actually serving, so asking the provider would hand back the
|
|
378
|
+
* declaration rather than the fact.
|
|
379
|
+
*/
|
|
380
|
+
get servingProviderId() {
|
|
381
|
+
return this.run.metadata.servingProvider ?? this.run.metadata.provider;
|
|
382
|
+
}
|
|
342
383
|
clearLastPromptTokens() {
|
|
343
384
|
this._lastPromptTokens = undefined;
|
|
344
385
|
this._lastPromptMessageCount = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../src/manager/run/persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAkC,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AASlG,OAAO,
|
|
1
|
+
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../src/manager/run/persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAkC,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AASlG,OAAO,EAEN,SAAS,EACT,cAAc,EACd,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAgB3D,MAA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,GAAG,EAAE;YACnB,aAAa,EAAE,MAAM;YACrB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS;SAC7B,CAAA;IACF,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC1C,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC3C,uEAAuE;QACvE,8CAA8C;QAC9C,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAE1C,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACjD,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE;YACtC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE;YAClB,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;SAC9B,CAAC,CAAA;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModelPricing } from '../utils/cost.js';
|
|
2
|
+
export interface VendorRates {
|
|
3
|
+
/** Matched against `LLMProvider.id`. */
|
|
4
|
+
readonly providerId: string;
|
|
5
|
+
/**
|
|
6
|
+
* This driver bills nothing for a token, whatever the model — local
|
|
7
|
+
* inference. Its runs are priced at zero, which is KNOWN-free and so
|
|
8
|
+
* distinct from a model nobody has a rate for.
|
|
9
|
+
*/
|
|
10
|
+
readonly unmetered: boolean;
|
|
11
|
+
/** Keyed by normalised model id. Empty when `unmetered`. */
|
|
12
|
+
readonly models: ReadonlyMap<string, ModelPricing>;
|
|
13
|
+
}
|
|
14
|
+
export declare const VENDOR_RATES: readonly VendorRates[];
|
|
15
|
+
//# sourceMappingURL=catalogue.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue.generated.d.ts","sourceRoot":"","sources":["../../src/pricing/catalogue.generated.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,MAAM,WAAW,WAAW;IAC3B,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;CAClD;AAED,eAAO,MAAM,YAAY,EAAE,SAAS,WAAW,EA2R9C,CAAA"}
|