@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
@@ -3,9 +3,18 @@ import { Box, Text } from "ink";
3
3
  import { OrbitGlyph } from "./ActivitySpinner.js";
4
4
  import { theme } from "./theme.js";
5
5
  import { useTick } from "./tick.js";
6
+ import { termCols, termRows } from "./term.js";
7
+ import { cellWidth, truncateToWidth } from "./StatusRule.js";
8
+ import { fmtElapsed, fmtTok } from "./format.js";
6
9
  const GLYPH = { queued: "◌", working: "●", idle: "✓", stopped: "✗" };
7
10
  const COLOR = { queued: theme.muted, working: theme.running, idle: theme.success, stopped: theme.error };
8
11
  const DISPLAY_STATUS = { queued: "queued", working: "running", idle: "done", stopped: "errored" };
12
+ // A stop by the owner, the orchestrator, the stall watchdog or the engine is a STOP, not an error (TUI plan #4): ■ in
13
+ // muted amber and the word "stopped". Only a failed start or a thrown error reads ✗ errored.
14
+ const deliberateStop = (a) => a.status === "stopped" && !!a.endKind && a.endKind !== "failed" && a.endKind !== "error";
15
+ const glyphOf = (a) => (deliberateStop(a) ? "■" : GLYPH[a.status]);
16
+ const colorOf = (a) => (deliberateStop(a) ? theme.blocked : COLOR[a.status]);
17
+ const statusOf = (a) => (deliberateStop(a) ? "stopped" : DISPLAY_STATUS[a.status]);
9
18
  const toks = (n) => (n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`);
10
19
  // Live per-agent metrics: tokens generated + elapsed. While working, elapsed is derived from
11
20
  // startedAt at render time (updates each round tick); once finished, the wall time is frozen.
@@ -31,7 +40,7 @@ const ACTIVITY_VERB = {
31
40
  task_add: "planning", task_update: "planning", task_clear: "planning", spawn_agent: "delegating",
32
41
  message_agent: "messaging", web_search: "searching web", web_fetch: "fetching",
33
42
  };
34
- const humanStep = (name) => ACTIVITY_VERB[name] ?? name.replace(/_/g, " ");
43
+ export const humanStep = (name) => ACTIVITY_VERB[name] ?? name.replace(/_/g, " ");
35
44
  // One short phrase for what THIS round is actually doing, next to "round N" — the round counter alone is
36
45
  // just a number; this is the "editing cli.py" a glance needs. Prefers the in-flight tool call, then falls
37
46
  // back to the live reasoning tail, then the last settled step, so it's never blank while the agent is
@@ -68,10 +77,14 @@ export function ledgerLine(a) {
68
77
  export function detailLine(a) {
69
78
  if (a.status === "working" && a.stuck)
70
79
  return { text: `⚠ stuck: ${a.stuck} — /agents ${a.id} msg <steer> · /agents ${a.id} stop`, tone: "stuck" };
80
+ // A message the owner sent (@Name) takes the detail line until the agent takes it — the panel keeps its three rows.
81
+ if ((a.status === "working" || a.status === "queued") && a.pendingMessages) {
82
+ return { text: `✉ ${a.pendingMessages} message${a.pendingMessages > 1 ? "s" : ""} waiting · ${a.status === "queued" ? "lands when it starts" : "lands at its next round"}`, tone: "dim" };
83
+ }
71
84
  if (a.status === "idle")
72
85
  return { text: "result posted — scroll up or /agents to review", tone: "dim" };
73
86
  if (a.status === "stopped")
74
- return { text: "errored — check transcript for details", tone: "dim" };
87
+ return { text: a.endReason ?? "errored — check transcript for details", tone: "dim" };
75
88
  if (a.status === "queued")
76
89
  return { text: "waiting for a free slot", tone: "dim" };
77
90
  const steps = a.steps ?? [];
@@ -85,7 +98,7 @@ export function detailLine(a) {
85
98
  // every tick, and Ink repainted the whole frame (the flashing, 10/31).
86
99
  function AgentRows({ a }) {
87
100
  const d = detailLine(a);
88
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Box, { flexGrow: 1, flexShrink: 1, children: _jsxs(Text, { wrap: "truncate-end", children: [a.status === "working" ? _jsx(OrbitGlyph, {}) : _jsx(Text, { color: COLOR[a.status], children: GLYPH[a.status] }), " ", _jsx(Text, { bold: true, children: a.name ?? a.label }), a.name ? _jsx(Text, { dimColor: true, children: ` · ${cap(a.label, 40)}` }) : null, a.round != null ? ` · round ${a.round}` : "", a.status === "working" && missionLine(a) ? _jsxs(Text, { color: theme.accent, children: [" \u00B7 ", cap(missionLine(a), 36)] }) : null] }) }), _jsx(Box, { flexShrink: 0, marginLeft: 1, children: _jsx(Text, { dimColor: true, children: (() => { const m = metrics(a); const ds = DISPLAY_STATUS[a.status]; return m ? `${m} · ${ds}` : ds; })() }) })] }), _jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: ledgerLine(a) }) }), _jsx(Box, { paddingLeft: 2, children: d.tone === "stuck" ? _jsx(Text, { color: theme.error, wrap: "truncate-end", children: d.text }) : _jsx(Text, { dimColor: true, wrap: "truncate-end", children: cap(d.text, 110) }) })] }));
101
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Box, { flexGrow: 1, flexShrink: 1, children: _jsxs(Text, { wrap: "truncate-end", children: [a.status === "working" ? _jsx(OrbitGlyph, {}) : _jsx(Text, { color: colorOf(a), children: glyphOf(a) }), " ", _jsx(Text, { bold: true, children: a.name ?? a.label }), a.name ? _jsx(Text, { dimColor: true, children: ` · ${cap(a.label, 40)}` }) : null, a.round != null ? ` · round ${a.round}` : "", a.status === "working" && missionLine(a) ? _jsxs(Text, { color: theme.accent, children: [" \u00B7 ", cap(missionLine(a), 36)] }) : null] }) }), _jsx(Box, { flexShrink: 0, marginLeft: 1, children: _jsx(Text, { dimColor: true, children: (() => { const m = metrics(a); const ds = statusOf(a); return m ? `${m} · ${ds}` : ds; })() }) })] }), _jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: ledgerLine(a) }) }), _jsx(Box, { paddingLeft: 2, children: d.tone === "stuck" ? _jsx(Text, { color: theme.error, wrap: "truncate-end", children: d.text }) : _jsx(Text, { dimColor: true, wrap: "truncate-end", children: cap(d.text, 110) }) })] }));
89
102
  }
90
103
  // Cap how many agent rows the DYNAMIC panel renders. Each agent is ~3 lines; a full fan-out (6–8 agents)
91
104
  // makes the non-Static frame tall AND it re-renders on every sub-agent token — so when it sits near the
@@ -126,8 +139,9 @@ export function BgPanel({ agents, jobs = [], title = "sub-agents" }) {
126
139
  const running = agents.filter((a) => a.status === "working").length;
127
140
  const queued = agents.filter((a) => a.status === "queued").length;
128
141
  const done = agents.filter((a) => a.status === "idle").length;
129
- const errored = agents.filter((a) => a.status === "stopped").length;
130
- const counts = [running ? `${running} running` : "", queued ? `${queued} queued` : "", done ? `${done} done` : "", errored ? `${errored} errored` : ""].filter(Boolean).join(" · ");
142
+ const stopped = agents.filter(deliberateStop).length;
143
+ const errored = agents.filter((a) => a.status === "stopped").length - stopped;
144
+ const counts = [running ? `${running} running` : "", queued ? `${queued} queued` : "", done ? `${done} done` : "", stopped ? `${stopped} stopped` : "", errored ? `${errored} errored` : ""].filter(Boolean).join(" · ");
131
145
  const label = `${title}${counts ? ` · ${counts}` : ` (${agents.length})`}`;
132
146
  // A designated, bounded zone (per request): a dim rounded box with the section label as its first line,
133
147
  // detached from the plan list above by a top margin — sub-agents read as their own region instead of
@@ -138,3 +152,89 @@ export function BgPanel({ agents, jobs = [], title = "sub-agents" }) {
138
152
  // borderless column (the label line alone still heads it).
139
153
  return (_jsxs(Box, { flexDirection: "column", marginTop: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { dimColor: true, children: label }), shown.map((a) => _jsx(AgentRows, { a: a }, a.id)), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more running` }) : null, _jsx(ShellJobs, { jobs: jobs })] }));
140
154
  }
155
+ const LANE_GLYPH = {
156
+ main: "✷", working: "◠", waiting: "◌", queued: "◌", done: "✓", stopped: "■", error: "✗", stuck: "⚠", job: "▶", jobDone: "✓", jobFailed: "✗",
157
+ };
158
+ const LANE_COLOR = {
159
+ main: theme.accent, working: theme.accent, waiting: theme.blocked, queued: theme.muted, done: theme.success, stopped: theme.blocked,
160
+ error: theme.error, stuck: theme.warn, job: theme.info, jobDone: theme.success, jobFailed: theme.error,
161
+ };
162
+ /** A gate owner label as a lane says it: "main", or the sub-agent's name. */
163
+ const holderShort = (h) => (!h || h === "sub-agent" ? "another agent" : h === "compaction" ? "a compaction" : h);
164
+ export function mainLaneOf(m) {
165
+ return { key: "main", tone: "main", name: "main", role: m.model, mission: m.activity, elapsedMs: m.elapsedMs, tokens: m.tokens };
166
+ }
167
+ /** One sub-agent as a lane: its round and mission, who holds the slot it waits for, why it stopped. Pure. */
168
+ export function agentLaneOf(a, now, ctx = {}) {
169
+ const elapsedMs = a.status === "working" ? (a.startedAt !== undefined ? now - a.startedAt : undefined) : a.durationMs;
170
+ const base = { key: a.id, name: a.name ?? a.id, role: a.title ?? "sub-agent", elapsedMs, tokens: a.tokens };
171
+ const ledger = [a.written?.length ? `wrote ${a.written.length}` : "", a.reads ? `read ${a.reads}` : "", a.commands ? `ran ${a.commands}` : ""].filter(Boolean).join(" · ");
172
+ const join = (...xs) => xs.filter(Boolean).join(" · ");
173
+ if (a.status === "queued")
174
+ return { ...base, tone: "queued", mission: ctx.maxRunning ? `queued: ${ctx.running ?? ctx.maxRunning} of ${ctx.maxRunning} agent slots busy` : "queued for a free agent slot" };
175
+ if (a.status === "idle")
176
+ return { ...base, tone: "done", mission: join("done", a.verified === true ? "✓ verified" : a.verified === false ? "✗ unverified" : undefined, a.written?.length ? `wrote ${a.written.slice(-1).map((p) => p.split("/").pop()).join("")}` : undefined, "report delivered") };
177
+ if (a.status === "stopped") {
178
+ const err = a.endKind === "failed" || a.endKind === "error" || !a.endKind;
179
+ return { ...base, tone: err ? "error" : "stopped", mission: join(a.endReason ?? "errored", a.headline?.startsWith("partial:") ? "partial notes delivered" : undefined) };
180
+ }
181
+ if (a.stuck)
182
+ return { ...base, tone: "stuck", mission: `stuck: ${a.stuck} · /agents ${(a.name ?? a.id).toLowerCase()} msg | stop` };
183
+ if (a.slotWaitSince !== undefined) {
184
+ return { ...base, tone: "waiting", mission: join(`waiting ${fmtElapsed(now - a.slotWaitSince)}: ${a.model ?? "its model"}'s slot is held by ${holderShort(a.slotHolder)}`, ledger || undefined) };
185
+ }
186
+ const where = a.model && ctx.mainServing ? (a.model === ctx.mainServing ? "shares main's slot" : "own server") : undefined;
187
+ return { ...base, tone: "working", mission: join(a.round ? `r${a.round}` : undefined, missionLine(a), ledger || undefined, where) };
188
+ }
189
+ export function jobLaneOf(j, now) {
190
+ const tone = j.status === "running" ? "job" : j.status === "done" ? "jobDone" : "jobFailed";
191
+ return { key: j.id, tone, name: j.id, role: "", mission: j.cmd.replace(/\s+/g, " ").trim(), elapsedMs: j.status === "running" ? now - j.startedAt : j.elapsedMs, status: j.status === "running" ? "running" : j.status === "failed" ? `exit ${j.code ?? "?"}` : j.status };
192
+ }
193
+ /** How many workers are live at once — lanes mode is two or more. */
194
+ export function liveWorkers(main, agents, jobs) {
195
+ return (main ? 1 : 0) + agents.filter((a) => a.status === "working" || a.status === "queued").length + jobs.filter((j) => j.status === "running").length;
196
+ }
197
+ /** One lane as text (pure): the name and role columns, the mission clipped to fill, the right column (elapsed · tokens,
198
+ * or a job's state) right-aligned so the row ends at cols−1. 80–99 cols drop the role, 60–79 the tokens, and under 60
199
+ * only glyph · name · mission · elapsed stay. */
200
+ export function laneRow(l, cols) {
201
+ const lead = 4; // padding + the glyph (counted wide) + a space
202
+ const role = cols >= 100 && l.role ? ` ${l.role.slice(0, 11).padEnd(11)}` : "";
203
+ const left = `${l.name.slice(0, 6).padEnd(6)}${role} `;
204
+ const time = l.elapsedMs !== undefined ? fmtElapsed(l.elapsedMs) : "";
205
+ const tail = l.status ?? (cols >= 60 && l.tokens ? `${fmtTok(l.tokens)} tok` : "");
206
+ const right = cols >= 60 ? [time, tail].filter(Boolean).join(" · ") : time;
207
+ const room = cols - 1 - lead - cellWidth(left) - (right ? cellWidth(right) + 2 : 0);
208
+ const mission = truncateToWidth(l.mission, Math.max(0, room));
209
+ return { left, mission: mission + " ".repeat(Math.max(0, room - cellWidth(mission))), right };
210
+ }
211
+ /** The lanes header: counts, a rule, and the commands that act on them (dropped under 80 cols) — cols−1 wide. */
212
+ export function laneHeader(lanes, cols) {
213
+ const n = (t) => lanes.filter((l) => t.includes(l.tone)).length;
214
+ const running = n(["main", "working", "stuck"]), waiting = n(["waiting"]), queued = n(["queued"]), jobs = n(["job"]);
215
+ const counts = [`${lanes.length} lanes`, running ? `${running} running` : "", waiting ? `${waiting} waiting for a slot` : "", queued ? `${queued} queued` : "", jobs ? `${jobs} shell job${jobs === 1 ? "" : "s"}` : ""].filter(Boolean).join(" · ");
216
+ const hint = cols >= 80 ? " /agents · /jobs" : "";
217
+ const head = truncateToWidth(` ⇶ ${counts} `, cols - 1 - cellWidth(hint) - 1);
218
+ return head + "─".repeat(Math.max(1, cols - 1 - cellWidth(head) - cellWidth(hint))) + hint;
219
+ }
220
+ /** Rows below this cap the lanes at three, plus "+N more · /agents". */
221
+ export const LANES_SHORT_ROWS = 30;
222
+ function LaneRow({ lane, cols }) {
223
+ const { left, mission, right } = laneRow(lane, cols);
224
+ return (_jsxs(Text, { children: [" ", lane.tone === "working" ? _jsx(OrbitGlyph, {}) : _jsx(Text, { color: LANE_COLOR[lane.tone], children: LANE_GLYPH[lane.tone] }), " ", _jsx(Text, { bold: true, children: left.slice(0, 6) }), _jsx(Text, { dimColor: true, children: left.slice(6) }), _jsx(Text, { color: lane.tone === "stuck" ? theme.warn : undefined, dimColor: lane.tone !== "stuck" && lane.tone !== "main" && lane.tone !== "working", children: mission }), right ? _jsx(Text, { dimColor: true, children: ` ${right}` }) : null] }));
225
+ }
226
+ /** The lanes view: one row per live worker, finished agents lingering until they are reaped. */
227
+ export function Lanes({ main, agents, jobs, mainServing, maxRunning }) {
228
+ const cols = termCols();
229
+ const now = Date.now();
230
+ const running = agents.filter((a) => a.status === "working").length;
231
+ const order = (a) => (a.status === "working" ? (a.slotWaitSince !== undefined ? 1 : 0) : a.status === "queued" ? 2 : 3);
232
+ const lanes = [
233
+ ...(main ? [mainLaneOf(main)] : []),
234
+ ...[...agents].sort((a, b) => order(a) - order(b)).map((a) => agentLaneOf(a, now, { mainServing, running, maxRunning })),
235
+ ...jobs.map((j) => jobLaneOf(j, now)),
236
+ ];
237
+ const cap = termRows() < LANES_SHORT_ROWS ? 3 : 8;
238
+ const shown = lanes.slice(0, cap);
239
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { dimColor: true, children: laneHeader(lanes, cols) }), shown.map((l) => _jsx(LaneRow, { lane: l, cols: cols }, l.key)), lanes.length > shown.length ? _jsx(Text, { dimColor: true, children: ` +${lanes.length - shown.length} more · /agents` }) : null] }));
240
+ }
@@ -17,11 +17,15 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
17
17
  import { useEffect, useRef, useState } from "react";
18
18
  import { Box, Text, useInput, useStdin } from "ink";
19
19
  import { InputHistory } from "./useInputHistory.js";
20
+ import { isExpandKey } from "./expand.js";
20
21
  import { matchSlashCommands } from "./slashCommands.js";
21
22
  import { touchInput } from "../idle/activity.js";
23
+ import { isSlashCommand } from "../util/slash.js";
24
+ import { agentMention, matchAgentMentions, mentionCompletion, mentionMenuLine } from "./conversations.js";
25
+ import { termCols } from "./term.js";
22
26
  const PASTE_START = "\x1b[200~";
23
27
  const PASTE_END = "\x1b[201~";
24
- export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, onCycleMode, onCycleContext, onBackground, queued = 0, onEditQueued, onDropQueued, prompt = "› " }) {
28
+ export function Composer({ onSubmit, onInterrupt, onQueue, onSteer, disabled, suspended, onCycleMode, onCycleContext, onBackground, queued = 0, onEditQueued, onDropQueued, nextSteps = 0, onPickNext, onDismissNext, agents = [], onAgentMessage, onSendTo, onFocusSwitcher, onActNow, onOpenFinder, prompt = "› " }) {
25
29
  const [value, setValue] = useState("");
26
30
  const suspendedRef = useRef(suspended); // read by the raw-stdin paste listener, registered once below
27
31
  suspendedRef.current = suspended;
@@ -41,6 +45,9 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
41
45
  // handlers below); ↑/↓ move it without touching the draft.
42
46
  const menuMatches = matchSlashCommands(value);
43
47
  const menuSel = menuMatches.length ? Math.min(selIdx, menuMatches.length - 1) : 0;
48
+ // The "@" menu (A3.4): a bare "@token" lists the live sub-agents it can reach; Tab completes the highlighted one.
49
+ const atMatches = onAgentMessage ? matchAgentMentions(value, agents) : null;
50
+ const atSel = atMatches ? Math.min(selIdx, atMatches.length - 1) : 0;
44
51
  useEffect(() => {
45
52
  if (!isRawModeSupported || !stdin)
46
53
  return;
@@ -144,11 +151,18 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
144
151
  onCycleMode?.();
145
152
  return;
146
153
  }
147
- // Plain Tab completes the "/" menu to the highlighted command (with a trailing space, ready for args).
148
- // Always swallow a lone Tab so a literal tab character can never land in the draft.
154
+ // Plain Tab completes the "/" menu to the highlighted command (with a trailing space, ready for args); with no menu
155
+ // open and a turn running, it queues the draft for after the turn. Always swallowed: a literal tab never lands.
149
156
  if (key.tab) {
150
157
  if (menuMatches.length)
151
158
  setValue(`/${menuMatches[menuSel].name} `);
159
+ else if (atMatches)
160
+ setValue(mentionCompletion(atMatches[atSel]));
161
+ else if (disabled && onQueue) {
162
+ const text = commitDraft();
163
+ if (text !== null)
164
+ onQueue(text);
165
+ }
152
166
  return;
153
167
  }
154
168
  // ctrl+b moves the running command to the background (matches Claude Code). Inside tmux the first ctrl+b is
@@ -162,9 +176,26 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
162
176
  onCycleContext?.();
163
177
  return;
164
178
  }
179
+ if (isExpandKey(ch, key))
180
+ return; // ctrl+o expands the newest collapsed item — App owns the action; never lands in the draft
181
+ // ctrl+y — "use what you have": acts mid-turn whatever the draft holds, like ctrl+b. Swallowed either way.
182
+ if (isActNowKey(ch, key)) {
183
+ onActNow?.();
184
+ return;
185
+ }
186
+ // ctrl+g opens the skills and tools finder, idle or mid-turn; the draft stays as it is.
187
+ if (isFinderKey(ch, key)) {
188
+ onOpenFinder?.();
189
+ return;
190
+ }
165
191
  // ESC / Ctrl+C: apply the pure interruptPlan. ESC mid-turn with a pending draft flushes it into
166
192
  // the queue (so it goes through right after the interrupt, via the turn-finally drain), then
167
193
  // interrupts; an empty-draft ESC and every Ctrl+C are plain interrupts. See interruptPlan below.
194
+ // With the next-step strip up, Esc closes it; Ctrl+C keeps its meaning (at rest: quit) — review F13.
195
+ if (key.escape && nextSteps > 0) {
196
+ onDismissNext?.();
197
+ return;
198
+ }
168
199
  if (key.escape || (key.ctrl && ch === "c")) {
169
200
  const plan = interruptPlan({ escape: key.escape, ctrlC: key.ctrl && ch === "c" }, { disabled, hasQueue: !!onQueue, draftNonEmpty: !!expandPastes(value, pasteStoreRef.current).trim() });
170
201
  if (plan.flushDraft) {
@@ -176,6 +207,15 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
176
207
  onInterrupt();
177
208
  return;
178
209
  }
210
+ // After a stop, a digit on an empty draft picks a next step; any other typed key hides the strip and types normally.
211
+ if (nextSteps > 0) {
212
+ if (value === "" && /^[1-9]$/.test(ch) && Number(ch) <= nextSteps && !key.ctrl && !key.meta) {
213
+ onPickNext?.(Number(ch));
214
+ return;
215
+ }
216
+ if (ch && !key.ctrl && !key.meta)
217
+ onDismissNext?.();
218
+ }
179
219
  if (key.return) {
180
220
  if (key.shift) {
181
221
  setValue((v) => `${v}\n`);
@@ -188,7 +228,20 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
188
228
  const text = commitDraft(); // chips -> real payload; the model gets the full paste, not "[Pasted #1]"
189
229
  if (text === null)
190
230
  return;
191
- if (disabled && onQueue)
231
+ // "@Nova <text>" never queues and never costs a main-model turn, idle or mid-turn; an @token that names no live
232
+ // sub-agent falls through, so a file mention still reaches the model.
233
+ if (onAgentMessage && agentMention(text, agents)) {
234
+ onAgentMessage(text);
235
+ return;
236
+ }
237
+ if (onSendTo && !isSlashCommand(text)) {
238
+ onSendTo(text);
239
+ return;
240
+ }
241
+ const route = enterRoute(text, { disabled, canSteer: !!onSteer, canQueue: !!onQueue });
242
+ if (route === "steer")
243
+ onSteer(text);
244
+ else if (route === "queue")
192
245
  onQueue(text);
193
246
  else
194
247
  onSubmit(text);
@@ -207,13 +260,16 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
207
260
  onDropQueued?.();
208
261
  return;
209
262
  }
210
- // ↑/↓ navigate the "/" menu when it's open — takes priority over history recall so arrows move the
211
- // highlight instead of clobbering the "/command" draft. Wraps around.
212
- if ((key.upArrow || key.downArrow) && menuMatches.length > 0) {
213
- const n = menuMatches.length;
263
+ // ↑/↓ navigate the "/" or "@" menu when it's open — takes priority over history recall so arrows move the
264
+ // highlight instead of clobbering the draft. Wraps around.
265
+ if ((key.upArrow || key.downArrow) && (menuMatches.length > 0 || atMatches)) {
266
+ const n = menuMatches.length || atMatches.length;
214
267
  setSelIdx((i) => (key.upArrow ? (i - 1 + n) % n : (i + 1) % n));
215
268
  return;
216
269
  }
270
+ // ↓ with nothing to recall moves focus to the conversation switcher on the mode line (A3.4).
271
+ if (key.downArrow && value === "" && !historyRef.current.recalling && onFocusSwitcher?.())
272
+ return;
217
273
  // History recall (shell-style): only on a single-line buffer, so ↑/↓ stay free for navigating
218
274
  // a multi-line draft instead of clobbering it. See useInputHistory.ts for the ring/draft model.
219
275
  if ((key.upArrow || key.downArrow) && !value.includes("\n")) {
@@ -250,7 +306,7 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
250
306
  const on = i === menuSel;
251
307
  const label = `/${c.name}${c.args ? " " + c.args : ""}`.padEnd(24);
252
308
  return (_jsxs(Text, { children: [_jsx(Text, { color: on ? "green" : undefined, bold: on, children: (on ? "▸ " : " ") + label }), _jsx(Text, { dimColor: true, children: c.description })] }, c.name));
253
- }), menuMatches.length > 10 && _jsx(Text, { dimColor: true, children: ` …and ${menuMatches.length - 10} more` })] }))] }));
309
+ }), menuMatches.length > 10 && _jsx(Text, { dimColor: true, children: ` …and ${menuMatches.length - 10} more` })] })), atMatches ? _jsx(Text, { dimColor: true, children: mentionMenuLine(atMatches, atSel, termCols()) }) : null] }));
254
310
  }
255
311
  // Recognize media file paths in the draft. IMAGE covers the common still formats, VIDEO the moving
256
312
  // ones; a path matching VIDEO is chipped as video, otherwise image. Extensions only — no I/O.
@@ -345,6 +401,16 @@ export function interruptPlan(key, ctx) {
345
401
  return { flushDraft: false, interrupt: true };
346
402
  return { flushDraft: false, interrupt: false };
347
403
  }
404
+ /** Where Enter sends a committed draft. At rest it submits. While a turn runs, plain text STEERS — it goes in before the
405
+ * turn's next model call, as an owner message — and a known /command queues (the shell decides whether it runs now or
406
+ * after the turn). Without a steer sink it queues, as before. */
407
+ export function enterRoute(text, ctx) {
408
+ if (!ctx.disabled)
409
+ return "submit";
410
+ if (ctx.canSteer && !isSlashCommand(text))
411
+ return "steer";
412
+ return ctx.canQueue ? "queue" : "submit";
413
+ }
348
414
  /** Pure decision for ↑ / Backspace while messages are queued. Only an EMPTY draft is eligible, so typing, deleting
349
415
  * and history recall are untouched while there is text in the box: ↑ = "edit" (pop the most recent queued message
350
416
  * into the draft), Backspace/Delete = "drop" (discard it). Anything else, or an empty queue, is null. */
@@ -361,6 +427,16 @@ export function queuedKeyPlan(key, ctx) {
361
427
  export function isBackgroundKey(ch, key) {
362
428
  return !!key.ctrl && (ch === "b" || ch === "z");
363
429
  }
430
+ /** ctrl+y — "use what you have" (TUI A3.3). Not ctrl+g: that opens the skills and tools finder. ctrl+y is bound nowhere
431
+ * else in Operator; in readline it is yank, which this composer does not implement, and in raw mode the terminal's
432
+ * delayed-suspend (DSUSP) never sees it. */
433
+ export function isActNowKey(ch, key) {
434
+ return !!key.ctrl && ch === "y";
435
+ }
436
+ /** ctrl+g — the skills and tools finder (TUI A3.3, James: "control+g should be to find tool / skill from our gateway"). */
437
+ export function isFinderKey(ch, key) {
438
+ return !!key.ctrl && ch === "g";
439
+ }
364
440
  /** ctrl+x — cycle the context pin (Ink reports it as "x" with ctrl). */
365
441
  export function isContextCycleKey(ch, key) {
366
442
  return !!key.ctrl && ch === "x";
@@ -1,7 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { theme } from "./theme.js";
4
- import { bar } from "./chart.js";
4
+ import { termCols } from "./term.js";
5
+ import { cellWidth, truncateToWidth } from "./StatusRule.js";
6
+ import { fitSegments, seg } from "./fit.js";
7
+ import { fmtElapsed } from "./format.js";
5
8
  const GLYPH = { pending: "☐", in_progress: "◐", done: "☑", cancelled: "⊘" };
6
9
  const COLOR = { pending: theme.muted, in_progress: theme.running, done: theme.success, cancelled: theme.muted };
7
10
  const finished = (t) => t.status === "done" || t.status === "cancelled";
@@ -31,18 +34,79 @@ export function visiblePlan(tasks, max = PLAN_MAX_ROWS) {
31
34
  const shown = tasks.filter((t) => pick.has(t));
32
35
  return { shown, hidden: tasks.length - shown.length };
33
36
  }
34
- export function PlanPane({ tasks, title = "plan" }) {
37
+ /** A step's measured time: the time it was worked (registry.ts taskUpdate's activeMs, plus the stretch in progress up to
38
+ * `now`); a stretch it sat demoted to pending while another step ran does not count (review F6). Pending or never
39
+ * started → nothing. A task without work stamps (an older store) falls back to its span. */
40
+ export function stepMs(t, now) {
41
+ if (t.startedAt === undefined || t.status === "pending")
42
+ return undefined;
43
+ if (t.activeMs !== undefined || t.activeSince !== undefined) {
44
+ const open = t.status === "in_progress" && t.activeSince !== undefined ? now - t.activeSince : 0;
45
+ return Math.max(0, (t.activeMs ?? 0) + open);
46
+ }
47
+ if (finished(t))
48
+ return t.endedAt !== undefined ? Math.max(0, t.endedAt - t.startedAt) : undefined;
49
+ return Math.max(0, now - t.startedAt);
50
+ }
51
+ /** Narrow thresholds: the duration column leaves below 70 cols; below 50 the pane is one line. */
52
+ export const PLAN_DURATION_MIN_COLS = 70;
53
+ export const PLAN_ONE_LINE_COLS = 50;
54
+ const DUR_W = 7; // "21m 5s" plus a cell
55
+ const LEAD = 4; // paddingLeft + glyph (counted wide, as cellWidth does) + space
56
+ /** One row (pure): the step text clipped to fit, and its measured time right-aligned so the row ends at cols−1. */
57
+ export function planRow(t, cols, now) {
58
+ const avail = cols - 1 - LEAD;
59
+ const withDur = cols >= PLAN_DURATION_MIN_COLS;
60
+ const ms = withDur ? stepMs(t, now) : undefined;
61
+ const dur = ms !== undefined ? fmtElapsed(ms) : "";
62
+ const text = truncateToWidth(t.text, withDur ? avail - DUR_W - 1 : avail);
63
+ return { text, pad: dur ? " ".repeat(Math.max(1, avail - cellWidth(text) - cellWidth(dur))) : "", dur };
64
+ }
65
+ /** The pane as one line under PLAN_ONE_LINE_COLS: "plan 2/7 · ◐ Wire the fallback…". */
66
+ export function planOneLine(tasks, cols) {
67
+ const done = tasks.filter((t) => t.status === "done").length;
68
+ const cur = tasks.find((t) => t.status === "in_progress") ?? tasks.find((t) => t.status === "pending");
69
+ return fitSegments([seg(`plan ${done}/${tasks.length}`), ...(cur ? [seg(`${GLYPH[cur.status]} ${cur.text}`)] : [])], cols, { lead: " " });
70
+ }
71
+ /** The spinner verb while a step is being worked: "Step 3/7 · Wire the fallback into buildRouter". */
72
+ export function planVerb(tasks) {
73
+ const i = tasks.findIndex((t) => t.status === "in_progress");
74
+ return i < 0 ? undefined : `Step ${i + 1}/${tasks.length} · ${tasks[i].text}`;
75
+ }
76
+ /** The one Static line when the last open step lands: counts, the wall time from the first start to the last end, and
77
+ * the longest step — every number a timestamp the task store recorded. */
78
+ export function planReceipt(tasks, cols) {
79
+ const done = tasks.filter((t) => t.status === "done").length;
80
+ const cancelled = tasks.filter((t) => t.status === "cancelled").length;
81
+ const starts = tasks.map((t) => t.startedAt).filter((x) => x !== undefined);
82
+ const ends = tasks.map((t) => t.endedAt).filter((x) => x !== undefined);
83
+ const wall = starts.length && ends.length ? Math.max(...ends) - Math.min(...starts) : undefined;
84
+ let longest;
85
+ for (const t of tasks)
86
+ if ((stepMs(t, 0) ?? -1) > (longest ? stepMs(longest, 0) ?? -1 : -1))
87
+ longest = t;
88
+ const counts = cancelled ? `${done}/${tasks.length} done, ${cancelled} cancelled,` : `${done}/${tasks.length} steps`;
89
+ return fitSegments([
90
+ seg(wall !== undefined ? [`plan complete · ${counts} in ${fmtElapsed(wall)}`, `plan complete · ${counts.replace(/,$/, "")}`] : `plan complete · ${counts.replace(/,$/, "")}`, 2, true),
91
+ ...(longest && stepMs(longest, 0) !== undefined ? [seg(`longest: ${longest.text} (${fmtElapsed(stepMs(longest, 0))})`, 3)] : []),
92
+ ], cols, { lead: "☑ " });
93
+ }
94
+ export function PlanPane({ tasks, title = "plan", now = Date.now() }) {
35
95
  if (!tasks.length)
36
96
  return null;
37
97
  // A fully-completed plan clears itself — once every step is done it has no live value and shouldn't keep
38
- // occupying the frame. The per-step ✓ already showed as each landed; the finished list drops away.
98
+ // occupying the frame. The per-step ✓ already showed as each landed; cli.tsx settles one receipt line instead.
39
99
  if (tasks.every(finished))
40
100
  return null;
101
+ const cols = termCols();
102
+ if (cols < PLAN_ONE_LINE_COLS)
103
+ return _jsx(Text, { dimColor: true, children: planOneLine(tasks, cols) });
41
104
  // Borderless: this pane renders in Ink's DYNAMIC region; a box border there orphans its rows into
42
105
  // scrollback whenever the Static transcript grows during a long turn (the v0.1.92 line-flood). The
43
106
  // dim header labels the group without a border.
44
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: [`${title} · ${planProgress(tasks)} `, _jsx(Text, { color: theme.success, children: bar(tasks.filter((t) => t.status === "done").length, tasks.length, 8) })] }), (() => {
45
- const { shown, hidden } = visiblePlan(tasks);
46
- return (_jsxs(_Fragment, { children: [shown.map((t) => (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: finished(t), strikethrough: finished(t), children: t.text })] }, t.id))), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more` }) : null] }));
47
- })()] }));
107
+ const { shown, hidden } = visiblePlan(tasks);
108
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsx(Text, { dimColor: true, children: `${title} · ${planProgress(tasks)}` }), shown.map((t) => {
109
+ const { text, pad, dur } = planRow(t, cols, now);
110
+ return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: finished(t), strikethrough: finished(t), children: text }), dur ? _jsxs(Text, { dimColor: true, children: [pad, dur] }) : null] }, t.id));
111
+ }), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more` }) : null] }));
48
112
  }
@@ -84,7 +84,9 @@ export function questionKey(st, input, key, options, multiSelect = false) {
84
84
  return { state: { mode: "type", buffer: "", highlight: options.length, selected: st.selected } }; // open the free-text line
85
85
  return {};
86
86
  }
87
- export function QuestionPrompt({ pending }) {
87
+ /** `suspended`: another surface owns the keyboard (an overlay open over it, App.tsx) — drawn, with `waiting` saying how to
88
+ * reach it, and never answered by that surface's keys. */
89
+ export function QuestionPrompt({ pending, suspended = false, waiting }) {
88
90
  const multi = !!pending?.multiSelect;
89
91
  const [st, setSt] = useState({ mode: "choose", buffer: "", highlight: 0, selected: multi ? [] : undefined });
90
92
  const qRef = useRef(null);
@@ -104,7 +106,7 @@ export function QuestionPrompt({ pending }) {
104
106
  pending.resolve(a.resolve, a.index);
105
107
  else if (a.state)
106
108
  setSt(a.state);
107
- }, { isActive: !!pending });
109
+ }, { isActive: !!pending && !suspended });
108
110
  // Click-to-select (hooks run every render → compute before the early return). The question can WRAP, so
109
111
  // its height is measured rather than assumed; options + the chat escape are the clickable rows (1 line
110
112
  // each). A click moves the highlight — Enter still commits — so a mis-anchored click is visibly correctable.
@@ -119,12 +121,12 @@ export function QuestionPrompt({ pending }) {
119
121
  const headerLines = 1 /* marginTop */ + 1 /* top border */ + qLines;
120
122
  useClickList({
121
123
  id: "question-list",
122
- active: !!pending && st.mode === "choose",
124
+ active: !!pending && !suspended && st.mode === "choose",
123
125
  headerLines, rowHeight: 1, windowStart: 0, visibleCount: optCount,
124
126
  onPick: (idx) => setSt((s) => ({ ...s, mode: "choose", highlight: idx })),
125
127
  });
126
128
  if (!pending)
127
129
  return null;
128
130
  const chatIndex = pending.options.length; // 0-based highlight index for the chat escape
129
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Box, { ref: qRef, children: _jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }) }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsx(Text, { color: "cyan", children: multi ? (st.selected?.includes(i) ? "[x]" : "[ ]") : `[${i + 1}]` }), " ", _jsx(Text, { bold: st.mode === "choose" && st.highlight === i, children: o })] }, i))), _jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === chatIndex ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", chatIndex + 1, "]"] }), " ", _jsx(Text, { color: "magenta", bold: st.mode === "choose" && st.highlight === chatIndex, children: CHAT_LABEL })] }), st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : multi ? (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Space (or 1-", chatIndex, ") to toggle · Enter to confirm · ", chatIndex + 1, " to type your own · Esc to close"] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump · Esc to close"] }))] }));
131
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Box, { ref: qRef, children: _jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }) }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsx(Text, { color: "cyan", children: multi ? (st.selected?.includes(i) ? "[x]" : "[ ]") : `[${i + 1}]` }), " ", _jsx(Text, { bold: st.mode === "choose" && st.highlight === i, children: o })] }, i))), _jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === chatIndex ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", chatIndex + 1, "]"] }), " ", _jsx(Text, { color: "magenta", bold: st.mode === "choose" && st.highlight === chatIndex, children: CHAT_LABEL })] }), suspended ? (_jsx(Text, { dimColor: true, children: " waiting · " + (waiting ?? "another prompt has the keyboard") })) : st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : multi ? (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Space (or 1-", chatIndex, ") to toggle · Enter to confirm · ", chatIndex + 1, " to type your own · Esc to close"] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump · Esc to close"] }))] }));
130
132
  }
@@ -15,9 +15,14 @@ const TERMINAL_REPORT = /\x1b?\[<\d+;\d+;\d+[Mm]|\x1b?\[\d+;\d+R/g;
15
15
  const NOT_KEY = /[\s\x00-\x1f\x7f]/g;
16
16
  // Mask cells drawn at most: a 100+ character key stays on one line of an 80-column box; the count says the rest.
17
17
  export const MASK_MAX = 32;
18
+ /** One input chunk without what the terminal wrapped around it or sent of its own (paste markers, mouse and cursor
19
+ * reports) — the text the owner typed or pasted. */
20
+ export function typedText(input) {
21
+ return input.replace(PASTE_MARKER, "").replace(TERMINAL_REPORT, "");
22
+ }
18
23
  /** The characters of one input chunk that belong to the key. */
19
24
  export function secretChars(input) {
20
- return input.replace(PASTE_MARKER, "").replace(TERMINAL_REPORT, "").replace(NOT_KEY, "");
25
+ return typedText(input).replace(NOT_KEY, "");
21
26
  }
22
27
  /** Pure keystroke reducer (no React, no I/O), like questionKey: the next value, the value to store (Enter), or a cancel
23
28
  * (Esc / ctrl+c). ctrl+u clears; Enter on an empty value does nothing. */
@@ -39,7 +44,7 @@ export function secretKey(value, input, key) {
39
44
  export function maskFor(length) {
40
45
  return "•".repeat(Math.min(length, MASK_MAX));
41
46
  }
42
- export function SecretPrompt({ pending }) {
47
+ export function SecretPrompt({ pending, suspended = false }) {
43
48
  // A ref, not state: a paste can land as several chunks (with Enter right behind them) before React re-renders, and
44
49
  // each must extend what the last one typed. `size` is all the render ever sees.
45
50
  const valueRef = useRef("");
@@ -70,7 +75,7 @@ export function SecretPrompt({ pending }) {
70
75
  valueRef.current = a.value;
71
76
  setSize(a.value.length);
72
77
  }
73
- }, { isActive: !!pending });
78
+ }, { isActive: !!pending && !suspended });
74
79
  if (!pending)
75
80
  return null;
76
81
  return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.title })] }), _jsxs(Text, { children: [" ", _jsx(Text, { color: "magenta", children: "› " }), maskFor(size), _jsx(Text, { color: "cyan", children: "\u258C" }), size ? _jsx(Text, { dimColor: true, children: ` ${size} characters` }) : null] }), _jsx(Text, { dimColor: true, children: " Enter to store · Esc to cancel · ctrl+u to clear — the key is never shown or logged" })] }));
@@ -49,7 +49,7 @@ function windowFor(n, hi) {
49
49
  const start = Math.max(0, Math.min(hi - Math.floor(VISIBLE / 2), n - VISIBLE));
50
50
  return { start, end: start + VISIBLE };
51
51
  }
52
- export function SessionPicker({ pending }) {
52
+ export function SessionPicker({ pending, suspended = false }) {
53
53
  const [st, setSt] = useState({ scope: "all", query: "", highlight: 0 });
54
54
  const wasOpen = useRef(false);
55
55
  useEffect(() => {
@@ -74,7 +74,7 @@ export function SessionPicker({ pending }) {
74
74
  }
75
75
  else if (a.intent)
76
76
  pending.onIntent(a.intent);
77
- }, { isActive: !!pending });
77
+ }, { isActive: !!pending && !suspended });
78
78
  if (!pending)
79
79
  return null;
80
80
  const { loading, error, note } = pending;