@0perator/operator 0.1.17 → 0.1.21

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
@@ -7,6 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  import { useCallback, useEffect, useRef, useState } from "react";
8
8
  import { render, Box, Text, useApp } from "ink";
9
9
  import { App } from "./ui/index.js";
10
+ import { mastheadLines } from "./ui/Masthead.js";
10
11
  import { Session } from "./session.js";
11
12
  import { AuroraRouter } from "./router/router.js";
12
13
  import { BackgroundAgents } from "./background/index.js";
@@ -15,7 +16,7 @@ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
15
16
  import { join } from "node:path";
16
17
  import { homedir } from "node:os";
17
18
  import { createHash } from "node:crypto";
18
- const VERSION = "0.1.17";
19
+ const VERSION = "0.1.21";
19
20
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
20
21
  const settings = loadSettings();
21
22
  // Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
@@ -527,4 +528,7 @@ if (!process.stdin.isTTY) {
527
528
  process.stderr.write("kode-tsi needs an interactive terminal (TTY). For scripted turns, import { Session } from kode-tsi.\n");
528
529
  process.exit(1);
529
530
  }
531
+ // Boot masthead (design #29) — printed ONCE to stdout before Ink mounts, so the big gradient wordmark
532
+ // lives in permanent scrollback and never enters Ink's dynamic-frame redraw (reflow-safe by construction).
533
+ process.stdout.write(mastheadLines(`aurora · 1M · v${VERSION}`).join("\n") + "\n");
530
534
  render(_jsx(Root, {}));
@@ -86,20 +86,31 @@ const nodeImport = (m) => import(/* @vite-ignore */ m);
86
86
  * Handles `file_write` to a brand-new path whose parent dir is itself a symlink into a denylisted
87
87
  * root (e.g. workspace/keys_dir -> ~/.ssh, writing keys_dir/id_rsa.new). */
88
88
  async function realPathOf(p) {
89
- const parts = p.split("/");
90
- for (let i = parts.length; i >= 2; i--) {
91
- const head = parts.slice(0, i).join("/");
92
- const tail = parts.slice(i).join("/");
93
- try {
94
- const { realpath } = await nodeImport("node:fs/promises");
95
- const base = await realpath(head);
96
- return tail ? `${base}/${tail}` : base;
97
- }
98
- catch {
99
- /* this ancestor doesn't exist; walk up one level */
89
+ // Resolve symlinks COMPONENT BY COMPONENT via readlink. Plain realpath() ENOENTs on a dangling link
90
+ // (e.g. workspace/link -> ~/.ssh/id_rsa on a box where ~/.ssh doesn't exist yet), so it would MISS a
91
+ // symlink that launders a write/read into a denied path that doesn't exist. Walking + readlink'ing each
92
+ // segment lexically catches those too, and is environment-independent (fixed the CI failure where the
93
+ // runner has no ~/.ssh). `..` was already normalized by resolve() before this is called.
94
+ const fs = await nodeImport("node:fs/promises");
95
+ const parts = p.split("/").filter(Boolean);
96
+ let cur = "";
97
+ for (const seg of parts) {
98
+ cur = `${cur}/${seg}`;
99
+ for (let hops = 0; hops < 16; hops++) {
100
+ let st;
101
+ try {
102
+ st = await fs.lstat(cur);
103
+ }
104
+ catch {
105
+ break;
106
+ } // doesn't exist yet — nothing more to follow
107
+ if (!st.isSymbolicLink())
108
+ break;
109
+ const tgt = await fs.readlink(cur);
110
+ cur = tgt.startsWith("/") ? resolve(tgt) : resolve(`${cur.slice(0, cur.lastIndexOf("/") + 1)}${tgt}`);
100
111
  }
101
112
  }
102
- return p;
113
+ return cur || "/";
103
114
  }
104
115
  /** The full guard: lexical check, then — only when it passes — a realpath re-check so a symlink
105
116
  * cannot launder a write into a protected path (proven bypass, 2026-09-17 review). */
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Box, Text, useInput } from "ink";
3
- import { Header } from "./Header.js";
3
+ import { Masthead } from "./Masthead.js";
4
4
  export function AuthScreen({ version, ctxWindow, authBase, pending, error, onChoice }) {
5
5
  useInput((input, key) => {
6
6
  if (pending)
@@ -13,5 +13,5 @@ export function AuthScreen({ version, ctxWindow, authBase, pending, error, onCho
13
13
  else if (key.return || c === "g")
14
14
  onChoice("guest");
15
15
  });
16
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Header, { version: version, ctxWindow: ctxWindow }), _jsx(Box, { marginTop: 1, flexDirection: "column", paddingLeft: 1, children: pending ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["Signing in \u2014 open ", _jsx(Text, { color: "cyanBright", children: pending.url })] }), _jsxs(Text, { children: ["and enter code ", _jsx(Text, { bold: true, color: "whiteBright", children: pending.userCode })] }), _jsx(Text, { dimColor: true, children: "Waiting for approval in your browser\u2026 (Esc to cancel)" })] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { color: "whiteBright", children: "Welcome to Operator." }), _jsx(Text, { dimColor: true, children: "A local terminal coding agent on your own Aurora model." }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: "magentaBright", bold: true, children: " s" }), " Sign in ", _jsx(Text, { dimColor: true, children: "\u2014 connect your account (browser approval)" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "magentaBright", bold: true, children: " u" }), " Create account ", _jsxs(Text, { dimColor: true, children: ["\u2014 register at ", authBase.replace(/^https?:\/\//, "")] })] }), _jsxs(Text, { children: [_jsx(Text, { color: "magentaBright", bold: true, children: " \u21B5" }), " Continue as guest ", _jsx(Text, { dimColor: true, children: "\u2014 no account needed; sign in later with /login" })] })] }), error ? _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "red", children: error }) }) : null] })) })] }));
16
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Masthead, { info: `aurora${ctxWindow && ctxWindow >= 1_000_000 ? " · 1M" : ""} · v${version}` }), _jsx(Box, { marginTop: 1, flexDirection: "column", paddingLeft: 1, children: pending ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: ["Signing in \u2014 open ", _jsx(Text, { color: "cyanBright", children: pending.url })] }), _jsxs(Text, { children: ["and enter code ", _jsx(Text, { bold: true, color: "whiteBright", children: pending.userCode })] }), _jsx(Text, { dimColor: true, children: "Waiting for approval in your browser\u2026 (Esc to cancel)" })] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { color: "whiteBright", children: "Welcome to Operator." }), _jsx(Text, { dimColor: true, children: "A local terminal coding agent on your own Aurora model." }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: "magentaBright", bold: true, children: " s" }), " Sign in ", _jsx(Text, { dimColor: true, children: "\u2014 connect your account (browser approval)" })] }), _jsxs(Text, { children: [_jsx(Text, { color: "magentaBright", bold: true, children: " u" }), " Create account ", _jsxs(Text, { dimColor: true, children: ["\u2014 register at ", authBase.replace(/^https?:\/\//, "")] })] }), _jsxs(Text, { children: [_jsx(Text, { color: "magentaBright", bold: true, children: " \u21B5" }), " Continue as guest ", _jsx(Text, { dimColor: true, children: "\u2014 no account needed; sign in later with /login" })] })] }), error ? _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "red", children: error }) }) : null] })) })] }));
17
17
  }
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Boot masthead (SPEC §6) — header design #29 "Gradient Constellation": the OPERATOR wordmark at full
3
+ // block-letter scale, each letter washed one step along a violet→magenta ramp, framed above and below by
4
+ // a dim constellation star field. Two renderers share ONE source of truth (GLYPHS/GRAD/STAR_*):
5
+ //
6
+ // • mastheadLines() — chalk-colored plain strings, printed ONCE to stdout at boot in cli.tsx BEFORE
7
+ // Ink mounts. This is why the big 5-row wordmark is reflow-safe: it lands in terminal scrollback as
8
+ // static text and never enters Ink's per-keystroke dynamic-frame redraw (the class of bug that moved
9
+ // the input to the top of the screen when a line hit exact terminal width).
10
+ // • <Masthead/> — the same design as Ink <Box>/<Text>, for the static AuthScreen (no live composer
11
+ // below it, so no reflow hazard). NOT used inside App's dynamic tree.
12
+ import React from "react";
13
+ import { Box, Text } from "ink";
14
+ import chalk from "chalk";
15
+ // 5-row block glyphs (█ U+2588, BMP). Only the letters of OPERATOR are needed.
16
+ const GLYPHS = {
17
+ O: [" ███ ", "█ █", "█ █", "█ █", " ███ "],
18
+ P: ["████ ", "█ █", "████ ", "█ ", "█ "],
19
+ E: ["█████", "█ ", "████ ", "█ ", "█████"],
20
+ R: ["████ ", "█ █", "████ ", "█ █ ", "█ █"],
21
+ A: [" ███ ", "█ █", "█████", "█ █", "█ █"],
22
+ T: ["█████", " █ ", " █ ", " █ ", " █ "],
23
+ };
24
+ // violet→magenta ramp, one step per letter of OPERATOR (8 letters, 8 stops).
25
+ const GRAD = ["#5f4a80", "#7a5fb0", "#9068c9", "#a878e0", "#b98cf0", "#c07cff", "#c88fff", "#d3a6ff"];
26
+ const WORD = "OPERATOR";
27
+ const GLYPH_W = 5; // each block glyph is 5 cols wide
28
+ const WORD_W = WORD.length * GLYPH_W + (WORD.length - 1); // 8*5 + 7 gaps = 47 visible cols
29
+ // Constellation star rows framing the wordmark (✦ U+2726, ✧ U+2727, · U+00B7 — all BMP, render on macOS).
30
+ const STAR_TOP = "· ✦ ✧ · ✦ ✧ ·";
31
+ const STAR_BOT = " ✧ · ✦ · ✧ ✦ ·";
32
+ const STAR = "✷"; // AXE signal star (brand glyph, matches ThinkingSpinner)
33
+ /** The 5 block-wordmark rows as arrays of per-letter cells (cell i belongs to WORD[i], colored GRAD[i]). */
34
+ function wordCells() {
35
+ const rows = [[], [], [], [], []];
36
+ for (let i = 0; i < WORD.length; i++) {
37
+ const g = GLYPHS[WORD[i]];
38
+ for (let r = 0; r < 5; r++)
39
+ rows[r].push(g[r]);
40
+ }
41
+ return rows;
42
+ }
43
+ function pad(cols, visibleWidth) {
44
+ return " ".repeat(Math.max(0, Math.floor((cols - visibleWidth) / 2)));
45
+ }
46
+ /**
47
+ * Boot banner as chalk-colored lines for a one-time stdout print. `info` is the dim tagline
48
+ * (e.g. "aurora · 1M · v0.1.21"). Falls back to a compact one-line wordmark on a narrow terminal
49
+ * so the block letters never wrap (a wrapped glyph row is unreadable).
50
+ */
51
+ export function mastheadLines(info, cols = process.stdout.columns ?? 80) {
52
+ if (cols < WORD_W + 4) {
53
+ // compact fallback: single-line gradient wordmark + tagline
54
+ const compact = WORD.split("").map((c, i) => chalk.hex(GRAD[i])(c)).join("");
55
+ return ["", ` ${chalk.hex(GRAD[5])(STAR)} ${chalk.bold(compact)} ${chalk.dim(info)}`, ""];
56
+ }
57
+ const cells = wordCells();
58
+ const wordPad = pad(cols, WORD_W);
59
+ const lines = [""];
60
+ lines.push(pad(cols, STAR_TOP.length) + chalk.dim(STAR_TOP));
61
+ for (let r = 0; r < 5; r++) {
62
+ lines.push(wordPad + cells[r].map((cell, i) => chalk.hex(GRAD[i])(cell)).join(" "));
63
+ }
64
+ lines.push(pad(cols, STAR_BOT.length) + chalk.dim(STAR_BOT));
65
+ const tag = `${STAR} OPERATOR · ${info}`;
66
+ lines.push(pad(cols, tag.length) + chalk.dim(tag));
67
+ lines.push("");
68
+ return lines;
69
+ }
70
+ /** Ink render of design #29 — for static screens only (AuthScreen). Not for App's live tree. */
71
+ export function Masthead({ info }) {
72
+ const cols = process.stdout.columns ?? 80;
73
+ if (cols < WORD_W + 4) {
74
+ return (_jsxs(Box, { children: [_jsx(Text, { color: GRAD[5], bold: true, children: ` ${STAR} ` }), WORD.split("").map((c, i) => (_jsx(Text, { color: GRAD[i], bold: true, children: c }, i))), _jsx(Text, { dimColor: true, children: ` ${info}` })] }));
75
+ }
76
+ const cells = wordCells();
77
+ return (_jsxs(Box, { flexDirection: "column", alignItems: "center", children: [_jsx(Text, { dimColor: true, children: STAR_TOP }), cells.map((row, r) => (_jsx(Box, { children: row.map((cell, i) => (_jsxs(React.Fragment, { children: [_jsx(Text, { color: GRAD[i], children: cell }), i < row.length - 1 ? _jsx(Text, { children: " " }) : null] }, i))) }, r))), _jsx(Text, { dimColor: true, children: STAR_BOT }), _jsx(Text, { dimColor: true, children: `${STAR} OPERATOR · ${info}` })] }));
78
+ }
@@ -2,10 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  export function StatusRule({ route, ctxPct, version, build, user }) {
4
4
  const who = user ? `⬤ ${user} · ` : "";
5
- const tag = ` ${who}${route} · ${Math.round(ctxPct)}% · Operator v${version}${build ? ` ·${build}` : ""} `;
5
+ // Info block: identity · route · ctx% · version. Kept as one string so the width math is exact.
6
+ const info = `${who}${route} · ${Math.round(ctxPct)}% · v${version}${build ? ` ·${build}` : ""}`;
7
+ // The full right-hand content, styled below in segments (✷ magenta, OPERATOR bold, info dim). This
8
+ // plain string is only used to measure width so the leading rule fills precisely.
9
+ const right = `✷ OPERATOR · ${info} ─`;
6
10
  const cols = process.stdout.columns ?? 80;
7
- const fill = Math.max(1, cols - tag.length - 1);
8
- // Top rule of the input box: a dim line with the status text on the right. The composer sits BELOW
9
- // this and ABOVE the InputRule, so the input is bounded between the two lines.
10
- return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: "─".repeat(fill) }), _jsx(Text, { dimColor: true, children: tag + "─" })] }));
11
+ // Total width = fill + 1 space + right. Fill to cols-1, NOT cols: a line exactly the terminal width
12
+ // auto-wraps to a 2nd physical line Ink's height accounting misses, so its per-render erase is off by
13
+ // one and the whole dynamic frame (incl. the input) creeps UP the screen on each keystroke.
14
+ const fill = Math.max(1, cols - right.length - 2);
15
+ // Enterprise header: a dim rule sweeping to a magenta ✷ mark + bright OPERATOR wordmark + dim info,
16
+ // sitting just above the composer (the input is bounded between this and the InputRule below).
17
+ return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: "─".repeat(fill) + " " }), _jsx(Text, { color: "magenta", children: "\u2737 " }), _jsx(Text, { bold: true, children: "OPERATOR" }), _jsx(Text, { dimColor: true, children: ` · ${info} ─` })] }));
11
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.17",
3
+ "version": "0.1.21",
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": {
@@ -23,6 +23,7 @@
23
23
  "prepublishOnly": "npm run build && npm test"
24
24
  },
25
25
  "dependencies": {
26
+ "chalk": "^5.6.2",
26
27
  "ink": "^5.0.1",
27
28
  "react": "^18.3.1"
28
29
  },