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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Skills: a Faceless episode's output can't feed a later step, its check is the plan, and a skill check asks no AI helper
Claudec4782e283602
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 091ba26c..51979edb 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -457,9 +457,9 @@ Round 5 part 1 (Work2Skill W1 and W2; plan in `docs/research/work2skill-7.md`).- **The format** (`src/lib/recipe.ts`, pure and browser-safe; `RecipeSchema`, `fuobeRecipe: 1`). Typed inputs (`params`: image, video, audio, text, number, choice or @element; at most 12) and either a graph of `generate` steps (each a `GenerationRequest` with `after` and `chain`, exactly as `createPipeline` takes them; at most 24) or one `tool` step (a gated Assist tool such as `dub_video` or `add_captions`, alone). A string that is exactly `"{{id}}"` takes the input with its type; `{{id}}` inside a longer string inserts its text. Optional `checks` per step (kind, count, aspect, seconds, sound, and a `look` sentence for a model that sees images) and `verified` per engine (the day the plan check, the dry run and the real test passed, and `catalog`, a hash of each step's model, operation, route and price table). Server-set fields (`SERVER_FIELDS`: `skill`, `demo`, `asked`, `chainFilled`…) are stripped from a recipe's requests. `recipeProblems` refuses at save time, never at run time: unknown or unused placeholders, duplicate ids and keys, a tool step that isn't alone, a graph `createPipeline` would refuse, a count that varies on a step others wait for, and inputs whose default, example or options don't fit their type.- **Fill and compile.** `fill` puts the values in (defaults for what isn't given). `compile` turns one run into the filled requests of one `createPipeline`, each stamped with `skill {name, run}` and the skill's title as `batchTitle` (a dry run adds `demo: true` and the hidden feature `skill-check`), or into one tool call. `checkValues` validates a row and `parseRows` a pasted or uploaded CSV / TSV (up to 50 rows), the same in the browser and on the server. `recipeMarkdown` writes the "Run it" section (inputs, steps, the equivalent `generate` or studio-tool call; at most 20,000 characters) that `load_skill`, the chat context and MCP prompts add to a recipe skill.- **Runs on the server** (`src/server/recipes.ts`; routes under `src/app/api/assist/skills/[name]/` with `src/server/recipe-routes.ts`). `compileRun` sends every filled request through the API's own `GenerationRequestSchema` and puts a dual-engine Original on the run's engine. Fuobe never moves a step to the other engine: `recipeEngines` is the engines every step allows under Settings → Engine mode. `estimateRecipe` prices one run or many with `planSteps` / `planFor`, as Assist's approval card does. `runRecipe` starts one `createPipeline` per row, or one `executeTool` call per row whose rows `stampRequests` (`generations.ts`) stamps afterwards. A run is refused with 409 until the plan check has passed on that engine, or while the skill is switched off; a CSV with a header and no rows is a 422.-- **Checks** (`verifyRecipe`, `POST …/verify`). `plan`: each step planned and priced as it would start; when every refusal is only a provider to connect (`onlyConnect`: messages that start "Connect"), the same run on the demo route stands in, with a note. `demo` (the default): the plan check, then a free dry run on the mock provider whatever Settings → Demo mode says (`request.demo`; at most 120 s per engine; small stand-in files for media inputs with no example), whose hidden rows go to the Trash; a Run doesn't wait for it. `real` (API only, needs `confirm: true`, holds the request up to 15 minutes): the examples on the user's keys, outputs checked by their structure (`probeMedia`) and the look judged only by a model that sees images (`llmSeesImages`; on the GPU only Ollama, never paid Claude). Tool steps get the plan check only. `needsRecheck` asks for a check again when a step's model was retired (`REPLACED_BY`) or switched off, or the plan hash changed. A check that finds the recipe changed while it ran refuses with 409 and keeps the edit. An uploaded `recipe.json` loses its `verified` dates, and the .zip download (`?format=zip`) never carries this install's checks; examples and source stay out unless `&examples=1`.+- **Checks** (`verifyRecipe`, `POST …/verify`). `plan`: each step planned and priced as it would start; when every refusal is only a provider to connect (`onlyConnect`: messages that start "Connect"), the same run on the demo route stands in, with a note. `demo` (the default): the plan check, then a free dry run on the mock provider whatever Settings → Demo mode says (`request.demo`; at most 120 s per engine; small stand-in files for media inputs with no example), whose hidden rows go to the Trash; a Run doesn't wait for it. `real` (API only, needs `confirm: true`, holds the request up to 15 minutes): the examples on the user's keys, outputs checked by their structure (`probeMedia`) and the look judged only by a model that sees images (`llmSeesImages`; on the GPU only Ollama, never paid Claude). Studio tool steps dry-run too, inside `runAsDemo` (W7: their studio records are deleted afterwards, and the AI helpers give their offline wording there); Faceless Studio's episode, which goes on in steps of its own, gets the plan check only. `needsRecheck` asks for a check again when a step's model was retired (`REPLACED_BY`) or switched off, or the plan hash changed. A check that finds the recipe changed while it ran refuses with 409 and keeps the edit. An uploaded `recipe.json` loses its `verified` dates, and the .zip download (`?format=zip`) never carries this install's checks; examples and source stay out unless `&examples=1`.- **Making a skill from results** (W2; `src/server/recipe-builder.ts`, `src/lib/recipe-builder.ts`, `src/components/skills/*`). `draftFromGenerations` walks the picked results back through `depends_on` and chain slots to the exact requests that made them. Results handed on by hand in the composer (Edit, Animate) are linked by matching file URLs (`linkByFile`); a stack that ran as one job per result becomes one step (`jobsOf`); an expansion comes back as the request it was asked as (`GenerationRequest.asked`; older ones are told apart by step labels and refused with `STEPS_REFUSAL`); a retired model moves to its replacement (`currentRequest`); and Translate & dub, Katana and Captions are lifted to their Assist tools (`dub_video`, `katana`, `add_captions`). Other studios that plan their own steps are refused by name (`STUDIOS`, `notSupported`). Every input starts Fixed. The review screen marks what varies (media, @elements, whole prompts, words picked in a prompt, and the takes, shape, length and quality), and `buildRecipe` and `skillBody` write the recipe and SKILL.md live. `POST /api/assist/skills/draft` returns the draft and the refusals; `/draft/check` runs the plan check and the dry run on an unsaved recipe (kept in memory by recipe hash, `draftKey`: 200 entries for 6 hours, so a restart loses a passed dry run); `/draft/name` is an optional naming pass by Claude or Ollama; `/draft/save` checks the plan again and saves, with 409 for a taken name and 422 for a failing plan. "draft" is a reserved skill name; a user skill already called that would have its GET, PATCH and DELETE routes shadowed by the POST-only draft route (read from the routing, not tested, and nothing renames it). A skill made from demo results says so in its Run form (`DEMO_NOTE`, `source.demo`) until a real test passes.-- **Skills that span studios** (W7; `src/server/skill-runs.ts`, `src/server/demo-scope.ts`). Recipe version 2 (`fuobeRecipe: 2`; version 1 files still load and run as before) puts `{{steps.<key>.output}}` in a step's input: the whole field takes that earlier step's first output of the kind the field takes (`fieldKind`; a studio tool's output kind is `TOOL_MAKES`), and tool steps may sit anywhere in the order. `recipeProblems` checks that each reference points at an earlier step of a kind that fits, that a step's output fills a whole field, that a generate step doesn't wait (`after`) for a studio step, that a dub feeding a later step dubs in one go (`review: false`), and that no parts wait for each other. Such a recipe compiles to `staged` parts (`recipeParts`): each graph of generate steps joined by `after` is one `createPipeline`, each tool step one `executeTool` call. `runRecipe` starts a `skill_runs` row per run (`startSkillRun`) and every part whose inputs exist; `advanceSkillRun` settles running parts, fails the parts that wait for a failure ("Didn't start: Dub failed", the run saying which step failed and why), and starts each waiting part with its references filled from the finished steps (`fillRefs`). A 10 s sweep started with the generation runner (`ensureSkillRunSweep`, `src/instrumentation.ts`) advances every running run, so a run carries on after a restart. `createPipeline`'s `existing` option is not used: every later step waits for the sweep. A run's result names its `run` and the steps that `wait`; `run_skill` tells the agent so, the CLI's `--wait` follows `GET /api/assist/skills/[name]/runs`, and the skill's dialog shows each run as "Dub · done → Captions · running → 9:16 cut · waiting" with "Open in <Studio>" (`components/assist/skill-runs.tsx`). Plans price each part with stand-ins for references (a studio that keeps a clip's length is priced on the clip it takes). Studio dry runs: inside `runAsDemo` (an `AsyncLocalStorage` scope) `chooseRoute` returns the demo route and `createGenerations` stamps `request.demo`, so a studio module runs as a free demo with no change to its code; the check (also for a single tool step now) then trashes what it made and deletes the studio records it opened (a dub, a Layers project, a Shorts session, a Faceless episode, Katana jobs naming its results). Save as skill (`draftFromThread`) writes a chat's result handed into or out of a studio call as a step reference (`linkStudios`) instead of refusing it; the Library builder still makes one studio step per skill. The routes are the owner's: guests and accounts are refused by the proxy like the rest of Assist.+- **Skills that span studios** (W7; `src/server/skill-runs.ts`, `src/server/demo-scope.ts`). Recipe version 2 (`fuobeRecipe: 2`; version 1 files still load and run as before) puts `{{steps.<key>.output}}` in a step's input: the whole field takes that earlier step's first output of the kind the field takes (`fieldKind`; a studio tool's output kind is `TOOL_MAKES`), and tool steps may sit anywhere in the order. `recipeProblems` checks that each reference points at an earlier step of a kind that fits, that a step's output fills a whole field, that a generate step doesn't wait (`after`) for a studio step, that a dub feeding a later step dubs in one go (`review: false`), that no step takes a Faceless episode's output (`OUTPUT_NOT_HANDED_ON`: its result is only the first stills), and that no parts wait for each other. Such a recipe compiles to `staged` parts (`recipeParts`): each graph of generate steps joined by `after` is one `createPipeline`, each tool step one `executeTool` call. `runRecipe` starts a `skill_runs` row per run (`startSkillRun`) and every part whose inputs exist; `advanceSkillRun` settles running parts, fails the parts that wait for a failure ("Didn't start: Dub failed", the run saying which step failed and why), and starts each waiting part with its references filled from the finished steps (`fillRefs`). A 10 s sweep started with the generation runner (`ensureSkillRunSweep`, `src/instrumentation.ts`) advances every running run, so a run carries on after a restart. `createPipeline`'s `existing` option is not used: every later step waits for the sweep. A run's result names its `run` and the steps that `wait`; `run_skill` tells the agent so, the CLI's `--wait` follows `GET /api/assist/skills/[name]/runs?ids=…` (its own runs, however many rows), and the skill's dialog shows each run as "Dub · done → Captions · running → 9:16 cut · waiting" with "Open in <Studio>" (`components/assist/skill-runs.tsx`). Plans price each part with stand-ins for references (a studio that keeps a clip's length is priced on the clip it takes). Studio dry runs: inside `runAsDemo` (an `AsyncLocalStorage` scope) `chooseRoute` returns the demo route and `createGenerations` stamps `request.demo`, so a studio module runs as a free demo with no change to its code; the check (also for a single tool step now) then trashes what it made and deletes the studio records it opened (a dub, a Layers project, a Shorts session, Katana jobs naming its results); the timers a dry run may start first (`outsideRuns`, the sweep) leave its scope (`outsideDemo`). Save as skill (`draftFromThread`) writes a chat's result handed into or out of a studio call as a step reference (`linkStudios`) instead of refusing it; the Library builder still makes one studio step per skill. The routes are the owner's: guests and accounts are refused by the proxy like the rest of Assist.- **UI.** A recipe skill's card on the Skills page shows "Runs by itself", and its dialog shows where it was checked or why it needs a re-check (`skills-view.tsx`). The Run form (`run-skill-dialog.tsx`, `/assist/skills?run=<name>`) builds its fields from the inputs, offers only engines whose check passed, prices live, lists the steps (`plan-jobs.tsx`) and has a Many tab for CSV rows. ⌘K lists "Run <skill>…" (`skillEntries` in `src/lib/command-search.ts`). "Make a skill from this…" is in every finished result's ⋯ menu and "Make a skill" in the Library's selection bar; `SkillBuilderProvider` wraps `StudioChrome` (`app-sidebar.tsx`), so the viewer opened from ⌘K or a job notification has it too, and loads the review screen on first open.- **Checked** in demo mode only: unit and API tests (`recipe`, `recipes`, `recipe-builder`) with Demo mode off and no keys, and the browser checks `skills-run` and `skills-builder`. No skill has run with a paid key or on a GPU, the naming pass and look judging have not met a live Claude or Ollama vision model, the three lifts are tested as drafts only, and the real check level has no button. The text agents read (the "Run it" section, a built skill's SKILL.md) mentions a `run_skill` MCP tool that comes with W3 and doesn't exist yet.diff --git a/skills/README.md b/skills/README.mdindex d473e883..179c8c9e 100644--- a/skills/README.md+++ b/skills/README.md@@ -56,7 +56,8 @@ AI. The format is in `src/lib/recipe.ts` (and `docs/research/work2skill-7.md`):takes an earlier step's first result of the kind the field takes, so a studio step can feed latersteps and the other way round ("dub, then captions, then a 9:16 cut"), with tool steps anywhere inthe order. Each step starts by itself when the steps it takes from are done; the skill's dialog shows- the run's progress. A dub that feeds a later step dubs in one go (`"review": false`).+ the run's progress. A dub that feeds a later step dubs in one go (`"review": false`). A Faceless+ episode (`faceless_episode`) finishes in Faceless Studio's own steps, so no later step takes its output.- Optional `checks` per step (what it makes, how many, the shape, the length, sound, a sentence aboutthe look) and `source` (where the recipe came from).diff --git a/src/lib/recipe.ts b/src/lib/recipe.tsindex 9a55876c..eeecb88e 100644--- a/src/lib/recipe.ts+++ b/src/lib/recipe.ts@@ -247,6 +247,14 @@ export function stepRefs(v: unknown, path: (string | number)[] = [], out: StepRereturn out;}+/**+ * Studio tools whose result names only a first stage, so no later step can take what they finally make: Faceless+ * Studio's result is the episode's stills, and the episode is animated and mixed afterwards by Faceless's own steps.+ */+export const OUTPUT_NOT_HANDED_ON: Record<string, string> = {+ faceless_episode: "Faceless Studio finishes an episode in steps of its own after its first pictures",+};+/** What each studio tool makes, for a later step that takes its output (its first output of the field's kind). */export const TOOL_MAKES: Record<string, MediaKind> = {dub_video: "video",@@ -256,7 +264,6 @@ export const TOOL_MAKES: Record<string, MediaKind> = {remove_person: "video",blockout_film: "video",fly_around: "video",- faceless_episode: "video",katana: "video",split_layers: "image",create_ads: "image",@@ -332,6 +339,10 @@ function refProblems(recipe: Recipe, makes?: (s: GenerateStep) => MediaKind | uncontinue;}const from = recipe.steps[j];+ if (from.kind === "tool" && OUTPUT_NOT_HANDED_ON[from.tool]) {+ out.push(`Step “${s.key}” takes the output of “${r.key}”, which no step can take yet: ${OUTPUT_NOT_HANDED_ON[from.tool]}`);+ continue;+ }const wants = fieldKind(r.path, s.kind === "tool" ? s.tool : undefined);const made = from.kind === "tool" ? TOOL_MAKES[from.tool] : (recipe.checks?.[from.key]?.kind ?? makes?.(from));if (wants && made && made !== wants) out.push(`Step “${s.key}” takes ${wants === "image" ? "an image" : `a${wants === "audio" ? "n" : ""} ${wants}`} from “${r.key}”, which makes ${made === "image" ? "an image" : made === "audio" ? "audio" : `a ${made}`}`);diff --git a/src/server/demo-scope.ts b/src/server/demo-scope.tsindex fd34b07c..fa5d53d6 100644--- a/src/server/demo-scope.ts+++ b/src/server/demo-scope.ts@@ -18,3 +18,11 @@ export function runAsDemo<T>(fn: () => T): T {export function inDemoScope(): boolean {return scope.getStore()?.demo === true;}++/**+ * Run `fn` outside runAsDemo: for timers a dry run may be first to start (the generation runner, the skill-run sweep),+ * which would otherwise carry the scope into every later tick and make every run on the install a demo.+ */+export function outsideDemo<T>(fn: () => T): T {+ return scope.exit(fn);+}diff --git a/src/server/enhance.ts b/src/server/enhance.tsindex e3e2107f..8ef96f0c 100644--- a/src/server/enhance.ts+++ b/src/server/enhance.ts@@ -5,6 +5,7 @@ import { writeCaption } from "@/lib/ideogram-caption";import { normalizeLyrics } from "@/lib/lyrics";import { activeLocal, aiHelper, chatLocal, type JsonSpec } from "./llm";import { engineMode, getSetting } from "./settings";+import { inDemoScope } from "./demo-scope";import { tenant } from "./tenant";/**@@ -115,6 +116,8 @@ export async function llmText(system: string, user: string, images?: LlmImage[],export async function llmText(system: string, user: string, a: LlmImage[] | LlmTextOptions = [], b: LlmTextOptions = {}): Promise<string | null> {const images: LlmImage[] = Array.isArray(a) ? a : [];const opts: LlmTextOptions = Array.isArray(a) ? b : a;+ // A skill's free dry run (runAsDemo) never asks a paid or local model: the offline wording stands in.+ if (inDemoScope()) return null;// The open engine never calls a paid API: a local model, unless the AI helper is off.const backend = opts.ollamaOnly && llmTextBackend() === "claude" ? "ollama" : llmTextBackend();if (backend === "claude") return viaClaude(system, user, images).catch(() => null);diff --git a/src/server/faceless.ts b/src/server/faceless.tsindex 83fe3302..ac853497 100644--- a/src/server/faceless.ts+++ b/src/server/faceless.ts@@ -92,6 +92,7 @@ import type { JsonSpec } from "./llm";import { llmBackends, probeLocal } from "./providers/llm";import { fetchRemote } from "./remote-fetch";import { engineMode, getSetting } from "./settings";+import { inDemoScope } from "./demo-scope";import { fileUrl, saveFile } from "./storage";import { firstOn, offeredModel } from "./model-access";@@ -222,7 +223,7 @@ const TOPICS_TIMEOUT_MS = 25_000;/** One answer from the engine's text model, or null (no LLM, AI helper off, demo mode on, or it failed: `onError` hears why). */export async function askLlm(engine: Engine, system: string, user: string, o: AskOptions = {}): Promise<string | null> {- if (getSetting("demoMode") === "on") return null;+ if (getSetting("demoMode") === "on" || inDemoScope()) return null;// A text model switched off in Settings → Models & licences gives way to the offline wording, like no LLM at all.const found = getModel(ENGINE_MODELS[engine].write);const model = found && offeredModel(found);diff --git a/src/server/generations.ts b/src/server/generations.tsindex 00251f9b..732d9511 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -98,7 +98,7 @@ import { accountSend } from "./account-send";import { stamped, stampOf, withRunStamp } from "./run-stamp";import { placeInLine, poolWaitMs, runOnPool } from "./hosted";import { sweepBilling } from "./billing-outbox";-import { inDemoScope } from "./demo-scope";+import { inDemoScope, outsideDemo } from "./demo-scope";import { moderationConfigured } from "./moderation";import { holdForCheck, sweepOutputChecks } from "./output-checks";import { absolutePath, adoptFile, contentTypeFor, deleteAsset, localHead, readRef, saveFile, scratchDir } from "./storage";@@ -1986,12 +1986,12 @@ declare global {}/**- * Run `fn` as the owner's background work: outside any account's run (its tenant, its ComfyUI, the open-engine settings+ * Run `fn` as the owner's background work: outside a skill check's demo scope and any account's run (its tenant, its ComfyUI, the open-engine settings* it runs with). Timers started inside inherit where they were started, so the runner, often first started by a run, is* started this way: every tick then polls each row in that row's own context.*/export function outsideRuns<T>(fn: () => T): T {- return outsideTenant(() => outsideOwnGpu(() => withoutCandidates(fn)));+ return outsideDemo(() => outsideTenant(() => outsideOwnGpu(() => withoutCandidates(fn))));}/**diff --git a/src/server/recipe-builder.ts b/src/server/recipe-builder.tsindex 19c27fb6..98a8f61e 100644--- a/src/server/recipe-builder.ts+++ b/src/server/recipe-builder.ts@@ -7,7 +7,7 @@ import { dubLanguageFor } from "@/lib/assist-studios";import { isHelperFeature } from "@/lib/library";import { probeMedia } from "@/lib/media-probe";import { videoPoster } from "@/lib/output-actions";-import { isMediaRef, leafKeys, RECIPE_LIMITS, stepRef, stepRefs, today, type ParamType, type Recipe, type RecipeCheck, type RecipeStep } from "@/lib/recipe";+import { isMediaRef, leafKeys, OUTPUT_NOT_HANDED_ON, RECIPE_LIMITS, stepRef, stepRefs, today, type ParamType, type Recipe, type RecipeCheck, type RecipeStep } from "@/lib/recipe";import {DEMO_NOTE,isExpansionLabel,@@ -396,6 +396,8 @@ function linkStudios(walk: Walk): boolean {if (typeof v === "string") {const src = made.get(v);if (!src || src === n || src.gen.createdAt > n.gen.createdAt || (!src.tool && !n.tool)) return v;+ // A studio whose result is only its first stage (Faceless's stills) is kept as the file it handed on.+ if (src.step.kind === "tool" && OUTPUT_NOT_HANDED_ON[src.step.tool]) return v;linked = true;return stepRef(src.key);}diff --git a/src/server/recipes.ts b/src/server/recipes.tsindex d6ff052c..ca347421 100644--- a/src/server/recipes.ts+++ b/src/server/recipes.ts@@ -23,6 +23,7 @@ import {RECIPE_LIMITS,recipeProblems,RecipeSchema,+ OUTPUT_NOT_HANDED_ON,SKILL_CHECK_FEATURE,today,verifiedLine,@@ -739,11 +740,19 @@ async function finishRun(id: string, ms: number) {* inside runAsDemo, unchanged), then what it made goes to the Trash and the studio records it opened are deleted.*/async function studioDryRun(skill: { name: string; title: string }, recipe: Recipe, c: Extract<Compiled, { kind: "tool" | "staged" }>, engine: Engine, values: RecipeValues): Promise<NonNullable<EngineCheck["dryRun"]>> {- const run = await startSkillRun(skill, recipe, partsOf(c), engine, values, { check: true });+ // A studio that goes on in steps of its own after its result (Faceless) would outlive the check, so its plan is its+ // check, as in W1; no step takes its output (recipeProblems), so the rest dry-runs without it.+ const all = partsOf(c);+ const parts = all.filter((p) => !(p.kind === "tool" && OUTPUT_NOT_HANDED_ON[p.tool]));+ const left = all.filter((p) => !parts.includes(p)).map((p) => (p.kind === "tool" ? p.tool : ""));+ const skipped = left.length ? `A studio step (${left.join(", ")}) is checked by its plan only` : undefined;+ if (!parts.length) return { ok: true, problems: [], skipped };+ const kept = new Set(parts.flatMap((p) => (p.kind === "tool" ? [p.key] : p.steps.map((s) => s.key))));+ const run = await startSkillRun(skill, recipe, parts, engine, values, { check: true });try {const v = await finishRun(run.id, DRY_RUN_MS);const problems: string[] = [];- for (const s of v.steps) {+ for (const s of v.steps.filter((x) => kept.has(x.key))) {if (s.status === "failed") {problems.push(`Step “${s.key}” ${s.error?.startsWith("Didn't start") ? `didn't start (${s.error.replace(/^Didn't start: /, "")})` : `failed${s.error ? `: ${s.error}` : ""}`}`);continue;@@ -753,7 +762,7 @@ async function studioDryRun(skill: { name: string; title: string }, recipe: Reciconst outputs = s.ids.flatMap((id) => getGeneration(id, { includeDeleted: true })?.outputs ?? []);if (!outputs.some((o) => o.kind === kind)) problems.push(`Step “${s.key}” made no ${kind}`);}- return { ok: !problems.length, problems };+ return { ok: !problems.length, problems, ...(skipped && { skipped }) };} finally {await discardSkillRun(run.id);}diff --git a/src/server/restore.ts b/src/server/restore.tsindex f05acb6a..cb968471 100644--- a/src/server/restore.ts+++ b/src/server/restore.ts@@ -29,6 +29,7 @@ import { gatedFileReady, gatedHint } from "./loras";import { isOffered, offeredModel } from "./model-access";import { localLabel, localWhat, probeLocal } from "./llm";import { engineMode, getSetting } from "./settings";+import { inDemoScope } from "./demo-scope";import { probeSource, ShortsError } from "./shorts";import { tenant } from "./tenant";@@ -131,7 +132,7 @@ export interface PromptAnswer {export async function writeRestorePrompt(body: z.infer<typeof PromptSchema>): Promise<PromptAnswer> {mustMatchMode(body.engine);const offline = (why: string): PromptAnswer => ({ ...offlineRestorePrompt(body.hint), by: "offline", why });- if (getSetting("demoMode") === "on") return offline("demo mode");+ if (getSetting("demoMode") === "on" || inDemoScope()) return offline("demo mode");const textModel = getModel(body.engine === "open" ? "oss-text-llm" : "text-llm");if (!textModel || !offeredModel(textModel)) return offline(`the text model is switched off in ${ACCESS_PLACE}`);const backend = llmTextBackend();diff --git a/tests/skill-runs.test.ts b/tests/skill-runs.test.tsindex 46fe506b..c02af0ec 100644--- a/tests/skill-runs.test.ts+++ b/tests/skill-runs.test.ts@@ -20,7 +20,8 @@ const gens = await import("@/server/generations");const { db } = await import("@/server/db");const { saveFile } = await import("@/server/storage");const { executeTool } = await import("@/server/assist/tools");-const { inDemoScope, runAsDemo } = await import("@/server/demo-scope");+const { inDemoScope, outsideDemo, runAsDemo } = await import("@/server/demo-scope");+const { llmText } = await import("@/server/enhance");const lib = await import("@/lib/recipe");const runsRoute = await import("@/app/api/assist/skills/[name]/runs/route");@@ -98,6 +99,19 @@ describe("the recipe format, version 2", () => {expect(lib.recipeProblems(v1).join("\n")).toMatch(/needs "fuobeRecipe": 2/);});+ it("refuses a step that takes a Faceless episode's output: its result is only the first stills", () => {+ const scenes = Array.from({ length: 3 }, (_, i) => ({ narration: `Line ${i}`, visual: `Scene ${i}` }));+ const r = lib.RecipeSchema.parse({+ fuobeRecipe: 2,+ params: [],+ steps: [+ { key: "ep", kind: "tool", tool: "faceless_episode", input: { scenes, style: "flat 2D" } },+ { key: "captions", kind: "tool", tool: "add_captions", input: { video: "{{steps.ep.output}}" } },+ ],+ });+ expect(lib.recipeProblems(r).join("\n")).toMatch(/“captions” takes the output of “ep”, which no step can take yet: Faceless Studio finishes an episode/);+ });+it("compiles to parts, and fills a reference with the step's first output of the field's kind", () => {const r = lib.RecipeSchema.parse(spanishShort());const c = lib.compile(r, { video: clip, lang: "Spanish" }, { skill: "s", run: "r", title: "Spanish short" });@@ -193,6 +207,40 @@ describe("a skill that spans studios, in demo mode", () => {});});+describe("following runs", () => {+ it("the runs route lists a skill's newest 8, or exactly the runs asked for by id however many", async () => {+ makeSkill("many-runs", spanishShort());+ const state = JSON.stringify({ engine: "cloud", title: "Spanish short", labels: [], parts: [] });+ const add = db().prepare("INSERT INTO skill_runs (id, skill, status, values_json, state_json, created_at, updated_at) VALUES (?, ?, 'done', '{}', ?, ?, ?)");+ const ids = Array.from({ length: 12 }, (_, i) => `many${i}`);+ ids.forEach((id, i) => add.run(id, "many-runs", state, 1000 + i, 1000 + i));+ add.run("other0", "spanish-short", state, 5000, 5000);+ const get = async (q = "") => {+ const res = await runsRoute.GET(new Request(`http://x/api/assist/skills/many-runs/runs${q}`), { params: Promise.resolve({ name: "many-runs" }) });+ return { status: res.status, items: ((await res.json()) as { items?: { id: string }[] }).items?.map((r) => r.id) };+ };+ expect((await get()).items).toEqual(ids.slice(4).reverse());+ // The CLI following a 10-row table asks for its own runs: the oldest of them too, and never another skill's.+ const asked = [...ids.slice(0, 10), "other0"];+ expect((await get(`?ids=${asked.join(",")}`)).items?.sort()).toEqual(ids.slice(0, 10).sort());+ expect((await get(`?ids=${Array.from({ length: 51 }, (_, i) => `x${i}`).join(",")}`)).status).toBe(400);+ });+});++describe("the demo scope", () => {+ it("is left by the timers a dry run may start first, and asks no LLM inside it", async () => {+ await runAsDemo(async () => {+ expect(inDemoScope()).toBe(true);+ expect(outsideDemo(() => inDemoScope())).toBe(false);+ expect(gens.outsideRuns(() => inDemoScope())).toBe(false);+ // The skill-run sweep, first started here, ticks outside the scope.+ const seen = await new Promise<boolean>((resolve) => outsideDemo(() => setTimeout(() => resolve(inDemoScope()), 1)));+ expect(seen).toBe(false);+ expect(await llmText("system", "user")).toBeNull();+ });+ });+});+describe("the studio dry run", () => {it("runs a studio module as a demo with no change to its code", async () => {expect(inDemoScope()).toBe(false);@@ -230,4 +278,14 @@ describe("the studio dry run", () => {setSetting("demoMode", "auto");}});++ it("checks a Faceless episode by its plan only: it goes on in Faceless Studio's own steps after its result", async () => {+ const scenes = Array.from({ length: 3 }, (_, i) => ({ narration: `Line ${i}`, visual: `Scene ${i}` }));+ makeSkill("faceless-check", { fuobeRecipe: 2, params: [], steps: [{ key: "ep", kind: "tool", tool: "faceless_episode", input: { scenes, style: "flat 2D" } }] }, "Episode");+ const episodes = count("faceless_episodes");+ const check = await recipes.verifyRecipe("faceless-check", "demo", "cloud");+ expect(check.engines[0].plan.ok).toBe(true);+ expect(check.engines[0].dryRun).toEqual({ ok: true, problems: [], skipped: "A studio step (faceless_episode) is checked by its plan only" });+ expect(count("faceless_episodes")).toBe(episodes);+ });});