tokenmaxxing 1.47.0 → 1.48.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli/status.ts +30 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenmaxxing",
3
- "version": "1.47.0",
3
+ "version": "1.48.0",
4
4
  "description": "Automatic Claude Code account switching: pool multiple accounts, start each session on its own account, and resume a session on a fresher account when quota fills.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli/status.ts CHANGED
@@ -7,7 +7,7 @@ import { opencodeGo } from "../lib/opencodego.ts";
7
7
  import { loadAccounts, loadConfig, saveAccounts } from "../lib/state.ts";
8
8
  import { withLock } from "../lib/lock.ts";
9
9
  import { codexPool, grokPool, opencodeGoPool } from "../lib/paths.ts";
10
- import { earliestReset, isExhausted, isSessionWindow, limitWindows, nextWeeklyReset, sessionWindow, thresholdBars, weeklyWindow } from "../lib/picker.ts";
10
+ import { earliestReset, gatedWindows, isExhausted, isSessionWindow, limitWindows, liveUsed, nextWeeklyReset, sessionWindow, thresholdBars, weeklyWindow } from "../lib/picker.ts";
11
11
  import type { Provider, SampleReport } from "../lib/provider.ts";
12
12
  import { bar, c, count, emitJson, fmtAgo } from "./render.ts";
13
13
  import { ThresholdsSchema, type Account, type Config, type Window } from "../lib/types.ts";
@@ -50,6 +50,7 @@ const PoolReportSchema = z.object({
50
50
  thresholds: ThresholdsSchema,
51
51
  bars: ThresholdsSchema,
52
52
  projectionMargin: z.number(),
53
+ gatedNote: z.string().nullable(),
53
54
  accounts: z.array(StatusAccountSchema),
54
55
  });
55
56
  type PoolReport = z.infer<typeof PoolReportSchema>;
@@ -77,6 +78,29 @@ function usageReport(a: Account, now: number): StatusAccount["usage"] {
77
78
  };
78
79
  }
79
80
 
81
+ function gatedNote(accounts: Account[], families: string[] | null, weeklyBar: number, now: number): string | null {
82
+ const groups = new Map<string, { carriers: number; capped: number }>();
83
+ for (const a of accounts) {
84
+ if (a.needsReauth === true) continue;
85
+ for (const w of gatedWindows(a, families)) {
86
+ const key = (w.name ?? "").toLowerCase();
87
+ const g = groups.get(key) ?? { carriers: 0, capped: 0 };
88
+ g.carriers++;
89
+ if (liveUsed(w, now) >= weeklyBar) g.capped++;
90
+ groups.set(key, g);
91
+ }
92
+ }
93
+ const capped = [...groups.entries()].filter(([, g]) => g.capped === g.carriers).map(([name]) => name);
94
+ if (capped.length === 0) return null;
95
+ const headroom = accounts.filter((a) => {
96
+ if (a.needsReauth === true) return false;
97
+ const w = weeklyWindow(a);
98
+ return w != null && liveUsed(w, now) < weeklyBar;
99
+ }).length;
100
+ if (headroom === 0) return null;
101
+ return `every ${capped.join(", ")} cap is at the weekly bar, but ${count({ n: headroom, noun: "account" })} still ha${headroom === 1 ? "s" : "ve"} weekly aggregate headroom for other models`;
102
+ }
103
+
80
104
  async function collect(p: Provider, cfg: Config, now: number, cached: boolean): Promise<PoolReport> {
81
105
  let idx = loadAccounts(p.pool);
82
106
  let reports = new Map<string, SampleReport>();
@@ -119,6 +143,7 @@ async function collect(p: Provider, cfg: Config, now: number, cached: boolean):
119
143
  thresholds: { session: cfg.thresholds.session, weekly: cfg.thresholds.weekly },
120
144
  bars,
121
145
  projectionMargin: cfg.policy.projectionMargin,
146
+ gatedNote: gatedNote(idx.accounts, ctx.families, bars.weekly, now),
122
147
  accounts,
123
148
  };
124
149
  }
@@ -232,6 +257,10 @@ function renderPool(p: Provider, pool: PoolReport, header: string, now: number,
232
257
  console.log(c.dim(header));
233
258
  console.log();
234
259
  renderGrid(pool.accounts.map((a) => card(p, a, now, staleAfterMs)));
260
+ if (pool.gatedNote) {
261
+ console.log(c.yellow(pool.gatedNote));
262
+ console.log();
263
+ }
235
264
  }
236
265
 
237
266
  export async function cmdStatus(opts: { json?: boolean; cached?: boolean } = {}): Promise<number> {