@project-ava-supernova/core 0.2.194 → 0.2.195

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.
@@ -0,0 +1,243 @@
1
+ // Usage ledger — every model reply, one line each, in ~/.ava/usage/<YYYY-MM>.jsonl.
2
+ //
3
+ // His call, 21 Nov 2026 (plan 2026-11-21-usage-timeline): the Usage tab gets a
4
+ // timeline — look up what you spent over any period, money AND tokens.
5
+ //
6
+ // Why a ledger and not counters. The old Usage tab kept one running total per
7
+ // month (extension in VS Code's storage, IDE in browser storage). That lost
8
+ // three things a timeline needs:
9
+ // - the DAY: a closed month was one number, so no day or week could be shown;
10
+ // - the PRICE AT THE TIME: cost was recalculated on every page open at
11
+ // today's rates, so last month moved whenever a rate changed;
12
+ // - the OTHER APP: each kept its own, so neither showed your real total.
13
+ // One line per reply, written where every reply already reports its tokens
14
+ // (Agent.run), fixes all three, and every view is summed from the same lines,
15
+ // so no two views can disagree.
16
+ //
17
+ // Recording is OFF until a program switches it on with configureUsageLedger.
18
+ // The extension host, the IDE sidecar, the CLI and the Unreal panel do; the
19
+ // website's server imports core too, and must never write a ~/.ava on Render.
20
+ //
21
+ // Plain files, append-only, one per month — the same pattern as memory and the
22
+ // audit log. A line is ~200 bytes; a heavy month is a few MB.
23
+ import { appendFileSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
24
+ import { join } from 'node:path';
25
+ import { AsyncLocalStorage } from 'node:async_hooks';
26
+ import { AVA_HOME } from '../core/constants.js';
27
+ import { usdRateFor } from '../audit/cost.js';
28
+ let surface = null;
29
+ let dirOverride = null;
30
+ /**
31
+ * Switch recording on for this process. Call once at start-up, in the program
32
+ * that owns the user's machine. `dir` is for tests only.
33
+ */
34
+ export function configureUsageLedger(opts) {
35
+ surface = opts?.surface ?? null;
36
+ dirOverride = opts?.dir ?? null;
37
+ }
38
+ export function usageLedgerEnabled() {
39
+ return surface !== null;
40
+ }
41
+ const scopeStorage = new AsyncLocalStorage();
42
+ /**
43
+ * Run `fn` with its spend filed under this room and mode. An outer scope wins:
44
+ * a nested agent working for a Health turn is Health spend, not 'main'.
45
+ */
46
+ export function withUsageScope(scope, fn) {
47
+ return scopeStorage.getStore() ? fn() : scopeStorage.run(scope, fn);
48
+ }
49
+ /** The room and mode the current call belongs to, if a turn set one. */
50
+ export function currentUsageScope() {
51
+ return scopeStorage.getStore();
52
+ }
53
+ /** Where the ledger lives. */
54
+ export function usageDir() {
55
+ return dirOverride ?? join(AVA_HOME, 'usage');
56
+ }
57
+ function pad(n, w = 2) {
58
+ return String(Math.abs(Math.trunc(n))).padStart(w, '0');
59
+ }
60
+ /** ISO 8601 in local time with its offset: 2026-11-21T23:40:05.120+00:00. */
61
+ export function localIso(d = new Date()) {
62
+ const off = -d.getTimezoneOffset();
63
+ const sign = off >= 0 ? '+' : '-';
64
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
65
+ + `T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`
66
+ + `${sign}${pad(off / 60)}:${pad(off % 60)}`;
67
+ }
68
+ /** The local calendar day of an entry, 'YYYY-MM-DD' — read off its own stamp,
69
+ * so a day stays the day it was spent even if the user later travels. */
70
+ export function entryDay(e) {
71
+ return e.t.slice(0, 10);
72
+ }
73
+ /** Prompt tokens served from cache, under whichever name the provider uses. */
74
+ function cachedFrom(usage) {
75
+ if (!usage)
76
+ return undefined;
77
+ const details = usage.prompt_tokens_details;
78
+ for (const v of [details?.cached_tokens, usage.cached_tokens, usage.prompt_cache_hit_tokens]) {
79
+ if (typeof v === 'number' && Number.isFinite(v))
80
+ return v;
81
+ }
82
+ return undefined;
83
+ }
84
+ /** What a reply cost, in USD, at today's rate card. Falls back to the cost the
85
+ * model definition worked out, when the rate card does not know the model. */
86
+ export function usageCost(model, provider, input, output, fallback) {
87
+ const rate = usdRateFor(model, provider);
88
+ if (rate)
89
+ return (input / 1_000_000) * rate.inputPerMillion + (output / 1_000_000) * rate.outputPerMillion;
90
+ return typeof fallback === 'number' && Number.isFinite(fallback) ? fallback : undefined;
91
+ }
92
+ /**
93
+ * Record one reply. Never throws and never blocks the turn: a ledger that
94
+ * cannot be written is a lost line, not a failed reply.
95
+ */
96
+ export function recordUsage(r) {
97
+ if (!surface)
98
+ return null;
99
+ const input = Number(r.usage.prompt_tokens) || 0;
100
+ const output = Number(r.usage.completion_tokens) || 0;
101
+ if (input <= 0 && output <= 0)
102
+ return null;
103
+ const scope = currentUsageScope();
104
+ const entry = {
105
+ t: localIso(r.at),
106
+ surface,
107
+ // Outside any turn (memory upkeep, a title, a background job) the call
108
+ // is filed as 'background', so it is counted but never passed off as chat.
109
+ room: r.room || scope?.room || 'background',
110
+ mode: r.mode || scope?.mode || 'background',
111
+ provider: r.provider || 'unknown',
112
+ model: r.model || 'unknown',
113
+ in: input,
114
+ out: output,
115
+ };
116
+ const cached = cachedFrom(r.usage);
117
+ if (cached !== undefined)
118
+ entry.cached = cached;
119
+ const usd = usageCost(entry.model, entry.provider, input, output, r.cost);
120
+ if (usd !== undefined)
121
+ entry.usd = Math.round(usd * 1e8) / 1e8;
122
+ try {
123
+ const dir = usageDir();
124
+ mkdirSync(dir, { recursive: true });
125
+ // One write per line with the append flag: two programs (the extension and
126
+ // the IDE) can append to the same month without trampling each other.
127
+ appendFileSync(join(dir, `${entry.t.slice(0, 7)}.jsonl`), JSON.stringify(entry) + '\n', 'utf-8');
128
+ }
129
+ catch { /* a lost line, never a failed reply */ }
130
+ return entry;
131
+ }
132
+ function isEntry(v) {
133
+ const e = v;
134
+ return !!e && typeof e.t === 'string' && typeof e.model === 'string'
135
+ && typeof e.in === 'number' && typeof e.out === 'number';
136
+ }
137
+ /** Every month file present, 'YYYY-MM', oldest first. */
138
+ export function usageMonths() {
139
+ try {
140
+ return readdirSync(usageDir())
141
+ .map((f) => /^(\d{4}-\d{2})\.jsonl$/.exec(f)?.[1])
142
+ .filter((m) => !!m)
143
+ .sort();
144
+ }
145
+ catch {
146
+ return [];
147
+ }
148
+ }
149
+ /**
150
+ * Every entry whose local day is within [from, to], both 'YYYY-MM-DD' and
151
+ * inclusive. Omit either end for an open range. A broken line (a crash
152
+ * mid-write) is skipped, not fatal.
153
+ */
154
+ export function readUsage(from, to) {
155
+ const out = [];
156
+ for (const month of usageMonths()) {
157
+ if (from && month < from.slice(0, 7))
158
+ continue;
159
+ if (to && month > to.slice(0, 7))
160
+ continue;
161
+ let text;
162
+ try {
163
+ text = readFileSync(join(usageDir(), `${month}.jsonl`), 'utf-8');
164
+ }
165
+ catch {
166
+ continue;
167
+ }
168
+ for (const line of text.split('\n')) {
169
+ if (!line.trim())
170
+ continue;
171
+ let e;
172
+ try {
173
+ e = JSON.parse(line);
174
+ }
175
+ catch {
176
+ continue;
177
+ }
178
+ if (!isEntry(e))
179
+ continue;
180
+ const day = entryDay(e);
181
+ if (from && day < from)
182
+ continue;
183
+ if (to && day > to)
184
+ continue;
185
+ out.push(e);
186
+ }
187
+ }
188
+ return out.sort((a, b) => a.t.localeCompare(b.t));
189
+ }
190
+ function empty() {
191
+ return { usd: 0, in: 0, out: 0, replies: 0, unpriced: 0 };
192
+ }
193
+ function add(t, e) {
194
+ t.in += e.in;
195
+ t.out += e.out;
196
+ t.replies += 1;
197
+ if (typeof e.usd === 'number')
198
+ t.usd += e.usd;
199
+ else
200
+ t.unpriced += 1;
201
+ }
202
+ function grouped(entries, keyOf, name) {
203
+ const map = new Map();
204
+ for (const e of entries) {
205
+ const k = keyOf(e);
206
+ let t = map.get(k);
207
+ if (!t) {
208
+ t = empty();
209
+ map.set(k, t);
210
+ }
211
+ add(t, e);
212
+ }
213
+ return [...map.entries()].map(([k, t]) => ({ [name]: k, ...t }));
214
+ }
215
+ /** Sum entries every way the page needs. Biggest spend first, except days. */
216
+ export function summariseUsage(entries) {
217
+ const totals = empty();
218
+ for (const e of entries)
219
+ add(totals, e);
220
+ const bySpend = (a, b) => (b.usd - a.usd) || ((b.in + b.out) - (a.in + a.out));
221
+ const byModel = (() => {
222
+ const map = new Map();
223
+ for (const e of entries) {
224
+ const k = `${e.provider}\u0000${e.model}`;
225
+ let t = map.get(k);
226
+ if (!t) {
227
+ t = { model: e.model, provider: e.provider, ...empty() };
228
+ map.set(k, t);
229
+ }
230
+ add(t, e);
231
+ }
232
+ return [...map.values()].sort(bySpend);
233
+ })();
234
+ return {
235
+ totals,
236
+ byDay: grouped(entries, entryDay, 'day').sort((a, b) => a.day.localeCompare(b.day)),
237
+ byModel,
238
+ byRoom: grouped(entries, (e) => e.room, 'room').sort(bySpend),
239
+ byMode: grouped(entries, (e) => e.mode, 'mode').sort(bySpend),
240
+ bySurface: grouped(entries, (e) => e.surface, 'surface').sort(bySpend),
241
+ };
242
+ }
243
+ //# sourceMappingURL=ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/usage/ledger.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,iCAAiC;AACjC,gFAAgF;AAChF,yEAAyE;AACzE,kEAAkE;AAClE,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,gCAAgC;AAChC,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,EAAE;AACF,+EAA+E;AAC/E,8DAA8D;AAE9D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA6B9C,IAAI,OAAO,GA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AC,CAAC;YAAC,CAAC;YACpF,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,EAAE,CAAC;IACL,OAAO;QACL,MAAM;QACN,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACnF,OAAO;QACP,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QAC7D,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QAC7D,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;KACvE,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@project-ava-supernova/core",
3
- "version": "0.2.194",
3
+ "version": "0.2.195",
4
4
  "description": "Core engine for Ava Supernova — agent, providers, tools, config",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -199,6 +199,11 @@
199
199
  "require": "./dist/health/starters.js",
200
200
  "types": "./dist/health/starters.d.ts"
201
201
  },
202
+ "./usage": {
203
+ "import": "./dist/usage/ledger.js",
204
+ "require": "./dist/usage/ledger.js",
205
+ "types": "./dist/usage/ledger.d.ts"
206
+ },
202
207
  "./projects": {
203
208
  "import": "./dist/projects/project-data.js",
204
209
  "require": "./dist/projects/project-data.js",