@slkiser/opencode-quota 3.1.0 → 3.1.1
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 +3 -2
- package/dist/lib/grouped-entry-normalization.d.ts +5 -0
- package/dist/lib/grouped-entry-normalization.d.ts.map +1 -1
- package/dist/lib/grouped-entry-normalization.js +7 -3
- package/dist/lib/grouped-entry-normalization.js.map +1 -1
- package/dist/lib/quota-command-format.d.ts.map +1 -1
- package/dist/lib/quota-command-format.js +41 -42
- package/dist/lib/quota-command-format.js.map +1 -1
- package/dist/lib/quota-stats-format.d.ts.map +1 -1
- package/dist/lib/quota-stats-format.js +164 -121
- package/dist/lib/quota-stats-format.js.map +1 -1
- package/dist/lib/quota-status.d.ts.map +1 -1
- package/dist/lib/quota-status.js +556 -270
- package/dist/lib/quota-status.js.map +1 -1
- package/dist/lib/report-document.d.ts +36 -0
- package/dist/lib/report-document.d.ts.map +1 -0
- package/dist/lib/report-document.js +109 -0
- package/dist/lib/report-document.js.map +1 -0
- package/dist/lib/session-tokens-format.d.ts +8 -0
- package/dist/lib/session-tokens-format.d.ts.map +1 -1
- package/dist/lib/session-tokens-format.js +36 -20
- package/dist/lib/session-tokens-format.js.map +1 -1
- package/dist/lib/synthetic.d.ts.map +1 -1
- package/dist/lib/synthetic.js +22 -13
- package/dist/lib/synthetic.js.map +1 -1
- package/dist/lib/types.d.ts +7 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/providers/synthetic.d.ts.map +1 -1
- package/dist/providers/synthetic.js +18 -4
- package/dist/providers/synthetic.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -537,9 +537,10 @@ If OpenCode already has Synthetic configured, it should work automatically. Opti
|
|
|
537
537
|
For security, provider secrets are read from `SYNTHETIC_API_KEY`, your user/global OpenCode config, or `auth.json.synthetic` only. Repo-local `opencode.json` / `opencode.jsonc` is ignored for `provider.synthetic.options.apiKey`.
|
|
538
538
|
|
|
539
539
|
- The plugin calls `GET https://api.synthetic.new/v2/quotas`.
|
|
540
|
-
- It reads `subscription.limit`, `subscription.requests`, and `subscription.renewsAt`.
|
|
540
|
+
- It reads the documented subscription window fields `subscription.limit`, `subscription.requests`, and `subscription.renewsAt`.
|
|
541
541
|
- Synthetic currently expects numeric JSON values for `subscription.limit` and `subscription.requests`; malformed or stringified values are treated as API-shape errors. Invalid `subscription.renewsAt` values are ignored.
|
|
542
|
-
- `/quota`, toasts, and the sidebar
|
|
542
|
+
- `/quota`, toasts, and the sidebar currently expose the documented Synthetic subscription quota only. Grouped mode labels it as `5h:`; classic mode collapses it to one `Synthetic` row with the same compact `used/limit` summary used by other percent-based providers.
|
|
543
|
+
- Weekly credits and other billing-dashboard metrics are not shown unless Synthetic documents them in a public API response the plugin can verify.
|
|
543
544
|
- `/quota_status` shows a `synthetic` section with API-key diagnostics only; it does not do a live Synthetic fetch there.
|
|
544
545
|
- Allowed env templates are limited to `{env:SYNTHETIC_API_KEY}`.
|
|
545
546
|
|
|
@@ -3,5 +3,10 @@ export type GroupedRenderTarget = "toast" | "quota";
|
|
|
3
3
|
export type NormalizedGroupedQuotaEntry = QuotaToastEntry & {
|
|
4
4
|
group: string;
|
|
5
5
|
};
|
|
6
|
+
export type QuotaEntryGroup = {
|
|
7
|
+
group: string;
|
|
8
|
+
entries: NormalizedGroupedQuotaEntry[];
|
|
9
|
+
};
|
|
10
|
+
export declare function groupQuotaEntries(entries: QuotaToastEntry[], target: GroupedRenderTarget): QuotaEntryGroup[];
|
|
6
11
|
export declare function normalizeGroupedQuotaEntries(entries: QuotaToastEntry[], target: GroupedRenderTarget): NormalizedGroupedQuotaEntry[];
|
|
7
12
|
//# sourceMappingURL=grouped-entry-normalization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouped-entry-normalization.d.ts","sourceRoot":"","sources":["../../src/lib/grouped-entry-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEpD,MAAM,MAAM,2BAA2B,GAAG,eAAe,GAAG;IAC1D,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAyFF,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,eAAe,EAAE,EAC1B,MAAM,EAAE,mBAAmB,GAC1B,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"grouped-entry-normalization.d.ts","sourceRoot":"","sources":["../../src/lib/grouped-entry-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEpD,MAAM,MAAM,2BAA2B,GAAG,eAAe,GAAG;IAC1D,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,2BAA2B,EAAE,CAAC;CACxC,CAAC;AAyFF,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,EAAE,EAC1B,MAAM,EAAE,mBAAmB,GAC1B,eAAe,EAAE,CAqCnB;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,eAAe,EAAE,EAC1B,MAAM,EAAE,mBAAmB,GAC1B,2BAA2B,EAAE,CAE/B"}
|
|
@@ -72,7 +72,7 @@ function normalizeGroupedQuotaEntry(entry, target) {
|
|
|
72
72
|
...(target === "quota" ? { label: label ?? "Status:" } : {}),
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
export function
|
|
75
|
+
export function groupQuotaEntries(entries, target) {
|
|
76
76
|
const groupOrder = [];
|
|
77
77
|
const groupedEntries = new Map();
|
|
78
78
|
for (const [originalIndex, entry] of entries.entries()) {
|
|
@@ -90,9 +90,9 @@ export function normalizeGroupedQuotaEntries(entries, target) {
|
|
|
90
90
|
groupOrder.push(normalizedEntry.group);
|
|
91
91
|
groupedEntries.set(normalizedEntry.group, [rankedEntry]);
|
|
92
92
|
}
|
|
93
|
-
return groupOrder.
|
|
93
|
+
return groupOrder.map((group) => {
|
|
94
94
|
const rankedEntries = groupedEntries.get(group) ?? [];
|
|
95
|
-
|
|
95
|
+
const entries = rankedEntries
|
|
96
96
|
.slice()
|
|
97
97
|
.sort((left, right) => {
|
|
98
98
|
if (left.rank !== null && right.rank !== null && left.rank !== right.rank) {
|
|
@@ -105,6 +105,10 @@ export function normalizeGroupedQuotaEntries(entries, target) {
|
|
|
105
105
|
return left.originalIndex - right.originalIndex;
|
|
106
106
|
})
|
|
107
107
|
.map(({ entry }) => entry);
|
|
108
|
+
return { group, entries };
|
|
108
109
|
});
|
|
109
110
|
}
|
|
111
|
+
export function normalizeGroupedQuotaEntries(entries, target) {
|
|
112
|
+
return groupQuotaEntries(entries, target).flatMap((group) => group.entries);
|
|
113
|
+
}
|
|
110
114
|
//# sourceMappingURL=grouped-entry-normalization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouped-entry-normalization.js","sourceRoot":"","sources":["../../src/lib/grouped-entry-normalization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grouped-entry-normalization.js","sourceRoot":"","sources":["../../src/lib/grouped-entry-normalization.ts"],"names":[],"mappings":"AAmBA,SAAS,YAAY,CAAC,KAAc;IAClC,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACvC,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAA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K,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;gBAC1E,OAAO,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;YAChC,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI;gBAAE,OAAO,CAAC,CAAC,CAAC;YACzD,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI;gBAAE,OAAO,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QAClD,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAE7B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAA0B,EAC1B,MAA2B;IAE3B,OAAO,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-command-format.d.ts","sourceRoot":"","sources":["../../src/lib/quota-command-format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"quota-command-format.d.ts","sourceRoot":"","sources":["../../src/lib/quota-command-format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAwGxF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,CAET"}
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* - Includes session token summary (input/output per model)
|
|
8
8
|
*/
|
|
9
9
|
import { isValueEntry } from "./entries.js";
|
|
10
|
-
import { bar, clampInt, padRight
|
|
10
|
+
import { bar, clampInt, padRight } from "./format-utils.js";
|
|
11
11
|
import { formatGroupedHeader } from "./grouped-header-format.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { groupQuotaEntries } from "./grouped-entry-normalization.js";
|
|
13
|
+
import { renderPlainTextReport } from "./report-document.js";
|
|
14
|
+
import { buildSessionTokenSectionModel } from "./session-tokens-format.js";
|
|
14
15
|
/**
|
|
15
16
|
* Format reset time in compact form (different from toast countdown).
|
|
16
17
|
* Uses seconds/minutes/hours/days format for /quota command.
|
|
@@ -40,29 +41,14 @@ function getGroupedLeftText(entry) {
|
|
|
40
41
|
const right = entry.right?.trim();
|
|
41
42
|
return right ? `${label} ${right}` : label;
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const groups = new Map();
|
|
47
|
-
for (const e of entries) {
|
|
48
|
-
const list = groups.get(e.group);
|
|
49
|
-
if (list)
|
|
50
|
-
list.push(e);
|
|
51
|
-
else {
|
|
52
|
-
groupOrder.push(e.group);
|
|
53
|
-
groups.set(e.group, [e]);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const lines = [];
|
|
44
|
+
function buildQuotaCommandDocument(params) {
|
|
45
|
+
const groups = groupQuotaEntries(params.entries, "quota");
|
|
46
|
+
const normalizedEntries = groups.flatMap((group) => group.entries);
|
|
57
47
|
const barWidth = 18;
|
|
58
|
-
const leftCol = Math.max(16, Math.min(30,
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
if (i > 0)
|
|
63
|
-
lines.push("");
|
|
64
|
-
lines.push(`→ ${formatGroupedHeader(g)}`);
|
|
65
|
-
for (const row of list) {
|
|
48
|
+
const leftCol = Math.max(16, Math.min(30, normalizedEntries.reduce((max, entry) => Math.max(max, getGroupedLeftText(entry).length), 0)));
|
|
49
|
+
const sections = groups.map((group, index) => {
|
|
50
|
+
const lines = [];
|
|
51
|
+
for (const row of group.entries) {
|
|
66
52
|
const leftText = getGroupedLeftText(row);
|
|
67
53
|
const labelCol = padRight(leftText, leftCol);
|
|
68
54
|
const suffix = formatResetsIn(row.resetTimeIso);
|
|
@@ -73,27 +59,40 @@ function formatQuotaCommandBody(params) {
|
|
|
73
59
|
const pct = clampInt(row.percentRemaining, 0, 100);
|
|
74
60
|
lines.push(` ${labelCol} ${bar(pct, barWidth)} ${pct}% left${suffix}`);
|
|
75
61
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
return {
|
|
63
|
+
id: `group-${index}`,
|
|
64
|
+
title: `→ ${formatGroupedHeader(group.group)}`,
|
|
65
|
+
blocks: [{ kind: "lines", lines }],
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const tokenSection = buildSessionTokenSectionModel(params.sessionTokens);
|
|
69
|
+
if (tokenSection) {
|
|
70
|
+
sections.push({
|
|
71
|
+
id: "session-tokens",
|
|
72
|
+
title: tokenSection.heading,
|
|
73
|
+
blocks: [{ kind: "lines", lines: tokenSection.lines }],
|
|
74
|
+
});
|
|
82
75
|
}
|
|
83
76
|
if (params.errors.length > 0) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
sections.push({
|
|
78
|
+
id: "errors",
|
|
79
|
+
blocks: [
|
|
80
|
+
{
|
|
81
|
+
kind: "lines",
|
|
82
|
+
lines: params.errors.map((err) => `${err.label}: ${err.message}`),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
});
|
|
88
86
|
}
|
|
89
|
-
return
|
|
87
|
+
return {
|
|
88
|
+
heading: {
|
|
89
|
+
title: "Quota (/quota)",
|
|
90
|
+
generatedAtMs: params.generatedAtMs,
|
|
91
|
+
},
|
|
92
|
+
sections,
|
|
93
|
+
};
|
|
90
94
|
}
|
|
91
95
|
export function formatQuotaCommand(params) {
|
|
92
|
-
|
|
93
|
-
title: "Quota (/quota)",
|
|
94
|
-
generatedAtMs: params.generatedAtMs,
|
|
95
|
-
});
|
|
96
|
-
const body = formatQuotaCommandBody(params);
|
|
97
|
-
return body.length > 0 ? `${heading}\n\n${body}` : heading;
|
|
96
|
+
return renderPlainTextReport(buildQuotaCommandDocument(params));
|
|
98
97
|
}
|
|
99
98
|
//# sourceMappingURL=quota-command-format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-command-format.js","sourceRoot":"","sources":["../../src/lib/quota-command-format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"quota-command-format.js","sourceRoot":"","sources":["../../src/lib/quota-command-format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAA2C,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAAE,6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AAO,qBAAqB,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-stats-format.d.ts","sourceRoot":"","sources":["../../src/lib/quota-stats-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAgB,MAAM,kBAAkB,CAAC;AAcvF,KAAK,oBAAoB,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;AA8GpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mGAAmG;IACnG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,WAAW,CAAC,EAAE;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,eAAe,EAAE,CAAC;KAC1B,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"quota-stats-format.d.ts","sourceRoot":"","sources":["../../src/lib/quota-stats-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAgB,MAAM,kBAAkB,CAAC;AAcvF,KAAK,oBAAoB,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;AA8GpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mGAAmG;IACnG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,WAAW,CAAC,EAAE;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,eAAe,EAAE,CAAC;KAC1B,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,CAuTT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { renderMarkdownTable } from "./markdown-table.js";
|
|
1
|
+
import { renderMarkdownReport } from "./report-document.js";
|
|
3
2
|
import { emptyTokenBuckets, totalTokenBuckets } from "./token-buckets.js";
|
|
4
3
|
/** Use markdown-conceal for proper TUI alignment (strips markdown syntax for width calc) */
|
|
5
4
|
const TABLE_WIDTH_MODE = "markdown-conceal";
|
|
@@ -140,57 +139,70 @@ export function formatQuotaStatsReport(params) {
|
|
|
140
139
|
const combinedTokens = totalTokenBuckets(r.totals.priced) +
|
|
141
140
|
totalTokenBuckets(r.totals.unknown) +
|
|
142
141
|
totalTokenBuckets(r.totals.unpriced);
|
|
143
|
-
const
|
|
144
|
-
lines.push(renderCommandHeading({
|
|
145
|
-
title: params.title,
|
|
146
|
-
generatedAtMs: params.generatedAtMs,
|
|
147
|
-
}));
|
|
148
|
-
lines.push("");
|
|
142
|
+
const sections = [];
|
|
149
143
|
// Session-scoped reports use a compact summary without the time window column.
|
|
150
144
|
if (sessionOnly) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
sections.push({
|
|
146
|
+
id: "summary",
|
|
147
|
+
blocks: [
|
|
148
|
+
{
|
|
149
|
+
kind: "table",
|
|
150
|
+
headers: ["Messages", "Tokens", "Cost"],
|
|
151
|
+
aligns: ["right", "right", "right"],
|
|
152
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
153
|
+
rows: [
|
|
154
|
+
[
|
|
155
|
+
fmtCompact(r.totals.messageCount),
|
|
156
|
+
fmtCompact(combinedTokens),
|
|
157
|
+
fmtUsd(r.totals.costUsd),
|
|
158
|
+
],
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
161
|
],
|
|
162
|
-
})
|
|
162
|
+
});
|
|
163
163
|
}
|
|
164
164
|
else if (sessionTreeMode) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
165
|
+
sections.push({
|
|
166
|
+
id: "summary",
|
|
167
|
+
blocks: [
|
|
168
|
+
{
|
|
169
|
+
kind: "table",
|
|
170
|
+
headers: ["Messages", "Sessions", "Tokens", "Cost"],
|
|
171
|
+
aligns: ["right", "right", "right", "right"],
|
|
172
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
173
|
+
rows: [
|
|
174
|
+
[
|
|
175
|
+
fmtCompact(r.totals.messageCount),
|
|
176
|
+
fmtCompact(sessionTree.nodes.length),
|
|
177
|
+
fmtCompact(combinedTokens),
|
|
178
|
+
fmtUsd(r.totals.costUsd),
|
|
179
|
+
],
|
|
180
|
+
],
|
|
181
|
+
},
|
|
176
182
|
],
|
|
177
|
-
})
|
|
183
|
+
});
|
|
178
184
|
}
|
|
179
185
|
else {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
sections.push({
|
|
187
|
+
id: "summary",
|
|
188
|
+
blocks: [
|
|
189
|
+
{
|
|
190
|
+
kind: "table",
|
|
191
|
+
headers: ["Window", "Messages", "Sessions", "Tokens", "Cost"],
|
|
192
|
+
aligns: ["left", "right", "right", "right", "right"],
|
|
193
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
194
|
+
rows: [
|
|
195
|
+
[
|
|
196
|
+
fmtWindow(r.window),
|
|
197
|
+
fmtCompact(r.totals.messageCount),
|
|
198
|
+
fmtCompact(r.totals.sessionCount),
|
|
199
|
+
fmtCompact(combinedTokens),
|
|
200
|
+
fmtUsd(r.totals.costUsd),
|
|
201
|
+
],
|
|
202
|
+
],
|
|
203
|
+
},
|
|
192
204
|
],
|
|
193
|
-
})
|
|
205
|
+
});
|
|
194
206
|
}
|
|
195
207
|
const hasAnyReasoning = r.totals.priced.reasoning > 0 ||
|
|
196
208
|
r.totals.unknown.reasoning > 0 ||
|
|
@@ -245,15 +257,21 @@ export function formatQuotaStatsReport(params) {
|
|
|
245
257
|
}
|
|
246
258
|
}
|
|
247
259
|
if (rows.length > 0) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
260
|
+
sections.push({
|
|
261
|
+
id: "models",
|
|
262
|
+
title: "Models",
|
|
263
|
+
blocks: [
|
|
264
|
+
{
|
|
265
|
+
kind: "table",
|
|
266
|
+
headers,
|
|
267
|
+
rows,
|
|
268
|
+
aligns,
|
|
269
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
});
|
|
252
273
|
}
|
|
253
274
|
if (sessionTreeMode) {
|
|
254
|
-
lines.push("");
|
|
255
|
-
lines.push(`## Session Tree`);
|
|
256
|
-
lines.push("");
|
|
257
275
|
const sessionUsageByID = new Map(r.bySession.map((row) => [row.sessionID, row]));
|
|
258
276
|
const sessionTreeRows = sessionTree.nodes.map((node) => {
|
|
259
277
|
const usage = sessionUsageByID.get(node.sessionID);
|
|
@@ -267,18 +285,22 @@ export function formatQuotaStatsReport(params) {
|
|
|
267
285
|
truncateTitle(node.title ?? usage?.title),
|
|
268
286
|
];
|
|
269
287
|
});
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
288
|
+
sections.push({
|
|
289
|
+
id: "session-tree",
|
|
290
|
+
title: "Session Tree",
|
|
291
|
+
blocks: [
|
|
292
|
+
{
|
|
293
|
+
kind: "table",
|
|
294
|
+
headers: ["Relation", "Parent", "Session", "Cost", "Tokens", "Msgs", "Title"],
|
|
295
|
+
aligns: ["left", "left", "left", "right", "right", "right", "left"],
|
|
296
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
297
|
+
rows: sessionTreeRows,
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
});
|
|
276
301
|
}
|
|
277
302
|
// Skip Top Sessions for session-scoped reports (e.g., /tokens_session, /tokens_session_all).
|
|
278
303
|
if (reportKind === "standard") {
|
|
279
|
-
lines.push("");
|
|
280
|
-
lines.push(`## Top Sessions`);
|
|
281
|
-
lines.push("");
|
|
282
304
|
const sessionRows = [];
|
|
283
305
|
const visibleSessions = r.bySession.filter(hasRenderableSessionUsage);
|
|
284
306
|
const focus = params.focusSessionID
|
|
@@ -307,71 +329,92 @@ export function formatQuotaStatsReport(params) {
|
|
|
307
329
|
appendSessionRow(sessionRows, row);
|
|
308
330
|
}
|
|
309
331
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
332
|
+
sections.push({
|
|
333
|
+
id: "top-sessions",
|
|
334
|
+
title: "Top Sessions",
|
|
335
|
+
blocks: sessionRows.length > 0
|
|
336
|
+
? [
|
|
337
|
+
{
|
|
338
|
+
kind: "table",
|
|
339
|
+
headers: ["Current", "Session", "Cost", "Tokens", "Msgs", "Title"],
|
|
340
|
+
aligns: ["left", "left", "right", "right", "right", "left"],
|
|
341
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
342
|
+
rows: sessionRows,
|
|
343
|
+
},
|
|
344
|
+
]
|
|
345
|
+
: [{ kind: "lines", lines: ["(no sessions)"] }],
|
|
346
|
+
});
|
|
321
347
|
}
|
|
322
348
|
if (r.unpriced.length > 0) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
349
|
+
sections.push({
|
|
350
|
+
id: "unpriced-models",
|
|
351
|
+
title: "Unpriced Models",
|
|
352
|
+
blocks: [
|
|
353
|
+
{
|
|
354
|
+
kind: "table",
|
|
355
|
+
headers: ["Source", "Model", "Mapped", "Reason", "Tokens", "Msgs"],
|
|
356
|
+
aligns: ["left", "left", "left", "left", "right", "right"],
|
|
357
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
358
|
+
rows: r.unpriced.slice(0, 20).map((u) => {
|
|
359
|
+
const mapped = `${u.key.mappedProvider}/${u.key.mappedModel}`;
|
|
360
|
+
return [
|
|
361
|
+
normalizeSourceName(u.key.sourceProviderID),
|
|
362
|
+
u.key.sourceModelID,
|
|
363
|
+
mapped,
|
|
364
|
+
u.key.reason,
|
|
365
|
+
fmtCompact(totalTokenBuckets(u.tokens)),
|
|
366
|
+
fmtCompact(u.messageCount),
|
|
367
|
+
];
|
|
368
|
+
}),
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
});
|
|
342
372
|
}
|
|
343
373
|
if (r.unknown.length > 0) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
sections.push({
|
|
375
|
+
id: "unknown-pricing",
|
|
376
|
+
title: "Unknown Pricing",
|
|
377
|
+
blocks: [
|
|
378
|
+
{
|
|
379
|
+
kind: "table",
|
|
380
|
+
headers: ["Source", "Model", "Mapped", "Tokens", "Msgs"],
|
|
381
|
+
aligns: ["left", "left", "left", "right", "right"],
|
|
382
|
+
widthMode: TABLE_WIDTH_MODE,
|
|
383
|
+
rows: r.unknown.slice(0, 20).map((u) => {
|
|
384
|
+
const mappedBase = u.key.mappedProvider && u.key.mappedModel
|
|
385
|
+
? `${u.key.mappedProvider}/${u.key.mappedModel}`
|
|
386
|
+
: "-";
|
|
387
|
+
const candidateSuffix = u.key.providerCandidates && u.key.providerCandidates.length > 0
|
|
388
|
+
? `candidates: ${u.key.providerCandidates.join(",")}`
|
|
389
|
+
: "";
|
|
390
|
+
const mapped = candidateSuffix.length > 0
|
|
391
|
+
? mappedBase === "-"
|
|
392
|
+
? candidateSuffix
|
|
393
|
+
: `${mappedBase} (${candidateSuffix})`
|
|
394
|
+
: mappedBase;
|
|
395
|
+
return [
|
|
396
|
+
normalizeSourceName(u.key.sourceProviderID),
|
|
397
|
+
u.key.sourceModelID,
|
|
398
|
+
mapped,
|
|
399
|
+
fmtCompact(totalTokenBuckets(u.tokens)),
|
|
400
|
+
fmtCompact(u.messageCount),
|
|
401
|
+
];
|
|
402
|
+
}),
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
kind: "lines",
|
|
406
|
+
lines: ["Run /quota_status to see the full pricing diagnostics report."],
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
});
|
|
374
410
|
}
|
|
375
|
-
|
|
411
|
+
const document = {
|
|
412
|
+
heading: {
|
|
413
|
+
title: params.title,
|
|
414
|
+
generatedAtMs: params.generatedAtMs,
|
|
415
|
+
},
|
|
416
|
+
sections,
|
|
417
|
+
};
|
|
418
|
+
return renderMarkdownReport(document);
|
|
376
419
|
}
|
|
377
420
|
//# sourceMappingURL=quota-stats-format.js.map
|