@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
package/dist/bus/inbox.js
CHANGED
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
//
|
|
7
7
|
// SECURITY: a bus message is DATA written by another agent — untrusted input. The UI surfaces it to the
|
|
8
8
|
// operator; nothing here executes message contents.
|
|
9
|
-
import { readdirSync, readFileSync, renameSync, mkdirSync, existsSync } from "node:fs";
|
|
10
|
-
import {
|
|
9
|
+
import { readdirSync, readFileSync, renameSync, mkdirSync, existsSync, writeFileSync, realpathSync } from "node:fs";
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { isAbsolute, join, sep } from "node:path";
|
|
11
12
|
import { homedir, hostname } from "node:os";
|
|
13
|
+
import { redactSecrets } from "../engine/redact.js";
|
|
14
|
+
import { beamDrop, beamDropWake } from "./beam-drop.js";
|
|
12
15
|
/** The bus state root — mirrors the switchboard CLI's SWITCHBOARD_DIR. Neutral default (~/.switchboard) so
|
|
13
16
|
* this works on any box/surface, not just the AXE fleet; the env var repoints it wherever the bus lives. */
|
|
14
17
|
export function busDir() {
|
|
@@ -63,14 +66,25 @@ export function pollBus(agent = selfAgent(), opts = {}) {
|
|
|
63
66
|
* allowlist). PURE + tested — the cli.tsx poller calls this, then routes the text to the submit/queue path.
|
|
64
67
|
* Contract: a rendered bus message is only displayed; THIS is what puts a peer message into the model's context
|
|
65
68
|
* as an actionable turn. `allow` unset/empty = any sender wakes; otherwise only senders in the list. */
|
|
66
|
-
export function buildMentorWake(incoming, allow) {
|
|
67
|
-
const toWake = allow && allow.length ? incoming.filter((m) => allow.includes(m.from)) : incoming;
|
|
69
|
+
export function buildMentorWake(incoming, allow, rootPolicy) {
|
|
70
|
+
const toWake = (allow && allow.length ? incoming.filter((m) => allow.includes(m.from)) : incoming).filter((m) => !isAutoReport(m));
|
|
68
71
|
if (!toWake.length)
|
|
69
72
|
return null;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
const dir = rootPolicy ? wakeWorkdir(toWake, rootPolicy) : null;
|
|
74
|
+
const frame = `[mentor-wake] ${toWake.length} new bus message(s) arrived — review and act on them now:\n\n` +
|
|
75
|
+
toWake.map((m) => `--- from ${m.from}${m.subject ? ` · ${m.subject}` : ""} (${m.ts}) ---\n${wakeBody(m)}`).join("\n\n") +
|
|
76
|
+
(dir ? `\n\nThe harness set this turn's working directory to ${dir} (the brief's worktree): relative paths and shell commands resolve there for this turn only, then the session returns to its own folder.` : "") +
|
|
77
|
+
`\n\n${replyProtocol([...new Set(toWake.map((m) => m.from))])}`;
|
|
78
|
+
wakeRegistry.set(frame, { msgs: toWake, dir });
|
|
79
|
+
while (wakeRegistry.size > WAKE_REGISTRY_MAX)
|
|
80
|
+
wakeRegistry.delete(wakeRegistry.keys().next().value);
|
|
81
|
+
return frame;
|
|
73
82
|
}
|
|
83
|
+
/** A beam drop wakes with its one line and the sender's digest as quoted data, never the raw manifest. */
|
|
84
|
+
const wakeBody = (m) => {
|
|
85
|
+
const drop = beamDrop(m);
|
|
86
|
+
return drop ? beamDropWake(drop) : m.body;
|
|
87
|
+
};
|
|
74
88
|
/** The reply contract a woken turn owes its sender, spelled out in the frame itself. The sender is another agent
|
|
75
89
|
* on the bus and cannot see this screen: a turn that works in silence is invisible to the teacher, and the plan
|
|
76
90
|
* message BEFORE the work is what lets the teacher stop a wrong plan early. It lived only in memories.md until
|
|
@@ -127,3 +141,139 @@ export function pollSent(agent = selfAgent(), opts = {}) {
|
|
|
127
141
|
}
|
|
128
142
|
return out;
|
|
129
143
|
}
|
|
144
|
+
// ── Report delivery: a woken turn's answer reaches its sender ────────────────────────────────────────────────────
|
|
145
|
+
// replyProtocol asks the turn to send a report; nothing checked it, so a turn that ended without one left the sender
|
|
146
|
+
// with nothing (11/24: four D6 turns, zero replies). Claude Code returns a sub-agent's final message to its parent and
|
|
147
|
+
// `codex exec -o` writes the last message for its caller; the bus counterpart is below: at the end of a mentor-wake
|
|
148
|
+
// turn, each sender that got nothing from this agent during the turn receives the turn's final answer, marked
|
|
149
|
+
// auto-delivered. A turn that did reply is left alone.
|
|
150
|
+
/** The senders a `[mentor-wake]` frame came from (its `--- from <name>[ · subject] (<ts>) ---` headers), in order. */
|
|
151
|
+
/** The bus messages a wake frame was built from, recorded when the harness built it. The senders a woken turn
|
|
152
|
+
* owes a report come from here, never from the frame's text: a message body can contain a line that looks like a
|
|
153
|
+
* "--- from X ---" header. */
|
|
154
|
+
const wakeRegistry = new Map();
|
|
155
|
+
const WAKE_REGISTRY_MAX = 64;
|
|
156
|
+
function wakeEntry(turnText) {
|
|
157
|
+
for (const [frame, e] of wakeRegistry)
|
|
158
|
+
if (turnText === frame || turnText.endsWith(frame))
|
|
159
|
+
return e;
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
/** The messages behind the wake frame in this turn's text (a job notice may be prepended), or [] for any other turn. */
|
|
163
|
+
export function wakeMessages(turnText) {
|
|
164
|
+
return wakeEntry(turnText)?.msgs ?? [];
|
|
165
|
+
}
|
|
166
|
+
/** The working directory the harness chose for this wake turn (wakeWorkdir), or null. Read from the registry, never
|
|
167
|
+
* from the frame's text: a message body cannot set it. */
|
|
168
|
+
export function wakeRoot(turnText) {
|
|
169
|
+
return wakeEntry(turnText)?.dir ?? null;
|
|
170
|
+
}
|
|
171
|
+
const realDir = (p) => { try {
|
|
172
|
+
return realpathSync(p);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return null;
|
|
176
|
+
} };
|
|
177
|
+
const isCheckoutTop = (dir) => existsSync(join(dir, ".git"));
|
|
178
|
+
/** The one working directory a batch of wake messages names in its refs (`worktree`, else `cwd`), or null. It must be
|
|
179
|
+
* the same across the batch, absolute, and after realpath a git checkout's top folder inside one of the policy's
|
|
180
|
+
* roots — never `/`, $HOME, ~/.ssh or a root itself. The bus counterpart of Codex `--cd` and Claude Code's worktree
|
|
181
|
+
* isolation for a delegated agent. */
|
|
182
|
+
export function wakeWorkdir(msgs, policy, isTop = isCheckoutTop) {
|
|
183
|
+
const dirs = new Set();
|
|
184
|
+
for (const m of msgs) {
|
|
185
|
+
const v = m.refs?.worktree ?? m.refs?.cwd;
|
|
186
|
+
if (typeof v === "string" && v.trim())
|
|
187
|
+
dirs.add(v.trim().replace(/\/+$/, ""));
|
|
188
|
+
}
|
|
189
|
+
if (dirs.size !== 1)
|
|
190
|
+
return null;
|
|
191
|
+
const [named] = [...dirs];
|
|
192
|
+
if (!named || !isAbsolute(named))
|
|
193
|
+
return null;
|
|
194
|
+
const dir = realDir(named);
|
|
195
|
+
if (!dir || !isTop(dir))
|
|
196
|
+
return null;
|
|
197
|
+
const inside = policy.roots.map(realDir).some((r) => r && dir !== r && dir.startsWith(r.endsWith(sep) ? r : r + sep));
|
|
198
|
+
return inside ? dir : null;
|
|
199
|
+
}
|
|
200
|
+
/** An auto-delivered report: delivered to the inbox like any message but never wakes a turn, so two Operators
|
|
201
|
+
* can't answer each other's auto-reports forever. */
|
|
202
|
+
export function isAutoReport(m) {
|
|
203
|
+
return m.meta?.auto === true;
|
|
204
|
+
}
|
|
205
|
+
/** Whether `agent` already sent `to` this answer since `sinceMs` (the model replied itself, or quoted its final
|
|
206
|
+
* answer). A plan or progress message to the sender does not count: only the final answer closes the loop. */
|
|
207
|
+
export function reportedTo(agent, to, sinceMs, answer) {
|
|
208
|
+
const probe = answer.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
209
|
+
for (const dir of [sentOf(agent), sentReadOf(agent)]) {
|
|
210
|
+
if (!existsSync(dir))
|
|
211
|
+
continue;
|
|
212
|
+
let files;
|
|
213
|
+
try {
|
|
214
|
+
files = readdirSync(dir).filter((f) => f.endsWith(".json") && !f.startsWith(".tmp-"));
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
for (const f of files) {
|
|
220
|
+
const stamp = Number(f.split("-")[0]);
|
|
221
|
+
if (Number.isFinite(stamp) && stamp && stamp < sinceMs)
|
|
222
|
+
continue; // the file name leads with its send time (ms)
|
|
223
|
+
try {
|
|
224
|
+
const m = JSON.parse(readFileSync(join(dir, f), "utf8"));
|
|
225
|
+
if (m.to === to && Date.parse(m.ts) >= sinceMs && m.body.replace(/\s+/g, " ").includes(probe))
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
catch { /* skip corrupt */ }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
export function busSend(from, to, body, opts = {}) {
|
|
234
|
+
const id = randomUUID();
|
|
235
|
+
const msg = { id, from, to, ts: new Date().toISOString(), subject: opts.subject ?? null, thread: opts.thread ?? null, body, ...(opts.auto ? { meta: { auto: true } } : {}) };
|
|
236
|
+
const name = `${String(Date.now()).padStart(15, "0")}-${id.slice(0, 8)}.json`;
|
|
237
|
+
for (const dir of [inboxOf(to), sentOf(from)]) {
|
|
238
|
+
mkdirSync(dir, { recursive: true });
|
|
239
|
+
const tmp = join(dir, `.tmp-${name}`);
|
|
240
|
+
writeFileSync(tmp, JSON.stringify(msg), { mode: 0o600 });
|
|
241
|
+
renameSync(tmp, join(dir, name));
|
|
242
|
+
}
|
|
243
|
+
return id;
|
|
244
|
+
}
|
|
245
|
+
export const AUTO_REPORT_MAX = 8_000;
|
|
246
|
+
/** Who a woken turn owes a report, with the thread to answer in (the sender's last message's). */
|
|
247
|
+
function owed(turnText, agent) {
|
|
248
|
+
const last = new Map();
|
|
249
|
+
for (const m of wakeMessages(turnText))
|
|
250
|
+
if (m.from !== agent)
|
|
251
|
+
last.set(m.from, m);
|
|
252
|
+
return [...last.values()].map((m) => ({ to: m.from, thread: m.thread ?? m.id }));
|
|
253
|
+
}
|
|
254
|
+
/** A woken turn ended without sending its final answer to a sender: the harness delivers it (Claude Code returns a
|
|
255
|
+
* sub-agent's final message to its parent; `codex exec -o` writes it for the caller). One sender gets the answer;
|
|
256
|
+
* when one turn answered several senders, each gets a short note instead, so one agent's report never goes to
|
|
257
|
+
* another. Secrets are redacted and the message is tagged auto, so it never wakes the receiver. */
|
|
258
|
+
export function autoDeliverReport(turnText, finalAnswer, sinceMs, agent = selfAgent()) {
|
|
259
|
+
const answer = redactSecrets(finalAnswer.trim());
|
|
260
|
+
if (!answer)
|
|
261
|
+
return [];
|
|
262
|
+
const due = owed(turnText, agent).filter((o) => !reportedTo(agent, o.to, sinceMs, answer));
|
|
263
|
+
const shared = owed(turnText, agent).length > 1;
|
|
264
|
+
for (const o of due) {
|
|
265
|
+
const body = shared
|
|
266
|
+
? `Auto-delivered by Operator's harness: one turn handled messages from several agents and ended without a report to you. Its answer is not forwarded to keep reports separate; ask ${agent} or its owner for your part.`
|
|
267
|
+
: `Auto-delivered by Operator's harness: this turn ended without a report to you, so its final answer follows.\n\n${answer.length > AUTO_REPORT_MAX ? `${answer.slice(0, AUTO_REPORT_MAX)}\n… (cut at ${AUTO_REPORT_MAX} characters)` : answer}`;
|
|
268
|
+
busSend(agent, o.to, body, { subject: "Report (auto-delivered)", thread: o.thread, auto: true });
|
|
269
|
+
}
|
|
270
|
+
return due.map((o) => o.to);
|
|
271
|
+
}
|
|
272
|
+
/** A woken turn was interrupted or failed: its senders get a short note instead of silence. */
|
|
273
|
+
export function autoDeliverFailure(turnText, reason, agent = selfAgent()) {
|
|
274
|
+
const due = owed(turnText, agent);
|
|
275
|
+
for (const o of due) {
|
|
276
|
+
busSend(agent, o.to, `Auto-delivered by Operator's harness: the turn that took your message was ${reason} before it finished. No report was produced; resend the task if it is still needed.`, { subject: `Report (${reason})`, thread: o.thread, auto: true });
|
|
277
|
+
}
|
|
278
|
+
return due.map((o) => o.to);
|
|
279
|
+
}
|