@0perator/operator 0.2.4 → 0.2.6
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/autonomy/delegate-mode.js +4 -1
- package/dist/autonomy/delegate.js +3 -13
- package/dist/background/index.js +7 -10
- package/dist/background/notices.js +1 -1
- package/dist/cli.js +31 -14
- package/dist/config/persona.js +20 -3
- package/dist/engine/agent.js +62 -7
- package/dist/engine/aurora.js +30 -30
- package/dist/engine/batch-hints.js +45 -0
- package/dist/engine/batch-scheduler.js +23 -7
- package/dist/engine/decision-points.js +12 -2
- package/dist/engine/delegate-turn.js +24 -0
- package/dist/engine/grandmaster.js +28 -11
- package/dist/mcp/index.js +2 -2
- package/dist/permissions/modes.js +7 -3
- package/dist/session.js +65 -12
- package/dist/tools/classes.js +4 -0
- package/dist/tools/deferred.js +11 -6
- package/dist/tools/readonly-shell.js +92 -0
- package/dist/tools/registry.js +3 -3
- package/dist/tools/shell-session.js +56 -1
- package/dist/ui/ActivitySpinner.js +2 -2
- package/dist/ui/App.js +9 -9
- package/dist/ui/ApprovalPrompt.js +5 -4
- package/dist/ui/ArtifactPicker.js +4 -3
- package/dist/ui/AuthScreen.js +2 -1
- package/dist/ui/BgPanel.js +11 -8
- package/dist/ui/Composer.js +4 -3
- package/dist/ui/Header.js +2 -2
- package/dist/ui/Markdown.js +50 -77
- package/dist/ui/PlanPane.js +5 -5
- package/dist/ui/QuestionPrompt.js +2 -1
- package/dist/ui/SecretPrompt.js +2 -1
- package/dist/ui/SessionPicker.js +4 -3
- package/dist/ui/SkillFinder.js +3 -2
- package/dist/ui/StatsCard.js +2 -2
- package/dist/ui/StatusRule.js +2 -2
- package/dist/ui/SummaryCard.js +2 -2
- package/dist/ui/Table.js +25 -24
- package/dist/ui/ThinkingSpinner.js +2 -1
- package/dist/ui/ToolBatch.js +3 -3
- package/dist/ui/ToolStep.js +4 -4
- package/dist/ui/Transcript.js +12 -12
- package/dist/ui/UpdatePrompt.js +2 -1
- package/dist/ui/inline.js +109 -0
- package/dist/ui/reportLine.js +2 -0
- package/dist/ui/slashCommands.js +2 -2
- package/dist/ui/theme.js +4 -0
- package/package.json +1 -1
package/dist/ui/UpdatePrompt.js
CHANGED
|
@@ -4,6 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
// its row, Esc or ctrl+c skips this launch.
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { Box, Text, useInput } from "ink";
|
|
7
|
+
import { secondary } from "./theme.js";
|
|
7
8
|
const CHOICES = ["update", "skip", "skip-version"];
|
|
8
9
|
export function choiceLabels(p) {
|
|
9
10
|
return [`Update now (runs \`${p.command}\`)`, "Skip", "Skip until next version"];
|
|
@@ -36,5 +37,5 @@ export function UpdatePrompt({ pending, suspended = false }) {
|
|
|
36
37
|
}, { isActive: !!pending && !suspended });
|
|
37
38
|
if (!pending)
|
|
38
39
|
return null;
|
|
39
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { bold: true, children: ["Update available · ", _jsx(Text, {
|
|
40
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { bold: true, children: ["Update available · ", _jsx(Text, { ...secondary, children: pending.current }), " → ", _jsx(Text, { color: "green", children: pending.version })] }), _jsx(Text, { ...secondary, children: "Release notes: " + pending.notes }), _jsx(Text, { children: " " }), choiceLabels(pending).map((label, i) => (_jsxs(Text, { children: [i === sel ? _jsx(Text, { color: "cyan", bold: true, children: "› " }) : " ", _jsx(Text, { bold: i === sel, children: `${i + 1}. ${label}` })] }, label))), _jsx(Text, { children: " " }), _jsx(Text, { ...secondary, children: suspended ? "waiting · another prompt has the keyboard" : "enter continue · esc skip" })] }));
|
|
40
41
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
import { link, hyperlinksEnabled } from "./osc.js";
|
|
4
|
+
import { theme, secondary } from "./theme.js";
|
|
5
|
+
// Alternatives in order: `code`, [label](url), ***both***, **bold**, ~~strike~~, *italic*, _italic_, bare URL.
|
|
6
|
+
// The emphasis lookarounds keep identifiers and globs literal (snake_case, __init__, src/*.ts, 2 * 3).
|
|
7
|
+
const MARKS = /(`+)((?:(?!\1).)+)\1|\[((?:`[^`]*`|[^\]`])+)\]\(([^)\s]+)\)|\*\*\*(?!\s)((?:`[^`]*`|[^`])+?)(?<!\s)\*\*\*|\*\*(?!\s)((?:`[^`]*`|[^`])+?)(?<!\s)\*\*(?!\*)|~~(?!\s)((?:`[^`]*`|[^`])+?)(?<!\s)~~|(?<![\w*/\\])\*(?![\s*])((?:`[^`]*`|\*\*[^*]+\*\*|[^*`])+?)(?<!\s)\*(?![\w*])|(?<![\w\\])_(?![\s_])([^_]+?)(?<!\s)_(?!\w)|(https?:\/\/[^\s)`]+?)(?=\*\*|[\s)`]|$)/g;
|
|
8
|
+
export function parseInline(text, style = {}) {
|
|
9
|
+
const out = [];
|
|
10
|
+
let last = 0;
|
|
11
|
+
for (const m of text.matchAll(MARKS)) {
|
|
12
|
+
if (m.index > last)
|
|
13
|
+
out.push({ ...style, t: text.slice(last, m.index) });
|
|
14
|
+
const [tok, , code, label, url, both, bold, strike, star, under, bare] = m;
|
|
15
|
+
if (code !== undefined)
|
|
16
|
+
out.push({ ...style, code: true, t: code });
|
|
17
|
+
else if (label !== undefined) {
|
|
18
|
+
if (hyperlinksEnabled())
|
|
19
|
+
out.push(...parseInline(label, { ...style, url }));
|
|
20
|
+
else
|
|
21
|
+
out.push(...parseInline(label, { ...style, url }), { ...style, aside: true, t: " " + url });
|
|
22
|
+
}
|
|
23
|
+
else if (both !== undefined)
|
|
24
|
+
out.push(...parseInline(both, { ...style, bold: true, italic: true }));
|
|
25
|
+
else if (bold !== undefined)
|
|
26
|
+
out.push(...parseInline(bold, { ...style, bold: true }));
|
|
27
|
+
else if (strike !== undefined)
|
|
28
|
+
out.push(...parseInline(strike, { ...style, strike: true }));
|
|
29
|
+
else if (bare !== undefined)
|
|
30
|
+
out.push({ ...style, url: bare, t: bare });
|
|
31
|
+
else
|
|
32
|
+
out.push(...parseInline(star ?? under, { ...style, italic: true }));
|
|
33
|
+
last = m.index + tok.length;
|
|
34
|
+
}
|
|
35
|
+
if (last < text.length)
|
|
36
|
+
out.push({ ...style, t: text.slice(last) });
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
export function renderSpans(spans, kp) {
|
|
40
|
+
return spans.map((s, i) => (_jsx(Text, { bold: s.bold, italic: s.italic, strikethrough: s.strike, underline: !!s.url, ...(s.aside ? secondary : s.code || s.url ? { color: theme.info } : {}), children: s.url && hyperlinksEnabled() ? link(s.t, s.url) : s.t }, `${kp}s${i}`)));
|
|
41
|
+
}
|
|
42
|
+
export const renderInline = (text, kp) => renderSpans(parseInline(text), kp);
|
|
43
|
+
/** While a line is still streaming, close the bold or code marker it has opened (or drop a bare trailing one),
|
|
44
|
+
* so the half-typed span reads styled instead of showing the marker. */
|
|
45
|
+
export function closeOpen(line) {
|
|
46
|
+
for (const mark of ["`", "**"]) {
|
|
47
|
+
const rest = line.replace(/`[^`]*`|\*\*(?!\s)(?:`[^`]*`|[^`])+?(?<!\s)\*\*/g, "");
|
|
48
|
+
if (!new RegExp(`(?<=^|[\\s(|])${mark === "`" ? "`" : "\\*\\*"}(?!\\s)`).test(rest))
|
|
49
|
+
continue;
|
|
50
|
+
line = line.endsWith(mark) ? line.slice(0, -mark.length) : line.trimEnd() + mark;
|
|
51
|
+
}
|
|
52
|
+
return line;
|
|
53
|
+
}
|
|
54
|
+
// Cell widths as Ink measures them (East Asian wide and emoji two, combining marks none), so a table's right edge
|
|
55
|
+
// lines up. StatusRule's cellWidth over-counts symbols on purpose, which would leave a row with a ✓ one cell short.
|
|
56
|
+
const WIDE = /[ᄀ-ᅟ⺀-〾ぁ-㏿㐀-䶿一-鿿ꀀ-가-힣豈-︰-﹏-⦆¢-₩\u{20000}-\u{3fffd}]|\p{Emoji_Presentation}|️/u;
|
|
57
|
+
const ZERO = /^[\p{Mn}\p{Me}\p{Cf}]+$/u;
|
|
58
|
+
const segmenter = new Intl.Segmenter();
|
|
59
|
+
const graphemes = (s) => Array.from(segmenter.segment(s), (g) => g.segment);
|
|
60
|
+
const graphemeWidth = (g) => (ZERO.test(g) ? 0 : WIDE.test(g) ? 2 : 1);
|
|
61
|
+
export const textWidth = (s) => graphemes(s).reduce((w, g) => w + graphemeWidth(g), 0);
|
|
62
|
+
export const spansWidth = (spans) => spans.reduce((w, s) => w + textWidth(s.t), 0);
|
|
63
|
+
/** Word-wrap styled spans into lines of at most `width` cells; a word longer than the line is split. */
|
|
64
|
+
export function wrapSpans(spans, width) {
|
|
65
|
+
const words = [[]];
|
|
66
|
+
for (const s of spans) {
|
|
67
|
+
for (const part of s.t.split(/( +)/)) {
|
|
68
|
+
if (!part)
|
|
69
|
+
continue;
|
|
70
|
+
if (part.startsWith(" "))
|
|
71
|
+
words.push([{ ...s, t: part }], []);
|
|
72
|
+
else
|
|
73
|
+
words[words.length - 1].push({ ...s, t: part });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const lines = [[]];
|
|
77
|
+
let used = 0;
|
|
78
|
+
const newline = () => { lines.push([]); used = 0; };
|
|
79
|
+
const put = (s, w) => { lines[lines.length - 1].push(s); used += w; };
|
|
80
|
+
for (const word of words) {
|
|
81
|
+
const w = spansWidth(word);
|
|
82
|
+
if (!w)
|
|
83
|
+
continue;
|
|
84
|
+
const space = word[0].t.startsWith(" ");
|
|
85
|
+
if (used && used + w > width) {
|
|
86
|
+
newline();
|
|
87
|
+
if (space)
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (w <= width) {
|
|
91
|
+
lines[lines.length - 1].push(...word);
|
|
92
|
+
used += w;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
for (const s of word) {
|
|
96
|
+
for (const g of graphemes(s.t)) {
|
|
97
|
+
if (used && used + graphemeWidth(g) > width)
|
|
98
|
+
newline();
|
|
99
|
+
put({ ...s, t: g }, graphemeWidth(g));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return lines.map((l) => {
|
|
104
|
+
const end = [...l];
|
|
105
|
+
while (end.length && !end[end.length - 1].t.trim())
|
|
106
|
+
end.pop();
|
|
107
|
+
return end;
|
|
108
|
+
});
|
|
109
|
+
}
|
package/dist/ui/reportLine.js
CHANGED
|
@@ -18,6 +18,8 @@ const GLYPH = { done: "⤷", stopped: "■", error: "✗" };
|
|
|
18
18
|
export function reportCommand(a) {
|
|
19
19
|
return `/agents ${(a.name ?? a.id).toLowerCase()} report`;
|
|
20
20
|
}
|
|
21
|
+
/** Why a stopped sub-agent stopped, for the panel and agent_status. */
|
|
22
|
+
export const stopReasonOf = (a) => a.endKind === "engine" ? `stopped by the engine: ${a.endReason ?? "no progress"}` : a.endReason;
|
|
21
23
|
function outcome(a) {
|
|
22
24
|
const dur = a.durationMs != null ? fmtElapsed(a.durationMs) : undefined;
|
|
23
25
|
const rounds = a.round ? ` after ${a.round} round${a.round === 1 ? "" : "s"}` : "";
|
package/dist/ui/slashCommands.js
CHANGED
|
@@ -16,10 +16,10 @@ export const SLASH_COMMANDS = [
|
|
|
16
16
|
{ name: "remote", description: "remote control: let a follower attach and drive this session", args: "[on|off]" },
|
|
17
17
|
{ name: "pair", description: "pair a phone to drive this session — shows a QR for the Operator app (end-to-end encrypted)" },
|
|
18
18
|
{ name: "plan", description: "plan mode: read-only research + propose a plan (/plan again executes)" },
|
|
19
|
-
{ name: "mode", description: "set operating mode: autonomous · manual · plan · gated", args: "[auto|manual|plan|gated]" },
|
|
19
|
+
{ name: "mode", description: "set operating mode: autonomous · delegate · manual · plan · gated", args: "[auto|delegate|manual|plan|gated]" },
|
|
20
20
|
{ name: "think", description: "toggle extended reasoning (think before answering)" },
|
|
21
21
|
{ name: "ultrathink", description: "toggle deep, exhaustive reasoning for hard problems" },
|
|
22
|
-
{ name: "delegate", description: "any /model id as the MoA planner or
|
|
22
|
+
{ name: "delegate", description: "Delegate mode on|off; any /model id as the MoA planner or sub-agents; guard: no push, deploys or outside writes", args: "[on|off|planner <model> [executor]|subagents <model>|guard on|off|push on|off]" },
|
|
23
23
|
{ name: "agents", description: "detailed sub-agent status: running/queued/done/errored + metrics" },
|
|
24
24
|
{ name: "bg", description: "spawn a background sub-agent, list, or stop one", args: "<task|stop id>" },
|
|
25
25
|
{ name: "jobs", description: "background shell jobs: list, or stop one (ctrl+b moves a running command here)", args: "[stop id]" },
|
package/dist/ui/theme.js
CHANGED
|
@@ -24,6 +24,7 @@ const PALETTE = {
|
|
|
24
24
|
starBright: { hex: "#ffe2a0", ansi: "yellowBright", hc: "whiteBright" }, // the star's bright burst
|
|
25
25
|
textBright: { hex: "#ffffff", ansi: "whiteBright", hc: "whiteBright" }, // emphasized foreground
|
|
26
26
|
muted: { hex: "#8a8a8a", ansi: "gray", hc: "white" }, // borders, idle glyphs (a POSITIVE gray, not dimColor)
|
|
27
|
+
secondary: { hex: "#949494", ansi: "gray", hc: "white" }, // reasoning, previews, hints: a gray that reads on dark and light backgrounds (exact in 256-color)
|
|
27
28
|
mediaProgress: { hex: "#e6c84a", ansi: "yellow", hc: "yellowBright" }, // media-gen progress bar (image/video_generate) — James: yellow, not amber
|
|
28
29
|
compactProgress: { hex: "#ff6ac1", ansi: "magenta", hc: "magentaBright" }, // compaction/recovery sweep bar — James: pink, not amber (no ANSI-16 pink, magenta is the closest low-color fallback)
|
|
29
30
|
};
|
|
@@ -61,3 +62,6 @@ export function makeTheme(level = detectLevel(), mode = detectMode()) {
|
|
|
61
62
|
return out;
|
|
62
63
|
}
|
|
63
64
|
export const theme = makeTheme();
|
|
65
|
+
/** Props for secondary text: its own gray, not SGR dim, which terminals fade too far to read. Without color, dim.
|
|
66
|
+
* High contrast uses the default foreground, which reads on dark and light alike. */
|
|
67
|
+
export const secondary = detectMode() === "high-contrast" ? {} : theme.secondary ? { color: theme.secondary } : { dimColor: true };
|