@0perator/operator 0.1.54 → 0.1.56

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,24 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on t
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.56 — 2026-09-22
8
+ - **Shift+Tab cycles the operating mode (Claude-Code parity).** AUTO (execute without asking) → MANUAL
9
+ (approve mutating tools via the gated policy + approve bridge) → PLAN (read-only research + a proposed
10
+ plan, nothing runs) → AUTO. A persistent dim hint under the input shows the current mode, and each
11
+ switch prints a one-line confirmation. Maps to the mobile Manual/Auto/Plan selector. New Session API:
12
+ setPermissionMode() rebuilds the policy at runtime (preserving tier + rules); plan mode was already native.
13
+ - Tests: 365/365.
14
+
15
+ ## 0.1.55 — 2026-09-22
16
+ - **Remote-engine auth — Operator now runs against a REMOTE engine.** The model call sent no
17
+ Authorization header, so it only worked against a local `:8097`; a thin client pointed at the
18
+ authed `api.axe.onl` gateway got 401. `aurora.ts` now injects the operator bearer for a non-loopback
19
+ base (never for local `:8097`), loaded once at boot from the keychain. Verified E2E: `chat()` →
20
+ `https://api.axe.onl` with the operator token returned a real completion. This is what lets a 4 GB
21
+ MacBook run Operator against JL1's Aurora (`KODE_AURORA=https://api.axe.onl` + `operator auth login`).
22
+ - Relay: `ownerSub` now read from the AuthGate's `account.external_id` for real per-owner session scoping.
23
+ - Tests: 365/365.
24
+
7
25
  ## 0.1.54 — 2026-09-22
8
26
  - **Fixed the mobile/JSCore purity gate (CI was red on main).** The persistent-shell bash tool imported
9
27
  `node:child_process` via a string-literal `import("node:...")`, which esbuild `--platform=neutral`
package/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ import { homedir, hostname } from "node:os";
24
24
  import { createHash } from "node:crypto";
25
25
  // RELEASE CHECKLIST (every bump): update this + package.json "version", ADD A CHANGELOG.md ENTRY
26
26
  // (improvements / fixes / tests), run the suite, then publish to npm + push both remotes.
27
- const VERSION = "0.1.54";
27
+ const VERSION = "0.1.56";
28
28
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
29
29
  const settings = loadSettings();
30
30
  // Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
@@ -52,6 +52,18 @@ if (sd) {
52
52
  // The searxng module reads this env flag in its own sync exit hook; project the setting so it applies.
53
53
  if (settings.services?.stopOnExit?.searxng === false)
54
54
  process.env.KODE_STOP_SEARXNG_ON_EXIT = "0";
55
+ // Remote-engine auth. When this Operator points at a REMOTE engine (KODE_AURORA=https://api.axe.onl),
56
+ // the gateway fronts the model with operator-token auth, so the model call must carry the bearer. Load
57
+ // it once at boot from the keychain (or KODE_OPERATOR_TOKEN) and hand it to the engine; a local :8097
58
+ // never receives it (aurora.ts only sends to a non-loopback base), so this is safe on JL1 and costs
59
+ // nothing there. This is what lets a thin client (a 4 GB MacBook) run Operator against JL1's Aurora.
60
+ try {
61
+ const { loadCredentials } = await import("./auth/store.js");
62
+ const { setOperatorToken } = await import("./engine/aurora.js");
63
+ const creds = await loadCredentials().catch(() => null);
64
+ setOperatorToken(process.env.KODE_OPERATOR_TOKEN || creds?.token || undefined);
65
+ }
66
+ catch { /* auth is optional — a local engine needs none */ }
55
67
  // Computer control (opt-in, macOS embodiment). When enabled: register the control tools into the shared
56
68
  // registry and compute permission rules. The FOREGROUND forces each computer_* tool to "ask" so every
57
69
  // action prompts the owner via the approve() bridge in <Root>; BACKGROUND sub-agents get them DENIED —
@@ -308,6 +320,9 @@ function Root() {
308
320
  const [bgAgents, setBgAgents] = useState([]);
309
321
  const [authUser, setAuthUser] = useState(""); // signed-in identity for the status rule
310
322
  const [planMode, setPlanMode] = useState(false); // /plan: read-only research + propose, shown as a status badge
323
+ // Operating mode, cycled with Shift+Tab (like Claude Code): auto (no gate) → manual (approve mutations)
324
+ // → plan (read-only + propose) → auto. Auto=bypass policy, Manual=gated policy, Plan=session plan mode.
325
+ const [opMode, setOpMode] = useState(settings.permissions.mode === "gated" ? "manual" : "auto");
311
326
  const [thinkMode, setThinkMode] = useState("off"); // /think, /ultrathink badge
312
327
  const [elapsed, setElapsed] = useState(0); // live seconds since the current turn started (ticked by a
313
328
  const turnStartRef = useRef(0); // timer, so the clock advances even during a long reasoning
@@ -994,6 +1009,25 @@ function Root() {
994
1009
  }, [sendTurn, handleSlash]);
995
1010
  submitRef.current = onSubmit;
996
1011
  const onQueue = useCallback((text) => { queued.current = queued.current ? `${queued.current}\n${text}` : text; }, []);
1012
+ // Shift+Tab cycles the operating mode (Claude-Code parity). auto→manual→plan→auto. Auto drives with
1013
+ // no approval gate; Manual gates mutating tools through the approve() bridge; Plan is read-only research.
1014
+ const onCycleMode = useCallback(() => {
1015
+ setOpMode((cur) => {
1016
+ const next = cur === "auto" ? "manual" : cur === "manual" ? "plan" : "auto";
1017
+ if (next === "plan") {
1018
+ session.setPlanMode(true);
1019
+ }
1020
+ else {
1021
+ session.setPlanMode(false);
1022
+ session.setPermissionMode(next === "auto" ? "bypass" : "gated");
1023
+ }
1024
+ setPlanMode(next === "plan");
1025
+ sys(next === "auto" ? "◆ mode → AUTO — I execute without asking (shift+tab to cycle)"
1026
+ : next === "manual" ? "◈ mode → MANUAL — I ask before mutating (writes/edits/shell) (shift+tab to cycle)"
1027
+ : "◔ mode → PLAN — read-only research + a proposed plan; nothing runs (shift+tab to cycle)");
1028
+ return next;
1029
+ });
1030
+ }, [sys]);
997
1031
  const onInterrupt = useCallback(() => {
998
1032
  if (statusRef.current === "idle") {
999
1033
  bg.dispose();
@@ -1033,7 +1067,7 @@ function Root() {
1033
1067
  ? `${spin} reading your prompt… (${fmtDuration(elapsed)})`
1034
1068
  : `${spin} ${fmtMeta(elapsed, liveTok)}`
1035
1069
  : metrics;
1036
- return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, liveTools: liveTools, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, question: question, modelPicker: modelPicker, onApprovalDecide: (allow, always) => {
1070
+ return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, liveTools: liveTools, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, opMode: opMode, approval: approval, question: question, modelPicker: modelPicker, onApprovalDecide: (allow, always) => {
1037
1071
  const cur = approval;
1038
1072
  if (cur)
1039
1073
  settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
@@ -1,3 +1,18 @@
1
+ // A remote engine (api.axe.onl) fronts the model with gateway auth; a local :8097 does not. Only a
2
+ // non-loopback base needs (and should ever receive) the operator bearer, so a token is never sent to
3
+ // a local llama-server and the header is omitted entirely when there is nothing to send.
4
+ function isRemoteBase(base) {
5
+ return !/^https?:\/\/(127\.0\.0\.1|localhost|\[::1\])(:\d+)?(\/|$)/.test(base);
6
+ }
7
+ // One operator identity per process. The node CLI sets this at boot from the keychain
8
+ // (setOperatorToken); browser/JSCore hosts inject per-call via AuroraOpts.token or not at all.
9
+ // A local :8097 never receives it (isRemoteBase gate), so it is safe to set unconditionally.
10
+ let _operatorToken;
11
+ export function setOperatorToken(token) { _operatorToken = token || undefined; }
12
+ function authHeaders(o) {
13
+ const token = o.token ?? _operatorToken;
14
+ return token && isRemoteBase(o.base) ? { Authorization: `Bearer ${token}` } : {};
15
+ }
1
16
  // ---------------------------------------------------------------------------
2
17
  // Decode-time degeneration guard (SPEC §1). This is NOT a sampling penalty — it changes no
3
18
  // logits and touches no request knob, so a healthy model is completely unaffected. It only
@@ -71,7 +86,7 @@ function requestBody(messages, o, stream) {
71
86
  async function* streamDeltas(messages, o) {
72
87
  const res = await fetch(`${o.base}/v1/chat/completions`, {
73
88
  method: "POST",
74
- headers: { "Content-Type": "application/json" },
89
+ headers: { "Content-Type": "application/json", ...authHeaders(o) },
75
90
  body: requestBody(messages, o, true),
76
91
  signal: o.signal, // SPEC §9 interrupt parity: tears down the in-flight stream on abort, not at the next loop boundary
77
92
  });
package/dist/session.js CHANGED
@@ -85,7 +85,8 @@ export class Session {
85
85
  localSchemas;
86
86
  hub;
87
87
  tools;
88
- policy;
88
+ policy; // rebuilt by setPermissionMode (Shift+Tab mode cycle)
89
+ permissionCfg = { mode: "bypass" }; // base config; mode is swapped at runtime
89
90
  approve;
90
91
  telemetry;
91
92
  eventSink;
@@ -135,7 +136,8 @@ export class Session {
135
136
  this.wantRecall = cfg.recall ?? true;
136
137
  this.wantMcp = cfg.mcp === true || !!cfg.mcpHub;
137
138
  this.hub = cfg.mcpHub;
138
- this.policy = new PermissionPolicy(cfg.permissions);
139
+ this.permissionCfg = cfg.permissions ?? { mode: "bypass" };
140
+ this.policy = new PermissionPolicy(this.permissionCfg);
139
141
  this.approve = cfg.approve;
140
142
  this.telemetry = new Telemetry(cfg.telemetry);
141
143
  this.eventSink = cfg.eventSink;
@@ -192,6 +194,19 @@ export class Session {
192
194
  inPlanMode() {
193
195
  return this.planMode;
194
196
  }
197
+ /** Runtime permission-mode switch (Shift+Tab mode cycle). Rebuilds the policy + tool executor,
198
+ * preserving the base tier + rules; only the mode changes. Plan mode is separate (setPlanMode) and
199
+ * takes precedence in buildTools while active. */
200
+ setPermissionMode(mode) {
201
+ if (this.permissionCfg.mode === mode)
202
+ return;
203
+ this.permissionCfg = { ...this.permissionCfg, mode };
204
+ this.policy = new PermissionPolicy(this.permissionCfg);
205
+ this.tools = this.buildTools();
206
+ }
207
+ currentPermissionMode() {
208
+ return this.policy.currentMode();
209
+ }
195
210
  /** Set extended-reasoning mode (/think, /ultrathink). "think" re-enables Aurora's native reasoning for
196
211
  * each turn; "ultrathink" also pushes for deeper step-by-step reasoning via the system prompt. */
197
212
  setThinkMode(mode) {
package/dist/ui/App.js CHANGED
@@ -16,7 +16,7 @@ import { QuestionPrompt } from "./QuestionPrompt.js";
16
16
  // calls at once; anything past the cap is summarized as a count instead of another row.
17
17
  const MAX_LIVE_TOOL_ROWS = 6;
18
18
  export function App(props) {
19
- const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide, question = null, modelPicker = null } = props;
19
+ const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, onSubmit, onQueue, onInterrupt, onCycleMode, opMode, approval = null, onApprovalDecide, question = null, modelPicker = null } = props;
20
20
  const thinking = status === "thinking" || status === "streaming";
21
21
  // A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
22
22
  // a lone call isn't worth a bordered block, the braille spinner + name already says enough.
@@ -24,5 +24,5 @@ export function App(props) {
24
24
  const showSpinner = status === "recovering" || (status === "executing" && !showParallelRows) || thinking;
25
25
  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 })
26
26
  : status === "executing" ? _jsx(StepSpinner, { active: true, label: stepLabel })
27
- : _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), showParallelRows && (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "gray", paddingX: 1, children: [_jsxs(Text, { dimColor: true, children: ["running ", liveTools.length, " tools in parallel"] }), liveTools.slice(0, MAX_LIVE_TOOL_ROWS).map((step) => _jsx(ToolStep, { step: step }, step.id)), liveTools.length > MAX_LIVE_TOOL_ROWS ? _jsxs(Text, { dimColor: true, children: [" +", liveTools.length - MAX_LIVE_TOOL_ROWS, " more\u2026"] }) : null] })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker }), _jsx(InputRule, {})] }));
27
+ : _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), showParallelRows && (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "gray", paddingX: 1, children: [_jsxs(Text, { dimColor: true, children: ["running ", liveTools.length, " tools in parallel"] }), liveTools.slice(0, MAX_LIVE_TOOL_ROWS).map((step) => _jsx(ToolStep, { step: step }, step.id)), liveTools.length > MAX_LIVE_TOOL_ROWS ? _jsxs(Text, { dimColor: true, children: [" +", liveTools.length - MAX_LIVE_TOOL_ROWS, " more\u2026"] }) : null] })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, opMode: opMode, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker }), _jsx(InputRule, {})] }));
28
28
  }
@@ -16,7 +16,7 @@ import { Box, Text, useInput, useStdin } from "ink";
16
16
  import { InputHistory } from "./useInputHistory.js";
17
17
  const PASTE_START = "\x1b[200~";
18
18
  const PASTE_END = "\x1b[201~";
19
- export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, prompt = "› " }) {
19
+ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, onCycleMode, opMode, prompt = "› " }) {
20
20
  const [value, setValue] = useState("");
21
21
  const pasteCountRef = useRef(0);
22
22
  const pasteBufRef = useRef(null); // non-null while inside a bracketed paste
@@ -66,6 +66,12 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
66
66
  return; // an approval prompt owns the keyboard — don't consume or echo keystrokes
67
67
  if (pasteBufRef.current !== null)
68
68
  return; // raw paste bytes are owned by the data handler above
69
+ // Shift+Tab cycles the operating mode (Claude-Code parity). Terminals send backtab as ESC[Z, which
70
+ // Ink surfaces as key.tab + key.shift. Handled before text so it never lands a character in the draft.
71
+ if (key.tab && key.shift) {
72
+ onCycleMode?.();
73
+ return;
74
+ }
69
75
  if ((key.ctrl && ch === "c") || key.escape) {
70
76
  onInterrupt();
71
77
  return;
@@ -120,7 +126,7 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
120
126
  // Surface any image/video paths in the draft as attachment chips so the user can see multiple
121
127
  // media are attached (dragged/pasted paths land in the text). De-duped, basename only.
122
128
  const attachments = Array.from(new Set(value.match(MEDIA_RE) ?? []));
123
- return (_jsxs(Box, { flexDirection: "column", children: [lines.map((line, i) => (_jsxs(Text, { children: [i === 0 ? prompt : " ", line, i === lines.length - 1 ? "▌" : ""] }, i))), attachments.length > 0 && (_jsx(Text, { dimColor: true, children: " " + attachments.map((a) => `${VIDEO_RE.test(a) ? "▷ vid" : "◇ img"}:${a.split("/").pop()}`).join(" ") }))] }));
129
+ return (_jsxs(Box, { flexDirection: "column", children: [lines.map((line, i) => (_jsxs(Text, { children: [i === 0 ? prompt : " ", line, i === lines.length - 1 ? "▌" : ""] }, i))), attachments.length > 0 && (_jsx(Text, { dimColor: true, children: " " + attachments.map((a) => `${VIDEO_RE.test(a) ? "▷ vid" : "◇ img"}:${a.split("/").pop()}`).join(" ") })), opMode && (_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "◆ auto" : opMode === "manual" ? "◈ manual" : "◔ plan"} · shift+tab to cycle` }))] }));
124
130
  }
125
131
  // Recognize media file paths in the draft. IMAGE covers the common still formats, VIDEO the moving
126
132
  // ones; a path matching VIDEO is chipped as video, otherwise image. Extensions only — no I/O.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.54",
3
+ "version": "0.1.56",
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": {