@0perator/operator 0.2.0 → 0.2.2-next.0
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/README.md +5 -4
- package/dist/auth/byo.js +1 -1
- package/dist/auth/commands.js +15 -5
- package/dist/auth/identity.js +1 -0
- package/dist/auth/staff.js +55 -0
- package/dist/autonomy/agent-cli.js +1 -1
- package/dist/autonomy/delegate-mode.js +2 -2
- package/dist/autonomy/delegate.js +41 -14
- package/dist/autonomy/headless.js +37 -10
- package/dist/autonomy/index.js +2 -4
- package/dist/autonomy/pr-isolation.js +92 -0
- package/dist/autonomy/pr-preflight.js +474 -0
- package/dist/autonomy/session-factory.js +13 -12
- package/dist/autonomy/subagent-model.js +17 -7
- package/dist/background/capacity.js +136 -0
- package/dist/background/evidence.js +42 -0
- package/dist/background/index.js +311 -44
- package/dist/background/lane-phase.js +60 -0
- package/dist/background/lane-summary.js +151 -0
- package/dist/background/notices.js +12 -3
- package/dist/background/synthesis.js +25 -0
- package/dist/browser/capture.js +505 -0
- package/dist/browser/engine.js +4 -3
- package/dist/browser/page-capture.js +167 -0
- package/dist/browser/png.js +116 -0
- package/dist/browser/visual-compare.js +229 -0
- package/dist/bus/beam-drop.js +55 -0
- package/dist/bus/inbox.js +157 -7
- package/dist/cli.js +316 -120
- package/dist/config/features.js +3 -3
- package/dist/config/managed.js +40 -1
- package/dist/config/persona.js +80 -29
- package/dist/config/product-hosts.js +2 -0
- package/dist/config/settings.js +289 -31
- package/dist/config/skills-index.js +37 -14
- package/dist/config/staff-prompt.js +12 -0
- package/dist/engine/agent.js +52 -41
- package/dist/engine/aurora.js +54 -13
- package/dist/engine/batch-scheduler.js +4 -13
- package/dist/engine/compaction.js +1 -1
- package/dist/engine/continuation.js +66 -32
- package/dist/engine/decision-points.js +2 -3
- package/dist/engine/fanout.js +16 -0
- package/dist/engine/identity.js +42 -0
- package/dist/engine/loop-guard.js +26 -83
- package/dist/engine/messages.js +2 -2
- package/dist/engine/moa.js +23 -1
- package/dist/engine/native-vision-node.js +72 -0
- package/dist/engine/native-vision.js +103 -0
- package/dist/engine/net-error.js +15 -0
- package/dist/engine/rolling-summary.js +142 -93
- package/dist/engine/verify-gate.js +37 -7
- package/dist/engine/waterfall.js +33 -0
- package/dist/gateway-cli.js +24 -4
- package/dist/memory/live-progress.js +4 -5
- package/dist/memory/session-index.js +3 -3
- package/dist/moa/codeact-lane.js +98 -0
- package/dist/moa/codeact-sandbox.js +409 -0
- package/dist/moa/codeact.js +140 -0
- package/dist/permissions/artifact-visibility.js +10 -0
- package/dist/permissions/index.js +2 -1
- package/dist/permissions/policy.js +9 -2
- package/dist/permissions/tier.js +13 -3
- package/dist/products/craft.js +92 -3
- package/dist/products/temple.js +20 -1
- package/dist/products/voice.js +112 -0
- package/dist/remote/grants.js +119 -0
- package/dist/remote/host.js +33 -5
- package/dist/router/free-models.js +5 -9
- package/dist/router/models.js +80 -26
- package/dist/router/provider-models.js +78 -0
- package/dist/router/router.js +15 -3
- package/dist/selfimprove/index.js +8 -6
- package/dist/selfimprove/lessons.js +23 -0
- package/dist/services/preflight.js +35 -91
- package/dist/session.js +316 -125
- package/dist/skills/catalogue.js +5 -2
- package/dist/skills/finder.js +4 -4
- package/dist/skills/install-guard.js +68 -0
- package/dist/skills/install.js +67 -0
- package/dist/toolchain/manifest.json +13 -13
- package/dist/tools/background-result.js +1 -1
- package/dist/tools/beam.js +246 -0
- package/dist/tools/classes.js +103 -0
- package/dist/tools/contract.js +1 -1
- package/dist/tools/craft.js +36 -2
- package/dist/tools/deferred.js +7 -3
- package/dist/tools/doc-text.js +1 -1
- package/dist/tools/executor.js +25 -15
- package/dist/tools/generation-gateway.js +94 -0
- package/dist/tools/registry.js +135 -158
- package/dist/tools/sandbox.js +6 -6
- package/dist/ui/App.js +17 -6
- package/dist/ui/ApprovalPrompt.js +1 -1
- package/dist/ui/BgPanel.js +15 -10
- package/dist/ui/Composer.js +44 -2
- package/dist/ui/Header.js +1 -6
- package/dist/ui/StatusRule.js +20 -8
- package/dist/ui/ToolStep.js +3 -3
- package/dist/ui/Transcript.js +41 -14
- package/dist/ui/batchLine.js +4 -4
- package/dist/ui/editdiff.js +2 -4
- package/dist/ui/format.js +4 -20
- package/dist/ui/liveTools.js +3 -3
- package/dist/ui/modelPicker.js +10 -6
- package/dist/ui/opsMode.js +20 -0
- package/dist/ui/phase.js +4 -2
- package/dist/ui/slashCommands.js +1 -0
- package/dist/ui/types.js +0 -2
- package/dist/ui/voice.js +185 -0
- package/dist/update-check.js +17 -6
- package/dist/update.js +1 -2
- package/dist/util/audio-io.js +82 -0
- package/dist/util/slash.js +2 -2
- package/dist/vision/pairs.js +239 -0
- package/package.json +1 -1
- package/dist/tools/mutating.js +0 -15
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// The lane's "what is it doing" line, in plain words, from real signals only: the running tool and its key argument, the
|
|
2
|
+
// plan step it marked in progress, and the stream phase with its progress. Never the backend (that explains a wait, so it
|
|
3
|
+
// lives in the queued reason and /agents <id>), never a full command line, and redacted before it reaches the TUI. Pure.
|
|
4
|
+
import { redactSecrets } from "../engine/redact.js";
|
|
5
|
+
import { fmtElapsed, fmtTok } from "../ui/format.js";
|
|
6
|
+
import { FILE_READ, LOCAL_SEARCH, PLAN_TOOLS, SHELL_ANY, WEB_FETCH, WEB_SEARCH } from "../tools/classes.js";
|
|
7
|
+
/** Fits one lane line at 100 columns beside the name, round, elapsed and tokens. */
|
|
8
|
+
export const SUMMARY_MAX = 56;
|
|
9
|
+
const WRITES = { file_write: "writing", file_create: "writing", write_file: "writing", file_edit: "editing", edit_file: "editing", multi_edit: "editing", apply_patch: "patching", notebook_edit: "editing" };
|
|
10
|
+
const str = (v) => (typeof v === "string" && v.trim() ? v.replace(/\s+/g, " ").trim() : undefined);
|
|
11
|
+
const num = (v) => (typeof v === "number" && Number.isFinite(v) ? v : typeof v === "string" && /^\d+$/.test(v) ? Number(v) : undefined);
|
|
12
|
+
const base = (p) => p.replace(/[/\\]+$/, "").split(/[/\\]/).pop() || p;
|
|
13
|
+
const quoted = (s, n = 28) => `"${s.length > n ? `${s.slice(0, n - 1)}…` : s}"`;
|
|
14
|
+
/** Trim to `max` cells with a clean "…" (never mid-surrogate). */
|
|
15
|
+
export function clip(s, max = SUMMARY_MAX) {
|
|
16
|
+
const chars = [...s];
|
|
17
|
+
return chars.length <= max ? s : `${chars.slice(0, max - 1).join("").trimEnd()}…`;
|
|
18
|
+
}
|
|
19
|
+
function lineWindow(args) {
|
|
20
|
+
const start = num(args.start_line) ?? num(args.offset) ?? num(args.line);
|
|
21
|
+
const end = num(args.end_line) ?? (start !== undefined && num(args.limit) !== undefined ? start + num(args.limit) - 1 : undefined);
|
|
22
|
+
if (start === undefined)
|
|
23
|
+
return num(args.limit) !== undefined ? `lines 1–${num(args.limit)}` : undefined;
|
|
24
|
+
return end !== undefined ? `lines ${start}–${end}` : `from line ${start}`;
|
|
25
|
+
}
|
|
26
|
+
const WRAPPERS = new Set(["sudo", "nice", "time", "env", "nohup", "exec"]);
|
|
27
|
+
/** The program a command runs, without its arguments: env assignments and `cd …&&` are skipped, a path is cut to its name. */
|
|
28
|
+
export function commandWord(cmd) {
|
|
29
|
+
const words = cmd.trim().split(/\s+/).filter(Boolean);
|
|
30
|
+
for (let i = 0; i < words.length; i++) {
|
|
31
|
+
const w = words[i];
|
|
32
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(w) || WRAPPERS.has(w) || /^-/.test(w) || /^\d+$/.test(w))
|
|
33
|
+
continue;
|
|
34
|
+
if (w === "cd") {
|
|
35
|
+
while (i < words.length && !/^(&&|;)$/.test(words[i]) && !/;$/.test(words[i]))
|
|
36
|
+
i++;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (/^(&&|;|\|\|)$/.test(w))
|
|
40
|
+
continue;
|
|
41
|
+
return base(w).replace(/[^\w.+-]/g, "") || undefined;
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
/** One tool call in plain words: "reading digest.md (lines 1–900)", "searching the repo for "relayClient"". */
|
|
46
|
+
export function toolSummary(name, args = {}) {
|
|
47
|
+
const path = str(args.path) ?? str(args.file_path) ?? str(args.file) ?? (Array.isArray(args.paths) ? str(args.paths[0]) : undefined);
|
|
48
|
+
if (FILE_READ.has(name)) {
|
|
49
|
+
const more = Array.isArray(args.paths) && args.paths.length > 1 ? ` +${args.paths.length - 1}` : "";
|
|
50
|
+
const win = lineWindow(args);
|
|
51
|
+
return path ? `reading ${base(path)}${more}${win ? ` (${win})` : ""}` : "reading files";
|
|
52
|
+
}
|
|
53
|
+
if (LOCAL_SEARCH.has(name)) {
|
|
54
|
+
const q = str(args.pattern) ?? str(args.query) ?? str(args.glob) ?? str(args.name);
|
|
55
|
+
return q ? `searching the repo for ${quoted(q)}` : "searching the repo";
|
|
56
|
+
}
|
|
57
|
+
if (WEB_SEARCH.has(name)) {
|
|
58
|
+
const q = str(args.query);
|
|
59
|
+
return q ? `searching the web for ${quoted(q)}` : "searching the web";
|
|
60
|
+
}
|
|
61
|
+
if (WEB_FETCH.has(name)) {
|
|
62
|
+
const u = str(args.url);
|
|
63
|
+
let host;
|
|
64
|
+
try {
|
|
65
|
+
host = u ? new URL(u).hostname : undefined;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
host = undefined;
|
|
69
|
+
}
|
|
70
|
+
return host ? `fetching ${host}` : "browsing";
|
|
71
|
+
}
|
|
72
|
+
if (SHELL_ANY.has(name)) {
|
|
73
|
+
const d = str(args.description);
|
|
74
|
+
if (d)
|
|
75
|
+
return d.charAt(0).toLowerCase() + d.slice(1);
|
|
76
|
+
const w = str(args.command) ? commandWord(String(args.command)) : undefined;
|
|
77
|
+
return w ? `running ${w}` : "running a command";
|
|
78
|
+
}
|
|
79
|
+
if (WRITES[name])
|
|
80
|
+
return path ? `${WRITES[name]} ${base(path)}` : `${WRITES[name]} a file`;
|
|
81
|
+
if (PLAN_TOOLS.has(name))
|
|
82
|
+
return "updating its plan";
|
|
83
|
+
if (name === "message_agent")
|
|
84
|
+
return "messaging another agent";
|
|
85
|
+
if (name === "codeact_run")
|
|
86
|
+
return `running one ${str(args.language) ? `${str(args.language)} ` : ""}program over its targets`;
|
|
87
|
+
return name.replace(/_/g, " ");
|
|
88
|
+
}
|
|
89
|
+
/** The step a task_update put in progress, read from the tool's own result ("[>] #3 Check relay callers"). */
|
|
90
|
+
export function planStepFrom(args, result) {
|
|
91
|
+
if (args.status !== "in_progress")
|
|
92
|
+
return undefined;
|
|
93
|
+
const id = num(args.id);
|
|
94
|
+
const line = result.split("\n").find((l) => l.startsWith("[>]") && (id === undefined || l.startsWith(`[>] #${id} `)));
|
|
95
|
+
return line ? str(line.replace(/^\[>\]\s*#\d+\s*/, "")) : undefined;
|
|
96
|
+
}
|
|
97
|
+
/** The first clause of the agent's own progress line ("Checking the relay callers, then…" → "checking the relay callers"). */
|
|
98
|
+
function firstClause(s) {
|
|
99
|
+
const c = s?.split(/[.;:!?](?=\s|$)|,\s|\s—\s|\s-\s/)[0]?.trim();
|
|
100
|
+
return c ? c.charAt(0).toLowerCase() + c.slice(1) : undefined;
|
|
101
|
+
}
|
|
102
|
+
function poolBusy(reason) {
|
|
103
|
+
const m = reason ? /(\d+)\/(\d+) busy/.exec(reason) : null;
|
|
104
|
+
return m ? `pool ${m[1]}/${m[2]} busy` : undefined;
|
|
105
|
+
}
|
|
106
|
+
/** What the lane is doing now, short and redacted. Falls back to the agent's progress line, then "starting". */
|
|
107
|
+
export function laneSummary(a, now) {
|
|
108
|
+
const p = a.phase;
|
|
109
|
+
const step = a.planStep ? clip(a.planStep, 30) : undefined;
|
|
110
|
+
const t = p ? fmtElapsed(now - p.since) : "";
|
|
111
|
+
let s;
|
|
112
|
+
switch (p?.kind) {
|
|
113
|
+
case "queued":
|
|
114
|
+
case "slot": {
|
|
115
|
+
const busy = p.kind === "queued" ? poolBusy(a.queueReason) : p.holder ? `held by ${p.holder}` : undefined;
|
|
116
|
+
s = `waiting for a free model slot${busy ? ` (${busy})` : ""}`;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case "sent":
|
|
120
|
+
s = `${step ?? "waiting for the model"} (sent ${t} ago)`;
|
|
121
|
+
break;
|
|
122
|
+
case "reading": {
|
|
123
|
+
const fresh = Math.max(1, p.total - p.cached);
|
|
124
|
+
const pct = Math.min(100, Math.round((Math.max(0, p.processed - p.cached) / fresh) * 100));
|
|
125
|
+
s = `${step ? `${step}: ` : ""}reading its context (${fmtTok(fresh)} tok, ${pct}%)`;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "thinking":
|
|
129
|
+
case "writing": {
|
|
130
|
+
const n = p.tokens - p.startTokens;
|
|
131
|
+
const what = step ?? firstClause(a.progress) ?? p.kind;
|
|
132
|
+
s = `${what}${n > 0 ? ` (${fmtTok(n)} tok)` : ""}`;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "tool": {
|
|
136
|
+
const d = `${a.doing ?? p.name.replace(/_/g, " ")}${p.count > 1 ? ` +${p.count - 1}` : ""}`;
|
|
137
|
+
s = d.endsWith(")") ? `${d.slice(0, -1)}, ${t})` : `${d} (${t})`;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "between":
|
|
141
|
+
s = step ?? "between rounds";
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
s ??= firstClause(a.progress) ?? (a.steps?.length ? a.steps[a.steps.length - 1].name.replace(/_/g, " ") : undefined) ?? "starting";
|
|
145
|
+
// The trailing "(…)" carries the live numbers: keep it whole and cut the words before it.
|
|
146
|
+
const red = redactSecrets(s);
|
|
147
|
+
const tail = /\s(\([^()]*\))$/.exec(red);
|
|
148
|
+
if (!tail || [...red].length <= SUMMARY_MAX)
|
|
149
|
+
return clip(red);
|
|
150
|
+
return `${clip(red.slice(0, tail.index), SUMMARY_MAX - [...tail[1]].length - 1)} ${tail[1]}`;
|
|
151
|
+
}
|
|
@@ -10,6 +10,10 @@ const REPORT_CHARS = 8000; // the spawn brief asks for a ~1-2k token report; a r
|
|
|
10
10
|
// report on blank lines and print each paragraph — the model's instructions included — as its own "⤷" line.
|
|
11
11
|
const reports = [];
|
|
12
12
|
const listeners = new Set();
|
|
13
|
+
let gate = () => ({ ready: true, missing: "" });
|
|
14
|
+
export function setReportGate(fn) {
|
|
15
|
+
gate = fn ?? (() => ({ ready: true, missing: "" }));
|
|
16
|
+
}
|
|
13
17
|
const clip = (s, n) => s.length <= n ? s : s.slice(0, n) + `\n… [report clipped at ${n} chars — re-run the sub-agent with a tighter deliverable if the rest matters]`;
|
|
14
18
|
const who = (a) => `${a.name ? `${a.name} (${a.title ?? "sub-agent"}, ${a.id})` : `sub-agent ${a.id}`} — ${a.label}`;
|
|
15
19
|
/** The notice the model reads when a sub-agent finishes: who, what it changed, its report — and what to do with it.
|
|
@@ -38,7 +42,7 @@ export function ownerLine(agent, result) {
|
|
|
38
42
|
}
|
|
39
43
|
/** Queue a stuck notice for the next turn and wake the shell (same channel as a finished report). */
|
|
40
44
|
export function queueAgentNotice(text, owner = "a sub-agent notice") {
|
|
41
|
-
reports.push({ text, owner });
|
|
45
|
+
reports.push({ text, owner, kind: "notice" });
|
|
42
46
|
for (const fn of listeners) {
|
|
43
47
|
try {
|
|
44
48
|
fn();
|
|
@@ -48,7 +52,7 @@ export function queueAgentNotice(text, owner = "a sub-agent notice") {
|
|
|
48
52
|
}
|
|
49
53
|
/** Queue a finished agent's report for the next turn and tell the shell (which wakes an idle session). */
|
|
50
54
|
export function queueAgentReport(agent, result) {
|
|
51
|
-
reports.push({ text: formatAgentReport(agent, result), owner: ownerLine(agent, result) });
|
|
55
|
+
reports.push({ text: formatAgentReport(agent, result), owner: ownerLine(agent, result), kind: "report" });
|
|
52
56
|
for (const fn of listeners) {
|
|
53
57
|
try {
|
|
54
58
|
fn();
|
|
@@ -59,10 +63,15 @@ export function queueAgentReport(agent, result) {
|
|
|
59
63
|
export function pendingAgentReports() {
|
|
60
64
|
return reports.length;
|
|
61
65
|
}
|
|
66
|
+
/** Whether queued reports should wake the session now: any notice, or reports once the synthesis gate is ready. */
|
|
67
|
+
export function agentReportsDue() {
|
|
68
|
+
return reports.some((r) => r.kind === "notice") || (reports.length > 0 && gate().ready);
|
|
69
|
+
}
|
|
62
70
|
/** Take every queued report: the model's text (joined, byte-identical to what it always was) and the owner lines. */
|
|
63
71
|
export function drainAgentNotices() {
|
|
64
72
|
const taken = reports.splice(0);
|
|
65
|
-
|
|
73
|
+
const missing = taken.some((r) => r.kind === "report") ? gate().missing : "";
|
|
74
|
+
return { text: [...taken.map((r) => r.text), ...(missing ? [missing] : [])].join("\n\n"), owners: taken.map((r) => r.owner) };
|
|
66
75
|
}
|
|
67
76
|
/** Take every queued report (joined), or "" when none. Called at the start of a turn. */
|
|
68
77
|
export function drainAgentReports() {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { fmtElapsed } from "../ui/format.js";
|
|
2
|
+
const live = (a) => a.status === "working" || a.status === "queued";
|
|
3
|
+
export function synthesisState(agents, now) {
|
|
4
|
+
const running = agents.filter(live);
|
|
5
|
+
const waitingOn = running.filter((a) => a.optional !== true).map((a) => a.name ?? a.id);
|
|
6
|
+
const missing = running.filter((a) => a.optional === true).map((a) => ({
|
|
7
|
+
name: a.name ?? a.id,
|
|
8
|
+
reason: a.deadlineAt !== undefined && now > a.deadlineAt ? `optional, ${fmtElapsed(now - a.deadlineAt)} past its deadline` : "optional, still running",
|
|
9
|
+
}));
|
|
10
|
+
return { ready: waitingOn.length === 0, waitingOn, missing };
|
|
11
|
+
}
|
|
12
|
+
/** The line the parent reads with the reports it synthesizes from. "" when nothing is missing. */
|
|
13
|
+
export function missingLine(missing) {
|
|
14
|
+
if (!missing.length)
|
|
15
|
+
return "";
|
|
16
|
+
return `[system notice] missing: ${missing.map((m) => `${m.name} (${m.reason})`).join(", ")}. Synthesize from the reports you have ` +
|
|
17
|
+
`and say what is missing; a late report arrives on its own if it finishes — do not wait or poll for it.`;
|
|
18
|
+
}
|
|
19
|
+
/** The lane's deadline words: "4m 10s left", "overdue 1m 2s". Undefined without a deadline. */
|
|
20
|
+
export function deadlineText(a, now) {
|
|
21
|
+
if (a.deadlineAt === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
const left = a.deadlineAt - now;
|
|
24
|
+
return left >= 0 ? `⏱ ${fmtElapsed(left)} left` : `⏱ overdue ${fmtElapsed(-left)}${a.optional ? " (not waited on)" : ""}`;
|
|
25
|
+
}
|