@0perator/operator 0.1.284 → 0.1.313

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 (99) hide show
  1. package/README.md +24 -2
  2. package/dist/acp/agent.js +3 -2
  3. package/dist/acp/config-options.js +15 -1
  4. package/dist/acp/tool-map.js +2 -1
  5. package/dist/auth/commands.js +69 -13
  6. package/dist/autonomy/agent-cli.js +304 -0
  7. package/dist/autonomy/cloud-agent.js +439 -0
  8. package/dist/autonomy/cron-lifecycle.js +78 -0
  9. package/dist/autonomy/cron-lock.js +121 -0
  10. package/dist/autonomy/cron.js +216 -43
  11. package/dist/autonomy/delegate.js +5 -1
  12. package/dist/autonomy/incidents.js +135 -0
  13. package/dist/autonomy/session-factory.js +25 -16
  14. package/dist/background/index.js +40 -0
  15. package/dist/bus/inbox.js +20 -0
  16. package/dist/classifier/config.js +47 -0
  17. package/dist/classifier/modes.js +41 -0
  18. package/dist/classifier/types.js +1 -0
  19. package/dist/cli.js +529 -53
  20. package/dist/config/features.js +69 -0
  21. package/dist/config/persona.js +118 -99
  22. package/dist/config/scaffold.js +15 -0
  23. package/dist/config/settings.js +96 -6
  24. package/dist/consolidation/sleep.js +73 -11
  25. package/dist/engine/agent.js +275 -18
  26. package/dist/engine/anthropic-chat.js +343 -0
  27. package/dist/engine/aurora.js +101 -13
  28. package/dist/engine/batch-scheduler.js +41 -9
  29. package/dist/engine/classifier.js +85 -0
  30. package/dist/engine/compaction.js +24 -5
  31. package/dist/engine/fast-start.js +25 -0
  32. package/dist/engine/loop-guard.js +448 -0
  33. package/dist/engine/moa.js +5 -1
  34. package/dist/engine/net-error.js +24 -0
  35. package/dist/engine/repetition-guard.js +180 -0
  36. package/dist/engine/selfheal.js +8 -0
  37. package/dist/engine/toolcalls.js +51 -1
  38. package/dist/engine/verify-gate.js +2 -0
  39. package/dist/flywheel/processor.js +78 -31
  40. package/dist/flywheel/srft.js +13 -0
  41. package/dist/hooks/index.js +196 -0
  42. package/dist/mcp/config.js +21 -1
  43. package/dist/memory/index.js +0 -0
  44. package/dist/memory/providers.js +210 -0
  45. package/dist/memory/session-catalog.js +422 -0
  46. package/dist/memory/session-providers.js +121 -0
  47. package/dist/memory/session-sources.js +335 -0
  48. package/dist/memory/skylark.js +131 -0
  49. package/dist/models/bench.js +103 -0
  50. package/dist/models/registry.js +144 -0
  51. package/dist/models/switch.js +69 -0
  52. package/dist/observability/blackbox.js +37 -0
  53. package/dist/permissions/policy.js +31 -6
  54. package/dist/router/discovery.js +127 -0
  55. package/dist/router/models.js +117 -24
  56. package/dist/router/portal.js +100 -0
  57. package/dist/router/router.js +1 -1
  58. package/dist/services/preflight.js +55 -7
  59. package/dist/session.js +316 -46
  60. package/dist/tools/chauffeur.js +12 -0
  61. package/dist/tools/executor.js +19 -9
  62. package/dist/tools/find-files.js +483 -0
  63. package/dist/tools/git-pr.js +94 -0
  64. package/dist/tools/incident-tools.js +82 -0
  65. package/dist/tools/memory.js +12 -2
  66. package/dist/tools/registry.js +281 -85
  67. package/dist/tools/semantic-compress.js +124 -0
  68. package/dist/tools/shell-context.js +1 -0
  69. package/dist/tools/shell-jobs.js +160 -0
  70. package/dist/tools/shell-session.js +170 -4
  71. package/dist/tools/wave-tools.js +609 -0
  72. package/dist/tools/wave2-tools.js +411 -0
  73. package/dist/ui/App.js +15 -4
  74. package/dist/ui/BgPanel.js +30 -6
  75. package/dist/ui/Composer.js +11 -1
  76. package/dist/ui/QuestionPrompt.js +31 -11
  77. package/dist/ui/SessionPicker.js +86 -0
  78. package/dist/ui/StatusRule.js +5 -5
  79. package/dist/ui/ToolStep.js +2 -1
  80. package/dist/ui/Transcript.js +17 -1
  81. package/dist/ui/index.js +1 -1
  82. package/dist/ui/liveTools.js +21 -3
  83. package/dist/ui/slashCommands.js +2 -0
  84. package/dist/util/screenshots.js +74 -8
  85. package/dist/util/slash.js +2 -2
  86. package/package.json +8 -2
  87. package/dist/engine/cli.js +0 -1171
  88. package/dist/router/models.js.bak +0 -78
  89. package/dist/router/models.js.bak-1791259923 +0 -78
  90. package/dist/router/models.js.bak-pre-gateway +0 -78
  91. package/dist/router/models.js.bak-pre-patch2 +0 -78
  92. package/dist/router/models.js.bak2 +0 -78
  93. package/dist/services/model-autodetect.js +0 -240
  94. package/dist/tools/native-redirect.js +0 -140
  95. package/dist/tools/power-tools.js +0 -627
  96. package/dist/tools/registry.js.bak-1791259948 +0 -1914
  97. package/dist/tools/registry.js.bak-pre-plugins +0 -1914
  98. package/dist/ui/BusTray.js +0 -70
  99. package/dist/ui/resize.js +0 -160
@@ -14,14 +14,20 @@ export const CHAT_LABEL = "Chat about it — type your own reply";
14
14
  // Returned to the model when the owner opens the chat line but sends it empty: a clear signal to stop
15
15
  // offering a menu and discuss, rather than a blank answer.
16
16
  export const DISCUSS = "Let's talk it through — I don't want to pick one of the listed options; discuss it with me.";
17
+ // Joins the chosen options for the model when multi-select confirms a set — a stable, readable delimiter.
18
+ export const MULTI_JOIN = "; ";
19
+ // Flip option index `i` in/out of the (sorted) selection set — the Space/digit toggle in multi mode.
20
+ const toggleSelected = (sel, i) => sel.includes(i) ? sel.filter((x) => x !== i) : [...sel, i].sort((a, b) => a - b);
17
21
  // Pure keystroke reducer (no React, no I/O) so the whole selection + free-text behavior is testable without
18
- // a TTY. Returns either the next state, or a `resolve` string = the answer to hand back to the model.
19
- export function questionKey(st, input, key, options) {
22
+ // a TTY. Returns either the next state, or a `resolve` string = the answer to hand back to the model. In
23
+ // multi-select mode Space (or a digit) toggles an option and Enter confirms the whole SET (joined); single
24
+ // mode is unchanged — a digit or Enter resolves immediately. The chat escape works identically in both.
25
+ export function questionKey(st, input, key, options, multiSelect = false) {
20
26
  if (st.mode === "type") {
21
27
  if (key.return)
22
28
  return { resolve: st.buffer.trim() || DISCUSS };
23
29
  if (key.escape)
24
- return { state: { mode: "choose", buffer: "", highlight: st.highlight } }; // back to the menu
30
+ return { state: { mode: "choose", buffer: "", highlight: st.highlight, selected: st.selected } }; // back to the menu
25
31
  if (key.backspace || key.delete)
26
32
  return { state: { ...st, buffer: st.buffer.slice(0, -1) } };
27
33
  if (input && !key.ctrl && !key.meta)
@@ -30,6 +36,7 @@ export function questionKey(st, input, key, options) {
30
36
  }
31
37
  if (key.ctrl && input.toLowerCase() === "c")
32
38
  return { resolve: DISCUSS }; // bail = discuss, NEVER a silently-picked real answer
39
+ const chatIndex = options.length; // 0-based index of the chat escape
33
40
  const total = options.length + 1; // options + chat escape
34
41
  if (key.upArrow) {
35
42
  const next = st.highlight <= 0 ? total - 1 : st.highlight - 1;
@@ -39,28 +46,41 @@ export function questionKey(st, input, key, options) {
39
46
  const next = st.highlight >= total - 1 ? 0 : st.highlight + 1;
40
47
  return { state: { ...st, highlight: next } };
41
48
  }
49
+ // Multi-select: Space toggles the highlighted option (never the chat escape) without committing.
50
+ if (multiSelect && input === " " && st.highlight < options.length) {
51
+ return { state: { ...st, selected: toggleSelected(st.selected ?? [], st.highlight) } };
52
+ }
42
53
  if (key.return) {
43
- const chatIndex = options.length; // 0-based
44
54
  if (st.highlight === chatIndex)
45
- return { state: { mode: "type", buffer: "", highlight: st.highlight } };
55
+ return { state: { mode: "type", buffer: "", highlight: st.highlight, selected: st.selected } };
56
+ if (multiSelect) {
57
+ // Confirm the SET. Nothing toggled yet ⇒ treat Enter on the highlighted row as picking just that one,
58
+ // so Enter is never a dead key.
59
+ const sel = (st.selected && st.selected.length ? st.selected : [st.highlight]).slice().sort((a, b) => a - b);
60
+ return { resolve: sel.map((i) => options[i]).join(MULTI_JOIN) };
61
+ }
46
62
  return { resolve: options[st.highlight] };
47
63
  }
48
64
  const n = Number(input);
49
- if (Number.isInteger(n) && n >= 1 && n <= options.length)
65
+ if (Number.isInteger(n) && n >= 1 && n <= options.length) {
66
+ if (multiSelect)
67
+ return { state: { ...st, highlight: n - 1, selected: toggleSelected(st.selected ?? [], n - 1) } }; // digit toggles, doesn't commit
50
68
  return { resolve: options[n - 1] };
69
+ }
51
70
  if (n === options.length + 1)
52
- return { state: { mode: "type", buffer: "", highlight: options.length } }; // open the free-text line
71
+ return { state: { mode: "type", buffer: "", highlight: options.length, selected: st.selected } }; // open the free-text line
53
72
  return {};
54
73
  }
55
74
  export function QuestionPrompt({ pending }) {
56
- const [st, setSt] = useState({ mode: "choose", buffer: "", highlight: 0 });
75
+ const multi = !!pending?.multiSelect;
76
+ const [st, setSt] = useState({ mode: "choose", buffer: "", highlight: 0, selected: multi ? [] : undefined });
57
77
  const qRef = useRef(null);
58
78
  const [qLines, setQLines] = useState(1); // measured height of the (possibly wrapping) question line
59
- useEffect(() => { setSt({ mode: "choose", buffer: "", highlight: 0 }); }, [pending]); // reset for each new question
79
+ useEffect(() => { setSt({ mode: "choose", buffer: "", highlight: 0, selected: pending?.multiSelect ? [] : undefined }); }, [pending]); // reset for each new question
60
80
  useInput((input, key) => {
61
81
  if (!pending)
62
82
  return;
63
- const a = questionKey(st, input, key, pending.options);
83
+ const a = questionKey(st, input, key, pending.options, pending.multiSelect);
64
84
  if (a.resolve !== undefined)
65
85
  pending.resolve(a.resolve);
66
86
  else if (a.state)
@@ -87,5 +107,5 @@ export function QuestionPrompt({ pending }) {
87
107
  if (!pending)
88
108
  return null;
89
109
  const chatIndex = pending.options.length; // 0-based highlight index for the chat escape
90
- 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: " " }), _jsxs(Text, { color: "cyan", children: ["[", 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" })] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump"] }))] }));
110
+ 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"] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump"] }))] }));
91
111
  }
@@ -0,0 +1,86 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ // The /sessions browser: search Operator's and other agents' sessions on this machine (providers configured
3
+ // in agents.md — memory/session-catalog.ts) by what was said in it, then pick one up. Same shape as ArtifactPicker — a
4
+ // pure keystroke reducer (testable without a TTY) + useInput gated while the picker is up, drawn as a
5
+ // bordered inline box above the composer. The search box is always live: typing filters, Tab cycles the
6
+ // scope (Workspace = this folder, Project = this git repo, All), ↑/↓ move, Enter opens, Esc clears the
7
+ // query and then closes.
8
+ import { useEffect, useRef, useState } from "react";
9
+ import { Box, Text, useInput } from "ink";
10
+ import { SESSION_SCOPES, metaLine, roleLabel } from "../memory/session-catalog.js";
11
+ const VISIBLE = 5; // sessions on screen (3 lines each); the list scrolls within it
12
+ const SCOPE_LABEL = { workspace: "Workspace", project: "Project", all: "All" };
13
+ // Pure keystroke reducer: next state and/or an intent. Any query or scope change re-runs the search.
14
+ export function sessionKey(st, input, key, n) {
15
+ const hi = Math.min(Math.max(st.highlight, 0), Math.max(0, n - 1));
16
+ if (key.escape) {
17
+ if (st.query) {
18
+ const next = { ...st, query: "", highlight: 0 };
19
+ return { state: next, intent: { kind: "query", query: "", scope: st.scope } };
20
+ }
21
+ return { intent: { kind: "close" } };
22
+ }
23
+ if (key.tab) {
24
+ const i = SESSION_SCOPES.indexOf(st.scope);
25
+ const scope = SESSION_SCOPES[(i + (key.shift ? SESSION_SCOPES.length - 1 : 1)) % SESSION_SCOPES.length];
26
+ return { state: { ...st, scope, highlight: 0 }, intent: { kind: "query", query: st.query, scope } };
27
+ }
28
+ if (key.upArrow)
29
+ return { state: { ...st, highlight: n ? (hi <= 0 ? n - 1 : hi - 1) : 0 } };
30
+ if (key.downArrow)
31
+ return { state: { ...st, highlight: n ? (hi >= n - 1 ? 0 : hi + 1) : 0 } };
32
+ if (key.return)
33
+ return n ? { intent: { kind: "open", id: "" } } : {}; // id filled in by the caller (it has the rows)
34
+ if (key.backspace || key.delete) {
35
+ if (!st.query)
36
+ return {};
37
+ const query = st.query.slice(0, -1);
38
+ return { state: { ...st, query, highlight: 0 }, intent: { kind: "query", query, scope: st.scope } };
39
+ }
40
+ if (input && !key.ctrl && !key.meta) {
41
+ const query = st.query + input;
42
+ return { state: { ...st, query, highlight: 0 }, intent: { kind: "query", query, scope: st.scope } };
43
+ }
44
+ return {};
45
+ }
46
+ function windowFor(n, hi) {
47
+ if (n <= VISIBLE)
48
+ return { start: 0, end: n };
49
+ const start = Math.max(0, Math.min(hi - Math.floor(VISIBLE / 2), n - VISIBLE));
50
+ return { start, end: start + VISIBLE };
51
+ }
52
+ export function SessionPicker({ pending }) {
53
+ const [st, setSt] = useState({ scope: "all", query: "", highlight: 0 });
54
+ const wasOpen = useRef(false);
55
+ useEffect(() => {
56
+ const open = !!pending;
57
+ if (open && !wasOpen.current)
58
+ setSt({ scope: pending.initialScope ?? "all", query: pending.initialQuery ?? "", highlight: 0 });
59
+ wasOpen.current = open;
60
+ }, [pending]);
61
+ const items = pending?.items ?? [];
62
+ const n = items.length;
63
+ const hi = Math.min(Math.max(st.highlight, 0), Math.max(0, n - 1));
64
+ useInput((input, key) => {
65
+ if (!pending)
66
+ return;
67
+ const a = sessionKey(st, input, key, n);
68
+ if (a.state)
69
+ setSt(a.state);
70
+ if (a.intent?.kind === "open") {
71
+ const row = items[hi];
72
+ if (row)
73
+ pending.onIntent({ kind: "open", id: row.id });
74
+ }
75
+ else if (a.intent)
76
+ pending.onIntent(a.intent);
77
+ }, { isActive: !!pending });
78
+ if (!pending)
79
+ return null;
80
+ const { loading, error, note } = pending;
81
+ const { start, end } = windowFor(n, hi);
82
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["◆ Agent sessions ", SESSION_SCOPES.map((sc) => (_jsxs(Text, { color: sc === st.scope ? "cyan" : undefined, bold: sc === st.scope, dimColor: sc !== st.scope, children: [sc === st.scope ? `[${SCOPE_LABEL[sc]}]` : ` ${SCOPE_LABEL[sc]} `, " "] }, sc))), _jsx(Text, { dimColor: true, children: loading ? "indexing…" : `${n} session${n === 1 ? "" : "s"} · newest first` })] }), _jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "search› " }), st.query, _jsx(Text, { color: "cyan", children: "\u258C" })] }), error ? _jsx(Text, { color: "red", children: " " + error }) : null, !loading && !error && n === 0 ? (_jsx(Text, { dimColor: true, children: st.query ? ` no session in ${SCOPE_LABEL[st.scope]} mentions "${st.query}" — Tab widens the scope` : ` no sessions in ${SCOPE_LABEL[st.scope]} yet — Tab widens the scope` })) : null, items.slice(start, end).map((it, i) => {
83
+ const sel = start + i === hi;
84
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [sel ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsx(Text, { bold: sel, children: it.title }), _jsx(Text, { dimColor: true, children: " " + metaLine(it) })] }), _jsx(Text, { dimColor: true, wrap: "truncate-end", children: " " + (it.snippet ? `${roleLabel(it.role)}${it.role ? ": " : ""}${it.snippet}` : "") }), _jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [" " + (it.cwd ?? ""), it.gone ? _jsx(Text, { color: "yellow", children: " folder gone" }) : null] })] }, it.id));
85
+ }), n > end ? _jsx(Text, { dimColor: true, children: ` ⋯ +${n - end} more` }) : null, note ? _jsx(Text, { color: "green", children: " " + note }) : null, _jsx(Text, { dimColor: true, children: " type to search · Tab scope · ↑/↓ move · Enter open · Esc clear/close" })] }));
86
+ }
@@ -51,11 +51,11 @@ export function statusRight(p, cols) {
51
51
  const think = p.thinkMode === "ultrathink" ? `✲✲ ultrathink · ` : p.thinkMode === "think" ? `✲ think · ` : "";
52
52
  const tok = p.sessionTokens && p.sessionTokens > 0 ? `Σ${fmtK(p.sessionTokens)} · ` : ""; // session token total
53
53
  // ctx as a fill ring (○◔◑◕●) + the exact % — a glance shows how full the context window is, the number keeps precision.
54
- // Display-only: show the Aurora model under an aurora-* name (operator-1m → aurora-300k) without touching
55
- // the internal model id — routing, /model, and persisted settings still key on the real id. The "-1m"
56
- // suffix renders as "-300k" because the server's real window is 300K (standardized 2026-09-27); showing
57
- // "1m" would be untruthful. Other routes (operator-128k, moa, custom) pass through unchanged.
58
- const routeLabel = p.route.replace(/^operator-/, "aurora-").replace(/-1m$/, "-300k");
54
+ // Show the real route id (operator-1m, operator-128k, moa, custom …) — the outward name IS operator-*
55
+ // (the aurora-* model is internal, never shown; see router/models.ts). The old display rewrite turned
56
+ // operator-1m into "aurora-300k", which was indistinguishable from the dead cloud profile axe-aurora-300k
57
+ // (api.axe.onl) — so the owner couldn't tell the local default from the broken remote. Route is the truth.
58
+ const routeLabel = p.route;
59
59
  let info = `${think}${plan}${seat}${who}${routeLabel} · ${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
60
60
  let right = `✷ OPERATOR · ${info} ─`;
61
61
  const maxRight = cols - 3; // leaves fill ≥ 1 and total = cols-1
@@ -5,6 +5,7 @@ import { fileLink } from "./osc.js";
5
5
  import { theme } from "./theme.js";
6
6
  import { computeEditDiff } from "./editdiff.js";
7
7
  import { useTick } from "./tick.js";
8
+ import { rowBackgroundHint } from "./liveTools.js";
8
9
  import { glyphFor, toolKind, KIND_HUE } from "./toolicons.js";
9
10
  import { renderBar, mediaEtaMs, mediaProgressFraction } from "./progressbar.js";
10
11
  import { ShimmerText, huePalette } from "./shimmer.js";
@@ -70,5 +71,5 @@ export function ToolStep({ step }) {
70
71
  // lands. Only RUNNING media rows get the bar — everything else renders exactly as before.
71
72
  const isRunningMedia = toolKind(step.name) === "media" && step.status === "running";
72
73
  const mediaFraction = isRunningMedia && elapsed != null ? mediaProgressFraction(elapsed, mediaEtaMs(step.name, step.args)) : undefined;
73
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: step.status === "running" ? KIND_HUE[toolKind(step.name)] : COLOR[step.status], bold: true, children: glyphFor(step.name, step.status, frame) }), " ", step.status === "running" ? _jsx(ShimmerText, { text: step.name, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : step.name, "(", argsPreview(step.args), ")", mediaFraction != null ? (_jsxs(Text, { children: [" ", _jsx(Text, { color: theme.mediaProgress, children: renderBar(mediaFraction) }), " ", Math.round(mediaFraction * 100), "%"] })) : null, elapsed != null ? _jsxs(Text, { dimColor: true, children: [" ", formatDuration(elapsed)] }) : null, editDiff ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.success, children: ["+", editDiff.added] }), " ", _jsxs(Text, { color: theme.error, children: ["-", editDiff.removed] })] })) : null] }), step.summary ? step.summary.split("\n").map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, `sm${i}`))) : null, editDiff?.preview?.map((l, i) => (_jsxs(Text, { color: l.kind === "add" ? theme.success : theme.error, children: [" ", l.kind === "add" ? "+ " : "- ", l.text] }, i)))] }));
74
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: step.status === "running" ? KIND_HUE[toolKind(step.name)] : COLOR[step.status], bold: true, children: glyphFor(step.name, step.status, frame) }), " ", step.status === "running" ? _jsx(ShimmerText, { text: step.name, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : step.name, "(", argsPreview(step.args), ")", mediaFraction != null ? (_jsxs(Text, { children: [" ", _jsx(Text, { color: theme.mediaProgress, children: renderBar(mediaFraction) }), " ", Math.round(mediaFraction * 100), "%"] })) : null, elapsed != null ? _jsxs(Text, { dimColor: true, children: [" ", formatDuration(elapsed)] }) : null, editDiff ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.success, children: ["+", editDiff.added] }), " ", _jsxs(Text, { color: theme.error, children: ["-", editDiff.removed] })] })) : null] }), rowBackgroundHint(step, now) ? _jsxs(Text, { dimColor: true, children: [" ", rowBackgroundHint(step, now)] }) : null, step.summary ? step.summary.split("\n").map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, `sm${i}`))) : null, editDiff?.preview?.map((l, i) => (_jsxs(Text, { color: l.kind === "add" ? theme.success : theme.error, children: [" ", l.kind === "add" ? "+ " : "- ", l.text] }, i)))] }));
74
75
  }
@@ -1,4 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Scrollback (SPEC §6). Settled entries render via Ink's <Static> — written once to stdout and
3
+ // never re-diffed, which is what actually makes the prompt-echo/scroll/overwrite bug class
4
+ // (endemic to the ANSI-cursor Python core) impossible here: new lines only ever get appended
5
+ // below, terminal scrollback is never touched again. Only the in-flight entry re-renders live.
6
+ import React from "react";
2
7
  import { Box, Static, Text } from "ink";
3
8
  import { ToolStep } from "./ToolStep.js";
4
9
  import { Markdown } from "./Markdown.js";
@@ -144,6 +149,16 @@ function renderEntry(entry, live = false) {
144
149
  }
145
150
  return _jsx(ToolStep, { step: entry.step });
146
151
  }
152
+ // One settled transcript row, MEMOIZED. In fullscreen there is no <Static>, so every App re-render (a
153
+ // sub-agent token tick, the ~15fps live stream, a spinner-driven parent render) otherwise re-runs renderEntry
154
+ // for the WHOLE visible window and Ink repaints all of it — the full-frame flash. Settled entries are
155
+ // immutable (append-only; their object reference never changes), so React.memo on the entry reference lets the
156
+ // reconciler skip every unchanged row and Ink repaints only what actually changed (the live line + glyph).
157
+ // `cols` is a deliberate second key so a terminal RESIZE still re-wraps settled rows (BusCard wraps to width),
158
+ // while a same-width tick does not — it is read inside renderEntry via termCols(), passed here only to bust the memo.
159
+ const TranscriptRow = React.memo(function TranscriptRow({ entry }) {
160
+ return _jsx(Box, { children: renderEntry(entry) });
161
+ });
147
162
  export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
148
163
  if (bounded) {
149
164
  // Fullscreen: no <Static>; render a wheel-scrollable window as a plain column the parent clips +
@@ -151,7 +166,8 @@ export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
151
166
  // history; at 0 it's the newest `BOUNDED_TAIL` entries with the live stream pinned below.
152
167
  const { start, end, olderOff, newerOff } = boundedWindow(entries.length, scrollBack);
153
168
  const tail = entries.slice(start, end);
154
- return (_jsxs(Box, { flexDirection: "column", children: [olderOff > 0 ? (_jsx(Text, { dimColor: true, children: `⋯ ${olderOff} earlier line(s) scrolled off` })) : null, tail.map((entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry))), newerOff > 0
169
+ const cols = termCols(); // memo key: a resize re-wraps settled rows, a per-tick re-render does not
170
+ return (_jsxs(Box, { flexDirection: "column", children: [olderOff > 0 ? (_jsx(Text, { dimColor: true, children: `⋯ ${olderOff} earlier line(s) scrolled off` })) : null, tail.map((entry) => _jsx(TranscriptRow, { entry: entry, cols: cols }, entryKey(entry))), newerOff > 0
155
171
  ? _jsx(Text, { dimColor: true, children: `⋯ ${newerOff} newer line(s) below — scroll down (new output jumps here)` })
156
172
  : (live ? _jsx(Box, { children: renderEntry(live, true) }) : null)] }));
157
173
  }
package/dist/ui/index.js CHANGED
@@ -8,4 +8,4 @@ export { ToolStep } from "./ToolStep.js";
8
8
  export { BgPanel } from "./BgPanel.js";
9
9
  export * from "./types.js";
10
10
  export { formatDuration, isErrorResult } from "./format.js";
11
- export { seedLiveTools, settleLiveTool } from "./liveTools.js";
11
+ export { seedLiveTools, settleLiveTool, backgroundHint } from "./liveTools.js";
@@ -1,8 +1,7 @@
1
1
  import { isErrorResult, resultPreview } from "./format.js";
2
2
  /** Seed one live row per call, all "running" from the same instant — the batch was just dispatched
3
- * together, so that's the honest starting state even though safe calls run concurrently and mutating
4
- * ones run sequentially (the UI can't see that split; each row's own elapsed timer still ticks
5
- * correctly once ToolStep renders it, per-row, independent of the others). */
3
+ * together. Reads and independent bash/shell_exec overlap; conflicting writes and device barriers
4
+ * still serialize (BTX). Each row's own elapsed timer ticks per-row once ToolStep renders it. */
6
5
  export function seedLiveTools(calls, now = Date.now()) {
7
6
  return calls.map((c) => ({ id: c.id, name: c.name, args: c.args, status: "running", startedAt: now }));
8
7
  }
@@ -19,3 +18,22 @@ export function settleLiveTool(rows, id, result, now = Date.now()) {
19
18
  });
20
19
  return changed ? next : rows;
21
20
  }
21
+ const SHELL_TOOLS = new Set(["bash", "shell_exec"]);
22
+ export const BACKGROUND_HINT_AFTER_MS = 2000;
23
+ /** Inline per-row variant of the hint, under the running command itself (Claude Code parity). */
24
+ export function rowBackgroundHint(step, now = Date.now(), inTmux = !!process.env.TMUX) {
25
+ if (!SHELL_TOOLS.has(step.name) || step.status !== "running")
26
+ return null;
27
+ if (now - (step.startedAt ?? now) <= BACKGROUND_HINT_AFTER_MS)
28
+ return null;
29
+ return inTmux ? "(ctrl+b ctrl+b or ctrl+z to run in background)" : "(ctrl+b to run in background)";
30
+ }
31
+ /** The muted hint shown once a shell command has run a while: how to move it to the background. Null while no
32
+ * shell command has run past the threshold. Inside tmux ctrl+b is the prefix key, so the first press is
33
+ * swallowed by tmux: say "twice", and name the alias key that has no such clash. */
34
+ export function backgroundHint(rows, now = Date.now(), inTmux = !!process.env.TMUX) {
35
+ const slow = rows.some((r) => SHELL_TOOLS.has(r.name) && r.status === "running" && now - (r.startedAt ?? now) > BACKGROUND_HINT_AFTER_MS);
36
+ if (!slow)
37
+ return null;
38
+ return inTmux ? "ctrl+b ctrl+b (tmux) or ctrl+z to run in the background" : "ctrl+b to run in the background";
39
+ }
@@ -19,11 +19,13 @@ export const SLASH_COMMANDS = [
19
19
  { name: "ultrathink", description: "toggle deep, exhaustive reasoning for hard problems" },
20
20
  { name: "agents", description: "detailed sub-agent status: running/queued/done/errored + metrics" },
21
21
  { name: "bg", description: "spawn a background sub-agent, list, or stop one", args: "<task|stop id>" },
22
+ { name: "jobs", description: "background shell jobs: list, or stop one (ctrl+b moves a running command here)", args: "[stop id]" },
22
23
  { name: "monitor", description: "toggle the live event stream (tool decisions, turns, control)" },
23
24
  { name: "audit", description: "recent tool + control-plane events from the audit trail", args: "[n]" },
24
25
  { name: "stats", description: "session dashboard: turns · tools · tokens · throughput · context fill" },
25
26
  { name: "dashboard", description: "launch the live swarm console (watches every Operator session)" },
26
27
  { name: "artifacts", description: "browse + attach your Compose artifacts: search · attach · copy url · delete" },
28
+ { name: "sessions", description: "search Operator's and other agents' sessions (providers in agents.md) and pick one up", args: "[query]" },
27
29
  { name: "remember", description: "store a note to recall in future sessions", args: "<note>" },
28
30
  { name: "memory", description: "show remembered notes (all, or matching a query)", args: "[query]" },
29
31
  { name: "compact", description: "force-compact the conversation now" },
@@ -7,16 +7,79 @@
7
7
  // file twice). So we copy any such ephemeral image to a durable attachments dir at INPUT time
8
8
  // and rewrite the reference to the copy. Local paths (Desktop/Downloads) are stable and pass
9
9
  // through untouched. Pure, synchronous, model-agnostic input preprocessing -- the same seam and
10
- // shape as expandFileMentions, run on the user's text before it reaches the model.
11
- import { statSync, copyFileSync, mkdirSync } from "node:fs";
10
+ // shape as expandFileMentions, run on the user's text before it reaches the model. The durable
11
+ // copies are themselves swept on a retention policy (sweepAttachments, below) so the attachments
12
+ // dir doesn't grow forever.
13
+ import { statSync, copyFileSync, mkdirSync, readdirSync, rmSync, readFileSync } from "node:fs";
14
+ import { createHash } from "node:crypto";
15
+ import { join } from "node:path";
12
16
  import { operatorPath } from "../config/home.js";
17
+ // Retention sweep for the attachments dir -- mirrors tool-output-spill.ts's sweepToolOutputs (the
18
+ // established pattern in this codebase for a cache dir that otherwise grows forever). Every snapshotted
19
+ // screenshot gets a unique name and nothing ever deleted it, so the dir accumulated multi-MB PNGs
20
+ // indefinitely with no bound. Age out first, then cap total bytes, oldest-first.
21
+ const ATTACHMENT_RETENTION_MS = 7 * 24 * 3600_000; // a week -- long enough to re-check a recent analysis
22
+ const ATTACHMENT_MAX_DIR_BYTES = 250 * 1024 * 1024; // hard ceiling (250MB) on the attachments dir
23
+ const ATTACHMENT_SWEEP_INTERVAL_MS = 3600_000; // at most once per hour, from snapshotEphemeralImages
24
+ let _lastAttachmentSweep = 0;
25
+ /** Best-effort retention sweep for operatorPath("attachments"): age out >ATTACHMENT_RETENTION_MS files,
26
+ * then cap the dir at ATTACHMENT_MAX_DIR_BYTES oldest-first. force:true bypasses the hourly throttle
27
+ * (tests / an explicit "clean it now"). Never throws -- attachments are copies of already-ephemeral
28
+ * originals, so a failed sweep just leaves the cache a bit fuller, never loses anything unrecoverable. */
29
+ export function sweepAttachments(dir = operatorPath("attachments"), opts = {}) {
30
+ const now = Date.now();
31
+ if (!opts.force && now - _lastAttachmentSweep < ATTACHMENT_SWEEP_INTERVAL_MS)
32
+ return;
33
+ _lastAttachmentSweep = now;
34
+ let entries;
35
+ try {
36
+ entries = readdirSync(dir)
37
+ .filter((f) => f.startsWith("shot-"))
38
+ .map((f) => {
39
+ try {
40
+ const st = statSync(join(dir, f));
41
+ return { f, mtime: st.mtimeMs, size: st.size };
42
+ }
43
+ catch {
44
+ return null;
45
+ }
46
+ })
47
+ .filter((x) => !!x);
48
+ }
49
+ catch {
50
+ return;
51
+ } // dir missing = nothing to sweep
52
+ for (const e of entries) {
53
+ if (now - e.mtime > ATTACHMENT_RETENTION_MS) {
54
+ try {
55
+ rmSync(join(dir, e.f));
56
+ }
57
+ catch { /* raced; fine */ }
58
+ }
59
+ }
60
+ const alive = entries.filter((e) => now - e.mtime <= ATTACHMENT_RETENTION_MS);
61
+ let total = alive.reduce((n, e) => n + e.size, 0);
62
+ if (total > ATTACHMENT_MAX_DIR_BYTES) {
63
+ for (const e of [...alive].sort((a, b) => a.mtime - b.mtime)) {
64
+ if (total <= ATTACHMENT_MAX_DIR_BYTES)
65
+ break;
66
+ try {
67
+ rmSync(join(dir, e.f));
68
+ total -= e.size;
69
+ }
70
+ catch { /* skip */ }
71
+ }
72
+ }
73
+ }
13
74
  // A path under the macOS per-user temp root (/var/folders, optionally /private-prefixed) or /tmp,
14
- // ending in an image extension. "\\ " matches a shell-escaped space so a dragged screenshot's
15
- // spaced filename ("Screenshot 2026-10-11 at 9.00.10 PM.png") is captured whole; "\S" covers the
16
- // rest. Lazy so it stops at the first image extension and never spans two paths.
17
- const EPHEMERAL_IMG_RE = /(?:\/private)?\/(?:var\/folders|tmp)\/(?:\\ |\S)+?\.(?:png|jpe?g|gif|webp|bmp|heic|heif|tiff?)/gi;
75
+ // ending in an image extension. Directory segments never contain a real space, so they're matched
76
+ // as shell-escaped-space-or-non-slash runs; the FINAL (filename) segment is matched separately and
77
+ // allows literal spaces too -- a dragged screenshot's name ("Screenshot 2026-10-11 at 9.00.10 PM.png")
78
+ // reaches this regex with real, unescaped spaces as often as shell-escaped ones, depending on how the
79
+ // path was typed/pasted/quoted into the TUI (not always a shell). Excluding quotes/newlines from the
80
+ // filename segment keeps the lazy match from swallowing a wrapping quote or spanning two paths.
81
+ const EPHEMERAL_IMG_RE = /(?:\/private)?\/(?:var\/folders|tmp)\/(?:\\ |[^\s/])+(?:\/(?:\\ |[^\s/])+)*\/[^\n"']+?\.(?:png|jpe?g|gif|webp|bmp|heic|heif|tiff?)/gi;
18
82
  const MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;
19
- let seq = 0;
20
83
  // Replace every ephemeral screenshot/image path in `text` that still exists on disk with a durable
21
84
  // copy under the operator home's attachments dir. Anything that cannot be snapshotted (already
22
85
  // deleted, unreadable, too large) is left exactly as written -- the tool then surfaces its own
@@ -34,7 +97,10 @@ export function snapshotEphemeralImages(text) {
34
97
  return match;
35
98
  const ext = (real.split(".").pop() || "png").toLowerCase();
36
99
  mkdirSync(operatorPath("attachments"), { recursive: true, mode: 0o700 });
37
- const dest = operatorPath("attachments", "shot-" + Date.now() + "-" + seq++ + "." + ext);
100
+ sweepAttachments();
101
+ const bytes = readFileSync(real);
102
+ const hash = createHash("sha1").update(bytes).digest("hex").slice(0, 12);
103
+ const dest = operatorPath("attachments", "shot-" + hash + "." + ext);
38
104
  copyFileSync(real, dest);
39
105
  changed = true;
40
106
  return dest; // clean, space-free path -- no downstream escaping needed
@@ -3,9 +3,9 @@
3
3
  // a slash command — it goes to the model as user input.
4
4
  const KNOWN = new Set([
5
5
  "help", "model", "route", "endpoints", "services", "audit", "dashboard", "plan", "mode",
6
- "think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "monitor",
6
+ "think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "jobs", "monitor",
7
7
  "bg", "new", "clear", "exit", "quit", "stats", "login", "logout", "remote", "remotecontrol", "rc",
8
- "artifacts", "skills", "deep-research", "deepresearch", "research", "pair",
8
+ "artifacts", "sessions", "skills", "deep-research", "deepresearch", "research", "pair",
9
9
  ]);
10
10
  export function isSlashCommand(text) {
11
11
  const t = text.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.284",
3
+ "version": "0.1.313",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "operator": "dist/cli.js",
@@ -22,7 +22,9 @@
22
22
  "lint": "biome check src test",
23
23
  "test": "tsx test/run.mts",
24
24
  "test:watch": "tsx watch test/run.mts",
25
- "prepublishOnly": "npm run build && npm test"
25
+ "prepublishOnly": "npm run build && npm test",
26
+ "test:shell-parallel": "npx tsx scripts/e2e-shell-parallel.ts",
27
+ "test:shell-parallel:live": "npx tsx scripts/e2e-shell-parallel.ts --live"
26
28
  },
27
29
  "dependencies": {
28
30
  "@zed-industries/agent-client-protocol": "^0.4.5",
@@ -59,5 +61,9 @@
59
61
  "publishConfig": {
60
62
  "access": "restricted",
61
63
  "registry": "https://registry.npmjs.org/"
64
+ },
65
+ "allowScripts": {
66
+ "esbuild@0.28.2": true,
67
+ "fsevents@2.3.3": true
62
68
  }
63
69
  }