@0perator/operator 0.1.360-next.2 → 0.2.1

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 (104) hide show
  1. package/README.md +5 -4
  2. package/dist/auth/commands.js +7 -3
  3. package/dist/auth/identity.js +1 -0
  4. package/dist/auth/staff.js +55 -0
  5. package/dist/autonomy/delegate-mode.js +159 -0
  6. package/dist/autonomy/delegate.js +42 -15
  7. package/dist/autonomy/headless.js +7 -4
  8. package/dist/autonomy/index.js +2 -4
  9. package/dist/autonomy/session-factory.js +13 -12
  10. package/dist/autonomy/subagent-model.js +17 -7
  11. package/dist/background/capacity.js +136 -0
  12. package/dist/background/evidence.js +42 -0
  13. package/dist/background/index.js +336 -45
  14. package/dist/background/lane-phase.js +60 -0
  15. package/dist/background/lane-summary.js +151 -0
  16. package/dist/background/notices.js +12 -3
  17. package/dist/background/resume.js +125 -0
  18. package/dist/background/synthesis.js +25 -0
  19. package/dist/browser/engine.js +163 -0
  20. package/dist/browser/session.js +130 -140
  21. package/dist/bus/inbox.js +150 -6
  22. package/dist/cli.js +343 -86
  23. package/dist/config/features.js +3 -3
  24. package/dist/config/persona.js +29 -3
  25. package/dist/config/settings.js +262 -21
  26. package/dist/config/staff-prompt.js +12 -0
  27. package/dist/engine/agent.js +52 -41
  28. package/dist/engine/aurora.js +40 -8
  29. package/dist/engine/batch-scheduler.js +4 -13
  30. package/dist/engine/compaction.js +2 -2
  31. package/dist/engine/continuation.js +30 -32
  32. package/dist/engine/decision-points.js +2 -3
  33. package/dist/engine/fanout.js +16 -0
  34. package/dist/engine/loop-guard.js +26 -83
  35. package/dist/engine/messages.js +2 -2
  36. package/dist/engine/moa.js +18 -2
  37. package/dist/engine/native-vision-node.js +72 -0
  38. package/dist/engine/native-vision.js +103 -0
  39. package/dist/engine/selfheal.js +1 -1
  40. package/dist/engine/toolcalls.js +6 -6
  41. package/dist/engine/verify-gate.js +37 -7
  42. package/dist/gateway-cli.js +14 -3
  43. package/dist/index.js +3 -0
  44. package/dist/mcp/phone-server.js +30 -0
  45. package/dist/memory/live-progress.js +4 -5
  46. package/dist/moa/codeact-lane.js +98 -0
  47. package/dist/moa/codeact-sandbox.js +409 -0
  48. package/dist/moa/codeact.js +140 -0
  49. package/dist/permissions/artifact-visibility.js +10 -0
  50. package/dist/permissions/index.js +33 -17
  51. package/dist/permissions/signature.js +5 -0
  52. package/dist/permissions/tier.js +4 -2
  53. package/dist/phone-cli.js +65 -0
  54. package/dist/products/craft.js +2 -2
  55. package/dist/remote/grants.js +119 -0
  56. package/dist/remote/host.js +63 -6
  57. package/dist/router/models.js +29 -29
  58. package/dist/selfimprove/index.js +9 -7
  59. package/dist/services/preflight.js +35 -91
  60. package/dist/session.js +173 -46
  61. package/dist/skills/install-guard.js +68 -0
  62. package/dist/skills/install.js +67 -0
  63. package/dist/toolchain/manifest.json +13 -13
  64. package/dist/tools/background-result.js +1 -1
  65. package/dist/tools/classes.js +103 -0
  66. package/dist/tools/contract.js +1 -1
  67. package/dist/tools/craft.js +13 -2
  68. package/dist/tools/deferred.js +1 -0
  69. package/dist/tools/device/android.js +227 -0
  70. package/dist/tools/device/classify.js +127 -0
  71. package/dist/tools/device/deps.js +69 -0
  72. package/dist/tools/device/desktop.js +82 -0
  73. package/dist/tools/device/harness.js +262 -0
  74. package/dist/tools/device/iphone.js +206 -0
  75. package/dist/tools/device/mirroring-jxa.js +146 -0
  76. package/dist/tools/device/setup.js +90 -0
  77. package/dist/tools/device/tools.js +70 -0
  78. package/dist/tools/device/types.js +19 -0
  79. package/dist/tools/executor.js +25 -15
  80. package/dist/tools/generation-gateway.js +94 -0
  81. package/dist/tools/registry.js +95 -155
  82. package/dist/ui/App.js +18 -6
  83. package/dist/ui/ApprovalPrompt.js +10 -4
  84. package/dist/ui/BgPanel.js +17 -12
  85. package/dist/ui/Header.js +1 -6
  86. package/dist/ui/StatusRule.js +18 -7
  87. package/dist/ui/ToolStep.js +3 -3
  88. package/dist/ui/Transcript.js +36 -14
  89. package/dist/ui/UpdatePrompt.js +40 -0
  90. package/dist/ui/batchLine.js +4 -4
  91. package/dist/ui/editdiff.js +2 -4
  92. package/dist/ui/format.js +4 -20
  93. package/dist/ui/liveTools.js +3 -3
  94. package/dist/ui/modelPicker.js +1 -1
  95. package/dist/ui/opsMode.js +20 -0
  96. package/dist/ui/slashCommands.js +1 -0
  97. package/dist/ui/types.js +0 -2
  98. package/dist/update-check.js +145 -0
  99. package/dist/update.js +59 -15
  100. package/dist/util/slash.js +2 -2
  101. package/package.json +4 -2
  102. package/src/tools/device/NOTICE +37 -0
  103. package/dist/browser/cdp.js +0 -271
  104. package/dist/tools/mutating.js +0 -15
package/dist/ui/Header.js CHANGED
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { termCols } from "./term.js";
4
4
  import { theme } from "./theme.js";
5
+ import { prettyRoute } from "./StatusRule.js"; // the ONE outward-name rule, shared with the status rule
5
6
  const STAR = "✷"; // ✷ — the AXE signal star (brand glyph, matches ThinkingSpinner)
6
7
  function tierLabel(ctx) {
7
8
  if (!ctx)
@@ -12,12 +13,6 @@ function tierLabel(ctx) {
12
13
  return `${Math.round(ctx / 1024)}K`; // /1024 so 307200→"300K", 131072→"128K" (KiB-tokens, truthful)
13
14
  return String(ctx);
14
15
  }
15
- // The status line shows the OUTWARD name only: the internal model ids (operator-1m, or the legacy
16
- // aurora-* alias) collapse to "Operator" — the tier (· 1M) is appended separately below, so
17
- // "operator-1m" would just be redundant. MOA and any custom /model id pass through unchanged.
18
- function prettyRoute(r) {
19
- return /^(operator|aurora)(-|$)/i.test(r) ? "Operator" : r;
20
- }
21
16
  export function Header({ version, route = "operator", ctxWindow, user, build }) {
22
17
  const cols = termCols();
23
18
  const tier = tierLabel(ctxWindow);
@@ -3,6 +3,7 @@ import { Box, Text } from "ink";
3
3
  import { termCols } from "./term.js";
4
4
  import { theme } from "./theme.js";
5
5
  import { ring } from "./chart.js";
6
+ import { opsModeOn } from "./opsMode.js";
6
7
  // Compact token count for the status rule: 1234 -> "1.2k", 45231 -> "45k", 800 -> "800".
7
8
  function fmtK(n) {
8
9
  if (n < 1000)
@@ -44,10 +45,18 @@ export function truncateToWidth(s, max) {
44
45
  // the terminal is too narrow to hold every badge, `info` is truncated so cellWidth(right) ≤ cols-3 —
45
46
  // which keeps the leading fill ≥ 1 and the whole line at cols-1, so the rule never becomes the line that
46
47
  // wraps (the creep bug) no matter how many badges are lit or how narrow the window.
47
- const ROUTE_LABELS = { "operator-1m": "aurora" };
48
- /** The model as the owner reads it everywhere ("cortana"; the default operator-1m reads "aurora"). */
48
+ // The OUTWARD name only. Every Operator-branded model id (operator-1m, operator-flash, the legacy
49
+ // aurora-* aliases) reads "Operator" — the tier badge beside it carries the window, so the id would add
50
+ // nothing. A retired name is never shown for a live model: the hardcoded "operator-1m → aurora" map
51
+ // printed "aurora" while Operator-Flash was answering (owner screenshot, 11/26). Any other id — a fleet
52
+ // row, a BYO endpoint, MOA — passes through unchanged, because inventing a name for a model we know
53
+ // nothing about is worse than showing its id.
54
+ export function prettyRoute(r) {
55
+ return /^(operator|aurora)(-|$)/i.test(r) ? "Operator" : r;
56
+ }
57
+ /** The model as the owner reads it everywhere — the one label function every surface calls. */
49
58
  export function routeLabel(route) {
50
- return ROUTE_LABELS[route] ?? route;
59
+ return prettyRoute(route);
51
60
  }
52
61
  export function statusRight(p, cols) {
53
62
  const who = p.user ? `◆ ${p.user} · ` : "";
@@ -61,12 +70,13 @@ export function statusRight(p, cols) {
61
70
  // its id operator-1m (owner, 11/03: "just aurora 300k"), and the window is the one served, not a pin above it.
62
71
  const window = p.ctxWindow ? ` ${p.ctxWindow}` : "";
63
72
  let info = `${think}${plan}${seat}${who}${routeLabel(p.route)}${window} ${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
64
- let right = `✷ OPERATOR · ${info} ─`;
73
+ const word = p.ops ? "OPS" : "OPERATOR";
74
+ let right = `✷ ${word} · ${info} ─`;
65
75
  const maxRight = cols - 3; // leaves fill ≥ 1 and total = cols-1
66
76
  if (cellWidth(right) > maxRight) {
67
77
  const framing = cellWidth(right) - cellWidth(info); // the wordmark + separators + trailing " ─"
68
78
  info = truncateToWidth(info, maxRight - framing);
69
- right = `✷ OPERATOR · ${info} ─`;
79
+ right = `✷ ${word} · ${info} ─`;
70
80
  }
71
81
  return { info, right };
72
82
  }
@@ -79,9 +89,10 @@ export function ruleFill(right, cols) {
79
89
  }
80
90
  export function StatusRule(props) {
81
91
  const cols = termCols();
82
- const { info, right } = statusRight(props, cols);
92
+ const ops = props.ops ?? opsModeOn();
93
+ const { info, right } = statusRight({ ...props, ops }, cols);
83
94
  const fill = ruleFill(right, cols);
84
95
  // Enterprise header: a dim rule sweeping to a magenta ✷ mark + bright OPERATOR wordmark + dim info,
85
96
  // sitting just above the composer (the input is bounded between this and the InputRule below).
86
- return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: "─".repeat(fill) + " " }), _jsx(Text, { color: theme.accent, children: "\u2737 " }), _jsx(Text, { bold: true, children: "OPERATOR" }), _jsx(Text, { dimColor: true, children: ` · ${info} ─` })] }));
97
+ return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: "─".repeat(fill) + " " }), _jsx(Text, { color: theme.accent, children: "\u2737 " }), _jsx(Text, { bold: true, children: ops ? "OPS" : "OPERATOR" }), _jsx(Text, { dimColor: true, children: ` · ${info} ─` })] }));
87
98
  }
@@ -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 { SHELL_ANY } from "../tools/classes.js";
8
9
  import { rowBackgroundHint, BULK_ARGS } from "./liveTools.js";
9
10
  import { glyphFor, toolKind, KIND_HUE } from "./toolicons.js";
10
11
  import { renderSweepBar } from "./progressbar.js";
@@ -19,7 +20,6 @@ const COLOR = { selected: theme.muted, running: theme.running, done: theme.succe
19
20
  // (never truncated), so you can always read the exact file name / path a tool wrote or read. Order matters:
20
21
  // path-like keys first.
21
22
  const KEY_ARGS = ["path", "file", "filename", "command", "cmd", "pattern", "url", "query", "workspace", "cwd", "name"];
22
- const SHELL_TOOLS = new Set(["bash", "shell_exec", "shell_background"]);
23
23
  /** `link: false` gives the plain text (a live row clips it, and clipping an OSC-8 escape cuts it); `sizes` are a
24
24
  * draft's bulk arguments by their running length, shown where the finished call shows its own. */
25
25
  export function argsPreview(args, opts = {}) {
@@ -65,7 +65,7 @@ export function argsPreview(args, opts = {}) {
65
65
  /** The call's title. A shell call reads as the command itself — "$ ls -la /path" — like a terminal prompt (owner, 10/31:
66
66
  * "bash needs to just show $"); every other tool reads name(args). `note` is the shell call's description, shown dim. */
67
67
  export function stepTitle(step) {
68
- if (SHELL_TOOLS.has(step.name) && typeof step.args?.command === "string") {
68
+ if (SHELL_ANY.has(step.name) && typeof step.args?.command === "string") {
69
69
  const cmd = step.args.command.replace(/\s+/g, " ").trim();
70
70
  const desc = typeof step.args.description === "string" && step.args.description.trim() ? step.args.description.trim() : undefined;
71
71
  return { head: "$", body: cmd.length > 160 ? cmd.slice(0, 157) + "..." : cmd, note: desc };
@@ -74,7 +74,7 @@ export function stepTitle(step) {
74
74
  }
75
75
  /** For shell tools with a description, the command is shown dim beneath the description line. */
76
76
  export function shellCommandHint(step) {
77
- if (!SHELL_TOOLS.has(step.name) || !step.args?.description)
77
+ if (!SHELL_ANY.has(step.name) || !step.args?.description)
78
78
  return null;
79
79
  const cmd = step.args.command;
80
80
  if (typeof cmd !== "string")
@@ -44,30 +44,36 @@ function entryKey(entry) {
44
44
  // approaches the window height, and the worst moment is the settle transition when this frame is erased.
45
45
  // So cap the live view to a small slice (≤ ~16 rows, less on short terminals): enough to watch the answer
46
46
  // stream, while the full text always renders complete via <Static> once it settles. Pure (dimensions
47
- // passed in) so the bound is unit-testable.
48
- export function liveTail(s, rows, cols) {
47
+ // passed in) so the bound is unit-testable. `budget` (inline mode) is the exact row count the caller measured
48
+ // as free; without it the budget is derived from the terminal height as before (fullscreen).
49
+ export function liveTail(s, rows, cols, budget) {
49
50
  // Clamp degenerate dimensions: a minimized/detached terminal reports 0, and cols=0 divides to
50
51
  // Infinity/NaN below — which walks `start` to 0 and returns the WHOLE message unbounded, ballooning the
51
52
  // dynamic frame and stacking the streaming line into scrollback (the minimize-duplication bug). Guard
52
53
  // here too (not just at the call site) since this is the pure, unit-tested unit — it must not trust its caller.
53
54
  const c = cols > 0 ? cols : 80;
54
- const budget = Math.max(6, Math.min((rows > 0 ? rows : 24) - 14, 16)); // rendered rows the live frame may occupy
55
+ const cap = budget !== undefined ? Math.max(1, budget) : Math.max(6, Math.min((rows > 0 ? rows : 24) - 14, 16)); // rendered rows the live frame may occupy
55
56
  const lines = s.split("\n");
56
57
  // Walk up from the last line, counting the PHYSICAL rows each takes after wrapping, and keep only what
57
58
  // fits the budget — so even all-long-wrapping lines can't push the dynamic frame past the window.
58
59
  let used = 0, start = lines.length;
59
60
  for (let i = lines.length - 1; i >= 0; i--) {
60
61
  const wrapped = Math.max(1, Math.ceil(lines[i].length / c));
61
- if (used + wrapped > budget && start !== lines.length)
62
+ if (used + wrapped > cap && start !== lines.length)
62
63
  break;
63
64
  used += wrapped;
64
65
  start = i;
65
- if (used >= budget)
66
+ if (used >= cap)
66
67
  break;
67
68
  }
69
+ // One streaming paragraph with no newline yet can wrap past the cap on its own: keep its newest rows.
70
+ if (used > cap) {
71
+ const last = lines[lines.length - 1];
72
+ return { text: last.slice(last.length - cap * c), clipped: lines.length - 1, used: cap };
73
+ }
68
74
  if (start <= 0)
69
- return { text: s, clipped: 0 };
70
- return { text: lines.slice(start).join("\n"), clipped: start };
75
+ return { text: s, clipped: 0, used };
76
+ return { text: lines.slice(start).join("\n"), clipped: start, used };
71
77
  }
72
78
  // A Switchboard bus message rendered inline (SPEC §6, Switchboard surface). Static-rendered like any
73
79
  // settled entry, so it's printed once and scrolls with history — anchored to when it arrived/was sent,
@@ -113,7 +119,7 @@ function ReportRow({ agent }) {
113
119
  const name = body.split(" · ")[0];
114
120
  return (_jsxs(Text, { children: [_jsx(Text, { color: tone === "done" ? theme.success : tone === "stopped" ? theme.blocked : theme.error, children: line.slice(0, 2) }), _jsx(Text, { bold: true, children: name }), _jsx(Text, { dimColor: true, children: body.slice(name.length) }), hint ? _jsx(Text, { color: theme.info, children: hint }) : null] }));
115
121
  }
116
- function renderEntry(entry, live = false) {
122
+ function renderEntry(entry, live = false, liveRows) {
117
123
  if (entry.kind === "summary")
118
124
  return _jsx(SummaryCard, { summary: entry.summary });
119
125
  if (entry.kind === "report")
@@ -142,13 +148,29 @@ function renderEntry(entry, live = false) {
142
148
  // process through the WHOLE workflow, not just the gap before the answer starts. Before the answer begins,
143
149
  // reasoning tails the full window; once the answer is streaming, reasoning keeps showing at lower opacity in
144
150
  // a small reserved band above it, and the answer stays primary.
151
+ // Inline mode passes liveRows: the rows the rest of the dynamic frame leaves free (App measures them). Every
152
+ // row of this block (both clip notices and the bottom margin) is then counted against it, so the frame stays
153
+ // under the terminal height. Ink clears the whole screen and repaints all history on every render once it
154
+ // reaches it, which is the inline flicker.
145
155
  const rows = termRows(), cols = termCols();
146
156
  const hasAnswer = !!message.content;
147
157
  const reasoning = message.reasoning ?? "";
148
- const rRows = hasAnswer ? Math.min(6, Math.max(0, Math.floor(rows / 3))) : rows; // dim band capped small once the answer is flowing
149
- const r = reasoning && rRows > 0 ? liveTail(reasoning, rRows, cols) : null;
150
- const aRows = Math.max(1, rows - (r ? rRows + 1 : 0)); // answer gets the remaining height (−1 for the band's clip notice)
151
- const a = hasAnswer ? liveTail(message.content, aRows, cols) : null;
158
+ let r, a;
159
+ if (liveRows !== undefined) {
160
+ const room = liveRows - 1; // −1: this block's marginBottom
161
+ if (room < 2)
162
+ return null; // the panels below fill the window: the answer shows in full once it settles
163
+ const rBudget = (hasAnswer ? Math.min(6, Math.floor(room / 3)) : room) - 1; // −1: the band's clip notice
164
+ r = reasoning && rBudget >= 1 ? liveTail(reasoning, 0, cols, rBudget) : null;
165
+ const aBudget = room - (r ? r.used + (r.clipped > 0 ? 1 : 0) : 0) - 1; // −1: the answer's clip notice
166
+ a = hasAnswer && aBudget >= 1 ? liveTail(message.content, 0, cols, aBudget) : null;
167
+ }
168
+ else {
169
+ const rRows = hasAnswer ? Math.min(6, Math.max(0, Math.floor(rows / 3))) : rows; // dim band capped small once the answer is flowing
170
+ r = reasoning && rRows > 0 ? liveTail(reasoning, rRows, cols) : null;
171
+ const aRows = Math.max(1, rows - (r ? rRows + 1 : 0)); // answer gets the remaining height (−1 for the band's clip notice)
172
+ a = hasAnswer ? liveTail(message.content, aRows, cols) : null;
173
+ }
152
174
  if (!r && !a)
153
175
  return _jsx(Box, { marginBottom: 1 });
154
176
  return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [r && r.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${r.clipped} more thinking line${r.clipped === 1 ? "" : "s"} above` }) : null, r ? _jsx(Text, { dimColor: true, children: r.text }) : null, a && a.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${a.clipped} more line${a.clipped === 1 ? "" : "s"} above (full text shown when complete)` }) : null, a ? _jsx(Text, { children: a.text }) : null] }));
@@ -170,7 +192,7 @@ function renderEntry(entry, live = false) {
170
192
  const TranscriptRow = React.memo(function TranscriptRow({ entry }) {
171
193
  return _jsx(Box, { children: renderEntry(entry) });
172
194
  });
173
- export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
195
+ export function Transcript({ entries, live, bounded, scrollBack = 0, liveRows }) {
174
196
  if (bounded) {
175
197
  // Fullscreen: no <Static>; render a wheel-scrollable window as a plain column the parent clips +
176
198
  // bottom-anchors. scrollBack (from MouseProvider wheel events, via App) slides the window back through
@@ -182,5 +204,5 @@ export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
182
204
  ? _jsx(Text, { dimColor: true, children: `⋯ ${newerOff} newer line(s) below — scroll down (new output jumps here)` })
183
205
  : (live ? _jsx(Box, { children: renderEntry(live, true) }) : null)] }));
184
206
  }
185
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live, true) }) : null] }));
207
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live, true, liveRows) }) : null] }));
186
208
  }
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The update-available prompt (update-check.ts): shown before the first turn when the startup check found a newer build.
3
+ // It owns the keyboard while up (App.tsx promptUp suspends the composer). Enter takes the highlighted choice, a digit takes
4
+ // its row, Esc or ctrl+c skips this launch.
5
+ import { useState } from "react";
6
+ import { Box, Text, useInput } from "ink";
7
+ const CHOICES = ["update", "skip", "skip-version"];
8
+ export function choiceLabels(p) {
9
+ return [`Update now (runs \`${p.command}\`)`, "Skip", "Skip until next version"];
10
+ }
11
+ /** Pure keystroke reducer: the next highlight, or the choice made. */
12
+ export function updateKey(sel, input, key) {
13
+ if (key.escape || (key.ctrl && input.toLowerCase() === "c"))
14
+ return { choice: "skip" };
15
+ if (key.return)
16
+ return { choice: CHOICES[sel] };
17
+ if (key.upArrow)
18
+ return { sel: (sel + CHOICES.length - 1) % CHOICES.length };
19
+ if (key.downArrow)
20
+ return { sel: (sel + 1) % CHOICES.length };
21
+ const n = Number(input);
22
+ if (Number.isInteger(n) && n >= 1 && n <= CHOICES.length)
23
+ return { choice: CHOICES[n - 1] };
24
+ return {};
25
+ }
26
+ export function UpdatePrompt({ pending, suspended = false }) {
27
+ const [sel, setSel] = useState(0);
28
+ useInput((input, key) => {
29
+ if (!pending)
30
+ return;
31
+ const r = updateKey(sel, input, key);
32
+ if (r.choice)
33
+ pending.resolve(r.choice);
34
+ else if (r.sel !== undefined)
35
+ setSel(r.sel);
36
+ }, { isActive: !!pending && !suspended });
37
+ if (!pending)
38
+ return null;
39
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { bold: true, children: ["Update available · ", _jsx(Text, { dimColor: true, children: pending.current }), " → ", _jsx(Text, { color: "green", children: pending.version })] }), _jsx(Text, { dimColor: true, children: "Release notes: " + pending.notes }), _jsx(Text, { children: " " }), choiceLabels(pending).map((label, i) => (_jsxs(Text, { children: [i === sel ? _jsx(Text, { color: "cyan", bold: true, children: "› " }) : " ", _jsx(Text, { bold: i === sel, children: `${i + 1}. ${label}` })] }, label))), _jsx(Text, { children: " " }), _jsx(Text, { dimColor: true, children: suspended ? "waiting · another prompt has the keyboard" : "enter continue · esc skip" })] }));
40
+ }
@@ -9,7 +9,7 @@ import { computeEditDiff } from "./editdiff.js";
9
9
  import { fitSegments, seg } from "./fit.js";
10
10
  import { fmtTok } from "./format.js";
11
11
  import { humanStep } from "./BgPanel.js";
12
- const SHELL_TOOLS = new Set(["bash", "shell_exec", "shell_background"]);
12
+ import { SHELL_ANY } from "../tools/classes.js";
13
13
  const PATH_KEYS = ["path", "file", "filename"];
14
14
  /** A row's time: sub-second precision while short ("80ms", "1.1s"), minutes past one ("2m 13s"). */
15
15
  const rowTime = (ms) => (ms < 60_000 ? formatDuration(ms) : fmtElapsed(ms));
@@ -53,7 +53,7 @@ function tail(step, now) {
53
53
  export function liveRow(step, cols, now = Date.now()) {
54
54
  const t = tail(step, now);
55
55
  const max = cols - 1 - 4; // paddingLeft + the status glyph (counted wide, as cellWidth does) + space
56
- const shell = SHELL_TOOLS.has(step.name) && typeof step.args?.command === "string";
56
+ const shell = SHELL_ANY.has(step.name) && typeof step.args?.command === "string";
57
57
  const head = shell ? "$" : truncateToWidth(step.name, Math.max(1, Math.min(max - 2, Math.max(12, Math.floor(max * 0.6)))));
58
58
  const args = step.args ?? {};
59
59
  if (step.name === "delegate_task" && typeof args.task === "string") { // its title is the task the specialist works on
@@ -127,7 +127,7 @@ export function chipOf(step) {
127
127
  const glyph = tone === "done" ? "✓" : tone === "error" ? "✗" : "⊘";
128
128
  const path = PATH_KEYS.map((k) => a[k]).find((v) => typeof v === "string");
129
129
  let label;
130
- if (SHELL_TOOLS.has(step.name) && typeof a.command === "string")
130
+ if (SHELL_ANY.has(step.name) && typeof a.command === "string")
131
131
  label = words(a.command, 2);
132
132
  else if (/grep|search|find|glob/.test(step.name) && typeof (a.pattern ?? a.query) === "string")
133
133
  label = `${/find|glob/.test(step.name) ? "find" : "grep"} "${String(a.pattern ?? a.query).slice(0, 24)}"`;
@@ -141,7 +141,7 @@ export function chipOf(step) {
141
141
  label = step.name;
142
142
  const tail = step.outcome === "blocked" ? "blocked" : step.outcome === "cancelled" ? "cancelled"
143
143
  : step.exitCode !== undefined ? `exit ${step.exitCode}`
144
- : (() => { const d = step.status === "done" ? computeEditDiff(step.name, step.args) : undefined; return d ? `+${d.added} -${d.removed}` : step.lines && !SHELL_TOOLS.has(step.name) ? String(step.lines) : ""; })();
144
+ : (() => { const d = step.status === "done" ? computeEditDiff(step.name, step.args) : undefined; return d ? `+${d.added} -${d.removed}` : step.lines && !SHELL_ANY.has(step.name) ? String(step.lines) : ""; })();
145
145
  return { tone, glyph, label: tail ? `${label} ${tail}` : label, name: step.name };
146
146
  }
147
147
  /** The chip line: "⇉ 4 calls · 3.4s", then chips while they fit in cols−1, the rest folded into "+3 ✓ +1 ✗", then the
@@ -1,7 +1,5 @@
1
1
  const MAX_PREVIEW_LINES = 4;
2
2
  const MAX_LINE_WIDTH = 100; // a single preview line is truncated, never left to wrap/flood the row
3
- const EDIT_TOOL_NAMES = new Set(["file_edit", "multi_edit"]);
4
- const WRITE_TOOL_NAMES = new Set(["file_write"]);
5
3
  function splitLines(s) {
6
4
  return s === "" ? [] : s.split("\n");
7
5
  }
@@ -54,7 +52,7 @@ function lineDiff(oldLines, newLines) {
54
52
  export function computeEditDiff(name, args) {
55
53
  if (!args)
56
54
  return undefined;
57
- if (EDIT_TOOL_NAMES.has(name)) {
55
+ if (name === "file_edit") {
58
56
  const oldStr = args.old_string;
59
57
  const newStr = args.new_string;
60
58
  if (typeof oldStr !== "string" || typeof newStr !== "string")
@@ -67,7 +65,7 @@ export function computeEditDiff(name, args) {
67
65
  const preview = script.length <= MAX_PREVIEW_LINES ? script.map((l) => ({ kind: l.kind, text: truncateLine(l.text) })) : undefined;
68
66
  return { added, removed, preview };
69
67
  }
70
- if (WRITE_TOOL_NAMES.has(name)) {
68
+ if (name === "file_write") {
71
69
  const content = args.content;
72
70
  if (typeof content !== "string")
73
71
  return undefined;
package/dist/ui/format.js CHANGED
@@ -28,26 +28,10 @@ export function fmtTok(n) {
28
28
  return `${Math.round(v / 1000)}k`;
29
29
  return `${(v / 1_000_000).toFixed(1)}M`;
30
30
  }
31
- export function toolOutcome(result, refused) {
32
- if (refused)
33
- return refused;
34
- const s = result.trim();
35
- if (/^(error|loop guard|\[interrupted|\[timed out)/i.test(s))
36
- return "fail";
37
- const exit = exitCode(s);
38
- if ((exit !== undefined && exit !== 0) || /^\(no output; exit \?\)/.test(s))
39
- return "fail";
40
- if (/\n\[timed out after [^\n]*\]$/.test(s))
41
- return "fail";
42
- return "ok";
43
- }
44
- /** A shell call's exit code from its result (registry.ts shellExec), or undefined: output then an `[exit N]` line —
45
- * which shellResultNotes' `[note: …]`/`[hint: …]` lines and the result guard's notes may follow — or, for a command
46
- * that printed nothing, `(no output; exit N)`. */
47
- export function exitCode(result) {
48
- const m = /(?:^|\n)\[exit (\d+)\](?:\n+\[[^\n]*\])*\s*$/.exec(result) ?? /^\s*\(no output; exit (\d+)\)/.exec(result);
49
- return m ? Number(m[1]) : undefined;
50
- }
31
+ // How a tool call ended (ok · fail · blocked · cancelled) and a shell result's exit code: one reading for the
32
+ // transcript, the live rows, the fold, the editor adapter and the loop guard (tools/classes.ts).
33
+ export { toolOutcome, exitCode } from "../tools/classes.js";
34
+ import { toolOutcome } from "../tools/classes.js";
51
35
  // A tool result reads as an error/loop-guard/interrupt sentinel rather than real output — shared by the
52
36
  // settled-transcript push (cli.tsx) and the live per-call row update (ui/liveTools.ts) so both classify
53
37
  // a result the same way.
@@ -1,4 +1,5 @@
1
1
  import { settledFields } from "./fold.js";
2
+ import { SHELL_FOREGROUND } from "../tools/classes.js";
2
3
  // Bulky payloads — never dumped (they'd bury the path and blow up the line); shown as a size instead.
3
4
  export const BULK_ARGS = ["content", "text", "body", "data", "new_string", "old_string", "diff", "message"];
4
5
  const BULK = new Set(BULK_ARGS);
@@ -168,11 +169,10 @@ export function settleLiveTool(rows, id, result, now = Date.now(), refused) {
168
169
  });
169
170
  return changed ? next : rows;
170
171
  }
171
- const SHELL_TOOLS = new Set(["bash", "shell_exec"]);
172
172
  export const BACKGROUND_HINT_AFTER_MS = 2000;
173
173
  /** Inline per-row variant of the hint, under the running command itself (matches Claude Code). */
174
174
  export function rowBackgroundHint(step, now = Date.now(), inTmux = !!process.env.TMUX) {
175
- if (!SHELL_TOOLS.has(step.name) || step.status !== "running")
175
+ if (!SHELL_FOREGROUND.has(step.name) || step.status !== "running")
176
176
  return null;
177
177
  if (now - (step.startedAt ?? now) <= BACKGROUND_HINT_AFTER_MS)
178
178
  return null;
@@ -182,7 +182,7 @@ export function rowBackgroundHint(step, now = Date.now(), inTmux = !!process.env
182
182
  * shell command has run past the threshold. Inside tmux ctrl+b is the prefix key, so the first press is
183
183
  * swallowed by tmux: say "twice", and name the alias key that has no such clash. */
184
184
  export function backgroundHint(rows, now = Date.now(), inTmux = !!process.env.TMUX) {
185
- const slow = rows.some((r) => SHELL_TOOLS.has(r.name) && r.status === "running" && now - (r.startedAt ?? now) > BACKGROUND_HINT_AFTER_MS);
185
+ const slow = rows.some((r) => SHELL_FOREGROUND.has(r.name) && r.status === "running" && now - (r.startedAt ?? now) > BACKGROUND_HINT_AFTER_MS);
186
186
  if (!slow)
187
187
  return null;
188
188
  return inTmux ? "ctrl+b ctrl+b (tmux) or ctrl+z to run in the background" : "ctrl+b to run in the background";
@@ -15,7 +15,7 @@ export const CONNECT_ROW = "+ Connect a provider key (Anthropic, Google, Nous, O
15
15
  * `:free` listing joins here. */
16
16
  export const FREE_ROW_PRESETS = ["operator", "nous"];
17
17
  /** The /model main rows, in this order (0.1.361); everything else sits behind MORE_ROW. */
18
- export const MAIN_MODEL_IDS = ["operator-flash", "kimi-linear-48b", "qwen3.8-27b"];
18
+ export const MAIN_MODEL_IDS = ["operator-flash", "kimi-linear-48b", "operator-dense"];
19
19
  /** The last main row: an action that opens the rest (other fleet rows, connected providers, free rows, MOA, connect). */
20
20
  export const MORE_ROW = "More models…";
21
21
  // fleet → connected providers → free rows → MOA. The built-ins already list the local row before the gateway rows.
@@ -0,0 +1,20 @@
1
+ // Team mode shows as "OPS" in the status rule's tier slot. The mode is the flag file `team on|off` writes
2
+ // (~/.axe/nimbus/team, TEAM_FLAG_FILE overrides it). The rule re-renders on every keystroke, so the read is cached
3
+ // for a second; any read failure means off — a missing flag must never break the frame.
4
+ import { readFileSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { join } from "node:path";
7
+ const TTL_MS = 1000;
8
+ let cached;
9
+ export function opsModeOn(now = Date.now()) {
10
+ const path = process.env.TEAM_FLAG_FILE || join(homedir(), ".axe", "nimbus", "team");
11
+ if (cached && cached.path === path && now - cached.at < TTL_MS)
12
+ return cached.on;
13
+ let on = false;
14
+ try {
15
+ on = readFileSync(path, "utf8").trim() === "on";
16
+ }
17
+ catch { /* off */ }
18
+ cached = { path, at: now, on };
19
+ return on;
20
+ }
@@ -19,6 +19,7 @@ export const SLASH_COMMANDS = [
19
19
  { name: "mode", description: "set operating mode: autonomous · manual · plan · gated", args: "[auto|manual|plan|gated]" },
20
20
  { name: "think", description: "toggle extended reasoning (think before answering)" },
21
21
  { name: "ultrathink", description: "toggle deep, exhaustive reasoning for hard problems" },
22
+ { name: "delegate", description: "any /model id as the MoA planner or the sub-agents; guard: no push, deploys or writes outside this repo", args: "[planner <model> [executor]|subagents <model>|guard on|off|push on|off|off]" },
22
23
  { name: "agents", description: "detailed sub-agent status: running/queued/done/errored + metrics" },
23
24
  { name: "bg", description: "spawn a background sub-agent, list, or stop one", args: "<task|stop id>" },
24
25
  { name: "jobs", description: "background shell jobs: list, or stop one (ctrl+b moves a running command here)", args: "[stop id]" },
package/dist/ui/types.js CHANGED
@@ -1,3 +1 @@
1
- // Shared shapes for the UI lane. The engine lane (kode-tsi/src/engine/**) is expected to produce
2
- // these and feed them into <App/> as props — this file IS the UI/engine contract.
3
1
  export {};
@@ -0,0 +1,145 @@
1
+ // The update-available prompt (ui/UpdatePrompt.tsx): an interactive start of a packaged install asks the public download
2
+ // URL (update.ts) which version each channel holds, in the background, and offers a newer one before the first turn.
3
+ // Never for a subcommand (`operator run`, acp, mcp, update…), a non-TTY, CI, a source checkout (it updates by git), or
4
+ // with settings.updates.check false / OPERATOR_NO_UPDATE_CHECK=1. The answer is cached ~4 h in the Operator home's
5
+ // state folder, with the version "skip until next version" chose. A sign-in (the TUI's /login, the shell's
6
+ // `operator auth login`) checks again past the cache, so a release out since the last check is offered right then.
7
+ // Every failure is silent: no offer.
8
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
9
+ import { dirname } from "node:path";
10
+ import { operatorPath } from "./config/home.js";
11
+ import { channelOf, distBase, distTagsAsync, installedVersion, installPackaged, isOlder, isReleaseInstall, platformLabel, VERSION } from "./update.js";
12
+ export const CHECK_TTL_MS = 4 * 3600_000; // a release reaches a working day's next launch; a check is one small file
13
+ const FETCH_MS = 1500;
14
+ const REGISTRY_MS = 5000;
15
+ const NOTES = {
16
+ latest: "https://github.com/axetechnologies/kode/blob/main/CHANGELOG.md",
17
+ next: "https://github.com/axetechnologies/kode/blob/develop/CHANGELOG.md",
18
+ };
19
+ export const statePath = () => operatorPath("state", "update-check.json");
20
+ const on = (v) => !!v && v !== "0" && v.toLowerCase() !== "false";
21
+ /** Whether this launch checks at all. `argv` is process.argv: any subcommand (a bare word after the binary) is not an
22
+ * interactive start. */
23
+ export function checkEnabled(o) {
24
+ const sub = o.argv[2];
25
+ if (sub && !sub.startsWith("-"))
26
+ return false;
27
+ if (o.argv.includes("--version") || o.argv.includes("-V") || o.argv.includes("--help"))
28
+ return false;
29
+ if (!o.tty || on(o.env.CI) || on(o.env.OPERATOR_NO_UPDATE_CHECK) || on(o.env.KODE_NO_UPDATE_CHECK))
30
+ return false;
31
+ return o.settings.updates?.check !== false && !o.sourceCheckout;
32
+ }
33
+ /** What to offer: a newer build on the install's own channel; a next build also sees latest and gets the newer of the
34
+ * two (a release that has passed the prerelease it runs). Never an older or equal one (update.ts isOlder). */
35
+ export function pickOffer(current, found) {
36
+ const own = channelOf(current);
37
+ let best = null;
38
+ for (const channel of own === "next" ? ["next", "latest"] : ["latest"]) {
39
+ const v = found[channel];
40
+ if (!v || !isOlder(current, v) || (best && !isOlder(best.version, v)))
41
+ continue;
42
+ best = { version: v, channel };
43
+ }
44
+ return best;
45
+ }
46
+ /** The channel files at the public URL; when none answers (and not for an install.sh install, whose update never uses
47
+ * the registry) the registry's dist-tags of the same names. Unreachable everywhere = {}. */
48
+ export async function fetchVersions(own, o = {}) {
49
+ const want = own === "next" ? ["next", "latest"] : ["latest"];
50
+ const base = o.base ?? distBase();
51
+ const read = async (ch) => {
52
+ try {
53
+ const res = await fetch(`${base}/${ch}.txt`, { signal: AbortSignal.timeout(FETCH_MS) });
54
+ const v = res.ok ? (await res.text()).trim() : "";
55
+ return VERSION.test(v) ? v : undefined;
56
+ }
57
+ catch {
58
+ return undefined;
59
+ }
60
+ };
61
+ const got = {};
62
+ await Promise.all(want.map(async (ch) => { const v = await read(ch); if (v)
63
+ got[ch] = v; }));
64
+ if (Object.keys(got).length || o.registry === false)
65
+ return got;
66
+ const t = await (o.tags ?? distTagsAsync)(REGISTRY_MS);
67
+ if ("error" in t)
68
+ return got;
69
+ for (const ch of want)
70
+ if (VERSION.test(t.tags[ch] ?? ""))
71
+ got[ch] = t.tags[ch];
72
+ return got;
73
+ }
74
+ export function readState(path = statePath()) {
75
+ try {
76
+ const s = JSON.parse(readFileSync(path, "utf8"));
77
+ return s && typeof s === "object" && !Array.isArray(s) ? s : {};
78
+ }
79
+ catch {
80
+ return {};
81
+ }
82
+ }
83
+ function writeState(state, path) {
84
+ mkdirSync(dirname(path), { recursive: true });
85
+ const tmp = `${path}.${process.pid}.tmp`;
86
+ writeFileSync(tmp, JSON.stringify(state, null, 2) + "\n", { mode: 0o600 });
87
+ renameSync(tmp, path);
88
+ }
89
+ /** The offer for this launch, or null. A check younger than CHECK_TTL_MS is reused unless `force`; a fresh one is
90
+ * written only when something answered, so a launch without network asks again next time. */
91
+ export async function checkForUpdate(current, o = {}) {
92
+ try {
93
+ const now = o.now ?? Date.now(), path = o.path ?? statePath();
94
+ const state = readState(path);
95
+ const fresh = !o.force && typeof state.checkedAt === "number" && now >= state.checkedAt && now - state.checkedAt < CHECK_TTL_MS;
96
+ let found = { latest: state.latest, next: state.next };
97
+ if (!fresh) {
98
+ found = await (o.fetch ?? ((own) => fetchVersions(own, { registry: !isReleaseInstall() })))(channelOf(current));
99
+ if (found.latest || found.next)
100
+ writeState({ ...readState(path), checkedAt: now, latest: found.latest, next: found.next }, path);
101
+ }
102
+ const pick = pickOffer(current, found);
103
+ if (!pick || pick.version === state.skipVersion)
104
+ return null;
105
+ const command = pick.channel === channelOf(current) ? "operator update" : `operator update --${pick.channel}`;
106
+ return { current, ...pick, notes: NOTES[pick.channel], command };
107
+ }
108
+ catch {
109
+ return null;
110
+ }
111
+ }
112
+ /** The check after a sign-in: every checkEnabled rule except the subcommand one (the shell's `operator auth login` is
113
+ * one), and past the cache. */
114
+ export function checkAfterSignIn(current, o, check = checkForUpdate) {
115
+ if (!checkEnabled({ ...o, argv: ["node", "operator"] }))
116
+ return Promise.resolve(null);
117
+ return check(current, { force: true });
118
+ }
119
+ /** The offer as plain text, for the shell. */
120
+ export const offerLine = (offer) => `Operator ${offer.version} is available (you have ${offer.current}). Run: ${offer.command}`;
121
+ /** "Skip until next version": this exact version is not offered again; a newer one is. */
122
+ export function skipVersion(version, path = statePath()) {
123
+ try {
124
+ writeState({ ...readState(path), skipVersion: version }, path);
125
+ }
126
+ catch { /* best-effort: it is asked again next launch */ }
127
+ }
128
+ /** "Update now", after the TUI has closed: the same packaged update `operator update` runs, then the version the next
129
+ * `operator` starts, read back. Success is said only when that read matches. */
130
+ export async function runOfferedUpdate(offer, o = {}) {
131
+ const say = o.write ?? ((s) => { process.stdout.write(s); });
132
+ say(`Updating Operator via \`${offer.command}\`...\n`);
133
+ say(`==> Updating Operator from ${offer.current} to ${offer.version}\n`);
134
+ say(`==> Detected platform: ${platformLabel()}\n`);
135
+ say(`==> Resolved version: ${offer.version}\n`);
136
+ const code = await installPackaged(offer.channel, true, o.pkgJson);
137
+ const now = installedVersion(o.pkgJson);
138
+ if (code === 0 && now === offer.version) {
139
+ say(`Operator ${now} installed successfully.\n`);
140
+ say("Update ran successfully. Please restart Operator.\n");
141
+ return 0;
142
+ }
143
+ say(`Operator ${offer.version} was not installed: \`operator\` still starts v${now ?? "?"}. Run \`${offer.command}\` to try again.\n`);
144
+ return code || 1;
145
+ }