@songsid/agend 2.3.0-beta.5 → 2.3.0-beta.7
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/agent-cli-instructions.md +1 -1
- package/dist/agent-cli.js +21 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.js +4 -0
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-file-read.js +68 -8
- package/dist/agent-file-read.js.map +1 -1
- package/dist/agent-whats-new.js +4 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/auth-api.js +3 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/authority-state.d.ts +38 -0
- package/dist/authority/authority-state.js +114 -0
- package/dist/authority/authority-state.js.map +1 -0
- package/dist/authority/session-authorizations.d.ts +43 -0
- package/dist/authority/session-authorizations.js +102 -0
- package/dist/authority/session-authorizations.js.map +1 -0
- package/dist/authority/web-authority.d.ts +31 -11
- package/dist/authority/web-authority.js +39 -12
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/cache-ledger.d.ts +16 -3
- package/dist/cache-ledger.js +33 -13
- package/dist/cache-ledger.js.map +1 -1
- package/dist/cache-service.d.ts +55 -3
- package/dist/cache-service.js +152 -16
- package/dist/cache-service.js.map +1 -1
- package/dist/channel/mcp-tools.js +12 -6
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +2 -2
- package/dist/classic-channel-manager.js +2 -6
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/config-validator.js +10 -4
- package/dist/config-validator.js.map +1 -1
- package/dist/daemon.js +2 -0
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +8 -0
- package/dist/delivery-outbox.js +7 -1
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +109 -2
- package/dist/fleet-manager.js +280 -12
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +2 -1
- package/dist/general-knowledge/skills/multi-channel/SKILL.md +2 -1
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +81 -25
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +55 -8
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
- package/dist/human-delivery-receipts.d.ts +14 -0
- package/dist/human-delivery-receipts.js +42 -6
- package/dist/human-delivery-receipts.js.map +1 -1
- package/dist/instance-names.d.ts +4 -0
- package/dist/instance-names.js +12 -0
- package/dist/instance-names.js.map +1 -0
- package/dist/instructions.d.ts +8 -1
- package/dist/instructions.js +9 -2
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +52 -0
- package/dist/locale.js.map +1 -1
- package/dist/outbound-handlers.d.ts +6 -0
- package/dist/outbound-handlers.js +45 -1
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +57 -1
- package/dist/outbound-schemas.js +33 -1
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +8 -2
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/rollout-index.d.ts +5 -0
- package/dist/rollout-index.js +26 -5
- package/dist/rollout-index.js.map +1 -1
- package/dist/settings-api.d.ts +6 -0
- package/dist/settings-api.js +50 -1
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +27 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.js +8 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/tool-permissions.d.ts +0 -7
- package/dist/tool-permissions.js +73 -5
- package/dist/tool-permissions.js.map +1 -1
- package/dist/topic-commands.d.ts +2 -1
- package/dist/topic-commands.js +2 -4
- package/dist/topic-commands.js.map +1 -1
- package/dist/types.d.ts +13 -2
- package/dist/ui/app-effects.js +43 -25
- package/dist/ui/chat-ambient.js +306 -0
- package/dist/ui/chat-effect-posters.js +6 -7
- package/dist/ui/chat-effects.js +38 -15
- package/dist/ui/chat-strings.js +17 -4
- package/dist/ui/panel-chat.js +15 -7
- package/dist/ui/panel-settings.js +4 -1
- package/dist/ui/settings-appearance.js +8 -0
- package/dist/ui/settings-mods.js +19 -6
- package/dist/ui/settings-owner-effects.js +3 -3
- package/dist/ui/settings-strings.js +28 -0
- package/dist/ui/settings-web-authority.js +91 -0
- package/dist/ui/shared/app-session.js +2 -0
- package/dist/ui/shared/app-shell.js +2 -1
- package/dist/ui/shared/app-themes.js +24 -6
- package/dist/ui/shared/app.css +42 -8
- package/dist/ui/shared/effect-app-runtime.js +67 -18
- package/dist/ui/shared/effect-chat-runtime.js +16 -3
- package/dist/ui/shared/effect-frame.js +17 -3
- package/dist/ui/shared/effect-policy.js +18 -4
- package/dist/ui/shared/effect-registry.js +11 -18
- package/dist/ui/shared/effect-stock-trust.js +2 -2
- package/dist/ui/shared/effect-trial-stage.js +18 -7
- package/dist/ui/shared/fx-motion.js +58 -0
- package/dist/ui/shared/web-authorize.js +151 -0
- package/dist/usage-report.d.ts +147 -0
- package/dist/usage-report.js +195 -0
- package/dist/usage-report.js.map +1 -0
- package/dist/usage-rollup.d.ts +51 -0
- package/dist/usage-rollup.js +168 -0
- package/dist/usage-rollup.js.map +1 -0
- package/dist/web-ambient.d.ts +72 -0
- package/dist/web-ambient.js +154 -0
- package/dist/web-ambient.js.map +1 -0
- package/dist/web-api.d.ts +32 -0
- package/dist/web-api.js +143 -18
- package/dist/web-api.js.map +1 -1
- package/dist/web-appearance-tools.d.ts +3 -0
- package/dist/web-appearance-tools.js +18 -3
- package/dist/web-appearance-tools.js.map +1 -1
- package/dist/web-appearance-view.d.ts +14 -2
- package/dist/web-appearance-view.js +32 -5
- package/dist/web-appearance-view.js.map +1 -1
- package/dist/web-appearance.d.ts +15 -1
- package/dist/web-appearance.js +77 -1
- package/dist/web-appearance.js.map +1 -1
- package/dist/web-asset-parts.d.ts +2 -2
- package/dist/web-asset-parts.js +3 -3
- package/dist/web-asset-parts.js.map +1 -1
- package/dist/web-auth.js +3 -1
- package/dist/web-auth.js.map +1 -1
- package/dist/web-effect-bootstrap.d.ts +12 -0
- package/dist/web-effect-bootstrap.js +49 -0
- package/dist/web-effect-bootstrap.js.map +1 -0
- package/dist/web-effect-bundle.js +46 -1
- package/dist/web-effect-bundle.js.map +1 -1
- package/dist/web-effect-playback.d.ts +30 -0
- package/dist/web-effect-playback.js +71 -0
- package/dist/web-effect-playback.js.map +1 -0
- package/dist/web-effect-profiles.d.ts +4 -4
- package/dist/web-effect-service.d.ts +11 -4
- package/dist/web-effect-service.js +25 -4
- package/dist/web-effect-service.js.map +1 -1
- package/dist/web-effect-tools.d.ts +1 -0
- package/dist/web-effect-tools.js +2 -1
- package/dist/web-effect-tools.js.map +1 -1
- package/dist/web-effect-worker.d.ts +1 -1
- package/dist/web-effect-worker.js +2 -2
- package/dist/web-effect-worker.js.map +1 -1
- package/dist/web-guest-access.js +3 -1
- package/dist/web-guest-access.js.map +1 -1
- package/dist/web-mod-agent.js +5 -1
- package/dist/web-mod-agent.js.map +1 -1
- package/dist/web-mod-bundle.d.ts +9 -1
- package/dist/web-mod-bundle.js +62 -3
- package/dist/web-mod-bundle.js.map +1 -1
- package/dist/web-mod-export.d.ts +9 -0
- package/dist/web-mod-export.js +21 -0
- package/dist/web-mod-export.js.map +1 -1
- package/dist/web-mod-store.d.ts +2 -1
- package/dist/web-mod-store.js +13 -6
- package/dist/web-mod-store.js.map +1 -1
- package/dist/web-session-authorization.d.ts +132 -0
- package/dist/web-session-authorization.js +193 -0
- package/dist/web-session-authorization.js.map +1 -0
- package/dist/web-session.d.ts +5 -0
- package/dist/web-session.js +16 -0
- package/dist/web-session.js.map +1 -1
- package/dist/web-settings-patch.d.ts +24 -2
- package/dist/web-settings-patch.js +47 -1
- package/dist/web-settings-patch.js.map +1 -1
- package/dist/web-settings-tools.d.ts +8 -0
- package/dist/web-settings-tools.js +14 -1
- package/dist/web-settings-tools.js.map +1 -1
- package/dist/web-theme-store.d.ts +39 -0
- package/dist/web-theme-store.js +122 -11
- package/dist/web-theme-store.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { PRICES_CHECKED, ratesFor } from "./cache-prices.js";
|
|
2
|
+
import { hourSources, localDate } from "./usage-rollup.js";
|
|
3
|
+
export const USAGE_GROUPS = ["instance", "backend", "model", "profile", "team"];
|
|
4
|
+
export const USAGE_RANGES = ["today", "7d", "month", "all"];
|
|
5
|
+
/** What every amount is, in words — the page, the CSV and the agent tool all carry it. */
|
|
6
|
+
export const usageBasis = (checked = PRICES_CHECKED) => `API-equivalent at list price (checked ${checked}) — not money spent`;
|
|
7
|
+
/** Daily rows returned at most (the CSV and the trend); beyond it the report says it is truncated. */
|
|
8
|
+
export const USAGE_DAILY_MAX = 20_000;
|
|
9
|
+
const M = 1_000_000;
|
|
10
|
+
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
11
|
+
/** A range as asked (query string or tool argument); anything else is the last 7 days. */
|
|
12
|
+
export function usageRange(kind, from, to) {
|
|
13
|
+
if (kind === "custom" && typeof from === "string" && typeof to === "string" && DATE.test(from) && DATE.test(to) && from <= to)
|
|
14
|
+
return { kind: "custom", from, to };
|
|
15
|
+
return USAGE_RANGES.includes(kind) ? { kind: kind } : { kind: "7d" };
|
|
16
|
+
}
|
|
17
|
+
export const usageGroup = (g) => USAGE_GROUPS.includes(g) ? g : "instance";
|
|
18
|
+
/** A local date (YYYY-MM-DD) moved by `n` calendar days — a date's arithmetic, never 24-hour steps (a DST day is 23 or 25). */
|
|
19
|
+
export const shiftDate = (date, n) => new Date(Date.UTC(Number(date.slice(0, 4)), Number(date.slice(5, 7)) - 1, Number(date.slice(8, 10)) + n)).toISOString().slice(0, 10);
|
|
20
|
+
/** The range's first and last local dates (inclusive) in `zone`: "7d" is today and the 6 calendar days before it. */
|
|
21
|
+
export function rangeDates(range, now, zone) {
|
|
22
|
+
const today = localDate(now, zone);
|
|
23
|
+
switch (range.kind) {
|
|
24
|
+
case "today": return { from: today, to: today };
|
|
25
|
+
case "7d": return { from: shiftDate(today, -6), to: today };
|
|
26
|
+
case "month": return { from: `${today.slice(0, 8)}01`, to: today };
|
|
27
|
+
case "all": return { from: "0000-01-01", to: today };
|
|
28
|
+
case "custom": return { from: range.from, to: range.to };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const zero = () => ({ input: 0, output: 0, cacheRead: 0, cacheWrite5m: 0, cacheWrite1h: 0, cacheWrite: 0, requests: 0 });
|
|
32
|
+
const addTotals = (into, [n, uncached, read, w5, w1h, w, out]) => {
|
|
33
|
+
into.requests += n;
|
|
34
|
+
into.input += uncached;
|
|
35
|
+
into.cacheRead += read;
|
|
36
|
+
into.cacheWrite5m += w5;
|
|
37
|
+
into.cacheWrite1h += w1h;
|
|
38
|
+
into.cacheWrite += w;
|
|
39
|
+
into.output += out;
|
|
40
|
+
};
|
|
41
|
+
const splitKey = (mk) => { const bar = mk.lastIndexOf("|"); return { model: mk.slice(0, bar), long: mk.slice(bar + 1) === "1" }; };
|
|
42
|
+
/**
|
|
43
|
+
* The list-price amount of one slice, or null when its model is not in the table. Codex writes not reported are 0 in the
|
|
44
|
+
* ledger (it marks writesSeen on the first one above 0), so they add nothing and are never priced as uncached input.
|
|
45
|
+
*/
|
|
46
|
+
function amountOf(model, long, [, uncached, read, w5, w1h, w, out]) {
|
|
47
|
+
const r = ratesFor(model, long ? Number.MAX_SAFE_INTEGER : 0);
|
|
48
|
+
if (!r)
|
|
49
|
+
return null;
|
|
50
|
+
return (uncached * r.input + read * r.read + w5 * r.write5m + w1h * r.write1h + w * r.write + out * r.output) / M;
|
|
51
|
+
}
|
|
52
|
+
const unknownSource = (s) => s.backend === "unknown" || s.profile === "unknown";
|
|
53
|
+
export function buildUsageReport(input) {
|
|
54
|
+
const { from, to } = rangeDates(input.range, input.now, input.zone);
|
|
55
|
+
const inRange = (date) => date >= from && date <= to;
|
|
56
|
+
const slices = [];
|
|
57
|
+
const notMeasured = [];
|
|
58
|
+
const shared = [];
|
|
59
|
+
const coverage = [];
|
|
60
|
+
for (const i of input.instances) {
|
|
61
|
+
// Its status is about collecting now; what it measured before — under another backend, or before it shared a
|
|
62
|
+
// working directory — is still its history and is reported below.
|
|
63
|
+
if (i.status === "shared")
|
|
64
|
+
shared.push({ name: i.name, backend: i.backend, with: i.with ?? [] });
|
|
65
|
+
else if (i.status !== "ok")
|
|
66
|
+
notMeasured.push({ name: i.name, backend: i.backend, reason: i.status === "credit_billed" ? "credit_billed" : i.status === "no_data" ? "no_data" : "unsupported" });
|
|
67
|
+
if (!i.ledger || !i.days)
|
|
68
|
+
continue;
|
|
69
|
+
coverage.push({ name: i.name, intervals: i.days.coverage.map(([a, b]) => [a, b]) });
|
|
70
|
+
// Codex: a write is reported only once a real one has been seen (every CLI so far records 0).
|
|
71
|
+
const writesSeen = i.ledger.writesSeen === true;
|
|
72
|
+
const base = { instance: i.name, team: i.team };
|
|
73
|
+
for (const row of i.days.rows) {
|
|
74
|
+
if (!inRange(row.date))
|
|
75
|
+
continue;
|
|
76
|
+
for (const [mk, tot] of Object.entries(row.m))
|
|
77
|
+
slices.push({ ...base, backend: row.be, writesReported: row.be !== "codex" || writesSeen, date: row.date, zone: row.zone, profile: row.pf, ...splitKey(mk), tot });
|
|
78
|
+
}
|
|
79
|
+
for (const [hk, hour] of Object.entries(i.ledger.hours)) {
|
|
80
|
+
const h = Number(hk);
|
|
81
|
+
if (h <= i.days.checkpoint)
|
|
82
|
+
continue; // already in the rollup: counted once (§5.2)
|
|
83
|
+
const date = localDate(h, input.zone);
|
|
84
|
+
if (!inRange(date))
|
|
85
|
+
continue;
|
|
86
|
+
for (const src of hourSources(hour)) {
|
|
87
|
+
for (const [mk, tot] of Object.entries(src.m))
|
|
88
|
+
slices.push({ ...base, backend: src.backend, writesReported: src.backend !== "codex" || writesSeen, date, zone: input.zone, profile: src.profile, ...splitKey(mk), tot });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const keyOf = (s) => {
|
|
93
|
+
switch (input.group) {
|
|
94
|
+
case "instance": return s.instance;
|
|
95
|
+
case "backend": return s.backend;
|
|
96
|
+
case "model": return s.model;
|
|
97
|
+
case "profile": return s.profile;
|
|
98
|
+
case "team": return s.team ?? "";
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const rows = new Map();
|
|
102
|
+
const newRow = (key) => ({ key, ...zero(), total: 0, messages: null, amount: null, priced: "none", flags: [], unpriced: [], instances: [], backends: [], models: [], profiles: [], _amount: 0, _pricedAny: false, _unpricedAny: false });
|
|
103
|
+
const uniq = (list, v) => { if (!list.includes(v))
|
|
104
|
+
list.push(v); };
|
|
105
|
+
const daily = [];
|
|
106
|
+
for (const s of slices) {
|
|
107
|
+
const key = keyOf(s);
|
|
108
|
+
const row = rows.get(key) ?? (rows.set(key, newRow(key)), rows.get(key));
|
|
109
|
+
addTotals(row, s.tot);
|
|
110
|
+
uniq(row.instances, s.instance);
|
|
111
|
+
uniq(row.backends, s.backend);
|
|
112
|
+
uniq(row.models, s.model);
|
|
113
|
+
uniq(row.profiles, s.profile);
|
|
114
|
+
const amount = amountOf(s.model, s.long, s.tot);
|
|
115
|
+
if (amount === null) {
|
|
116
|
+
row._unpricedAny = true;
|
|
117
|
+
uniq(row.unpriced, s.model);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
row._pricedAny = true;
|
|
121
|
+
row._amount += amount;
|
|
122
|
+
}
|
|
123
|
+
if (!s.writesReported)
|
|
124
|
+
uniq(row.flags, "cache_write_not_reported");
|
|
125
|
+
if (unknownSource(s))
|
|
126
|
+
uniq(row.flags, "source_unknown");
|
|
127
|
+
if (daily.length <= USAGE_DAILY_MAX) {
|
|
128
|
+
const t = zero();
|
|
129
|
+
addTotals(t, s.tot);
|
|
130
|
+
daily.push({ date: s.date, zone: s.zone, instance: s.instance, backend: s.backend, model: s.model, tier: s.long ? "long" : "standard", profile: s.profile, ...t, amount, flags: [...(s.writesReported ? [] : ["cache_write_not_reported"]), ...(amount === null ? ["not_priced"] : []), ...(unknownSource(s) ? ["source_unknown"] : [])] });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Messages: delivered, per instance and hour (§5.4); placed on days the same way as tokens.
|
|
134
|
+
const messagesDaily = new Map();
|
|
135
|
+
const perInstance = new Map();
|
|
136
|
+
for (const m of input.messages) {
|
|
137
|
+
const date = localDate(m.hour, input.zone);
|
|
138
|
+
if (!inRange(date))
|
|
139
|
+
continue;
|
|
140
|
+
perInstance.set(m.instance, (perInstance.get(m.instance) ?? 0) + m.count);
|
|
141
|
+
const k = `${date}\u0000${m.instance}`;
|
|
142
|
+
const e = messagesDaily.get(k) ?? (messagesDaily.set(k, { date, instance: m.instance, count: 0 }), messagesDaily.get(k));
|
|
143
|
+
e.count += m.count;
|
|
144
|
+
}
|
|
145
|
+
const instTeam = new Map(input.instances.map(i => [i.name, i]));
|
|
146
|
+
if (input.group === "instance" || input.group === "backend" || input.group === "team") {
|
|
147
|
+
// An instance with messages but no measured tokens still gets a row (its tokens are not measured; it says so). A
|
|
148
|
+
// message is counted per instance only, so by backend it goes under the instance's backend now.
|
|
149
|
+
for (const [name, count] of perInstance) {
|
|
150
|
+
const i = instTeam.get(name);
|
|
151
|
+
const key = input.group === "instance" ? name : input.group === "backend" ? (i?.backend ?? "") : (i?.team ?? "");
|
|
152
|
+
const row = rows.get(key) ?? (rows.set(key, newRow(key)), rows.get(key));
|
|
153
|
+
row.messages = (row.messages ?? 0) + count;
|
|
154
|
+
uniq(row.instances, name);
|
|
155
|
+
if (i)
|
|
156
|
+
uniq(row.backends, i.backend);
|
|
157
|
+
}
|
|
158
|
+
for (const row of rows.values())
|
|
159
|
+
row.messages ??= 0;
|
|
160
|
+
}
|
|
161
|
+
const finish = (row) => {
|
|
162
|
+
const { _amount, _pricedAny, _unpricedAny, ...rest } = row;
|
|
163
|
+
rest.total = rest.input + rest.output + rest.cacheRead + rest.cacheWrite5m + rest.cacheWrite1h + rest.cacheWrite;
|
|
164
|
+
rest.amount = _pricedAny ? _amount : null;
|
|
165
|
+
rest.priced = _pricedAny ? (_unpricedAny ? "partial" : "all") : "none";
|
|
166
|
+
if (_unpricedAny)
|
|
167
|
+
uniq(rest.flags, "not_priced");
|
|
168
|
+
return rest;
|
|
169
|
+
};
|
|
170
|
+
const out = [...rows.values()].map(finish)
|
|
171
|
+
.sort((a, b) => (b.amount ?? -1) - (a.amount ?? -1) || b.total - a.total || a.key.localeCompare(b.key));
|
|
172
|
+
const totals = finish(newRow("all"));
|
|
173
|
+
for (const r of out) {
|
|
174
|
+
for (const k of ["input", "output", "cacheRead", "cacheWrite5m", "cacheWrite1h", "cacheWrite", "requests"])
|
|
175
|
+
totals[k] += r[k];
|
|
176
|
+
totals.total += r.total;
|
|
177
|
+
if (r.messages !== null)
|
|
178
|
+
totals.messages = (totals.messages ?? 0) + r.messages;
|
|
179
|
+
if (r.amount !== null)
|
|
180
|
+
totals.amount = (totals.amount ?? 0) + r.amount;
|
|
181
|
+
for (const f of r.flags)
|
|
182
|
+
uniq(totals.flags, f);
|
|
183
|
+
for (const m of r.unpriced)
|
|
184
|
+
uniq(totals.unpriced, m);
|
|
185
|
+
}
|
|
186
|
+
totals.priced = out.some(r => r.priced !== "none") ? (out.some(r => r.priced !== "all" && r.total > 0) ? "partial" : "all") : "none";
|
|
187
|
+
return {
|
|
188
|
+
range: { kind: input.range.kind, from, to }, zone: input.zone, granularity: "hour", basis: usageBasis(), pricesChecked: PRICES_CHECKED,
|
|
189
|
+
group: input.group, rows: out, totals,
|
|
190
|
+
daily: daily.slice(0, USAGE_DAILY_MAX), dailyTruncated: daily.length > USAGE_DAILY_MAX,
|
|
191
|
+
messagesDaily: [...messagesDaily.values()].sort((a, b) => a.date.localeCompare(b.date) || a.instance.localeCompare(b.instance)),
|
|
192
|
+
notMeasured, shared, coverage, scanning: input.scanning,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=usage-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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ept per instance; beyond it the two oldest merge (an over-wide interval only hides a gap). */
|
|
4
|
+
export declare const COVERAGE_MAX = 64;
|
|
5
|
+
/** One day row: its local date, the zone it was folded in, its source (backend, profile) → model|tier → totals. */
|
|
6
|
+
export interface DayRow {
|
|
7
|
+
date: string;
|
|
8
|
+
zone: string;
|
|
9
|
+
be: string;
|
|
10
|
+
pf: string;
|
|
11
|
+
m: Record<string, HourTotals>;
|
|
12
|
+
}
|
|
13
|
+
/** Where an hour's totals were read: the backend whose reader read them ("unknown" before #2122), and the profile. */
|
|
14
|
+
export interface HourSource {
|
|
15
|
+
backend: string;
|
|
16
|
+
profile: string;
|
|
17
|
+
m: Record<string, HourTotals>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An hour's totals by source (cache-ledger.ts `src`), each exact. What `m` holds beyond them was counted before #2122:
|
|
21
|
+
* one more source, backend and profile "unknown".
|
|
22
|
+
*/
|
|
23
|
+
export declare function hourSources(hour: HourAgg): HourSource[];
|
|
24
|
+
export interface UsageDays {
|
|
25
|
+
v: 1;
|
|
26
|
+
/** The last UTC hour (ms) held here; -1: none yet. */
|
|
27
|
+
checkpoint: number;
|
|
28
|
+
rows: DayRow[];
|
|
29
|
+
/** Merged UTC intervals [from, to] the scanner has read (§5.5). */
|
|
30
|
+
coverage: Array<[number, number]>;
|
|
31
|
+
}
|
|
32
|
+
export declare const emptyDays: () => UsageDays;
|
|
33
|
+
/** A rollup read back from disk; anything that is not one is empty. */
|
|
34
|
+
export declare function reviveDays(raw: unknown): UsageDays;
|
|
35
|
+
/** The local date (YYYY-MM-DD) an instant falls on in `zone` (an IANA name; an unknown one is UTC). */
|
|
36
|
+
export declare function localDate(t: number, zone: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Fold the ledger's hours that are about to leave it (older than `cutoff`) and after the checkpoint into their days.
|
|
39
|
+
* Mutates `days`; returns whether anything moved. Never folds an hour at or before the checkpoint (it is already here),
|
|
40
|
+
* so a fold repeated after a crash adds nothing twice.
|
|
41
|
+
*/
|
|
42
|
+
export declare function foldHours(days: UsageDays, ledger: Ledger, cutoff: number, zone: string): boolean;
|
|
43
|
+
/** Drop day rows older than the rollup keeps (by date, against `now` in `zone`). */
|
|
44
|
+
export declare function pruneDays(days: UsageDays, now: number, zone: string): boolean;
|
|
45
|
+
/** Record that the scanner has read [from, to]: merged into the intervals, at most COVERAGE_MAX of them. */
|
|
46
|
+
export declare function addCoverage(days: UsageDays, from: number, to: number): void;
|
|
47
|
+
/** Whether the scanner has read the hour starting at `h`. */
|
|
48
|
+
export declare const covered: (days: UsageDays, h: number) => boolean;
|
|
49
|
+
export declare function readDays(path: string): Promise<UsageDays>;
|
|
50
|
+
/** Written whole and renamed into place (0600): a crash leaves the old file or the new one, never a mix. */
|
|
51
|
+
export declare function writeDays(path: string, days: UsageDays): Promise<boolean>;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #2122 §5: the daily usage rollup — what the cache ledger (cache-ledger.ts, hourly, 31 days) no longer keeps, folded
|
|
3
|
+
* into days so the usage report can go back up to 400 days. One file per instance, `usage-days.json`, beside the ledger.
|
|
4
|
+
*
|
|
5
|
+
* - Two tiers, one checkpoint: an hour is in the rollup if and only if it is at or before `checkpoint` (a UTC hour);
|
|
6
|
+
* otherwise it is only in the ledger. A view is the rollup up to the checkpoint plus the ledger after it.
|
|
7
|
+
* - Fold, then prune: the hours about to leave the ledger and after the checkpoint are added to their days, the rollup
|
|
8
|
+
* is written (atomic rename) with the new checkpoint, and only then may the ledger drop hours at or before it
|
|
9
|
+
* (pruneLedger's `foldedThrough`). A crash between the two leaves those hours in both; the next fold skips them (they
|
|
10
|
+
* are at or before the checkpoint) and the prune finishes. A crash before the write moves nothing.
|
|
11
|
+
* - Days at hour granularity: an hour belongs to the local date its start falls on in the fleet's zone (in a zone with
|
|
12
|
+
* a half-hour offset a day's edge falls on the hour that holds local midnight — said so on the page). Each day row
|
|
13
|
+
* records its zone; changing the zone re-buckets only the ledger's hours.
|
|
14
|
+
* - Provenance: each row is one source — the backend whose reader read it and the credential profile it was read under
|
|
15
|
+
* (hourSources) — kept apart, so an instance that changes backend or profile never relabels what it read before.
|
|
16
|
+
* Hours counted before #2122 have no source: they are "unknown", never today's backend.
|
|
17
|
+
* - Coverage: what the scanner has read, as merged UTC intervals — never inferred from missing hours (an idle hour has
|
|
18
|
+
* no bucket and is a real zero).
|
|
19
|
+
* Messages are not here: they are counted in the delivery database (human-delivery-receipts.ts).
|
|
20
|
+
*/
|
|
21
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
22
|
+
import { dirname } from "node:path";
|
|
23
|
+
export const ROLLUP_KEEP_DAYS = 400;
|
|
24
|
+
const HOUR = 3_600_000;
|
|
25
|
+
const DAY = 86_400_000;
|
|
26
|
+
/** Coverage intervals kept per instance; beyond it the two oldest merge (an over-wide interval only hides a gap). */
|
|
27
|
+
export const COVERAGE_MAX = 64;
|
|
28
|
+
const READER_BACKEND = { claude: "claude-code", codex: "codex" };
|
|
29
|
+
/**
|
|
30
|
+
* An hour's totals by source (cache-ledger.ts `src`), each exact. What `m` holds beyond them was counted before #2122:
|
|
31
|
+
* one more source, backend and profile "unknown".
|
|
32
|
+
*/
|
|
33
|
+
export function hourSources(hour) {
|
|
34
|
+
const out = [];
|
|
35
|
+
const known = dict();
|
|
36
|
+
for (const [sk, m] of Object.entries(hour.src ?? {})) {
|
|
37
|
+
const colon = sk.indexOf(":");
|
|
38
|
+
out.push({ backend: READER_BACKEND[sk.slice(0, colon)] ?? "unknown", profile: sk.slice(colon + 1), m });
|
|
39
|
+
for (const [mk, t] of Object.entries(m))
|
|
40
|
+
add(known[mk] ??= [0, 0, 0, 0, 0, 0, 0], t);
|
|
41
|
+
}
|
|
42
|
+
const legacy = dict();
|
|
43
|
+
for (const [mk, t] of Object.entries(hour.m)) {
|
|
44
|
+
const k = known[mk], rest = t.map((n, i) => n - (k?.[i] ?? 0));
|
|
45
|
+
if (rest.some(n => n > 0))
|
|
46
|
+
legacy[mk] = rest.map(n => Math.max(0, n));
|
|
47
|
+
}
|
|
48
|
+
if (Object.keys(legacy).length)
|
|
49
|
+
out.push({ backend: "unknown", profile: "unknown", m: legacy });
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
const dict = () => Object.create(null);
|
|
53
|
+
const add = (into, from) => { for (let i = 0; i < 7; i++)
|
|
54
|
+
into[i] = (into[i] ?? 0) + (from[i] ?? 0); };
|
|
55
|
+
export const emptyDays = () => ({ v: 1, checkpoint: -1, rows: [], coverage: [] });
|
|
56
|
+
/** A rollup read back from disk; anything that is not one is empty. */
|
|
57
|
+
export function reviveDays(raw) {
|
|
58
|
+
const d = emptyDays();
|
|
59
|
+
if (!raw || typeof raw !== "object" || raw.v !== 1)
|
|
60
|
+
return d;
|
|
61
|
+
const r = raw;
|
|
62
|
+
if (Number.isSafeInteger(r.checkpoint))
|
|
63
|
+
d.checkpoint = r.checkpoint;
|
|
64
|
+
if (Array.isArray(r.rows))
|
|
65
|
+
for (const row of r.rows) {
|
|
66
|
+
if (!row || typeof row.date !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(row.date) || typeof row.zone !== "string" || typeof row.be !== "string" || typeof row.pf !== "string")
|
|
67
|
+
continue;
|
|
68
|
+
const m = dict();
|
|
69
|
+
for (const [k, t] of Object.entries(row.m ?? {}))
|
|
70
|
+
if (Array.isArray(t) && t.length === 7 && t.every(n => Number.isFinite(n)))
|
|
71
|
+
m[k] = t;
|
|
72
|
+
d.rows.push({ date: row.date, zone: row.zone, be: row.be, pf: row.pf, m });
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(r.coverage))
|
|
75
|
+
for (const c of r.coverage)
|
|
76
|
+
if (Array.isArray(c) && c.length === 2 && Number.isFinite(c[0]) && Number.isFinite(c[1]) && c[0] <= c[1])
|
|
77
|
+
d.coverage.push([c[0], c[1]]);
|
|
78
|
+
return d;
|
|
79
|
+
}
|
|
80
|
+
/** The local date (YYYY-MM-DD) an instant falls on in `zone` (an IANA name; an unknown one is UTC). */
|
|
81
|
+
export function localDate(t, zone) {
|
|
82
|
+
try {
|
|
83
|
+
return new Intl.DateTimeFormat("en-CA", { timeZone: zone, year: "numeric", month: "2-digit", day: "2-digit" }).format(new Date(t));
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return new Date(t).toISOString().slice(0, 10);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Fold the ledger's hours that are about to leave it (older than `cutoff`) and after the checkpoint into their days.
|
|
91
|
+
* Mutates `days`; returns whether anything moved. Never folds an hour at or before the checkpoint (it is already here),
|
|
92
|
+
* so a fold repeated after a crash adds nothing twice.
|
|
93
|
+
*/
|
|
94
|
+
export function foldHours(days, ledger, cutoff, zone) {
|
|
95
|
+
const hours = Object.keys(ledger.hours).map(Number).filter(h => h + HOUR <= cutoff && h > days.checkpoint).sort((a, b) => a - b);
|
|
96
|
+
if (!hours.length)
|
|
97
|
+
return false;
|
|
98
|
+
const index = new Map(days.rows.map((r, i) => [`${r.date}\u0000${r.zone}\u0000${r.be}\u0000${r.pf}`, i]));
|
|
99
|
+
for (const h of hours) {
|
|
100
|
+
const date = localDate(h, zone);
|
|
101
|
+
for (const src of hourSources(ledger.hours[String(h)])) {
|
|
102
|
+
const key = `${date}\u0000${zone}\u0000${src.backend}\u0000${src.profile}`;
|
|
103
|
+
let i = index.get(key);
|
|
104
|
+
if (i === undefined) {
|
|
105
|
+
i = days.rows.push({ date, zone, be: src.backend, pf: src.profile, m: dict() }) - 1;
|
|
106
|
+
index.set(key, i);
|
|
107
|
+
}
|
|
108
|
+
const row = days.rows[i];
|
|
109
|
+
for (const [mk, tot] of Object.entries(src.m))
|
|
110
|
+
add(row.m[mk] ??= [0, 0, 0, 0, 0, 0, 0], tot);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
days.checkpoint = hours[hours.length - 1];
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
/** Drop day rows older than the rollup keeps (by date, against `now` in `zone`). */
|
|
117
|
+
export function pruneDays(days, now, zone) {
|
|
118
|
+
const oldest = localDate(now - ROLLUP_KEEP_DAYS * DAY, zone);
|
|
119
|
+
const before = days.rows.length;
|
|
120
|
+
days.rows = days.rows.filter(r => r.date >= oldest);
|
|
121
|
+
const cov = days.coverage.filter(([, to]) => to >= now - ROLLUP_KEEP_DAYS * DAY);
|
|
122
|
+
const changed = days.rows.length !== before || cov.length !== days.coverage.length;
|
|
123
|
+
days.coverage = cov;
|
|
124
|
+
return changed;
|
|
125
|
+
}
|
|
126
|
+
/** Record that the scanner has read [from, to]: merged into the intervals, at most COVERAGE_MAX of them. */
|
|
127
|
+
export function addCoverage(days, from, to) {
|
|
128
|
+
if (!(from <= to))
|
|
129
|
+
return;
|
|
130
|
+
const all = [...days.coverage, [from, to]].sort((a, b) => a[0] - b[0]);
|
|
131
|
+
const merged = [];
|
|
132
|
+
for (const [a, b] of all) {
|
|
133
|
+
const last = merged[merged.length - 1];
|
|
134
|
+
if (last && a <= last[1] + HOUR)
|
|
135
|
+
last[1] = Math.max(last[1], b);
|
|
136
|
+
else
|
|
137
|
+
merged.push([a, b]);
|
|
138
|
+
}
|
|
139
|
+
while (merged.length > COVERAGE_MAX) {
|
|
140
|
+
const [x, y] = merged.splice(0, 2);
|
|
141
|
+
merged.unshift([x[0], y[1]]);
|
|
142
|
+
}
|
|
143
|
+
days.coverage = merged;
|
|
144
|
+
}
|
|
145
|
+
/** Whether the scanner has read the hour starting at `h`. */
|
|
146
|
+
export const covered = (days, h) => days.coverage.some(([a, b]) => h + HOUR > a && h <= b);
|
|
147
|
+
export async function readDays(path) {
|
|
148
|
+
try {
|
|
149
|
+
return reviveDays(JSON.parse(await readFile(path, "utf8")));
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return emptyDays();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** Written whole and renamed into place (0600): a crash leaves the old file or the new one, never a mix. */
|
|
156
|
+
export async function writeDays(path, days) {
|
|
157
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
158
|
+
try {
|
|
159
|
+
await mkdir(dirname(path), { recursive: true });
|
|
160
|
+
await writeFile(tmp, JSON.stringify(days), { mode: 0o600 });
|
|
161
|
+
await rename(tmp, path);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=usage-rollup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-rollup.js","sourceRoot":"","sources":["../src/usage-rollup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,qHAAqH;AACrH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAO/B,MAAM,cAAc,GAA2B,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACzF;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,EAAc,CAAC;IACjC,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC;QACrD,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,GAAG,CAAC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UAAU,SAAS,CAAC,IAAY,EAAE,IAAe;IAC3D,MAAM,GAAG,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,MAAM,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,KAAK,CAAC;IAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare const AMBIENT_PRESETS: readonly ["fall", "rise", "twinkle", "burst-on-click"];
|
|
2
|
+
export type AmbientPreset = typeof AMBIENT_PRESETS[number];
|
|
3
|
+
/** Where a preset is kept: a chat has one of each. */
|
|
4
|
+
export declare const AMBIENT_KINDS: readonly ["loop", "click"];
|
|
5
|
+
export type AmbientKind = typeof AMBIENT_KINDS[number];
|
|
6
|
+
export declare const ambientKind: (preset: AmbientPreset) => AmbientKind;
|
|
7
|
+
export declare const AMBIENT_GLYPHS_MAX = 4;
|
|
8
|
+
export declare const AMBIENT_GLYPH_GRAPHEMES = 2;
|
|
9
|
+
export declare const AMBIENT_COLORS_MAX = 5;
|
|
10
|
+
export declare const AMBIENT_SPEC_MAX_BYTES = 1024;
|
|
11
|
+
/** The page's caps (chat-ambient.js keeps the same numbers): 24 looping particles, 3 bursts of 16 at once. */
|
|
12
|
+
export declare const AMBIENT_LOOP_MAX = 24;
|
|
13
|
+
export declare const AMBIENT_BURST_MAX = 16;
|
|
14
|
+
export declare const AMBIENT_BURSTS_LIVE = 3;
|
|
15
|
+
type Range = readonly [number, number];
|
|
16
|
+
/** Each preset's bounds and defaults. A count is particles (loops) or particles per click (burst). */
|
|
17
|
+
export declare const AMBIENT_RULES: Record<AmbientPreset, {
|
|
18
|
+
count: Range;
|
|
19
|
+
countDefault: number;
|
|
20
|
+
duration: Range;
|
|
21
|
+
durationDefault: Range;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const AMBIENT_SIZE: Range;
|
|
24
|
+
export declare const AMBIENT_SIZE_DEFAULT: Range;
|
|
25
|
+
export declare const AMBIENT_SWAY_MAX = 80;
|
|
26
|
+
export declare const AMBIENT_SWAY_DEFAULT = 40;
|
|
27
|
+
export declare const AMBIENT_SPREAD: Range;
|
|
28
|
+
export declare const AMBIENT_SPREAD_DEFAULT: Range;
|
|
29
|
+
export declare const AMBIENT_ROTATE_MAX = 720;
|
|
30
|
+
export declare const AMBIENT_ROTATE_DEFAULT = 300;
|
|
31
|
+
export declare const AMBIENT_OPACITY_DEFAULT: readonly [0, 0.85, 0.15];
|
|
32
|
+
export type AmbientGlyph = string | {
|
|
33
|
+
asset: string;
|
|
34
|
+
};
|
|
35
|
+
/** Canonical: every field present, so the page and a preview draw the same thing. */
|
|
36
|
+
export interface AmbientSpec {
|
|
37
|
+
preset: AmbientPreset;
|
|
38
|
+
glyphs: AmbientGlyph[];
|
|
39
|
+
/** Empty: the theme's accent. */
|
|
40
|
+
colors: string[];
|
|
41
|
+
count: number;
|
|
42
|
+
duration: [number, number];
|
|
43
|
+
size: [number, number];
|
|
44
|
+
sway: number;
|
|
45
|
+
spread: [number, number];
|
|
46
|
+
rotate: number;
|
|
47
|
+
opacity: [number, number, number];
|
|
48
|
+
layer: "behind";
|
|
49
|
+
}
|
|
50
|
+
export interface AmbientProblem {
|
|
51
|
+
path: string;
|
|
52
|
+
problem: string;
|
|
53
|
+
}
|
|
54
|
+
export type Checked<T> = {
|
|
55
|
+
ok: true;
|
|
56
|
+
value: T;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
errors: AmbientProblem[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A spec, closed and canonical: unknown keys, a value out of its preset's bounds or a glyph that is not 1..2 visible
|
|
63
|
+
* graphemes (or one of this instance's `glyph` pictures, when `glyphAsset` is given) are refused.
|
|
64
|
+
*/
|
|
65
|
+
export declare function checkAmbient(raw: unknown, opts?: {
|
|
66
|
+
glyphAsset?: (id: string) => boolean;
|
|
67
|
+
}): Checked<AmbientSpec>;
|
|
68
|
+
/** The glyph pictures a spec names. */
|
|
69
|
+
export declare function ambientAssets(spec: AmbientSpec): string[];
|
|
70
|
+
/** One line per problem, for a tool's refusal. */
|
|
71
|
+
export declare function ambientProblems(errors: AmbientProblem[]): string;
|
|
72
|
+
export {};
|