@0perator/operator 0.1.162 → 0.1.163

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on A
4
4
  Newest first. Every release bumps `src/cli.tsx` VERSION + `package.json`, adds an entry here, and ships to
5
5
  npm + both git remotes (memjar/kode, axetechnologies/kode). Test counts are the full suite at that release.
6
6
 
7
+ ## 0.1.163 — 2026-09-30 — TUI: live Switchboard messages in the terminal (click-to-expand)
8
+ - Incoming Switchboard agent messages (the provider-agnostic on-box bus, memjar/switchboard) now surface
9
+ **live in the Operator terminal** as a click-to-expand tray — the end-to-end proof of the Phase-1 mouse
10
+ layer. `src/bus/inbox.ts` reads this session's inbox directly (same mailbox format, no cross-repo dep;
11
+ neutral defaults `SWITCHBOARD_DIR`→`~/.switchboard`, `SWITCHBOARD_AGENT`→`AXE_AGENT`→`role@host`); a 3s
12
+ poller in `cli.tsx` feeds a bounded tail to `<App>`.
13
+ - `src/ui/BusTray.tsx` renders each message as a collapsible card, **top-anchored** so each card's absolute
14
+ terminal row is deterministic (`trayLayout()`, pure + tested) — which is what makes left-click hit-testing
15
+ reliable without Ink absolute-position measurement. Click toggles the body; inline mode shows cards
16
+ read-only (no mouse there). A box without Switchboard installed shows nothing (empty-safe).
17
+ - Enterprise/AI-agnostic: no vendor lock, neutral env-overridable paths, works on any surface. Received
18
+ messages are DATA, never executed. Decision log: `_ai-docs/decisions/2026-09-30-switchboard-tui-bustray.md`.
19
+ Suite 748 green (+10).
20
+
7
21
  ## 0.1.162 — 2026-09-30 — TUI: wheel-scrollback in fullscreen (mouse layer wired into App)
8
22
  - The Phase 1 mouse mechanism is now live in the app. `App.tsx`'s fullscreen branch mounts `MouseProvider`
9
23
  (enabled only on a mouse-capable TTY — inline stays a native-scroll no-op) and a new `FullscreenBody`
@@ -0,0 +1,58 @@
1
+ // Switchboard inbox reader (Operator side of the provider-agnostic agent bus, memjar/switchboard).
2
+ // The bus is a file mailbox: one JSON file per message under <SWITCHBOARD_DIR>/agents/<agent>/inbox.
3
+ // This module reads THIS session's inbox so incoming messages can surface live in the TUI (BusTray) — the
4
+ // counterpart to the `switch`/`sb-msg` CLI other agents send with. We read the format directly rather than
5
+ // depend on the switchboard package, so kode-tsi stays self-contained.
6
+ //
7
+ // SECURITY: a bus message is DATA written by another agent — untrusted input. The UI surfaces it to the
8
+ // operator; nothing here executes message contents.
9
+ import { readdirSync, readFileSync, renameSync, mkdirSync, existsSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ import { homedir, hostname } from "node:os";
12
+ /** The bus state root — mirrors the switchboard CLI's SWITCHBOARD_DIR. Neutral default (~/.switchboard) so
13
+ * this works on any box/surface, not just the AXE fleet; the env var repoints it wherever the bus lives. */
14
+ export function busDir() {
15
+ return process.env.SWITCHBOARD_DIR || join(homedir(), ".switchboard");
16
+ }
17
+ /** This session's bus identity. Convention is role@node. SWITCHBOARD_AGENT is the neutral primary; AXE_AGENT
18
+ * is honored as a fleet fallback; else <role>@<host>. Vendor-neutral by default (no AI/product baked in). */
19
+ export function selfAgent() {
20
+ return process.env.SWITCHBOARD_AGENT || process.env.AXE_AGENT || `operator@${hostname().split(".")[0]}`;
21
+ }
22
+ const inboxOf = (agent) => join(busDir(), "agents", encodeURIComponent(agent), "inbox");
23
+ const readOf = (agent) => join(busDir(), "agents", encodeURIComponent(agent), "read");
24
+ /** Read `agent`'s inbox oldest-first. Unless `peek`, each message is moved to the read/ archive so it
25
+ * surfaces exactly once (delivered-once, matching the CLI). Corrupt or in-flight (.tmp-) files are
26
+ * skipped, never thrown — a bad drop can't wedge polling. Returns [] when the bus/inbox doesn't exist. */
27
+ export function pollBus(agent = selfAgent(), opts = {}) {
28
+ const dir = inboxOf(agent);
29
+ if (!existsSync(dir))
30
+ return [];
31
+ let files;
32
+ try {
33
+ files = readdirSync(dir).filter((f) => f.endsWith(".json") && !f.startsWith(".tmp-")).sort();
34
+ }
35
+ catch {
36
+ return [];
37
+ }
38
+ const out = [];
39
+ for (const f of files) {
40
+ const full = join(dir, f);
41
+ let msg = null;
42
+ try {
43
+ msg = JSON.parse(readFileSync(full, "utf8"));
44
+ }
45
+ catch { /* skip corrupt */ }
46
+ if (!msg || typeof msg.body !== "string")
47
+ continue;
48
+ out.push(msg);
49
+ if (!opts.peek) {
50
+ try {
51
+ mkdirSync(readOf(agent), { recursive: true });
52
+ renameSync(full, join(readOf(agent), f));
53
+ }
54
+ catch { /* already consumed by a concurrent read */ }
55
+ }
56
+ }
57
+ return out;
58
+ }
package/dist/cli.js CHANGED
@@ -11,6 +11,7 @@ import { mastheadLines } from "./ui/Masthead.js";
11
11
  import { hyperlinkHint } from "./ui/capabilities.js";
12
12
  import { shouldPromptPlanExit, resolvePlanExit, PLAN_EXIT_OPTIONS } from "./ui/planExit.js";
13
13
  import { RemoteHost } from "./remote/host.js";
14
+ import { pollBus, selfAgent } from "./bus/inbox.js";
14
15
  import { isErrorResult } from "./ui/format.js";
15
16
  import { seedLiveTools, settleLiveTool } from "./ui/liveTools.js";
16
17
  import { Session } from "./session.js";
@@ -415,6 +416,7 @@ function Root() {
415
416
  // Gates the exit-time picker below — plan mode toggled on/off with no proposal stays silent.
416
417
  const planProposedRef = useRef(false);
417
418
  const [planExitPicker, setPlanExitPicker] = useState(null);
419
+ const [busMessages, setBusMessages] = useState([]); // live Switchboard messages for the click-to-expand tray
418
420
  const alwaysAllowRef = useRef(new Set());
419
421
  // Remembers the email a `/login <email>` sent a 6-digit code to, so the follow-up `/login <code>`
420
422
  // knows which address to verify against — the in-session twin of the shell's email-code login.
@@ -1488,6 +1490,19 @@ function Root() {
1488
1490
  const id = setInterval(() => setElapsed((Date.now() - turnStartRef.current) / 1000), 500); // 500ms: the elapsed readout shows whole/half seconds; 250ms doubled the whole-frame re-render rate (flashing)
1489
1491
  return () => clearInterval(id);
1490
1492
  }, [status]);
1493
+ // Switchboard poller: pull this session's incoming agent messages every few seconds and surface them in
1494
+ // the BusTray (click-to-expand). pollBus consumes each (moves to read/), so a message shows once; we keep a
1495
+ // bounded tail. Only runs once ready, and is a no-op when the bus dir doesn't exist — so a box without
1496
+ // Switchboard installed simply shows nothing. MUST be above the boot early-returns (stable hook order).
1497
+ useEffect(() => {
1498
+ if (boot !== "ready")
1499
+ return;
1500
+ const pull = () => { const incoming = pollBus(selfAgent()); if (incoming.length)
1501
+ setBusMessages((prev) => [...prev, ...incoming].slice(-20)); };
1502
+ pull();
1503
+ const id = setInterval(pull, 3000);
1504
+ return () => clearInterval(id);
1505
+ }, [boot]);
1491
1506
  if (boot === "checking")
1492
1507
  return _jsx(Text, { dimColor: true, children: bootDetail || "connecting to Operator…" });
1493
1508
  if (boot === "down") {
@@ -1507,7 +1522,7 @@ function Root() {
1507
1522
  ? `${spin} reading your prompt… (${fmtDuration(elapsed)})`
1508
1523
  : `${spin} ${fmtMeta(elapsed, liveTok)}`
1509
1524
  : metrics;
1510
- return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, liveTools: liveTools, route: route, ctxPct: ctxPct, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, opMode: opMode, approval: approval, question: question, modelPicker: modelPicker, planExitPicker: planExitPicker, onApprovalDecide: (allow, always) => {
1525
+ return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, liveTools: liveTools, route: route, ctxPct: ctxPct, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, opMode: opMode, approval: approval, question: question, modelPicker: modelPicker, planExitPicker: planExitPicker, busMessages: busMessages, onApprovalDecide: (allow, always) => {
1511
1526
  const cur = approval;
1512
1527
  if (cur)
1513
1528
  settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
package/dist/ui/App.js CHANGED
@@ -4,9 +4,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
4
4
  // src/engine, src/tools, or src/router.
5
5
  import { useEffect, useState } from "react";
6
6
  import { Box, Text } from "ink";
7
- import { termRows } from "./term.js";
7
+ import { termRows, termCols } from "./term.js";
8
8
  import { caps } from "./capabilities.js";
9
9
  import { MouseProvider, useOnWheel } from "./MouseProvider.js";
10
+ import { BusTray } from "./BusTray.js";
10
11
  import { StatusRule } from "./StatusRule.js";
11
12
  import { InputRule } from "./InputRule.js";
12
13
  import { Transcript } from "./Transcript.js";
@@ -24,7 +25,7 @@ import { QuestionPrompt } from "./QuestionPrompt.js";
24
25
  // calls at once; anything past the cap is summarized as a count instead of another row.
25
26
  const MAX_LIVE_TOOL_ROWS = 6;
26
27
  export function App(props) {
27
- const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, tasks = [], onSubmit, onQueue, onInterrupt, onCycleMode, opMode, approval = null, onApprovalDecide, question = null, modelPicker = null, planExitPicker = null } = props;
28
+ const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, tasks = [], onSubmit, onQueue, onInterrupt, onCycleMode, opMode, approval = null, onApprovalDecide, question = null, modelPicker = null, planExitPicker = null, busMessages = [] } = props;
28
29
  const thinking = status === "thinking" || status === "streaming";
29
30
  // A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
30
31
  // a lone call isn't worth a bordered block, the braille spinner + name already says enough.
@@ -46,11 +47,11 @@ export function App(props) {
46
47
  // Enable the SGR mouse layer ONLY in fullscreen on a mouse-capable TTY — inline keeps the terminal's
47
48
  // native scroll+copy, so it must never receive tracking. FullscreenBody (under the provider) turns
48
49
  // wheel events into scrollback over the alt-screen transcript, which otherwise has no way to scroll.
49
- return (_jsx(MouseProvider, { enabled: caps().mouse, children: _jsx(FullscreenBody, { messages: messages, live: live, activity: activity, prompts: prompts, bottom: bottom }) }));
50
+ return (_jsx(MouseProvider, { enabled: caps().mouse, children: _jsx(FullscreenBody, { messages: messages, live: live, activity: activity, prompts: prompts, bottom: bottom, busMessages: busMessages }) }));
50
51
  }
51
52
  // Inline (default): the dynamic frame grows below the Static transcript; unused space sits below it and
52
53
  // fills as the conversation grows. Native scrollback preserved.
53
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), activity, prompts, bottom] }));
54
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(BusTray, { messages: busMessages, cols: termCols() }), _jsx(Transcript, { entries: messages, live: live }), activity, prompts, bottom] }));
54
55
  }
55
56
  // Entries the transcript window slides per wheel notch. A notch is one detent of the physical wheel; 3
56
57
  // entries keeps scrollback brisk without leaping past short exchanges.
@@ -60,7 +61,7 @@ const WHEEL_STEP = 3;
60
61
  // entries the bottom-anchored clip would otherwise hide), wheel-down returns toward the live bottom, and
61
62
  // any new output snaps straight back to it — you never get stranded in history while the answer grows.
62
63
  // Split out from App because useOnWheel must run inside the provider App itself returns.
63
- function FullscreenBody({ messages, live, activity, prompts, bottom }) {
64
+ function FullscreenBody({ messages, live, activity, prompts, bottom, busMessages }) {
64
65
  const rows = termRows();
65
66
  const [scrollBack, setScrollBack] = useState(0);
66
67
  // New settled output resets the view to the live bottom (messages.length only grows as entries settle).
@@ -70,5 +71,7 @@ function FullscreenBody({ messages, live, activity, prompts, bottom }) {
70
71
  ? Math.min(s + WHEEL_STEP, Math.max(0, messages.length - 1)) // clamp: the oldest entry stays reachable
71
72
  : Math.max(0, s - WHEEL_STEP));
72
73
  });
73
- return (_jsxs(Box, { flexDirection: "column", height: rows, children: [_jsxs(Box, { flexGrow: 1, flexDirection: "column", overflow: "hidden", justifyContent: "flex-end", children: [_jsx(Transcript, { entries: messages, live: live, bounded: true, scrollBack: scrollBack }), activity] }), prompts, bottom] }));
74
+ // BusTray is the FIRST child so it top-anchors at row 1 — its cards' absolute rows are then deterministic
75
+ // (trayLayout topRow=1), which is what makes click hit-testing reliable. It renders nothing when empty.
76
+ return (_jsxs(Box, { flexDirection: "column", height: rows, children: [_jsx(BusTray, { messages: busMessages, cols: termCols() }), _jsxs(Box, { flexGrow: 1, flexDirection: "column", overflow: "hidden", justifyContent: "flex-end", children: [_jsx(Transcript, { entries: messages, live: live, bounded: true, scrollBack: scrollBack }), activity] }), prompts, bottom] }));
74
77
  }
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // BusTray — live Switchboard messages surfaced in the Operator TUI as click-to-expand cards. Top-anchored
3
+ // in the fullscreen layout so each card's absolute terminal row is deterministic (topRow + Σ heights above),
4
+ // which is what makes mouse hit-testing reliable without Ink absolute-position measurement. Clicking a card
5
+ // toggles its body (the Phase-1 mouse layer in action). In inline mode (no mouse) the cards still render,
6
+ // just not clickable. Messages are DATA from other agents — shown, never executed.
7
+ import { useEffect, useState } from "react";
8
+ import { Box, Text } from "ink";
9
+ import { useMouse } from "./MouseProvider.js";
10
+ const MAX_BODY_LINES = 8; // cap an expanded card's body so one big message can't dominate the screen
11
+ function wrap(line, width) {
12
+ const w = Math.max(1, width);
13
+ if (line.length <= w)
14
+ return [line];
15
+ const out = [];
16
+ for (let i = 0; i < line.length; i += w)
17
+ out.push(line.slice(i, i + w));
18
+ return out;
19
+ }
20
+ /** Pure layout: assign each message a card with an absolute row (y) and height, given which ids are
21
+ * expanded and the terminal width. Deterministic top-to-bottom stacking from `topRow` — the basis for both
22
+ * render order and click hit-testing. Exported for unit tests. */
23
+ export function trayLayout(messages, expanded, cols, topRow = 1) {
24
+ const width = cols > 0 ? cols : 80;
25
+ const cards = [];
26
+ let y = topRow;
27
+ for (const msg of messages) {
28
+ const isExp = expanded.has(msg.id);
29
+ const bodyLines = isExp
30
+ ? msg.body.split("\n").flatMap((l) => wrap(l, width - 2)).slice(0, MAX_BODY_LINES)
31
+ : [];
32
+ const height = 1 + bodyLines.length;
33
+ cards.push({ msg, y, height, expanded: isExp, bodyLines });
34
+ y += height;
35
+ }
36
+ return cards;
37
+ }
38
+ function preview(body, cols) {
39
+ const one = body.replace(/\s+/g, " ").trim();
40
+ const budget = Math.max(10, (cols > 0 ? cols : 80) - 28);
41
+ return one.length > budget ? one.slice(0, budget - 1) + "…" : one;
42
+ }
43
+ /** The tray. `cols` is the terminal width (for wrapping + region width). Renders nothing when empty. */
44
+ export function BusTray({ messages, cols }) {
45
+ const { registerRegion, enabled } = useMouse();
46
+ const [expanded, setExpanded] = useState(() => new Set());
47
+ const cards = trayLayout(messages, expanded, cols);
48
+ // Register every card's clickable region imperatively (one effect, not a hook-per-card — the message
49
+ // count varies, which would violate rules-of-hooks). A left-press anywhere on a card toggles its body.
50
+ const sig = cards.map((c) => `${c.msg.id}:${c.y}:${c.height}`).join("|");
51
+ useEffect(() => {
52
+ if (!enabled || !cards.length)
53
+ return;
54
+ const disposers = cards.map((c) => registerRegion({ id: `bus:${c.msg.id}`, x: 1, y: c.y, width: Math.max(1, cols), height: c.height }, () => {
55
+ setExpanded((prev) => {
56
+ const next = new Set(prev);
57
+ if (next.has(c.msg.id))
58
+ next.delete(c.msg.id);
59
+ else
60
+ next.add(c.msg.id);
61
+ return next;
62
+ });
63
+ }));
64
+ return () => disposers.forEach((d) => d());
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ }, [enabled, registerRegion, cols, sig]);
67
+ if (!messages.length)
68
+ return null;
69
+ return (_jsx(Box, { flexDirection: "column", children: cards.map((c) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "cyan", children: [c.expanded ? "▾" : "▸", " ", "📨 ", c.msg.from, c.msg.subject ? ` [${c.msg.subject}]` : "", c.expanded ? "" : `: ${preview(c.msg.body, cols)}`, enabled && !c.expanded ? _jsx(Text, { dimColor: true, children: " \u00B7 click to expand" }) : null] }), c.expanded ? c.bodyLines.map((l, i) => _jsx(Text, { dimColor: true, children: " " + l }, i)) : null] }, c.msg.id))) }));
70
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.162",
3
+ "version": "0.1.163",
4
4
  "description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
5
5
  "type": "module",
6
6
  "bin": {