quotacap 0.0.56 → 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/advisory/engine.js +16 -6
- package/dist/advisory/snapshot.js +1 -0
- package/dist/advisory/types.d.ts +24 -0
- package/dist/advisory/types.js +22 -0
- 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 +6 -1
- 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/PaceBar.d.ts +2 -1
- package/dist/web/src/components/PaceBar.js +4 -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/web/src/state.d.ts +5 -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-Co33DTl5.css +0 -1
- package/web/dist/assets/index-oqxiN-gi.js +0 -13
package/dist/advisory/engine.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MIN_PACE_SPAN_DAYS, BLEND_K, RISK_MARGIN, GATE_TOL } from "./types.js";
|
|
1
|
+
import { MIN_PACE_SPAN_DAYS, BLEND_K, RISK_MARGIN, GATE_TOL, paceTube } from "./types.js";
|
|
2
2
|
const DAY_MS = 86400000;
|
|
3
3
|
/**
|
|
4
4
|
* Pace from a single reading.
|
|
@@ -113,6 +113,7 @@ export function computeAdvisory(q, recent, baseline, now = new Date(), exhausted
|
|
|
113
113
|
recentRate: null,
|
|
114
114
|
baselineRate: null,
|
|
115
115
|
aheadOfElapsed: null,
|
|
116
|
+
closeToReset: false,
|
|
116
117
|
avgPace,
|
|
117
118
|
burnMeasured: false,
|
|
118
119
|
paceSource: "unknown",
|
|
@@ -136,6 +137,7 @@ export function computeAdvisory(q, recent, baseline, now = new Date(), exhausted
|
|
|
136
137
|
recentRate: null,
|
|
137
138
|
baselineRate: null,
|
|
138
139
|
aheadOfElapsed: null,
|
|
140
|
+
closeToReset: false,
|
|
139
141
|
avgPace,
|
|
140
142
|
burnMeasured,
|
|
141
143
|
paceSource,
|
|
@@ -151,6 +153,9 @@ export function computeAdvisory(q, recent, baseline, now = new Date(), exhausted
|
|
|
151
153
|
}
|
|
152
154
|
// Red needs a deadband margin and a cumulatively-ahead position on a
|
|
153
155
|
// verified clock; a missing or estimated clock caps at Watch.
|
|
156
|
+
// The on-track tube widens with time left: a near-full finish reads on
|
|
157
|
+
// track while the reset is days away, and the shell out to RISK_MARGIN
|
|
158
|
+
// stays Watch so a small miss still warns near the reset.
|
|
154
159
|
const elapsed = elapsedPctOf(q, now);
|
|
155
160
|
const estimated = q.resetsAtEstimated === true;
|
|
156
161
|
const gate = elapsed !== null && !estimated && q.weeklyPct >= elapsed * (1 - GATE_TOL);
|
|
@@ -158,14 +163,17 @@ export function computeAdvisory(q, recent, baseline, now = new Date(), exhausted
|
|
|
158
163
|
const wastePct = Math.max(0, remaining - burnRate * daysLeft);
|
|
159
164
|
const daysToExhaust = burnRate > 0 ? remaining / burnRate : Infinity;
|
|
160
165
|
const over = daysToExhaust < daysLeft * (1 - RISK_MARGIN);
|
|
161
|
-
const
|
|
166
|
+
const missFrac = Number.isFinite(daysToExhaust) ? Math.abs(daysToExhaust - daysLeft) / daysLeft : Infinity;
|
|
167
|
+
const insideTube = missFrac <= paceTube(daysLeft);
|
|
168
|
+
const inShell = !over && !insideTube && daysToExhaust < daysLeft * (1 + RISK_MARGIN);
|
|
162
169
|
let status;
|
|
163
170
|
if (over && gate)
|
|
164
171
|
status = "at risk";
|
|
165
|
-
else if (over ||
|
|
172
|
+
else if (over || inShell || (insideTube && estimated))
|
|
166
173
|
status = "watch";
|
|
167
174
|
else
|
|
168
175
|
status = "on track";
|
|
176
|
+
const closeToReset = status === "on track" && insideTube;
|
|
169
177
|
let urgency = "on track";
|
|
170
178
|
if (wastePct > 30 && daysLeft < 3)
|
|
171
179
|
urgency = "burn now";
|
|
@@ -177,7 +185,7 @@ export function computeAdvisory(q, recent, baseline, now = new Date(), exhausted
|
|
|
177
185
|
urgency = "save";
|
|
178
186
|
if (estimated && urgency === "burn now")
|
|
179
187
|
urgency = "use soon";
|
|
180
|
-
return { provider: q.provider, daysLeft, remaining, idealRate, burnRate, recentRate: recent, baselineRate: baseline, aheadOfElapsed, avgPace, burnMeasured, paceSource, daysToExhaust, status, wastePct, urgency, bindingWindow, bindingRemaining, bindingDaysLeft, exhaustedAt };
|
|
188
|
+
return { provider: q.provider, daysLeft, remaining, idealRate, burnRate, recentRate: recent, baselineRate: baseline, aheadOfElapsed, closeToReset, avgPace, burnMeasured, paceSource, daysToExhaust, status, wastePct, urgency, bindingWindow, bindingRemaining, bindingDaysLeft, exhaustedAt };
|
|
181
189
|
}
|
|
182
190
|
/**
|
|
183
191
|
* Known-waste sort key. `wastePct` is a flow (budget forecast to go unspent
|
|
@@ -250,10 +258,12 @@ export function recommend(quotas, _task, paceByProvider = new Map(), now = new D
|
|
|
250
258
|
advisories,
|
|
251
259
|
};
|
|
252
260
|
}
|
|
253
|
-
// 3. No meaningful candidate
|
|
261
|
+
// 3. No meaningful candidate. A hot board names the amber and red tiers.
|
|
262
|
+
// An on-track board with nothing spare (a finish inside the tube) does not.
|
|
263
|
+
const hot = advisories.some(a => a.status === "at risk" || a.status === "watch");
|
|
254
264
|
return {
|
|
255
265
|
use: "none",
|
|
256
|
-
reason: "all quotas at risk, watch, or exhausted",
|
|
266
|
+
reason: hot ? "all quotas at risk, watch, or exhausted" : "no avoidable waste",
|
|
257
267
|
wastePct: 0,
|
|
258
268
|
idealRate: 0,
|
|
259
269
|
recommendationBasis: "none",
|
|
@@ -17,6 +17,7 @@ function normalizeAdvisory(adv) {
|
|
|
17
17
|
recentRate: adv.recentRate != null && Number.isFinite(adv.recentRate) ? adv.recentRate : null,
|
|
18
18
|
baselineRate: adv.baselineRate != null && Number.isFinite(adv.baselineRate) ? adv.baselineRate : null,
|
|
19
19
|
aheadOfElapsed: typeof adv.aheadOfElapsed === "boolean" ? adv.aheadOfElapsed : null,
|
|
20
|
+
closeToReset: adv.closeToReset === true,
|
|
20
21
|
avgPace: adv.avgPace !== null && Number.isFinite(adv.avgPace) ? adv.avgPace : null,
|
|
21
22
|
daysToExhaust: adv.daysToExhaust !== null && Number.isFinite(adv.daysToExhaust) ? adv.daysToExhaust : null,
|
|
22
23
|
wastePct: adv.wastePct !== null && Number.isFinite(adv.wastePct) ? adv.wastePct : null,
|
package/dist/advisory/types.d.ts
CHANGED
|
@@ -11,6 +11,23 @@ export declare const MIN_PACE_SPAN_DAYS: number;
|
|
|
11
11
|
export declare const BLEND_K = 0.5;
|
|
12
12
|
export declare const RISK_MARGIN = 0.15;
|
|
13
13
|
export declare const GATE_TOL = 0.1;
|
|
14
|
+
/** Weekly quota window. "Far from reset" in the on-track tube is this long. */
|
|
15
|
+
export declare const PACE_WINDOW_DAYS = 7;
|
|
16
|
+
/**
|
|
17
|
+
* Narrowest on-track tube, as a fraction of the time still left. At the
|
|
18
|
+
* reset, a finish within 5% of it still reads on track.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TUBE_FLOOR = 0.05;
|
|
21
|
+
/**
|
|
22
|
+
* Half-width of the on-track tube, as a fraction of `daysLeft`.
|
|
23
|
+
*
|
|
24
|
+
* The tube grows from `TUBE_FLOOR` at the reset to `margin` once about 4.7
|
|
25
|
+
* days remain, and never wider than `margin`. A forecast inside it is close
|
|
26
|
+
* enough to a full finish to read on track. The shell between the tube and
|
|
27
|
+
* `margin` stays Watch, so a small miss still warns near the reset. Cap risk
|
|
28
|
+
* stays outside `margin` on the early side.
|
|
29
|
+
*/
|
|
30
|
+
export declare function paceTube(daysLeft: number, margin?: number): number;
|
|
14
31
|
export type Urgency = "burn now" | "use soon" | "slow down" | "save" | "on track";
|
|
15
32
|
export type BurnStatus = "at risk" | "watch" | "on track" | "unknown";
|
|
16
33
|
export type PaceSource = "recent" | "window-average" | "unknown";
|
|
@@ -27,6 +44,13 @@ export interface Advisory {
|
|
|
27
44
|
recentRate?: number | null;
|
|
28
45
|
baselineRate?: number | null;
|
|
29
46
|
aheadOfElapsed?: boolean | null;
|
|
47
|
+
/**
|
|
48
|
+
* True when the forecast finish sits inside the horizon tube around the
|
|
49
|
+
* reset and the verdict is on track. The badge stays On track even if
|
|
50
|
+
* usage is slightly ahead of elapsed time. False for a clear leftover,
|
|
51
|
+
* a Watch shell, and an estimated clock.
|
|
52
|
+
*/
|
|
53
|
+
closeToReset: boolean;
|
|
30
54
|
/**
|
|
31
55
|
* Window-average pace (used % ÷ days elapsed), always computed when the
|
|
32
56
|
* window start is known — independent of `burnRate`, which is the forecast
|
package/dist/advisory/types.js
CHANGED
|
@@ -8,3 +8,25 @@ export const MIN_PACE_SPAN_DAYS = 6 / 24;
|
|
|
8
8
|
export const BLEND_K = 0.5;
|
|
9
9
|
export const RISK_MARGIN = 0.15;
|
|
10
10
|
export const GATE_TOL = 0.10;
|
|
11
|
+
/** Weekly quota window. "Far from reset" in the on-track tube is this long. */
|
|
12
|
+
export const PACE_WINDOW_DAYS = 7;
|
|
13
|
+
/**
|
|
14
|
+
* Narrowest on-track tube, as a fraction of the time still left. At the
|
|
15
|
+
* reset, a finish within 5% of it still reads on track.
|
|
16
|
+
*/
|
|
17
|
+
export const TUBE_FLOOR = 0.05;
|
|
18
|
+
/**
|
|
19
|
+
* Half-width of the on-track tube, as a fraction of `daysLeft`.
|
|
20
|
+
*
|
|
21
|
+
* The tube grows from `TUBE_FLOOR` at the reset to `margin` once about 4.7
|
|
22
|
+
* days remain, and never wider than `margin`. A forecast inside it is close
|
|
23
|
+
* enough to a full finish to read on track. The shell between the tube and
|
|
24
|
+
* `margin` stays Watch, so a small miss still warns near the reset. Cap risk
|
|
25
|
+
* stays outside `margin` on the early side.
|
|
26
|
+
*/
|
|
27
|
+
export function paceTube(daysLeft, margin = RISK_MARGIN) {
|
|
28
|
+
if (!(daysLeft > 0) || !(margin > 0))
|
|
29
|
+
return TUBE_FLOOR;
|
|
30
|
+
const grown = TUBE_FLOOR + margin * (daysLeft / PACE_WINDOW_DAYS);
|
|
31
|
+
return Math.min(margin, grown);
|
|
32
|
+
}
|
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;
|
|
@@ -159,7 +160,8 @@ export function railCells(ps, now) {
|
|
|
159
160
|
}
|
|
160
161
|
// Shared STATE vocabulary (locked badge mapping): any exclusion reads
|
|
161
162
|
// Not reporting; at-risk status beats urgency, then watch, then unknown;
|
|
162
|
-
// on-track rows ahead of cumulative elapsed time revive Ahead of pace
|
|
163
|
+
// on-track rows ahead of cumulative elapsed time revive Ahead of pace,
|
|
164
|
+
// except a finish inside the horizon tube, which stays On track;
|
|
163
165
|
// urgency maps to the remaining pace words.
|
|
164
166
|
export function stateWord(ps) {
|
|
165
167
|
if (ps.exclusionReason !== null)
|
|
@@ -183,6 +185,8 @@ export function stateWord(ps) {
|
|
|
183
185
|
return "Watch";
|
|
184
186
|
if (adv.status === "unknown")
|
|
185
187
|
return "Measuring";
|
|
188
|
+
if (adv.status === "on track" && adv.closeToReset === true)
|
|
189
|
+
return "On track";
|
|
186
190
|
if (adv.aheadOfElapsed === true)
|
|
187
191
|
return "Ahead of pace";
|
|
188
192
|
switch (adv.urgency) {
|
|
@@ -401,5 +405,6 @@ export function buildRow(ps, now) {
|
|
|
401
405
|
usedPct: usedPctOf(ps),
|
|
402
406
|
railCells: railCells(ps, now),
|
|
403
407
|
pace: paceText(ps, now),
|
|
408
|
+
wait: rateLimitWaits(ps, now).map((w) => w.text).join(" · "),
|
|
404
409
|
};
|
|
405
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,7 +4,8 @@ export type PaceBadge = "Not reporting" | "Cap risk" | "Watch" | "Behind pace" |
|
|
|
4
4
|
/**
|
|
5
5
|
* Pace-state badge from the mapping table. Exclusion always wins; a blocked
|
|
6
6
|
* month next; otherwise status "at risk" wins, then "watch", then "unknown";
|
|
7
|
-
* on-track rows ahead of cumulative elapsed time read Ahead of pace
|
|
7
|
+
* on-track rows ahead of cumulative elapsed time read Ahead of pace,
|
|
8
|
+
* except a finish inside the horizon tube, which stays On track;
|
|
8
9
|
* otherwise urgency decides. No client thresholds.
|
|
9
10
|
*/
|
|
10
11
|
export declare function paceBadge(provider: ProviderView): PaceBadge;
|
|
@@ -3,7 +3,8 @@ import { ageDuration } from "../state.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Pace-state badge from the mapping table. Exclusion always wins; a blocked
|
|
5
5
|
* month next; otherwise status "at risk" wins, then "watch", then "unknown";
|
|
6
|
-
* on-track rows ahead of cumulative elapsed time read Ahead of pace
|
|
6
|
+
* on-track rows ahead of cumulative elapsed time read Ahead of pace,
|
|
7
|
+
* except a finish inside the horizon tube, which stays On track;
|
|
7
8
|
* otherwise urgency decides. No client thresholds.
|
|
8
9
|
*/
|
|
9
10
|
export function paceBadge(provider) {
|
|
@@ -26,6 +27,8 @@ export function paceBadge(provider) {
|
|
|
26
27
|
return "Watch";
|
|
27
28
|
if (advisory.status === "unknown")
|
|
28
29
|
return "Measuring";
|
|
30
|
+
if (advisory.status === "on track" && advisory.closeToReset === true)
|
|
31
|
+
return "On track";
|
|
29
32
|
if (advisory.aheadOfElapsed === true)
|
|
30
33
|
return "Ahead of pace";
|
|
31
34
|
switch (advisory.urgency) {
|
|
@@ -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
|
+
}
|