@laoyuehanni/dsh-token-usage 0.4.0 → 0.4.2
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 +2 -10
- package/README.zh.md +2 -10
- package/docs/pricing.md +3 -13
- package/lib/client/PricingDialog.d.ts +51 -0
- package/lib/client/PricingDialog.d.ts.map +1 -0
- package/lib/client/PricingDialog.js +127 -0
- package/lib/client/PricingDialog.js.map +1 -0
- package/lib/client/PricingOverviewDialog.d.ts +76 -0
- package/lib/client/PricingOverviewDialog.d.ts.map +1 -0
- package/lib/client/PricingOverviewDialog.js +361 -0
- package/lib/client/PricingOverviewDialog.js.map +1 -0
- package/lib/client/QuotaButton.d.ts.map +1 -1
- package/lib/client/QuotaButton.js.map +1 -1
- package/lib/client/SessionStatsChip.d.ts.map +1 -1
- package/lib/client/SessionStatsChip.js.map +1 -1
- package/lib/client/SessionTable.d.ts +39 -0
- package/lib/client/SessionTable.d.ts.map +1 -0
- package/lib/client/SessionTable.js +181 -0
- package/lib/client/SessionTable.js.map +1 -0
- package/lib/client/TokenUsageSection.d.ts +16 -9
- package/lib/client/TokenUsageSection.d.ts.map +1 -1
- package/lib/client/TokenUsageSection.js +66 -128
- package/lib/client/TokenUsageSection.js.map +1 -1
- package/lib/client/TrendChart.d.ts +1 -1
- package/lib/client/TrendChart.d.ts.map +1 -1
- package/lib/client/TrendChart.js +13 -5
- package/lib/client/TrendChart.js.map +1 -1
- package/lib/client/UsageView.d.ts +10 -3
- package/lib/client/UsageView.d.ts.map +1 -1
- package/lib/client/UsageView.js +12 -3
- package/lib/client/UsageView.js.map +1 -1
- package/lib/client/card-form.d.ts +1 -1
- package/lib/client/card-form.d.ts.map +1 -1
- package/lib/client/index.d.ts +7 -6
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +27 -7
- package/lib/client/index.js.map +1 -1
- package/lib/client/locales.d.ts +25 -0
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +50 -0
- package/lib/client/locales.js.map +1 -1
- package/lib/client/trend-chart/index.d.ts +2 -0
- package/lib/client/trend-chart/index.d.ts.map +1 -1
- package/lib/client/trend-chart/index.js +1 -0
- package/lib/client/trend-chart/index.js.map +1 -1
- package/lib/client/trend-chart/path.d.ts +36 -0
- package/lib/client/trend-chart/path.d.ts.map +1 -0
- package/lib/client/trend-chart/path.js +51 -0
- package/lib/client/trend-chart/path.js.map +1 -0
- package/lib/client/trend-chart/points.d.ts +1 -0
- package/lib/client/trend-chart/points.d.ts.map +1 -1
- package/lib/client/trend-chart/points.js +1 -0
- package/lib/client/trend-chart/points.js.map +1 -1
- package/lib/client/trend-chart/scale.d.ts +8 -3
- package/lib/client/trend-chart/scale.d.ts.map +1 -1
- package/lib/client/trend-chart/scale.js +22 -14
- package/lib/client/trend-chart/scale.js.map +1 -1
- package/lib/client.js +1478 -304
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +9 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +72 -28
- package/lib/index.js.map +1 -1
- package/lib/migrate.d.ts +3 -2
- package/lib/migrate.d.ts.map +1 -1
- package/lib/migrate.js +4 -2
- package/lib/migrate.js.map +1 -1
- package/lib/pricing.d.ts +29 -23
- package/lib/pricing.d.ts.map +1 -1
- package/lib/pricing.js +38 -50
- package/lib/pricing.js.map +1 -1
- package/lib/rollup.d.ts +7 -1
- package/lib/rollup.d.ts.map +1 -1
- package/lib/rollup.js +15 -0
- package/lib/rollup.js.map +1 -1
- package/lib/session-meta.d.ts +68 -0
- package/lib/session-meta.d.ts.map +1 -0
- package/lib/session-meta.js +174 -0
- package/lib/session-meta.js.map +1 -0
- package/lib/stats-route.d.ts +22 -0
- package/lib/stats-route.d.ts.map +1 -1
- package/lib/stats-route.js +85 -6
- package/lib/stats-route.js.map +1 -1
- package/lib/stats.d.ts +35 -3
- package/lib/stats.d.ts.map +1 -1
- package/lib/stats.js +185 -6
- package/lib/stats.js.map +1 -1
- package/lib/sync-state.d.ts +42 -10
- package/lib/sync-state.d.ts.map +1 -1
- package/lib/sync-state.js +61 -19
- package/lib/sync-state.js.map +1 -1
- package/lib/sync.d.ts +55 -9
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +55 -10
- package/lib/sync.js.map +1 -1
- package/lib/wire.d.ts +114 -10
- package/lib/wire.d.ts.map +1 -1
- package/lib/wire.js +3 -0
- package/lib/wire.js.map +1 -1
- package/package.json +26 -21
package/lib/stats-route.js
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* @module token-usage/stats-route
|
|
8
8
|
*/
|
|
9
9
|
import { consoleLogger } from "./log.js";
|
|
10
|
-
import { readPricingTable, readUsdExchangeRate, resolveRate } from "./pricing.js";
|
|
11
|
-
import { attachCosts, buildSummary, filterRecordsBySessions, filterSummary, requestSeriesOf, summarizeRecords } from "./stats.js";
|
|
10
|
+
import { readPricingOverview, readPricingTable, readUsdExchangeRate, resolveRate } from "./pricing.js";
|
|
11
|
+
import { attachCosts, buildSessionRows, buildSummary, filterRecordsBySessions, filterSummary, requestSeriesOf, SESSION_ROW_LIMIT, summarizeRecords } from "./stats.js";
|
|
12
12
|
import { readCachedRecords } from "./record-cache.js";
|
|
13
|
+
import { SessionMetaStore } from "./session-meta.js";
|
|
13
14
|
import { bucketSeries, pointsOfBuckets } from "./trend-bucket.js";
|
|
14
|
-
import { decodeChildGroups, decodeSessionScope, DIR_GUARD_PATH, FULL_SYNC_PATH, MIGRATION_PATH, STATS_PATH, UNPRICED_KEY } from "./wire.js";
|
|
15
|
+
import { decodeChildGroups, decodeSessionScope, DIR_GUARD_PATH, FULL_SYNC_PATH, MIGRATION_PATH, PRICING_PATH, STATS_PATH, UNPRICED_KEY } from "./wire.js";
|
|
15
16
|
/** The stats endpoint path, exported for tests and the client half. */
|
|
16
17
|
export { STATS_PATH } from "./wire.js";
|
|
17
18
|
/** The migration-progress endpoint path, exported for the client half. */
|
|
@@ -20,6 +21,8 @@ export { MIGRATION_PATH } from "./wire.js";
|
|
|
20
21
|
export { DIR_GUARD_PATH } from "./wire.js";
|
|
21
22
|
/** The full-sync endpoint path, exported for the client half. */
|
|
22
23
|
export { FULL_SYNC_PATH } from "./wire.js";
|
|
24
|
+
/** The pricing-overview endpoint path, exported for the client half. */
|
|
25
|
+
export { PRICING_PATH } from "./wire.js";
|
|
23
26
|
/** A day query key must be exactly `YYYY-MM-DD`. */
|
|
24
27
|
const DAY_KEY = /^\d{4}-\d{2}-\d{2}$/u;
|
|
25
28
|
/** Read the filter query parameters off the request URL. */
|
|
@@ -124,6 +127,53 @@ export function createDirectoryGuardRoute(judge) {
|
|
|
124
127
|
},
|
|
125
128
|
};
|
|
126
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Build the pricing-overview route the settings page's overview dialog reads:
|
|
132
|
+
* the full cloud-mirror model list in its model-row shape (modelId + aliases
|
|
133
|
+
* + family + rules, never flattened into the alias-keyed table). The overview
|
|
134
|
+
* is deliberately filter-free — it serves every model the mirror carries, so
|
|
135
|
+
* it takes no query parameters and stays independent of the stats filters.
|
|
136
|
+
* @param dir - reads the directory currently in force (per request, so a
|
|
137
|
+
* settings-driven move starts answering from the new location at once).
|
|
138
|
+
* @param options - the currency thunk; defaults to CNY (the domestic default).
|
|
139
|
+
* @returns the exact GET route serving the overview JSON.
|
|
140
|
+
*/
|
|
141
|
+
export function createPricingRoute(dir, options = {}) {
|
|
142
|
+
const logger = options.logger ?? consoleLogger;
|
|
143
|
+
return {
|
|
144
|
+
kind: 'exact',
|
|
145
|
+
path: PRICING_PATH,
|
|
146
|
+
handler: async (req, res) => {
|
|
147
|
+
if (req.method !== 'GET') {
|
|
148
|
+
res.writeHead(405, { 'content-type': 'text/plain; charset=utf-8' });
|
|
149
|
+
res.end('method not allowed');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!isSameOriginFetch(req)) {
|
|
153
|
+
res.writeHead(403, { 'content-type': 'text/plain; charset=utf-8' });
|
|
154
|
+
res.end('forbidden');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const dataDir = dir();
|
|
159
|
+
const [models, usdExchangeRate] = await Promise.all([
|
|
160
|
+
readPricingOverview(dataDir, logger),
|
|
161
|
+
readUsdExchangeRate(dataDir, logger),
|
|
162
|
+
]);
|
|
163
|
+
res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
|
|
164
|
+
res.end(JSON.stringify({
|
|
165
|
+
models,
|
|
166
|
+
currency: options.currency?.() ?? 'CNY',
|
|
167
|
+
usdExchangeRate,
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
res.writeHead(500, { 'content-type': 'application/json; charset=utf-8' });
|
|
172
|
+
res.end(JSON.stringify({ error: error instanceof Error ? error.message : String(error) }));
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
127
177
|
/**
|
|
128
178
|
* Build the full-sync route backing the card's manual "scan again" button.
|
|
129
179
|
* The handler is small by design: it only owns the request/response shape
|
|
@@ -180,14 +230,18 @@ function childBreakdown(records, filter, dataDir, resolve, pricing) {
|
|
|
180
230
|
}
|
|
181
231
|
return rows;
|
|
182
232
|
}
|
|
183
|
-
/** Session-scoped wire shape: `full` keeps the CostedSummary
|
|
233
|
+
/** Session-scoped wire shape: `full` keeps the CostedSummary (minus the
|
|
234
|
+
* granular bySession cells — the fold happened server-side); `session` /
|
|
184
235
|
* `chip` drop the unused pricing / rate / recent / hour layers, and
|
|
185
236
|
* `session` sends a pre-bucketed request series (≤ 60 points). */
|
|
186
237
|
function slimSessionPayload(input) {
|
|
187
238
|
const { summary, sessionIds, series, currency, usdExchangeRate, fields, children } = input;
|
|
239
|
+
// The granular per-session cells stay behind the route: session-scoped
|
|
240
|
+
// consumers read totals / byModel / requestSeries, never the cells.
|
|
241
|
+
const { bySession: _cells, ...summaryRest } = summary;
|
|
188
242
|
const requestSeries = fields === 'session' ? pointsOfBuckets(bucketSeries(series)) : [...series];
|
|
189
243
|
const full = {
|
|
190
|
-
...
|
|
244
|
+
...summaryRest,
|
|
191
245
|
scope: 'session',
|
|
192
246
|
sessionIds,
|
|
193
247
|
requestSeries,
|
|
@@ -224,6 +278,18 @@ function slimSessionPayload(input) {
|
|
|
224
278
|
* @returns the exact GET route serving the JSON summary.
|
|
225
279
|
*/
|
|
226
280
|
export function createStatsRoute(dir, options = {}) {
|
|
281
|
+
// One metadata store per data directory (its mtime cache is per-path), so
|
|
282
|
+
// repeated stats reads do not reparse an unchanged sessions.json. A
|
|
283
|
+
// relocation keys a new entry and the old one just goes unused.
|
|
284
|
+
const metaStores = new Map();
|
|
285
|
+
const metaStoreOf = (dataDir) => {
|
|
286
|
+
const existing = metaStores.get(dataDir);
|
|
287
|
+
if (existing !== undefined)
|
|
288
|
+
return existing;
|
|
289
|
+
const created = new SessionMetaStore(dataDir, options.logger ?? consoleLogger);
|
|
290
|
+
metaStores.set(dataDir, created);
|
|
291
|
+
return created;
|
|
292
|
+
};
|
|
227
293
|
return {
|
|
228
294
|
kind: 'exact',
|
|
229
295
|
path: STATS_PATH,
|
|
@@ -279,6 +345,18 @@ export function createStatsRoute(dir, options = {}) {
|
|
|
279
345
|
// page converts (÷ usdExchangeRate) when the region pick says USD.
|
|
280
346
|
const currency = options.currency?.() ?? 'CNY';
|
|
281
347
|
const usdExchangeRate = await readUsdExchangeRate(dataDir, logger);
|
|
348
|
+
// The session table's final rows: the costed bySession cells fold
|
|
349
|
+
// per top-level session (the whole subtree merges in), sorted by
|
|
350
|
+
// cost and truncated top-N server-side, with the metadata index's
|
|
351
|
+
// titles and directories attached. The fold is unconditional —
|
|
352
|
+
// subagents badge through childCount, never their own rows.
|
|
353
|
+
const metaIndex = await metaStoreOf(dataDir).read();
|
|
354
|
+
const meta = new Map(Object.entries(metaIndex));
|
|
355
|
+
const sessionRows = buildSessionRows(summary, meta, SESSION_ROW_LIMIT);
|
|
356
|
+
// Strip the granular cells from the whole-scope payload: the client
|
|
357
|
+
// renders the folded rows, and sending the cells would duplicate
|
|
358
|
+
// every aggregate once more on the wire.
|
|
359
|
+
const { bySession: _cells, ...summaryRest } = summary;
|
|
282
360
|
const children = allRecords !== undefined && filter.childGroups.length > 0
|
|
283
361
|
? childBreakdown(allRecords, filter, dataDir, resolve, pricing)
|
|
284
362
|
: undefined;
|
|
@@ -293,8 +371,9 @@ export function createStatsRoute(dir, options = {}) {
|
|
|
293
371
|
children,
|
|
294
372
|
})
|
|
295
373
|
: {
|
|
296
|
-
...
|
|
374
|
+
...summaryRest,
|
|
297
375
|
scope: 'whole',
|
|
376
|
+
sessionRows,
|
|
298
377
|
currency,
|
|
299
378
|
usdExchangeRate,
|
|
300
379
|
};
|
package/lib/stats-route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats-route.js","sourceRoot":"","sources":["../src/stats-route.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,aAAa,EAAmB,MAAM,UAAU,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEjI,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAI3I,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,0EAA0E;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,uEAAu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Q;qBACT,CAAC;oBACF,CAAC,CAAC;wBACA,GAAG,WAAW;wBACd,KAAK,EAAE,OAAgB;wBACvB,WAAW;wBACX,QAAQ;wBACR,eAAe;qBACO,CAAA;gBAC1B,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;oBACjB,cAAc,EAAE,iCAAiC;oBACjD,oEAAoE;oBACpE,eAAe,EAAE,UAAU;iBAC5B,CAAC,CAAA;gBACF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;YAClC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,iCAAiC,EAAE,CAAC,CAAA;gBACzE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;YAC5F,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/lib/stats.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { type LoggerLike } from './log.ts';
|
|
14
14
|
import type { UsageRecord } from './usage-record.ts';
|
|
15
|
-
import type { CostedSummary, PricingTable, RateKey, RequestPoint, TokenSummary, UsageTotals } from './wire.ts';
|
|
15
|
+
import type { CostedSummary, PricingTable, RateKey, RequestPoint, SessionUsageRow, TokenSummary, UsageTotals } from './wire.ts';
|
|
16
16
|
/** Bounded recent window length: only the newest records cross the wire. */
|
|
17
17
|
export declare const RECENT_LIMIT = 20;
|
|
18
18
|
/**
|
|
@@ -131,6 +131,39 @@ export declare function filterSummary(summary: TokenSummary & {
|
|
|
131
131
|
export declare function attachCosts(summary: TokenSummary & {
|
|
132
132
|
dataDir: string;
|
|
133
133
|
}, pricing: PricingTable): CostedSummary;
|
|
134
|
+
/** How many session rows the route sends, counted after the fold — the
|
|
135
|
+
* truncation that makes folding a server-side concern in the first place. */
|
|
136
|
+
export declare const SESSION_ROW_LIMIT = 20;
|
|
137
|
+
/** One entry of the session-metadata index the fold reads identities from
|
|
138
|
+
* (the duck-typed projection of `session-meta.ts`'s store). */
|
|
139
|
+
export interface SessionMetaEntry {
|
|
140
|
+
title?: string;
|
|
141
|
+
cwd?: string;
|
|
142
|
+
parentSession?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Fold the costed per-session cells into the final rows the settings page's
|
|
146
|
+
* session table renders: one row per top-level session with its whole
|
|
147
|
+
* subtree merged in, priced, sorted by cost descending, and truncated to
|
|
148
|
+
* `limit` — the fold changes ranking (a parent row ranks by its subtree's
|
|
149
|
+
* cost), so the cut must see the folded order or it would drop the wrong
|
|
150
|
+
* rows. Subagents never surface as rows of their own; the row's
|
|
151
|
+
* `childCount` badge is their only visibility here (the conversation view's
|
|
152
|
+
* subagent table owns the per-child drill-down).
|
|
153
|
+
*
|
|
154
|
+
* Fold rules all converge on "the sum never changes": a session without a
|
|
155
|
+
* `parentSession` is a root, a parent missing from the cells (or from the
|
|
156
|
+
* index) leaves the child a top-level row, nested subagents walk to the
|
|
157
|
+
* topmost root, and a defensive cut on a parent cycle keeps every row as
|
|
158
|
+
* its own root rather than dropping one. Identity fields (title, cwd) come
|
|
159
|
+
* from the metadata index — the server attaches them so the wire carries
|
|
160
|
+
* final rows and the client never reassembles anything.
|
|
161
|
+
* @param summary - the (already filtered) costed summary.
|
|
162
|
+
* @param meta - the session-metadata index (id → identity fields).
|
|
163
|
+
* @param limit - maximum rows returned.
|
|
164
|
+
* @returns the truncated, cost-descending session rows.
|
|
165
|
+
*/
|
|
166
|
+
export declare function buildSessionRows(summary: CostedSummary, meta: ReadonlyMap<string, SessionMetaEntry>, limit: number): SessionUsageRow[];
|
|
134
167
|
/**
|
|
135
168
|
* Read every day file into records, in day-file order. An absent data
|
|
136
169
|
* directory (nothing written yet) yields an empty list. Uncached — the
|
|
@@ -138,8 +171,7 @@ export declare function attachCosts(summary: TokenSummary & {
|
|
|
138
171
|
* usage-tab polls do not re-parse frozen files.
|
|
139
172
|
* @param dir - the plugin's data directory.
|
|
140
173
|
* @returns parsed records, or [] when the directory does not exist.
|
|
141
|
-
*/
|
|
142
|
-
export declare function readAllRecords(dir: string, logger?: LoggerLike): Promise<UsageRecord[]>;
|
|
174
|
+
*/ export declare function readAllRecords(dir: string, logger?: LoggerLike): Promise<UsageRecord[]>;
|
|
143
175
|
/**
|
|
144
176
|
* Build the full stats payload for one data directory: the rollup over every
|
|
145
177
|
* frozen day file (advanced lazily and rewritten atomically when unabsorbed
|
package/lib/stats.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../src/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../src/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,KAAK,EAGV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,eAAe,EACf,YAAY,EAMZ,WAAW,EACZ,MAAM,WAAW,CAAA;AAGlB,4EAA4E;AAC5E,eAAO,MAAM,YAAY,KAAK,CAAA;AAE9B;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAA;AAO3D,iFAAiF;AACjF,wBAAgB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AAI,CAAC,EAAE,MAAM,EACb,EAAE,CAAC,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,GACb,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAkCpC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,YAAY,GAAG,aAAa,CA0C7G;AAED;6EAC6E;AAC7E,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC;+DAC+D;AAC/D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC3C,KAAK,EAAE,MAAM,GACZ,eAAe,EAAE,CAuFnB;AAED;;;;;;;GAOG,CAAA,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,UAA0B,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAM/G;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,IAAuB,EAClC,OAAO,GAAE,YAAiC,EAC1C,MAAM,GAAE,UAA0B,GACjC,OAAO,CAAC,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA2B7C"}
|
package/lib/stats.js
CHANGED
|
@@ -19,7 +19,7 @@ import { UNPRICED_KEY } from "./wire.js";
|
|
|
19
19
|
export const RECENT_LIMIT = 20;
|
|
20
20
|
/** Empty rollup used as the merge base when no rollup exists on disk yet. */
|
|
21
21
|
function emptyRollup() {
|
|
22
|
-
return { upto: '', total: emptyTotals(), byDay: [], byHour: [], byModel: [], rateRows: [], recent: [] };
|
|
22
|
+
return { upto: '', total: emptyTotals(), byDay: [], byHour: [], byModel: [], rateRows: [], bySession: [], recent: [] };
|
|
23
23
|
}
|
|
24
24
|
/** Zeroed totals; requests counts rows, the token buckets sum reported usage. */
|
|
25
25
|
export function emptyTotals() {
|
|
@@ -83,6 +83,17 @@ function rateRowsSorted(rows) {
|
|
|
83
83
|
function rateRowKey(day, model, rate) {
|
|
84
84
|
return `${day}\n${model}\n${rate.ruleStart}-${rate.ruleEnd}-${rate.tier}-${rate.slot}`;
|
|
85
85
|
}
|
|
86
|
+
/** Deterministic session-cell order: session id, day, model, rate identity. */
|
|
87
|
+
function sessionRowsSorted(rows) {
|
|
88
|
+
return [...rows].sort((left, right) => left.sessionId < right.sessionId ? -1 : left.sessionId > right.sessionId ? 1
|
|
89
|
+
: left.day < right.day ? -1 : left.day > right.day ? 1
|
|
90
|
+
: left.model < right.model ? -1 : left.model > right.model ? 1
|
|
91
|
+
: compareKeys(left.rate, right.rate));
|
|
92
|
+
}
|
|
93
|
+
/** Map key of one (sessionId, day, model, rate) cell. */
|
|
94
|
+
function sessionRowKey(row) {
|
|
95
|
+
return `${row.sessionId}\n${row.day}\n${row.model}\n${row.rate.ruleStart}-${row.rate.ruleEnd}-${row.rate.tier}-${row.rate.slot}`;
|
|
96
|
+
}
|
|
86
97
|
/**
|
|
87
98
|
* Fold one record into totals; a record without provider usage still counts a
|
|
88
99
|
* request, and a compaction record additionally counts the `compactions`
|
|
@@ -158,6 +169,7 @@ export function summarizeRecords(records, resolve = () => UNPRICED_KEY) {
|
|
|
158
169
|
const hours = new Map();
|
|
159
170
|
const models = new Map();
|
|
160
171
|
const rated = new Map();
|
|
172
|
+
const sessions = new Map();
|
|
161
173
|
const recent = [];
|
|
162
174
|
for (const record of records) {
|
|
163
175
|
addUsage(total, record);
|
|
@@ -168,7 +180,9 @@ export function summarizeRecords(records, resolve = () => UNPRICED_KEY) {
|
|
|
168
180
|
// An unattributed failure (`model === ''`) still folds into totals,
|
|
169
181
|
// byDay, and rateRows (so a day-range filter keeps the count). It
|
|
170
182
|
// stays out of byModel / byHour — a blank table row would pretend
|
|
171
|
-
// we know the route.
|
|
183
|
+
// we know the route. The session dimension keeps it too: request
|
|
184
|
+
// counts must reconcile per session, and a failure belongs to its
|
|
185
|
+
// session even when no model was ever observed.
|
|
172
186
|
if (record.model !== '') {
|
|
173
187
|
const hour = hourKey(record.time);
|
|
174
188
|
const hourTotals = hours.get(hourRowKey(hour, record.model)) ?? emptyTotals();
|
|
@@ -184,6 +198,20 @@ export function summarizeRecords(records, resolve = () => UNPRICED_KEY) {
|
|
|
184
198
|
?? { day, model: record.model, rate, totals: emptyTotals() };
|
|
185
199
|
addUsage(cell.totals, record);
|
|
186
200
|
rated.set(rowKey, cell);
|
|
201
|
+
const sessionCell = {
|
|
202
|
+
sessionId: record.sessionId,
|
|
203
|
+
day,
|
|
204
|
+
model: record.model,
|
|
205
|
+
rate,
|
|
206
|
+
lastTime: record.time,
|
|
207
|
+
totals: emptyTotals(),
|
|
208
|
+
};
|
|
209
|
+
const sessionKey = sessionRowKey(sessionCell);
|
|
210
|
+
const folded = sessions.get(sessionKey) ?? sessionCell;
|
|
211
|
+
addUsage(folded.totals, record);
|
|
212
|
+
sessions.set(sessionKey, folded);
|
|
213
|
+
if (record.time > folded.lastTime)
|
|
214
|
+
folded.lastTime = record.time;
|
|
187
215
|
if (recent.length === RECENT_LIMIT)
|
|
188
216
|
recent.shift();
|
|
189
217
|
recent.push(record);
|
|
@@ -192,7 +220,15 @@ export function summarizeRecords(records, resolve = () => UNPRICED_KEY) {
|
|
|
192
220
|
const byHour = hourRows(hours);
|
|
193
221
|
const byModel = modelRows(models);
|
|
194
222
|
recent.sort((left, right) => right.time - left.time);
|
|
195
|
-
return {
|
|
223
|
+
return {
|
|
224
|
+
total,
|
|
225
|
+
byDay,
|
|
226
|
+
byHour,
|
|
227
|
+
byModel,
|
|
228
|
+
rateRows: rateRowsSorted(rated.values()),
|
|
229
|
+
bySession: sessionRowsSorted(sessions.values()),
|
|
230
|
+
recent,
|
|
231
|
+
};
|
|
196
232
|
}
|
|
197
233
|
/**
|
|
198
234
|
* Keep only the records owned by one of the listed sessions. The rollup
|
|
@@ -287,6 +323,7 @@ export function mergeSummaries(left, right) {
|
|
|
287
323
|
const hours = new Map();
|
|
288
324
|
const models = new Map();
|
|
289
325
|
const rated = new Map();
|
|
326
|
+
const sessions = new Map();
|
|
290
327
|
for (const row of [...left.byDay, ...right.byDay]) {
|
|
291
328
|
const day = days.get(row.day) ?? emptyTotals();
|
|
292
329
|
addTotals(day, row.totals);
|
|
@@ -310,6 +347,18 @@ export function mergeSummaries(left, right) {
|
|
|
310
347
|
addTotals(cell.totals, row.totals);
|
|
311
348
|
rated.set(key, cell);
|
|
312
349
|
}
|
|
350
|
+
// `?? []`: a hand-built or legacy-shaped summary without the session
|
|
351
|
+
// dimension folds as if it had none — on-disk rollups fail validation
|
|
352
|
+
// instead (isRollupFile), so this leniency only serves in-memory shapes.
|
|
353
|
+
for (const row of [...(left.bySession ?? []), ...(right.bySession ?? [])]) {
|
|
354
|
+
const key = sessionRowKey(row);
|
|
355
|
+
const cell = sessions.get(key)
|
|
356
|
+
?? { ...row, totals: emptyTotals() };
|
|
357
|
+
addTotals(cell.totals, row.totals);
|
|
358
|
+
if (row.lastTime > cell.lastTime)
|
|
359
|
+
cell.lastTime = row.lastTime;
|
|
360
|
+
sessions.set(key, cell);
|
|
361
|
+
}
|
|
313
362
|
const recent = [...left.recent, ...right.recent]
|
|
314
363
|
.sort((a, b) => b.time - a.time)
|
|
315
364
|
.slice(0, RECENT_LIMIT);
|
|
@@ -319,6 +368,7 @@ export function mergeSummaries(left, right) {
|
|
|
319
368
|
byHour: hourRows(hours),
|
|
320
369
|
byModel: modelRows(models),
|
|
321
370
|
rateRows: rateRowsSorted(rated.values()),
|
|
371
|
+
bySession: sessionRowsSorted(sessions.values()),
|
|
322
372
|
recent,
|
|
323
373
|
};
|
|
324
374
|
}
|
|
@@ -348,6 +398,12 @@ export function filterSummary(summary, from, to, model) {
|
|
|
348
398
|
const byHour = summary.byHour.filter(row => (from === undefined || row.hour.slice(0, 10) >= from)
|
|
349
399
|
&& (to === undefined || row.hour.slice(0, 10) <= to)
|
|
350
400
|
&& (model === undefined || row.model === model));
|
|
401
|
+
// Session cells keep the same granule the rate rows carry (day × model ×
|
|
402
|
+
// rate per session), so the filtered fold stays the exact source the cost
|
|
403
|
+
// layer bills from — same pattern as `rows`, one dimension wider.
|
|
404
|
+
const bySession = summary.bySession.filter(row => (from === undefined || row.day >= from)
|
|
405
|
+
&& (to === undefined || row.day <= to)
|
|
406
|
+
&& (model === undefined || row.model === model));
|
|
351
407
|
const total = emptyTotals();
|
|
352
408
|
const days = new Map();
|
|
353
409
|
const models = new Map();
|
|
@@ -363,7 +419,7 @@ export function filterSummary(summary, from, to, model) {
|
|
|
363
419
|
}
|
|
364
420
|
}
|
|
365
421
|
const recent = filterRecordsByRange(summary.recent, undefined, dayRangeFilter(from, to, model));
|
|
366
|
-
return { dataDir: summary.dataDir, total, byDay: dayRows(days), byHour, byModel: modelRows(models), rateRows: rateRowsSorted(rows), recent };
|
|
422
|
+
return { dataDir: summary.dataDir, total, byDay: dayRows(days), byHour, byModel: modelRows(models), rateRows: rateRowsSorted(rows), bySession, recent };
|
|
367
423
|
}
|
|
368
424
|
/**
|
|
369
425
|
* Attach the cost layer to a token-only summary: each rate row is priced at
|
|
@@ -387,6 +443,17 @@ export function attachCosts(summary, pricing) {
|
|
|
387
443
|
costs.set(row.model, (costs.get(row.model) ?? 0) + cost);
|
|
388
444
|
totalCost += cost;
|
|
389
445
|
}
|
|
446
|
+
// Session cells bill from their own rate identity — the same units the
|
|
447
|
+
// per-model cost folds from, so the session table's cost column and the
|
|
448
|
+
// summary card reconcile without any extra plumbing. An unpriced model's
|
|
449
|
+
// cells stay 0 and surface through unpricedModels as before.
|
|
450
|
+
const bySession = summary.bySession.map(row => {
|
|
451
|
+
const rules = pricing[row.model];
|
|
452
|
+
return {
|
|
453
|
+
...row,
|
|
454
|
+
cost: rules === undefined ? 0 : costOf(row.totals, ratesForKey(rules, row.rate)),
|
|
455
|
+
};
|
|
456
|
+
});
|
|
390
457
|
const byModel = summary.byModel.map(row => ({
|
|
391
458
|
model: row.model,
|
|
392
459
|
totals: row.totals,
|
|
@@ -404,10 +471,123 @@ export function attachCosts(summary, pricing) {
|
|
|
404
471
|
byDay: summary.byDay,
|
|
405
472
|
byHour: summary.byHour,
|
|
406
473
|
byModel,
|
|
474
|
+
bySession,
|
|
407
475
|
rateRows: summary.rateRows,
|
|
408
476
|
recent: summary.recent,
|
|
409
477
|
};
|
|
410
478
|
}
|
|
479
|
+
/** How many session rows the route sends, counted after the fold — the
|
|
480
|
+
* truncation that makes folding a server-side concern in the first place. */
|
|
481
|
+
export const SESSION_ROW_LIMIT = 20;
|
|
482
|
+
/**
|
|
483
|
+
* Fold the costed per-session cells into the final rows the settings page's
|
|
484
|
+
* session table renders: one row per top-level session with its whole
|
|
485
|
+
* subtree merged in, priced, sorted by cost descending, and truncated to
|
|
486
|
+
* `limit` — the fold changes ranking (a parent row ranks by its subtree's
|
|
487
|
+
* cost), so the cut must see the folded order or it would drop the wrong
|
|
488
|
+
* rows. Subagents never surface as rows of their own; the row's
|
|
489
|
+
* `childCount` badge is their only visibility here (the conversation view's
|
|
490
|
+
* subagent table owns the per-child drill-down).
|
|
491
|
+
*
|
|
492
|
+
* Fold rules all converge on "the sum never changes": a session without a
|
|
493
|
+
* `parentSession` is a root, a parent missing from the cells (or from the
|
|
494
|
+
* index) leaves the child a top-level row, nested subagents walk to the
|
|
495
|
+
* topmost root, and a defensive cut on a parent cycle keeps every row as
|
|
496
|
+
* its own root rather than dropping one. Identity fields (title, cwd) come
|
|
497
|
+
* from the metadata index — the server attaches them so the wire carries
|
|
498
|
+
* final rows and the client never reassembles anything.
|
|
499
|
+
* @param summary - the (already filtered) costed summary.
|
|
500
|
+
* @param meta - the session-metadata index (id → identity fields).
|
|
501
|
+
* @param limit - maximum rows returned.
|
|
502
|
+
* @returns the truncated, cost-descending session rows.
|
|
503
|
+
*/
|
|
504
|
+
export function buildSessionRows(summary, meta, limit) {
|
|
505
|
+
const cells = new Map();
|
|
506
|
+
for (const cell of summary.bySession) {
|
|
507
|
+
const bucket = cells.get(cell.sessionId) ?? {
|
|
508
|
+
totals: emptyTotals(),
|
|
509
|
+
cost: 0,
|
|
510
|
+
firstTime: dayStart(cell.day),
|
|
511
|
+
lastTime: cell.lastTime,
|
|
512
|
+
};
|
|
513
|
+
addTotals(bucket.totals, cell.totals);
|
|
514
|
+
bucket.cost += cell.cost;
|
|
515
|
+
const dayStartMs = dayStart(cell.day);
|
|
516
|
+
if (dayStartMs < bucket.firstTime)
|
|
517
|
+
bucket.firstTime = dayStartMs;
|
|
518
|
+
if (cell.lastTime > bucket.lastTime)
|
|
519
|
+
bucket.lastTime = cell.lastTime;
|
|
520
|
+
cells.set(cell.sessionId, bucket);
|
|
521
|
+
}
|
|
522
|
+
// Lineage index: a parent the index never saw is the same as no parent.
|
|
523
|
+
const parentOf = new Map();
|
|
524
|
+
for (const [id, entry] of meta) {
|
|
525
|
+
if (entry.parentSession !== undefined && entry.parentSession !== '')
|
|
526
|
+
parentOf.set(id, entry.parentSession);
|
|
527
|
+
}
|
|
528
|
+
// Walk up the lineage to the topmost ancestor that holds cells; a parent
|
|
529
|
+
// outside the cells (no usage in the window, or an orphan) ends the walk,
|
|
530
|
+
// and a `seen` guard turns a pathological cycle into a top-level row.
|
|
531
|
+
const rootOf = (id) => {
|
|
532
|
+
let current = id;
|
|
533
|
+
const seen = new Set([id]);
|
|
534
|
+
for (;;) {
|
|
535
|
+
const parent = parentOf.get(current);
|
|
536
|
+
if (parent === undefined || seen.has(parent) || !cells.has(parent))
|
|
537
|
+
return current;
|
|
538
|
+
seen.add(parent);
|
|
539
|
+
current = parent;
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
// Two-pass fold: group every session's accumulation under its root
|
|
543
|
+
// first, then merge each group — order-independent, so iteration order
|
|
544
|
+
// cannot double-count a root or drop a child that landed first.
|
|
545
|
+
const grouped = new Map();
|
|
546
|
+
for (const [id, accum] of cells) {
|
|
547
|
+
const root = rootOf(id);
|
|
548
|
+
const bucket = grouped.get(root) ?? [];
|
|
549
|
+
bucket.push(accum);
|
|
550
|
+
grouped.set(root, bucket);
|
|
551
|
+
}
|
|
552
|
+
const rows = new Map();
|
|
553
|
+
for (const [root, accums] of grouped) {
|
|
554
|
+
const merged = { totals: emptyTotals(), cost: 0, firstTime: accums[0].firstTime, lastTime: accums[0].lastTime };
|
|
555
|
+
for (const accum of accums) {
|
|
556
|
+
addTotals(merged.totals, accum.totals);
|
|
557
|
+
merged.cost += accum.cost;
|
|
558
|
+
if (accum.firstTime < merged.firstTime)
|
|
559
|
+
merged.firstTime = accum.firstTime;
|
|
560
|
+
if (accum.lastTime > merged.lastTime)
|
|
561
|
+
merged.lastTime = accum.lastTime;
|
|
562
|
+
}
|
|
563
|
+
// The root itself is one of the group's sessions (rootOf always lands
|
|
564
|
+
// on a session that holds cells); the rest are its folded descendants.
|
|
565
|
+
rows.set(root, { accum: merged, childCount: accums.length - 1 });
|
|
566
|
+
}
|
|
567
|
+
const entryOf = (id) => {
|
|
568
|
+
const entry = meta.get(id);
|
|
569
|
+
return entry !== undefined && (entry.title !== undefined || entry.cwd !== undefined)
|
|
570
|
+
? { ...(entry.title !== undefined ? { title: entry.title } : {}), ...(entry.cwd !== undefined ? { cwd: entry.cwd } : {}) }
|
|
571
|
+
: undefined;
|
|
572
|
+
};
|
|
573
|
+
const out = [...rows.entries()].map(([sessionId, { accum, childCount }]) => {
|
|
574
|
+
const entry = entryOf(sessionId);
|
|
575
|
+
return {
|
|
576
|
+
sessionId,
|
|
577
|
+
...(entry !== undefined ? entry : {}),
|
|
578
|
+
// The folded-descendants badge: a subagent subtree's only visibility
|
|
579
|
+
// in this table (count 0 omits the key entirely).
|
|
580
|
+
...(childCount > 0 ? { childCount } : {}),
|
|
581
|
+
totals: accum.totals,
|
|
582
|
+
cost: accum.cost,
|
|
583
|
+
firstTime: accum.firstTime,
|
|
584
|
+
lastTime: accum.lastTime,
|
|
585
|
+
};
|
|
586
|
+
});
|
|
587
|
+
out.sort((left, right) => right.cost - left.cost || right.lastTime - left.lastTime
|
|
588
|
+
|| (left.sessionId < right.sessionId ? -1 : 1));
|
|
589
|
+
return out.length > limit ? out.slice(0, limit) : out;
|
|
590
|
+
}
|
|
411
591
|
/**
|
|
412
592
|
* Read every day file into records, in day-file order. An absent data
|
|
413
593
|
* directory (nothing written yet) yields an empty list. Uncached — the
|
|
@@ -415,8 +595,7 @@ export function attachCosts(summary, pricing) {
|
|
|
415
595
|
* usage-tab polls do not re-parse frozen files.
|
|
416
596
|
* @param dir - the plugin's data directory.
|
|
417
597
|
* @returns parsed records, or [] when the directory does not exist.
|
|
418
|
-
*/
|
|
419
|
-
export async function readAllRecords(dir, logger = consoleLogger) {
|
|
598
|
+
*/ export async function readAllRecords(dir, logger = consoleLogger) {
|
|
420
599
|
const records = [];
|
|
421
600
|
for (const name of await listDayFiles(dir)) {
|
|
422
601
|
records.push(...await readDayFile(dir, name, logger));
|