@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
@@ -9,7 +9,7 @@ import { buildMemory } from "../memory/providers.js";
9
9
  import { indexSessions, readSession, searchSessions } from "../memory/session-index.js";
10
10
  import { formatHits, indexCatalog, readCatalogSession, searchCatalog, sessionSearchConfig, SESSION_SCOPES } from "../memory/session-catalog.js";
11
11
  import { listLocalSkills, localSkillsDir as profileSkillsDir, resolveSkillFile } from "../config/skills-index.js";
12
- import { operatorPath } from "../config/home.js";
12
+ import { globalMemoriesPath, operatorPath } from "../config/home.js";
13
13
  import { PRODUCT_API_HOST } from "../config/product-hosts.js";
14
14
  import { ownChild } from "../util/owned-children.js";
15
15
  import { BG_MAX_RUNNING, createJob, finishJob, newJobId, pruneShellJobs, runningJobCount, shellJobs, stopShellJob, trackJobOutput } from "./shell-jobs.js";
@@ -17,6 +17,7 @@ import { pexecFile } from "./exec.js";
17
17
  import { AUTO_BACKGROUNDED, MOVED_TO_BACKGROUND, STARTED_BACKGROUND_JOB, jobFinishedLine } from "./background-result.js";
18
18
  import { WAVE_TOOLS } from "./wave-tools.js";
19
19
  import { WAVE2_TOOLS } from "./wave2-tools.js";
20
+ import { BEAM_TOOLS } from "./beam.js";
20
21
  import { GIT_PR_TOOLS } from "./git-pr.js";
21
22
  import { MDOC_TOOLS } from "./mdoc.js";
22
23
  import { INCIDENT_TOOLS } from "./incident-tools.js";
@@ -27,10 +28,12 @@ import { formatGitStatus } from "./git-status.js";
27
28
  import { DOC_TEXT_EXTS, describeDocText, docExt, extractDocText } from "./doc-text.js";
28
29
  import { askVision, visionGateways, VISION_LIMITS } from "./vision-gateway.js";
29
30
  import { DESIGN_PROBE_JS, DESIGN_QUESTION, MEDIA_CAPS, downloadVideoPage, evenTimes, fmtTime, formatDesignRead, grabFrames, isVideoPageUrl, parseTimestamps } from "./vision-media.js";
31
+ import { generate, generationGateways } from "./generation-gateway.js";
30
32
  import { expandPath, assertContentSearchScope, assertShellHomeWideSearch, assertShellBlindDownload } from "./paths.js";
31
33
  import { resolveReadPath } from "./read-path.js";
32
34
  import { recordRead, getRead, forgetReads, seenView } from "./read-ledger.js"; // per-session read-state (pure, node-free — stays out of the neutral graph)
33
35
  import { CRAFT_TOOLS } from "./craft.js";
36
+ import { artifactVisibility } from "../permissions/artifact-visibility.js";
34
37
  import { runMemoryTool } from "./memory.js";
35
38
  import { documentGenerate } from "./document.js";
36
39
  import { runCronTool } from "../autonomy/cron.js";
@@ -687,9 +690,31 @@ async function memorySearch(args) {
687
690
  const query = str(args.query);
688
691
  const limit = Number(args.limit ?? 10);
689
692
  const hits = await (await memory()).recall(query || undefined, limit);
690
- return hits.length
691
- ? hits.map(h => `[${h.id ?? "no-id"}] [${new Date(h.ts).toISOString()}] ${h.text}`).join("\n")
692
- : "(no matches)";
693
+ const lines = hits.map(h => `[${h.id ?? "no-id"}] [${new Date(h.ts).toISOString()}] ${h.text}`);
694
+ const lessons = query ? (await memoryLessons(query)).slice(0, Math.max(1, limit)) : [];
695
+ if (lessons.length)
696
+ lines.push(`lessons (memories.md):\n${lessons.join("\n")}`);
697
+ return lines.length ? lines.join("\n") : "(no matches)";
698
+ }
699
+ // The system prompt loads only the top lessons (settings.memory.promptLessons); the rest are found here. Global
700
+ // memories, then the project's — lazy loads, like settings, so the lessons module stays out of the neutral graph.
701
+ async function memoryLessons(query) {
702
+ try {
703
+ const { readFileSync } = (await nodeImport("node:fs"));
704
+ const { join } = (await nodeImport("node:path"));
705
+ const read = (f) => { try {
706
+ return readFileSync(f, "utf8");
707
+ }
708
+ catch {
709
+ return "";
710
+ } };
711
+ const project = [".operator/memories.md", "memories.md"].map((n) => read(join(process.cwd(), n))).find((t) => t.trim()) ?? "";
712
+ const { matchLessons } = (await nodeImport("../selfimprove/lessons.js"));
713
+ return matchLessons([read(globalMemoriesPath()), project], query);
714
+ }
715
+ catch {
716
+ return [];
717
+ }
693
718
  }
694
719
  // Git run for checkpoints, HARDENED so a checkpoint can never freeze the session (the "checkpoint… spins
695
720
  // forever, esc won't help" hang, 2026-09-28). Every step gets a TIMEOUT + killSignal SIGKILL — a slow or hung
@@ -1530,9 +1555,6 @@ async function taskClear(args) {
1530
1555
  // short-lived process that loads FLUX, renders, and exits (steady-state RAM = 0). This is the ONLY sanctioned
1531
1556
  // way to make images — loading a diffusion model inline in a turn pins GBs on the serving box, swaps, and
1532
1557
  // crawls decode to ~1 tok/s. Returns the saved PNG path(s), never the base64 (that would flood the transcript).
1533
- /** Candidate image-service endpoints in priority order: explicit env first, then the shared fleet service
1534
- * (Cloudflare-tunneled — reachable from anywhere), then a local broker as a last resort. De-duped, trailing
1535
- * slash trimmed. KODE_IMAGE_URL / AXE_IMAGE_URL override. */
1536
1558
  /** ONE-API gateway: when KODE_GATEWAY_URL is set, prefer the unified route `api.axe.onl/<service>/…`, which
1537
1559
  * fans out to the broker server-side (one door, one token). Empty when unset → per-broker URLs are used. The
1538
1560
  * gateway strips the `/<service>/` prefix, so the broker still sees its native OpenAI path. See
@@ -1541,11 +1563,6 @@ function gatewayEndpoints(service) {
1541
1563
  const g = process.env.KODE_GATEWAY_URL;
1542
1564
  return g ? [`${g.replace(/\/$/, "")}/${service}`] : [];
1543
1565
  }
1544
- function imageEndpoints() {
1545
- const envs = [process.env.KODE_IMAGE_URL, process.env.AXE_IMAGE_URL].filter(Boolean);
1546
- const defaults = ["https://image.axe.onl", "http://127.0.0.1:8791"];
1547
- return [...new Set([...gatewayEndpoints("images"), ...envs, ...defaults])].map((u) => u.replace(/\/$/, ""));
1548
- }
1549
1566
  /** Candidate IDENTITY-broker endpoints (reference-likeness: SDXL RealVisXL + IP-Adapter-FaceID). Used when
1550
1567
  * image_generate carries a `reference` (preserve a SPECIFIC face). KODE_IDENTITY_URL is tried FIRST: point it at
1551
1568
  * a worker on your own network so a cold render (~80-90s to load the 9.4GB pipeline) never hits the public host's
@@ -1610,8 +1627,7 @@ async function recordMediaGen(rec) {
1610
1627
  * broker). Shared by image_generate + video_generate so the URL-first contract is identical for both. */
1611
1628
  async function saveGeneratedMedia(items, outArg, ext) {
1612
1629
  const { writeFile, mkdir } = await nodeImport("node:fs/promises");
1613
- const { tmpdir } = await nodeImport("node:os");
1614
- const { join, dirname } = await nodeImport("node:path");
1630
+ const { dirname } = await nodeImport("node:path");
1615
1631
  const kind = ext === "png" ? "image" : "video";
1616
1632
  const dotExt = new RegExp(`(\\.${ext})?$`, "i");
1617
1633
  const refs = []; // renderable reference per item — public URL when present, else a local path
@@ -1622,7 +1638,7 @@ async function saveGeneratedMedia(items, outArg, ext) {
1622
1638
  if (b64 && (outArg || !url)) {
1623
1639
  const p = outArg
1624
1640
  ? (items.length > 1 ? outArg.replace(dotExt, `-${i + 1}.${ext}`) : (outArg.toLowerCase().endsWith(`.${ext}`) ? outArg : `${outArg}.${ext}`))
1625
- : join(tmpdir(), `axe-${kind}-${Date.now().toString(36)}-${i + 1}.${ext}`);
1641
+ : operatorPath("artifacts", `axe-${kind}-${Date.now().toString(36)}-${i + 1}.${ext}`);
1626
1642
  await mkdir(dirname(p), { recursive: true }).catch(() => { });
1627
1643
  await writeFile(p, Buffer.from(b64, "base64"));
1628
1644
  saved.push(p);
@@ -1634,6 +1650,8 @@ async function saveGeneratedMedia(items, outArg, ext) {
1634
1650
  }
1635
1651
  return { refs, saved };
1636
1652
  }
1653
+ /** A render takes 160–214 s on today's worker, plus up to 300 s in the route's queue; the router job holds it past the edge's cap. */
1654
+ const IMAGE_TIMEOUT_MS = 600_000;
1637
1655
  async function imageGenerate(args) {
1638
1656
  const prompt = str(args.prompt);
1639
1657
  if (!prompt)
@@ -1641,147 +1659,77 @@ async function imageGenerate(args) {
1641
1659
  const size = /^\d+x\d+$/.test(str(args.size)) ? str(args.size) : "512x512";
1642
1660
  const n = Math.max(1, Math.min(Number(args.n) || 1, 4));
1643
1661
  const wantExpand = args.expand === true || str(args.expand) === "true"; // ask the broker to rewrite the prompt via Aurora (never blocks; used:false = ran on the original)
1644
- // Route reference-bearing requests to the IDENTITY broker (preserve a SPECIFIC face via IP-Adapter-FaceID);
1645
- // plain text-to-image stays on flux. Try identity first when a reference is given, fall back to flux if the
1646
- // identity node is asleep — a request never hard-fails just because one broker is down.
1647
- const wantIdentity = !!str(args.reference);
1648
- let base;
1649
- let identity = false;
1650
- if (wantIdentity)
1662
+ const timeoutMs = Number(args.timeout_ms ?? IMAGE_TIMEOUT_MS);
1663
+ const genBody = { prompt, n, size, ...(wantExpand ? { expand: true } : {}), ...(Number(args.steps) > 0 ? { steps: Number(args.steps) } : {}) };
1664
+ // A reference-bearing request tries the IDENTITY broker first (preserve a SPECIFIC face via IP-Adapter-FaceID). It
1665
+ // has no route yet, so it keeps its direct endpoints; asleep, the image-gen route restyles from the reference instead.
1666
+ let identityBase;
1667
+ if (str(args.reference))
1651
1668
  for (const e of identityEndpoints()) {
1652
1669
  if (await imageHealthy(e)) {
1653
- base = e;
1654
- identity = true;
1670
+ identityBase = e;
1655
1671
  break;
1656
1672
  }
1657
1673
  }
1658
- if (!base)
1659
- for (const e of imageEndpoints()) {
1660
- if (await imageHealthy(e)) {
1661
- base = e;
1662
- break;
1663
- }
1674
+ let answer;
1675
+ if (identityBase) {
1676
+ const ctrl = new AbortController();
1677
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
1678
+ try {
1679
+ const res = await fetch(`${identityBase}/v1/images/generations`, {
1680
+ method: "POST", signal: ctrl.signal,
1681
+ headers: { "Content-Type": "application/json", "User-Agent": "operator/kode-tsi", ...mediaAuth() },
1682
+ body: JSON.stringify({ ...genBody, reference: str(args.reference), strength: Number(args.strength ?? 0.65), ip_adapter_scale: Number(args.ip_adapter_scale ?? 0.8) }),
1683
+ });
1684
+ if (!res.ok)
1685
+ return `error: identity worker returned ${res.status}`;
1686
+ answer = { json: (await res.json().catch(() => ({}))) };
1687
+ }
1688
+ catch (e) {
1689
+ const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
1690
+ return `error: identity worker unreachable at ${identityBase} (${msg})`;
1691
+ }
1692
+ finally {
1693
+ clearTimeout(timer);
1664
1694
  }
1665
- if (!base)
1666
- return `error: no image service reachable. Bring up the flux-worker (image.axe.onl / :8791)${wantIdentity ? " or the identity-worker (identity.axe.onl / :8793)" : ""}. Do NOT load a diffusion model inline — that starves the serving model.`;
1667
- const ctrl = new AbortController();
1668
- const timer = setTimeout(() => ctrl.abort(), Number(args.timeout_ms ?? 180_000)); // a cold FLUX load + denoise is ~tens of seconds
1669
- try {
1670
- const genBody = { prompt, n, size, ...(wantExpand ? { expand: true } : {}), ...(Number(args.steps) > 0 ? { steps: Number(args.steps) } : {}) };
1671
- if (!identity)
1672
- genBody.model = "flux-schnell"; // the identity broker runs RealVisXL and picks its own base
1673
- if (str(args.reference)) {
1674
- genBody.reference = str(args.reference); // the FACE (identity) — or the init (flux)
1675
- genBody.strength = Number(args.strength ?? 0.65);
1676
- if (identity)
1677
- genBody.ip_adapter_scale = Number(args.ip_adapter_scale ?? 0.8); // IP-Adapter-FaceID strength
1678
- else
1679
- genBody.image = str(args.reference); // flux img2img: the reference doubles as init
1680
- }
1681
- const res = await fetch(`${base}/v1/images/generations`, {
1682
- method: "POST", signal: ctrl.signal,
1683
- headers: { "Content-Type": "application/json", "User-Agent": "operator/kode-tsi", ...mediaAuth() },
1684
- body: JSON.stringify(genBody),
1685
- });
1686
- if (!res.ok)
1687
- return `error: image worker returned ${res.status} — ensure the flux-worker broker (com.axe.flux-worker) is up`;
1688
- const j = (await res.json().catch(() => ({})));
1689
- const imgs = j.data ?? [];
1690
- if (!imgs.length)
1691
- return "error: image worker returned no image data";
1692
- const { refs, saved } = await saveGeneratedMedia(imgs, str(args.out), "png");
1693
- if (!refs.length)
1694
- return "error: image worker returned no url and no decodable PNG";
1695
- const exp = j.axe_prompt_expansion?.used ? j.axe_prompt_expansion.expanded : undefined; // the broker-rewritten prompt that was actually rendered
1696
- const id = j.axe_identity?.identity_applied ? j.axe_identity : undefined; // the identity broker injected a real face (honest method/fidelity)
1697
- const i2i = !id && j.axe_img2img?.used ? j.axe_img2img : undefined; // pose/style restyle from a reference — NOT the exact face
1698
- await recordMediaGen({ tool: "image_generate", prompt, model: id?.base_model || "flux-schnell", params: { size, n }, refs, ok: true, ...(exp ? { expanded: exp } : {}), ...(id ? { identity: id } : {}), ...(i2i ? { img2img: i2i } : {}) });
1699
- const extra = saved.length && refs.some((r) => /^https?:\/\//.test(r)) ? ` (also saved: ${saved.join(", ")})` : "";
1700
- const expNote = exp ? ` (expanded → "${exp.length > 160 ? exp.slice(0, 160) + "…" : exp}")` : "";
1701
- // Honest provenance in the result: name WHICH reference mechanism actually ran, so likeness is never overclaimed.
1702
- const refNote = id
1703
- ? ` (identity: ${id.method ?? "reference"}${id.base_model ? ` on ${id.base_model}` : ""}${id.fidelity_note ? ` — ${id.fidelity_note}` : ""})`
1704
- : i2i
1705
- ? ` (img2img restyle @ strength ${i2i.strength ?? "?"} — matches pose/composition/style, NOT the exact face)`
1706
- : "";
1707
- return `generated ${refs.length} image${refs.length > 1 ? "s" : ""} (${size}) → ${refs.join(", ")}${extra}${expNote}${refNote}`;
1708
- }
1709
- catch (e) {
1710
- const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
1711
- return `error: image worker unreachable at ${base} (${msg}) — start the flux-worker broker (com.axe.flux-worker on the image node). Do NOT load a diffusion model inline; that starves the serving model.`;
1712
- }
1713
- finally {
1714
- clearTimeout(timer);
1715
1695
  }
1716
- }
1717
- // video_generate — same scale-to-zero broker as image_generate (the flux-worker node also serves /v1/video),
1718
- // so generation NEVER runs on the LLM-serving box. Mirrors image_generate's URL-first contract (prefer the
1719
- // broker's public url, fall back to a saved local file) via saveGeneratedMedia. KODE_VIDEO_URL overrides,
1720
- // else it reuses the image endpoints (same broker host).
1721
- /** Candidate video-service endpoints in priority order: KODE_VIDEO_URL first, then the shared image
1722
- * endpoints (the flux-worker broker serves /v1/video alongside /v1/images). De-duped, trailing slash trimmed. */
1723
- function videoEndpoints() {
1724
- const envs = [process.env.KODE_VIDEO_URL].filter(Boolean);
1725
- // The LTX video broker lives at its OWN host (video.axe.onl), not the image host — do NOT fall back to the
1726
- // image endpoints, whose /health is 200 but which 404 on /v1/video (we'd pick a healthy-but-wrong broker).
1727
- // An LTX render takes >100s, which trips the public host's ~100s edge timeout (524): point KODE_VIDEO_URL at a
1728
- // worker on your own network (tried first, no such cap). The public host is the fallback.
1729
- const defaults = ["https://video.axe.onl"];
1730
- return [...new Set([...envs, ...defaults])].map((u) => u.replace(/\/$/, ""));
1731
- }
1696
+ else {
1697
+ if (str(args.reference))
1698
+ Object.assign(genBody, { image: str(args.reference), strength: Number(args.strength ?? 0.65) }); // flux img2img: the reference is the init
1699
+ try {
1700
+ answer = await generate(generationGateways(), "image", genBody, timeoutMs);
1701
+ }
1702
+ catch (e) {
1703
+ return `error: ${e.message}`;
1704
+ }
1705
+ }
1706
+ const j = answer.json;
1707
+ const imgs = j.data ?? [];
1708
+ if (!imgs.length)
1709
+ return "error: image worker returned no image data";
1710
+ const { refs, saved } = await saveGeneratedMedia(imgs, str(args.out), "png");
1711
+ if (!refs.length)
1712
+ return "error: image worker returned no url and no decodable PNG";
1713
+ const exp = j.axe_prompt_expansion?.used ? j.axe_prompt_expansion.expanded : undefined; // the broker-rewritten prompt that was actually rendered
1714
+ const id = j.axe_identity?.identity_applied ? j.axe_identity : undefined; // the identity broker injected a real face (honest method/fidelity)
1715
+ const i2i = !id && j.axe_img2img?.used ? j.axe_img2img : undefined; // pose/style restyle from a reference — NOT the exact face
1716
+ await recordMediaGen({ tool: "image_generate", prompt, model: id?.base_model || answer.backend || "image", params: { size, n }, refs, ok: true, ...(exp ? { expanded: exp } : {}), ...(id ? { identity: id } : {}), ...(i2i ? { img2img: i2i } : {}) });
1717
+ const extra = saved.length && refs.some((r) => /^https?:\/\//.test(r)) ? ` (also saved: ${saved.join(", ")})` : "";
1718
+ const expNote = exp ? ` (expanded → "${exp.length > 160 ? exp.slice(0, 160) + "…" : exp}")` : "";
1719
+ // Honest provenance in the result: name WHICH reference mechanism actually ran, so likeness is never overclaimed.
1720
+ const refNote = id
1721
+ ? ` (identity: ${id.method ?? "reference"}${id.base_model ? ` on ${id.base_model}` : ""}${id.fidelity_note ? ` — ${id.fidelity_note}` : ""})`
1722
+ : i2i
1723
+ ? ` (img2img restyle @ strength ${i2i.strength ?? "?"} — matches pose/composition/style, NOT the exact face)`
1724
+ : "";
1725
+ const via = answer.backend ? ` (via ${answer.backend})` : ""; // which leg rendered it: a fallback leg is a different model
1726
+ return `generated ${refs.length} image${refs.length > 1 ? "s" : ""} (${size}) → ${refs.join(", ")}${extra}${expNote}${refNote}${via}`;
1727
+ }
1728
+ // video_generate — no video leg serves yet, so there is no route behind it: one plain answer instead of a host probe.
1732
1729
  async function videoGenerate(args) {
1733
- const prompt = str(args.prompt);
1734
- if (!prompt)
1730
+ if (!str(args.prompt))
1735
1731
  return "error: video_generate needs a prompt";
1736
- const size = /^\d+x\d+$/.test(str(args.size)) ? str(args.size) : "704x480"; // LTX natural default; the broker rounds w/h to ×32
1737
- const numFrames = Math.max(1, Math.min(Number(args.num_frames) || 97, 257)); // LTX default ≈97 (~4s @ 24fps); broker rounds to 8n+1
1738
- const fps = Math.max(1, Math.min(Number(args.fps) || 24, 60));
1739
- const seed = Number.isFinite(Number(args.seed)) ? Number(args.seed) : undefined;
1740
- const model = str(args.model);
1741
- const refImage = str(args.reference_image); // image-to-video: the broker uses this as LTX first-frame conditioning (path/url or b64)
1742
- const wantExpand = args.expand === true || str(args.expand) === "true";
1743
- // Pick the first reachable endpoint (shared fleet service preferred), failing fast over dead ones.
1744
- const candidates = videoEndpoints();
1745
- let base;
1746
- for (const e of candidates) {
1747
- if (await imageHealthy(e)) {
1748
- base = e;
1749
- break;
1750
- }
1751
- }
1752
- if (!base)
1753
- return `error: no video service reachable (tried ${candidates.join(", ")}). Bring up the flux-worker broker on the image node (it serves /v1/video). Do NOT load a video model inline — that starves the serving model.`;
1754
- const ctrl = new AbortController();
1755
- const timer = setTimeout(() => ctrl.abort(), Number(args.timeout_ms ?? 600_000)); // a cold video model load + sampling runs minutes, not seconds
1756
- try {
1757
- const res = await fetch(`${base}/v1/video/generations`, {
1758
- method: "POST", signal: ctrl.signal,
1759
- headers: { "Content-Type": "application/json", "User-Agent": "operator/kode-tsi", ...mediaAuth() },
1760
- body: JSON.stringify({ prompt, size, num_frames: numFrames, fps, ...(seed != null ? { seed } : {}), ...(model ? { model } : {}), ...(refImage ? { image: refImage } : {}), ...(wantExpand ? { expand: true } : {}) }),
1761
- });
1762
- if (!res.ok)
1763
- return `error: video worker returned ${res.status} — ensure the flux-worker broker serves /v1/video (video_gen.py)`;
1764
- const j = (await res.json().catch(() => ({})));
1765
- const vids = j.data ?? [];
1766
- if (!vids.length)
1767
- return "error: video worker returned no video data";
1768
- const { refs, saved } = await saveGeneratedMedia(vids, str(args.out), "mp4");
1769
- if (!refs.length)
1770
- return "error: video worker returned no url and no decodable video";
1771
- const exp = j.axe_prompt_expansion?.used ? j.axe_prompt_expansion.expanded : undefined;
1772
- await recordMediaGen({ tool: "video_generate", prompt, model: model || "ltx-video", params: { size, num_frames: numFrames, fps, ...(seed != null ? { seed } : {}) }, refs, ok: true, ...(refImage ? { conditioned: j.conditioned !== false } : {}), ...(exp ? { expanded: exp } : {}) });
1773
- const extra = saved.length && refs.some((r) => /^https?:\/\//.test(r)) ? ` (also saved: ${saved.join(", ")})` : "";
1774
- const condNote = refImage ? (j.conditioned !== false ? " (image-conditioned)" : " (reference ignored — broker not image-conditioned yet)") : "";
1775
- const expNote = exp ? ` (expanded → "${exp.length > 160 ? exp.slice(0, 160) + "…" : exp}")` : "";
1776
- return `generated ${refs.length} video${refs.length > 1 ? "s" : ""} (${size}, ${numFrames}f @ ${fps}fps) → ${refs.join(", ")}${extra}${condNote}${expNote}`;
1777
- }
1778
- catch (e) {
1779
- const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
1780
- return `error: video worker unreachable at ${base} (${msg}) — start the flux-worker broker (it serves /v1/video on the image node). Do NOT load a video model inline; that starves the serving model.`;
1781
- }
1782
- finally {
1783
- clearTimeout(timer);
1784
- }
1732
+ return "error: video generation isn't available yet";
1785
1733
  }
1786
1734
  async function visionSettings() {
1787
1735
  const { loadSettings } = await nodeImport("../config/settings.js"); // variable-specifier load keeps settings out of the browser graph
@@ -1901,7 +1849,7 @@ async function flattenAlpha(image) {
1901
1849
  return image;
1902
1850
  }
1903
1851
  }
1904
- async function visionImageDataUrl(image, lim) {
1852
+ export async function visionImageDataUrl(image, lim) {
1905
1853
  image = await absMediaPath(image);
1906
1854
  if (/^https?:\/\//.test(image))
1907
1855
  image = await fetchImageToTemp(image);
@@ -1929,7 +1877,7 @@ async function visionImageDataUrl(image, lim) {
1929
1877
  const { stdout } = await pexec("sips", ["-g", "pixelWidth", "-g", "pixelHeight", image]);
1930
1878
  const w = Number((/pixelWidth:\s*(\d+)/.exec(stdout) || [])[1] || 0);
1931
1879
  const h = Number((/pixelHeight:\s*(\d+)/.exec(stdout) || [])[1] || 0);
1932
- if (w && h && buf.length < w * h * BLANK_BYTES_PER_PX) {
1880
+ if (!lim.keepBlank && w && h && buf.length < w * h * BLANK_BYTES_PER_PX) {
1933
1881
  const flat = await flatColour(pexec, image, join(dir, "t.bmp"));
1934
1882
  if (flat)
1935
1883
  return { blank: `${w}×${h}, one flat colour ${flat}, ${Math.max(1, Math.round(buf.length / 1024))} KB` };
@@ -2317,7 +2265,11 @@ async function imageRecreate(args) {
2317
2265
  async function artifactCreate(args) {
2318
2266
  const temple = (await nodeImport("../products/temple.js"));
2319
2267
  const paths = Array.isArray(args.paths) ? args.paths.map(String).filter(Boolean) : [];
2320
- const visibility = /^(private|link|public)$/.test(str(args.visibility)) ? str(args.visibility) : "link";
2268
+ const { loadSettings } = await nodeImport("../config/settings.js");
2269
+ const vis = artifactVisibility(loadSettings().permissions?.tier, args.visibility, true);
2270
+ if ("error" in vis)
2271
+ return `error: ${vis.error}`;
2272
+ const visibility = vis.visibility;
2321
2273
  const r = await temple.publish({ title: str(args.title) || "Operator artifact", content: str(args.content) || undefined, content_type: str(args.content_type) || undefined, kind: str(args.kind) || undefined, paths, visibility });
2322
2274
  if (!r.ok)
2323
2275
  return `error: ${r.error}${/reach|timed out/.test(r.error) ? " — if this persists, write a local file with file_create instead" : ""}`;
@@ -2797,13 +2749,13 @@ const TOOLS = [
2797
2749
  expand: { type: "boolean", description: "rewrite the prompt richer first (the quality lever)" },
2798
2750
  steps: { type: "number", description: "default 4; ~8 for finer img2img" },
2799
2751
  out: { type: "string", description: ".png path (default temp)" },
2800
- timeout_ms: { type: "number", description: "default 180000" },
2752
+ timeout_ms: { type: "number", description: "default 600000" },
2801
2753
  }, required: ["prompt"] },
2802
2754
  run: imageGenerate,
2803
2755
  },
2804
2756
  {
2805
2757
  name: "video_generate",
2806
- description: "Generate a short video (AXE video worker, LTX-Video, scale-to-zero) → a renderable URL or .mp4 path. Never load a video model inline — that pins GBs on the serving box and crawls your decode.",
2758
+ description: "Not available yet: no video service is connected, so this returns that answer. Use image_generate for stills. Never load a video model inline — that pins GBs on the serving box and crawls your decode.",
2807
2759
  parameters: { type: "object", properties: {
2808
2760
  prompt: { type: "string", description: "what to generate" },
2809
2761
  size: { type: "string", description: "WxH (default \"704x480\")" },
@@ -2813,7 +2765,7 @@ const TOOLS = [
2813
2765
  reference_image: { type: "string", description: "first-frame image path/url (image-to-video)" },
2814
2766
  expand: { type: "boolean", description: "rewrite the prompt richer first" },
2815
2767
  out: { type: "string", description: ".mp4 path (default temp)" },
2816
- timeout_ms: { type: "number", description: "default 600000" },
2768
+ timeout_ms: { type: "number", description: "default 900000" },
2817
2769
  }, required: ["prompt"] },
2818
2770
  run: videoGenerate,
2819
2771
  },
@@ -3064,6 +3016,28 @@ const TOOLS = [
3064
3016
  }, required: ["action"] },
3065
3017
  run: runBrowserRead,
3066
3018
  },
3019
+ {
3020
+ name: "page_capture", safe: false,
3021
+ contract: { v: 1, effects: ["fetch", "read", "state"], bins: ["chrome"], paths: { read: ["url"] } },
3022
+ description: "Page screenshot + design tokens, to replicate or match a website's design: full-page screenshot tiles per viewport, tokens from computed styles (palette, fonts, type scale, spacing, radii, shadows, breakpoints, motion) and a section outline; full JSON on disk.",
3023
+ parameters: { type: "object", properties: {
3024
+ url: { type: "string", description: "http(s) URL, local .html path or raw HTML" },
3025
+ viewports: { type: "array", items: { type: "string" }, description: "default desktop 1440 + phone 390; also tablet, a width or WxH" },
3026
+ }, required: ["url"] },
3027
+ run: async (args) => (await nodeImport("../browser/page-capture.js")).runPageCapture(args),
3028
+ },
3029
+ {
3030
+ name: "visual_compare", safe: false,
3031
+ contract: { v: 1, effects: ["fetch", "read", "state"], bins: ["chrome"], paths: { read: ["reference", "candidate"] } },
3032
+ description: "Visual diff / regression check: compare a page you built with the reference design it should match, at one viewport. Pixel mismatch per screenshot tile with diff PNGs, and token/section differences ranked.",
3033
+ parameters: { type: "object", properties: {
3034
+ reference: { type: "string", description: "URL, .html path or raw HTML" },
3035
+ candidate: { type: "string", description: "your version, same forms" },
3036
+ viewport: { type: "string", description: "desktop (default), tablet, phone, width or WxH" },
3037
+ describe: { type: "boolean", description: "vision note on the worst tile" },
3038
+ }, required: ["reference", "candidate"] },
3039
+ run: async (args) => (await nodeImport("../browser/visual-compare.js")).runVisualCompare(args),
3040
+ },
3067
3041
  {
3068
3042
  name: "browser_vault", safe: false,
3069
3043
  description: "Origin-bound website credentials from the owner's vault. THE RULE: never type a password yourself, never ask for one in chat, never repeat one — results withhold values. list: handles, users, bound origins (no secrets). fill(handle, user_selector, password_selector): fills the ACTIVE browser page after an exact origin match (open the login page with browser first). No item for an origin → tell the owner to add one in their terminal; never guess.",
@@ -3085,7 +3059,7 @@ const TOOLS = [
3085
3059
  description: "The OFFICIAL optional-skills catalogue shipped with Operator; nothing in it is active until installed. browse(query?) lists entries; install(name) copies a skill into the operator home's skills/ (live next session); remove(name) deletes an installed copy (hand-written skills are never touched).",
3086
3060
  parameters: { type: "object", properties: {
3087
3061
  action: { type: "string", enum: ["browse", "install", "remove"], description: "what to do" },
3088
- query: { type: "string", description: "browse: name/category/description filter" },
3062
+ query: { type: "string", description: "browse: name/category/description/tag filter" },
3089
3063
  name: { type: "string", description: "install/remove: exact name from browse" },
3090
3064
  }, required: ["action"] },
3091
3065
  run: runSkillCatalog,
@@ -3388,7 +3362,7 @@ async function skillPublish(name, version) {
3388
3362
  export async function localSkills() {
3389
3363
  return listLocalSkills();
3390
3364
  }
3391
- export const registry = new Map([...TOOLS, ...WAVE_TOOLS, ...WAVE2_TOOLS, ...INCIDENT_TOOLS, ...MONITORING_TOOLS, ...GIT_PR_TOOLS].map(t => [t.name, t]));
3365
+ export const registry = new Map([...TOOLS, ...WAVE_TOOLS, ...WAVE2_TOOLS, ...INCIDENT_TOOLS, ...MONITORING_TOOLS, ...GIT_PR_TOOLS, ...BEAM_TOOLS].map(t => [t.name, t]));
3392
3366
  // ── Cloud agents (feature-gated — NOT in the base registry) ───────────────────────
3393
3367
  // Sovereign "cloud/background agents": spawn an autonomous agent in an ISOLATED DOCKER CONTAINER on a configured
3394
3368
  // fleet host (autonomy/cloud-agent.ts). These are kept OUT of the static `registry`/`TOOLS` so they are absent by
@@ -3447,10 +3421,13 @@ export function cloudAgentToolsFor(settings) {
3447
3421
  export function mdocToolsFor(settings) {
3448
3422
  return isFeatureEnabled("mdoc", settings ?? undefined) ? MDOC_TOOLS : [];
3449
3423
  }
3450
- // Flag-gated craft product tools (config/features.ts `craft`): absent from the base registry so the stock prompt
3451
- // prefix is unchanged; the session adds them only when the `craft` feature is on, exactly like mdoc + cloud-agent.
3424
+ // The artifact library (craft_list/get/update/delete) is on for every seat (2026-11-29): artifact_create makes an
3425
+ // artifact, these find and change it, so nobody has to add an MCP server to manage their own work. With deferred
3426
+ // tools (default on) they cost nothing in the cached prefix. craft_create and craft_room stay behind the `craft`
3427
+ // flag: craft_create duplicates artifact_create, the one way to make an artifact, and rooms are opt-in collaboration.
3428
+ const CRAFT_FLAGGED = new Set(["craft_create", "craft_room"]);
3452
3429
  export function craftToolsFor(settings) {
3453
- return isFeatureEnabled("craft", settings ?? undefined) ? CRAFT_TOOLS : [];
3430
+ return isFeatureEnabled("craft", settings ?? undefined) ? CRAFT_TOOLS : CRAFT_TOOLS.filter(t => !CRAFT_FLAGGED.has(t.name));
3454
3431
  }
3455
3432
  export function toSchemas(reg = registry) {
3456
3433
  return [...reg.values()].map(t => ({
@@ -224,7 +224,7 @@ export async function deniedReadAsync(path) {
224
224
  }
225
225
  return null;
226
226
  }
227
- export function seatbeltProfile(mode) {
227
+ export function seatbeltProfile(mode, scope = {}) {
228
228
  const q = (s) => s.replace(/"/g, '\\"');
229
229
  // Read-containment: block reads of credential paths in BOTH modes so a shell command can't read+exfil
230
230
  // secrets. Scoped to real secrets so /usr,/etc,/bin stay readable and normal commands still run.
@@ -235,10 +235,10 @@ export function seatbeltProfile(mode) {
235
235
  // writes, re-allow the roots, then re-deny the credential/system/op-policy paths on top (SBPL is
236
236
  // last-match-wins) so a write can't land there even when an allow-root contains it (e.g. cwd == $HOME).
237
237
  // The two modes differ only in the network: workspace leaves it open, strict cuts it.
238
- const allow = allowedWriteRoots().concat("/dev").map((r) => `(subpath "${q(r)}")`).join(" ");
238
+ const allow = (scope.writeRoots?.map(resolve) ?? allowedWriteRoots()).concat("/dev").map((r) => `(subpath "${q(r)}")`).join(" ");
239
239
  const denySub = denyWriteSubpaths().map((d) => `(subpath "${q(d)}")`).join(" ");
240
240
  const denyFiles = denyWriteFiles().map((f) => `(literal "${q(f)}")`).join(" ");
241
- const net = mode === "strict" ? "(deny network*)" : "";
241
+ const net = (scope.network ?? mode !== "strict") ? "" : "(deny network*)";
242
242
  return `(version 1)(allow default)(deny file-write*)(allow file-write* ${allow})(deny file-write* ${denySub} ${denyFiles})${denyRead}${net}`;
243
243
  }
244
244
  /** Bubblewrap (bwrap) argv enforcing the SAME intent as seatbeltProfile(), for the Linux fleet where
@@ -249,7 +249,7 @@ export function seatbeltProfile(mode) {
249
249
  * (empty tmpfs / /dev/null so reads can't exfil), and strict makes the whole FS read-only except the
250
250
  * allow-roots and cuts the network. Returns the args BEFORE the `/bin/bash …` argv. Exported for unit
251
251
  * tests. NOTE: kernel enforcement must be validated on a real Linux node — untestable on macOS/JL1. */
252
- export function bwrapArgs(mode) {
252
+ export function bwrapArgs(mode, scope = {}) {
253
253
  const a = [];
254
254
  // BOTH modes confine writes: the whole FS is read-only except the allow-roots (cwd + operator home + tmp),
255
255
  // with the credential/system/op-policy paths re-bound read-only on top so a write can't land there even
@@ -257,13 +257,13 @@ export function bwrapArgs(mode) {
257
257
  // workspace leaves it connected.
258
258
  a.push("--ro-bind", "/", "/"); // whole FS read-only …
259
259
  a.push("--proc", "/proc", "--dev", "/dev");
260
- for (const root of allowedWriteRoots())
260
+ for (const root of scope.writeRoots?.map(resolve) ?? allowedWriteRoots())
261
261
  a.push("--bind-try", root, root); // … except the allow-roots
262
262
  for (const d of denyWriteSubpaths())
263
263
  a.push("--ro-bind-try", resolve(d), resolve(d)); // protected dirs stay read-only (incl. operator policy/audit dirs)
264
264
  for (const f of denyWriteFiles())
265
265
  a.push("--ro-bind-try", resolve(f), resolve(f)); // protected files stay read-only (incl. operator policy files)
266
- if (mode === "strict")
266
+ if (!(scope.network ?? mode !== "strict"))
267
267
  a.push("--unshare-net"); // strict: no network
268
268
  // Read-containment (BOTH modes): mask secret dirs with an empty tmpfs, secret files with /dev/null,
269
269
  // so a shell command can't read + exfil credentials. Placed last so it wins over the read-only binds.
package/dist/ui/App.js CHANGED
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
4
4
  // src/engine, src/tools, or src/router.
5
5
  import React, { useEffect, useRef, useState } from "react";
6
6
  import { Box, Text, measureElement, useInput } from "ink";
7
- import { useTerminalSize, termCols } from "./term.js";
7
+ import { useTerminalSize, termCols, termRows } from "./term.js";
8
8
  import { caps } from "./capabilities.js";
9
9
  import { MouseProvider, useOnWheel, useMouse } from "./MouseProvider.js";
10
10
  import { StatusRule } from "./StatusRule.js";
@@ -36,7 +36,7 @@ import { nextStepLine } from "./nextStep.js";
36
36
  import { centreLayout, switcherLine } from "./conversations.js";
37
37
  import { cellWidth } from "./StatusRule.js";
38
38
  import { ACT_NOW_NARROW, actNowLine } from "./actNow.js";
39
- import { fitSegments } from "./fit.js";
39
+ import { fitSegments, seg } from "./fit.js";
40
40
  // The footer's mode badge. Gated is outside the shift+tab cycle (permissions/modes.ts); shift+tab leaves it.
41
41
  const MODE_BADGE = { auto: "⎈ Autonomous", manual: "⊙ Manual", plan: "◑ Plan", gated: "⊘ Gated" };
42
42
  // Cap on live rows shown at once for a parallel tool batch — keeps the dynamic (non-Static) frame
@@ -91,8 +91,19 @@ function ExpandKey({ onExpand, active }) {
91
91
  return null;
92
92
  }
93
93
  export function App(props) {
94
- const { messages, live = null, status, thinkingVerb, verbs, stepLabel, phase = null, fold = null, delegate = null, liveTools = [], route, ctxPct, ctxWindow, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], mainLane = null, mainServing, maxRunning, onBackground, tasks = [], planNow, onSubmit, onQueue, onSteer, pending = [], onEditQueued, onDropQueued, nextSteps, onPickNext, onDismissNext, agents = [], onAgentMessage, conversations = [], switcher, onSwitcher, onFocusSwitcher, conversationPane = null, onSendTo, actOffer = null, onActNow, finder = null, onOpenFinder, onInterrupt, onExpand, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null, update = null } = props;
94
+ const { messages, live = null, status, thinkingVerb, verbs, stepLabel, phase = null, fold = null, delegate = null, liveTools = [], route, ctxPct, ctxWindow, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], mainLane = null, mainServing, maxRunning, lanePool, laneWarnings, onBackground, tasks = [], planNow, onSubmit, onQueue, onSteer, pending = [], onEditQueued, onDropQueued, nextSteps, onPickNext, onDismissNext, agents = [], onAgentMessage, conversations = [], switcher, onSwitcher, onFocusSwitcher, conversationPane = null, onSendTo, actOffer = null, onActNow, finder = null, onOpenFinder, onInterrupt, onExpand, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, voice = null, onVoiceKey, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null, update = null } = props;
95
95
  const cols = useTerminalSize().cols; // subscribe so the inline pinned UI (status rule, composer, footer) reflows the instant the terminal resizes
96
+ // Inline: the height of everything under the live entry (spinner, plan, lanes, prompts, composer), measured after
97
+ // each layout. The live entry gets only the rows left over, so the dynamic frame never reaches the terminal height.
98
+ const chromeRef = useRef(null);
99
+ const [chromeRows, setChromeRows] = useState(undefined);
100
+ useEffect(() => {
101
+ if (fullscreen || !chromeRef.current)
102
+ return;
103
+ const { height } = measureElement(chromeRef.current);
104
+ if (height !== chromeRows)
105
+ setChromeRows(height);
106
+ });
96
107
  const thinking = status === "thinking" || status === "streaming";
97
108
  // Tool rows exist before their calls run (TUI plan #8): from the first streamed argument (drafting) through waiting
98
109
  // its turn to running and settled — one row per call, a lone call included, instead of the bare "⠋ name…".
@@ -102,7 +113,7 @@ export function App(props) {
102
113
  const activity = (_jsxs(_Fragment, { children: [showSpinner && (_jsx(Box, { marginTop: 1, marginBottom: showLiveRows ? 0 : 1, children: status === "recovering" || status === "compacting" ? _jsx(RecoverSpinner, { active: true, label: stepLabel })
103
114
  : status === "executing" && !showLiveRows ? _jsx(StepSpinner, { active: true, label: stepLabel })
104
115
  : _jsx(ThinkingSpinner, { active: true, verb: status === "executing" ? thinkingVerb ?? "Running" : thinkingVerb, verbs: verbs, metrics: metrics }) })), showLiveRows && (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, paddingLeft: 1, children: [_jsx(Text, { dimColor: true, children: batchHeader(liveTools, termCols()) }), liveTools.slice(0, MAX_LIVE_TOOL_ROWS).map((step) => (_jsxs(React.Fragment, { children: [_jsx(LiveRow, { step: step }), delegate && step.id === delegateRow(liveTools, delegate) ? _jsx(DelegateChild, { view: delegate }) : null] }, step.id))), liveTools.length > MAX_LIVE_TOOL_ROWS ? _jsxs(Text, { dimColor: true, children: [" +", liveTools.length - MAX_LIVE_TOOL_ROWS, " more\u2026"] }) : null] })), fold ? (() => { const line = foldLine(fold, termCols(), true); return _jsxs(Text, { children: [_jsx(Text, { color: theme.blocked, children: line.slice(0, 1) }), _jsx(Text, { dimColor: true, children: line.slice(1) })] }); })() : null, _jsx(PlanPane, { tasks: tasks, now: planNow }), liveWorkers(mainLane, bgAgents, shellJobs) >= 2
105
- ? _jsx(Lanes, { main: mainLane, agents: bgAgents, jobs: shellJobs, mainServing: mainServing, maxRunning: maxRunning })
116
+ ? _jsx(Lanes, { main: mainLane, agents: bgAgents, jobs: shellJobs, mainServing: mainServing, maxRunning: maxRunning, pool: lanePool, warnings: laneWarnings })
106
117
  : _jsx(BgPanel, { agents: bgAgents, jobs: shellJobs }), (thinking || status === "executing" || status === "recovering" || status === "compacting") && (_jsx(PhaseLine, { view: phase ?? { phase: status === "executing" ? "tools" : status === "recovering" ? "recovering" : status === "compacting" ? "compacting" : status === "streaming" ? "writing" : "waiting", label: stepLabel }, rows: liveTools, offer: actOffer }))] }));
107
118
  // One input owner at a time. An open overlay — the finder, the focused switcher — keeps the keyboard; a prompt that
108
119
  // arrives under it (an approval, an ask_user, the plan review) is drawn, waiting, and answered only once the overlay
@@ -120,7 +131,7 @@ export function App(props) {
120
131
  const modeText = opMode ? ` ${MODE_BADGE[opMode]} · shift+tab to cycle` : "";
121
132
  const rcText = `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} `;
122
133
  const centre = switcher ? switcherLine(conversations, switcher, Math.max(0, cols - 1 - cellWidth(modeText) - cellWidth(rcText) - 2)) : "";
123
- const bottom = (_jsxs(_Fragment, { children: [_jsx(SwitcherKeys, { active: owner === "switcher", onKey: onSwitcher }), conversationPane ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "magenta", children: conversationPane.header }), conversationPane.lines.map((l, i) => _jsx(Text, { dimColor: !l.startsWith("⏺") && !l.startsWith("❯"), children: l || " " }, i))] })) : null, _jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxWindow: ctxWindow, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), owner === "composer" && status === "idle" && nextSteps?.length ? _jsx(Text, { color: "cyan", children: nextStepLine(nextSteps, cols) }) : null, pendingLines(pending, cols, phase ? phaseWord(phase.phase) : undefined).map((line, i) => _jsx(Text, { color: "yellow", children: line }, i)), onExpand ? _jsx(ExpandKey, { onExpand: onExpand, active: owner === "composer" }) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onSteer: onSteer, queued: pending.length, nextSteps: owner === "composer" && status === "idle" ? nextSteps?.length ?? 0 : 0, onPickNext: onPickNext, onDismissNext: onDismissNext, agents: agents, onAgentMessage: onAgentMessage, onSendTo: conversationPane ? onSendTo : undefined, onFocusSwitcher: onFocusSwitcher, onActNow: onActNow, onOpenFinder: onOpenFinder, prompt: conversationPane ? `${conversationPane.target} › ` : undefined, onEditQueued: onEditQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: owner !== "composer" }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: modeText }), centre ? (() => {
134
+ const bottom = (_jsxs(_Fragment, { children: [_jsx(SwitcherKeys, { active: owner === "switcher", onKey: onSwitcher }), conversationPane ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "magenta", children: conversationPane.header }), conversationPane.lines.map((l, i) => _jsx(Text, { dimColor: !l.startsWith("⏺") && !l.startsWith("❯"), children: l || " " }, i))] })) : null, _jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxWindow: ctxWindow, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), owner === "composer" && status === "idle" && nextSteps?.length ? _jsx(Text, { color: "cyan", children: nextStepLine(nextSteps, cols) }) : null, pendingLines(pending, cols, phase ? phaseWord(phase.phase) : undefined).map((line, i) => _jsx(Text, { color: "yellow", children: line }, i)), voice ? _jsx(Text, { color: voice.recording ? "red" : undefined, bold: voice.recording, dimColor: !voice.recording, children: fitSegments([seg(voice.line)], cols) }) : null, onExpand ? _jsx(ExpandKey, { onExpand: onExpand, active: owner === "composer" }) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onSteer: onSteer, queued: pending.length, nextSteps: owner === "composer" && status === "idle" ? nextSteps?.length ?? 0 : 0, onPickNext: onPickNext, onDismissNext: onDismissNext, agents: agents, onAgentMessage: onAgentMessage, onSendTo: conversationPane ? onSendTo : undefined, onFocusSwitcher: onFocusSwitcher, onActNow: onActNow, onOpenFinder: onOpenFinder, onVoiceKey: onVoiceKey, prompt: conversationPane ? `${conversationPane.target} › ` : undefined, onEditQueued: onEditQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: owner !== "composer" }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: modeText }), centre ? (() => {
124
135
  const pad = centreLayout(cellWidth(modeText), cellWidth(centre), cellWidth(rcText), cols);
125
136
  return _jsx(Text, { color: switcher?.focused ? "cyan" : undefined, dimColor: !switcher?.focused, children: " ".repeat(pad.before) + centre + " ".repeat(Math.max(0, pad.after - 1)) });
126
137
  })() : null, _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: rcText })] }))] }));
@@ -136,7 +147,7 @@ export function App(props) {
136
147
  // but DEMAND-DRIVEN — the provider only turns SGR tracking on while an overlay (picker/approval) is open,
137
148
  // so the terminal's native scrollback (wheel-scroll + drag-to-copy) is untouched the rest of the time.
138
149
  // The composer is measured (MeasuredComposer) so an open picker's click anchor knows what sits below it.
139
- return (_jsx(MouseProvider, { enabled: caps().mouse, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), activity, _jsxs(MeasuredStack, { children: [prompts, bottom] })] }) }));
150
+ return (_jsx(MouseProvider, { enabled: caps().mouse, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live, liveRows: chromeRows === undefined ? undefined : termRows() - chromeRows - 1 }), _jsxs(Box, { ref: chromeRef, flexDirection: "column", children: [activity, _jsxs(MeasuredStack, { children: [prompts, bottom] })] })] }) }));
140
151
  }
141
152
  // Keys while the conversation switcher has focus (the composer is suspended meanwhile): ←/→ (or ↓) pick, Enter opens,
142
153
  // ↑ or Esc hands the keyboard back to the composer.
@@ -38,7 +38,7 @@ export function ApprovalPrompt({ approval, onDecide, suspended = false, waiting
38
38
  else if (c === "a" || key.return)
39
39
  onDecide(true, false); // allow once
40
40
  else if (c === "s" && !approval.ctx?.once)
41
- onDecide(true, true); // allow always (this session); never for a phone signature line
41
+ onDecide(true, true); // allow always (this session); never when ctx.once
42
42
  else if (c === "d" || key.escape)
43
43
  onDecide(false, false); // deny
44
44
  }, { isActive: !!approval && !suspended });