@nodii/dev 0.6.175 → 0.6.176

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -571,7 +571,7 @@ map. Gather pins the always-on clauses for a lane's repository and side
571
571
  (`GET /rules/gather-pins`), marked `always-on` in the Clause map.
572
572
 
573
573
  The hooks that run on every tool call or stop (`safety-pre`, `nudge-pre`,
574
- `nudge-stop`, `lane-heartbeat`, and `claude-figma-pre` on a Figma write) read the lane from Dev on each call, never from
574
+ `nudge-stop`, `lane-heartbeat` on stop, and `claude-figma-pre` on a Figma write) read the lane from Dev on each call, never from
575
575
  a kept copy, and ask for as little as decides the same thing
576
576
  (hub-528). A lane is read as `GET /lanes/KEY?view=hook`: only the
577
577
  fields the hooks use, without the lane's timeline. A Dev that does not know
@@ -652,6 +652,9 @@ nodii-dev lane ask withdraw ID
652
652
  nodii-dev lane answer ID --text TEXT
653
653
  nodii-dev lane defer ID --reason TEXT [--minutes N] [--leeway]
654
654
  nodii-dev lane asks [--machine M] [--state S] [--lane KEY] [--cursor C] [--limit N]
655
+ nodii-dev lane message TO --body TEXT|--body-file FILE [--issue ISSUE]
656
+ nodii-dev lane inbox [KEY] [--all]
657
+ # lane-to-lane messaging (NODII-DEV-CLI-191); see "Lane messages"
655
658
  nodii-dev coordinator items [--machine NAME|ID]
656
659
  nodii-dev lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
657
660
  # after a reboot (coordinator): resume every host_lost lane
@@ -673,6 +676,12 @@ nodii-dev lane resume KEY --profile PATH --class long|short|no-build
673
676
  # offline or unread account, and LANE_ALREADY_ON_ACCOUNT. A
674
677
  # lane stopped by two deaths moves off an exhausted account
675
678
  # with no amendment or override, and its death count restarts
679
+ # NODII-DEV-CLI-191: any lane resume first reads the
680
+ # profiles recorded exhausted (see "Account failures" below).
681
+ # A lane on one is moved to another account of its runtime
682
+ # whose fresh band admits its class, and the output says so;
683
+ # with none it is refused ACCOUNT_EXHAUSTED naming the reset.
684
+ # --profile naming another account goes as before
676
685
  nodii-dev lane resume KEY [--override --reason TEXT]
677
686
  # --override (coordinator): resume a lane the two-identical-
678
687
  # deaths rule stopped; Dev refuses it with
@@ -683,6 +692,30 @@ nodii-dev lane resume KEY [--override --reason TEXT]
683
692
  # running run or a lane-agent heartbeat since the death
684
693
  # that is not yet old enough to be dead: one process per
685
694
  # lane (the coordinator's own heartbeats do not count)
695
+ nodii-dev lane resume KEY --if-changed
696
+ # OFF unless NODII_DEV_RESUME_IF_CHANGED=1 (see "Switched-off
697
+ # lane features"); off, it refuses RESUME_IF_CHANGED_OFF.
698
+ # NODII-DEV-CLI-191: resume only when what blocks the lane
699
+ # changed since its last resume: each PR wait's state, head
700
+ # and merge commit (gh), each issue wait's status and each
701
+ # blocking lane's status (Dev), its leeways and its latest
702
+ # amendment. Heartbeat notes never count. Unchanged prints
703
+ # BLOCKERS_UNCHANGED and exits 0; the fingerprint is kept in
704
+ # runs/resume-fingerprints.json. A superseded lane (every
705
+ # issue it holds closed) is refused as LANE_DEAD with the
706
+ # evidence; nothing stops it here (the coordinator ends it by
707
+ # the MW1-28 exit that fits). A
708
+ # lane whose work is landed (MW1-30.1: its changed paths
709
+ # match origin/main) before deploy is refused as
710
+ # LANDED_NOT_DONE and never stopped: landed is not done
711
+ # (MW1-28), so it goes on to deploy and the dev check. With
712
+ # NODII_DEV_SAME_SESSION_RESUME=1, every resume
713
+ # continues the dead run's own session when this machine has
714
+ # its log and the lane stayed on its account (`claude
715
+ # --resume`, `codex exec resume`), with a prompt of its last
716
+ # conclusion, what changed and the claim-and-fix directive,
717
+ # never the full Freeze; otherwise it starts fresh with the
718
+ # Freeze as before
686
719
  nodii-dev lane check KEY [--gate CMD ...] [--critical] [--max-iterations N] [--picker agent]
687
720
  # from the lane's worktree: the rules, Figma and code checks (DEV-REV) over
688
721
  # the diff against origin/main, tracked and untracked; --gate runs the gates
@@ -937,18 +970,40 @@ and is retried after ten minutes, not on every write.
937
970
  The Stop nudge asks the session to continue once (`decision: block`, skipped
938
971
  when `stop_hook_active`); Codex passes it through its managed dispatcher.
939
972
  Before that, in a lane session (a `lane-*.json` identity), the same hook holds
940
- the stop while the lane's done check is not recorded and the lane is not
941
- BLOCKED (NODII-DEV-CLI-8), even after an earlier block: it reads the lane from
942
- Dev and answers `Lane KEY: done check not recorded. Continue the Task: STEP.`
943
- Recording the done check (`lane done-check`), a blocked step (`lane step
944
- --block`) or a heartbeat note that starts with "blocked" lets the stop
945
- through, and so does a lane Dev can't serve. A block on an open issue that no
946
- live lane holds does not let it through (MW1-12.6, DEC-0486): the hook answers
947
- with the `lane leeway` command to run, and while a leeway is asked or granted
948
- it keeps the session on what is not blocked, or on the fix. One session is held at most
949
- `NODII_DEV_STOP_BLOCK_LIMIT` times in a row (default 5), as a cost backstop. A
950
- nudge hook skips the amendment guard and the waiting-results banner, since
951
- either would corrupt its JSON; it cannot run a Delta gather.
973
+ the stop while the lane's done check is not recorded (NODII-DEV-CLI-8), even
974
+ after an earlier block: it reads the lane from Dev and answers `Lane KEY: done
975
+ check not recorded. Continue the Task: STEP.` By default a blocked step, an
976
+ open wait or a heartbeat note that starts "blocked" or "WAITING:" lets the stop
977
+ through, except where leeway covers the blocker (MW1-12.6). With
978
+ `NODII_DEV_BLOCKED_NOT_EXIT=1` (NODII-DEV-CLI-191; off until its clause is in
979
+ force, as lane questions were, DEC-0503), BLOCKED is not an exit:
980
+ only a typed human gate lets the stop through. The gates
981
+ are a wait on an operator question (`Q-n`), a decision (`DEC-n`), a release or
982
+ launch day; a wait on a `steward-*` lane; or a latest heartbeat typed
983
+ `WAITING: human-gate totp|steward|spend: WHAT THE PERSON MUST DO`. Any other
984
+ blocker, such as a blocked step, a PR, an issue, another lane, or an untyped
985
+ BLOCKED or WAITING note, holds the stop. The answer then names the blocker and
986
+ says to claim it with `lane leeway` (MW1-12.6), fix it with the lane's
987
+ subagents, and keep working what is not blocked. Recording the done check
988
+ (`lane done-check`) lets the stop through, and so does a lane Dev can't serve.
989
+ While a leeway is asked or granted (MW1-12.6, DEC-0486), the hook keeps the
990
+ session on what is not blocked, or on the fix. A no-progress guard lets the
991
+ stop through after `NODII_DEV_STOP_STALL_LIMIT` holds in a row (default 2) with
992
+ no new tool call in the session's transcript. One session is held at most
993
+ `NODII_DEV_STOP_BLOCK_LIMIT` times in a row (default 40), as a cost backstop.
994
+ The Stop nudge answers "I couldn't …" with "fix it, or claim it and fix it with
995
+ your subagents", and citing an issue key no longer silences it. No
996
+ hook (the managed dispatcher included) runs the amendment guard or the
997
+ waiting-results banner: a hook cannot enforce them, since it exits 0 on
998
+ anything but a policy denial, either would corrupt its JSON, and it cannot run
999
+ a Delta gather (NODII-DEV-CLI-191). Every command the agent runs still reads
1000
+ both fresh from Dev; `hook nudge-pre` tells the lane of a pending amendment.
1001
+
1002
+ The managed dispatcher runs `safety-pre`, `nudge-pre`, `tooling-docs` and
1003
+ `safety-post` inside its own process, with the same code and the same answers
1004
+ as `nodii-dev hook ACTION`; every other handler still gets its own process. A
1005
+ `Bash` call in a lane was two dispatcher processes plus five handler processes;
1006
+ it is now the two dispatchers.
952
1007
 
953
1008
  ### DS conformance: `design roles` and `design check` (DEC-0034)
954
1009
 
@@ -1700,9 +1755,31 @@ which it also ends blocked from the lane's record. Every report carries `exit_co
1700
1755
  `lane_status` evidence. `process.pid` still holds the runtime's own PID, and the
1701
1756
  supervisor appends its report line to `process.log`.
1702
1757
 
1758
+ **Account failures (NODII-DEV-CLI-191).** When the newest line the runtime
1759
+ itself wrote (not a tool's output) names a usage limit (`Claude AI usage limit
1760
+ reached|EPOCH`, `You've hit your limit`, `5-hour limit reached ∙ resets 3pm`,
1761
+ a weekly limit, Codex's `You've hit your usage limit ... try again at|in ...`),
1762
+ an auth failure (`OAuth token has expired`, `401`, `authentication_error`,
1763
+ `Invalid API key`, `Please run /login`) or a network one (Cloudflare,
1764
+ `cf-ray`, `ECONNRESET`, `ETIMEDOUT`, `fetch failed`, `529 Overloaded`), the
1765
+ unfinished exit is reported with the fingerprint `lane-account-usage_limit`,
1766
+ `lane-account-auth` or `lane-account-network`, and the reason names the kind,
1767
+ the reset time and the line. The run's profile (`CLAUDE_CONFIG_DIR` or
1768
+ `CODEX_HOME`, else `~/.claude` or `~/.codex`) is recorded exhausted until the
1769
+ reset the line gives, else for 5 hours (a limit) or 1 hour (auth, network), in
1770
+ `exhausted-accounts.json` in the nodii-dev config directory (beside
1771
+ `config.json`). A later, shorter failure never shortens a recorded wait. The
1772
+ supervisor does not continue the same session on such a failure. `lane resume`
1773
+ reads the file before it asks Dev for a run: a lane whose recorded profile is
1774
+ still exhausted moves to another registered account of its runtime on this
1775
+ machine whose fresh band admits the lane's class (`ok` for long work), or is
1776
+ refused `ACCOUNT_EXHAUSTED` naming the reset; `--profile` naming the exhausted
1777
+ profile is refused too.
1778
+
1703
1779
  Before it reports an unfinished exit, the supervisor continues the same session
1704
- (NODII-DEV-CLI-9) when the lane is not BLOCKED (a lane with leeway asked,
1705
- granted or open to ask is not) and the run log names the
1780
+ (NODII-DEV-CLI-9) unless the lane waits on a typed human gate
1781
+ (NODII-DEV-CLI-191; a fixable blocker is continued with the claim-and-fix
1782
+ directive) and the run log names the
1706
1783
  session (Claude's `session_id`, Codex's `thread_id`). It runs `claude ...
1707
1784
  --resume SESSION`, or `codex exec resume ... SESSION -`, with the same model
1708
1785
  and permission mode, and sends `Lane KEY: done check not recorded. Continue the
@@ -1713,9 +1790,20 @@ Task: STEP.` on stdin. It does this up to `NODII_DEV_LANE_CONTINUATIONS` times
1713
1790
  continuations included, the supervisor heartbeats its run every
1714
1791
  `NODII_DEV_RUN_HEARTBEAT_SECONDS` (60) as the lane identity that owns it. A
1715
1792
  runtime that is alive but writes nothing gets no heartbeat from the supervisor,
1716
- so it goes Quiet at 15 minutes and Orphan at 45 (MW1-36). `lane heartbeat` and
1717
- the harness's `hook lane-heartbeat` (on `PostToolUse` and `Stop`) also heartbeat
1718
- the run. The hook beats at most once a minute per worktree. It reads its lane
1793
+ so it goes Quiet at 15 minutes and Orphan at 45 (MW1-36). A write to the
1794
+ session's Claude transcript (`<profile>/projects/<worktree>/<session>.jsonl`,
1795
+ and its subagents' transcripts) counts as one too. The same tick is the lane's
1796
+ harness heartbeat (`POST /lanes/KEY/heartbeat` with `source: "hook"`), which
1797
+ keeps Dev's `stuck` meaningful, and the run heartbeat's note ends `last
1798
+ activity <time>` (NODII-DEV-CLI-191). This lighter tracking is off unless
1799
+ `NODII_DEV_STOP_ONLY_HEARTBEAT=1` (see "Switched-off lane features"); off, the
1800
+ harness registers `hook lane-heartbeat` on every tool call and on `Stop` as
1801
+ before, and neither the supervisor nor `hook nudge-pre` beats the lane. On, no
1802
+ hook process runs on every tool call for it: the harness's `hook lane-heartbeat`
1803
+ is registered on `Stop` only. A session with no lane supervisor (no `NODII_DEV_RUN_ID`) is beaten from
1804
+ `hook nudge-pre`, which already runs on each tool call, at most once every 5
1805
+ minutes. `lane heartbeat` also heartbeats the run. The Stop hook beats at most
1806
+ once a minute per worktree. It reads its lane
1719
1807
  from Dev once and keeps the lane's id and key in the worktree's git private dir
1720
1808
  (`nodii-lane-heartbeat-lane.json`, beside `nodii-lane.json`), so a beat is one
1721
1809
  small POST. It reads the lane again when the branch or the lane key changes,
@@ -1889,6 +1977,66 @@ ask and, when Dev has no such ask, as a leeway, and `--leeway` goes straight to
1889
1977
  the leeway. `lane asks [--machine M] [--state S] [--lane KEY] [--cursor C]
1890
1978
  [--limit N]` lists asks.
1891
1979
 
1980
+ ### Switched-off lane features (NODII-DEV-CLI-191)
1981
+
1982
+ These features ship off by default until their clauses are in Dev's rulebook,
1983
+ as lane questions (`NODII_DEV_LANE_ASKS`) and BLOCKED is not an exit
1984
+ (`NODII_DEV_BLOCKED_NOT_EXIT`) did. The clauses are drafted on NODII-DEV-CLI-191
1985
+ for a Docs change; when a clause is in force, its default flips. Each
1986
+ is on only when its variable is exactly `1`, in the environment of the process
1987
+ that does the work: the coordinator's for `lane resume`, the lane session's for
1988
+ hooks, and the harness's for `harness update`.
1989
+
1990
+ | Variable | Feature | Off (the default) |
1991
+ |---|---|---|
1992
+ | `NODII_DEV_RESUME_IF_CHANGED` | `lane resume --if-changed` | Refused `RESUME_IF_CHANGED_OFF`; resume without it |
1993
+ | `NODII_DEV_SAME_SESSION_RESUME` | A resume continues the dead run's own session with a short prompt | A resume starts a fresh session with the Freeze |
1994
+ | `NODII_DEV_SUBAGENT_BUDGET` | The subagent budget line in the launch brief, gather's next step and the resume prompt | No line |
1995
+ | `NODII_DEV_ISSUES_GROUP` | `issues group` | Refused `ISSUES_GROUP_OFF` |
1996
+ | `NODII_DEV_LANE_MESSAGES` | `lane message`, `lane inbox` and their delivery by the Stop hook, `hook nudge-pre` and the supervisor | Refused `LANE_MESSAGES_OFF`; no hook delivers from an inbox file |
1997
+ | `NODII_DEV_STOP_ONLY_HEARTBEAT` | The harness beats a lane on `Stop` only; the supervisor and `hook nudge-pre` beat it while it acts | The harness's `hook lane-heartbeat` runs on every tool call and on `Stop`, as before |
1998
+
1999
+ ### Lane messages (NODII-DEV-CLI-191)
2000
+
2001
+ Off unless `NODII_DEV_LANE_MESSAGES=1` (see "Switched-off lane features").
2002
+
2003
+ Lanes, stewards and the coordinator message each other by name: a lane by its
2004
+ lane key, a steward by its steward lane key, the machine's coordinator as
2005
+ `coordinator`. `lane message TO --body TEXT` (or `--body-file FILE`) sends one.
2006
+ The sender is the session's own identity: the current lane (`NODII_DEV_LANE_KEY`),
2007
+ else this agent's Dev name. No flag names it (P-8). A delivered message is
2008
+ marked as information from another session, not an instruction: the lane's
2009
+ Freeze and the rulebook still govern.
2010
+
2011
+ Dev keeps the durable record: the message is a comment on the recipient lane's
2012
+ issue (a message to the coordinator goes on the sending lane's issue; `--issue
2013
+ ISSUE` names another), headed
2014
+
2015
+ ```
2016
+ [lane message] from <sender> to <recipient> · <ISO time> · id <short id>
2017
+ ```
2018
+
2019
+ A local inbox file is the doorbell. When the recipient runs on this machine (a
2020
+ lane provisioned here, a lane Dev places on this agent's machine, or the
2021
+ coordinator), the message is also appended as one JSON line,
2022
+ `{id, from, to, at, body, issueKey, commentRef}`, to
2023
+ `<config dir>/inbox/<key>.jsonl` (file 0600, folder 0700). A read marker beside
2024
+ it (`<key>.read.json`) records how far it has been delivered.
2025
+
2026
+ A lane gets an unread message without polling, Claude and Codex alike:
2027
+
2028
+ - at its next tool call, `hook nudge-pre` adds it to the call's context, from
2029
+ the inbox file alone (no Dev call);
2030
+ - at its next stop, the Stop hook holds the session with the messages (sender,
2031
+ time and body, oldest first, about 1,500 characters at most; the rest wait
2032
+ for the next delivery);
2033
+ - at its next continuation, the lane supervisor puts them ahead of the
2034
+ continuation prompt, so a headless lane takes them as its next turn.
2035
+
2036
+ Each message is delivered once. `lane inbox [KEY]` prints the unread messages
2037
+ and marks them read (`--all` prints every one); it also reads Dev's record and
2038
+ adds the messages sent from another machine that the local file lacks.
2039
+
1892
2040
  Dev counts what lanes wait on a machine's coordinator for (questions, leeway
1893
2041
  asks, waits and escalations) and names the count in the `x-dev-lane-items`
1894
2042
  response header. Every command the coordinator runs prints one line for it
@@ -1922,7 +2070,8 @@ shown and never gate. When Dev cannot be read the call passes with the note
1922
2070
  same check as a direct hook. The governor's launch gate is separate and still
1923
2071
  fails closed.
1924
2072
 
1925
- On the lane side, `hook nudge-pre` and `hook lane-heartbeat` tell a
2073
+ On the lane side, `hook nudge-pre` (and `hook lane-heartbeat`, where an older
2074
+ harness still runs it after a tool call) tell a
1926
2075
  long-running session about an amendment it has not acknowledged (an answer, a
1927
2076
  leeway grant, a rebrief) as `additionalContext`, through the 15-second read
1928
2077
  cache and at most once a minute per newest version, so it learns of it without
@@ -1987,6 +2136,7 @@ missing base ref, an invalid policy file or a git error lets the call through.
1987
2136
  | `ASK_DECIDED` | The ask is already answered or withdrawn | Read it with lane asks --lane KEY |
1988
2137
  | `LANE_NOT_FINISHED` | lane close before the lane's own agent marked the lane finished | The lane runs lane finish KEY --reason TEXT --evidence REF |
1989
2138
  | `LANE_ALREADY_FINISHED` | The lane is already marked finished | Nothing; its coordinator closes it with lane close |
2139
+ | `ACCOUNT_EXHAUSTED` | lane resume would relaunch onto a profile whose last run died on a usage limit, auth or the network, before its recorded reset, and no other account of its runtime has headroom | Resume after the reset it names, or move it with lane resume KEY --profile PATH --class CLASS |
1990
2140
  | `HARNESS_INVALID` | A managed hook entry is not one nodii-dev command, or Dev's harness cannot take the managed hooks | Run harness update, and file the entry as a harness issue |
1991
2141
  | `HARNESS_SETTINGS_INVALID` | .claude/settings.json or .codex/hooks.json is not valid JSON | Repair the file, then run harness update |
1992
2142
  | `TOOLING_DOCS_STALE` | The change touches a tooling file named in nodii.repo.yaml (toolingDocs.tooling) and no docs file (toolingDocs.docs), so hook tooling-docs refuses the push or the pull request (MW1-46.3) | Update the docs in the same change, or add the commit trailer Docs-unaffected: <reason>; check with repo docs-check |
package/dist/accounts.js CHANGED
@@ -7,7 +7,7 @@ import { execFile as execFileCallback } from "node:child_process";
7
7
  import { createHash } from "node:crypto";
8
8
  import { mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
9
9
  import { homedir, tmpdir } from "node:os";
10
- import { dirname, isAbsolute, join, normalize } from "node:path";
10
+ import { basename, dirname, isAbsolute, join, normalize } from "node:path";
11
11
  import { promisify } from "node:util";
12
12
  import { CliError, configPath, devRequest, encode, readConfig } from "./core.js";
13
13
 
@@ -224,6 +224,67 @@ async function resolveCodexBin(run = execFile) {
224
224
  catch { return null; }
225
225
  }
226
226
 
227
+ // NODII-DEV-CLI-191: a profile whose lane run died on a usage limit, auth
228
+ // or the network, until its reset. The lane supervisor writes it (as the
229
+ // lane's identity, whose config sits under agents/) and lane resume reads it
230
+ // (as the coordinator's), so it lives in the nodii-dev dir both share.
231
+ export function exhaustedAccountsPath(path = configPath()) {
232
+ const dir = dirname(path);
233
+ return join(basename(dir) === "agents" ? dirname(dir) : dir, "exhausted-accounts.json");
234
+ }
235
+
236
+ async function readExhausted(path, read = readFile) {
237
+ try {
238
+ const entries = JSON.parse(await read(path, "utf8"));
239
+ return entries && typeof entries === "object" && !Array.isArray(entries) ? entries : {};
240
+ } catch { return {}; }
241
+ }
242
+
243
+ const liveOnly = (entries, now) => Object.fromEntries(Object.entries(entries)
244
+ .filter(([, entry]) => Date.parse(entry?.until) > now.getTime()));
245
+
246
+ /** The profiles recorded exhausted whose reset has not come yet, by profile. */
247
+ export async function liveExhaustedAccounts({ path = exhaustedAccountsPath(), now = () => new Date(), read = readFile } = {}) {
248
+ return liveOnly(await readExhausted(path, read), now());
249
+ }
250
+
251
+ /**
252
+ * Record a profile exhausted until `entry.until`. A later failure with an
253
+ * earlier time never shortens a recorded wait; entries past their time are
254
+ * dropped.
255
+ */
256
+ export async function recordExhaustedAccount(profile, entry, { path = exhaustedAccountsPath(), now = () => new Date() } = {}) {
257
+ const key = profilePath(profile);
258
+ const entries = liveOnly(await readExhausted(path), now());
259
+ const recorded = entries[key];
260
+ if (!recorded || Date.parse(entry.until) >= Date.parse(recorded.until)) entries[key] = entry;
261
+ await mkdir(dirname(path), { recursive: true, mode: 0o700 });
262
+ const temporary = `${path}.tmp-${process.pid}`;
263
+ await writeFile(temporary, `${JSON.stringify(entries, null, 2)}\n`, { mode: 0o600 });
264
+ await rename(temporary, path);
265
+ return entries[key];
266
+ }
267
+
268
+ // MW1-38.2: a long resume needs an ok band; a short or no-build one fits up to short_only.
269
+ const ADMITS = { long: ["ok"], short: ["ok", "warning", "short_only"], no_build: ["ok", "warning", "short_only"] };
270
+
271
+ /**
272
+ * Another registered account of the runtime on this machine whose freshly
273
+ * read band admits the work class, skipping `from` and the `exclude`d
274
+ * (recorded exhausted) profiles; null when none has headroom or the
275
+ * accounts cannot be listed.
276
+ */
277
+ export async function pickHeadroomAccount({ runtime, from, exclude = [], workClass = "long" }, { request = devRequest, config = readConfig, readers = READERS } = {}) {
278
+ let accounts;
279
+ try { accounts = await listAccounts(await coordinatorMachineId({ request, config }), { request }); }
280
+ catch { return null; }
281
+ const skip = new Set([from, ...exclude].map(profilePath));
282
+ const candidates = accounts.filter((account) => account.runtime === runtime && !skip.has(profilePath(account.profile)));
283
+ if (!candidates.length) return null;
284
+ const results = await reportUsage(candidates, { request, readers });
285
+ return results.find((result) => !result.error && (ADMITS[workClass] ?? ADMITS.long).includes(result.band)) ?? null;
286
+ }
287
+
227
288
  const READERS = { claude: readClaudeUsage, codex: readCodexUsage };
228
289
 
229
290
  /** The usage ceiling body Dev stores for one reading. */