tokenmaxxing 1.89.0 → 1.90.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.
package/DESIGN.md CHANGED
@@ -53,7 +53,7 @@ The switching path runs no long-lived daemon. The statusline pushes usage. Hooks
53
53
  ## 3. How a move happens
54
54
 
55
55
  ### 3.1 Usage feed (free, push-based)
56
- The Stop hook's stdin has no usage data, but the **statusLine does** (`rate_limits.{five_hour,seven_day}.{used_percentage,resets_at}`, after every turn, 300ms debounce, zero cost). tokenmaxxing's statusLine tees that to `usage/<uuid8>.json` for the session's seat, read from the inherited `CLAUDE_SECURESTORAGE_CONFIG_DIR` (write-on-change, O(ms)), and renders its own native line (it replaced the earlier pass-through delegation on 2026-07-11: install takes the statusLine slot outright, so a pre-existing custom statusline command is overwritten). A session with no pooled seat writes no tee. The seat is sampled when its tee is older than `policy.usagePollTtlMs`, and for the per-model rows when the active model is a gated family: the direct no-spend usage read with the seat's stored token. The compact child still sets `TOKENMAXXING_PROBE=1` so the hook entries return at once. The sample takes one attempt per interval; a failed sample doubles the interval up to 30 minutes, and a success resets it. An expired stored access token stays unmeasured until a session on that store refreshes it.
56
+ The Stop hook's stdin has no usage data, but the **statusLine does** (`rate_limits.{five_hour,seven_day}.{used_percentage,resets_at}`, after every turn, 300ms debounce, zero cost). tokenmaxxing's statusLine tees that to `usage/<uuid8>.json` for the session's seat, read from the inherited `CLAUDE_SECURESTORAGE_CONFIG_DIR` (write-on-change, O(ms)), and renders its own native line (it replaced the earlier pass-through delegation on 2026-07-11: install takes the statusLine slot outright, so a pre-existing custom statusline command is overwritten). A session with no pooled seat writes no tee. The seat is sampled when its tee is older than `policy.usagePollTtlMs`, and for the per-model rows when the active model is a gated family, at most once per the account's sample interval (§5): the direct no-spend usage read with the seat's stored token. The compact child still sets `TOKENMAXXING_PROBE=1` so the hook entries return at once. The sample takes one attempt per interval; a failed sample doubles the interval up to 30 minutes, and a success resets it. An expired stored access token stays unmeasured until a session on that store refreshes it.
57
57
 
58
58
  ### 3.2 Detect + decide + signal (Stop hook, per turn)
59
59
  1. Resolve the seat: the pooled account whose store the inherited `CLAUDE_SECURESTORAGE_CONFIG_DIR` names. No seat (a session started outside the supervisor) means nothing to move.
@@ -87,7 +87,7 @@ Each terminal ran the supervisor, so each has its own child `claude`, its own `-
87
87
  The [switching policy](docs/content/docs/switching.mdx) is one rule: under both bars, hold; at or over a bar, move to the usable account that ranks first; nothing usable, queue first come first served onto a reset target (at most four waiters per account, overflow takes the soonest anyway) and wait for that reset. The same ranking places a session at launch.
88
88
 
89
89
  - Ranking (decided by consult for #79): greatest remaining headroom to the session bar divided by the number of sessions after placement, `(bar - used) / (sessions + 1)`, then highest pace pressure (remaining percent of the binding gated per-model cap, or of the weekly aggregate for an account with no gated row, over time to its reset), then soonest weekly reset, then lowest weekly usage; unknown usage ranks last. Organization membership is not an input. Codex drops the headroom key, keeps the pace ordering and the weekly tie-breaks, and excludes accounts running in another codex session, because codex has no cross-process refresh lock and two sessions must never share a login.
90
- - Selection reads the cached figures only, after folding every account's tee. Each periodic check tick samples up to three accounts whose last sample attempt is oldest, skipping any attempted within `policy.usagePollTtlMs`, over the direct no-spend usage read with the account's stored token, so every account is attempted about once per three ticks per pooled account, or once per `policy.usagePollTtlMs` plus a tick when that is longer, and its cached figure is as fresh as its last successful attempt or its sessions' latest push. The pool lock covers only the reservation and the result write, never the usage GET. The usage endpoint rate limits each account on its own and names the time to come back in the `retry-after` of its HTTP 429; that time is stored as `usageRetryAt`, and no sampler (the tick, `status`, the seat's in-decision sample) reads the account before it. An expired stored access token stays unmeasured until a session on that store refreshes it.
90
+ - Selection reads the cached figures only, after folding every account's tee. Each periodic check tick samples up to three accounts whose last sample attempt is oldest, skipping any attempted within the account's sample interval, over the direct no-spend usage read with the account's stored token. The interval is 15 minutes times the unused fraction of the bar closest to being reached, never under `policy.usagePollTtlMs`, and 15 minutes for an account at or over an aggregate bar. The windows are the session and weekly aggregates plus the `policy.switchModels` caps that are still under their bar, and an account with no stored aggregate gets `policy.usagePollTtlMs`. Every account is attempted about once per three ticks per pooled account, or once per its sample interval plus a tick when that is longer, and its cached figure is as fresh as its last successful attempt or its sessions' latest push. The pool lock covers only the reservation and the result write, never the usage GET. The usage endpoint rate limits each account on its own and names the time to come back in the `retry-after` of its HTTP 429; that time is stored as `usageRetryAt`, and no sampler (the tick, `status`, the seat's in-decision sample) reads the account before it. An expired stored access token stays unmeasured until a session on that store refreshes it, and no sampler sends a read with it, because the endpoint answers it with 401 and, after a few, with the same 429.
91
91
  - The depleted pause happens at the bar, not at 100; Codex has no pause and rides its account until the server refuses it, because a running sibling cannot adopt another account without restarting.
92
92
  - Neither pool has a post-swap cooldown or a manual `switch`: a move is a respawn of one session under a fixed store, so nothing another session reads is invalidated by it, and placement at launch replaces the manual pick.
93
93
 
package/README.md CHANGED
@@ -90,7 +90,7 @@ The bars' headroom is deliberate: it's the budget to reach a clean turn boundary
90
90
 
91
91
  Launches and moves rank usable accounts by session-window headroom per running session, `(bar - used) / (sessions + 1)`, so two fresh accounts alternate and a third session goes to whichever has more headroom left per session; ties break by pace pressure (remaining percent of the binding gated per-model cap, or of the weekly aggregate for an account with no gated row, divided by time to its reset, highest first), then soonest weekly reset, then lowest weekly use. Organization membership is not an input.
92
92
 
93
- - Every periodic check tick folds fresh statusline tees into the index and samples up to three accounts whose last sample attempt is oldest, skipping any attempted within `policy.usagePollTtlMs`, with the direct no-spend usage read; a move reads the cached figures, which are as fresh as each account's last successful attempt or its sessions' latest push. An expired stored access token stays unmeasured until a session on that store refreshes it.
93
+ - Every periodic check tick folds fresh statusline tees into the index and samples up to three accounts whose last sample attempt is oldest, skipping any attempted within the account's sample interval (15 minutes for an empty account, shrinking to `policy.usagePollTtlMs` as it nears a bar, and 15 minutes again at or over an aggregate bar), with the direct no-spend usage read; a move reads the cached figures, which are as fresh as each account's last successful attempt or its sessions' latest push. An expired stored access token stays unmeasured until a session on that store refreshes it.
94
94
  - When no account is usable, the session queues first come first served onto a reset target (at most four waiters per account) and pauses until that reset if it lands within `policy.maxWaitMs`, and otherwise stays put.
95
95
 
96
96
  See [How switching decides](docs/content/docs/switching.mdx) for the policy and the [cache-cost profile](docs/content/docs/switching-profile.mdx) for measurements and their limits.
@@ -112,7 +112,7 @@ See [How switching decides](docs/content/docs/switching.mdx) for the policy and
112
112
  }
113
113
  ```
114
114
 
115
- `thresholds.session` and `thresholds.weekly` are the two bars, one number each (an array `thresholds.session`, the former ladder, fails config loading with a message naming the field); `projectionMargin` is a fixed safety margin subtracted from the session bar only (default 3), so a large turn is less likely to blow past the 5-hour bar between checks; the weekly bar takes no margin because one turn cannot overshoot a week; `switchModels` names the models whose per-model cap triggers a move; `usagePollTtlMs` is how long a usage sample stays fresh, for a seat's own sample and for the accounts each check tick samples; `maxWaitMs` bounds the depleted-pool countdown - a reset further out than this does not pause the session (no respawn marker is written and the session simply keeps hitting its limit until an account recovers); `checkIntervalMs` is the periodic check tick (default 60s), which `init` writes into the timer - re-run `tokenmaxxing init` after changing it so the timer unit picks up the new tick. `claudeBin`, `codexBin`, `grokBin`, `opencodeBin`, and `piBin` pin the real binaries; `init` writes them, and `TOKENMAXXING_CLAUDE_BIN`, `TOKENMAXXING_CODEX_BIN`, `TOKENMAXXING_GROK_BIN`, `TOKENMAXXING_OPENCODE_BIN`, and `TOKENMAXXING_PI_BIN` override them for one process, except that `init` pins the binary it resolved into `config.json`.
115
+ `thresholds.session` and `thresholds.weekly` are the two bars, one number each (an array `thresholds.session`, the former ladder, fails config loading with a message naming the field); `projectionMargin` is a fixed safety margin subtracted from the session bar only (default 3), so a large turn is less likely to blow past the 5-hour bar between checks; the weekly bar takes no margin because one turn cannot overshoot a week; `switchModels` names the models whose per-model cap triggers a move; `usagePollTtlMs` is the shortest sample interval, the one an account near a bar gets, for a seat's own sample, for `status`, and for the accounts each check tick samples; `maxWaitMs` bounds the depleted-pool countdown - a reset further out than this does not pause the session (no respawn marker is written and the session simply keeps hitting its limit until an account recovers); `checkIntervalMs` is the periodic check tick (default 60s), which `init` writes into the timer - re-run `tokenmaxxing init` after changing it so the timer unit picks up the new tick. `claudeBin`, `codexBin`, `grokBin`, `opencodeBin`, and `piBin` pin the real binaries; `init` writes them, and `TOKENMAXXING_CLAUDE_BIN`, `TOKENMAXXING_CODEX_BIN`, `TOKENMAXXING_GROK_BIN`, `TOKENMAXXING_OPENCODE_BIN`, and `TOKENMAXXING_PI_BIN` override them for one process, except that `init` pins the binary it resolved into `config.json`.
116
116
 
117
117
  State lives in `~/.config/tokenmaxxing/`; outside it the install touches Claude Code's `settings.json`, codex's `hooks.json`, the timer and usage hub units, and your shell rc. Each account's credential store is `stores/<uuid8>/`, which Claude Code reads and refreshes as its own: on macOS the credential is a login-keychain item keyed by the store path (never plaintext on disk), on Linux a 0600 `.credentials.json` inside the store (the same plaintext model claude itself uses for `~/.claude/.credentials.json`).
118
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenmaxxing",
3
- "version": "1.89.0",
3
+ "version": "1.90.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
@@ -27,7 +27,7 @@ type StatusAccount = {
27
27
  usage: UsageReport | null;
28
28
  usageAt: number | null;
29
29
  limitsAt: number | null;
30
- sample: SampleReport | { ok: true; source: "cached" };
30
+ sample: SampleReport;
31
31
  };
32
32
 
33
33
  type PoolReport = {
@@ -109,6 +109,10 @@ async function collect(p: Provider, cfg: Config, now: number, cached: boolean):
109
109
  stored.usageRetryAt = a.usageRetryAt;
110
110
  dirty = true;
111
111
  }
112
+ if ((a.lastProbeAt ?? 0) > (stored.lastProbeAt ?? 0)) {
113
+ stored.lastProbeAt = a.lastProbeAt;
114
+ dirty = true;
115
+ }
112
116
  if (a.lastUsageAt != null && (stored.lastUsageAt == null || a.lastUsageAt > stored.lastUsageAt)) {
113
117
  landWindows(stored, p.mergeWindows(a.windows, stored.windows), a.lastUsageAt, bars);
114
118
  if (a.email != null) stored.email = a.email;
package/src/lib/claude.ts CHANGED
@@ -13,7 +13,7 @@ import { landWindows, pickBest, pickEarliestReset, thresholdBars, type PickCtx }
13
13
  import { deletePiStore } from "./piauth.ts";
14
14
  import { livingPresences } from "./presence.ts";
15
15
  import { StoreUnusableError, type Observation, type Provider, type SampleReport } from "./provider.ts";
16
- import { foldTee, sampleAccountUsage, teeObservation, usageBlockedUntil } from "./sample.ts";
16
+ import { foldTee, readyToSample, runSample, sampleAccountUsage, sampleDue, sampleIntervalMs, teeObservation, usageBlockedUntil } from "./sample.ts";
17
17
  import { clearUsageSnapshot, liveWaitClaims, loadAccounts, loadConfig, loadUsageSnapshot, pinBinOverride, readJsonFile, saveAccounts, type Harvest } from "./state.ts";
18
18
  import { saveTermios, restoreTermios } from "./tty.ts";
19
19
  import { fetchUsageDirect, gatedFamilies, mergeWindows, modelFromFlag, scrubCredentialEnv, windowsOf } from "./usage.ts";
@@ -33,11 +33,10 @@ function presence(): Map<string, number> {
33
33
  const PROBE_BACKOFF_CAP_MS = 30 * 60 * 1000;
34
34
 
35
35
  async function observeLive(account: Account, cfg: Config, now: number, opts: { probe: boolean; perModel: boolean }): Promise<Observation | null> {
36
- const ttl = cfg.policy.usagePollTtlMs;
37
- const interval = Math.min(ttl * 2 ** (account.probeFails ?? 0), PROBE_BACKOFF_CAP_MS);
36
+ const interval = Math.min(sampleIntervalMs(account, cfg, now) * 2 ** (account.probeFails ?? 0), PROBE_BACKOFF_CAP_MS);
38
37
  const probeAttempted = account.lastProbeAt != null && now - account.lastProbeAt <= interval;
39
38
  const snap = loadUsageSnapshot(account.id);
40
- const fresh = snap != null && now - snap.at <= ttl;
39
+ const fresh = snap != null && now - snap.at <= cfg.policy.usagePollTtlMs;
41
40
  if (opts.probe && !probeAttempted && usageBlockedUntil(account, now) == null && (!fresh || opts.perModel)) {
42
41
  const startedAt = Date.now();
43
42
  const outcome = await sampleAccountUsage(account);
@@ -64,9 +63,10 @@ async function observeLive(account: Account, cfg: Config, now: number, opts: { p
64
63
  return teeObservation(current);
65
64
  }
66
65
 
67
- async function samplePool(accounts: Account[]): Promise<Map<string, SampleReport>> {
66
+ async function samplePool(accounts: Account[], _liveId: string | null, now: number): Promise<Map<string, SampleReport>> {
68
67
  const reports = new Map<string, SampleReport>();
69
- const bars = thresholdBars(loadConfig());
68
+ const cfg = loadConfig();
69
+ const bars = thresholdBars(cfg);
70
70
  await Promise.all(
71
71
  accounts.map(async (a) => {
72
72
  const tee = loadUsageSnapshot(a.id);
@@ -76,7 +76,17 @@ async function samplePool(accounts: Account[]): Promise<Map<string, SampleReport
76
76
  reports.set(a.id, { ok: true, source: "statusline" });
77
77
  return;
78
78
  }
79
- const outcome = await sampleAccountUsage(a);
79
+ const ready = await readyToSample(a, now);
80
+ if (!ready.ok) {
81
+ reports.set(a.id, { ok: false, reason: ready.reason });
82
+ return;
83
+ }
84
+ if (!sampleDue(a, cfg, now)) {
85
+ reports.set(a.id, { ok: true, source: "cached" });
86
+ return;
87
+ }
88
+ a.lastProbeAt = now;
89
+ const outcome = await runSample(a, ready);
80
90
  if (!outcome.ok) {
81
91
  if (outcome.retryAt != null) a.usageRetryAt = outcome.retryAt;
82
92
  reports.set(a.id, { ok: false, reason: outcome.reason });
package/src/lib/picker.ts CHANGED
@@ -49,7 +49,7 @@ export function liveUsed(w: Window, now: number): number {
49
49
  return w.usedPercentage;
50
50
  }
51
51
 
52
- function barFor(w: Window, thresholds: Thresholds): number {
52
+ export function barFor(w: Window, thresholds: Thresholds): number {
53
53
  return isSessionWindow(w) ? thresholds.session : thresholds.weekly;
54
54
  }
55
55
 
@@ -4,7 +4,7 @@ import type { Account, Config, Window } from "./types.ts";
4
4
 
5
5
  export type Observation = { windows: Window[]; at: number };
6
6
 
7
- export type SampleReport = { ok: true; source: "statusline" | "probe" } | { ok: false; reason: string };
7
+ export type SampleReport = { ok: true; source: "statusline" | "probe" | "cached" } | { ok: false; reason: string };
8
8
 
9
9
  export type SwapFailure = "dead-grant" | "skip" | "fatal";
10
10
 
package/src/lib/sample.ts CHANGED
@@ -3,16 +3,36 @@ import { withLock } from "./lock.ts";
3
3
  import { errorMessage, log } from "./log.ts";
4
4
  import { claudeTierLabel, isDeadCredential } from "./oauth.ts";
5
5
  import { claudePool, paths } from "./paths.ts";
6
- import { landWindows, thresholdBars } from "./picker.ts";
6
+ import { barFor, gatedWindows, landWindows, liveUsed, thresholdBars } from "./picker.ts";
7
7
  import { seatCounts } from "./presence.ts";
8
8
  import type { Observation } from "./provider.ts";
9
9
  import { loadAccounts, loadUsageSnapshot, saveAccounts } from "./state.ts";
10
10
  import { fetchUsageDirect, mergeWindows, windowsOf } from "./usage.ts";
11
- import type { Account, Config, Thresholds, UsageWindows } from "./types.ts";
11
+ import type { Account, Config, Thresholds, UsageWindows, Window } from "./types.ts";
12
12
 
13
13
  export type SampleOutcome = { ok: true; usage: UsageWindows; via: "get" } | { ok: false; reason: string; retryAt?: number };
14
14
 
15
- type PreparedSample = { ok: true; token: string } | { ok: false; reason: string };
15
+ type PreparedSample = { ok: true; token: string; expiresAt: number } | { ok: false; reason: string };
16
+
17
+ const SAMPLE_INTERVAL_MAX_MS = 15 * 60 * 1000;
18
+
19
+ export function sampleIntervalMs(account: Account, cfg: Config, now: number): number {
20
+ const floor = cfg.policy.usagePollTtlMs;
21
+ const bars = thresholdBars(cfg);
22
+ const aggregates = account.windows.filter((w) => w.name == null);
23
+ if (aggregates.length === 0) return floor;
24
+ const blocked = (w: Window) => liveUsed(w, now) >= barFor(w, bars);
25
+ if (aggregates.some(blocked)) return Math.max(floor, SAMPLE_INTERVAL_MAX_MS);
26
+ const open = [...aggregates, ...gatedWindows(account, cfg.policy.switchModels).filter((w) => !blocked(w))];
27
+ const spare = Math.min(...open.map((w) => 1 - liveUsed(w, now) / barFor(w, bars)));
28
+ return Math.max(floor, SAMPLE_INTERVAL_MAX_MS * spare);
29
+ }
30
+
31
+ const sampledAt = (a: Account) => Math.max(a.lastUsageAt ?? 0, a.lastProbeAt ?? 0);
32
+
33
+ export function sampleDue(account: Account, cfg: Config, now: number): boolean {
34
+ return now - sampledAt(account) > sampleIntervalMs(account, cfg, now);
35
+ }
16
36
 
17
37
  export function teeObservation(account: Account): Observation | null {
18
38
  const stored = account.lastUsageAt != null ? { windows: account.windows, at: account.lastUsageAt } : null;
@@ -45,7 +65,7 @@ export async function prepareSample(account: Account): Promise<PreparedSample> {
45
65
  }
46
66
  if (!account.oauthAccount) return { ok: false, reason: "account record has no oauthAccount - run `tokenmaxxing auth`" };
47
67
  account.tier = claudeTierLabel(creds) ?? account.tier;
48
- return { ok: true, token: creds.accessToken };
68
+ return { ok: true, token: creds.accessToken, expiresAt: creds.expiresAt };
49
69
  }
50
70
 
51
71
  export function usageBlockedUntil(account: Account, now: number): number | null {
@@ -56,19 +76,27 @@ function rateLimitedReason(retryAt: number, now: number): string {
56
76
  return `the usage endpoint rate limited this account, next read in ${Math.ceil((retryAt - now) / 60_000)}m`;
57
77
  }
58
78
 
59
- export async function runSample(account: Account, token: string): Promise<SampleOutcome> {
60
- const read = await fetchUsageDirect(token);
79
+ const EXPIRED_REASON = "the stored access token expired, next read after a session on this account refreshes it";
80
+
81
+ export async function runSample(account: Account, prepared: { token: string; expiresAt: number }): Promise<SampleOutcome> {
82
+ if (prepared.expiresAt <= Date.now()) return { ok: false, reason: EXPIRED_REASON };
83
+ const read = await fetchUsageDirect(prepared.token);
61
84
  if (read.ok) return { ok: true, usage: read.usage, via: "get" };
62
85
  if (read.retryAt == null) return { ok: false, reason: "usage read failed (see log)" };
63
86
  return { ok: false, reason: rateLimitedReason(read.retryAt, Date.now()), retryAt: read.retryAt };
64
87
  }
65
88
 
66
- export async function sampleAccountUsage(account: Account): Promise<SampleOutcome> {
67
- const now = Date.now();
89
+ export async function readyToSample(account: Account, now: number): Promise<PreparedSample> {
68
90
  const blockedUntil = usageBlockedUntil(account, now);
69
91
  if (blockedUntil != null) return { ok: false, reason: rateLimitedReason(blockedUntil, now) };
70
92
  const prepared = await prepareSample(account);
71
- return prepared.ok ? runSample(account, prepared.token) : prepared;
93
+ if (prepared.ok && prepared.expiresAt <= now) return { ok: false, reason: EXPIRED_REASON };
94
+ return prepared;
95
+ }
96
+
97
+ export async function sampleAccountUsage(account: Account): Promise<SampleOutcome> {
98
+ const ready = await readyToSample(account, Date.now());
99
+ return ready.ok ? runSample(account, ready) : ready;
72
100
  }
73
101
 
74
102
  const SAMPLE_BATCH = 3;
@@ -80,17 +108,16 @@ export async function sampleOldest(cfg: Config): Promise<void> {
80
108
  const idx = loadAccounts(claudePool);
81
109
  let dirty = false;
82
110
  for (const a of idx.accounts) dirty = foldTee(a, thresholdBars(cfg)) || dirty;
83
- const sampledAt = (a: Account) => Math.max(a.lastUsageAt ?? 0, a.lastProbeAt ?? 0);
84
111
  const seats = seatCounts(paths.presenceDir);
85
112
  const stale = idx.accounts
86
- .filter((a) => a.needsReauth !== true && now - sampledAt(a) > cfg.policy.usagePollTtlMs)
113
+ .filter((a) => a.needsReauth !== true && sampleDue(a, cfg, now))
87
114
  .sort((a, b) => Number(seats.has(b.id)) - Number(seats.has(a.id)) || sampledAt(a) - sampledAt(b))
88
115
  .slice(0, SAMPLE_BATCH);
89
116
  if (stale.length === 0) {
90
117
  if (dirty) saveAccounts(claudePool, idx);
91
118
  return [];
92
119
  }
93
- const batch: { account: Account; token: string }[] = [];
120
+ const batch: { account: Account; prepared: { token: string; expiresAt: number } }[] = [];
94
121
  for (const target of stale) {
95
122
  target.lastProbeAt = now;
96
123
  const prepared = await prepareSample(target);
@@ -101,15 +128,15 @@ export async function sampleOldest(cfg: Config): Promise<void> {
101
128
  continue;
102
129
  }
103
130
  target.storeFails = 0;
104
- if (usageBlockedUntil(target, now) == null) batch.push({ account: target, token: prepared.token });
131
+ if (usageBlockedUntil(target, now) == null) batch.push({ account: target, prepared });
105
132
  }
106
133
  saveAccounts(claudePool, idx);
107
134
  return batch;
108
135
  });
109
136
  await Promise.all(
110
- reserved.map(async ({ account, token }) => {
137
+ reserved.map(async ({ account, prepared }) => {
111
138
  const startedAt = Date.now();
112
- const outcome = await runSample(account, token);
139
+ const outcome = await runSample(account, prepared);
113
140
  await withLock(claudePool.lockFile, () => {
114
141
  const idx = loadAccounts(claudePool);
115
142
  const stored = idx.accounts.find((a) => a.id === account.id);