@0perator/operator 0.1.33 → 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.33";
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).
@@ -149,6 +149,7 @@ const HELP = [
149
149
  " /services ensure/inspect the service lever (aurora+autopilot+searxng); /services stop",
150
150
  " /audit [n] recent tool + control-plane events from the audit trail (default 15)",
151
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)",
152
153
  " /compact force-compact the conversation now",
153
154
  " /remember <note> store a note to recall in future sessions",
154
155
  " /memory [query] show remembered notes (all, or matching query)",
@@ -185,6 +186,7 @@ function Root() {
185
186
  // setLive re-render that already happens, so there's no performance cost and no animation timer.
186
187
  const [bgAgents, setBgAgents] = useState([]);
187
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
188
190
  const [elapsed, setElapsed] = useState(0); // live seconds since the current turn started (ticked by a
189
191
  const turnStartRef = useRef(0); // timer, so the clock advances even during a long reasoning
190
192
  // phase where no content tokens stream — that was the "timer stuck" bug (Ink only re-renders on deltas).
@@ -555,6 +557,15 @@ function Root() {
555
557
  sys("endpoints:\n" + s.endpoints().map((e) => ` ${h[e.name] ? "●" : "○"} ${e.name} ${e.base} ${e.model} ctx ${e.ctxWindow.toLocaleString()}`).join("\n"));
556
558
  break;
557
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
+ }
558
569
  case "audit": {
559
570
  // The human-supervisor view of the frozen event stream: recent tool decisions + control events
560
571
  // (tier denials, signature lines, RC) straight from the audit JSONL. Read-only.
@@ -730,7 +741,7 @@ function Root() {
730
741
  const liveMetrics = active
731
742
  ? `${SPIN[Math.floor(elapsed * 4) % SPIN.length]} ${fmtMeta(elapsed, liveTok)}`
732
743
  : metrics;
733
- 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) => {
734
745
  const cur = approval;
735
746
  if (cur)
736
747
  settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
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() {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.33",
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": {