@0perator/operator 0.1.351 → 0.1.353

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 (92) hide show
  1. package/dist/acp/agent.js +2 -2
  2. package/dist/acp/tool-map.js +5 -4
  3. package/dist/autonomy/delegate.js +54 -1
  4. package/dist/autonomy/headless.js +2 -0
  5. package/dist/autonomy/session-factory.js +1 -0
  6. package/dist/background/index.js +86 -10
  7. package/dist/background/notices.js +16 -4
  8. package/dist/cli.js +1073 -177
  9. package/dist/config/home.js +6 -0
  10. package/dist/config/memory-sections.js +92 -0
  11. package/dist/config/persona.js +144 -26
  12. package/dist/config/settings.js +15 -4
  13. package/dist/consolidation/scheduler.js +9 -2
  14. package/dist/consolidation/sleep.js +39 -278
  15. package/dist/engine/agent.js +444 -76
  16. package/dist/engine/anthropic-chat.js +13 -2
  17. package/dist/engine/aurora.js +66 -19
  18. package/dist/engine/batch-scheduler.js +27 -3
  19. package/dist/engine/compaction.js +12 -5
  20. package/dist/engine/continuation.js +14 -12
  21. package/dist/engine/contract.js +1 -1
  22. package/dist/engine/decision-points.js +7 -1
  23. package/dist/engine/front-door.js +59 -0
  24. package/dist/engine/grandmaster.js +13 -1
  25. package/dist/engine/loop-guard.js +694 -0
  26. package/dist/engine/owner-act.js +52 -0
  27. package/dist/engine/verify-gate.js +52 -0
  28. package/dist/flywheel/processor.js +3 -1
  29. package/dist/flywheel/srft.js +8 -4
  30. package/dist/hooks/index.js +12 -8
  31. package/dist/mcp/index.js +9 -4
  32. package/dist/permissions/index.js +32 -11
  33. package/dist/permissions/modes.js +42 -0
  34. package/dist/permissions/plan-review.js +100 -0
  35. package/dist/permissions/policy.js +16 -5
  36. package/dist/permissions/signature.js +8 -3
  37. package/dist/remote/safe-commands.js +1 -1
  38. package/dist/router/read-rates.js +152 -0
  39. package/dist/selfimprove/backfill.js +174 -0
  40. package/dist/selfimprove/index.js +146 -57
  41. package/dist/selfimprove/lessons.js +429 -0
  42. package/dist/selfimprove/sync.js +58 -0
  43. package/dist/session.js +362 -33
  44. package/dist/skills/finder.js +219 -0
  45. package/dist/toolchain/toolchain.py +528 -112
  46. package/dist/tools/deferred.js +28 -18
  47. package/dist/tools/executor.js +7 -3
  48. package/dist/tools/registry.js +68 -7
  49. package/dist/tools/result-cap.js +1 -1
  50. package/dist/ui/ActivitySpinner.js +21 -12
  51. package/dist/ui/App.js +107 -30
  52. package/dist/ui/ApprovalPrompt.js +5 -3
  53. package/dist/ui/ArtifactPicker.js +3 -3
  54. package/dist/ui/BgPanel.js +105 -5
  55. package/dist/ui/Composer.js +85 -9
  56. package/dist/ui/PlanPane.js +72 -8
  57. package/dist/ui/QuestionPrompt.js +6 -4
  58. package/dist/ui/SecretPrompt.js +8 -3
  59. package/dist/ui/SessionPicker.js +2 -2
  60. package/dist/ui/SkillFinder.js +153 -0
  61. package/dist/ui/StatusRule.js +5 -2
  62. package/dist/ui/SummaryCard.js +3 -1
  63. package/dist/ui/ThinkingSpinner.js +11 -2
  64. package/dist/ui/ToolBatch.js +11 -2
  65. package/dist/ui/ToolStep.js +36 -13
  66. package/dist/ui/Transcript.js +13 -2
  67. package/dist/ui/actNow.js +61 -0
  68. package/dist/ui/batchLine.js +165 -0
  69. package/dist/ui/conversations.js +154 -0
  70. package/dist/ui/decodeHealth.js +77 -0
  71. package/dist/ui/expand.js +17 -0
  72. package/dist/ui/fit.js +40 -0
  73. package/dist/ui/fitTail.js +14 -0
  74. package/dist/ui/fold.js +149 -0
  75. package/dist/ui/format.js +46 -2
  76. package/dist/ui/liveTools.js +163 -13
  77. package/dist/ui/modelPicker.js +78 -6
  78. package/dist/ui/nextStep.js +103 -0
  79. package/dist/ui/pending.js +57 -0
  80. package/dist/ui/phase.js +105 -0
  81. package/dist/ui/planExit.js +0 -5
  82. package/dist/ui/progressbar.js +4 -26
  83. package/dist/ui/readForecast.js +44 -0
  84. package/dist/ui/readProgress.js +119 -0
  85. package/dist/ui/reportLine.js +62 -0
  86. package/dist/ui/slashCommands.js +1 -1
  87. package/dist/ui/theme.js +1 -0
  88. package/dist/ui/turnFlow.js +72 -0
  89. package/dist/ui/turnLedger.js +121 -0
  90. package/dist/ui/turnScope.js +11 -0
  91. package/dist/util/slash.js +18 -0
  92. package/package.json +1 -1
@@ -61,30 +61,34 @@ function describe(st, names) {
61
61
  }
62
62
  /** Wrap a composed executor; meta names route here, everything else falls through in order. */
63
63
  export function withDeferred(base, st) {
64
- const runMeta = async (name, args) => {
65
- if (name === "tool_search")
64
+ const runMeta = async (name, args, report) => {
65
+ if (name === "tool_search") {
66
+ report?.started();
66
67
  return search(st, String(args.query ?? ""));
67
- if (name === "tool_describe")
68
+ }
69
+ if (name === "tool_describe") {
70
+ report?.started();
68
71
  return describe(st, args.names);
72
+ }
69
73
  if (name === "tool_call") {
70
74
  const target = String(args.name ?? "");
71
75
  if (!st.defs.has(target))
72
76
  return `tool_call: '${target}' is not in the deferred catalog — run tool_search`;
73
77
  if (!st.loaded.has(target)) {
74
78
  st.loaded.add(target); // auto-load so follow-up direct calls work; disclosure happens on the first result
75
- return `tool_call ${target} (auto-described): ${await base.execute(target, args.args ?? {})}`;
79
+ return `tool_call ${target} (auto-described): ${await base.execute(target, args.args ?? {}, report)}`;
76
80
  }
77
- return base.execute(target, args.args ?? {});
81
+ return base.execute(target, args.args ?? {}, report);
78
82
  }
79
83
  return `deferred: unknown meta '${name}'`;
80
84
  };
81
85
  return {
82
- async execute(name, args) {
86
+ async execute(name, args, report) {
83
87
  if (DEFERRED_META_NAMES.includes(name))
84
- return runMeta(name, args);
85
- return base.execute(name, args);
88
+ return runMeta(name, args, report);
89
+ return base.execute(name, args, report);
86
90
  },
87
- async executeParallel(calls, onSettle, signal) {
91
+ async executeParallel(calls, onSettle, signal, onStart) {
88
92
  // BTX finding B/C follow-through: meta trio and base calls share ONE scheduled batch —
89
93
  // tool_call used to runMeta-inline (racing the base batch it dispatches INTO), and the meta
90
94
  // Promise.all barrier made base calls wait for every meta first. Now: search/describe classify
@@ -95,9 +99,11 @@ export function withDeferred(base, st) {
95
99
  : n === "tool_search" || n === "tool_describe" ? "read"
96
100
  : base.sched ? base.sched.classify(n) : "write"),
97
101
  keys: (n, a) => (base.sched ? base.sched.keys(n, a) : defaultKeys(n, a)),
98
- runOne: (c) => (DEFERRED_META_NAMES.includes(c.name)
99
- ? runMeta(c.name, c.args) : base.execute(c.name, c.args)),
102
+ runOne: (c, report) => (DEFERRED_META_NAMES.includes(c.name)
103
+ ? runMeta(c.name, c.args, report) : base.execute(c.name, c.args, report)),
100
104
  onSettle,
105
+ onStart,
106
+ startsBelow: true, // tool_call's target, and every pass-through, starts where the chain below releases it
101
107
  signal,
102
108
  });
103
109
  },
@@ -218,9 +224,11 @@ export function validateToolArgs(schema, args) {
218
224
  /** Wrap the composed (permission + hooks) executor: the meta pair routes here, everything else falls through, so
219
225
  * a deferred tool called directly by name still runs. tool_call is a batch barrier (it can run anything). */
220
226
  export function withNativeDeferred(base, cat) {
221
- const runMeta = async (name, args) => {
222
- if (name === "tool_search")
227
+ const runMeta = async (name, args, report) => {
228
+ if (name === "tool_search") {
229
+ report?.started();
223
230
  return nativeSearch(cat, String(args.query ?? ""));
231
+ }
224
232
  const target = String(args.name ?? "").trim();
225
233
  const schema = catalogGet(cat, target);
226
234
  if (!schema && !cat.core.has(target))
@@ -231,7 +239,7 @@ export function withNativeDeferred(base, cat) {
231
239
  if (errs.length)
232
240
  return `tool_call ${target}: ${errs.join("; ")}. Schema: ${JSON.stringify(schema.function?.parameters ?? {})}`;
233
241
  }
234
- return base.execute(target, toolArgs);
242
+ return base.execute(target, toolArgs, report);
235
243
  };
236
244
  const isMeta = (n) => NATIVE_META_NAMES.includes(n);
237
245
  const classify = (n) => (n === "tool_call" ? "barrier"
@@ -239,14 +247,16 @@ export function withNativeDeferred(base, cat) {
239
247
  : base.sched ? base.sched.classify(n) : "write");
240
248
  const keys = (n, a) => (base.sched ? base.sched.keys(n, a) : defaultKeys(n, a));
241
249
  return {
242
- async execute(name, args) {
243
- return isMeta(name) ? runMeta(name, args) : base.execute(name, args);
250
+ async execute(name, args, report) {
251
+ return isMeta(name) ? runMeta(name, args, report) : base.execute(name, args, report);
244
252
  },
245
- async executeParallel(calls, onSettle, signal) {
253
+ async executeParallel(calls, onSettle, signal, onStart) {
246
254
  return runBatch(calls, {
247
255
  classify, keys,
248
- runOne: (c) => (isMeta(c.name) ? runMeta(c.name, c.args) : base.execute(c.name, c.args)),
256
+ runOne: (c, report) => (isMeta(c.name) ? runMeta(c.name, c.args, report) : base.execute(c.name, c.args, report)),
249
257
  onSettle,
258
+ onStart,
259
+ startsBelow: true,
250
260
  signal,
251
261
  });
252
262
  },
@@ -79,19 +79,21 @@ export class Executor {
79
79
  resetTurn() {
80
80
  this.seen.clear();
81
81
  }
82
- async execute(name, rawArgs) {
82
+ async execute(name, rawArgs, report) {
83
83
  const args = this.root ? rootArgs(name, rawArgs, this.root) : rawArgs;
84
84
  if (!LOOP_GUARD_EXEMPT.has(name) && !IDEMPOTENT_TOOLS.has(name)) { // poll/status tools are never loop-guarded (repeated calls are legit)
85
85
  const key = `${name} ${JSON.stringify(args)}`;
86
86
  const count = (this.seen.get(key) ?? 0) + 1;
87
87
  this.seen.set(key, count);
88
88
  if (count >= LOOP_GUARD_THRESHOLD) {
89
+ report?.refused("blocked");
89
90
  return `loop guard: "${name}" called ${count}x with identical args this turn — stop repeating it, try a different approach or ask the user.`;
90
91
  }
91
92
  }
92
93
  const tool = this.reg.get(name);
93
94
  if (!tool)
94
95
  return `error: unknown tool "${name}"`;
96
+ report?.started();
95
97
  try {
96
98
  // Run the tool inside THIS session's shell-key context so a persistent-shell tool (bash) picks
97
99
  // this session's own ShellSession, not a process-wide singleton shared with other sub-agents.
@@ -118,7 +120,7 @@ export class Executor {
118
120
  resolveKey(p, argName) {
119
121
  return KEY_PATH_ARG.test(argName) && !URL_LIKE.test(p) ? resolve(this.root ?? process.cwd(), expandPath(p)) : p;
120
122
  }
121
- async executeParallel(calls, onSettle, signal) {
123
+ async executeParallel(calls, onSettle, signal, onStart) {
122
124
  // BTX: one shared DAG scheduler (engine/batch-scheduler.ts) — per-resource write chains,
123
125
  // reads wait only for conflicting prior writes, device tools barrier-serialize, independent
124
126
  // bash/shell_exec overlap (shell kind). This replaces the 0.1.225 contiguous walk.
@@ -132,8 +134,10 @@ export class Executor {
132
134
  return shellExecMode.run(mode, () => runBatch(calls, {
133
135
  classify: this.sched.classify,
134
136
  keys: (n, a) => this.sched.keys(n, a),
135
- runOne: (c) => this.execute(c.name, c.args),
137
+ runOne: (c, report) => this.execute(c.name, c.args, report),
136
138
  onSettle,
139
+ onStart,
140
+ startsBelow: true,
137
141
  signal,
138
142
  }));
139
143
  }
@@ -128,7 +128,9 @@ async function shellExec(args) {
128
128
  // A `cwd` arg is scoped to this one call (subshell) so it doesn't silently move the persistent
129
129
  // session's directory; an explicit `cd` INSIDE the command persists, exactly like a terminal.
130
130
  const cwd = args.cwd ? expandPath(str(args.cwd)) : undefined;
131
- const toRun = cwd ? `( cd ${JSON.stringify(cwd)} && { ${command}; } )` : command;
131
+ // the command on its own lines: a trailing `# comment` used to swallow "; } )", and the shell then waited for the
132
+ // closing brace until the 120 s timeout (sub-agents in worktrees, headless --cwd runs)
133
+ const toRun = cwd ? `( cd ${JSON.stringify(cwd)} && {\n${command}\n} )` : command;
132
134
  try {
133
135
  const { shellExecMode } = (await nodeImport("./shell-context.js"));
134
136
  const mod = (await nodeImport("./shell-session.js"));
@@ -185,6 +187,32 @@ async function shellExec(args) {
185
187
  // capping here first lets us tell the model specifically to use offset/limit rather than "narrow your query".
186
188
  const FILE_READ_DEFAULT_LIMIT_LINES = 2000;
187
189
  const FILE_READ_MAX_CHARS = 40_000;
190
+ const RAW_READ_MAX_CHARS = 38_000; // under the 40K tool-result cap with room for the footer
191
+ /** Raw character paging (start_char/max_chars): the exact text, no line numbers. Line paging can't get past one line
192
+ * longer than the cap (minified code, one-line JSON or logs): limit=1 is still truncated, and "a smaller limit" is a
193
+ * dead end the model loops on. */
194
+ function rawSlice(src, startChar, maxChars) {
195
+ const start = Math.min(src.length, Math.max(0, Math.floor(startChar) || 0));
196
+ const end = Math.min(src.length, start + Math.min(RAW_READ_MAX_CHARS, Math.max(1, Math.floor(maxChars) || RAW_READ_MAX_CHARS)));
197
+ const out = src.slice(start, end);
198
+ return end < src.length ? `${out}\n…[chars ${start}-${end} of ${src.length} — next: start_char=${end}]` : out;
199
+ }
200
+ /** The raw character position where a line-numbered result cut at `cut` stops, so the truncation note can name the
201
+ * exact start_char to continue from (the `${n}\t` prefixes and the joining newlines aren't in the file). */
202
+ function rawOffsetAt(lines, offset, cut) {
203
+ let raw = 0;
204
+ for (let i = 0; i < offset && i < lines.length; i++)
205
+ raw += lines[i].length + 1;
206
+ let used = 0;
207
+ for (let i = offset; i < lines.length; i++) {
208
+ const prefix = `${i + 1}\t`.length;
209
+ if (used + prefix + lines[i].length + 1 > cut)
210
+ return raw + Math.max(0, cut - used - prefix);
211
+ used += prefix + lines[i].length + 1;
212
+ raw += lines[i].length + 1;
213
+ }
214
+ return raw;
215
+ }
188
216
  async function fileRead(args) {
189
217
  const path = await resolveReadPath(str(args.path));
190
218
  if (!path)
@@ -206,13 +234,16 @@ async function fileRead(args) {
206
234
  const { readFile } = await nodeImport("node:fs/promises");
207
235
  src = await readFile(path, "utf8");
208
236
  }
237
+ if (args.start_char !== undefined || args.max_chars !== undefined) {
238
+ return head + rawSlice(src, Number(args.start_char ?? 0), Number(args.max_chars ?? RAW_READ_MAX_CHARS));
239
+ }
209
240
  const lines = src.split("\n");
210
241
  const offset = Number(args.offset ?? 0);
211
242
  const explicitLimit = args.limit !== undefined;
212
243
  const limit = Number(args.limit ?? Math.min(lines.length, FILE_READ_DEFAULT_LIMIT_LINES));
213
244
  let out = lines.slice(offset, offset + limit).map((l, i) => `${offset + i + 1}\t${l}`).join("\n");
214
245
  if (out.length > FILE_READ_MAX_CHARS) {
215
- out = `${out.slice(0, FILE_READ_MAX_CHARS)}\n…[result truncated: ${FILE_READ_MAX_CHARS} of ${out.length} chars — pass a smaller offset/limit]`;
246
+ out = `${out.slice(0, FILE_READ_MAX_CHARS)}\n…[result truncated: ${FILE_READ_MAX_CHARS} of ${out.length} chars — pass a smaller offset/limit, or continue as raw text with start_char=${rawOffsetAt(lines, offset, FILE_READ_MAX_CHARS)} (works inside a long line)]`;
216
247
  }
217
248
  else if (!explicitLimit && offset + limit < lines.length) {
218
249
  out += `\n…[showing lines ${offset + 1}-${offset + limit} of ${lines.length} — pass offset/limit to see the rest]`;
@@ -1314,6 +1345,7 @@ async function bashKill(args) {
1314
1345
  }
1315
1346
  const agentTasks = [];
1316
1347
  let taskSeq = 0;
1348
+ let planRevision = 0; // bumped when the plan's steps change: task_add, or task_clear emptying the list
1317
1349
  const TASK_MARK = { pending: "[ ]", in_progress: "[>]", done: "[x]", cancelled: "[~]" };
1318
1350
  function renderTasks() {
1319
1351
  if (!agentTasks.length)
@@ -1335,12 +1367,20 @@ async function taskAdd(args) {
1335
1367
  return "error: task_add needs `text` or `tasks` (array)";
1336
1368
  for (const t of items)
1337
1369
  agentTasks.push({ id: ++taskSeq, text: t, status: "pending" });
1370
+ planRevision++;
1338
1371
  return `added ${items.length} task(s):\n${renderTasks()}`;
1339
1372
  }
1340
1373
  async function taskList() { return renderTasks(); }
1341
1374
  /** A snapshot of the session TODO list for the UI plan/checklist pane (SPEC §6). Copy, not the live array,
1342
1375
  * so a render can't mutate it. Empty when the model hasn't tracked any tasks this session. */
1343
1376
  export function getAgentTasks() { return agentTasks.map((t) => ({ ...t })); }
1377
+ /** Changes whenever the plan's steps change (a task added, or the list cleared); a status update, or dropping finished
1378
+ * tasks, is progress and leaves it. An Autonomous plan approval (permissions/plan-review.ts) stands only while this
1379
+ * stays the same. */
1380
+ export function taskPlanRevision() { return planRevision; }
1381
+ /** Steps still to do (pending or in_progress). An Autonomous plan approval ends when this reaches zero: a finished plan
1382
+ * approves nothing that comes after it. */
1383
+ export function openTaskCount() { return agentTasks.filter((t) => t.status === "pending" || t.status === "in_progress").length; }
1344
1384
  async function taskUpdate(args) {
1345
1385
  const id = Number(args.id);
1346
1386
  const status = str(args.status);
@@ -1354,8 +1394,25 @@ async function taskUpdate(args) {
1354
1394
  // Exactly ONE step in progress at a time — enforced by code, not by asking: a second in_progress returns the
1355
1395
  // earlier one to pending and says so, so the plan pane always shows the single step being worked.
1356
1396
  const demoted = status === "in_progress" ? agentTasks.filter((x) => x.id !== id && x.status === "in_progress") : [];
1357
- for (const d of demoted)
1397
+ const now = Date.now();
1398
+ const pause = (x) => { if (x.activeSince !== undefined) {
1399
+ x.activeMs = (x.activeMs ?? 0) + (now - x.activeSince);
1400
+ x.activeSince = undefined;
1401
+ } };
1402
+ for (const d of demoted) {
1403
+ pause(d);
1358
1404
  d.status = "pending";
1405
+ } // a demoted step keeps its startedAt and the time it was worked
1406
+ if (status === "in_progress") {
1407
+ t.startedAt ??= now;
1408
+ t.activeSince ??= now;
1409
+ }
1410
+ else
1411
+ pause(t);
1412
+ if (status === "done" || status === "cancelled")
1413
+ t.endedAt = now;
1414
+ else
1415
+ t.endedAt = undefined; // reopened
1359
1416
  t.status = status;
1360
1417
  const note = demoted.length ? ` (${demoted.map((d) => `#${d.id}`).join(", ")} returned to pending — one task in progress at a time)` : "";
1361
1418
  return `task #${id} → ${status}${note}\n${renderTasks()}`;
@@ -1371,6 +1428,8 @@ async function taskClear(args) {
1371
1428
  return `cleared ${before - agentTasks.length} completed task(s)\n${renderTasks()}`;
1372
1429
  }
1373
1430
  agentTasks.length = 0;
1431
+ if (before)
1432
+ planRevision++;
1374
1433
  return `cleared all ${before} task(s) — plan is empty`;
1375
1434
  }
1376
1435
  // Image generation via the AXE image service (FLUX.1-schnell, OpenAI-images-compatible) — a SHARED FLEET
@@ -2344,10 +2403,12 @@ const TOOLS = [
2344
2403
  },
2345
2404
  {
2346
2405
  name: "file_read", safe: true,
2347
- contract: { v: 1, effects: ["read"], bins: ["osascript", "textutil", "unzip"] },
2348
- description: "Read a file, optionally a line range, with line numbers. Without offset/limit, only the first 2000 lines are returned — pass offset/limit to page through a larger file.",
2406
+ contract: { v: 2, effects: ["read"], bins: ["osascript", "textutil", "unzip"] },
2407
+ description: "Read a file, optionally a line range, with line numbers. Without offset/limit, only the first 2000 lines are returned — pass offset/limit to page through a larger file. For very long lines (minified code, one-line JSON or logs) page by character instead: start_char (and max_chars, up to 38000) returns the exact raw text with no line numbers.",
2349
2408
  parameters: { type: "object", properties: {
2350
2409
  path: { type: "string" }, offset: { type: "number" }, limit: { type: "number" },
2410
+ start_char: { type: "number", description: "raw mode: character offset to start at (0-based); the reply names the next start_char" },
2411
+ max_chars: { type: "number", description: "raw mode: characters to return (default and max 38000)" },
2351
2412
  }, required: ["path"] },
2352
2413
  run: fileRead,
2353
2414
  },
@@ -2946,8 +3007,8 @@ const TOOLS = [
2946
3007
  // AXE skill registry (matching the Python core): a REMOTE HTTPS registry reachable from every surface
2947
3008
  // (CLI/web/mobile), so skills work everywhere without local fleet access. Bearer from OPERATOR_TOKEN or
2948
3009
  // ~/.axe/secrets/operator_token.txt; a real User-Agent is REQUIRED (the gateway WAF 403s the default).
2949
- const OPERATOR_URLS = [process.env.OPERATOR_URL ?? "https://operator.axe.onl", "https://skills.axe.onl"];
2950
- async function operatorToken() {
3010
+ export const OPERATOR_URLS = [process.env.OPERATOR_URL ?? "https://operator.axe.onl", "https://skills.axe.onl"];
3011
+ export async function operatorToken() {
2951
3012
  if (process.env.OPERATOR_TOKEN)
2952
3013
  return process.env.OPERATOR_TOKEN;
2953
3014
  try {
@@ -20,7 +20,7 @@ export function capToolResult(result, spill) {
20
20
  const tail = result.slice(-TOOL_RESULT_TAIL_CHARS);
21
21
  const path = spill ? spill(result) : null;
22
22
  const marker = path
23
- ? `\n…[${result.length} chars total; showing head+tail — FULL output saved to ${path} · re-read the omitted middle with file_read(path, offset, limit)]\n`
23
+ ? `\n…[${result.length} chars total; showing head+tail — FULL output saved to ${path} · re-read the omitted middle with file_read(path, start_char=${TOOL_RESULT_HEAD_CHARS})]\n`
24
24
  : `\n…[result truncated: ${TOOL_RESULT_MAX_CHARS} of ${result.length} chars — narrow your query]\n`;
25
25
  return head + marker + tail;
26
26
  }
@@ -9,7 +9,10 @@ import { useEffect, useRef } from "react";
9
9
  import { Text } from "ink";
10
10
  import { theme } from "./theme.js";
11
11
  import { useTick } from "./tick.js";
12
- import { renderBar } from "./progressbar.js";
12
+ import { renderSweepBar } from "./progressbar.js";
13
+ import { fmtElapsed } from "./format.js";
14
+ import { cellWidth, truncateToWidth } from "./StatusRule.js";
15
+ import { termCols } from "./term.js";
13
16
  // Every glyph advances off the ONE shared clock (tick.ts): a timer per spinner meant one full-frame redraw per
14
17
  // working sub-agent per tick — the panel flashed harder with each agent added (10/31).
15
18
  function useFrame(frames, active) {
@@ -37,19 +40,25 @@ export function OrbitGlyph() {
37
40
  return _jsx(Text, { color: theme.accent, children: useFrame(ORBIT, true) });
38
41
  }
39
42
  /** Self-heal in progress (context compaction / reconnect). Shown INSTEAD of a raw "http 400" so a recovery
40
- * reads as the agent working it out, not an error — a PINK turning disc + a calm label + a PINK bar that
41
- * FILLS as it works (full ≈ done). Compaction reports no percentage, so the fill is elapsed-based: it grows
42
- * toward a typical duration and caps just shy of full, then the spinner unmounts the moment compaction
43
- * finishes (status leaves "compacting"). Disc + fill advance off the ONE shared ticker (tick.ts). */
44
- const COMPACT_FILL_TICKS = 150; // ~18s at ~120ms/tick — the bar fills over a typical compaction, capped <100%
45
- export function RecoverSpinner({ active, label }) {
43
+ * reads as the agent working it out, not an error — a PINK turning disc + a calm label + a PINK bar and the
44
+ * time it has taken. The bar is a sweep that never fills: it used to fill on elapsed ticks toward an assumed ~18 s,
45
+ * and then from the summarizer's read — which is only the start of a compaction, so it read full while the summary
46
+ * was still being written (review F2). The phase line says what is measured. Disc + sweep advance off the ONE
47
+ * shared ticker (tick.ts). */
48
+ export function RecoverSpinner({ active, label, cols = termCols() }) {
46
49
  const frame = useTick(active);
47
- const startRef = useRef(null);
48
- useEffect(() => { startRef.current = active ? frame : null; }, [active]); // reset the fill each time it (re)activates
50
+ const startRef = useRef(Date.now());
51
+ useEffect(() => { if (active)
52
+ startRef.current = Date.now(); }, [active]); // the clock restarts each time it (re)activates
49
53
  if (!active)
50
54
  return null;
51
- const elapsed = startRef.current == null ? 0 : frame - startRef.current;
52
- const fraction = Math.min(0.96, elapsed / COMPACT_FILL_TICKS); // fills toward near-full; snaps away (unmounts) when done
53
55
  const glyph = SETTLE[frame % SETTLE.length];
54
- return (_jsxs(Text, { color: theme.compactProgress, children: [glyph, " ", label ?? "adjusting", "\u2026 ", _jsx(Text, { color: theme.compactProgress, children: renderBar(fraction) })] }));
56
+ const bar = renderSweepBar(frame);
57
+ const time = fmtElapsed(Date.now() - startRef.current);
58
+ // One row at cols−1 whatever the clock reads (review F9): as the clock widens past 10 s and 1 m the bar leaves first,
59
+ // then the label clips — a row that wrapped mid-compaction changed the frame's height on a tick.
60
+ const room = cols - 1 - cellWidth(glyph) - 1 - 2 - cellWidth(time);
61
+ const text = `${label ?? "adjusting"}…`;
62
+ const withBar = cellWidth(text) + 2 + cellWidth(bar) <= room;
63
+ return (_jsxs(Text, { color: theme.compactProgress, children: [glyph, " ", withBar ? text : truncateToWidth(text, Math.max(1, room)), withBar ? _jsxs(Text, { color: theme.compactProgress, children: [" ", bar] }) : null, " ", _jsx(Text, { dimColor: true, children: time })] }));
55
64
  }
package/dist/ui/App.js CHANGED
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  // Composes the UI lane into the SPEC §6 shell. This is the whole UI/engine contract surface —
3
3
  // the engine lane wires state + callbacks into these props; nothing below reaches into
4
4
  // src/engine, src/tools, or src/router.
5
- import { useEffect, useRef, useState } from "react";
6
- import { Box, Text, measureElement } from "ink";
7
- import { useTerminalSize } from "./term.js";
5
+ import React, { useEffect, useRef, useState } from "react";
6
+ import { Box, Text, measureElement, useInput } from "ink";
7
+ import { useTerminalSize, termCols } from "./term.js";
8
8
  import { caps } from "./capabilities.js";
9
9
  import { MouseProvider, useOnWheel, useMouse } from "./MouseProvider.js";
10
10
  import { StatusRule } from "./StatusRule.js";
@@ -13,54 +13,116 @@ import { Transcript } from "./Transcript.js";
13
13
  import { Composer } from "./Composer.js";
14
14
  import { ThinkingSpinner } from "./ThinkingSpinner.js";
15
15
  import { StepSpinner, RecoverSpinner } from "./ActivitySpinner.js";
16
- import { BgPanel } from "./BgPanel.js";
16
+ import { BgPanel, Lanes, liveWorkers } from "./BgPanel.js";
17
17
  import { PlanPane } from "./PlanPane.js";
18
- import { ToolStep } from "./ToolStep.js";
18
+ import { liveRow, batchHeader, delegateLine, relayFrame } from "./batchLine.js";
19
+ import { glyphFor, toolKind } from "./toolicons.js";
19
20
  import { backgroundHint } from "./liveTools.js";
20
21
  import { useTick } from "./tick.js";
22
+ import { phaseLine, phaseWord } from "./phase.js";
23
+ import { KIND_HUE } from "./toolicons.js";
24
+ import { foldLine } from "./fold.js";
25
+ import { isExpandKey } from "./expand.js";
26
+ import { theme } from "./theme.js";
21
27
  import { ApprovalPrompt } from "./ApprovalPrompt.js";
22
28
  import { QuestionPrompt } from "./QuestionPrompt.js";
23
29
  import { SecretPrompt } from "./SecretPrompt.js";
24
30
  import { ArtifactPicker } from "./ArtifactPicker.js";
25
31
  import { SessionPicker } from "./SessionPicker.js";
32
+ import { SkillFinder } from "./SkillFinder.js";
33
+ import { pendingLines, turnKeySegs } from "./pending.js";
34
+ import { nextStepLine } from "./nextStep.js";
35
+ import { centreLayout, switcherLine } from "./conversations.js";
36
+ import { cellWidth } from "./StatusRule.js";
37
+ import { ACT_NOW_NARROW, actNowLine } from "./actNow.js";
38
+ import { fitSegments } from "./fit.js";
39
+ // The footer's mode badge. Gated is outside the shift+tab cycle (permissions/modes.ts); shift+tab leaves it.
40
+ const MODE_BADGE = { auto: "⎈ Autonomous", manual: "⊙ Manual", plan: "◑ Plan", gated: "⊘ Gated" };
26
41
  // Cap on live rows shown at once for a parallel tool batch — keeps the dynamic (non-Static) frame
27
42
  // bounded (same render-collapse concern liveTail guards in Transcript.tsx: Ink corrupts the frame once
28
43
  // the non-Static portion approaches the terminal height). A batch rarely runs more than a handful of
29
44
  // calls at once; anything past the cap is summarized as a count instead of another row.
30
45
  const MAX_LIVE_TOOL_ROWS = 6;
31
- /** The yellow line above the composer while messages wait for the turn to end: count, the keys that act on the queue,
32
- * then a one-line preview of everything queued (newlines as " / ", capped at 120 chars). */
33
- export function queuedHint(queued) {
34
- const preview = queued.join("\n").replace(/\n/g, " / ");
35
- const head = queued.length > 1 ? `⏎ ${queued.length} queued · send together when this turn ends` : "⏎ queued · sends when this turn ends";
36
- const keys = queued.length > 1 ? "Esc send now · ↑ edit last · ⌫ cancel last" : "Esc send now · ↑ edit · ⌫ cancel";
37
- return `${head} · ${keys}: ${preview.slice(0, 120)}${preview.length > 120 ? "…" : ""}`;
46
+ // One live tool row (ui/batchLine.ts): the status glyph (the kind's own motion while running, ○ while drafting or
47
+ // waiting its turn), the tool name in its kind's color, and the rest — the result rides on the row, never under it.
48
+ function LiveRow({ step }) {
49
+ const moving = step.status === "running" || (step.status === "selected" && !!step.drafting);
50
+ const frame = useTick(moving);
51
+ const { head, rest } = liveRow(step, termCols(), Date.now());
52
+ const hue = KIND_HUE[toolKind(step.name)];
53
+ const glyph = step.status === "running" ? glyphFor(step.name, "running", frame) : step.status === "selected" ? "○" : step.outcome ? "⊘" : step.status === "error" ? "✗" : "✓";
54
+ const color = step.status === "running" ? hue : step.status === "selected" ? theme.muted : step.outcome === "blocked" ? theme.blocked : step.outcome ? theme.muted : step.status === "error" ? theme.error : theme.success;
55
+ return (_jsxs(Text, { children: [_jsx(Text, { color: color, bold: true, children: glyph }), " ", _jsx(Text, { color: hue, children: head }), _jsx(Text, { dimColor: step.status !== "running", children: rest })] }));
38
56
  }
39
- // Muted "ctrl+b to run in the background" tail on the phase line, once a shell command has run past ~2s. Ticks
40
- // on the shared animation clock only while a shell command is running, so it appears without any other event.
41
- function BackgroundHint({ rows }) {
42
- const watching = rows.some((r) => (r.name === "bash" || r.name === "shell_exec") && r.status === "running");
43
- useTick(watching);
44
- const hint = backgroundHint(rows);
45
- return hint ? _jsx(Text, { dimColor: true, children: ` · ${hint}` }) : null;
57
+ // Which running delegate_task row a child's progress belongs to: the one whose task matches (whitespace aside — the
58
+ // emitter trims it, live 11/04), else the only one running (delegate_task is a scheduler barrier, so one runs at a time).
59
+ const normTask = (t) => String(t ?? "").replace(/\s+/g, " ").trim();
60
+ export function delegateRow(rows, view) {
61
+ const running = rows.filter((r) => r.name === "delegate_task" && r.status === "running");
62
+ return (running.find((r) => normTask(r.args?.task) === normTask(view.task)) ?? (running.length === 1 ? running[0] : undefined))?.id;
63
+ }
64
+ // The specialist's live line under its running delegate_task (TUI plan #9), led by the delegation's own relay motion.
65
+ function DelegateChild({ view }) {
66
+ const frame = useTick(true);
67
+ return (_jsxs(Text, { children: [" ", _jsx(Text, { color: KIND_HUE.agent, children: relayFrame(frame) }), " ", _jsx(Text, { dimColor: true, children: delegateLine(view, termCols()) })] }));
68
+ }
69
+ // The phase line (ui/phase.ts): one dim row naming what the turn is measurably doing, then the keys that act on it
70
+ // (Enter steers, Tab queues, Esc stops), fitted to cols−1. It ticks on the shared clock only while it has something
71
+ // that moves — the read meter's head, or a shell command that may cross the ~2 s mark where the "ctrl+b to run in the
72
+ // background" hint appears without any other event. A ctrl+y offer (ui/actNow.ts — a long reasoning stream, a long
73
+ // read, the loop guard refusing) takes the line over.
74
+ function PhaseLine({ view, rows, offer = null }) {
75
+ const cols = termCols();
76
+ const watchingShell = view.phase === "tools" && rows.some((r) => (r.name === "bash" || r.name === "shell_exec") && r.status === "running");
77
+ const frame = useTick(watchingShell || (view.phase === "reading" && !!view.read));
78
+ const act = actNowLine(phaseWord(view.phase), offer);
79
+ if (act)
80
+ return _jsx(Text, { dimColor: true, children: cols < 45 ? ACT_NOW_NARROW : fitSegments(act, cols, { sep: "" }) });
81
+ // No steer keys while compacting: a manual /compact is no turn to steer — what is typed waits for it.
82
+ const { meter, text } = phaseLine({ ...view, hint: view.phase === "tools" ? backgroundHint(rows) : null, keys: view.phase === "compacting" ? undefined : turnKeySegs() }, cols, frame);
83
+ return (_jsxs(Text, { dimColor: true, children: [" ", meter ? _jsx(Text, { color: KIND_HUE.read, children: `${meter} ` }) : null, text] }));
84
+ }
85
+ // ctrl+o appends the newest collapsed item (a sub-agent report, a settled batch). Its own listener, so the composer only
86
+ // has to swallow the key; inactive while an overlay owns the keyboard.
87
+ function ExpandKey({ onExpand, active }) {
88
+ useInput((ch, key) => { if (isExpandKey(ch, key))
89
+ onExpand(); }, { isActive: active });
90
+ return null;
46
91
  }
47
92
  export function App(props) {
48
- const { messages, live = null, status, thinkingVerb, verbs, stepLabel, prefill = "", liveTools = [], route, ctxPct, ctxWindow, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], onBackground, tasks = [], onSubmit, onQueue, queuedPreview = [], onEditQueued, onDropQueued, onInterrupt, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null } = props;
49
- useTerminalSize(); // subscribe so the inline pinned UI (status rule, composer, footer) reflows the instant the terminal resizes
93
+ const { messages, live = null, status, thinkingVerb, verbs, stepLabel, phase = null, fold = null, delegate = null, liveTools = [], route, ctxPct, ctxWindow, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], mainLane = null, mainServing, maxRunning, onBackground, tasks = [], planNow, onSubmit, onQueue, onSteer, pending = [], onEditQueued, onDropQueued, nextSteps, onPickNext, onDismissNext, agents = [], onAgentMessage, conversations = [], switcher, onSwitcher, onFocusSwitcher, conversationPane = null, onSendTo, actOffer = null, onActNow, finder = null, onOpenFinder, onInterrupt, onExpand, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null } = props;
94
+ const cols = useTerminalSize().cols; // subscribe so the inline pinned UI (status rule, composer, footer) reflows the instant the terminal resizes
50
95
  const thinking = status === "thinking" || status === "streaming";
51
- // A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
52
- // a lone call isn't worth a bordered block, the braille spinner + name already says enough.
53
- const showParallelRows = status === "executing" && liveTools.length > 1;
54
- const showSpinner = status === "recovering" || status === "compacting" || (status === "executing" && !showParallelRows) || thinking;
96
+ // Tool rows exist before their calls run (TUI plan #8): from the first streamed argument (drafting) through waiting
97
+ // its turn to running and settled — one row per call, a lone call included, instead of the bare "⠋ name…".
98
+ const showLiveRows = liveTools.length > 0 && (status === "executing" || phase?.phase === "drafting");
99
+ const showSpinner = status === "recovering" || status === "compacting" || (status === "executing" && !showLiveRows) || thinking;
55
100
  // The live activity band (spinner / parallel-tool view) and the bg-agents panel — shared by both layouts.
56
101
  const activity = (_jsxs(_Fragment, { children: [showSpinner && (_jsx(Box, { marginTop: 1, marginBottom: 1, children: status === "recovering" || status === "compacting" ? _jsx(RecoverSpinner, { active: true, label: stepLabel })
57
102
  : status === "executing" ? _jsx(StepSpinner, { active: true, label: stepLabel })
58
- : _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), showParallelRows && (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: ["running ", liveTools.length, " tools in parallel"] }), liveTools.slice(0, MAX_LIVE_TOOL_ROWS).map((step) => _jsx(ToolStep, { step: step }, step.id)), liveTools.length > MAX_LIVE_TOOL_ROWS ? _jsxs(Text, { dimColor: true, children: [" +", liveTools.length - MAX_LIVE_TOOL_ROWS, " more\u2026"] }) : null] })), _jsx(PlanPane, { tasks: tasks }), _jsx(BgPanel, { agents: bgAgents, jobs: shellJobs }), (thinking || status === "executing" || status === "recovering") && (_jsxs(Text, { dimColor: true, children: [` ${status === "executing" ? "running tools" : status === "recovering" ? "recovering" : status === "streaming" ? "writing" : prefill || "reasoning"} · esc to interrupt`, status === "executing" ? _jsx(BackgroundHint, { rows: liveTools }) : null] }))] }));
59
- // Interactive prompts own the keyboard while up; kept out of the fullscreen clip region so they can't
60
- // be scrolled off. The Composer is `suspended` (keystrokes route to the decision, not the draft).
61
- const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(SecretPrompt, { pending: secretPrompt }), _jsx(QuestionPrompt, { pending: planExitPicker }), _jsx(ArtifactPicker, { pending: artifactsPicker }), _jsx(SessionPicker, { pending: sessionsPicker })] }));
103
+ : _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), showLiveRows && (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, paddingLeft: 1, children: [_jsx(Text, { dimColor: true, children: batchHeader(liveTools, termCols()) }), liveTools.slice(0, MAX_LIVE_TOOL_ROWS).map((step) => (_jsxs(React.Fragment, { children: [_jsx(LiveRow, { step: step }), delegate && step.id === delegateRow(liveTools, delegate) ? _jsx(DelegateChild, { view: delegate }) : null] }, step.id))), liveTools.length > MAX_LIVE_TOOL_ROWS ? _jsxs(Text, { dimColor: true, children: [" +", liveTools.length - MAX_LIVE_TOOL_ROWS, " more\u2026"] }) : null] })), fold ? (() => { const line = foldLine(fold, termCols(), true); return _jsxs(Text, { children: [_jsx(Text, { color: theme.blocked, children: line.slice(0, 1) }), _jsx(Text, { dimColor: true, children: line.slice(1) })] }); })() : null, _jsx(PlanPane, { tasks: tasks, now: planNow }), liveWorkers(mainLane, bgAgents, shellJobs) >= 2
104
+ ? _jsx(Lanes, { main: mainLane, agents: bgAgents, jobs: shellJobs, mainServing: mainServing, maxRunning: maxRunning })
105
+ : _jsx(BgPanel, { agents: bgAgents, jobs: shellJobs }), (thinking || status === "executing" || status === "recovering" || status === "compacting") && (_jsx(PhaseLine, { view: phase ?? { phase: status === "executing" ? "tools" : status === "recovering" ? "recovering" : status === "compacting" ? "compacting" : status === "streaming" ? "writing" : "waiting", label: stepLabel }, rows: liveTools, offer: actOffer }))] }));
106
+ // One input owner at a time. An open overlay — the finder, the focused switcher — keeps the keyboard; a prompt that
107
+ // arrives under it (an approval, an ask_user, the plan review) is drawn, waiting, and answered only once the overlay
108
+ // closes, so nothing typed into the overlay can answer it. With no overlay open a pending prompt owns the keyboard and
109
+ // the composer gives way, its next-step strip with it. Overlays open only from the composer, so never over a prompt.
110
+ const promptUp = !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker;
111
+ const owner = finder ? "finder" : switcher?.focused ? "switcher" : promptUp ? "prompt" : "composer";
112
+ const held = owner === "finder" || owner === "switcher";
113
+ const waiting = owner === "finder" ? "esc closes the finder, then answer here" : "↑ hands the keyboard back, then answer here";
114
+ // Prompts are kept out of the fullscreen clip region so they can't be scrolled off.
115
+ const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }), suspended: held, waiting: waiting }), _jsx(QuestionPrompt, { pending: question, suspended: held, waiting: waiting }), _jsx(QuestionPrompt, { pending: modelPicker, suspended: held, waiting: waiting }), _jsx(SecretPrompt, { pending: secretPrompt, suspended: held }), _jsx(QuestionPrompt, { pending: planExitPicker, suspended: held, waiting: waiting }), _jsx(ArtifactPicker, { pending: artifactsPicker, suspended: held }), _jsx(SessionPicker, { pending: sessionsPicker, suspended: held }), _jsx(SkillFinder, { pending: finder })] }));
62
116
  // The pinned bottom band: status rule, composer, bottom rule, then the mode/cycle FOOTER below the rule.
63
- const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxWindow: ctxWindow, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview.length ? _jsx(Text, { color: "yellow", children: queuedHint(queuedPreview) }) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, queued: queuedPreview.length, onEditQueued: onEditQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} ` })] }))] }));
117
+ // The mode line: the mode on the left, the conversation switcher in the centre, remote control on the right. The centre
118
+ // gets what the two sides leave, so the row stays at cols−1.
119
+ const modeText = opMode ? ` ${MODE_BADGE[opMode]} · shift+tab to cycle` : "";
120
+ const rcText = `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} `;
121
+ const centre = switcher ? switcherLine(conversations, switcher, Math.max(0, cols - 1 - cellWidth(modeText) - cellWidth(rcText) - 2)) : "";
122
+ const bottom = (_jsxs(_Fragment, { children: [_jsx(SwitcherKeys, { active: owner === "switcher", onKey: onSwitcher }), conversationPane ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "magenta", children: conversationPane.header }), conversationPane.lines.map((l, i) => _jsx(Text, { dimColor: !l.startsWith("⏺") && !l.startsWith("❯"), children: l || " " }, i))] })) : null, _jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxWindow: ctxWindow, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), owner === "composer" && status === "idle" && nextSteps?.length ? _jsx(Text, { color: "cyan", children: nextStepLine(nextSteps, cols) }) : null, pendingLines(pending, cols, phase ? phaseWord(phase.phase) : undefined).map((line, i) => _jsx(Text, { color: "yellow", children: line }, i)), onExpand ? _jsx(ExpandKey, { onExpand: onExpand, active: owner === "composer" }) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onSteer: onSteer, queued: pending.length, nextSteps: owner === "composer" && status === "idle" ? nextSteps?.length ?? 0 : 0, onPickNext: onPickNext, onDismissNext: onDismissNext, agents: agents, onAgentMessage: onAgentMessage, onSendTo: conversationPane ? onSendTo : undefined, onFocusSwitcher: onFocusSwitcher, onActNow: onActNow, onOpenFinder: onOpenFinder, prompt: conversationPane ? `${conversationPane.target} › ` : undefined, onEditQueued: onEditQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: owner !== "composer" }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: modeText }), centre ? (() => {
123
+ const pad = centreLayout(cellWidth(modeText), cellWidth(centre), cellWidth(rcText), cols);
124
+ return _jsx(Text, { color: switcher?.focused ? "cyan" : undefined, dimColor: !switcher?.focused, children: " ".repeat(pad.before) + centre + " ".repeat(Math.max(0, pad.after - 1)) });
125
+ })() : null, _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: rcText })] }))] }));
64
126
  // Fullscreen (opt-in): a full-terminal-height column. The transcript fills a clipped, bottom-anchored
65
127
  // region (non-Static tail) so the newest output sits just above a composer pinned to the very bottom —
66
128
  // no dead space. Off by default: inline keeps the terminal's native scrollback (mouse-scroll + copy).
@@ -75,6 +137,21 @@ export function App(props) {
75
137
  // The composer is measured (MeasuredComposer) so an open picker's click anchor knows what sits below it.
76
138
  return (_jsx(MouseProvider, { enabled: caps().mouse, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), activity, _jsxs(MeasuredStack, { children: [prompts, bottom] })] }) }));
77
139
  }
140
+ // Keys while the conversation switcher has focus (the composer is suspended meanwhile): ←/→ (or ↓) pick, Enter opens,
141
+ // ↑ or Esc hands the keyboard back to the composer.
142
+ function SwitcherKeys({ active, onKey }) {
143
+ useInput((_input, key) => {
144
+ if (key.leftArrow)
145
+ onKey?.("left");
146
+ else if (key.rightArrow || key.downArrow || key.tab)
147
+ onKey?.("right");
148
+ else if (key.return)
149
+ onKey?.("open");
150
+ else if (key.upArrow || key.escape)
151
+ onKey?.("back");
152
+ }, { isActive: active });
153
+ return null;
154
+ }
78
155
  // Measures the overlay stack (open picker + the composer block below it) as ONE block and publishes its
79
156
  // height to the mouse layer. An open picker is the top of this stack, so its top row = frameBottom −
80
157
  // stackHeight + 1 — the single measurement folds in the composer height and every inter-element margin, so
@@ -24,7 +24,7 @@ function summarize(name, args) {
24
24
  }
25
25
  }
26
26
  }
27
- export function ApprovalPrompt({ approval, onDecide }) {
27
+ export function ApprovalPrompt({ approval, onDecide, suspended = false, waiting }) {
28
28
  useInput((input, key) => {
29
29
  if (!approval)
30
30
  return;
@@ -37,9 +37,11 @@ export function ApprovalPrompt({ approval, onDecide }) {
37
37
  onDecide(true, true); // allow always (this session)
38
38
  else if (c === "d" || key.escape)
39
39
  onDecide(false, false); // deny
40
- }, { isActive: !!approval });
40
+ }, { isActive: !!approval && !suspended });
41
41
  if (!approval)
42
42
  return null;
43
43
  const detail = summarize(approval.name, approval.args);
44
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "yellow", paddingX: 1, children: [_jsxs(Text, { color: "yellow", bold: true, children: ["⚠ Operator wants to run ", _jsx(Text, { color: "magenta", children: approval.name })] }), detail ? _jsx(Text, { dimColor: true, children: " " + detail }) : null, _jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "[a]" }), " allow once ", _jsx(Text, { color: "cyan", children: "[s]" }), " allow always ", _jsx(Text, { color: "red", children: "[d]" }), " deny ", _jsx(Text, { dimColor: true, children: "(Enter=allow \u00B7 Esc=deny)" })] })] }));
44
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "yellow", paddingX: 1, children: [_jsxs(Text, { color: "yellow", bold: true, children: ["⚠ Operator wants to run ", _jsx(Text, { color: "magenta", children: approval.name })] }), detail ? _jsx(Text, { dimColor: true, children: " " + detail }) : null, suspended
45
+ ? _jsx(Text, { dimColor: true, children: " waiting · " + (waiting ?? "another prompt has the keyboard") })
46
+ : _jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "[a]" }), " allow once ", _jsx(Text, { color: "cyan", children: "[s]" }), " allow always ", _jsx(Text, { color: "red", children: "[d]" }), " deny ", _jsx(Text, { dimColor: true, children: "(Enter=allow \u00B7 Esc=deny)" })] })] }));
45
47
  }
@@ -62,7 +62,7 @@ function windowFor(n, hi) {
62
62
  start = Math.max(0, Math.min(start, n - VISIBLE_ROWS));
63
63
  return { start, end: start + VISIBLE_ROWS };
64
64
  }
65
- export function ArtifactPicker({ pending }) {
65
+ export function ArtifactPicker({ pending, suspended = false }) {
66
66
  const [st, setSt] = useState({ mode: "list", query: "", highlight: 0 });
67
67
  const wasOpen = useRef(false);
68
68
  useEffect(() => {
@@ -79,7 +79,7 @@ export function ArtifactPicker({ pending }) {
79
79
  setSt(a.state);
80
80
  if (a.intent)
81
81
  pending.onIntent(a.intent);
82
- }, { isActive: !!pending });
82
+ }, { isActive: !!pending && !suspended });
83
83
  // Row layout for click-to-select (hooks must run every render, so compute from safe defaults before the
84
84
  // early return). Rows below the box top: 1 border + 1 title (+1 search line in search mode). Each item is
85
85
  // one line. Click a row → highlight it; Enter still runs the primary action, per the footer help.
@@ -91,7 +91,7 @@ export function ArtifactPicker({ pending }) {
91
91
  const headerLines = 1 /* marginTop */ + 1 /* top border */ + 1 /* title */ + (st.mode === "search" ? 1 : 0);
92
92
  useClickList({
93
93
  id: "artifact-list",
94
- active: !!pending && !pending.loading && !pending.error,
94
+ active: !!pending && !suspended && !pending.loading && !pending.error,
95
95
  headerLines, rowHeight: 1, windowStart: start, visibleCount: end - start,
96
96
  onPick: (idx) => setSt((s) => ({ ...s, highlight: idx, confirmDeleteId: undefined })),
97
97
  });