Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

CLI: fuobe skills run names the steps that wait in a skill that spans studios, and --wait follows it to the end

Claudee6b9b7c4960b
diff --git a/bin/lib/commands.mjs b/bin/lib/commands.mjs
index f18ea7ca..3e6091ac 100644
--- a/bin/lib/commands.mjs
+++ b/bin/lib/commands.mjs
@@ -274,6 +274,45 @@ export async function waitFor(ctx, ids) {
}
}
+/**
+ * Wait for runs of a skill that spans studios to end (each later step starts on the server when the steps before it
+ * finish): every step's generations, or why waiting stopped.
+ * @returns {Promise<{ ids: string[], stopped?: "timeout" | "interrupted" }>}
+ */
+async function waitRuns(ctx, name, runIds) {
+ const v = ctx.values;
+ const timeout = (v.timeout ?? 1800) * 1000;
+ const interval = Math.max(0.2, v.interval ?? 2) * 1000;
+ const started = ctx.io.now();
+ const pause = new AbortController();
+ const stopped = new Promise((resolve) => pause.signal.addEventListener("abort", resolve, { once: true }));
+ const off = ctx.io.onInterrupt(() => pause.abort());
+ const seen = new Map();
+ try {
+ for (;;) {
+ const { items = [] } = await ctx.client.request("GET", `/api/assist/skills/${enc(name)}/runs`);
+ const mine = items.filter((r) => runIds.includes(r.id));
+ if (!v.json) {
+ for (const r of mine) {
+ const line = r.steps.map((s) => `${s.label} · ${s.status}`).join(" → ");
+ if (seen.get(r.id) !== line) ctx.note(line);
+ seen.set(r.id, line);
+ }
+ }
+ const ids = mine.flatMap((r) => r.steps.flatMap((s) => s.ids));
+ if (mine.length === runIds.length && mine.every((r) => r.status !== "running")) {
+ for (const r of mine) if (r.error && !v.json) ctx.note(r.error);
+ return { ids };
+ }
+ if (timeout > 0 && ctx.io.now() - started >= timeout) return { ids, stopped: "timeout" };
+ await Promise.race([ctx.io.sleep(interval, pause.signal), stopped]);
+ if (pause.signal.aborted) return { ids, stopped: "interrupted" };
+ }
+ } finally {
+ off();
+ }
+}
+
/** Save every output of the finished generations into `dir`. */
async function saveOutputs(ctx, gens, dir) {
const files = [];
@@ -835,10 +874,16 @@ async function skillsRun(ctx, name) {
const runsOut = out.runs.map((r, i) => (req.rows ? { ...r, line: req.runLine(i) } : r));
const demo = out.demo ? " (a demo: nothing connected, free)" : "";
for (const [i, r] of out.runs.entries()) if (r.error && !v.json) ctx.note(`${req.rows ? `Row ${req.runLine(i)}` : `Run ${i + 1}`} didn't start: ${r.error}`);
- const studio = out.runs.find((r) => r.href && !r.href.startsWith("/library"))?.href;
+ const studio = out.runs.find((r) => r.href && !r.href.startsWith("/library") && !r.href.startsWith("/assist/skills"))?.href;
+ // A skill that spans studios: its later steps start by themselves on the server as the steps before them finish.
+ const waiting = [...new Set(out.runs.flatMap((r) => r.waiting ?? []))];
+ const progress = absolute(ctx, `/assist/skills?skill=${enc(view.name)}`);
if (v.wait || v.out) {
if (!v.json) ctx.note(`Started ${started === 1 ? view.title : `${started} runs of ${view.title}`}${all ? "" : ` (${out.runs.length - started} didn't start)`}${demo}.${studio ? ` It opens in ${absolute(ctx, studio)}` : ""}`);
- const code = await finish(ctx, ids, { download: !!v.out, also: { runs: runsOut } });
+ const staged = out.runs.filter((r) => r.run && !r.error);
+ const later = staged.length ? await waitRuns(ctx, view.name, staged.map((r) => r.run)) : null;
+ if (later?.stopped) return later.stopped === "interrupted" ? EXIT.interrupted : EXIT.timeout;
+ const code = await finish(ctx, later ? [...new Set([...ids, ...later.ids])] : ids, { download: !!v.out, also: { runs: runsOut } });
return code === EXIT.ok && !all ? EXIT.failed : code;
}
if (v.json) {
@@ -847,7 +892,8 @@ async function skillsRun(ctx, name) {
}
ctx.print(`Started ${started === 1 ? view.title : `${started} runs of ${view.title}`} on ${engineWords(out.engine)}${demo}: ${ids.join(" ")}`);
if (studio) ctx.print(`It opens in ${absolute(ctx, studio)}`);
- if (ids.length) ctx.print(`Wait for ${ids.length === 1 ? "it" : "them"}: fuobe wait ${ids.join(" ")} Save ${ids.length === 1 ? "it" : "them"}: fuobe download ${ids.join(" ")} --out .`);
+ if (waiting.length) ctx.print(`Then ${waiting.join(", ")} start${waiting.length === 1 ? "s" : ""} by ${waiting.length === 1 ? "itself" : "themselves"} as the steps before finish. Follow it: ${progress} (or run it with --wait)`);
+ else if (ids.length) ctx.print(`Wait for ${ids.length === 1 ? "it" : "them"}: fuobe wait ${ids.join(" ")} Save ${ids.length === 1 ? "it" : "them"}: fuobe download ${ids.join(" ")} --out .`);
return all ? EXIT.ok : EXIT.failed;
}
diff --git a/docs/cli.md b/docs/cli.md
index d7c161a6..f64c74d4 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -229,6 +229,11 @@ fuobe skills export weekly-promo --out weekly-promo.zip # SKILL.md and its fil
`run` prints the ids to pass to `fuobe wait` or `fuobe download`. When a row didn't start (a studio
tool's run can refuse one row and start the rest), it says which by its line in your file and exits 1;
`--json` lists every run under `runs`, each with its `error` and, for `--rows`, its `line`.
+- A skill that spans studios (a dub, then captions, then a 9:16 cut) starts its first steps at once, and the
+ server starts each later step when the steps it takes from finish: `run` names the steps that wait and
+ where to follow the run (the skill's **Runs** in **Assist → Skills**). `--wait` and `--out` follow the
+ run until its last step is done, printing each change (`Dub · done → Captions · running → 9:16 cut ·
+ waiting`), then wait for and save every step's results; `--json` lists each run's `run` id and `waiting`.
- `export` saves the skill as a zip (`SKILL.md`, `recipe.json` and its other files); `--examples` keeps
the values it was made with, which are left out by default.
diff --git a/tests/cli-run.test.ts b/tests/cli-run.test.ts
index 02f26cb4..542184d1 100644
--- a/tests/cli-run.test.ts
+++ b/tests/cli-run.test.ts
@@ -30,6 +30,7 @@ let base = "";
let requireAuth = true;
let seen: Seen[] = [];
let polls = 0;
+let runPolls = 0;
const generation = (status: string, extra: Record<string, unknown> = {}) => ({
id: "gen1",
@@ -115,6 +116,13 @@ beforeAll(async () => {
// A server that names its output after a path, and a job that never finishes.
if (route === "GET /api/generations/evil") return send(200, generation("succeeded", { id: "../escaped", outputs: [{ url: "/api/files/outputs/2026-10-22/out1.png", kind: "image" }] }));
if (route === "GET /api/generations/slow") return send(200, generation("running", { id: "slow" }));
+ // The later step of a skill that spans studios (W7), started on the server once the dub finished.
+ if (route === "GET /api/generations/gen9") return send(200, generation("succeeded", { id: "gen9", kind: "video", outputs: [{ url: "/api/files/outputs/2026-10-22/cut.mp4", kind: "video" }] }));
+ if (route === "GET /api/assist/skills/weekly-promo/runs") {
+ runPolls++;
+ const done = runPolls >= 2;
+ return send(200, { items: [{ id: "r1", status: done ? "done" : "running", steps: [{ key: "dub", label: "Dub", status: "done", ids: ["gen1"] }, { key: "cut", label: "9:16 cut", status: done ? "done" : "waiting", ids: done ? ["gen9"] : [] }] }] });
+ }
if (route === "GET /api/generations") return send(200, { items: [generation("succeeded")] });
if (route === "GET /api/files/outputs/2026-10-22/out1.png") {
res.writeHead(200, { "content-type": "image/png" });
@@ -143,6 +151,8 @@ beforeAll(async () => {
const long = rows.filter((r) => r.name === "toolong");
if (long.length) return send(422, { error: `Fix the recipe first: ${long.map((r) => `Row ${r.line}: The clip is longer than 10 s`).join("; ")}`, problems: [] });
// A tool row that couldn't start while the others run.
+ // A skill that spans studios: a run whose later step waits for the dub (W7).
+ if (rows[0].name === "Spanish") return send(201, { engine: "cloud", demo: false, runs: [{ run: "r1", batchId: "r1", ids: ["gen1"], href: "/audio/translate?dub=d1", waiting: ["9:16 cut"] }] });
return send(201, { engine: b.engine ?? "cloud", demo: false, runs: rows.map((r, i) => (r.name === "nope" ? { ids: [], error: "The tool couldn't start" } : { batchId: `b${i}`, ids: i ? [`gen${i + 1}`] : ["gen1"], href: "/library" })) });
}
// A clip is priced by its length once it's uploaded: more than its stand-in.
@@ -471,6 +481,23 @@ describe("fuobe skills: a skill that runs by itself (W4)", () => {
expect(posts("run")[0].json).toEqual({ values: { product: "/api/files/uploads/2026-10-22/up1.png", name: "Lumen" }, engine: "cloud" });
});
+ it("a skill that spans studios says which steps wait, and --wait follows the run until its last step is done", async () => {
+ fs.writeFileSync(path.join(tmp, "lamp.png"), PNG);
+ const r = await run(["skills", "run", "weekly-promo", "-p", "product=lamp.png", "-p", "name=Spanish", "--yes"]);
+ expect(r.code).toBe(0);
+ expect(r.stdout).toContain(`It opens in ${base}/audio/translate?dub=d1`);
+ expect(r.stdout).toContain(`Then 9:16 cut starts by itself as the steps before finish. Follow it: ${base}/assist/skills?skill=weekly-promo (or run it with --wait)`);
+ polls = 0;
+ runPolls = 0;
+ const w = await run(["skills", "run", "weekly-promo", "-p", "product=lamp.png", "-p", "name=Spanish", "--yes", "--wait", "--json", "--interval", "0.2"]);
+ expect(w.code).toBe(0);
+ expect((JSON.parse(w.stdout) as { items: { id: string; status: string }[] }).items.map((g) => [g.id, g.status])).toEqual([
+ ["gen1", "succeeded"],
+ ["gen9", "succeeded"],
+ ]);
+ expect(runPolls).toBeGreaterThanOrEqual(2);
+ });
+
it("--rows: one run per row, -p fills the empty cells, files beside the table go up once, and --json skips the question", async () => {
const dir = path.join(tmp, "products");
fs.mkdirSync(dir, { recursive: true });