@0perator/operator 0.0.6 → 0.1.17
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/auth/client.js +17 -0
- package/dist/auth/commands.js +124 -27
- package/dist/background/index.js +59 -18
- package/dist/cli.js +140 -17
- package/dist/config/settings.js +4 -1
- package/dist/engine/agent.js +24 -6
- package/dist/engine/aurora.js +20 -4
- package/dist/engine/grandmaster.js +172 -0
- package/dist/mcp/index.js +5 -1
- package/dist/memory/index.js +0 -0
- package/dist/session.js +1 -0
- package/dist/tools/computer.js +279 -0
- package/dist/tools/executor.js +0 -0
- package/dist/tools/registry.js +258 -16
- package/dist/tools/sandbox.js +118 -13
- package/dist/ui/App.js +7 -5
- package/dist/ui/ApprovalPrompt.js +45 -0
- package/dist/ui/BgPanel.js +12 -1
- package/dist/ui/Composer.js +11 -2
- package/dist/ui/InputRule.js +6 -0
- package/dist/ui/Markdown.js +76 -0
- package/dist/ui/StatusRule.js +6 -6
- package/dist/ui/ThinkingSpinner.js +6 -5
- package/dist/ui/Transcript.js +8 -3
- package/dist/ui/index.js +1 -0
- package/dist/update.js +16 -4
- package/package.json +1 -1
package/dist/ui/Composer.js
CHANGED
|
@@ -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, prompt = "› " }) {
|
|
19
|
+
export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, 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
|
|
@@ -62,6 +62,8 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, prompt = "
|
|
|
62
62
|
};
|
|
63
63
|
}, [stdin, isRawModeSupported]);
|
|
64
64
|
useInput((ch, key) => {
|
|
65
|
+
if (suspended)
|
|
66
|
+
return; // an approval prompt owns the keyboard — don't consume or echo keystrokes
|
|
65
67
|
if (pasteBufRef.current !== null)
|
|
66
68
|
return; // raw paste bytes are owned by the data handler above
|
|
67
69
|
if ((key.ctrl && ch === "c") || key.escape) {
|
|
@@ -115,5 +117,12 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, prompt = "
|
|
|
115
117
|
}
|
|
116
118
|
});
|
|
117
119
|
const lines = value.length ? value.split("\n") : [""];
|
|
118
|
-
|
|
120
|
+
// Surface any image/video paths in the draft as attachment chips so the user can see multiple
|
|
121
|
+
// media are attached (dragged/pasted paths land in the text). De-duped, basename only.
|
|
122
|
+
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(" ") }))] }));
|
|
119
124
|
}
|
|
125
|
+
// Recognize media file paths in the draft. IMAGE covers the common still formats, VIDEO the moving
|
|
126
|
+
// ones; a path matching VIDEO is chipped as video, otherwise image. Extensions only — no I/O.
|
|
127
|
+
const MEDIA_RE = /\S+\.(?:png|jpe?g|gif|webp|bmp|svg|heic|heif|mp4|mov|webm|mkv|avi|m4v)\b/gi;
|
|
128
|
+
const VIDEO_RE = /\.(?:mp4|mov|webm|mkv|avi|m4v)$/i;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
export function InputRule() {
|
|
4
|
+
const cols = process.stdout.columns ?? 80;
|
|
5
|
+
return (_jsx(Box, { children: _jsx(Text, { dimColor: true, children: "─".repeat(Math.max(1, cols - 1)) }) }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
// Split one line into styled inline spans: **bold**, `code`, *italic* / _italic_. Longest markers first.
|
|
4
|
+
function renderInline(text, kp) {
|
|
5
|
+
const nodes = [];
|
|
6
|
+
const re = /(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g;
|
|
7
|
+
let last = 0;
|
|
8
|
+
let m;
|
|
9
|
+
let i = 0;
|
|
10
|
+
while ((m = re.exec(text)) !== null) {
|
|
11
|
+
if (m.index > last)
|
|
12
|
+
nodes.push(_jsx(Text, { children: text.slice(last, m.index) }, `${kp}t${i++}`));
|
|
13
|
+
const tok = m[0];
|
|
14
|
+
if (tok.startsWith("**"))
|
|
15
|
+
nodes.push(_jsx(Text, { bold: true, children: tok.slice(2, -2) }, `${kp}b${i++}`));
|
|
16
|
+
else if (tok.startsWith("`"))
|
|
17
|
+
nodes.push(_jsx(Text, { color: "cyan", children: tok.slice(1, -1) }, `${kp}c${i++}`));
|
|
18
|
+
else
|
|
19
|
+
nodes.push(_jsx(Text, { italic: true, children: tok.slice(1, -1) }, `${kp}i${i++}`));
|
|
20
|
+
last = m.index + tok.length;
|
|
21
|
+
}
|
|
22
|
+
if (last < text.length)
|
|
23
|
+
nodes.push(_jsx(Text, { children: text.slice(last) }, `${kp}t${i++}`));
|
|
24
|
+
return nodes.length ? nodes : [_jsx(Text, { children: text }, `${kp}e`)];
|
|
25
|
+
}
|
|
26
|
+
export function Markdown({ content }) {
|
|
27
|
+
const lines = content.split("\n");
|
|
28
|
+
const blocks = [];
|
|
29
|
+
let inFence = false;
|
|
30
|
+
let fence = [];
|
|
31
|
+
let k = 0;
|
|
32
|
+
const flushFence = () => {
|
|
33
|
+
// Fenced code: verbatim, tinted, indented — no inline parsing inside.
|
|
34
|
+
blocks.push(_jsx(Box, { flexDirection: "column", paddingLeft: 1, children: fence.map((l, idx) => (_jsx(Text, { color: "cyan", dimColor: true, children: l.length ? l : " " }, idx))) }, `f${k++}`));
|
|
35
|
+
fence = [];
|
|
36
|
+
};
|
|
37
|
+
for (const line of lines) {
|
|
38
|
+
if (/^\s*```/.test(line)) {
|
|
39
|
+
if (inFence) {
|
|
40
|
+
flushFence();
|
|
41
|
+
inFence = false;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
inFence = true;
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (inFence) {
|
|
49
|
+
fence.push(line);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const h = /^(#{1,6})\s+(.*)$/.exec(line);
|
|
53
|
+
if (h) {
|
|
54
|
+
blocks.push(_jsx(Text, { bold: true, children: renderInline(h[2], `h${k}`) }, `h${k++}`));
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const b = /^(\s*)[-*+]\s+(.*)$/.exec(line);
|
|
58
|
+
if (b) {
|
|
59
|
+
blocks.push(_jsxs(Text, { children: [b[1], _jsx(Text, { color: "cyan", children: "\u2022 " }), renderInline(b[2], `b${k}`)] }, `b${k++}`));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const n = /^(\s*)(\d+)\.\s+(.*)$/.exec(line);
|
|
63
|
+
if (n) {
|
|
64
|
+
blocks.push(_jsxs(Text, { children: [n[1], _jsxs(Text, { bold: true, children: [n[2], "."] }), " ", renderInline(n[3], `n${k}`)] }, `n${k++}`));
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (line.trim() === "") {
|
|
68
|
+
blocks.push(_jsx(Text, { children: " " }, `s${k++}`));
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
blocks.push(_jsx(Text, { children: renderInline(line, `p${k}`) }, `p${k++}`));
|
|
72
|
+
}
|
|
73
|
+
if (inFence && fence.length)
|
|
74
|
+
flushFence();
|
|
75
|
+
return _jsx(Box, { flexDirection: "column", children: blocks });
|
|
76
|
+
}
|
package/dist/ui/StatusRule.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
|
-
|
|
4
|
-
const BRAND_W = 10; // visible width of "✷ OPERATOR"
|
|
5
|
-
export function StatusRule({ route, ctxPct, version, build, metrics, user }) {
|
|
3
|
+
export function StatusRule({ route, ctxPct, version, build, user }) {
|
|
6
4
|
const who = user ? `⬤ ${user} · ` : "";
|
|
7
|
-
const tag = ` ${who}${route} · ${Math.round(ctxPct)}
|
|
5
|
+
const tag = ` ${who}${route} · ${Math.round(ctxPct)}% · Operator v${version}${build ? ` ·${build}` : ""} `;
|
|
8
6
|
const cols = process.stdout.columns ?? 80;
|
|
9
|
-
const fill = Math.max(1, cols -
|
|
10
|
-
|
|
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
11
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// AXE loading star — the "signal" heartbeat (SPEC §6): sun → collapse to a point → a beat of silence →
|
|
3
3
|
// re-ignite → bright burst, looping. Ported 1:1 from the reference star_signal.py (assets/star_signal.py):
|
|
4
4
|
// same 10-phase FRAMES, same tones, same 110ms tick, same glyph set (all Dingbats/geometric so they
|
|
5
|
-
// render in Menlo without tofu). A rotating amber verb sits beside it unless the engine pins one
|
|
5
|
+
// render in Menlo without tofu). A rotating amber verb sits beside it unless the engine pins one, and
|
|
6
|
+
// the live token/time metrics (formerly on StatusRule) ride beside that.
|
|
6
7
|
import { useEffect, useState } from "react";
|
|
7
|
-
import { Text } from "ink";
|
|
8
|
+
import { Box, Text } from "ink";
|
|
8
9
|
const DEFAULT_VERBS = [
|
|
9
10
|
"Thinking", "Reasoning", "Noodling", "Synthesizing", "Percolating", "Untangling", "Weighing",
|
|
10
11
|
];
|
|
@@ -37,7 +38,7 @@ export function expandStar(frames = FRAMES) {
|
|
|
37
38
|
return out;
|
|
38
39
|
}
|
|
39
40
|
const SEQUENCE = expandStar();
|
|
40
|
-
export function ThinkingSpinner({ active, verb, verbs = DEFAULT_VERBS, verbIntervalMs = 2000, tickMs = 110, }) {
|
|
41
|
+
export function ThinkingSpinner({ active, verb, verbs = DEFAULT_VERBS, verbIntervalMs = 2000, tickMs = 110, metrics, }) {
|
|
41
42
|
const [tick, setTick] = useState(0);
|
|
42
43
|
const [verbIdx, setVerbIdx] = useState(0);
|
|
43
44
|
useEffect(() => {
|
|
@@ -57,5 +58,5 @@ export function ThinkingSpinner({ active, verb, verbs = DEFAULT_VERBS, verbInter
|
|
|
57
58
|
const [tone, glyph] = SEQUENCE[tick];
|
|
58
59
|
const style = TONE_STYLE[tone];
|
|
59
60
|
const label = verb ?? verbs[verbIdx % verbs.length];
|
|
60
|
-
return (_jsxs(Text, { color: style.color, bold: style.bold, dimColor: style.dim, children: [glyph, " ", label, "\u2026"] }));
|
|
61
|
+
return (_jsxs(Box, { children: [_jsxs(Text, { color: style.color, bold: style.bold, dimColor: style.dim, children: [glyph, " ", label, "\u2026"] }), metrics ? _jsx(Text, { dimColor: true, children: " " + metrics }) : null] }));
|
|
61
62
|
}
|
package/dist/ui/Transcript.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Static, Text } from "ink";
|
|
3
3
|
import { ToolStep } from "./ToolStep.js";
|
|
4
|
+
import { Markdown } from "./Markdown.js";
|
|
4
5
|
function entryKey(entry) {
|
|
5
6
|
return entry.kind === "message" ? entry.message.id : entry.step.id;
|
|
6
7
|
}
|
|
7
|
-
function renderEntry(entry) {
|
|
8
|
+
function renderEntry(entry, live = false) {
|
|
8
9
|
if (entry.kind === "message") {
|
|
9
10
|
const { message } = entry;
|
|
10
11
|
if (message.role === "user") {
|
|
@@ -13,10 +14,14 @@ function renderEntry(entry) {
|
|
|
13
14
|
if (message.role === "system") {
|
|
14
15
|
return _jsx(Text, { dimColor: true, children: message.content }); // slash-command output / status notes
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
// Thought process first, dimmed and lower-opacity; the real answer follows at full weight, so the
|
|
18
|
+
// reasoning reads as recessive scaffolding and the answer stands out (per the requested look).
|
|
19
|
+
// Settled answers render as markdown (bold/code/lists/headers formatted, not raw `**`/backticks);
|
|
20
|
+
// the LIVE stream stays plain text so a half-open ``` fence can't swallow the text while it types.
|
|
21
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [message.reasoning ? _jsx(Text, { dimColor: true, children: message.reasoning }) : null, message.content ? (live ? _jsx(Text, { children: message.content }) : _jsx(Markdown, { content: message.content })) : null] }));
|
|
17
22
|
}
|
|
18
23
|
return _jsx(ToolStep, { step: entry.step });
|
|
19
24
|
}
|
|
20
25
|
export function Transcript({ entries, live }) {
|
|
21
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live) }) : null] }));
|
|
26
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live, true) }) : null] }));
|
|
22
27
|
}
|
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { App } from "./App.js";
|
|
2
2
|
export { Transcript } from "./Transcript.js";
|
|
3
3
|
export { StatusRule } from "./StatusRule.js";
|
|
4
|
+
export { InputRule } from "./InputRule.js";
|
|
4
5
|
export { Composer } from "./Composer.js";
|
|
5
6
|
export { ThinkingSpinner } from "./ThinkingSpinner.js";
|
|
6
7
|
export { ToolStep } from "./ToolStep.js";
|
package/dist/update.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
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;
|
|
5
5
|
// a global install lives under a node_modules tree with no repo around it.
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
7
|
-
import { existsSync } from "node:fs";
|
|
6
|
+
import { spawnSync, execSync } from "node:child_process";
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
8
8
|
import { dirname, join, resolve } from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
const PKG = "@0perator/operator"; // published (private) scope/name — keep in sync with package.json
|
|
@@ -43,8 +43,20 @@ export async function runUpdate() {
|
|
|
43
43
|
if (code !== 0)
|
|
44
44
|
return code;
|
|
45
45
|
code = run("npm", ["run", "build"], pkgDir);
|
|
46
|
-
if (code === 0)
|
|
47
|
-
|
|
46
|
+
if (code === 0) {
|
|
47
|
+
let ver = "?", sha = "";
|
|
48
|
+
try {
|
|
49
|
+
ver = JSON.parse(readFileSync(join(pkgDir, "package.json"), "utf8")).version;
|
|
50
|
+
}
|
|
51
|
+
catch { /* best-effort */ }
|
|
52
|
+
try {
|
|
53
|
+
sha = execSync(`git -C '${repo}' rev-parse --short HEAD`).toString().trim();
|
|
54
|
+
}
|
|
55
|
+
catch { /* best-effort */ }
|
|
56
|
+
process.stderr.write(`\noperator update: ✓ updated to v${ver}${sha ? ` (${sha})` : ""} and rebuilt.\n` +
|
|
57
|
+
`RESTART to run it — type /exit and relaunch \`operator\`, or open a new terminal. Your CURRENT ` +
|
|
58
|
+
`session keeps the old version until you restart (that is why a re-run can behave the same).\n`);
|
|
59
|
+
}
|
|
48
60
|
return code;
|
|
49
61
|
}
|
|
50
62
|
process.stderr.write(`operator update: reinstalling ${PKG}@latest from the registry\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.17",
|
|
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": {
|