@0perator/operator 0.1.360-next.2 → 0.2.1
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/commands.js +7 -3
- package/dist/auth/identity.js +1 -0
- package/dist/auth/staff.js +55 -0
- package/dist/autonomy/delegate-mode.js +159 -0
- package/dist/autonomy/delegate.js +42 -15
- package/dist/autonomy/headless.js +7 -4
- package/dist/autonomy/index.js +2 -4
- 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 +336 -45
- 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/resume.js +125 -0
- package/dist/background/synthesis.js +25 -0
- package/dist/browser/engine.js +163 -0
- package/dist/browser/session.js +130 -140
- package/dist/bus/inbox.js +150 -6
- package/dist/cli.js +343 -86
- package/dist/config/features.js +3 -3
- package/dist/config/persona.js +29 -3
- package/dist/config/settings.js +262 -21
- package/dist/config/staff-prompt.js +12 -0
- package/dist/engine/agent.js +52 -41
- package/dist/engine/aurora.js +40 -8
- package/dist/engine/batch-scheduler.js +4 -13
- package/dist/engine/compaction.js +2 -2
- package/dist/engine/continuation.js +30 -32
- package/dist/engine/decision-points.js +2 -3
- package/dist/engine/fanout.js +16 -0
- package/dist/engine/loop-guard.js +26 -83
- package/dist/engine/messages.js +2 -2
- package/dist/engine/moa.js +18 -2
- package/dist/engine/native-vision-node.js +72 -0
- package/dist/engine/native-vision.js +103 -0
- package/dist/engine/selfheal.js +1 -1
- package/dist/engine/toolcalls.js +6 -6
- package/dist/engine/verify-gate.js +37 -7
- package/dist/gateway-cli.js +14 -3
- package/dist/index.js +3 -0
- package/dist/mcp/phone-server.js +30 -0
- package/dist/memory/live-progress.js +4 -5
- 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 +33 -17
- package/dist/permissions/signature.js +5 -0
- package/dist/permissions/tier.js +4 -2
- package/dist/phone-cli.js +65 -0
- package/dist/products/craft.js +2 -2
- package/dist/remote/grants.js +119 -0
- package/dist/remote/host.js +63 -6
- package/dist/router/models.js +29 -29
- package/dist/selfimprove/index.js +9 -7
- package/dist/services/preflight.js +35 -91
- package/dist/session.js +173 -46
- 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/classes.js +103 -0
- package/dist/tools/contract.js +1 -1
- package/dist/tools/craft.js +13 -2
- package/dist/tools/deferred.js +1 -0
- package/dist/tools/device/android.js +227 -0
- package/dist/tools/device/classify.js +127 -0
- package/dist/tools/device/deps.js +69 -0
- package/dist/tools/device/desktop.js +82 -0
- package/dist/tools/device/harness.js +262 -0
- package/dist/tools/device/iphone.js +206 -0
- package/dist/tools/device/mirroring-jxa.js +146 -0
- package/dist/tools/device/setup.js +90 -0
- package/dist/tools/device/tools.js +70 -0
- package/dist/tools/device/types.js +19 -0
- package/dist/tools/executor.js +25 -15
- package/dist/tools/generation-gateway.js +94 -0
- package/dist/tools/registry.js +95 -155
- package/dist/ui/App.js +18 -6
- package/dist/ui/ApprovalPrompt.js +10 -4
- package/dist/ui/BgPanel.js +17 -12
- package/dist/ui/Header.js +1 -6
- package/dist/ui/StatusRule.js +18 -7
- package/dist/ui/ToolStep.js +3 -3
- package/dist/ui/Transcript.js +36 -14
- package/dist/ui/UpdatePrompt.js +40 -0
- 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 +1 -1
- package/dist/ui/opsMode.js +20 -0
- package/dist/ui/slashCommands.js +1 -0
- package/dist/ui/types.js +0 -2
- package/dist/update-check.js +145 -0
- package/dist/update.js +59 -15
- package/dist/util/slash.js +2 -2
- package/package.json +4 -2
- package/src/tools/device/NOTICE +37 -0
- package/dist/browser/cdp.js +0 -271
- package/dist/tools/mutating.js +0 -15
package/dist/tools/registry.js
CHANGED
|
@@ -27,10 +27,12 @@ import { formatGitStatus } from "./git-status.js";
|
|
|
27
27
|
import { DOC_TEXT_EXTS, describeDocText, docExt, extractDocText } from "./doc-text.js";
|
|
28
28
|
import { askVision, visionGateways, VISION_LIMITS } from "./vision-gateway.js";
|
|
29
29
|
import { DESIGN_PROBE_JS, DESIGN_QUESTION, MEDIA_CAPS, downloadVideoPage, evenTimes, fmtTime, formatDesignRead, grabFrames, isVideoPageUrl, parseTimestamps } from "./vision-media.js";
|
|
30
|
+
import { generate, generationGateways } from "./generation-gateway.js";
|
|
30
31
|
import { expandPath, assertContentSearchScope, assertShellHomeWideSearch, assertShellBlindDownload } from "./paths.js";
|
|
31
32
|
import { resolveReadPath } from "./read-path.js";
|
|
32
33
|
import { recordRead, getRead, forgetReads, seenView } from "./read-ledger.js"; // per-session read-state (pure, node-free — stays out of the neutral graph)
|
|
33
34
|
import { CRAFT_TOOLS } from "./craft.js";
|
|
35
|
+
import { artifactVisibility } from "../permissions/artifact-visibility.js";
|
|
34
36
|
import { runMemoryTool } from "./memory.js";
|
|
35
37
|
import { documentGenerate } from "./document.js";
|
|
36
38
|
import { runCronTool } from "../autonomy/cron.js";
|
|
@@ -1530,9 +1532,6 @@ async function taskClear(args) {
|
|
|
1530
1532
|
// short-lived process that loads FLUX, renders, and exits (steady-state RAM = 0). This is the ONLY sanctioned
|
|
1531
1533
|
// way to make images — loading a diffusion model inline in a turn pins GBs on the serving box, swaps, and
|
|
1532
1534
|
// 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
1535
|
/** ONE-API gateway: when KODE_GATEWAY_URL is set, prefer the unified route `api.axe.onl/<service>/…`, which
|
|
1537
1536
|
* fans out to the broker server-side (one door, one token). Empty when unset → per-broker URLs are used. The
|
|
1538
1537
|
* gateway strips the `/<service>/` prefix, so the broker still sees its native OpenAI path. See
|
|
@@ -1541,11 +1540,6 @@ function gatewayEndpoints(service) {
|
|
|
1541
1540
|
const g = process.env.KODE_GATEWAY_URL;
|
|
1542
1541
|
return g ? [`${g.replace(/\/$/, "")}/${service}`] : [];
|
|
1543
1542
|
}
|
|
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
1543
|
/** Candidate IDENTITY-broker endpoints (reference-likeness: SDXL RealVisXL + IP-Adapter-FaceID). Used when
|
|
1550
1544
|
* image_generate carries a `reference` (preserve a SPECIFIC face). KODE_IDENTITY_URL is tried FIRST: point it at
|
|
1551
1545
|
* 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 +1604,7 @@ async function recordMediaGen(rec) {
|
|
|
1610
1604
|
* broker). Shared by image_generate + video_generate so the URL-first contract is identical for both. */
|
|
1611
1605
|
async function saveGeneratedMedia(items, outArg, ext) {
|
|
1612
1606
|
const { writeFile, mkdir } = await nodeImport("node:fs/promises");
|
|
1613
|
-
const {
|
|
1614
|
-
const { join, dirname } = await nodeImport("node:path");
|
|
1607
|
+
const { dirname } = await nodeImport("node:path");
|
|
1615
1608
|
const kind = ext === "png" ? "image" : "video";
|
|
1616
1609
|
const dotExt = new RegExp(`(\\.${ext})?$`, "i");
|
|
1617
1610
|
const refs = []; // renderable reference per item — public URL when present, else a local path
|
|
@@ -1622,7 +1615,7 @@ async function saveGeneratedMedia(items, outArg, ext) {
|
|
|
1622
1615
|
if (b64 && (outArg || !url)) {
|
|
1623
1616
|
const p = outArg
|
|
1624
1617
|
? (items.length > 1 ? outArg.replace(dotExt, `-${i + 1}.${ext}`) : (outArg.toLowerCase().endsWith(`.${ext}`) ? outArg : `${outArg}.${ext}`))
|
|
1625
|
-
:
|
|
1618
|
+
: operatorPath("artifacts", `axe-${kind}-${Date.now().toString(36)}-${i + 1}.${ext}`);
|
|
1626
1619
|
await mkdir(dirname(p), { recursive: true }).catch(() => { });
|
|
1627
1620
|
await writeFile(p, Buffer.from(b64, "base64"));
|
|
1628
1621
|
saved.push(p);
|
|
@@ -1634,6 +1627,8 @@ async function saveGeneratedMedia(items, outArg, ext) {
|
|
|
1634
1627
|
}
|
|
1635
1628
|
return { refs, saved };
|
|
1636
1629
|
}
|
|
1630
|
+
/** 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. */
|
|
1631
|
+
const IMAGE_TIMEOUT_MS = 600_000;
|
|
1637
1632
|
async function imageGenerate(args) {
|
|
1638
1633
|
const prompt = str(args.prompt);
|
|
1639
1634
|
if (!prompt)
|
|
@@ -1641,147 +1636,77 @@ async function imageGenerate(args) {
|
|
|
1641
1636
|
const size = /^\d+x\d+$/.test(str(args.size)) ? str(args.size) : "512x512";
|
|
1642
1637
|
const n = Math.max(1, Math.min(Number(args.n) || 1, 4));
|
|
1643
1638
|
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
|
-
|
|
1645
|
-
|
|
1646
|
-
//
|
|
1647
|
-
|
|
1648
|
-
let
|
|
1649
|
-
|
|
1650
|
-
if (wantIdentity)
|
|
1639
|
+
const timeoutMs = Number(args.timeout_ms ?? IMAGE_TIMEOUT_MS);
|
|
1640
|
+
const genBody = { prompt, n, size, ...(wantExpand ? { expand: true } : {}), ...(Number(args.steps) > 0 ? { steps: Number(args.steps) } : {}) };
|
|
1641
|
+
// A reference-bearing request tries the IDENTITY broker first (preserve a SPECIFIC face via IP-Adapter-FaceID). It
|
|
1642
|
+
// has no route yet, so it keeps its direct endpoints; asleep, the image-gen route restyles from the reference instead.
|
|
1643
|
+
let identityBase;
|
|
1644
|
+
if (str(args.reference))
|
|
1651
1645
|
for (const e of identityEndpoints()) {
|
|
1652
1646
|
if (await imageHealthy(e)) {
|
|
1653
|
-
|
|
1654
|
-
identity = true;
|
|
1647
|
+
identityBase = e;
|
|
1655
1648
|
break;
|
|
1656
1649
|
}
|
|
1657
1650
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
}
|
|
1651
|
+
let answer;
|
|
1652
|
+
if (identityBase) {
|
|
1653
|
+
const ctrl = new AbortController();
|
|
1654
|
+
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
1655
|
+
try {
|
|
1656
|
+
const res = await fetch(`${identityBase}/v1/images/generations`, {
|
|
1657
|
+
method: "POST", signal: ctrl.signal,
|
|
1658
|
+
headers: { "Content-Type": "application/json", "User-Agent": "operator/kode-tsi", ...mediaAuth() },
|
|
1659
|
+
body: JSON.stringify({ ...genBody, reference: str(args.reference), strength: Number(args.strength ?? 0.65), ip_adapter_scale: Number(args.ip_adapter_scale ?? 0.8) }),
|
|
1660
|
+
});
|
|
1661
|
+
if (!res.ok)
|
|
1662
|
+
return `error: identity worker returned ${res.status}`;
|
|
1663
|
+
answer = { json: (await res.json().catch(() => ({}))) };
|
|
1664
|
+
}
|
|
1665
|
+
catch (e) {
|
|
1666
|
+
const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
|
|
1667
|
+
return `error: identity worker unreachable at ${identityBase} (${msg})`;
|
|
1668
|
+
}
|
|
1669
|
+
finally {
|
|
1670
|
+
clearTimeout(timer);
|
|
1664
1671
|
}
|
|
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
1672
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1673
|
+
else {
|
|
1674
|
+
if (str(args.reference))
|
|
1675
|
+
Object.assign(genBody, { image: str(args.reference), strength: Number(args.strength ?? 0.65) }); // flux img2img: the reference is the init
|
|
1676
|
+
try {
|
|
1677
|
+
answer = await generate(generationGateways(), "image", genBody, timeoutMs);
|
|
1678
|
+
}
|
|
1679
|
+
catch (e) {
|
|
1680
|
+
return `error: ${e.message}`;
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
const j = answer.json;
|
|
1684
|
+
const imgs = j.data ?? [];
|
|
1685
|
+
if (!imgs.length)
|
|
1686
|
+
return "error: image worker returned no image data";
|
|
1687
|
+
const { refs, saved } = await saveGeneratedMedia(imgs, str(args.out), "png");
|
|
1688
|
+
if (!refs.length)
|
|
1689
|
+
return "error: image worker returned no url and no decodable PNG";
|
|
1690
|
+
const exp = j.axe_prompt_expansion?.used ? j.axe_prompt_expansion.expanded : undefined; // the broker-rewritten prompt that was actually rendered
|
|
1691
|
+
const id = j.axe_identity?.identity_applied ? j.axe_identity : undefined; // the identity broker injected a real face (honest method/fidelity)
|
|
1692
|
+
const i2i = !id && j.axe_img2img?.used ? j.axe_img2img : undefined; // pose/style restyle from a reference — NOT the exact face
|
|
1693
|
+
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 } : {}) });
|
|
1694
|
+
const extra = saved.length && refs.some((r) => /^https?:\/\//.test(r)) ? ` (also saved: ${saved.join(", ")})` : "";
|
|
1695
|
+
const expNote = exp ? ` (expanded → "${exp.length > 160 ? exp.slice(0, 160) + "…" : exp}")` : "";
|
|
1696
|
+
// Honest provenance in the result: name WHICH reference mechanism actually ran, so likeness is never overclaimed.
|
|
1697
|
+
const refNote = id
|
|
1698
|
+
? ` (identity: ${id.method ?? "reference"}${id.base_model ? ` on ${id.base_model}` : ""}${id.fidelity_note ? ` — ${id.fidelity_note}` : ""})`
|
|
1699
|
+
: i2i
|
|
1700
|
+
? ` (img2img restyle @ strength ${i2i.strength ?? "?"} — matches pose/composition/style, NOT the exact face)`
|
|
1701
|
+
: "";
|
|
1702
|
+
const via = answer.backend ? ` (via ${answer.backend})` : ""; // which leg rendered it: a fallback leg is a different model
|
|
1703
|
+
return `generated ${refs.length} image${refs.length > 1 ? "s" : ""} (${size}) → ${refs.join(", ")}${extra}${expNote}${refNote}${via}`;
|
|
1704
|
+
}
|
|
1705
|
+
// video_generate — no video leg serves yet, so there is no route behind it: one plain answer instead of a host probe.
|
|
1732
1706
|
async function videoGenerate(args) {
|
|
1733
|
-
|
|
1734
|
-
if (!prompt)
|
|
1707
|
+
if (!str(args.prompt))
|
|
1735
1708
|
return "error: video_generate needs a prompt";
|
|
1736
|
-
|
|
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
|
-
}
|
|
1709
|
+
return "error: video generation isn't available yet";
|
|
1785
1710
|
}
|
|
1786
1711
|
async function visionSettings() {
|
|
1787
1712
|
const { loadSettings } = await nodeImport("../config/settings.js"); // variable-specifier load keeps settings out of the browser graph
|
|
@@ -1901,7 +1826,7 @@ async function flattenAlpha(image) {
|
|
|
1901
1826
|
return image;
|
|
1902
1827
|
}
|
|
1903
1828
|
}
|
|
1904
|
-
async function visionImageDataUrl(image, lim) {
|
|
1829
|
+
export async function visionImageDataUrl(image, lim) {
|
|
1905
1830
|
image = await absMediaPath(image);
|
|
1906
1831
|
if (/^https?:\/\//.test(image))
|
|
1907
1832
|
image = await fetchImageToTemp(image);
|
|
@@ -1929,7 +1854,7 @@ async function visionImageDataUrl(image, lim) {
|
|
|
1929
1854
|
const { stdout } = await pexec("sips", ["-g", "pixelWidth", "-g", "pixelHeight", image]);
|
|
1930
1855
|
const w = Number((/pixelWidth:\s*(\d+)/.exec(stdout) || [])[1] || 0);
|
|
1931
1856
|
const h = Number((/pixelHeight:\s*(\d+)/.exec(stdout) || [])[1] || 0);
|
|
1932
|
-
if (w && h && buf.length < w * h * BLANK_BYTES_PER_PX) {
|
|
1857
|
+
if (!lim.keepBlank && w && h && buf.length < w * h * BLANK_BYTES_PER_PX) {
|
|
1933
1858
|
const flat = await flatColour(pexec, image, join(dir, "t.bmp"));
|
|
1934
1859
|
if (flat)
|
|
1935
1860
|
return { blank: `${w}×${h}, one flat colour ${flat}, ${Math.max(1, Math.round(buf.length / 1024))} KB` };
|
|
@@ -1941,6 +1866,15 @@ async function visionImageDataUrl(image, lim) {
|
|
|
1941
1866
|
shrank = true;
|
|
1942
1867
|
}
|
|
1943
1868
|
catch {
|
|
1869
|
+
try {
|
|
1870
|
+
// Without sips the size comes from ffprobe, so an image already small enough keeps its own bytes and
|
|
1871
|
+
// type on every OS instead of being re-encoded as JPEG.
|
|
1872
|
+
const { stdout } = await pexec("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height", "-of", "csv=p=0:s=x", image]);
|
|
1873
|
+
const [w, h] = stdout.trim().split("x").map(Number);
|
|
1874
|
+
if (w && h && Math.max(w, h) <= lim.maxEdge && buf.length <= lim.maxBytes)
|
|
1875
|
+
return { url: `data:${mime};base64,${buf.toString("base64")}` };
|
|
1876
|
+
}
|
|
1877
|
+
catch { /* no ffprobe: fall through to the resize */ }
|
|
1944
1878
|
try {
|
|
1945
1879
|
// non-macOS / sips missing → ffmpeg; min() clamps the fit-box to the image so it never upscales.
|
|
1946
1880
|
await pexec("ffmpeg", ["-nostdin", "-y", "-loglevel", "error", "-i", image, "-vf", `scale='min(iw,${lim.maxEdge})':'min(ih,${lim.maxEdge})':force_original_aspect_ratio=decrease`, out]);
|
|
@@ -2160,7 +2094,7 @@ async function analyzePage(args) {
|
|
|
2160
2094
|
return `${head}\n\n${formatDesignRead({ source: shot.finalUrl, seen, ...pixels, ...(css ? { css } : {}) })}`;
|
|
2161
2095
|
}
|
|
2162
2096
|
// video_analyze — real video understanding: ffmpeg samples frames evenly across the clip, then the VL model
|
|
2163
|
-
// (same
|
|
2097
|
+
// (same vision endpoint, multi-image) describes what happens. Needs ffmpeg on PATH; verified the model
|
|
2164
2098
|
// synthesizes motion from ordered frames ("calm ocean with gentle waves, golden hue").
|
|
2165
2099
|
// A video PAGE link (YouTube, Vimeo, … or any url that answers HTML) resolves to a file through yt-dlp, inside
|
|
2166
2100
|
// MEDIA_CAPS; frames are single ffmpeg seeks at `timestamps` or evenly spaced times, so a long video is never decoded
|
|
@@ -2308,7 +2242,11 @@ async function imageRecreate(args) {
|
|
|
2308
2242
|
async function artifactCreate(args) {
|
|
2309
2243
|
const temple = (await nodeImport("../products/temple.js"));
|
|
2310
2244
|
const paths = Array.isArray(args.paths) ? args.paths.map(String).filter(Boolean) : [];
|
|
2311
|
-
const
|
|
2245
|
+
const { loadSettings } = await nodeImport("../config/settings.js");
|
|
2246
|
+
const vis = artifactVisibility(loadSettings().permissions?.tier, args.visibility, true);
|
|
2247
|
+
if ("error" in vis)
|
|
2248
|
+
return `error: ${vis.error}`;
|
|
2249
|
+
const visibility = vis.visibility;
|
|
2312
2250
|
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 });
|
|
2313
2251
|
if (!r.ok)
|
|
2314
2252
|
return `error: ${r.error}${/reach|timed out/.test(r.error) ? " — if this persists, write a local file with file_create instead" : ""}`;
|
|
@@ -2788,13 +2726,13 @@ const TOOLS = [
|
|
|
2788
2726
|
expand: { type: "boolean", description: "rewrite the prompt richer first (the quality lever)" },
|
|
2789
2727
|
steps: { type: "number", description: "default 4; ~8 for finer img2img" },
|
|
2790
2728
|
out: { type: "string", description: ".png path (default temp)" },
|
|
2791
|
-
timeout_ms: { type: "number", description: "default
|
|
2729
|
+
timeout_ms: { type: "number", description: "default 600000" },
|
|
2792
2730
|
}, required: ["prompt"] },
|
|
2793
2731
|
run: imageGenerate,
|
|
2794
2732
|
},
|
|
2795
2733
|
{
|
|
2796
2734
|
name: "video_generate",
|
|
2797
|
-
description: "
|
|
2735
|
+
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.",
|
|
2798
2736
|
parameters: { type: "object", properties: {
|
|
2799
2737
|
prompt: { type: "string", description: "what to generate" },
|
|
2800
2738
|
size: { type: "string", description: "WxH (default \"704x480\")" },
|
|
@@ -2804,7 +2742,7 @@ const TOOLS = [
|
|
|
2804
2742
|
reference_image: { type: "string", description: "first-frame image path/url (image-to-video)" },
|
|
2805
2743
|
expand: { type: "boolean", description: "rewrite the prompt richer first" },
|
|
2806
2744
|
out: { type: "string", description: ".mp4 path (default temp)" },
|
|
2807
|
-
timeout_ms: { type: "number", description: "default
|
|
2745
|
+
timeout_ms: { type: "number", description: "default 900000" },
|
|
2808
2746
|
}, required: ["prompt"] },
|
|
2809
2747
|
run: videoGenerate,
|
|
2810
2748
|
},
|
|
@@ -3032,11 +2970,11 @@ const TOOLS = [
|
|
|
3032
2970
|
{
|
|
3033
2971
|
name: "browser", safe: false,
|
|
3034
2972
|
contract: { v: 1, effects: ["fetch", "egress", "exec", "write"], bins: ["chrome"] },
|
|
3035
|
-
description: "Drive a REAL headless browser (
|
|
2973
|
+
description: "Drive a REAL headless browser (Playwright); state persists across calls — JS pages, logins, forms, clicks. Prefer browser_read for content. Actions: open/navigate(url) reload back forward click(selector) fill(selector, text) submit(selector) eval(js, awaits promises) screenshot → png path, tab_select/tab_close(index) close. http/https/about/data URLs only. Login wall: NEVER guess credentials — ask the owner.",
|
|
3036
2974
|
parameters: { type: "object", properties: {
|
|
3037
2975
|
action: { type: "string", enum: ["open", "navigate", "reload", "back", "forward", "click", "fill", "submit", "eval", "screenshot", "tab_select", "tab_close", "close"], description: "the browser action" },
|
|
3038
2976
|
url: { type: "string", description: "for open|navigate" },
|
|
3039
|
-
selector: { type: "string", description: "CSS selector for click|fill|submit" },
|
|
2977
|
+
selector: { type: "string", description: "CSS/Playwright selector for click|fill|submit" },
|
|
3040
2978
|
text: { type: "string", description: "value for fill" },
|
|
3041
2979
|
js: { type: "string", description: "JS expression for eval" },
|
|
3042
2980
|
index: { type: "number", description: "tab index" },
|
|
@@ -3438,10 +3376,12 @@ export function cloudAgentToolsFor(settings) {
|
|
|
3438
3376
|
export function mdocToolsFor(settings) {
|
|
3439
3377
|
return isFeatureEnabled("mdoc", settings ?? undefined) ? MDOC_TOOLS : [];
|
|
3440
3378
|
}
|
|
3441
|
-
//
|
|
3442
|
-
//
|
|
3379
|
+
// The artifact library (craft_list/get/update/delete) is on for every seat (2026-11-29): artifact_create makes an
|
|
3380
|
+
// artifact, these find and change it, so nobody has to add an MCP server to manage their own work. With deferred
|
|
3381
|
+
// tools (default on) they cost nothing in the cached prefix. craft_create stays behind the `craft` flag: it
|
|
3382
|
+
// duplicates artifact_create, the one way to make an artifact.
|
|
3443
3383
|
export function craftToolsFor(settings) {
|
|
3444
|
-
return isFeatureEnabled("craft", settings ?? undefined) ? CRAFT_TOOLS :
|
|
3384
|
+
return isFeatureEnabled("craft", settings ?? undefined) ? CRAFT_TOOLS : CRAFT_TOOLS.filter(t => t.name !== "craft_create");
|
|
3445
3385
|
}
|
|
3446
3386
|
export function toSchemas(reg = registry) {
|
|
3447
3387
|
return [...reg.values()].map(t => ({
|
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";
|
|
@@ -30,6 +30,7 @@ import { SecretPrompt } from "./SecretPrompt.js";
|
|
|
30
30
|
import { ArtifactPicker } from "./ArtifactPicker.js";
|
|
31
31
|
import { SessionPicker } from "./SessionPicker.js";
|
|
32
32
|
import { SkillFinder } from "./SkillFinder.js";
|
|
33
|
+
import { UpdatePrompt } from "./UpdatePrompt.js";
|
|
33
34
|
import { pendingLines, turnKeySegs } from "./pending.js";
|
|
34
35
|
import { nextStepLine } from "./nextStep.js";
|
|
35
36
|
import { centreLayout, switcherLine } from "./conversations.js";
|
|
@@ -90,8 +91,19 @@ function ExpandKey({ onExpand, active }) {
|
|
|
90
91
|
return null;
|
|
91
92
|
}
|
|
92
93
|
export function App(props) {
|
|
93
|
-
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 } = 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, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null, update = null } = props;
|
|
94
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
|
+
});
|
|
95
107
|
const thinking = status === "thinking" || status === "streaming";
|
|
96
108
|
// Tool rows exist before their calls run (TUI plan #8): from the first streamed argument (drafting) through waiting
|
|
97
109
|
// its turn to running and settled — one row per call, a lone call included, instead of the bare "⠋ name…".
|
|
@@ -101,18 +113,18 @@ export function App(props) {
|
|
|
101
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 })
|
|
102
114
|
: status === "executing" && !showLiveRows ? _jsx(StepSpinner, { active: true, label: stepLabel })
|
|
103
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
|
|
104
|
-
? _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 })
|
|
105
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 }))] }));
|
|
106
118
|
// One input owner at a time. An open overlay — the finder, the focused switcher — keeps the keyboard; a prompt that
|
|
107
119
|
// arrives under it (an approval, an ask_user, the plan review) is drawn, waiting, and answered only once the overlay
|
|
108
120
|
// closes, so nothing typed into the overlay can answer it. With no overlay open a pending prompt owns the keyboard and
|
|
109
121
|
// the composer gives way, its next-step strip with it. Overlays open only from the composer, so never over a prompt.
|
|
110
|
-
const promptUp = !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker;
|
|
122
|
+
const promptUp = !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker || !!update;
|
|
111
123
|
const owner = finder ? "finder" : switcher?.focused ? "switcher" : promptUp ? "prompt" : "composer";
|
|
112
124
|
const held = owner === "finder" || owner === "switcher";
|
|
113
125
|
const waiting = owner === "finder" ? "esc closes the finder, then answer here" : "↑ hands the keyboard back, then answer here";
|
|
114
126
|
// Prompts are kept out of the fullscreen clip region so they can't be scrolled off.
|
|
115
|
-
const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }), suspended: held, waiting: waiting }), _jsx(QuestionPrompt, { pending: question, suspended: held, waiting: waiting }), _jsx(QuestionPrompt, { pending: modelPicker, suspended: held, waiting: waiting }), _jsx(SecretPrompt, { pending: secretPrompt, suspended: held }), _jsx(QuestionPrompt, { pending: planExitPicker, suspended: held, waiting: waiting }), _jsx(ArtifactPicker, { pending: artifactsPicker, suspended: held }), _jsx(SessionPicker, { pending: sessionsPicker, suspended: held }), _jsx(SkillFinder, { pending: finder })] }));
|
|
127
|
+
const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }), suspended: held, waiting: waiting }), _jsx(QuestionPrompt, { pending: question, suspended: held, waiting: waiting }), _jsx(QuestionPrompt, { pending: modelPicker, suspended: held, waiting: waiting }), _jsx(SecretPrompt, { pending: secretPrompt, suspended: held }), _jsx(QuestionPrompt, { pending: planExitPicker, suspended: held, waiting: waiting }), _jsx(ArtifactPicker, { pending: artifactsPicker, suspended: held }), _jsx(SessionPicker, { pending: sessionsPicker, suspended: held }), _jsx(UpdatePrompt, { pending: update, suspended: held }), _jsx(SkillFinder, { pending: finder })] }));
|
|
116
128
|
// The pinned bottom band: status rule, composer, bottom rule, then the mode/cycle FOOTER below the rule.
|
|
117
129
|
// The mode line: the mode on the left, the conversation switcher in the centre, remote control on the right. The centre
|
|
118
130
|
// gets what the two sides leave, so the row stays at cols−1.
|
|
@@ -135,7 +147,7 @@ export function App(props) {
|
|
|
135
147
|
// but DEMAND-DRIVEN — the provider only turns SGR tracking on while an overlay (picker/approval) is open,
|
|
136
148
|
// so the terminal's native scrollback (wheel-scroll + drag-to-copy) is untouched the rest of the time.
|
|
137
149
|
// The composer is measured (MeasuredComposer) so an open picker's click anchor knows what sits below it.
|
|
138
|
-
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] })] })] }) }));
|
|
139
151
|
}
|
|
140
152
|
// Keys while the conversation switcher has focus (the composer is suspended meanwhile): ←/→ (or ↓) pick, Enter opens,
|
|
141
153
|
// ↑ or Esc hands the keyboard back to the composer.
|
|
@@ -15,6 +15,10 @@ function summarize(name, args) {
|
|
|
15
15
|
case "computer_key": return `key: ${s(args.key)}${Array.isArray(args.modifiers) && args.modifiers.length ? ` +${args.modifiers.join("+")}` : ""}`;
|
|
16
16
|
case "computer_click": return `click at ${s(args.x)},${s(args.y)}`;
|
|
17
17
|
case "computer_screenshot": return "capture the screen to a file";
|
|
18
|
+
case "phone_tap": return `${args.device ? `${s(args.device)}: ` : ""}tap ${typeof args.text === "string" ? `"${s(args.text)}"` : `${s(args.x)},${s(args.y)}`}`;
|
|
19
|
+
case "phone_type": return `${args.device ? `${s(args.device)}: ` : ""}type ${String(args.text ?? "").length} characters${args.submit === true ? " and press enter" : ""}`;
|
|
20
|
+
case "phone_key": return `${args.device ? `${s(args.device)}: ` : ""}press ${s(args.key)}`;
|
|
21
|
+
case "phone_open_app": return `${args.device ? `${s(args.device)}: ` : ""}open ${s(args.name)}`;
|
|
18
22
|
case "shell_exec": return `$ ${s(args.command, 120)}`;
|
|
19
23
|
case "file_write": return `write ${s(args.path)}`;
|
|
20
24
|
case "file_edit": return `edit ${s(args.path)}`;
|
|
@@ -33,15 +37,17 @@ export function ApprovalPrompt({ approval, onDecide, suspended = false, waiting
|
|
|
33
37
|
onDecide(false, false); // Ctrl-C at the prompt = deny (bail out safely)
|
|
34
38
|
else if (c === "a" || key.return)
|
|
35
39
|
onDecide(true, false); // allow once
|
|
36
|
-
else if (c === "s")
|
|
37
|
-
onDecide(true, true); // allow always (this session)
|
|
40
|
+
else if (c === "s" && !approval.ctx?.once)
|
|
41
|
+
onDecide(true, true); // allow always (this session); never for a phone signature line
|
|
38
42
|
else if (c === "d" || key.escape)
|
|
39
43
|
onDecide(false, false); // deny
|
|
40
44
|
}, { isActive: !!approval && !suspended });
|
|
41
45
|
if (!approval)
|
|
42
46
|
return null;
|
|
43
47
|
const detail = summarize(approval.name, approval.args);
|
|
44
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "yellow", paddingX: 1, children: [_jsxs(Text, { color: "yellow", bold: true, children: ["⚠ Operator wants to run ", _jsx(Text, { color: "magenta", children: approval.name })] }), detail ? _jsx(Text, { dimColor: true, children: " " + detail }) : null, suspended
|
|
48
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "yellow", paddingX: 1, children: [_jsxs(Text, { color: "yellow", bold: true, children: ["⚠ Operator wants to run ", _jsx(Text, { color: "magenta", children: approval.name })] }), detail ? _jsx(Text, { dimColor: true, children: " " + detail }) : null, approval.ctx ? _jsx(Text, { color: "red", bold: true, children: ` ${approval.ctx.line} — a human signs this one, every time` }) : null, approval.ctx?.preview ? _jsx(Text, { children: " the screen it will act on: " + approval.ctx.preview }) : null, suspended
|
|
45
49
|
? _jsx(Text, { dimColor: true, children: " waiting · " + (waiting ?? "another prompt has the keyboard") })
|
|
46
|
-
:
|
|
50
|
+
: approval.ctx?.once
|
|
51
|
+
? _jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "[a]" }), " allow once ", _jsx(Text, { color: "red", children: "[d]" }), " deny ", _jsx(Text, { dimColor: true, children: "(Enter=allow \u00B7 Esc=deny)" })] })
|
|
52
|
+
: _jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "[a]" }), " allow once ", _jsx(Text, { color: "cyan", children: "[s]" }), " allow always ", _jsx(Text, { color: "red", children: "[d]" }), " deny ", _jsx(Text, { dimColor: true, children: "(Enter=allow \u00B7 Esc=deny)" })] })] }));
|
|
47
53
|
}
|
package/dist/ui/BgPanel.js
CHANGED
|
@@ -6,6 +6,8 @@ import { useTick } from "./tick.js";
|
|
|
6
6
|
import { termCols, termRows } from "./term.js";
|
|
7
7
|
import { cellWidth, truncateToWidth } from "./StatusRule.js";
|
|
8
8
|
import { fmtElapsed, fmtTok } from "./format.js";
|
|
9
|
+
import { laneSummary } from "../background/lane-summary.js";
|
|
10
|
+
import { deadlineText } from "../background/synthesis.js";
|
|
9
11
|
const GLYPH = { queued: "◌", working: "●", idle: "✓", stopped: "✗" };
|
|
10
12
|
const COLOR = { queued: theme.muted, working: theme.running, idle: theme.success, stopped: theme.error };
|
|
11
13
|
const DISPLAY_STATUS = { queued: "queued", working: "running", idle: "done", stopped: "errored" };
|
|
@@ -69,7 +71,7 @@ export function ledgerLine(a) {
|
|
|
69
71
|
a.commands ? `ran ${a.commands}` : "",
|
|
70
72
|
].filter(Boolean).join(" · ");
|
|
71
73
|
const verify = a.verified == null ? "" : a.verified ? "✓ verified" : `✗ unverified${a.verifyDetail ? `: ${cap(a.verifyDetail, 30)}` : ""}`;
|
|
72
|
-
return [a.title ?? "assistant", a.model, done || (a.status === "working" ? "nothing written yet" : ""), verify, a.malformed ? "⚠ malformed" : ""]
|
|
74
|
+
return [a.title ?? "assistant", a.resumed ? "resumed" : "", a.model, done || (a.status === "working" ? "nothing written yet" : ""), verify, a.malformed ? "⚠ malformed" : ""]
|
|
73
75
|
.filter(Boolean).join(" · ");
|
|
74
76
|
}
|
|
75
77
|
/** The third row (pure, testable): a stuck agent shows WHY and the exact commands to re-steer or stop it; a working one
|
|
@@ -86,7 +88,7 @@ export function detailLine(a) {
|
|
|
86
88
|
if (a.status === "stopped")
|
|
87
89
|
return { text: a.endReason ?? "errored — check transcript for details", tone: "dim" };
|
|
88
90
|
if (a.status === "queued")
|
|
89
|
-
return { text: "waiting for a free slot", tone: "dim" };
|
|
91
|
+
return { text: a.queueReason ? `waiting: ${a.queueReason}` : "waiting for a free slot", tone: "dim" };
|
|
90
92
|
const steps = a.steps ?? [];
|
|
91
93
|
const stepLine = steps.slice(-3).map((s) => s.name + (s.arg ? `(${s.arg})` : "") + (s.running ? " …" : "")).join(" · ");
|
|
92
94
|
const head = stepLine ? `↳ ${stepLine}` : a.thought ? `⋮ ${a.thought.replace(/^…/, "").trim()}` : "";
|
|
@@ -167,11 +169,13 @@ export function mainLaneOf(m) {
|
|
|
167
169
|
/** One sub-agent as a lane: its round and mission, who holds the slot it waits for, why it stopped. Pure. */
|
|
168
170
|
export function agentLaneOf(a, now, ctx = {}) {
|
|
169
171
|
const elapsedMs = a.status === "working" ? (a.startedAt !== undefined ? now - a.startedAt : undefined) : a.durationMs;
|
|
170
|
-
const base = { key: a.id, name: a.name ?? a.id, role: a.title ?? "sub-agent"
|
|
172
|
+
const base = { key: a.id, name: a.name ?? a.id, role: `${a.title ?? "sub-agent"}${a.resumed ? " · resumed" : ""}`, elapsedMs, tokens: a.tokens };
|
|
171
173
|
const ledger = [a.written?.length ? `wrote ${a.written.length}` : "", a.reads ? `read ${a.reads}` : "", a.commands ? `ran ${a.commands}` : ""].filter(Boolean).join(" · ");
|
|
172
174
|
const join = (...xs) => xs.filter(Boolean).join(" · ");
|
|
173
|
-
if (a.status === "queued")
|
|
174
|
-
|
|
175
|
+
if (a.status === "queued") {
|
|
176
|
+
const why = a.queueReason ?? (ctx.maxRunning ? `${ctx.running ?? ctx.maxRunning} of ${ctx.maxRunning} agent slots busy` : "waiting for a free agent slot");
|
|
177
|
+
return { ...base, tone: "queued", mission: join(`waiting${a.phase?.kind === "queued" ? ` ${fmtElapsed(now - a.phase.since)}` : ""}: ${why}`, deadlineText(a, now)) };
|
|
178
|
+
}
|
|
175
179
|
if (a.status === "idle")
|
|
176
180
|
return { ...base, tone: "done", mission: join("done", a.verified === true ? "✓ verified" : a.verified === false ? "✗ unverified" : undefined, a.written?.length ? `wrote ${a.written.slice(-1).map((p) => p.split("/").pop()).join("")}` : undefined, "report delivered") };
|
|
177
181
|
if (a.status === "stopped") {
|
|
@@ -183,8 +187,8 @@ export function agentLaneOf(a, now, ctx = {}) {
|
|
|
183
187
|
if (a.slotWaitSince !== undefined) {
|
|
184
188
|
return { ...base, tone: "waiting", mission: join(`waiting ${fmtElapsed(now - a.slotWaitSince)}: ${a.model ?? "its model"}'s slot is held by ${holderShort(a.slotHolder)}`, ledger || undefined) };
|
|
185
189
|
}
|
|
186
|
-
|
|
187
|
-
return { ...base, tone: "working", mission: join(a.round ? `r${a.round}` : undefined,
|
|
190
|
+
// What it is doing in plain words; the backend explains only a wait, so it stays out of a working lane (/agents <id>).
|
|
191
|
+
return { ...base, tone: "working", mission: join(a.round ? `r${a.round}` : undefined, laneSummary(a, now), deadlineText(a, now), a.evidence ? "⚠ shared input" : undefined, ledger || undefined) };
|
|
188
192
|
}
|
|
189
193
|
export function jobLaneOf(j, now) {
|
|
190
194
|
const tone = j.status === "running" ? "job" : j.status === "done" ? "jobDone" : "jobFailed";
|
|
@@ -208,11 +212,12 @@ export function laneRow(l, cols) {
|
|
|
208
212
|
const mission = truncateToWidth(l.mission, Math.max(0, room));
|
|
209
213
|
return { left, mission: mission + " ".repeat(Math.max(0, room - cellWidth(mission))), right };
|
|
210
214
|
}
|
|
211
|
-
/** The lanes header: counts, a rule, and the commands that act on them
|
|
212
|
-
|
|
215
|
+
/** The lanes header: counts, the live pool when the router reports one, a rule, and the commands that act on them
|
|
216
|
+
* (dropped under 80 cols) — cols−1 wide. */
|
|
217
|
+
export function laneHeader(lanes, cols, pool) {
|
|
213
218
|
const n = (t) => lanes.filter((l) => t.includes(l.tone)).length;
|
|
214
219
|
const running = n(["main", "working", "stuck"]), waiting = n(["waiting"]), queued = n(["queued"]), jobs = n(["job"]);
|
|
215
|
-
const counts = [`${lanes.length} lanes`, running ? `${running} running` : "", waiting ? `${waiting} waiting for a slot` : "", queued ? `${queued} queued` : "", jobs ? `${jobs} shell job${jobs === 1 ? "" : "s"}` : ""].filter(Boolean).join(" · ");
|
|
220
|
+
const counts = [`${lanes.length} lanes`, running ? `${running} running` : "", waiting ? `${waiting} waiting for a slot` : "", queued ? `${queued} queued` : "", jobs ? `${jobs} shell job${jobs === 1 ? "" : "s"}` : "", pool ?? ""].filter(Boolean).join(" · ");
|
|
216
221
|
const hint = cols >= 80 ? " /agents · /jobs" : "";
|
|
217
222
|
const head = truncateToWidth(` ⇶ ${counts} `, cols - 1 - cellWidth(hint) - 1);
|
|
218
223
|
return head + "─".repeat(Math.max(1, cols - 1 - cellWidth(head) - cellWidth(hint))) + hint;
|
|
@@ -224,7 +229,7 @@ function LaneRow({ lane, cols }) {
|
|
|
224
229
|
return (_jsxs(Text, { children: [" ", lane.tone === "working" ? _jsx(OrbitGlyph, {}) : _jsx(Text, { color: LANE_COLOR[lane.tone], children: LANE_GLYPH[lane.tone] }), " ", _jsx(Text, { bold: true, children: left.slice(0, 6) }), _jsx(Text, { dimColor: true, children: left.slice(6) }), _jsx(Text, { color: lane.tone === "stuck" ? theme.warn : undefined, dimColor: lane.tone !== "stuck" && lane.tone !== "main" && lane.tone !== "working", children: mission }), right ? _jsx(Text, { dimColor: true, children: ` ${right}` }) : null] }));
|
|
225
230
|
}
|
|
226
231
|
/** The lanes view: one row per live worker, finished agents lingering until they are reaped. */
|
|
227
|
-
export function Lanes({ main, agents, jobs, mainServing, maxRunning }) {
|
|
232
|
+
export function Lanes({ main, agents, jobs, mainServing, maxRunning, pool, warnings = [] }) {
|
|
228
233
|
const cols = termCols();
|
|
229
234
|
const now = Date.now();
|
|
230
235
|
const running = agents.filter((a) => a.status === "working").length;
|
|
@@ -236,5 +241,5 @@ export function Lanes({ main, agents, jobs, mainServing, maxRunning }) {
|
|
|
236
241
|
];
|
|
237
242
|
const cap = termRows() < LANES_SHORT_ROWS ? 3 : 8;
|
|
238
243
|
const shown = lanes.slice(0, cap);
|
|
239
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { dimColor: true, children: laneHeader(lanes, cols) }), shown.map((l) => _jsx(LaneRow, { lane: l, cols: cols }, l.key)), lanes.length > shown.length ? _jsx(Text, { dimColor: true, children: ` +${lanes.length - shown.length} more · /agents` }) : null] }));
|
|
244
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { dimColor: true, children: laneHeader(lanes, cols, pool) }), shown.map((l) => _jsx(LaneRow, { lane: l, cols: cols }, l.key)), warnings.slice(0, 1).map((w) => _jsx(Text, { color: theme.warn, wrap: "truncate-end", children: ` ⚠ ${w}` }, w)), lanes.length > shown.length ? _jsx(Text, { dimColor: true, children: ` +${lanes.length - shown.length} more · /agents` }) : null] }));
|
|
240
245
|
}
|