quotacap 0.0.57 → 0.0.58
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/cli/advise.js +3 -2
- package/dist/format/markdown.d.ts +1 -1
- package/dist/format/markdown.js +8 -5
- package/dist/format/rate-limit-wait.d.ts +38 -0
- package/dist/format/rate-limit-wait.js +104 -0
- package/dist/format/rows.d.ts +6 -0
- package/dist/format/rows.js +2 -0
- package/dist/format/terminal.d.ts +1 -1
- package/dist/format/terminal.js +18 -5
- package/dist/mcp/server.js +3 -2
- package/dist/version.js +1 -1
- package/dist/web/src/components/ProviderCard.js +2 -1
- package/dist/web/src/components/ProviderDrawer.js +2 -1
- package/dist/web/src/components/ProviderRow.js +2 -1
- package/dist/web/src/components/RateLimitNote.d.ts +7 -0
- package/dist/web/src/components/RateLimitNote.js +11 -0
- package/dist/webAssets.js +1 -1
- package/dist/webHtml.js +1 -1
- package/package.json +1 -1
- package/web/dist/assets/index-CnAonL1R.css +1 -0
- package/web/dist/assets/index-DGCyW-uy.js +13 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BFBVZ1r_.js +0 -13
- package/web/dist/assets/index-Co33DTl5.css +0 -1
package/dist/cli/advise.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { projectRecommendationResponse } from "../advisory/snapshot.js";
|
|
2
|
+
import { renderRecommendationSummary } from "../format/markdown.js";
|
|
2
3
|
import { validateTask } from "../advisory/validate.js";
|
|
3
4
|
import { ensureConfig, getDbPath } from "../config.js";
|
|
4
5
|
import { createServiceClient } from "../runtime/client.js";
|
|
@@ -128,7 +129,7 @@ export function registerAdviseCommand(program, deps) {
|
|
|
128
129
|
if (o.json)
|
|
129
130
|
console.log(JSON.stringify(rec, null, 2));
|
|
130
131
|
else {
|
|
131
|
-
console.log(
|
|
132
|
+
console.log(renderRecommendationSummary(emptySnapshot(t, cfg.providerNames), t));
|
|
132
133
|
printVersionLine(o, VERSION, health?.version);
|
|
133
134
|
printUpdateFooter(o, footer);
|
|
134
135
|
}
|
|
@@ -144,7 +145,7 @@ export function registerAdviseCommand(program, deps) {
|
|
|
144
145
|
if (o.json)
|
|
145
146
|
console.log(JSON.stringify(rec, null, 2));
|
|
146
147
|
else {
|
|
147
|
-
console.log(
|
|
148
|
+
console.log(renderRecommendationSummary(resolved.snapshot, t));
|
|
148
149
|
const modelsLine = formatModelsLine(rec, t, cfg.catalogTtlHours);
|
|
149
150
|
if (modelsLine)
|
|
150
151
|
console.log(modelsLine);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { StateSnapshot } from "../advisory/types.js";
|
|
2
2
|
export declare function renderMarkdownTable(snapshot: StateSnapshot, now: Date): string;
|
|
3
|
-
export declare function renderRecommendationSummary(snapshot: StateSnapshot): string;
|
|
3
|
+
export declare function renderRecommendationSummary(snapshot: StateSnapshot, now?: Date): string;
|
|
4
4
|
export declare function renderModelsMarkdownTable(models: any[]): string;
|
package/dist/format/markdown.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rateLimitWaitLines } from "./rate-limit-wait.js";
|
|
1
2
|
import { buildRow, sortProviders } from "./rows.js";
|
|
2
3
|
function esc(cell) {
|
|
3
4
|
return cell.replace(/\|/g, "\\|").replace(/[\r\n]+/g, " ");
|
|
@@ -10,17 +11,19 @@ export function renderMarkdownTable(snapshot, now) {
|
|
|
10
11
|
const name = p.id === use && use !== "none" ? `★ ${p.displayName}` : p.displayName;
|
|
11
12
|
const used = row.usedPct === null ? "—" : `${row.usedPct}%`;
|
|
12
13
|
const elapsed = row.elapsedPct === null ? "—" : `${row.elapsedPct}%`;
|
|
13
|
-
|
|
14
|
+
const wait = row.wait === "" ? "—" : row.wait;
|
|
15
|
+
return `| ${esc(name)} | ${used} | ${elapsed} | ${esc(row.pace)} | ${esc(row.countdown)} | ${esc(row.state)} | ${esc(row.forecast)} | ${esc(wait)} |`;
|
|
14
16
|
});
|
|
15
17
|
return [
|
|
16
|
-
"| Provider | Used | Elapsed | Pace (%/day avg · 24h) | Resets | State | Forecast |",
|
|
17
|
-
"
|
|
18
|
+
"| Provider | Used | Elapsed | Pace (%/day avg · 24h) | Resets | State | Forecast | Wait |",
|
|
19
|
+
"|---|---|---|---|---|---|---|---|",
|
|
18
20
|
...lines,
|
|
19
21
|
].join("\n");
|
|
20
22
|
}
|
|
21
|
-
export function renderRecommendationSummary(snapshot) {
|
|
23
|
+
export function renderRecommendationSummary(snapshot, now = new Date(snapshot.asOf)) {
|
|
22
24
|
const rec = snapshot.recommendation;
|
|
23
|
-
|
|
25
|
+
const waits = rateLimitWaitLines(snapshot.providers, now);
|
|
26
|
+
return [`${rec.use}: ${rec.reason}`, ...waits].join("\n");
|
|
24
27
|
}
|
|
25
28
|
export function renderModelsMarkdownTable(models) {
|
|
26
29
|
const lines = models.map((m) => {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type RateLimitWindow = "five-hour" | "weekly";
|
|
2
|
+
export interface RateLimitWait {
|
|
3
|
+
window: RateLimitWindow;
|
|
4
|
+
label: "5h limit" | "Weekly limit";
|
|
5
|
+
/** Reported finish instant. Null when the provider did not report one. */
|
|
6
|
+
resetsAt: string | null;
|
|
7
|
+
/** Local date and 24-hour time, e.g. "Thu Oct 23 18:59". */
|
|
8
|
+
until: string | null;
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RateLimitSource {
|
|
12
|
+
exclusionReason?: string | null;
|
|
13
|
+
quota?: {
|
|
14
|
+
weeklyPct?: number | null;
|
|
15
|
+
resetsAt?: string | null;
|
|
16
|
+
fiveHourPct?: number | null;
|
|
17
|
+
/** One-release alias for fiveHourPct. */
|
|
18
|
+
sessionPct?: number | null;
|
|
19
|
+
fiveHourResetsAt?: string | null;
|
|
20
|
+
monthlyPct?: number | null;
|
|
21
|
+
monthlyResetsAt?: string | null;
|
|
22
|
+
monthlyStatus?: "ok" | "exhausted" | null;
|
|
23
|
+
monthlyKind?: "included" | null;
|
|
24
|
+
} | null;
|
|
25
|
+
}
|
|
26
|
+
/** Weekday, calendar date, and 24-hour clock in the locked English copy. */
|
|
27
|
+
export declare function limitStamp(iso: string): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Short windows that are full while the reset-window quota still has room.
|
|
30
|
+
* A 5h window on any plan, and the week on a plan whose quota resets monthly.
|
|
31
|
+
* A full week on a weekly plan is the quota itself, so it stays with the
|
|
32
|
+
* quota badge. An exhausted included month already blocks the provider.
|
|
33
|
+
*/
|
|
34
|
+
export declare function rateLimitWaits(source: RateLimitSource, now: Date): RateLimitWait[];
|
|
35
|
+
/** One sentence per provider that has a short window to wait out. Snapshot order. */
|
|
36
|
+
export declare function rateLimitWaitLines(providers: Array<RateLimitSource & {
|
|
37
|
+
displayName: string;
|
|
38
|
+
}>, now: Date): string[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// A full short window the user has to wait out. Presentation only:
|
|
2
|
+
// pace, forecast, and which provider to use next stay on the reset window.
|
|
3
|
+
function part(when, options, type) {
|
|
4
|
+
return new Intl.DateTimeFormat("en-US", options).formatToParts(when).find((p) => p.type === type)?.value ?? "";
|
|
5
|
+
}
|
|
6
|
+
/** Weekday, calendar date, and 24-hour clock in the locked English copy. */
|
|
7
|
+
export function limitStamp(iso) {
|
|
8
|
+
const ms = Date.parse(iso);
|
|
9
|
+
if (!Number.isFinite(ms))
|
|
10
|
+
return null;
|
|
11
|
+
const when = new Date(ms);
|
|
12
|
+
const weekday = part(when, { weekday: "short" }, "weekday");
|
|
13
|
+
const month = part(when, { month: "short" }, "month");
|
|
14
|
+
const day = part(when, { day: "numeric" }, "day");
|
|
15
|
+
const time = new Intl.DateTimeFormat("en-US", {
|
|
16
|
+
hour: "2-digit",
|
|
17
|
+
minute: "2-digit",
|
|
18
|
+
hourCycle: "h23",
|
|
19
|
+
}).formatToParts(when);
|
|
20
|
+
const hour = time.find((p) => p.type === "hour")?.value ?? "";
|
|
21
|
+
const minute = time.find((p) => p.type === "minute")?.value ?? "";
|
|
22
|
+
if (!weekday || !month || !day || !hour || !minute)
|
|
23
|
+
return null;
|
|
24
|
+
return `${weekday} ${month} ${day} ${hour.padStart(2, "0")}:${minute.padStart(2, "0")}`;
|
|
25
|
+
}
|
|
26
|
+
function instant(iso) {
|
|
27
|
+
if (!iso)
|
|
28
|
+
return null;
|
|
29
|
+
const ms = Date.parse(iso);
|
|
30
|
+
return Number.isFinite(ms) ? ms : null;
|
|
31
|
+
}
|
|
32
|
+
/** True when the window has not been reported as already finished. */
|
|
33
|
+
function stillOpen(iso, nowMs) {
|
|
34
|
+
const ms = instant(iso);
|
|
35
|
+
return ms === null || ms > nowMs;
|
|
36
|
+
}
|
|
37
|
+
function includedMonth(q) {
|
|
38
|
+
return q.monthlyKind === "included" && typeof q.monthlyPct === "number" && !!q.monthlyResetsAt;
|
|
39
|
+
}
|
|
40
|
+
function monthExhausted(q) {
|
|
41
|
+
return q.monthlyStatus === "exhausted" || (typeof q.monthlyPct === "number" && q.monthlyPct >= 100);
|
|
42
|
+
}
|
|
43
|
+
function waitFor(window, label, iso) {
|
|
44
|
+
const resetsAt = instant(iso) === null ? null : iso ?? null;
|
|
45
|
+
const until = resetsAt ? limitStamp(resetsAt) : null;
|
|
46
|
+
return {
|
|
47
|
+
window,
|
|
48
|
+
label,
|
|
49
|
+
resetsAt,
|
|
50
|
+
until,
|
|
51
|
+
text: until ? `${label} until ${until}` : `${label} reached`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Short windows that are full while the reset-window quota still has room.
|
|
56
|
+
* A 5h window on any plan, and the week on a plan whose quota resets monthly.
|
|
57
|
+
* A full week on a weekly plan is the quota itself, so it stays with the
|
|
58
|
+
* quota badge. An exhausted included month already blocks the provider.
|
|
59
|
+
*/
|
|
60
|
+
export function rateLimitWaits(source, now) {
|
|
61
|
+
if (source.exclusionReason)
|
|
62
|
+
return [];
|
|
63
|
+
const q = source.quota;
|
|
64
|
+
if (!q)
|
|
65
|
+
return [];
|
|
66
|
+
const nowMs = now.getTime();
|
|
67
|
+
const monthly = includedMonth(q);
|
|
68
|
+
if (monthly && monthExhausted(q))
|
|
69
|
+
return [];
|
|
70
|
+
const weekFull = typeof q.weeklyPct === "number" && q.weeklyPct >= 100;
|
|
71
|
+
if (!monthly && weekFull)
|
|
72
|
+
return [];
|
|
73
|
+
const waits = [];
|
|
74
|
+
const five = q.fiveHourPct ?? q.sessionPct;
|
|
75
|
+
if (typeof five === "number" && five >= 100 && stillOpen(q.fiveHourResetsAt, nowMs)) {
|
|
76
|
+
waits.push(waitFor("five-hour", "5h limit", q.fiveHourResetsAt));
|
|
77
|
+
}
|
|
78
|
+
if (monthly && weekFull && stillOpen(q.resetsAt, nowMs)) {
|
|
79
|
+
waits.push(waitFor("weekly", "Weekly limit", q.resetsAt));
|
|
80
|
+
}
|
|
81
|
+
waits.sort((a, b) => {
|
|
82
|
+
const am = instant(a.resetsAt);
|
|
83
|
+
const bm = instant(b.resetsAt);
|
|
84
|
+
if (am === null && bm === null)
|
|
85
|
+
return 0;
|
|
86
|
+
if (am === null)
|
|
87
|
+
return 1;
|
|
88
|
+
if (bm === null)
|
|
89
|
+
return -1;
|
|
90
|
+
return am - bm;
|
|
91
|
+
});
|
|
92
|
+
return waits;
|
|
93
|
+
}
|
|
94
|
+
/** One sentence per provider that has a short window to wait out. Snapshot order. */
|
|
95
|
+
export function rateLimitWaitLines(providers, now) {
|
|
96
|
+
const lines = [];
|
|
97
|
+
for (const provider of providers) {
|
|
98
|
+
const waits = rateLimitWaits(provider, now);
|
|
99
|
+
if (waits.length === 0)
|
|
100
|
+
continue;
|
|
101
|
+
lines.push(`${provider.displayName}: ${waits.map((w) => w.text).join(" · ")}`);
|
|
102
|
+
}
|
|
103
|
+
return lines;
|
|
104
|
+
}
|
package/dist/format/rows.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export interface Row {
|
|
|
13
13
|
railCells: RailCell[];
|
|
14
14
|
/** Compact pace pair without units, e.g. "10.6 avg · 0.0 24h". Surfaces label %/day once. */
|
|
15
15
|
pace: string;
|
|
16
|
+
/**
|
|
17
|
+
* Full short window the user has to wait out, with the date and time it
|
|
18
|
+
* clears. Empty when the reset-window quota is the block, or no short
|
|
19
|
+
* window is full. Never changes `state` or `forecast`.
|
|
20
|
+
*/
|
|
21
|
+
wait: string;
|
|
16
22
|
}
|
|
17
23
|
export declare const RAIL_CELLS = 20;
|
|
18
24
|
export declare const SORT_KEYS: SortKey[];
|
package/dist/format/rows.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rateLimitWaits } from "./rate-limit-wait.js";
|
|
1
2
|
export const RAIL_CELLS = 20;
|
|
2
3
|
export const SORT_KEYS = ["recommended", "reset-asc", "reset-desc", "used-desc", "used-asc"];
|
|
3
4
|
const DAY_MS = 86400000;
|
|
@@ -404,5 +405,6 @@ export function buildRow(ps, now) {
|
|
|
404
405
|
usedPct: usedPctOf(ps),
|
|
405
406
|
railCells: railCells(ps, now),
|
|
406
407
|
pace: paceText(ps, now),
|
|
408
|
+
wait: rateLimitWaits(ps, now).map((w) => w.text).join(" · "),
|
|
407
409
|
};
|
|
408
410
|
}
|
|
@@ -9,4 +9,4 @@ export interface RenderOptions {
|
|
|
9
9
|
export declare function provWidthFor(ids: string[]): number;
|
|
10
10
|
export declare function renderWide(snapshot: StateSnapshot, opts: RenderOptions): string;
|
|
11
11
|
export declare function renderNarrow(snapshot: StateSnapshot, opts: RenderOptions): string;
|
|
12
|
-
export declare function renderCompact(snapshot: StateSnapshot,
|
|
12
|
+
export declare function renderCompact(snapshot: StateSnapshot, now?: Date): string;
|
package/dist/format/terminal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildRow, compactSuffix, isMonthlyBound, sortProviders, weeklyPctOf, } from "./rows.js";
|
|
2
|
+
import { rateLimitWaits } from "./rate-limit-wait.js";
|
|
2
3
|
const GAP = " ";
|
|
3
4
|
const MIN_PROV_WIDTH = 12;
|
|
4
5
|
const MAX_PROV_WIDTH = 22;
|
|
@@ -108,6 +109,9 @@ export function renderWide(snapshot, opts) {
|
|
|
108
109
|
const countdown = (opts.ascii ? asciiText(row.countdown) : row.countdown).padEnd(9);
|
|
109
110
|
const state = row.state.padEnd(19);
|
|
110
111
|
const forecast = opts.ascii ? asciiText(row.forecast) : row.forecast;
|
|
112
|
+
const wait = row.wait
|
|
113
|
+
? `${GAP}${opts.ascii ? "-" : "·"}${GAP}${paint(opts.ascii ? asciiText(row.wait) : row.wait, STATE_COLORS["Quota exhausted"])}`
|
|
114
|
+
: "";
|
|
111
115
|
const main = [
|
|
112
116
|
color ? colorProviderField(name, recommended, row.state) : name,
|
|
113
117
|
used,
|
|
@@ -116,7 +120,7 @@ export function renderWide(snapshot, opts) {
|
|
|
116
120
|
rail,
|
|
117
121
|
countdown,
|
|
118
122
|
paint(state, STATE_COLORS[row.state]),
|
|
119
|
-
forecast,
|
|
123
|
+
forecast + wait,
|
|
120
124
|
].join(GAP);
|
|
121
125
|
const leftover = leftoverLine(p);
|
|
122
126
|
return leftover ? `${main}\n${leftover}` : main;
|
|
@@ -142,7 +146,10 @@ export function renderNarrow(snapshot, opts) {
|
|
|
142
146
|
const pace = opts.ascii ? asciiText(row.pace) : row.pace;
|
|
143
147
|
const paceBits = row.pace === "—" ? pace : `${pace} %/day`;
|
|
144
148
|
const state = color ? `${STATE_COLORS[row.state]}${row.state}${RESET}` : row.state;
|
|
145
|
-
|
|
149
|
+
const wait = row.wait
|
|
150
|
+
? ` ${g.sep} ${color ? `${STATE_COLORS["Quota exhausted"]}${opts.ascii ? asciiText(row.wait) : row.wait}${RESET}` : opts.ascii ? asciiText(row.wait) : row.wait}`
|
|
151
|
+
: "";
|
|
152
|
+
lines.push(`${color ? colorProviderField(name, recommended, row.state) : name} ${used} used ${g.sep} ${elapsed} elapsed ${g.sep} ${paceBits}`, `${rail} resets ${countdown} ${g.sep} ${state} ${g.sep} ${forecast}${wait}`);
|
|
146
153
|
const close = p.lastCloses?.[0];
|
|
147
154
|
if (close) {
|
|
148
155
|
const indent = " ".repeat(row.railCells.length + " resets ".length);
|
|
@@ -155,8 +162,7 @@ export function renderNarrow(snapshot, opts) {
|
|
|
155
162
|
}
|
|
156
163
|
// Always ASCII, never ANSI, even on a TTY: prompt-safe by construction.
|
|
157
164
|
// Takes the fixed clock for signature parity; compact shows no ages.
|
|
158
|
-
export function renderCompact(snapshot,
|
|
159
|
-
void _now;
|
|
165
|
+
export function renderCompact(snapshot, now = new Date()) {
|
|
160
166
|
const use = snapshot.recommendation.use;
|
|
161
167
|
const sorted = sortProviders(snapshot.providers, "recommended", use);
|
|
162
168
|
const entries = sorted
|
|
@@ -168,5 +174,12 @@ export function renderCompact(snapshot, _now) {
|
|
|
168
174
|
});
|
|
169
175
|
if (entries.length === 0)
|
|
170
176
|
return "(use: none)";
|
|
171
|
-
|
|
177
|
+
const waits = sorted.flatMap((p) => {
|
|
178
|
+
const found = rateLimitWaits(p, now);
|
|
179
|
+
if (found.length === 0)
|
|
180
|
+
return [];
|
|
181
|
+
return [`${p.id} ${found.map((w) => w.text).join(", ")}`];
|
|
182
|
+
});
|
|
183
|
+
const base = `${entries.join(" | ")} (use: ${use})`;
|
|
184
|
+
return waits.length === 0 ? base : `${base} (wait: ${waits.join("; ")})`;
|
|
172
185
|
}
|
package/dist/mcp/server.js
CHANGED
|
@@ -10,7 +10,7 @@ import { VERSION } from "../version.js";
|
|
|
10
10
|
import { ClientError, OFFLINE_LABEL, resolveSnapshot, } from "../cli/snapshot-source.js";
|
|
11
11
|
export const tools = [
|
|
12
12
|
{ name: "get_quotas", description: "All quotas with resets and health", inputSchema: { type: "object", properties: {}, required: [] } },
|
|
13
|
-
{ name: "get_recommendation", description: "Which provider to use next (same advice for every task)", inputSchema: { type: "object", properties: { task: { type: "string", enum: ["any", "heavy", "light"] } } } },
|
|
13
|
+
{ name: "get_recommendation", description: "Which provider to use next (same advice for every task). Also names a full 5h limit or a full week on a monthly plan, and when that limit clears.", inputSchema: { type: "object", properties: { task: { type: "string", enum: ["any", "heavy", "light"] } } } },
|
|
14
14
|
{ name: "get_models", description: "Currently listed models per quota bucket (inventory, not a task ranking)", inputSchema: { type: "object", properties: { provider: { type: "string" } } } },
|
|
15
15
|
{ name: "forecast", description: "Burn (24h + window avg) vs ideal + waste for a provider", inputSchema: { type: "object", properties: { provider: { type: "string" } }, required: ["provider"] } },
|
|
16
16
|
];
|
|
@@ -67,9 +67,10 @@ export async function handleTool(name, args) {
|
|
|
67
67
|
const { snapshot, source } = await resolveState();
|
|
68
68
|
if (source === "offline")
|
|
69
69
|
console.error(OFFLINE_LABEL);
|
|
70
|
+
const now = new Date();
|
|
70
71
|
return {
|
|
71
72
|
content: [
|
|
72
|
-
{ type: "text", text: renderRecommendationSummary(snapshot) },
|
|
73
|
+
{ type: "text", text: renderRecommendationSummary(snapshot, now) },
|
|
73
74
|
{ type: "text", text: JSON.stringify(projectRecommendationResponse(snapshot, task), null, 2) },
|
|
74
75
|
],
|
|
75
76
|
};
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by scripts/build-embed.mjs — do not edit
|
|
2
|
-
export const VERSION = "0.0.
|
|
2
|
+
export const VERSION = "0.0.58";
|
|
@@ -4,6 +4,7 @@ import { Badge, PaceBar, PaceStats, isMonthlyBound, quotaResetEstimated, quotaRe
|
|
|
4
4
|
import { ProviderIcon, providerTint } from "./ProviderIcon.js";
|
|
5
5
|
import { lastClose } from "./ClosedWeeks.js";
|
|
6
6
|
import { WindowsRow } from "./WindowsRow.js";
|
|
7
|
+
import { RateLimitNote } from "./RateLimitNote.js";
|
|
7
8
|
function resetsDate(provider) {
|
|
8
9
|
const resetIso = quotaResetsAt(provider);
|
|
9
10
|
if (!resetIso)
|
|
@@ -24,5 +25,5 @@ export function ProviderCard({ provider, recommended, asOf, onSelect, }) {
|
|
|
24
25
|
e.preventDefault();
|
|
25
26
|
onSelect(provider.id);
|
|
26
27
|
}
|
|
27
|
-
}, className: `pcard ${recommended ? "is-recommended is-top-pick" : ""}`, children: [_jsxs("div", { className: "pcard-head", children: [_jsx("span", { className: "picon", style: providerTint(provider.id), "aria-hidden": "true", children: _jsx(ProviderIcon, { id: provider.id, title: name }) }), _jsxs("div", { className: "who", children: [_jsxs("b", { children: [name, recommended && (_jsx("span", { className: "rec-icon", title: "Recommended for next session", role: "img", "aria-label": "recommended", children: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.3", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z" }) }) }))] }), updated && _jsxs("span", { className: "src", children: ["Updated ", updated, " ago"] })] }), _jsx(Badge, { provider: provider })] }), _jsxs("div", { className: "pcard-body", children: [_jsx(PaceBar, { provider: provider, asOf: asOf }), _jsx(WindowsRow, { provider: provider, asOf: asOf, variant: "card" }), _jsx(PaceStats, { provider: provider, asOf: asOf })] }), _jsxs("div", { className: "pcard-foot", children: [_jsxs("div", { className: "foot-meta", children: [_jsx("span", { children: resetsDate(provider) ?? resetCountdown(provider, asOfMs) }), last && (_jsxs("span", { className: "last-week", children: ["Last ", isMonthlyBound(provider) ? "month" : "week", " ", last.leftoverPct, "% leftover", last.resetsAtEstimated ? " (est.)" : ""] }))] }), _jsx("span", { className: "rowbtn", "aria-hidden": "true", children: "Inspect" })] })] }));
|
|
28
|
+
}, className: `pcard ${recommended ? "is-recommended is-top-pick" : ""}`, children: [_jsxs("div", { className: "pcard-head", children: [_jsx("span", { className: "picon", style: providerTint(provider.id), "aria-hidden": "true", children: _jsx(ProviderIcon, { id: provider.id, title: name }) }), _jsxs("div", { className: "who", children: [_jsxs("b", { children: [name, recommended && (_jsx("span", { className: "rec-icon", title: "Recommended for next session", role: "img", "aria-label": "recommended", children: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.3", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z" }) }) }))] }), updated && _jsxs("span", { className: "src", children: ["Updated ", updated, " ago"] })] }), _jsx(Badge, { provider: provider })] }), _jsxs("div", { className: "pcard-body", children: [_jsx(PaceBar, { provider: provider, asOf: asOf }), _jsx(RateLimitNote, { provider: provider, asOf: asOf }), _jsx(WindowsRow, { provider: provider, asOf: asOf, variant: "card" }), _jsx(PaceStats, { provider: provider, asOf: asOf })] }), _jsxs("div", { className: "pcard-foot", children: [_jsxs("div", { className: "foot-meta", children: [_jsx("span", { children: resetsDate(provider) ?? resetCountdown(provider, asOfMs) }), last && (_jsxs("span", { className: "last-week", children: ["Last ", isMonthlyBound(provider) ? "month" : "week", " ", last.leftoverPct, "% leftover", last.resetsAtEstimated ? " (est.)" : ""] }))] }), _jsx("span", { className: "rowbtn", "aria-hidden": "true", children: "Inspect" })] })] }));
|
|
28
29
|
}
|
|
@@ -6,6 +6,7 @@ import { ProviderIcon, providerTint } from "./ProviderIcon.js";
|
|
|
6
6
|
import { BurnDown } from "./BurnDown.js";
|
|
7
7
|
import { ClosedWeeks } from "./ClosedWeeks.js";
|
|
8
8
|
import { trackFillForPct } from "./WindowsRow.js";
|
|
9
|
+
import { RateLimitNote } from "./RateLimitNote.js";
|
|
9
10
|
import { laneOf } from "./Recommendation.js";
|
|
10
11
|
import { renameProvider } from "../api.js";
|
|
11
12
|
export function exclusionWords(reason) {
|
|
@@ -568,5 +569,5 @@ export function ProviderDrawer({ provider, asOf, recommendation, onClose, onRena
|
|
|
568
569
|
setIsEditing(false);
|
|
569
570
|
setNameDraft(provider.displayName);
|
|
570
571
|
setRenameError(null);
|
|
571
|
-
}, className: "btn btn-quiet btn-sm", style: { flex: "none" }, children: "Cancel" })] }), renameError && (_jsx("span", { style: { fontSize: "var(--t-2)", color: "var(--danger)" }, children: renameError }))] })), provider.builtinName && provider.displayName !== provider.builtinName && (_jsx("div", { className: "sub", style: { marginTop: "2px" }, "data-testid": "provider-builtin-name", children: `Built-in: ${provider.builtinName}` })), _jsx("span", { className: "sub", children: providerSubtitle(provider) ?? sub })] }), _jsx(Badge, { provider: provider, compact: true }), _jsx("button", { className: "drawer-close", type: "button", "aria-label": "Close provider details", onClick: onClose, children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M6 6l12 12M18 6L6 18" }) }) })] }), _jsxs("div", { className: `verdict ${verdict.tone}`, "data-testid": "drawer-verdict", children: [_jsx("b", { children: verdict.label }), verdict.detail && _jsx("span", { children: verdict.detail })] }), provider.description && _jsx("p", { className: "drawer-desc", children: provider.description }), notes.length > 0 && (_jsxs("section", { className: "dsec", "aria-label": "Notes", children: [_jsx("h3", { children: "Notes" }), _jsx("div", { className: "notes-list", children: notes.map((n) => (_jsxs("div", { className: "note", children: [_jsx("span", { className: `dot ${n.dot}`, "aria-hidden": "true" }), _jsx("span", { children: n.text })] }, n.key))) })] })), _jsxs("section", { className: "dsec", "aria-label": "Limits", children: [_jsx("h3", { children: "Limits" }), provider.quota ? (_jsxs(_Fragment, { children: [monthlyPrimary ? (_jsxs(_Fragment, { children: [monthlyRow, weeklyRow, fiveRow] })) : (_jsxs(_Fragment, { children: [weeklyRow, fiveRow, monthlyRow] })), (anyElapsed || weeklyHatchPct !== null) && (_jsxs("p", { className: "limit-legend", children: [_jsx("span", { className: "legend-label", children: "Legend" }), anyElapsed && (_jsxs("span", { className: "legend-item", children: [_jsx("span", { className: "legend-mark", "aria-hidden": "true" }), "Time elapsed"] })), weeklyHatchPct !== null && (_jsxs("span", { className: "legend-item", children: [_jsx("span", { className: "legend-hatch", "aria-hidden": "true" }), "Projected waste"] }))] }))] })) : (_jsx("p", { className: "cell-s", children: "No readings yet." }))] }), _jsx(BurnDown, { provider: provider, asOf: asOf, basis: paceBasisLine }), _jsx(ClosedWeeks, { closes: provider.lastCloses, windowName: quotaWindowName(provider) }), _jsxs("div", { className: "prov-foot", children: [footText, showCredential && _jsx("span", { className: "cred", children: credentialLabel(provider) })] })] })] }));
|
|
572
|
+
}, className: "btn btn-quiet btn-sm", style: { flex: "none" }, children: "Cancel" })] }), renameError && (_jsx("span", { style: { fontSize: "var(--t-2)", color: "var(--danger)" }, children: renameError }))] })), provider.builtinName && provider.displayName !== provider.builtinName && (_jsx("div", { className: "sub", style: { marginTop: "2px" }, "data-testid": "provider-builtin-name", children: `Built-in: ${provider.builtinName}` })), _jsx("span", { className: "sub", children: providerSubtitle(provider) ?? sub })] }), _jsx(Badge, { provider: provider, compact: true }), _jsx("button", { className: "drawer-close", type: "button", "aria-label": "Close provider details", onClick: onClose, children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M6 6l12 12M18 6L6 18" }) }) })] }), _jsxs("div", { className: `verdict ${verdict.tone}`, "data-testid": "drawer-verdict", children: [_jsx("b", { children: verdict.label }), verdict.detail && _jsx("span", { children: verdict.detail })] }), _jsx(RateLimitNote, { provider: provider, asOf: asOf }), provider.description && _jsx("p", { className: "drawer-desc", children: provider.description }), notes.length > 0 && (_jsxs("section", { className: "dsec", "aria-label": "Notes", children: [_jsx("h3", { children: "Notes" }), _jsx("div", { className: "notes-list", children: notes.map((n) => (_jsxs("div", { className: "note", children: [_jsx("span", { className: `dot ${n.dot}`, "aria-hidden": "true" }), _jsx("span", { children: n.text })] }, n.key))) })] })), _jsxs("section", { className: "dsec", "aria-label": "Limits", children: [_jsx("h3", { children: "Limits" }), provider.quota ? (_jsxs(_Fragment, { children: [monthlyPrimary ? (_jsxs(_Fragment, { children: [monthlyRow, weeklyRow, fiveRow] })) : (_jsxs(_Fragment, { children: [weeklyRow, fiveRow, monthlyRow] })), (anyElapsed || weeklyHatchPct !== null) && (_jsxs("p", { className: "limit-legend", children: [_jsx("span", { className: "legend-label", children: "Legend" }), anyElapsed && (_jsxs("span", { className: "legend-item", children: [_jsx("span", { className: "legend-mark", "aria-hidden": "true" }), "Time elapsed"] })), weeklyHatchPct !== null && (_jsxs("span", { className: "legend-item", children: [_jsx("span", { className: "legend-hatch", "aria-hidden": "true" }), "Projected waste"] }))] }))] })) : (_jsx("p", { className: "cell-s", children: "No readings yet." }))] }), _jsx(BurnDown, { provider: provider, asOf: asOf, basis: paceBasisLine }), _jsx(ClosedWeeks, { closes: provider.lastCloses, windowName: quotaWindowName(provider) }), _jsxs("div", { className: "prov-foot", children: [footText, showCredential && _jsx("span", { className: "cred", children: credentialLabel(provider) })] })] })] }));
|
|
572
573
|
}
|
|
@@ -2,6 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Badge, PaceBar, forecastLine, isMonthlyBound, paceLines, resetCellLines, } from "./PaceBar.js";
|
|
3
3
|
import { lastClose } from "./ClosedWeeks.js";
|
|
4
4
|
import { WindowsRow } from "./WindowsRow.js";
|
|
5
|
+
import { RateLimitNote } from "./RateLimitNote.js";
|
|
5
6
|
export function ProviderRow({ provider, recommended, asOf, onSelect, }) {
|
|
6
7
|
const quota = provider.quota;
|
|
7
8
|
const advisory = provider.advisory;
|
|
@@ -10,7 +11,7 @@ export function ProviderRow({ provider, recommended, asOf, onSelect, }) {
|
|
|
10
11
|
const name = provider.displayName;
|
|
11
12
|
const reset = resetCellLines(provider, asOfMs);
|
|
12
13
|
const last = lastClose(provider);
|
|
13
|
-
return (_jsxs("div", { "data-testid": `provider-row-${provider.id}`, className: `lrow ${recommended ? "is-recommended is-top-pick" : ""}`, onClick: () => onSelect(provider.id), children: [_jsxs("div", { className: "prov", "data-label": "Provider", children: [_jsx("span", { className: "dot", style: { background: `var(--p-${provider.id.split(":")[0]}, var(--surface-raised))` }, "aria-hidden": "true" }), _jsx("span", { children: _jsxs("span", { className: "nm", children: [name, recommended && (_jsx("span", { className: "rec-icon", title: "Recommended for next session", role: "img", "aria-label": "recommended", children: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.3", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z" }) }) }))] }) })] }), _jsx("div", { "data-label": "Used vs elapsed", children: quota ? (_jsxs(_Fragment, { children: [_jsx(PaceBar, { provider: provider, asOf: asOf }), _jsx(WindowsRow, { provider: provider, asOf: asOf, variant: "row" })] })) : "—" }), _jsxs("div", { "data-label": "Reset", className: "reset-cell", children: [_jsx("span", { className: "cell-b", children: reset.top }), reset.bottom && _jsx("span", { className: "cell-s", children: reset.bottom }), last && (_jsxs("span", { className: "cell-s", children: ["last ", isMonthlyBound(provider) ? "month" : "week", " ", last.leftoverPct, "% leftover", last.resetsAtEstimated ? " (est.)" : ""] }))] }), _jsxs("div", { "data-label": "Pace", children: [_jsx(Badge, { provider: provider }), lines.length > 0 && (_jsx("div", { style: { marginTop: 2 }, children: lines.map((l) => (_jsxs("div", { className: "cell-s paceline", title: l.tip, children: [_jsx("span", { children: l.label }), _jsx("span", { className: "cell-b", children: l.value })] }, l.label))) }))] }), _jsx("button", { type: "button", className: "rowbtn", onClick: (e) => {
|
|
14
|
+
return (_jsxs("div", { "data-testid": `provider-row-${provider.id}`, className: `lrow ${recommended ? "is-recommended is-top-pick" : ""}`, onClick: () => onSelect(provider.id), children: [_jsxs("div", { className: "prov", "data-label": "Provider", children: [_jsx("span", { className: "dot", style: { background: `var(--p-${provider.id.split(":")[0]}, var(--surface-raised))` }, "aria-hidden": "true" }), _jsx("span", { children: _jsxs("span", { className: "nm", children: [name, recommended && (_jsx("span", { className: "rec-icon", title: "Recommended for next session", role: "img", "aria-label": "recommended", children: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.3", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z" }) }) }))] }) })] }), _jsx("div", { "data-label": "Used vs elapsed", children: quota ? (_jsxs(_Fragment, { children: [_jsx(PaceBar, { provider: provider, asOf: asOf }), _jsx(RateLimitNote, { provider: provider, asOf: asOf }), _jsx(WindowsRow, { provider: provider, asOf: asOf, variant: "row" })] })) : "—" }), _jsxs("div", { "data-label": "Reset", className: "reset-cell", children: [_jsx("span", { className: "cell-b", children: reset.top }), reset.bottom && _jsx("span", { className: "cell-s", children: reset.bottom }), last && (_jsxs("span", { className: "cell-s", children: ["last ", isMonthlyBound(provider) ? "month" : "week", " ", last.leftoverPct, "% leftover", last.resetsAtEstimated ? " (est.)" : ""] }))] }), _jsxs("div", { "data-label": "Pace", children: [_jsx(Badge, { provider: provider }), lines.length > 0 && (_jsx("div", { style: { marginTop: 2 }, children: lines.map((l) => (_jsxs("div", { className: "cell-s paceline", title: l.tip, children: [_jsx("span", { children: l.label }), _jsx("span", { className: "cell-b", children: l.value })] }, l.label))) }))] }), _jsx("button", { type: "button", className: "rowbtn", onClick: (e) => {
|
|
14
15
|
e.stopPropagation();
|
|
15
16
|
onSelect(provider.id);
|
|
16
17
|
}, children: "Inspect" }), _jsx("span", { className: "sr-only", children: forecastLine(provider) })] }));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ProviderView } from "../state.js";
|
|
3
|
+
/** Full short window, with the date and time it clears. Quiet when none is full. */
|
|
4
|
+
export declare function RateLimitNote({ provider, asOf }: {
|
|
5
|
+
provider: ProviderView;
|
|
6
|
+
asOf: string;
|
|
7
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { rateLimitWaits } from "../../../src/format/rate-limit-wait.js";
|
|
3
|
+
/** Full short window, with the date and time it clears. Quiet when none is full. */
|
|
4
|
+
export function RateLimitNote({ provider, asOf }) {
|
|
5
|
+
const asOfMs = Date.parse(asOf);
|
|
6
|
+
const now = Number.isFinite(asOfMs) ? new Date(asOfMs) : new Date();
|
|
7
|
+
const waits = rateLimitWaits(provider, now);
|
|
8
|
+
if (waits.length === 0)
|
|
9
|
+
return null;
|
|
10
|
+
return (_jsx("p", { className: "rate-wait", "data-testid": `rate-wait-${provider.id}`, children: waits.map((w) => (_jsx("span", { children: w.text }, w.window))) }));
|
|
11
|
+
}
|