@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.
Files changed (117) hide show
  1. package/README.md +5 -4
  2. package/dist/auth/byo.js +1 -1
  3. package/dist/auth/commands.js +15 -5
  4. package/dist/auth/identity.js +1 -0
  5. package/dist/auth/staff.js +55 -0
  6. package/dist/autonomy/agent-cli.js +1 -1
  7. package/dist/autonomy/delegate-mode.js +2 -2
  8. package/dist/autonomy/delegate.js +41 -14
  9. package/dist/autonomy/headless.js +37 -10
  10. package/dist/autonomy/index.js +2 -4
  11. package/dist/autonomy/pr-isolation.js +92 -0
  12. package/dist/autonomy/pr-preflight.js +474 -0
  13. package/dist/autonomy/session-factory.js +13 -12
  14. package/dist/autonomy/subagent-model.js +17 -7
  15. package/dist/background/capacity.js +136 -0
  16. package/dist/background/evidence.js +42 -0
  17. package/dist/background/index.js +311 -44
  18. package/dist/background/lane-phase.js +60 -0
  19. package/dist/background/lane-summary.js +151 -0
  20. package/dist/background/notices.js +12 -3
  21. package/dist/background/synthesis.js +25 -0
  22. package/dist/browser/capture.js +505 -0
  23. package/dist/browser/engine.js +4 -3
  24. package/dist/browser/page-capture.js +167 -0
  25. package/dist/browser/png.js +116 -0
  26. package/dist/browser/visual-compare.js +229 -0
  27. package/dist/bus/beam-drop.js +55 -0
  28. package/dist/bus/inbox.js +157 -7
  29. package/dist/cli.js +316 -120
  30. package/dist/config/features.js +3 -3
  31. package/dist/config/managed.js +40 -1
  32. package/dist/config/persona.js +80 -29
  33. package/dist/config/product-hosts.js +2 -0
  34. package/dist/config/settings.js +289 -31
  35. package/dist/config/skills-index.js +37 -14
  36. package/dist/config/staff-prompt.js +12 -0
  37. package/dist/engine/agent.js +52 -41
  38. package/dist/engine/aurora.js +54 -13
  39. package/dist/engine/batch-scheduler.js +4 -13
  40. package/dist/engine/compaction.js +1 -1
  41. package/dist/engine/continuation.js +66 -32
  42. package/dist/engine/decision-points.js +2 -3
  43. package/dist/engine/fanout.js +16 -0
  44. package/dist/engine/identity.js +42 -0
  45. package/dist/engine/loop-guard.js +26 -83
  46. package/dist/engine/messages.js +2 -2
  47. package/dist/engine/moa.js +23 -1
  48. package/dist/engine/native-vision-node.js +72 -0
  49. package/dist/engine/native-vision.js +103 -0
  50. package/dist/engine/net-error.js +15 -0
  51. package/dist/engine/rolling-summary.js +142 -93
  52. package/dist/engine/verify-gate.js +37 -7
  53. package/dist/engine/waterfall.js +33 -0
  54. package/dist/gateway-cli.js +24 -4
  55. package/dist/memory/live-progress.js +4 -5
  56. package/dist/memory/session-index.js +3 -3
  57. package/dist/moa/codeact-lane.js +98 -0
  58. package/dist/moa/codeact-sandbox.js +409 -0
  59. package/dist/moa/codeact.js +140 -0
  60. package/dist/permissions/artifact-visibility.js +10 -0
  61. package/dist/permissions/index.js +2 -1
  62. package/dist/permissions/policy.js +9 -2
  63. package/dist/permissions/tier.js +13 -3
  64. package/dist/products/craft.js +92 -3
  65. package/dist/products/temple.js +20 -1
  66. package/dist/products/voice.js +112 -0
  67. package/dist/remote/grants.js +119 -0
  68. package/dist/remote/host.js +33 -5
  69. package/dist/router/free-models.js +5 -9
  70. package/dist/router/models.js +80 -26
  71. package/dist/router/provider-models.js +78 -0
  72. package/dist/router/router.js +15 -3
  73. package/dist/selfimprove/index.js +8 -6
  74. package/dist/selfimprove/lessons.js +23 -0
  75. package/dist/services/preflight.js +35 -91
  76. package/dist/session.js +316 -125
  77. package/dist/skills/catalogue.js +5 -2
  78. package/dist/skills/finder.js +4 -4
  79. package/dist/skills/install-guard.js +68 -0
  80. package/dist/skills/install.js +67 -0
  81. package/dist/toolchain/manifest.json +13 -13
  82. package/dist/tools/background-result.js +1 -1
  83. package/dist/tools/beam.js +246 -0
  84. package/dist/tools/classes.js +103 -0
  85. package/dist/tools/contract.js +1 -1
  86. package/dist/tools/craft.js +36 -2
  87. package/dist/tools/deferred.js +7 -3
  88. package/dist/tools/doc-text.js +1 -1
  89. package/dist/tools/executor.js +25 -15
  90. package/dist/tools/generation-gateway.js +94 -0
  91. package/dist/tools/registry.js +135 -158
  92. package/dist/tools/sandbox.js +6 -6
  93. package/dist/ui/App.js +17 -6
  94. package/dist/ui/ApprovalPrompt.js +1 -1
  95. package/dist/ui/BgPanel.js +15 -10
  96. package/dist/ui/Composer.js +44 -2
  97. package/dist/ui/Header.js +1 -6
  98. package/dist/ui/StatusRule.js +20 -8
  99. package/dist/ui/ToolStep.js +3 -3
  100. package/dist/ui/Transcript.js +41 -14
  101. package/dist/ui/batchLine.js +4 -4
  102. package/dist/ui/editdiff.js +2 -4
  103. package/dist/ui/format.js +4 -20
  104. package/dist/ui/liveTools.js +3 -3
  105. package/dist/ui/modelPicker.js +10 -6
  106. package/dist/ui/opsMode.js +20 -0
  107. package/dist/ui/phase.js +4 -2
  108. package/dist/ui/slashCommands.js +1 -0
  109. package/dist/ui/types.js +0 -2
  110. package/dist/ui/voice.js +185 -0
  111. package/dist/update-check.js +17 -6
  112. package/dist/update.js +1 -2
  113. package/dist/util/audio-io.js +82 -0
  114. package/dist/util/slash.js +2 -2
  115. package/dist/vision/pairs.js +239 -0
  116. package/package.json +1 -1
  117. package/dist/tools/mutating.js +0 -15
@@ -5,11 +5,9 @@
5
5
  // (there is no launchd; ensureServices returns everything "down" and the caller reports it).
6
6
  //
7
7
  // TWO tiers, and the split is the whole point:
8
- // • Aurora is SHARED infrastructure owned by launchd (co.0perator.gateway) — the router's jl2 backend, the
9
- // mobile app and LAN clients all read it — and it loads ON DEMAND (owner, 11/03): only the turn that needs
10
- // it starts it (ensureAurora, wired as the Session's onDemand hook). Boot never does: auroraAtBoot resolves
11
- // the published endpoint and reports `idle` for a local job that is not serving. Operator only ever brings
12
- // it UP; it NEVER stops Aurora on exit, because that would break every other client.
8
+ // • Aurora (co.0perator.gateway) is RETIRED (11/25): Operator never starts it — not at boot, not for a turn, not
9
+ // from /services. auroraAtBoot only resolves the published endpoint (server.json) and reports; `operator gateway
10
+ // start` refuses without --force. Operator also never stops it on exit.
13
11
  // • autopilot (:9333) is optional and handled the same start-only way (non-fatal if it won't come up).
14
12
  // • vision (:7788, axe.vision-bot) is OFF BY DEFAULT — the media-pipeline ADR (2026-10-19) keeps the
15
13
  // GPU with Aurora, so boot only PROBES + reports it (settings DEFAULTS ship autostart:false). Nothing
@@ -118,8 +116,9 @@ async function ensureLaunchd(name, healthUrl, okOnly, cfg, onProgress) {
118
116
  : { name, state: "down", detail: `started the launchd job but ${name} did not report ready at ${healthUrl} within ${waitSec}s` };
119
117
  }
120
118
  /** Start `name`'s launchd job: kickstart -k when it is loaded, else bootout any half-state and bootstrap the plist
121
- * fresh. Returns the report when it will not start it (autostart off, no label/uid, plist missing), else null. */
122
- async function kickLaunchd(name, cfg, onProgress) {
119
+ * fresh. Returns the report when it will not start it (autostart off, no label/uid, plist missing), else null.
120
+ * Optional companions only (autopilot, vision): nothing calls it for Aurora. */
121
+ export async function kickLaunchd(name, cfg, onProgress) {
123
122
  if (cfg.autostart === false)
124
123
  return { name, state: "down", detail: "down (autostart off)" };
125
124
  cfg = await withLegacyLabel(cfg);
@@ -141,7 +140,10 @@ async function kickLaunchd(name, cfg, onProgress) {
141
140
  }
142
141
  const run = cfg.launchctl ?? launchctl;
143
142
  const disabled = await run(["print-disabled", `gui/${uid}`]);
144
- if (disabled.code === 0 && isLaunchdDisabled(disabled.out, label))
143
+ // Fail closed: when launchd's disabled list cannot be read, the owner's `launchctl disable` cannot be honored, so nothing starts.
144
+ if (disabled.code !== 0)
145
+ return { name, state: "down", detail: `down (cannot read launchd's disabled list for ${label} — not starting it)` };
146
+ if (isLaunchdDisabled(disabled.out, label))
145
147
  return { name, state: "disabled", detail: disabledLine(name, label) };
146
148
  onProgress?.(`starting ${name} via launchd…`);
147
149
  const target = `gui/${uid}/${label}`;
@@ -188,90 +190,45 @@ const auroraHealth = (base) => (base ? `${base.replace(/\/$/, "")}/health` : "")
188
190
  function applyDiscovered(cfg, d) {
189
191
  if (!d)
190
192
  return;
191
- cfg.base = d.base.replace(/\/v1\/?$/, "");
193
+ const found = normBase(d.base);
194
+ if (cfg.base && !gatewayBases.has(normBase(cfg.base)) && normBase(cfg.base) !== found)
195
+ return; // an explicit endpoint (the router, a remote) is not the gateway's to overwrite
196
+ gatewayBases.add(found);
197
+ cfg.base = found;
192
198
  if (d.apiKey)
193
199
  cfg.apiKey = d.apiKey;
194
200
  }
195
- /** True iff Aurora is a launchd job on this box (its plist, or a legacy one, is on disk): the only case it loads on
196
- * demand. A remote or tester endpoint has no job here and keeps the old health-gated boot. */
201
+ const normBase = (b) => b.replace(/\/+$/, "").replace(/\/v1$/, "");
202
+ /** Every base this process has resolved from the gateway's server.json: the endpoints that ARE the local gateway. */
203
+ const gatewayBases = new Set();
204
+ /** True iff the endpoint is the local gateway: unset (auto-discover) or a base resolved from its server.json. Any other
205
+ * base (the router's `main`, a remote or tester endpoint) is served by something else, so a miss there is `down`, not
206
+ * `idle`. Call after applyDiscovered. */
207
+ function servedByLocalGateway(base) {
208
+ return !base || gatewayBases.has(normBase(base));
209
+ }
210
+ /** True iff Aurora is a launchd job on this box (its plist, or a legacy one, is on disk). A remote or tester endpoint has
211
+ * no job here and keeps the old health-gated report. */
197
212
  async function localAuroraJob(cfg) {
198
213
  const job = await withLegacyLabel(cfg);
199
214
  return !!job.launchdLabel && !!job.plistPath && (await fileExists(expandHome(job.plistPath)));
200
215
  }
201
216
  /** Boot's view of Aurora: resolve the published endpoint and report, never start the gateway. A local job that is not
202
- * serving is `idle` (the first turn that needs it loads it); with no local job it is `down`, as before. */
217
+ * serving is `idle` (retired: nothing loads it); with no local job it is `down`, as before. */
203
218
  export async function auroraAtBoot(cfg) {
204
219
  applyDiscovered(cfg, await discoverAuroraServer());
205
220
  const state = cfg.base ? await probe(auroraHealth(cfg.base), true) : "refused";
206
221
  if (state === "ready")
207
222
  return { name: "aurora", state: "up" };
208
- if (await localAuroraJob(cfg))
209
- return { name: "aurora", state: "idle", detail: state === "loading" ? "loading" : "loads on first use" };
223
+ if (servedByLocalGateway(cfg.base) && (await localAuroraJob(cfg)))
224
+ return { name: "aurora", state: "idle", detail: state === "loading" ? "loading" : "not serving (retired — Operator does not start it)" };
210
225
  return { name: "aurora", state: "down", detail: cfg.base ? `no response from ${cfg.base}` : "no gateway endpoint published" };
211
226
  }
212
- /** Aurora for a turn that needs it: serving → nothing; loading → wait; else start the launchd job and wait. */
213
- export async function ensureAurora(cfg, onProgress, signal) {
214
- applyDiscovered(cfg, await discoverAuroraServer());
215
- const first = cfg.base ? await probe(auroraHealth(cfg.base), true) : "refused";
216
- if (first === "ready")
217
- return { name: "aurora", state: "up" };
218
- if (first === "loading")
219
- onProgress?.("aurora is loading…");
220
- else {
221
- const refused = await kickLaunchd("aurora", cfg, onProgress);
222
- if (refused)
223
- return refused;
224
- }
225
- const waitSec = cfg.waitSec ?? 90;
226
- return (await waitForAurora(cfg, waitSec, signal))
227
- ? { name: "aurora", state: first === "loading" ? "up" : "started" }
228
- : { name: "aurora", state: "down", detail: `aurora did not report ready within ${waitSec}s` };
229
- }
230
- /** Poll until the published endpoint answers /health, re-reading server.json each time: the gateway publishes its
231
- * base only once llama-server is spawned and deletes server.json when it stops, so a base read before the kick is
232
- * stale or absent. Polling that one is the 11/03 boot that sat 90 s on "starting aurora via launchd…" with Aurora
233
- * ready after 16 s. */
234
- export async function waitForAurora(cfg, waitSec, signal) {
235
- for (let waited = 0;; waited += 2) {
236
- applyDiscovered(cfg, await discoverAuroraServer());
237
- if (cfg.base && (await probe(auroraHealth(cfg.base), true)) === "ready")
238
- return true;
239
- if (waited >= waitSec || signal?.aborted)
240
- return false;
241
- await new Promise((res) => setTimeout(res, 2000));
242
- }
243
- }
244
- /** The Session's onDemand hook for a local Aurora: before a turn on the default model, make sure the gateway is
245
- * serving (start it if not), and when its published base or key changed write them onto `endpoint` and return
246
- * `rebuild()`. Inert where Aurora is not a local launchd job, so a remote endpoint is never probed per turn. */
247
- export function auroraOnDemand(endpoint, svc, rebuild, onProgress, onDisabled) {
248
- let local;
249
- let told = false;
250
- return async (signal) => {
251
- local ??= localAuroraJob(svc ?? {});
252
- if (!(await local))
253
- return null;
254
- const cfg = { ...svc, base: endpoint.base, apiKey: endpoint.apiKey };
255
- const report = await ensureAurora(cfg, onProgress, signal);
256
- if (report.state === "disabled") {
257
- if (!told && report.detail)
258
- onDisabled?.(report.detail); // once per session: the router's next leg answers every turn
259
- told = true;
260
- return null;
261
- }
262
- if (cfg.base === endpoint.base && cfg.apiKey === endpoint.apiKey)
263
- return null;
264
- endpoint.base = cfg.base;
265
- if (cfg.apiKey)
266
- endpoint.apiKey = cfg.apiKey;
267
- return rebuild();
268
- };
269
- }
270
- /** Ensure the services Operator depends on are up. Aurora first (required, health-gated; with auroraOnDemand only
271
- * resolved and reported); autopilot and vision are optional and never block. Returns one report per service for the
272
- * boot UI. Mutates cfg.aurora.base in-place when the dynamic port is discovered from server.json. */
227
+ /** Ensure the services Operator depends on are up. Aurora is only resolved and reported (auroraAtBoot); autopilot and
228
+ * vision are optional and never block. Returns one report per service for the boot UI. Mutates cfg.aurora.base
229
+ * in-place when the dynamic port is discovered from server.json. */
273
230
  export async function ensureServices(cfg) {
274
- const reports = [cfg.auroraOnDemand ? await auroraAtBoot(cfg.aurora) : await ensureAurora(cfg.aurora, cfg.onProgress)];
231
+ const reports = [await auroraAtBoot(cfg.aurora)];
275
232
  if (cfg.autopilot) {
276
233
  reports.push(await ensureOptional("autopilot", cfg.autopilot, cfg.onProgress));
277
234
  }
@@ -303,21 +260,8 @@ async function installCompanion(name) {
303
260
  }
304
261
  catch { /* installer unavailable — the boot already skipped cleanly, nothing else to do */ }
305
262
  }
306
- /** Prime a just-started (cold) Aurora with a 1-token request so the FIRST real turn doesn't pay the
307
- * graph/Metal-shader warmup (the plist runs --no-warmup, so otherwise the owner's first turn eats it).
308
- * Fire-and-forget: never awaited from boot, never throws — a failed warmup just means the old behavior. */
309
- export async function warmAurora(base, model) {
310
- try {
311
- await fetch(`${base.replace(/\/$/, "")}/v1/chat/completions`, {
312
- method: "POST",
313
- headers: { "content-type": "application/json" },
314
- body: JSON.stringify({ model, messages: [{ role: "user", content: "warmup" }], max_tokens: 1, temperature: 0 }),
315
- });
316
- }
317
- catch { /* best-effort — warmup failing just restores the cold-first-turn behavior */ }
318
- }
319
- /** Tear down ONLY the session-scoped services on exit. Aurora and autopilot are shared, always-on, and
320
- * owned by launchd — Operator never stops them (other clients depend on :8097). SearXNG is the one
263
+ /** Tear down ONLY the session-scoped services on exit. Aurora and autopilot are shared and owned by launchd —
264
+ * Operator never stops them. SearXNG is the one
321
265
  * service Operator owns end to end. Best-effort; safe to call more than once. */
322
266
  export async function stopSessionServices(opts) {
323
267
  if (opts?.searxng === false)