@0perator/operator 0.1.32 → 0.1.34

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/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
18
18
  import { join } from "node:path";
19
19
  import { homedir, hostname } from "node:os";
20
20
  import { createHash } from "node:crypto";
21
- const VERSION = "0.1.32";
21
+ const VERSION = "0.1.34";
22
22
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
23
23
  const settings = loadSettings();
24
24
  // Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
@@ -104,7 +104,7 @@ function buildRouter() {
104
104
  }
105
105
  // Project context: auto-load a per-repo instructions file (AGENTS.md / CLAUDE.md / .operator/AGENTS.md)
106
106
  // from the working dir and append it to the system prompt, so Operator picks up house rules, conventions
107
- // and build commands the way Claude Code / Codex do. First match wins; capped so a huge file can't blow
107
+ // and build commands the way modern coding agents do. First match wins; capped so a huge file can't blow
108
108
  // the prompt. Best-effort — a missing file is normal.
109
109
  function loadProjectContext() {
110
110
  for (const name of ["AGENTS.md", "CLAUDE.md", ".operator/AGENTS.md", "OPERATOR.md"]) {
@@ -118,7 +118,11 @@ function loadProjectContext() {
118
118
  return "";
119
119
  }
120
120
  const SYSTEM_PROMPT = (settings.systemPrompt ??
121
- `You are Operator, a terse local terminal coding agent. Use your tools to inspect and edit the ` +
121
+ `You are Operator, AXE's terminal coding agent — built by AXE, running on AXE's Aurora model. Refer to ` +
122
+ `yourself as Operator and to the platform as AXE; never call yourself or the platform Claude, ` +
123
+ `Anthropic, or any other vendor. When you encounter files or directories on disk named "claude", ` +
124
+ `".claude", "anthropic", etc., describe them neutrally (by their literal path, or as "AI tooling ` +
125
+ `files") — do not attribute them to a vendor. Use your tools to inspect and edit the ` +
122
126
  `workspace; prefer doing over explaining. Answer concisely.\n## This machine\nWorking dir: ${process.cwd()}` +
123
127
  `\nContext window: 1,048,576 tokens (1M) — you run on the Aurora model served locally with a full ` +
124
128
  `1M-token context. You can hold very large files and long histories; do not claim a smaller limit.` +
@@ -145,6 +149,7 @@ const HELP = [
145
149
  " /services ensure/inspect the service lever (aurora+autopilot+searxng); /services stop",
146
150
  " /audit [n] recent tool + control-plane events from the audit trail (default 15)",
147
151
  " /dashboard launch the live swarm console (watches every Operator session)",
152
+ " /plan plan mode: read-only research + propose a plan (/plan again to execute)",
148
153
  " /compact force-compact the conversation now",
149
154
  " /remember <note> store a note to recall in future sessions",
150
155
  " /memory [query] show remembered notes (all, or matching query)",
@@ -181,6 +186,7 @@ function Root() {
181
186
  // setLive re-render that already happens, so there's no performance cost and no animation timer.
182
187
  const [bgAgents, setBgAgents] = useState([]);
183
188
  const [authUser, setAuthUser] = useState(""); // signed-in identity for the status rule
189
+ const [planMode, setPlanMode] = useState(false); // /plan: read-only research + propose, shown as a status badge
184
190
  const [elapsed, setElapsed] = useState(0); // live seconds since the current turn started (ticked by a
185
191
  const turnStartRef = useRef(0); // timer, so the clock advances even during a long reasoning
186
192
  // phase where no content tokens stream — that was the "timer stuck" bug (Ink only re-renders on deltas).
@@ -551,6 +557,15 @@ function Root() {
551
557
  sys("endpoints:\n" + s.endpoints().map((e) => ` ${h[e.name] ? "●" : "○"} ${e.name} ${e.base} ${e.model} ctx ${e.ctxWindow.toLocaleString()}`).join("\n"));
552
558
  break;
553
559
  }
560
+ case "plan": {
561
+ const on = !s.inPlanMode();
562
+ s.setPlanMode(on);
563
+ setPlanMode(on);
564
+ sys(on
565
+ ? "◔ plan mode ON — I'll research read-only and propose a plan; writes/edits/shell mutations are blocked. /plan again to approve + execute."
566
+ : "plan mode OFF — back to normal execution.");
567
+ break;
568
+ }
554
569
  case "audit": {
555
570
  // The human-supervisor view of the frozen event stream: recent tool decisions + control events
556
571
  // (tier denials, signature lines, RC) straight from the audit JSONL. Read-only.
@@ -726,7 +741,7 @@ function Root() {
726
741
  const liveMetrics = active
727
742
  ? `${SPIN[Math.floor(elapsed * 4) % SPIN.length]} ${fmtMeta(elapsed, liveTok)}`
728
743
  : metrics;
729
- return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, authUser: authUser, tier: EVENT_ACTOR.tier, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, onApprovalDecide: (allow, always) => {
744
+ return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, onApprovalDecide: (allow, always) => {
730
745
  const cur = approval;
731
746
  if (cur)
732
747
  settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
@@ -738,7 +753,7 @@ if (process.argv[2] === "auth") {
738
753
  const { runAuth } = await import("./auth/commands.js");
739
754
  process.exit(await runAuth(process.argv.slice(3)));
740
755
  }
741
- // `operator update` (bareword, like `claude update`) and `operator --update` both self-update.
756
+ // `operator update` (bareword) and `operator --update` both self-update.
742
757
  if (process.argv[2] === "update" || process.argv.includes("--update")) {
743
758
  const { runUpdate } = await import("./update.js");
744
759
  process.exit(await runUpdate());
package/dist/session.js CHANGED
@@ -63,6 +63,7 @@ export class Session {
63
63
  memory;
64
64
  wantRecall;
65
65
  recallBlock = ""; // memory recalled on the first turn, folded into the system prompt thereafter
66
+ planMode = false; // /plan: research read-only + propose a plan, no mutations until the owner approves
66
67
  recalled = false;
67
68
  constructor(cfg = {}) {
68
69
  // Per-session tool registry: the base set, plus `spawn_agent` when the shell provides a delegate
@@ -91,14 +92,40 @@ export class Session {
91
92
  /** The effective system prompt: the base persona plus any memory recalled this session. Injected as
92
93
  * ONE system prompt — never a second system message, which 400s llama.cpp's chat template. */
93
94
  sys() {
94
- if (!this.recallBlock)
95
- return this.systemPrompt;
96
- return this.systemPrompt ? `${this.systemPrompt}\n\n${this.recallBlock}` : this.recallBlock;
95
+ const base = this.recallBlock
96
+ ? (this.systemPrompt ? `${this.systemPrompt}\n\n${this.recallBlock}` : this.recallBlock)
97
+ : this.systemPrompt;
98
+ if (!this.planMode)
99
+ return base;
100
+ // Plan mode: the model researches read-only and proposes a plan; the read-only enforcement is in
101
+ // buildTools (mutating tools are denied), and this directive shapes the output shape.
102
+ const plan = `\n\n## PLAN MODE (active)\nYou are in plan mode. Investigate with READ-ONLY tools only ` +
103
+ `(read/grep/list/search) — file writes, edits, shell mutations and git are BLOCKED and will be ` +
104
+ `refused. Do NOT attempt to change anything. When you understand the task, STOP and present a ` +
105
+ `concise, numbered plan of the exact steps you would take, then wait. The owner exits plan mode ` +
106
+ `(/plan) to let you execute.`;
107
+ return (base ?? "") + plan;
97
108
  }
98
109
  /** Compose the tool executor: local tools + MCP (composite) with the permission/audit layer on top.
99
- * withPermissions returns the composite UNCHANGED when the policy is inert (bypass) — zero overhead. */
110
+ * withPermissions returns the composite UNCHANGED when the policy is inert (bypass) — zero overhead.
111
+ * In plan mode a read-only gated policy (no approver → mutating tools fail-safe deny) overrides the
112
+ * normal policy, so nothing can be modified regardless of the owner's mode/tier. */
100
113
  buildTools() {
101
- return withPermissions(withMcp(this.executor, this.hub), this.policy, { approve: this.approve, sink: this.eventSink, actor: this.eventActor, session: this.sessionId });
114
+ const policy = this.planMode
115
+ ? new PermissionPolicy({ mode: "gated", tier: this.policy.currentTier() }) // read-only: safe tools allow, mutating ask→deny (no approve fn)
116
+ : this.policy;
117
+ const approve = this.planMode ? undefined : this.approve; // no approver in plan mode = hard read-only
118
+ return withPermissions(withMcp(this.executor, this.hub), policy, { approve, sink: this.eventSink, actor: this.eventActor, session: this.sessionId });
119
+ }
120
+ /** Enter/leave plan mode (/plan). Read-only research + a proposed plan until the owner approves. */
121
+ setPlanMode(on) {
122
+ if (this.planMode === on)
123
+ return;
124
+ this.planMode = on;
125
+ this.tools = this.buildTools();
126
+ }
127
+ inPlanMode() {
128
+ return this.planMode;
102
129
  }
103
130
  /** Is the currently-selected endpoint reachable? Lets the shell fail clearly before a turn. */
104
131
  health() {
@@ -137,16 +137,30 @@ async function grepSearch(args) {
137
137
  const path = str(args.path, ".");
138
138
  if (!pattern)
139
139
  return "error: no pattern given";
140
- const flags = ["-rn", "-I", "--exclude-dir=.git", "--exclude-dir=node_modules", "--exclude=.operator-session.json"];
140
+ // -s suppresses errors for unreadable/special files (sockets, FIFOs, permission-denied) that a
141
+ // recursive grep over a real dir (e.g. /private/tmp, full of IPC sockets) inevitably hits; without it
142
+ // grep exits 2 and the tool used to report a hard failure even when it HAD found matches.
143
+ const flags = ["-rns", "-I", "--exclude-dir=.git", "--exclude-dir=node_modules", "--exclude=.operator-session.json"];
141
144
  if (args.glob)
142
145
  flags.push(`--include=${str(args.glob)}`);
143
146
  try {
144
- const { stdout } = await pexecFile("grep", [...flags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024 });
147
+ // A hard timeout+SIGKILL guards against a pathological special file grep can BLOCK on: a socket
148
+ // errors immediately, but a FIFO with no writer hangs grep on open forever. Killed grep still leaves
149
+ // whatever it matched in stdout (handled in the catch), so a real dir with a stray pipe can't wedge
150
+ // the agent.
151
+ const { stdout } = await pexecFile("grep", [...flags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024, timeout: 20_000, killSignal: "SIGKILL" });
145
152
  return capMatches(stdout);
146
153
  }
147
154
  catch (e) {
155
+ // grep exit codes: 0=match, 1=no match, 2=error. With -r, grep still emits every match it DID find
156
+ // before exiting 2 on an unreadable file (or being killed on timeout) — so prefer stdout when present;
157
+ // only a truly empty result is an error worth surfacing.
158
+ if (e.stdout && String(e.stdout).trim())
159
+ return capMatches(String(e.stdout));
148
160
  if (e.code === 1)
149
161
  return "(no matches)";
162
+ if (e.killed)
163
+ return "(search timed out — narrow the path; a blocking special file may be present)";
150
164
  return `error: ${e.stderr || e.message}`;
151
165
  }
152
166
  }
package/dist/ui/App.js CHANGED
@@ -9,10 +9,10 @@ import { StepSpinner, RecoverSpinner } from "./ActivitySpinner.js";
9
9
  import { BgPanel } from "./BgPanel.js";
10
10
  import { ApprovalPrompt } from "./ApprovalPrompt.js";
11
11
  export function App(props) {
12
- const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, authUser, tier, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide } = props;
12
+ const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, authUser, tier, planMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide } = props;
13
13
  const thinking = status === "thinking" || status === "streaming";
14
14
  const showSpinner = status === "recovering" || status === "executing" || thinking;
15
15
  return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), showSpinner && (_jsx(Box, { marginTop: 1, marginBottom: 1, children: status === "recovering" ? _jsx(RecoverSpinner, { active: true, label: stepLabel })
16
16
  : status === "executing" ? _jsx(StepSpinner, { active: true, label: stepLabel })
17
- : _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval }), _jsx(InputRule, {})] }));
17
+ : _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval }), _jsx(InputRule, {})] }));
18
18
  }
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
- export function StatusRule({ route, ctxPct, version, build, user, tier }) {
3
+ export function StatusRule({ route, ctxPct, version, build, user, tier, planMode }) {
4
4
  const who = user ? `⬤ ${user} · ` : "";
5
5
  const seat = tier && tier !== "admin" ? `⛨ ${tier} · ` : ""; // a narrowed seat is visible; the owner's admin is not
6
- // Info block: seat · identity · route · ctx% · version. Kept as one string so the width math is exact.
7
- const info = `${seat}${who}${route} · ${Math.round(ctxPct)}% · v${version}${build ? ` ·${build}` : ""}`;
6
+ const plan = planMode ? `◔ plan · ` : ""; // read-only research mode is visible while active
7
+ // Info block: plan · seat · identity · route · ctx% · version. One string so the width math is exact.
8
+ const info = `${plan}${seat}${who}${route} · ${Math.round(ctxPct)}% · v${version}${build ? ` ·${build}` : ""}`;
8
9
  // The full right-hand content, styled below in segments (✷ magenta, OPERATOR bold, info dim). This
9
10
  // plain string is only used to measure width so the leading rule fills precisely.
10
11
  const right = `✷ OPERATOR · ${info} ─`;
package/dist/update.js CHANGED
@@ -1,4 +1,4 @@
1
- // `operator update` — self-update, mirroring `claude update`. Two install shapes:
1
+ // `operator update` — self-update (bareword, like a CLI self-updater). Two install shapes:
2
2
  // • npm-global → the published package on the registry; update = reinstall @latest.
3
3
  // • source/dev → a git checkout linked via `npm link`; update = pull + rebuild.
4
4
  // We detect the shape from where THIS module resolves: a checkout still has a .git above it;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
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": {