@0perator/operator 0.1.350 → 0.1.352
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/index.js +6 -5
- package/dist/autonomy/session-factory.js +4 -0
- package/dist/cli.js +32 -14
- package/dist/engine/aurora.js +23 -0
- package/dist/permissions/policy.js +5 -2
- package/dist/services/preflight.js +98 -44
- package/dist/session.js +24 -5
- package/dist/toolchain/toolchain.py +528 -112
- package/dist/tools/registry.js +38 -5
- package/dist/tools/result-cap.js +1 -1
- package/dist/tools/wave2-tools.js +28 -13
- package/dist/ui/App.js +2 -2
- package/dist/ui/StatusRule.js +7 -6
- package/package.json +1 -1
package/dist/tools/registry.js
CHANGED
|
@@ -185,6 +185,32 @@ async function shellExec(args) {
|
|
|
185
185
|
// capping here first lets us tell the model specifically to use offset/limit rather than "narrow your query".
|
|
186
186
|
const FILE_READ_DEFAULT_LIMIT_LINES = 2000;
|
|
187
187
|
const FILE_READ_MAX_CHARS = 40_000;
|
|
188
|
+
const RAW_READ_MAX_CHARS = 38_000; // under the 40K tool-result cap with room for the footer
|
|
189
|
+
/** Raw character paging (start_char/max_chars): the exact text, no line numbers. Line paging can't get past one line
|
|
190
|
+
* longer than the cap (minified code, one-line JSON or logs): limit=1 is still truncated, and "a smaller limit" is a
|
|
191
|
+
* dead end the model loops on. */
|
|
192
|
+
function rawSlice(src, startChar, maxChars) {
|
|
193
|
+
const start = Math.min(src.length, Math.max(0, Math.floor(startChar) || 0));
|
|
194
|
+
const end = Math.min(src.length, start + Math.min(RAW_READ_MAX_CHARS, Math.max(1, Math.floor(maxChars) || RAW_READ_MAX_CHARS)));
|
|
195
|
+
const out = src.slice(start, end);
|
|
196
|
+
return end < src.length ? `${out}\n…[chars ${start}-${end} of ${src.length} — next: start_char=${end}]` : out;
|
|
197
|
+
}
|
|
198
|
+
/** The raw character position where a line-numbered result cut at `cut` stops, so the truncation note can name the
|
|
199
|
+
* exact start_char to continue from (the `${n}\t` prefixes and the joining newlines aren't in the file). */
|
|
200
|
+
function rawOffsetAt(lines, offset, cut) {
|
|
201
|
+
let raw = 0;
|
|
202
|
+
for (let i = 0; i < offset && i < lines.length; i++)
|
|
203
|
+
raw += lines[i].length + 1;
|
|
204
|
+
let used = 0;
|
|
205
|
+
for (let i = offset; i < lines.length; i++) {
|
|
206
|
+
const prefix = `${i + 1}\t`.length;
|
|
207
|
+
if (used + prefix + lines[i].length + 1 > cut)
|
|
208
|
+
return raw + Math.max(0, cut - used - prefix);
|
|
209
|
+
used += prefix + lines[i].length + 1;
|
|
210
|
+
raw += lines[i].length + 1;
|
|
211
|
+
}
|
|
212
|
+
return raw;
|
|
213
|
+
}
|
|
188
214
|
async function fileRead(args) {
|
|
189
215
|
const path = await resolveReadPath(str(args.path));
|
|
190
216
|
if (!path)
|
|
@@ -206,13 +232,16 @@ async function fileRead(args) {
|
|
|
206
232
|
const { readFile } = await nodeImport("node:fs/promises");
|
|
207
233
|
src = await readFile(path, "utf8");
|
|
208
234
|
}
|
|
235
|
+
if (args.start_char !== undefined || args.max_chars !== undefined) {
|
|
236
|
+
return head + rawSlice(src, Number(args.start_char ?? 0), Number(args.max_chars ?? RAW_READ_MAX_CHARS));
|
|
237
|
+
}
|
|
209
238
|
const lines = src.split("\n");
|
|
210
239
|
const offset = Number(args.offset ?? 0);
|
|
211
240
|
const explicitLimit = args.limit !== undefined;
|
|
212
241
|
const limit = Number(args.limit ?? Math.min(lines.length, FILE_READ_DEFAULT_LIMIT_LINES));
|
|
213
242
|
let out = lines.slice(offset, offset + limit).map((l, i) => `${offset + i + 1}\t${l}`).join("\n");
|
|
214
243
|
if (out.length > FILE_READ_MAX_CHARS) {
|
|
215
|
-
out = `${out.slice(0, FILE_READ_MAX_CHARS)}\n…[result truncated: ${FILE_READ_MAX_CHARS} of ${out.length} chars — pass a smaller offset/limit]`;
|
|
244
|
+
out = `${out.slice(0, FILE_READ_MAX_CHARS)}\n…[result truncated: ${FILE_READ_MAX_CHARS} of ${out.length} chars — pass a smaller offset/limit, or continue as raw text with start_char=${rawOffsetAt(lines, offset, FILE_READ_MAX_CHARS)} (works inside a long line)]`;
|
|
216
245
|
}
|
|
217
246
|
else if (!explicitLimit && offset + limit < lines.length) {
|
|
218
247
|
out += `\n…[showing lines ${offset + 1}-${offset + limit} of ${lines.length} — pass offset/limit to see the rest]`;
|
|
@@ -2344,10 +2373,12 @@ const TOOLS = [
|
|
|
2344
2373
|
},
|
|
2345
2374
|
{
|
|
2346
2375
|
name: "file_read", safe: true,
|
|
2347
|
-
contract: { v:
|
|
2348
|
-
description: "Read a file, optionally a line range, with line numbers. Without offset/limit, only the first 2000 lines are returned — pass offset/limit to page through a larger file.",
|
|
2376
|
+
contract: { v: 2, effects: ["read"], bins: ["osascript", "textutil", "unzip"] },
|
|
2377
|
+
description: "Read a file, optionally a line range, with line numbers. Without offset/limit, only the first 2000 lines are returned — pass offset/limit to page through a larger file. For very long lines (minified code, one-line JSON or logs) page by character instead: start_char (and max_chars, up to 38000) returns the exact raw text with no line numbers.",
|
|
2349
2378
|
parameters: { type: "object", properties: {
|
|
2350
2379
|
path: { type: "string" }, offset: { type: "number" }, limit: { type: "number" },
|
|
2380
|
+
start_char: { type: "number", description: "raw mode: character offset to start at (0-based); the reply names the next start_char" },
|
|
2381
|
+
max_chars: { type: "number", description: "raw mode: characters to return (default and max 38000)" },
|
|
2351
2382
|
}, required: ["path"] },
|
|
2352
2383
|
run: fileRead,
|
|
2353
2384
|
},
|
|
@@ -2868,8 +2899,10 @@ const TOOLS = [
|
|
|
2868
2899
|
run: runSkillCatalog,
|
|
2869
2900
|
},
|
|
2870
2901
|
// ── Chauffeur native tools (gated on binary availability) ──
|
|
2902
|
+
// The screen reads are not `safe`: that would grant screen capture to every seat tier and run it unprompted in
|
|
2903
|
+
// gated and plan mode. It is computer control, like computer_screenshot (tier.ts).
|
|
2871
2904
|
{
|
|
2872
|
-
name: "desktop_screenshot", safe:
|
|
2905
|
+
name: "desktop_screenshot", safe: false,
|
|
2873
2906
|
contract: { v: 1, effects: ["device"], bins: ["chauffeur-local", "chauffeur", "sh"] },
|
|
2874
2907
|
description: "Screenshot the desktop or one window via Chauffeur (text + image).",
|
|
2875
2908
|
parameters: { type: "object", properties: {
|
|
@@ -2892,7 +2925,7 @@ const TOOLS = [
|
|
|
2892
2925
|
run: desktopClick,
|
|
2893
2926
|
},
|
|
2894
2927
|
{
|
|
2895
|
-
name: "desktop_read", safe:
|
|
2928
|
+
name: "desktop_read", safe: false,
|
|
2896
2929
|
contract: { v: 1, effects: ["device"], bins: ["chauffeur-local", "chauffeur", "sh"] },
|
|
2897
2930
|
description: "Read the accessibility tree / window state of a running application via Chauffeur.",
|
|
2898
2931
|
parameters: { type: "object", properties: {
|
package/dist/tools/result-cap.js
CHANGED
|
@@ -20,7 +20,7 @@ export function capToolResult(result, spill) {
|
|
|
20
20
|
const tail = result.slice(-TOOL_RESULT_TAIL_CHARS);
|
|
21
21
|
const path = spill ? spill(result) : null;
|
|
22
22
|
const marker = path
|
|
23
|
-
? `\n…[${result.length} chars total; showing head+tail — FULL output saved to ${path} · re-read the omitted middle with file_read(path,
|
|
23
|
+
? `\n…[${result.length} chars total; showing head+tail — FULL output saved to ${path} · re-read the omitted middle with file_read(path, start_char=${TOOL_RESULT_HEAD_CHARS})]\n`
|
|
24
24
|
: `\n…[result truncated: ${TOOL_RESULT_MAX_CHARS} of ${result.length} chars — narrow your query]\n`;
|
|
25
25
|
return head + marker + tail;
|
|
26
26
|
}
|
|
@@ -62,12 +62,20 @@ function termGroup(pid) {
|
|
|
62
62
|
catch { }
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
|
-
/** Deadline
|
|
66
|
-
function
|
|
67
|
-
|
|
65
|
+
/** Deadline note shared by status/list: a report, never a signal. */
|
|
66
|
+
function deadlineNote(meta) {
|
|
67
|
+
return alive(meta.pid) && overdue(meta) ? " (deadline passed — shell_task_kill stops it)" : "";
|
|
68
|
+
}
|
|
69
|
+
/** The OS start time of `pid` (`ps -o lstart=`), or "" when it is gone or unreadable. lstart is strftime %c in
|
|
70
|
+
* local time, so the C locale and UTC are pinned: the same process reads the same from any session. */
|
|
71
|
+
async function procStart(pid) {
|
|
72
|
+
try {
|
|
73
|
+
const env = { ...process.env, LC_ALL: "C", TZ: "UTC" };
|
|
74
|
+
return (await pexecFile("ps", ["-o", "lstart=", "-p", String(pid)], { timeout: 5_000, encoding: "utf8", env })).stdout.trim();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
68
77
|
return "";
|
|
69
|
-
|
|
70
|
-
return " (deadline passed — terminated)";
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
80
|
async function shellTaskStartRun(args) {
|
|
73
81
|
const command = str(args.command);
|
|
@@ -94,7 +102,7 @@ async function shellTaskStartRun(args) {
|
|
|
94
102
|
}
|
|
95
103
|
child.unref();
|
|
96
104
|
await log.close();
|
|
97
|
-
const meta = { id, label, command, pid, logFile, started: new Date().toISOString(), deadlineMs };
|
|
105
|
+
const meta = { id, label, command, pid, logFile, started: new Date().toISOString(), deadlineMs, lstart: await procStart(pid) };
|
|
98
106
|
await writeJson(join(tasksDir(), `${id}.json`), meta);
|
|
99
107
|
const timer = setTimeout(() => termGroup(pid), deadlineMs);
|
|
100
108
|
timer.unref?.();
|
|
@@ -107,7 +115,7 @@ async function shellTaskStatusRun(args) {
|
|
|
107
115
|
const meta = await taskMeta(id);
|
|
108
116
|
if (!meta)
|
|
109
117
|
return `error: task ${id} not found`;
|
|
110
|
-
const note =
|
|
118
|
+
const note = deadlineNote(meta);
|
|
111
119
|
const { open } = await fsp();
|
|
112
120
|
let tailText = "";
|
|
113
121
|
try {
|
|
@@ -159,7 +167,7 @@ async function shellTaskListRun() {
|
|
|
159
167
|
const meta = await taskMeta(f.replace(/\.json$/, ""));
|
|
160
168
|
if (!meta)
|
|
161
169
|
continue;
|
|
162
|
-
const note =
|
|
170
|
+
const note = deadlineNote(meta);
|
|
163
171
|
rows.push(`${meta.id} ${alive(meta.pid) ? "RUNNING" : "STOPPED"}${note} pid=${meta.pid} ${meta.label}`);
|
|
164
172
|
}
|
|
165
173
|
return rows.length ? rows.join("\n") : "no background tasks";
|
|
@@ -173,6 +181,9 @@ async function shellTaskKillRun(args) {
|
|
|
173
181
|
return `error: task ${id} not found`;
|
|
174
182
|
if (!alive(meta.pid))
|
|
175
183
|
return `task ${id} already stopped`;
|
|
184
|
+
if (!meta.lstart || (await procStart(meta.pid)) !== meta.lstart) {
|
|
185
|
+
return `task ${id} not signalled: pid ${meta.pid} could not be confirmed as the process this task started`;
|
|
186
|
+
}
|
|
176
187
|
return termGroup(meta.pid) ? `killed ${id} (pid ${meta.pid})` : `task ${id} already stopped`;
|
|
177
188
|
}
|
|
178
189
|
// ─── sql_exec (approval-gated; argv, never a shell string) ──────────────────
|
|
@@ -188,8 +199,9 @@ async function sqlExecRun(args) {
|
|
|
188
199
|
return "error: database path required for sqlite";
|
|
189
200
|
if (!flagSafe(db))
|
|
190
201
|
return "error: database path must not start with '-'";
|
|
202
|
+
// argv keeps /bin/sh out, but sqlite3 itself runs a dot-command query (.shell, .system, .output); -safe refuses them.
|
|
191
203
|
try {
|
|
192
|
-
return (await pexecFile("sqlite3", ["-header", "-column", db, query], opts)).stdout || "(no output)";
|
|
204
|
+
return (await pexecFile("sqlite3", ["-safe", "-header", "-column", db, query], opts)).stdout || "(no output)";
|
|
193
205
|
}
|
|
194
206
|
catch (e) {
|
|
195
207
|
return `error: ${e.stderr?.trim() || e.message}`;
|
|
@@ -200,6 +212,9 @@ async function sqlExecRun(args) {
|
|
|
200
212
|
return "error: connection string required for psql";
|
|
201
213
|
if (!flagSafe(db))
|
|
202
214
|
return "error: connection string must not start with '-'";
|
|
215
|
+
// psql -c runs a string that starts with a backslash as a meta-command, and \! is a shell.
|
|
216
|
+
if (query.trimStart().startsWith("\\"))
|
|
217
|
+
return "error: psql backslash commands are refused — send SQL only";
|
|
203
218
|
try {
|
|
204
219
|
return (await pexecFile("psql", ["--no-psqlrc", db, "-c", query], opts)).stdout || "(no output)";
|
|
205
220
|
}
|
|
@@ -330,7 +345,7 @@ async function securityScanRun(args) {
|
|
|
330
345
|
export const WAVE2_TOOLS = [
|
|
331
346
|
{
|
|
332
347
|
name: "shell_task_start", safe: false,
|
|
333
|
-
contract: { v: 1, effects: ["exec"], bins: ["bash"] },
|
|
348
|
+
contract: { v: 1, effects: ["exec"], bins: ["bash", "ps"] },
|
|
334
349
|
description: "Start a long-running background shell task with a deadline. Returns a task id for monitoring.",
|
|
335
350
|
parameters: { type: "object", properties: {
|
|
336
351
|
command: { type: "string" },
|
|
@@ -341,7 +356,7 @@ export const WAVE2_TOOLS = [
|
|
|
341
356
|
},
|
|
342
357
|
{
|
|
343
358
|
name: "shell_task_status", safe: true,
|
|
344
|
-
contract: { v: 1, effects: ["read"
|
|
359
|
+
contract: { v: 1, effects: ["read"] },
|
|
345
360
|
description: "Check a background task's status and tail its log. Optionally match a regex in recent output.",
|
|
346
361
|
parameters: { type: "object", properties: {
|
|
347
362
|
id: { type: "string" },
|
|
@@ -351,14 +366,14 @@ export const WAVE2_TOOLS = [
|
|
|
351
366
|
},
|
|
352
367
|
{
|
|
353
368
|
name: "shell_task_list", safe: true,
|
|
354
|
-
contract: { v: 1, effects: ["read"
|
|
369
|
+
contract: { v: 1, effects: ["read"] },
|
|
355
370
|
description: "List background shell tasks and their status (running/stopped).",
|
|
356
371
|
parameters: { type: "object", properties: {} },
|
|
357
372
|
run: shellTaskListRun,
|
|
358
373
|
},
|
|
359
374
|
{
|
|
360
375
|
name: "shell_task_kill", safe: false,
|
|
361
|
-
contract: { v: 1, effects: ["destructive"] },
|
|
376
|
+
contract: { v: 1, effects: ["destructive"], bins: ["ps"] },
|
|
362
377
|
description: "Terminate a background shell task (and its process group) by id.",
|
|
363
378
|
parameters: { type: "object", properties: {
|
|
364
379
|
id: { type: "string" },
|
package/dist/ui/App.js
CHANGED
|
@@ -45,7 +45,7 @@ function BackgroundHint({ rows }) {
|
|
|
45
45
|
return hint ? _jsx(Text, { dimColor: true, children: ` · ${hint}` }) : null;
|
|
46
46
|
}
|
|
47
47
|
export function App(props) {
|
|
48
|
-
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, prefill = "", liveTools = [], route, ctxPct,
|
|
48
|
+
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, prefill = "", liveTools = [], route, ctxPct, ctxWindow, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], onBackground, tasks = [], onSubmit, onQueue, queuedPreview = [], onEditQueued, onDropQueued, onInterrupt, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null } = props;
|
|
49
49
|
useTerminalSize(); // subscribe so the inline pinned UI (status rule, composer, footer) reflows the instant the terminal resizes
|
|
50
50
|
const thinking = status === "thinking" || status === "streaming";
|
|
51
51
|
// A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
|
|
@@ -60,7 +60,7 @@ export function App(props) {
|
|
|
60
60
|
// be scrolled off. The Composer is `suspended` (keystrokes route to the decision, not the draft).
|
|
61
61
|
const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(SecretPrompt, { pending: secretPrompt }), _jsx(QuestionPrompt, { pending: planExitPicker }), _jsx(ArtifactPicker, { pending: artifactsPicker }), _jsx(SessionPicker, { pending: sessionsPicker })] }));
|
|
62
62
|
// The pinned bottom band: status rule, composer, bottom rule, then the mode/cycle FOOTER below the rule.
|
|
63
|
-
const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct,
|
|
63
|
+
const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxWindow: ctxWindow, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview.length ? _jsx(Text, { color: "yellow", children: queuedHint(queuedPreview) }) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, queued: queuedPreview.length, onEditQueued: onEditQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} ` })] }))] }));
|
|
64
64
|
// Fullscreen (opt-in): a full-terminal-height column. The transcript fills a clipped, bottom-anchored
|
|
65
65
|
// region (non-Static tail) so the newest output sits just above a composer pinned to the very bottom —
|
|
66
66
|
// no dead space. Off by default: inline keeps the terminal's native scrollback (mouse-scroll + copy).
|
package/dist/ui/StatusRule.js
CHANGED
|
@@ -44,6 +44,7 @@ export function truncateToWidth(s, max) {
|
|
|
44
44
|
// the terminal is too narrow to hold every badge, `info` is truncated so cellWidth(right) ≤ cols-3 —
|
|
45
45
|
// which keeps the leading fill ≥ 1 and the whole line at cols-1, so the rule never becomes the line that
|
|
46
46
|
// wraps (the creep bug) no matter how many badges are lit or how narrow the window.
|
|
47
|
+
const ROUTE_LABELS = { "operator-1m": "aurora" };
|
|
47
48
|
export function statusRight(p, cols) {
|
|
48
49
|
const who = p.user ? `◆ ${p.user} · ` : "";
|
|
49
50
|
const seat = p.tier && p.tier !== "admin" ? `⛨ ${p.tier} · ` : ""; // a narrowed seat shows; owner's admin doesn't
|
|
@@ -51,12 +52,12 @@ export function statusRight(p, cols) {
|
|
|
51
52
|
const think = p.thinkMode === "ultrathink" ? `✲✲ ultrathink · ` : p.thinkMode === "think" ? `✲ think · ` : "";
|
|
52
53
|
const tok = p.sessionTokens && p.sessionTokens > 0 ? `Σ${fmtK(p.sessionTokens)} · ` : ""; // session token total
|
|
53
54
|
// ctx as a fill ring (○◔◑◕●) + the exact % — a glance shows how full the context window is, the number keeps precision.
|
|
54
|
-
// Show the active model
|
|
55
|
-
// ("cortana@192.168.1.103:8112" read as noise; /endpoints lists the legs).
|
|
56
|
-
//
|
|
57
|
-
const routeLabel = p.route;
|
|
58
|
-
const
|
|
59
|
-
let info = `${think}${plan}${seat}${who}${routeLabel}
|
|
55
|
+
// Show the active model (cortana, claude-opus, moa, custom …) and the window it runs on, never the leg that answered
|
|
56
|
+
// ("cortana@192.168.1.103:8112" read as noise; /endpoints lists the legs). The default model reads as "aurora", not
|
|
57
|
+
// its id operator-1m (owner, 11/03: "just aurora 300k"), and the window is the one served, not a pin above it.
|
|
58
|
+
const routeLabel = ROUTE_LABELS[p.route] ?? p.route;
|
|
59
|
+
const window = p.ctxWindow ? ` ${p.ctxWindow}` : "";
|
|
60
|
+
let info = `${think}${plan}${seat}${who}${routeLabel}${window} ${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
|
|
60
61
|
let right = `✷ OPERATOR · ${info} ─`;
|
|
61
62
|
const maxRight = cols - 3; // leaves fill ≥ 1 and total = cols-1
|
|
62
63
|
if (cellWidth(right) > maxRight) {
|