@phren/cli 0.3.35 → 0.3.37

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 (89) hide show
  1. package/dist/bridge/account-choice.d.ts +82 -0
  2. package/dist/bridge/account-choice.js +173 -0
  3. package/dist/bridge/account-failover.d.ts +57 -0
  4. package/dist/bridge/account-failover.js +181 -0
  5. package/dist/bridge/account-usage.d.ts +2 -0
  6. package/dist/bridge/account-usage.js +17 -2
  7. package/dist/bridge/agent-hooks.d.ts +11 -1
  8. package/dist/bridge/agent-hooks.js +56 -19
  9. package/dist/bridge/changes.js +18 -9
  10. package/dist/bridge/dispatch-command.js +3 -1
  11. package/dist/bridge/dispatch-returns.d.ts +12 -0
  12. package/dist/bridge/dispatch-returns.js +37 -6
  13. package/dist/bridge/dispatch.d.ts +31 -3
  14. package/dist/bridge/dispatch.js +68 -10
  15. package/dist/bridge/hand-off.d.ts +23 -1
  16. package/dist/bridge/hand-off.js +36 -3
  17. package/dist/bridge/health.js +3 -1
  18. package/dist/bridge/host-key.d.ts +16 -0
  19. package/dist/bridge/host-key.js +35 -0
  20. package/dist/bridge/launch-brief.d.ts +5 -0
  21. package/dist/bridge/launch-brief.js +21 -0
  22. package/dist/bridge/link.js +11 -4
  23. package/dist/bridge/owner-inbox-sources.d.ts +5 -0
  24. package/dist/bridge/owner-inbox-sources.js +94 -0
  25. package/dist/bridge/owner-inbox-view.js +20 -1
  26. package/dist/bridge/owner-inbox.d.ts +7 -3
  27. package/dist/bridge/owner-inbox.js +113 -69
  28. package/dist/bridge/pair.js +3 -2
  29. package/dist/bridge/peers.js +4 -2
  30. package/dist/bridge/schedule-launch.js +5 -1
  31. package/dist/bridge/schedule-watch.d.ts +3 -0
  32. package/dist/bridge/schedule-watch.js +27 -1
  33. package/dist/bridge/server-launch.js +6 -2
  34. package/dist/bridge/server-routes.js +5 -1
  35. package/dist/bridge/server.js +9 -23
  36. package/dist/bridge/sudo.d.ts +36 -6
  37. package/dist/bridge/sudo.js +180 -37
  38. package/dist/bridge/usage.d.ts +4 -2
  39. package/dist/bridge/usage.js +4 -2
  40. package/dist/bridge/worker-reports.d.ts +8 -1
  41. package/dist/bridge/worker-reports.js +28 -7
  42. package/dist/bridge-hook.mjs +7120 -6298
  43. package/dist/clanker.d.ts +54 -0
  44. package/dist/clanker.js +188 -0
  45. package/dist/cli/config.js +56 -0
  46. package/dist/cli/hooks-output.d.ts +1 -1
  47. package/dist/cli/hooks-output.js +28 -21
  48. package/dist/cli/hooks.js +1 -1
  49. package/dist/cli/namespaces-skills.js +2 -2
  50. package/dist/cli/namespaces-tasks.js +46 -7
  51. package/dist/cli/session-start.js +12 -3
  52. package/dist/cli/session-stop.js +9 -0
  53. package/dist/cli/team.js +3 -0
  54. package/dist/cli-handlers.js +7 -0
  55. package/dist/cli-registry.js +1 -0
  56. package/dist/data/task-format.d.ts +5 -1
  57. package/dist/data/task-format.js +13 -5
  58. package/dist/index.js +82 -50
  59. package/dist/init/init-configure.d.ts +2 -0
  60. package/dist/init/init-configure.js +12 -0
  61. package/dist/init/init-uninstall.js +21 -2
  62. package/dist/init/init.d.ts +2 -0
  63. package/dist/init/init.js +11 -3
  64. package/dist/init/preferences.d.ts +12 -0
  65. package/dist/init/teardown.js +18 -4
  66. package/dist/link/doctor.js +2 -2
  67. package/dist/link/link.js +9 -0
  68. package/dist/link/refresh.d.ts +10 -0
  69. package/dist/link/refresh.js +34 -0
  70. package/dist/mcp/local-index.d.ts +20 -0
  71. package/dist/mcp/local-index.js +39 -1
  72. package/dist/modules/registry.js +1 -1
  73. package/dist/shared/index.d.ts +14 -0
  74. package/dist/shared/index.js +88 -74
  75. package/dist/shared/retrieval.js +1 -1
  76. package/dist/skill/files.js +40 -11
  77. package/dist/skill/registry.d.ts +6 -0
  78. package/dist/skill/registry.js +21 -5
  79. package/dist/task/lifecycle.js +3 -1
  80. package/dist/tools/dispatch.js +7 -4
  81. package/dist/tools/finding.js +20 -11
  82. package/dist/tools/graph.d.ts +2 -0
  83. package/dist/tools/graph.js +2 -0
  84. package/dist/tools/search.d.ts +2 -0
  85. package/dist/tools/search.js +88 -6
  86. package/dist/tools/tasks.js +45 -0
  87. package/dist/tools/types.d.ts +3 -1
  88. package/dist/tools/types.js +3 -2
  89. package/package.json +1 -1
@@ -193,7 +193,9 @@ export class AgentHooks {
193
193
  pushBindings = new PushBindingStore();
194
194
  /** Held asks that were pushed: action -> when the notification expires. */
195
195
  pushedHolds = new Map();
196
- /** Pushed asks whose hold ended with the request left in the terminal. */
196
+ /** Held asks whose hold ended with the request left in the terminal, by
197
+ * pane: the action keeps answering the pane's dialog, so a phone card,
198
+ * notification or dispatcher holding it is not left with a dead id. */
197
199
  releasedHolds = new Map();
198
200
  /** Terminal dialogs pushed to phones: by pane, the dialog last pushed; by
199
201
  * action, what an answer from the notification types. */
@@ -1054,8 +1056,10 @@ export class AgentHooks {
1054
1056
  this.pushBindings.dropAction(id);
1055
1057
  }
1056
1058
  async answer(target, id, decision, updatedInput) {
1057
- // A terminal dialog offered to a dispatching Hook (`workerApproval`) or pushed: answered with the pane's own keys.
1058
- if (id.startsWith("dialog-")) {
1059
+ // A terminal dialog offered to a dispatching Hook (`workerApproval`) or
1060
+ // pushed, or a held ask whose hold ended with its dialog still on screen:
1061
+ // answered with the pane's own keys.
1062
+ if (id.startsWith("dialog-") || (!this.pending.has(id) && await this.releasedHoldDialog(id))) {
1059
1063
  const dialog = this.dialogActions.get(id);
1060
1064
  if (!dialog || JSON.stringify(dialog.target) !== JSON.stringify(target))
1061
1065
  throw new BridgeError(409, "This approval is no longer pending.");
@@ -1190,16 +1194,7 @@ export class AgentHooks {
1190
1194
  await this.answer(pending.target, linked.action, decision);
1191
1195
  return;
1192
1196
  }
1193
- const released = [...this.releasedHolds].find(([, hold]) => hold.action === linked.action);
1194
- if (released && !this.dialogActions.has(linked.action)) {
1195
- // The hold just ended: read the pane now rather than wait for the tick.
1196
- const target = JSON.parse(released[0]);
1197
- await this.syncTerminalDialog(target, true).catch(() => { });
1198
- const entry = this.terminalPrompts.get(released[0]);
1199
- if (entry?.choice?.title)
1200
- this.adoptReleasedHold(released[0], target, entry.choice, entry.choice.title);
1201
- }
1202
- if (this.dialogActions.has(linked.action)) {
1197
+ if (await this.releasedHoldDialog(linked.action)) {
1203
1198
  await this.answerDialog(linked.action, decision);
1204
1199
  return;
1205
1200
  }
@@ -1221,6 +1216,20 @@ export class AgentHooks {
1221
1216
  }
1222
1217
  throw new BridgeError(409, "This approval is no longer pending.");
1223
1218
  }
1219
+ /** Whether this action now answers a terminal dialog: a released hold's
1220
+ * pane is read at once rather than at the next tick, and its dialog
1221
+ * adopted under the hold's own action. */
1222
+ async releasedHoldDialog(action) {
1223
+ const released = [...this.releasedHolds].find(([, hold]) => hold.action === action);
1224
+ if (released && !this.dialogActions.has(action)) {
1225
+ const target = JSON.parse(released[0]);
1226
+ await this.syncTerminalDialog(target, true).catch(() => { });
1227
+ const entry = this.terminalPrompts.get(released[0]);
1228
+ if (entry?.choice?.title)
1229
+ this.adoptReleasedHold(released[0], target, entry.choice, entry.choice.title);
1230
+ }
1231
+ return this.dialogActions.has(action);
1232
+ }
1224
1233
  /** Where a pushed ask lives, without answering it: the phone opens that
1225
1234
  * session's details when the notification itself is tapped. */
1226
1235
  pushTarget(binding) {
@@ -1283,6 +1292,18 @@ export class AgentHooks {
1283
1292
  .then(delivered => { if (!delivered)
1284
1293
  this.dropDialogPush(key); }).catch(() => this.dropDialogPush(key));
1285
1294
  }
1295
+ // A dialog stays answerable for as long as its pane shows it.
1296
+ const horizon = Date.now() + DIALOG_PUSH_MS;
1297
+ for (const key of waiting) {
1298
+ const hold = this.releasedHolds.get(key);
1299
+ if (hold && hold.expiresAt > Date.now())
1300
+ hold.expiresAt = Math.max(hold.expiresAt, horizon);
1301
+ for (const action of [this.dialogPushes.get(key)?.action, this.forwardedDialogs.get(key)?.action]) {
1302
+ const dialog = action ? this.dialogActions.get(action) : undefined;
1303
+ if (dialog && dialog.expiresAt > Date.now())
1304
+ dialog.expiresAt = Math.max(dialog.expiresAt, horizon);
1305
+ }
1306
+ }
1286
1307
  for (const [key, hold] of this.releasedHolds) {
1287
1308
  // Answered in the terminal, or expired: the notification can no longer act.
1288
1309
  if ((!waiting.has(key) && JSON.parse(key).server === server) || hold.expiresAt <= Date.now()) {
@@ -1348,10 +1369,12 @@ export class AgentHooks {
1348
1369
  const title = entry && (entry.dialog || entry.released) ? entry.choice?.title : undefined;
1349
1370
  if (!entry?.choice || !title)
1350
1371
  return undefined;
1372
+ // The ask was offered while held: keep offering it under the same id.
1373
+ this.adoptReleasedHold(key, target, entry.choice, title);
1351
1374
  const pushedDialog = this.dialogPushes.get(key);
1352
1375
  // A dialog is the same one only with the same title and command: Claude and Codex share generic titles.
1353
1376
  const pushedAction = pushedDialog && this.dialogActions.get(pushedDialog.action);
1354
- let action = pushedDialog?.title === title && pushedAction && pushedAction.choice.body === entry.choice.body ? pushedDialog.action : undefined;
1377
+ let action = pushedDialog?.title === title && pushedAction && pushedAction.choice.body === entry.choice.body && pushedAction.expiresAt > Date.now() ? pushedDialog.action : undefined;
1355
1378
  if (!action) {
1356
1379
  const known = this.forwardedDialogs.get(key);
1357
1380
  if (known?.title === title && known.body === entry.choice.body && (this.dialogActions.get(known.action)?.expiresAt ?? 0) > Date.now())
@@ -1392,14 +1415,27 @@ export class AgentHooks {
1392
1415
  .then(delivered => { if (!delivered)
1393
1416
  drop(); }).catch(drop);
1394
1417
  }
1418
+ /** Moves a released hold onto the dialog its pane now draws, under the
1419
+ * hold's action: as the pushed dialog when its notification is on the
1420
+ * phone, else as the dialog offered to a dispatching Hook. True when the
1421
+ * hold was pushed, so the dialog needs no second notification. */
1395
1422
  adoptReleasedHold(key, target, choice, title) {
1396
1423
  const hold = this.releasedHolds.get(key);
1424
+ if (!hold)
1425
+ return false;
1397
1426
  this.releasedHolds.delete(key);
1398
- if (!hold || hold.expiresAt <= Date.now())
1427
+ if (hold.expiresAt <= Date.now()) {
1428
+ this.dropPushBindings(hold.action);
1399
1429
  return false;
1400
- this.dialogPushes.set(key, { action: hold.action, title });
1430
+ }
1401
1431
  this.dialogActions.set(hold.action, { target, choice, expiresAt: hold.expiresAt });
1402
- return true;
1432
+ if (hold.pushed)
1433
+ this.dialogPushes.set(key, { action: hold.action, title });
1434
+ else {
1435
+ this.dropForwardedDialog(key);
1436
+ this.forwardedDialogs.set(key, { action: hold.action, title, body: choice.body });
1437
+ }
1438
+ return hold.pushed;
1403
1439
  }
1404
1440
  dropDialogPush(key) {
1405
1441
  const pushed = this.dialogPushes.get(key);
@@ -1743,8 +1779,9 @@ export class AgentHooks {
1743
1779
  released = true;
1744
1780
  this.pending.delete(action);
1745
1781
  this.rememberTerminalPrompt(target, body);
1746
- if (this.pushedHolds.has(action))
1747
- this.releasedHolds.set(JSON.stringify(target), { action, expiresAt: this.pushedHolds.get(action) });
1782
+ // The id was already handed out (phone card, push, dispatcher): it keeps answering the dialog.
1783
+ const pushed = this.pushedHolds.get(action);
1784
+ this.releasedHolds.set(JSON.stringify(target), { action, expiresAt: pushed ?? Date.now() + DIALOG_PUSH_MS, pushed: pushed !== undefined });
1748
1785
  this.pushedHolds.delete(action);
1749
1786
  res.end("{}");
1750
1787
  }, APPROVAL_HOLD_MS);
@@ -17,7 +17,11 @@ export const changedFileSchema = z.object({ root: z.string(), path: z.string(),
17
17
  added: z.number().int().nonnegative(), removed: z.number().int().nonnegative(), redacted: z.boolean().optional(), binary: z.boolean().optional(), truncated: z.boolean().optional() });
18
18
  const changeRowSchema = z.object({ toolUseId: z.string(), files: z.array(changedFileSchema) });
19
19
  export const secretName = (file) => /^(?:\.env(?:\..*)?|.*\.(?:pem|key|p12|pfx|keychain-db|tfstate)|id_rsa.*|id_ed25519.*|(?:.*\.)?credentials\.json|\.netrc|\.npmrc|\.pypirc)$/i.test(path.basename(file));
20
- const gitPool = new ProcessPool(2);
20
+ /** Two captures at a time, each holding its slot for all of its Git work. A
21
+ * slot per Git process interleaved every waiting capture, so under load they
22
+ * all finished late together and every one overran the budget; now they finish
23
+ * in turn and only the end of a long queue misses it. */
24
+ const capturePool = new ProcessPool(2);
21
25
  /** Tools whose filesystem changes are captured around the lifecycle callback. */
22
26
  export const SHELL_TOOLS = new Set(["Bash", "bash", "shell", "Shell", "exec_command", "shell_command", "local_shell", "write_stdin"]);
23
27
  const NAMED = /(?<![\w@:/])(?:~\/|\.\/|\/)[\w.@+~-]+(?:\/[\w.@+~-]+)*/g;
@@ -50,10 +54,12 @@ export function namedPaths(command, input = {}) {
50
54
  }
51
55
  return [...found].slice(0, 48);
52
56
  }
57
+ /** Only inside a `capturePool` slot. */
53
58
  async function git(cwd, args, extra = {}, signal) {
54
- return gitPool.run(signal, async () => (countGit("changes"), await exec("git", ["-C", cwd, "--no-pager", ...args], {
59
+ countGit("changes");
60
+ return (await exec("git", ["-C", cwd, "--no-pager", ...args], {
55
61
  signal, timeout: 10_000, maxBuffer: 8_388_608, env: { ...checkoutGitEnv(), ...extra },
56
- })).stdout);
62
+ })).stdout;
57
63
  }
58
64
  /** The repository holding `target` (a file, a folder, or something not yet
59
65
  * created), confined to the user's home; undefined otherwise. */
@@ -258,7 +264,7 @@ export class ToolChanges {
258
264
  const snapshot = { at: Date.now(), conversation, own: new Set(claimed), trees: new Map(), taking: true };
259
265
  this.snapshots.set(key, snapshot);
260
266
  try {
261
- await this.budget(async (signal) => {
267
+ await this.budget(signal => capturePool.run(signal, async () => {
262
268
  await realpath(cwd); // A vanished checkout must not resolve to its parent repository.
263
269
  const roots = new Set();
264
270
  for (const target of [cwd, phrenStoreRoot(), ...namedPaths(command, input)]) {
@@ -273,7 +279,7 @@ export class ToolChanges {
273
279
  snapshot.trees.set(root, await scratchTree(root, signal));
274
280
  }
275
281
  signal.throwIfAborted();
276
- });
282
+ }));
277
283
  snapshot.taking = false;
278
284
  if (snapshot.dropped) {
279
285
  await this.discard(snapshot);
@@ -351,10 +357,13 @@ export class ToolChanges {
351
357
  async compute(snapshot) {
352
358
  try {
353
359
  return await this.budget(async (signal) => {
354
- const files = [];
355
- for (const [root, before] of snapshot.trees) {
356
- files.push(...await treeDiff(root, before.hash, await treeHash(root, before.env, signal), before.env, signal));
357
- }
360
+ const files = await capturePool.run(signal, async () => {
361
+ const found = [];
362
+ for (const [root, before] of snapshot.trees) {
363
+ found.push(...await treeDiff(root, before.hash, await treeHash(root, before.env, signal), before.env, signal));
364
+ }
365
+ return found;
366
+ });
358
367
  // A file another agent's edit named during this call is its change,
359
368
  // not this call's, even though it landed inside the same window.
360
369
  // A call that names its files (an Edit, a Write, a patch) changed
@@ -5,6 +5,7 @@ import { hookRequest } from "./client.js";
5
5
  import { dispatchSchema } from "./dispatch.js";
6
6
  import { handOff } from "./hand-off.js";
7
7
  import { terminalPaneFromEnv } from "./terminal.js";
8
+ import { dispatchIdFromEnv } from "./launch-brief.js";
8
9
  import { addGrant, grantSchema, listNamedGrants, removeGrant } from "./grants.js";
9
10
  import { sessionId } from "./protocol.js";
10
11
  export async function runDispatch(args) {
@@ -13,7 +14,8 @@ export async function runDispatch(args) {
13
14
  const origin = await terminalPaneFromEnv();
14
15
  if (!origin || !values.prs)
15
16
  throw new Error("Usage inside a worker pane: phren dispatch report --prs <JSON array>");
16
- console.log(JSON.stringify(await hookRequest("/v1/dispatch/report", { origin, prs: prsSchema.parse(JSON.parse(values.prs)) }), null, 2));
17
+ const dispatch = dispatchIdFromEnv();
18
+ console.log(JSON.stringify(await hookRequest("/v1/dispatch/report", { origin, prs: prsSchema.parse(JSON.parse(values.prs)), ...(dispatch ? { dispatch } : {}) }), null, 2));
17
19
  return 0;
18
20
  }
19
21
  if (args.length === 1 && args[0] === "status") {
@@ -103,6 +103,11 @@ export interface WorkerObservation {
103
103
  /** The worker's checkout could not be read in time: the turn may be done,
104
104
  * but it is not closed on that (worker-close.ts). */
105
105
  unchecked?: true;
106
+ /** Where a worker that hit its Claude usage limit was working, for the dispatch that continues it. */
107
+ checkout?: {
108
+ path: string;
109
+ branch?: string;
110
+ };
106
111
  }
107
112
  export interface WorkerReaders {
108
113
  snapshot: (server: string) => Promise<Json>;
@@ -124,6 +129,8 @@ export interface WorkerReaders {
124
129
  uncommitted?: (directory: string) => Promise<Uncommitted>;
125
130
  /** Whether other panes' folders share the worker's checkout, whose changes then are not only its own. */
126
131
  shared?: (directory: string, folders: readonly unknown[]) => Promise<boolean>;
132
+ /** The branch checked out in a folder. */
133
+ branch?: (directory: string) => Promise<string | undefined>;
127
134
  }
128
135
  export declare function paneTurn(server: string, pane: Json, source: Provider): Promise<TurnRecord | undefined>;
129
136
  /** The default readers with the approval reader of the Hook that runs the workers. */
@@ -211,6 +218,10 @@ export interface DispatchReturnsOptions {
211
218
  /** A worker's new forwarded request was recorded. Returns true when this Hook pushed it to its phone. */
212
219
  onApproval?: (receipt: Receipt, approval: NonNullable<Receipt["approval"]>) => boolean | void;
213
220
  close?: (receipt: Receipt) => Promise<Json>;
221
+ /** Continues Claude workers stopped by their usage limit on another account, after each poll (account-failover.ts). */
222
+ failover?: {
223
+ run: () => Promise<void>;
224
+ };
214
225
  now?: () => number;
215
226
  }
216
227
  /** One notice's delivery id, named by what it reports: the same returns keep the same id on a retry. */
@@ -230,6 +241,7 @@ export declare class DispatchReturns {
230
241
  private readonly localAnswer?;
231
242
  private readonly onApproval?;
232
243
  private readonly close?;
244
+ private readonly failover?;
233
245
  private lastPoll;
234
246
  private readonly lastNotice;
235
247
  /** A return is waiting for a dispatching agent that was busy: try again on
@@ -2,7 +2,9 @@ import { intentionallyClosed } from "./worker-close.js";
2
2
  import { workerPrs, readIntegrator } from "./worker-reports.js";
3
3
  import { prsSchema } from "./return-contract.js";
4
4
  import { sessionStalls } from "./stalls.js";
5
+ import { execFile } from "node:child_process";
5
6
  import { createHash } from "node:crypto";
7
+ import { promisify } from "node:util";
6
8
  import { z } from "zod";
7
9
  import { logger } from "../logger.js";
8
10
  import { arrivalOf, dispatchStatus, updateReceipt } from "./dispatch.js";
@@ -14,7 +16,7 @@ import { handOff } from "./hand-off.js";
14
16
  import { hookPeers, peerRequest } from "./peers.js";
15
17
  import { isLocalComputer } from "./dispatch-hosts.js";
16
18
  import { BridgeError, objects, startingTargetSchema, targetSchema } from "./protocol.js";
17
- import { ownerQuestion, readFinalTurn } from "./schedule-watch.js";
19
+ import { isClaudeUsageLimit, ownerQuestion, readFinalTurn } from "./schedule-watch.js";
18
20
  import { liveWork, runningTasks } from "./session-activity.js";
19
21
  import { terminalProvider } from "./terminal.js";
20
22
  import { childAgentTree, runningChildAgents } from "./transcripts.js";
@@ -54,6 +56,19 @@ const SNAPSHOT_AGE_MS = 5_000;
54
56
  // older Hook's target schema strips it, so it is safe to send to any peer.
55
57
  const workerTarget = z.union([targetSchema.extend({ dispatch: briefId.optional() }), startingTargetSchema.extend({ dispatch: briefId.optional() })]);
56
58
  export const workerRequestSchema = z.object({ targets: z.array(workerTarget).min(1).max(64) }).strict();
59
+ const run = promisify(execFile);
60
+ async function checkedOutBranch(directory) {
61
+ const { stdout } = await run("git", ["-C", directory, "rev-parse", "--abbrev-ref", "HEAD"], { timeout: 3_000 });
62
+ const branch = stdout.trim();
63
+ return branch && branch !== "HEAD" ? branch.slice(0, 256) : undefined;
64
+ }
65
+ /** A worker stopped by its Claude usage limit: where it was working, so another account can pick it up there. */
66
+ async function limitCheckout(seen, directory, readers) {
67
+ if (!isClaudeUsageLimit(seen.error) || typeof directory !== "string" || !directory)
68
+ return {};
69
+ const branch = await (readers.branch ?? checkedOutBranch)(directory).catch(() => undefined);
70
+ return { checkout: { path: directory.slice(0, 4096), ...(branch ? { branch } : {}) } };
71
+ }
57
72
  export async function paneTurn(server, pane, source) {
58
73
  if (source !== "opencode")
59
74
  return readTurn(server, String(pane.pane_id));
@@ -72,6 +87,7 @@ const defaultReaders = {
72
87
  lost: (server, pane, session) => codexServers.lostTurn(server, pane, session),
73
88
  uncommitted: directory => recentUncommitted(directory),
74
89
  shared: sharedCheckout,
90
+ branch: checkedOutBranch,
75
91
  };
76
92
  /** The default readers with the approval reader of the Hook that runs the workers. */
77
93
  export const workerReaders = (approval) => ({ ...defaultReaders, approval });
@@ -222,7 +238,8 @@ export async function workerStates(input, readers = defaultReaders) {
222
238
  const seen = await fromTurn(own, own.session, status, target.source, readers);
223
239
  const full = targetSchema.safeParse({ ...target, session: seen.session });
224
240
  const prs = full.success && seen.state === "done" ? await workerPrs(full.data, own) : undefined;
225
- return { ...seen, ...(prs ? { prs } : {}), ...await unfinished(seen, own.stop?.cwd ?? paneDirectory(pane), readers, s, pane, prs), ...(full.success && seen.state === "working" ? await readers.stall?.(full.data, { ...pane, agent_status: "working" }, liveReader(own, target.source, own.session, readers)) : {}) };
241
+ return { ...seen, ...(prs ? { prs } : {}), ...await unfinished(seen, own.stop?.cwd ?? paneDirectory(pane), readers, s, pane, prs),
242
+ ...await limitCheckout(seen, own.stop?.cwd ?? paneDirectory(pane), readers), ...(full.success && seen.state === "working" ? await readers.stall?.(full.data, { ...pane, agent_status: "working" }, liveReader(own, target.source, own.session, readers)) : {}) };
226
243
  }
227
244
  const session = expected ?? current;
228
245
  const state = ["working", "idle", "done", "blocked"].find(value => value === status) ?? "unknown";
@@ -243,7 +260,7 @@ export async function workerStates(input, readers = defaultReaders) {
243
260
  }
244
261
  const seen = { state, session, completed: turn?.completed === true, ...(end?.background ? { background: end.background } : {}), ...(turn?.error ? { error: turn.error } : {}),
245
262
  ...(turn?.interrupted ? { interrupted: true } : {}), ...replyFields(turn?.lastAssistant) };
246
- return { ...seen, ...await unfinished(seen, paneDirectory(pane), readers, s, pane) };
263
+ return { ...seen, ...await unfinished(seen, paneDirectory(pane), readers, s, pane), ...await limitCheckout(seen, paneDirectory(pane), readers) };
247
264
  }));
248
265
  // Only a conversation this dispatch named can be answered; a starting target has no session yet.
249
266
  return { workers: workers.map((seen, index) => {
@@ -262,6 +279,7 @@ const observationSchema = z.object({
262
279
  prs: prsSchema.optional(),
263
280
  stalled: z.boolean().optional(), stalledSince: z.string().datetime().optional(), stallFor: z.number().nonnegative().optional(),
264
281
  interrupted: z.boolean().optional(), approval: z.unknown().optional(), unfinished: z.string().max(200).optional(), unchecked: z.boolean().optional(),
282
+ checkout: z.object({ path: z.string().max(4096), branch: z.string().max(256).optional() }).strict().optional(),
265
283
  }).passthrough();
266
284
  /** A worker's forwarded permission request as its Hook sent it; an invalid one is ignored, not a reason to drop the state. */
267
285
  const approvalObservation = z.object({
@@ -402,7 +420,9 @@ function observeState(receipt, parsed, now) {
402
420
  ...(next === "working" && waitingSince ? { waitingSince } : {}) };
403
421
  if (next !== "working") {
404
422
  receipt.returned = { state: next, at, read: false,
405
- ...(seen.reply && (next === "done" || next === "needs-you") ? { reply: seen.reply, ...(seen.truncated ? { truncated: true } : {}) } : {}),
423
+ // A worker stopped by its usage limit keeps its last reply: the dispatch that continues it hands it over.
424
+ ...(seen.reply && (next === "done" || next === "needs-you" || next === "failed" && isClaudeUsageLimit(failed)) ? { reply: seen.reply, ...(seen.truncated ? { truncated: true } : {}) } : {}),
425
+ ...(next === "failed" && seen.checkout ? { checkout: seen.checkout } : {}),
406
426
  ...(next === "done" && seen.prs ? { prs: seen.prs } : {}),
407
427
  ...(next === "stalled" ? { stalledSince: seen.stalledSince, stallFor: seen.stallFor } : {}),
408
428
  ...(failed ? { error: failed } : {}), ...(question ? { question } : {}), ...(turn ? { turn } : {}),
@@ -447,6 +467,8 @@ export function returnRow(receipt) {
447
467
  ...(receipt.approval && returned.state === "blocked" ? { approval: { actionId: receipt.approval.actionId, tool: receipt.approval.tool,
448
468
  ...(receipt.approval.request ? { request: receipt.approval.request } : {}), ...(receipt.approval.title ? { title: receipt.approval.title } : {}),
449
469
  ...(receipt.approval.terminal ? { terminal: true } : {}) } } : {}),
470
+ ...(receipt.account ? { account: receipt.account } : {}), ...(receipt.accountChoice ? { accountChoice: receipt.accountChoice } : {}),
471
+ ...(receipt.continued ? { continued: receipt.continued } : {}), ...(receipt.continues ? { continues: receipt.continues } : {}),
450
472
  ...(receipt.target ? { target: receipt.target } : {}) };
451
473
  }
452
474
  const originKey = (origin) => JSON.stringify([origin.server, origin.workspace, origin.tab, origin.pane, origin.terminal]);
@@ -469,6 +491,7 @@ export class DispatchReturns {
469
491
  localAnswer;
470
492
  onApproval;
471
493
  close;
494
+ failover;
472
495
  lastPoll = -Infinity;
473
496
  lastNotice = new Map();
474
497
  /** A return is waiting for a dispatching agent that was busy: try again on
@@ -477,6 +500,7 @@ export class DispatchReturns {
477
500
  running;
478
501
  constructor(options = {}) {
479
502
  this.close = options.close;
503
+ this.failover = options.failover;
480
504
  this.peers = options.peers ?? hookPeers;
481
505
  this.request = options.request ?? peerRequest;
482
506
  this.localWorkers = options.localWorkers ?? (input => workerStates(input));
@@ -546,8 +570,15 @@ export class DispatchReturns {
546
570
  return Promise.resolve();
547
571
  if (poll)
548
572
  this.lastPoll = this.now();
549
- this.running = (async () => { if (poll)
550
- await this.poll(); await this.forwardPrs(); await this.cleanup(); await this.notify(); })()
573
+ this.running = (async () => {
574
+ if (poll) {
575
+ await this.poll();
576
+ await this.failover?.run().catch(error => logger.warn("dispatch", `Account failover: ${error instanceof Error ? error.message : String(error)}`));
577
+ }
578
+ await this.forwardPrs();
579
+ await this.cleanup();
580
+ await this.notify();
581
+ })()
551
582
  .catch(() => { }).finally(() => { this.running = undefined; });
552
583
  return this.running;
553
584
  }
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { type DispatchHost } from "./dispatch-hosts.js";
3
3
  import { type Json, type Provider, type Target } from "./protocol.js";
4
+ import { type HarnessInventory } from "./harnesses.js";
5
+ import type { AccountRoom, WindowRoom } from "./account-choice.js";
4
6
  import { type BriefArrival } from "./launch-brief.js";
5
7
  export declare const projectName: z.ZodString;
6
8
  /** The harnesses a dispatch, a code note's hand-off or a schedule can start. */
@@ -214,6 +216,15 @@ declare const receiptSchema: z.ZodObject<{
214
216
  launch: "launch";
215
217
  typed: "typed";
216
218
  }>>;
219
+ accountChoice: z.ZodOptional<z.ZodString>;
220
+ continued: z.ZodOptional<z.ZodObject<{
221
+ id: z.ZodOptional<z.ZodString>;
222
+ computer: z.ZodOptional<z.ZodString>;
223
+ account: z.ZodOptional<z.ZodString>;
224
+ at: z.ZodString;
225
+ error: z.ZodOptional<z.ZodString>;
226
+ }, z.core.$strict>>;
227
+ continues: z.ZodOptional<z.ZodString>;
217
228
  granted: z.ZodOptional<z.ZodString>;
218
229
  authority: z.ZodOptional<z.ZodString>;
219
230
  authorityConfirmed: z.ZodOptional<z.ZodString>;
@@ -270,6 +281,10 @@ declare const receiptSchema: z.ZodObject<{
270
281
  error: z.ZodOptional<z.ZodString>;
271
282
  truncated: z.ZodOptional<z.ZodBoolean>;
272
283
  question: z.ZodOptional<z.ZodString>;
284
+ checkout: z.ZodOptional<z.ZodObject<{
285
+ path: z.ZodString;
286
+ branch: z.ZodOptional<z.ZodString>;
287
+ }, z.core.$strict>>;
273
288
  prs: z.ZodOptional<z.ZodArray<z.ZodObject<{
274
289
  url: z.ZodURL;
275
290
  repo: z.ZodString;
@@ -365,6 +380,8 @@ type Room = {
365
380
  leftPercent?: number;
366
381
  exhausted?: boolean;
367
382
  until?: string;
383
+ fiveHour?: WindowRoom;
384
+ week?: WindowRoom;
368
385
  };
369
386
  /** The account this dispatch would run under there, as its capacity probe reports it: Codex's one, or the named Claude home. */
370
387
  export declare function roomFor(data: {
@@ -372,11 +389,14 @@ export declare function roomFor(data: {
372
389
  account?: string;
373
390
  }, usage: readonly Room[] | undefined): Room | undefined;
374
391
  /** Why `anywhere` must not pick a computer for quota: only an account with none left (at 100% or refusing requests).
375
- * Low quota is not a reason; the owner often wants it used before it resets. */
392
+ * Low quota is not a reason; the owner often wants it used before it resets. A Claude dispatch that names no
393
+ * account runs under whichever has room there, so with several accounts that computer is out only when all are. */
376
394
  export declare function outOfQuota(data: {
377
395
  harness: string;
378
396
  account?: string;
379
397
  }, usage: readonly Room[] | undefined, now?: number): string | undefined;
398
+ /** A computer's signed-in Claude accounts with their room, from its capacity probe. */
399
+ export declare function capacityClaudeRooms(harnesses: HarnessInventory["harnesses"] | undefined, usage: readonly Room[] | undefined): AccountRoom[];
380
400
  /** What the worker's own hooks reported for a brief that went with its
381
401
  * launch, or undefined when the receiving Hook has no such brief. */
382
402
  export declare function arrivalOf(peer: Pick<DispatchHost, "request">, id: string): Promise<BriefArrival | undefined>;
@@ -404,8 +424,9 @@ export declare class DispatchService {
404
424
  * socket); tests replace it so they never reach a real Hook. */
405
425
  constructor(identity?: DispatchIdentity | undefined, local?: () => DispatchHost, settleIntervalMs?: number);
406
426
  /** `originValue` is the local pane the request came from, as its agent's
407
- * Herdr variables name it; a pane without a running agent is left out. */
408
- dispatch(input: unknown, originValue?: unknown): Promise<Json>;
427
+ * Herdr variables name it; a pane without a running agent is left out.
428
+ * `continues` names the dispatch whose worker hit its usage limit (account-failover.ts). */
429
+ dispatch(input: unknown, originValue?: unknown, continues?: string): Promise<Json>;
409
430
  /** Launches placed on `computer` whose brief is still being confirmed. */
410
431
  private inFlight;
411
432
  /**
@@ -427,6 +448,13 @@ export declare class DispatchService {
427
448
  * uncertain, and the returns loop keeps asking.
428
449
  */
429
450
  private confirmLaunched;
451
+ /** Every connected computer's signed-in Claude accounts and their room, this computer first:
452
+ * where a worker that hit its usage limit can continue (account-failover.ts). */
453
+ claudeRooms(): Promise<Array<{
454
+ computer: string;
455
+ local: boolean;
456
+ rooms: AccountRoom[];
457
+ }>>;
430
458
  /** The query a conductor's dispatch sends with each capacity probe; undefined for any other caller. */
431
459
  private conductorCaller;
432
460
  private origin;
@@ -32,7 +32,7 @@ export const dispatchSchema = z.object({
32
32
  model: text(200).optional().describe("Explicit model, otherwise the remote harness default."),
33
33
  effort: z.enum(launchEfforts).optional().describe("Reasoning effort for the worker (minimal, low, medium, high, xhigh, max), otherwise the harness default."),
34
34
  account: z.string().refine(isAccountSlug, "Account must be default or a lowercase slug.").optional()
35
- .describe("Claude account id to run the worker under (default, or a slug from `phren bridge accounts`). anywhere only picks computers where that account is signed in; a named computer without it fails."),
35
+ .describe("Claude account id to run the worker under (default, or a slug from `phren bridge accounts`). anywhere only picks computers where that account is signed in; a named computer without it fails. Without it, a computer with several signed-in Claude accounts picks the one with the most 5-hour room, then weekly; the receipt's accountChoice says why."),
36
36
  permissionMode: z.enum(PERMISSION_MODES).optional().describe("Permission mode the worker starts in: supervised, auto-edits, auto or full-access (Claude, Codex and Copilot; not OpenCode); otherwise the receiving computer's own default."),
37
37
  releaseActions: z.array(releaseAction).min(1).max(RELEASE_ACTIONS.length).optional()
38
38
  .describe("Release-type actions the brief asks the worker to do (merge, publish, deploy, app-store, github-admin). Ask-first projects refuse them from an agent unless the owner confirmed."),
@@ -55,6 +55,11 @@ const receiptSchema = dispatchSchema.omit({ prompt: true }).extend({
55
55
  target: remoteTarget.optional(), error: z.string().max(500).optional(),
56
56
  brief: z.enum(["launch", "typed"]).optional()
57
57
  .describe("How the brief reached the worker: as its first prompt at launch (confirmed by the worker's hook), or typed into its pane."),
58
+ accountChoice: z.string().max(400).optional().describe("Why the receiving Hook ran the worker under `account` when the dispatch named none."),
59
+ continued: z.object({ id: z.string().uuid().optional(), computer: z.string().max(200).optional(), account: z.string().max(64).optional(),
60
+ at: timestamp, error: z.string().max(500).optional() }).strict().optional()
61
+ .describe("The worker hit its Claude usage limit: the dispatch that continues it on another account, or why none could."),
62
+ continues: z.string().uuid().optional().describe("The dispatch this one continues after its worker hit its usage limit."),
58
63
  granted: z.string().max(200).optional().describe("Scope of the conductor grant that allowed this call."),
59
64
  authority: z.string().max(600).optional().describe("The release authority policy's line for this project, as a conductor quotes it."),
60
65
  authorityConfirmed: z.string().datetime().optional().describe("When the owner confirmed the ask-first release actions this agent dispatch used."),
@@ -71,6 +76,8 @@ const receiptSchema = dispatchSchema.omit({ prompt: true }).extend({
71
76
  returned: z.object({
72
77
  state: z.enum(["done", "needs-you", "failed", "blocked", "stalled", "gone"]), at: timestamp,
73
78
  reply: z.string().max(4000).optional(), error: z.string().max(500).optional(), truncated: z.boolean().optional(), question: z.string().max(200).optional(),
79
+ checkout: z.object({ path: z.string().max(4096), branch: z.string().max(256).optional() }).strict().optional()
80
+ .describe("Where a worker that failed was working, for the dispatch that continues it."),
74
81
  prs: prsSchema.optional(),
75
82
  integratorDelivery: z.object({ deliveryId: z.string(), state: z.enum(["pending", "queued", "delivered", "uncertain", "failed"]), at: timestamp, integrator: integratorSchema.optional() }).strict().optional(),
76
83
  stalledSince: timestamp.optional(), stallFor: z.number().nonnegative().optional(),
@@ -182,6 +189,7 @@ export async function dispatchStatus() {
182
189
  }
183
190
  return receipts.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
184
191
  }
192
+ const windowRoom = z.object({ leftPercent: z.number().min(0).max(100).optional(), resetsAt: z.string().max(40).optional() }).passthrough().optional();
185
193
  async function capacity(host, caller) {
186
194
  const value = await host.request(caller && !host.local ? `/v1/dispatch/capacity?${caller}` : "/v1/dispatch/capacity");
187
195
  const result = z.object({ product: z.literal("phren-hook"), protocol: z.literal(PROTOCOL), working: z.number().int().nonnegative(),
@@ -191,7 +199,7 @@ async function capacity(host, caller) {
191
199
  accounts: z.array(z.object({ id: z.string(), usable: z.boolean(), reason: z.string().optional() }).passthrough()).optional() }).passthrough()).optional(),
192
200
  // Missing from an older Hook or a slow read: that computer's quota is unknown, so it is never ruled out by it.
193
201
  usage: z.array(z.object({ source: z.string(), account: z.string().optional(), leftPercent: z.number().min(0).max(100).optional(),
194
- exhausted: z.boolean().optional(), until: z.string().max(40).optional() }).passthrough()).max(64).optional(),
202
+ exhausted: z.boolean().optional(), until: z.string().max(40).optional(), fiveHour: windowRoom, week: windowRoom }).passthrough()).max(64).optional(),
195
203
  knowsCaller: z.boolean().optional() }).parse(value);
196
204
  // This computer places on whichever Herdr server its own Hook runs.
197
205
  if (host.local && !result.servers.includes(host.server) && result.servers[0])
@@ -207,22 +215,48 @@ export function roomFor(data, usage) {
207
215
  const account = data.account ?? "default";
208
216
  return usage?.find(item => item.source === data.harness && (data.harness !== "claude" || (item.account ?? "default") === account));
209
217
  }
218
+ /** " for about 3 more hours" until `until`, or nothing when it is unknown. */
219
+ function backIn(until, now) {
220
+ const at = until ? Date.parse(until) : NaN;
221
+ const minutes = Number.isFinite(at) ? Math.max(1, Math.round((at - now) / 60_000)) : undefined;
222
+ return minutes === undefined ? "" : minutes >= 1440 ? ` for about ${Math.round(minutes / 1440)} more days` : minutes >= 60 ? ` for about ${Math.round(minutes / 60)} more hours` : ` for about ${minutes} more minutes`;
223
+ }
210
224
  /** Why `anywhere` must not pick a computer for quota: only an account with none left (at 100% or refusing requests).
211
- * Low quota is not a reason; the owner often wants it used before it resets. */
225
+ * Low quota is not a reason; the owner often wants it used before it resets. A Claude dispatch that names no
226
+ * account runs under whichever has room there, so with several accounts that computer is out only when all are. */
212
227
  export function outOfQuota(data, usage, now = Date.now()) {
228
+ const claude = usage?.filter(item => item.source === "claude") ?? [];
229
+ if (data.harness === "claude" && !data.account && claude.length > 1) {
230
+ if (claude.some(item => !item.exhausted))
231
+ return undefined;
232
+ return `Its claude accounts all have no quota left${backIn(claude.map(item => item.until).filter((value) => Boolean(value)).sort()[0], now)}.`;
233
+ }
213
234
  const room = roomFor(data, usage);
214
235
  if (!room?.exhausted)
215
236
  return undefined;
216
- const until = room.until ? Date.parse(room.until) : NaN;
217
- const minutes = Number.isFinite(until) ? Math.max(1, Math.round((until - now) / 60_000)) : undefined;
218
- const back = minutes === undefined ? "" : minutes >= 1440 ? ` for about ${Math.round(minutes / 1440)} more days` : minutes >= 60 ? ` for about ${Math.round(minutes / 60)} more hours` : ` for about ${minutes} more minutes`;
219
- return `Its ${data.harness}${data.harness === "claude" ? ` account ${data.account ?? "default"}` : ""} has no quota left${back}.`;
237
+ return `Its ${data.harness}${data.harness === "claude" ? ` account ${data.account ?? "default"}` : ""} has no quota left${backIn(room.until, now)}.`;
238
+ }
239
+ /** A computer's signed-in Claude accounts with their room, from its capacity probe. */
240
+ export function capacityClaudeRooms(harnesses, usage) {
241
+ const accounts = harnesses?.find(entry => entry.source === "claude")?.accounts ?? [];
242
+ return accounts.map(account => {
243
+ const room = usage?.find(item => item.source === "claude" && (item.account ?? "default") === account.id);
244
+ return { account: account.id, ...(account.key ? { key: account.key } : {}), usable: account.usable,
245
+ ...(room?.fiveHour ? { fiveHour: room.fiveHour } : {}), ...(room?.week ? { week: room.week } : {}),
246
+ ...(room?.exhausted ? { exhausted: true, ...(room.until ? { until: room.until } : {}) } : {}) };
247
+ });
220
248
  }
221
249
  /** Why a computer cannot run this dispatch's harness and account, or undefined when it can or cannot yet be told.
222
250
  * `unknown` (no `harnesses`) only counts against a computer when a non-default account was asked for. */
223
251
  function unusable(data, harnesses, strictUnknown) {
224
252
  if (!harnesses)
225
253
  return strictUnknown && data.account && data.account !== "default" ? "Its Hook does not report harnesses or accounts (update it)." : undefined;
254
+ // No account named: any signed-in Claude account there will do (the launch picks one).
255
+ if (data.harness === "claude" && !data.account) {
256
+ const usable = harnesses.find(entry => entry.source === "claude")?.accounts?.find(account => account.usable);
257
+ if (usable)
258
+ return unusable({ harness: "claude", account: usable.id }, harnesses, strictUnknown);
259
+ }
226
260
  const availability = hasUsable({ harnesses }, data.harness, data.account);
227
261
  return availability.ok ? undefined : availability.reason;
228
262
  }
@@ -419,8 +453,9 @@ export class DispatchService {
419
453
  this.settleIntervalMs = settleIntervalMs;
420
454
  }
421
455
  /** `originValue` is the local pane the request came from, as its agent's
422
- * Herdr variables name it; a pane without a running agent is left out. */
423
- async dispatch(input, originValue) {
456
+ * Herdr variables name it; a pane without a running agent is left out.
457
+ * `continues` names the dispatch whose worker hit its usage limit (account-failover.ts). */
458
+ async dispatch(input, originValue, continues) {
424
459
  const data = dispatchSchema.parse(input);
425
460
  if (data.permissionMode && data.harness === "opencode")
426
461
  throw new BridgeError(400, "OpenCode takes its permissions from its own config; permissionMode is for Claude, Codex and Copilot workers.");
@@ -532,7 +567,7 @@ export class DispatchService {
532
567
  createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), state: "launching",
533
568
  ...(grant ? { granted: grantLabel(grant) } : {}), ...(authority?.listed ? { authority: authority.line.slice(0, 600) } : {}),
534
569
  ...(checked?.confirmation ? { authorityConfirmed: checked.confirmation.confirmedAt } : {}),
535
- ...(skipped.length ? { skipped } : {}), ...(origin ? { origin } : {}) };
570
+ ...(skipped.length ? { skipped } : {}), ...(origin ? { origin } : {}), ...(continues ? { continues } : {}) };
536
571
  await save(receipt);
537
572
  try {
538
573
  // The brief goes with the launch: a Hook that can start the harness
@@ -541,6 +576,13 @@ export class DispatchService {
541
576
  // Placed: the brief is confirmed outside the lock.
542
577
  placed = peer.name;
543
578
  this.placing.set(placed, this.inFlight(placed) + 1);
579
+ // The receiving Hook chose the Claude account (the one with the most room) when none was named.
580
+ if (!data.account && typeof launched.account === "string" && isAccountSlug(launched.account)) {
581
+ receipt.account = launched.account;
582
+ if (typeof launched.accountChoice === "string")
583
+ receipt.accountChoice = launched.accountChoice.slice(0, 400);
584
+ logger.info("dispatch", `${receipt.label} on ${peer.name} runs under Claude account ${launched.account}${receipt.accountChoice ? `: ${receipt.accountChoice}` : ""}.`);
585
+ }
544
586
  release();
545
587
  // An older Hook ignores the field and starts the worker in its own default mode.
546
588
  const ignored = data.permissionMode && launched.permissionMode !== data.permissionMode ? IGNORED_MODE : undefined;
@@ -695,6 +737,22 @@ export class DispatchService {
695
737
  }
696
738
  receipt.error = `${receipt.harness} started with the brief on ${receipt.computer} but has not confirmed it yet (last status ${status ?? "unknown"}). The Hook keeps checking.`.slice(0, 500);
697
739
  }
740
+ /** Every connected computer's signed-in Claude accounts and their room, this computer first:
741
+ * where a worker that hit its usage limit can continue (account-failover.ts). */
742
+ async claudeRooms() {
743
+ const here = this.local();
744
+ const hosts = [here, ...(await hookPeers().catch(() => [])).map(candidate => peerHost(candidate))];
745
+ const found = await Promise.all(hosts.map(async (host) => {
746
+ try {
747
+ const reported = await capacity(host);
748
+ return { computer: host.name, local: host.local, rooms: capacityClaudeRooms(reported.harnesses, reported.usage) };
749
+ }
750
+ catch {
751
+ return undefined;
752
+ }
753
+ }));
754
+ return found.filter((item) => !!item);
755
+ }
698
756
  /** The query a conductor's dispatch sends with each capacity probe; undefined for any other caller. */
699
757
  async conductorCaller(value) {
700
758
  const pane = originPaneSchema.safeParse(value);