3D engine that AI agents drive
Raise render limits and bring the light bake to recipes
Nguyen Xuan An9f7296019bac
diff --git a/bench/reference/frame-time.mjs b/bench/reference/frame-time.mjsnew file mode 100644index 00000000..104dc988--- /dev/null+++ b/bench/reference/frame-time.mjs@@ -0,0 +1,32 @@+// Frame time of a reference scene with and without the light bake: node bench/reference/frame-time.mjs [scene-id] [gpu|cpu]+import { constants, setPriority } from 'node:os';+import { chromium } from 'playwright';+import { createServer } from 'vite';++const CHROME = process.env.CHROME_PATH ?? 'C:/Program Files/Google/Chrome/Application/chrome.exe';+const PAGE_LOAD_TIMEOUT = 180000;+const [sceneId = 'lit-interior', backend = 'gpu'] = process.argv.slice(2);+const BACKEND_ARGUMENTS = {+ gpu: ['--enable-webgl', '--ignore-gpu-blocklist', '--disable-renderer-backgrounding'],+ cpu: ['--enable-webgl', '--ignore-gpu-blocklist', '--use-angle=swiftshader', '--enable-unsafe-swiftshader'],+};++setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);+const server = await createServer({ server: { host: '127.0.0.1', port: 0 }, logLevel: 'silent' });+await server.listen();+const serverUrl = `http://127.0.0.1:${server.httpServer.address().port}`;+const browser = await chromium.launch({ executablePath: CHROME, headless: true, args: BACKEND_ARGUMENTS[backend] });+try {+ const page = await browser.newPage({ viewport: { width: 960, height: 540 } });+ await page.goto(`${serverUrl}/bench/reference/harness.html`, { timeout: PAGE_LOAD_TIMEOUT });+ await page.waitForFunction(() => window.measureReferenceFrameTime, null, { timeout: PAGE_LOAD_TIMEOUT });+ const results = [];+ // Alternate the order so a drifting machine load does not favor one side.+ for (const bake of [false, true, false, true]) {+ results.push(await page.evaluate(([id, shouldBake]) => window.measureReferenceFrameTime(id, { bake: shouldBake }), [sceneId, bake]));+ }+ console.log(JSON.stringify({ sceneId, backend, results }, null, 1));+} finally {+ await browser.close();+ await server.close();+}diff --git a/bench/reference/harness.js b/bench/reference/harness.jsindex 4968127f..159d581c 100644--- a/bench/reference/harness.js+++ b/bench/reference/harness.js@@ -103,5 +103,37 @@ async function renderReferenceScene(id, { describe, ambientOcclusion = 0, ambienreturn result;}+// Frame time of one scene with and without the light bake: a bake only adds an emissive map to each part, so this shows what it costs to draw.+async function measureReferenceFrameTime(id, { bake, warmupFrames = 20, measuredFrames = 200 }) {+ const scene = await REFERENCE_SCENES[id]();+ const baked = bake ? await bakeScene(scene, {}) : null;+ const renderer = new Renderer67(document.querySelector('canvas'), baked ? baked.parts : scene.parts, {+ ground: false, hdr: true, depth: true, samples: 4, pixelRatio: 1, memoryBudgetMiB: 1024, world: true,+ environment: scene.environment, shadowBounds: scene.shadow,+ });+ renderer.resize();+ const frame = { ...scene.camera, environment: scene.environment, time: 0, exposure: 1, effects: { ambientOcclusion: 0, ambientOcclusionRadius: 0.5 } };+ // finish() returns before a hardware GPU is done, so reading one pixel back is what waits for the frame.+ const pixel = new Uint8Array(4);+ const finishDrawing = () => renderer.context.readPixels(0, 0, 1, 1, renderer.context.RGBA, renderer.context.UNSIGNED_BYTE, pixel);+ for (let index = 0; index < warmupFrames; index++) {+ renderer.render(frame);+ finishDrawing();+ }+ const frameMilliseconds = [];+ for (let index = 0; index < measuredFrames; index++) {+ const started = performance.now();+ renderer.render(frame);+ finishDrawing();+ frameMilliseconds.push(performance.now() - started);+ }+ renderer.dispose();+ frameMilliseconds.sort((first, second) => first - second);+ const total = frameMilliseconds.reduce((sum, value) => sum + value, 0);+ return { baked: Boolean(bake), frames: measuredFrames, meanMilliseconds: total / measuredFrames,+ medianMilliseconds: frameMilliseconds[Math.floor(measuredFrames / 2)], p95Milliseconds: frameMilliseconds[Math.floor(measuredFrames * 0.95)] };+}++window.measureReferenceFrameTime = measureReferenceFrameTime;window.renderReferenceScene = renderReferenceScene;window.referenceSceneIds = Object.keys(REFERENCE_SCENES);diff --git a/bench/size/budgets.json b/bench/size/budgets.jsonindex c1facaf7..be2ff062 100644--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@ -31,15 +31,15 @@"entry:light-bake": 25400,"entry:texture-set": 900,"entry:agent-scene": 63700,- "entry:agent-scene+lazy": 206300,+ "entry:agent-scene+lazy": 211300,"entry:agent-asset": 94600,- "entry:agent-asset+lazy": 216800,+ "entry:agent-asset+lazy": 221800,"entry:hdri": 3300,"entry:camera-effects": 8600,"entry:render-passes": 1700,"scene:lit-box": 60200,"scene:gltf-box": 79700,"scene:agent-scene": 93500,- "scene:agent-scene+lazy": 236000+ "scene:agent-scene+lazy": 240600}}diff --git a/bench/tool-cost-budgets.json b/bench/tool-cost-budgets.jsonindex 3ac2b7fd..7ac742b2 100644--- a/bench/tool-cost-budgets.json+++ b/bench/tool-cost-budgets.json@@ -1,16 +1,16 @@{- "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool); raised by 650 total and 80 for scene_apply for clip layers, bone masks and retargeting through MCP; raised by 20 for scene_create and 20 for the scene_capabilities result after merging the expression language with the material graph; was 373388 schema bytes before shared IDs and recipe references; trimmed after the render-passes merge: material graph, depth of field, motion blur and passes details moved to scene_capabilities, budgets set to the measured value plus 0.5% (total 188267, scene_capabilities result 5167); raised by 95 for scene_apply and 690 for the scene_capabilities result for node relations; curve and text geometry entries shortened to a pointer at scene_capabilities curveText, budgets set to the measured value plus 0.5% (total 189468, scene_capabilities result 6399); then six modifier ops (weld, triangulate, edge_split, smooth, simple_deform, cast) added as one compact schema entry with details in scene_capabilities meshModifiers, entry and mesh_stack description shortened: total 190382 (budget unchanged at 190420), mesh_edit 34216 (budget 34220), scene_capabilities result 7042 (budget 7050); mesh_stack 11682 (budget 11690); after merging imported mesh topology with the modifier ops: raised the total to 190480 (measured 190471), mesh_edit to 34300 (measured 34293) and the scene_capabilities result to 7520 (measured 7512) for imported mesh edits; then cloth (recipe cloth, set-cloth, grid geometry) added with the total unchanged at 190480 (measured 189159): physics descriptions shortened and set-physics now takes the same record reference as set-motion, scene_create raised to 62150 and scene_apply lowered to 44130, scene_capabilities result raised to 8190 (measured 8176) for the cloth details; then particles and hair (recipe `particles`, set-particles) added with the total unchanged at 190480 (measured 189642, scene_create raised to 62350 and scene_apply to 44370 for the recipe particles reference and set-particles): the section is one record reference described in scene_capabilities, so the scene_capabilities result rose to 9570 (measured 9523) for the particle and hair fields; after merging the film timeline (recipe timeline, set-timeline) with particles: total 190719 (budget 190730), scene_create 62464, scene_apply 44620, scene_capabilities result 9902",+ "measured": "2026-11-01: recipe bake and set-bake added as record references with details in scene_capabilities bake (result 10613, budget 10670); total unchanged at 190730 (measured 189633) by shortening the face selection rule description, so scene_create and scene_apply were raised and mesh_edit and mesh_stack lowered. Earlier: 2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool); raised by 650 total and 80 for scene_apply for clip layers, bone masks and retargeting through MCP; raised by 20 for scene_create and 20 for the scene_capabilities result after merging the expression language with the material graph; was 373388 schema bytes before shared IDs and recipe references; trimmed after the render-passes merge: material graph, depth of field, motion blur and passes details moved to scene_capabilities, budgets set to the measured value plus 0.5% (total 188267, scene_capabilities result 5167); raised by 95 for scene_apply and 690 for the scene_capabilities result for node relations; curve and text geometry entries shortened to a pointer at scene_capabilities curveText, budgets set to the measured value plus 0.5% (total 189468, scene_capabilities result 6399); then six modifier ops (weld, triangulate, edge_split, smooth, simple_deform, cast) added as one compact schema entry with details in scene_capabilities meshModifiers, entry and mesh_stack description shortened: total 190382 (budget unchanged at 190420), mesh_edit 34216 (budget 34220), scene_capabilities result 7042 (budget 7050); mesh_stack 11682 (budget 11690); after merging imported mesh topology with the modifier ops: raised the total to 190480 (measured 190471), mesh_edit to 34300 (measured 34293) and the scene_capabilities result to 7520 (measured 7512) for imported mesh edits; then cloth (recipe cloth, set-cloth, grid geometry) added with the total unchanged at 190480 (measured 189159): physics descriptions shortened and set-physics now takes the same record reference as set-motion, scene_create raised to 62150 and scene_apply lowered to 44130, scene_capabilities result raised to 8190 (measured 8176) for the cloth details; then particles and hair (recipe `particles`, set-particles) added with the total unchanged at 190480 (measured 189642, scene_create raised to 62350 and scene_apply to 44370 for the recipe particles reference and set-particles): the section is one record reference described in scene_capabilities, so the scene_capabilities result rose to 9570 (measured 9523) for the particle and hair fields; after merging the film timeline (recipe timeline, set-timeline) with particles: total 190719 (budget 190730), scene_create 62464, scene_apply 44620, scene_capabilities result 9902","schemaTotalBytes": 190730,"schemaToolBytes": {- "scene_create": 62480,- "scene_apply": 44640,- "mesh_edit": 34300,+ "scene_create": 62700,+ "scene_apply": 44880,+ "mesh_edit": 33400,"scene_create_asset": 19310,- "mesh_stack": 11690+ "mesh_stack": 11540},"schemaOtherToolBytes": 4000,"resultBytes": {- "scene_capabilities": 9910,+ "scene_capabilities": 10670,"scene_create": 1400,"scene_inspect": 1400,"mesh_inspect": 1200,diff --git a/bin/67js-mcp.mjs b/bin/67js-mcp.mjsindex b413fbf1..bb48f57c 100644--- a/bin/67js-mcp.mjs+++ b/bin/67js-mcp.mjs@@ -7,7 +7,7 @@ if (argumentsValue.length === 1 && argumentsValue[0] === '--version') {console.log(packageMetadata.version);} else if (argumentsValue.length === 1 && argumentsValue[0] === '--help') {console.log(`67js-mcp ${packageMetadata.version}-Usage: 67js-mcp [--backend gpu|cpu] [--memory 32..256]+Usage: 67js-mcp [--backend gpu|cpu] [--memory 32..384][--browser <Chrome/Chromium executable>] [--assets <absolute GLB directory>][--jobs <absolute private output directory>] [--ffmpeg <absolute executable>]diff --git a/docs/agent-render-jobs.md b/docs/agent-render-jobs.mdindex dca5721a..fbf77114 100644--- a/docs/agent-render-jobs.md+++ b/docs/agent-render-jobs.md@@ -253,15 +253,16 @@ This conservative repair step prevents two recovery processes from deleting a ne| Retained records | 32 || Total store bytes | 512 MiB || Combined output bytes per job | 128 MiB |-| PNG artifact bytes | 1 MiB each |+| PNG artifact bytes | 12 MiB each (a 1920x1080 frame) || Snapshot JSON | 1 MiB || Asset bytes | 16 MiB |-| Dimensions | 64 to 1024 pixels each |+| Dimensions | 64 to 1920 pixels each, at most 1920x1080 pixels in all (1080x1920 fits) || Video frame rate | 1 to 30 fps || Duration | 0.1 to 60 seconds || Maximum video frames | 900 || Still frames | 8 |-| Job elapsed deadline | Five minutes |+| Job elapsed deadline | 60 seconds plus 2 seconds per frame, multiplied for frames larger than 1024x576 (360 frames at 1024x576 get 13 minutes), never more than 30 minutes |+| Video encoder drain and finalization | 30 seconds each || Close settlement deadline | Five seconds |The controller rejects odd MP4 dimensions.diff --git a/docs/light-bake.md b/docs/light-bake.mdindex 1f2b5af6..b2c1a4e7 100644--- a/docs/light-bake.md+++ b/docs/light-bake.md@@ -1,6 +1,6 @@# Light bake-`67js/addons/light-bake` writes the light that bounces between surfaces into one lightmap texture per part. It is in the current source and not yet published. It is code only: recipes and the MCP tools cannot ask for a bake yet (issue #55).+`67js/addons/light-bake` writes the light that bounces between surfaces into one lightmap texture per part. It is in the current source and not yet published. Recipes reach it through the `bake` section (see below), so MCP agents can bake without code (issue #55).```jsimport { bakeLightmaps } from '67js/addons/light-bake';@@ -14,6 +14,22 @@ const { parts: bakedParts, report } = bakeLightmaps(parts, {const renderer = new Renderer67(canvas, bakedParts, rendererOptions);```+## In a recipe++```json+{ "bake": { "preset": "standard" } }+```++`bake` (or the `set-bake` operation, `null` clears it) takes a `preset` and optional `samples`, `bounces` and `texelsPerUnit` that override it:++| Preset | samples | bounces | texelsPerUnit |+| --- | --- | --- | --- |+| `draft` | 32 | 1 | 3 |+| `standard` (default) | 128 | 2 | 6 |+| `fine` | 192 | 2 | 7 |++Ranges are 1 to 256 samples, 1 to 3 bounces and 1 to 12 texels per unit. The bake lights the rest pose with the recipe's point lights and key light (key colour times `keyIntensity`). It runs when the scene builds and again only when a part, its matrix, a light, a material or the bake fields change: camera edits, effects edits, motion seeks and renders reuse the result. A bake over 20 s fails the edit and leaves the scene as it was. The same recipe gives the same lightmap bytes. `scene_inspect` returns `bake`: the resolved fields, `texels`, `rayWork`, `seconds` (of the run that made the lightmaps), `bakedParts`, `skipped` (name and reason) and `reused`. Baked parts read every other material field live, so motion tracks on colour still work; the lightmap itself is fixed at the rest pose.+## What it bakesThe bake traces cosine-weighted paths from each texel through up to `bounces` reflections. Each hit adds its own emission and the direct light it receives from the point lights and the sun, with shadow rays. A texel stores that light times its own albedo. Direct light is not baked: it stays live, so shadows and moving lights keep working. The stored light is only what has bounced at least once, so a scene needs the same lights at run time that it gave the bake.@@ -42,4 +58,4 @@ The result is deterministic: the same parts, lights and options give the same by## Measured-The `lit-interior` reference scene (25,648 texels at the defaults) bakes in about 6 s in the page on an RTX 3060 machine, running at below-normal priority. Its score against Cycles goes from 0.5055 to 0.1444 with the bake (`npm run reference -- --bake lit-interior`; details in `bench/reference/README.md`). Frame time with and without the bake has not been measured.+The `lit-interior` reference scene (25,648 texels at the defaults) bakes in about 6 s in the page on an RTX 3060 machine, running at below-normal priority. Its score against Cycles goes from 0.5055 to 0.1444 with the bake (`npm run reference -- --bake lit-interior`; details in `bench/reference/README.md`). Frame time on the same scene (960x540, 4 samples, RTX 3060, below-normal priority, 200 frames read back after each draw, two runs of each in alternating order): median 2.08 and 2.02 ms without the bake, 1.88 and 1.66 ms with it, so the bake costs no measurable draw time (one extra texture read per baked part; the spread between runs is load on the machine). `node bench/reference/frame-time.mjs lit-interior gpu` repeats it. The recipe path on a closed room with 8 boxes bakes 13,184 texels in 4.8 s at `standard`.diff --git a/docs/mcp.md b/docs/mcp.mdindex 6f58c757..be26ef12 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -54,7 +54,7 @@ The MCP connection uses stdin and stdout, without an HTTP MCP listener.The browser path is optional for a standard Google Chrome installation. Pass `--browser` for another Chromium executable.Using Node directly also avoids shell-specific npm launcher behavior in MCP clients on Windows.`--backend` accepts `gpu` or `cpu` and defaults to `gpu`.-`--memory` accepts an integer from 32 to 256 MiB and defaults to 192.+`--memory` accepts an integer from 32 to 384 MiB and defaults to 192. A 1920x1080 frame needs about 175 MiB of render targets (measured, 4 samples), so the default fits an empty room at that size and 256 leaves room for textures; raise it for textured scenes.`--assets` selects an absolute directory containing self-contained GLB files.The asset catalog reads regular files directly inside that directory, with limits of 64 files and 16 MiB per file.@@ -207,7 +207,7 @@ The [scene contract](agent-scene.md) defines the geometry fields, transforms, ma| Unique geometry buffers | 32 MiB || Recipe or command JSON | 1 MiB || Incoming stdio buffer | 2 MiB |-| Preview dimensions | 64 to 1024 pixels per dimension |+| Preview dimensions | 64 to 1024 pixels per dimension (render jobs: up to 1920x1080) || Default preview dimensions | 768 by 512 pixels || PNG payload | 1 MiB |diff --git a/docs/parity.md b/docs/parity.mdindex 7cbaec99..871d6f7c 100644--- a/docs/parity.md+++ b/docs/parity.md@@ -187,7 +187,7 @@ To move to a new Blender release, run `node scripts/parity-manual-snapshot.mjs`.| Physics > Baking Physics Simulations | partial | Physics records to a timeline in code or when a recipe scene is created, on the main thread. | [film-physics](../tests/film-physics.test.js) | #61 || Physics > Simulation Nodes | missing | No node graph. | | #43 || Rendering > Render Engines > EEVEE | partial | A WebGL2 rasterizer with PBR, one directional shadow, 8 point lights, fog and bloom. There are no light probes. | [renderer](../tests/renderer.test.js), [scores against EEVEE](../bench/reference/baseline.json) | #52, #53, #55, #56 |-| Rendering > Render Engines > Cycles | partial | No path tracer. `addons/light-bake` bakes bounced light from point lights and the sun into a lightmap for each part, on the CPU with ray tracing; it is code only (no recipe field, no GLB export, no reflection probes, no spot or area lights, no baked AO). On `lit-interior` it brings the score against Cycles from 0.5055 to 0.1444 (`npm run reference -- --bake lit-interior`). | [light-bake](../tests/light-bake.test.js), [lit-interior scene](../bench/reference/scenes.js) | #55, #57 |+| Rendering > Render Engines > Cycles | partial | No path tracer. `addons/light-bake` bakes bounced light from point lights and the sun into a lightmap for each part, on the CPU with ray tracing; recipes reach it through the `bake` section and `set-bake` (draft, standard or fine presets; scene_inspect reports bake seconds and skipped parts), but there is no GLB export, no reflection probes, no spot or area lights, no baked AO. On `lit-interior` it brings the score against Cycles from 0.5055 to 0.1444 (`npm run reference -- --bake lit-interior`). | [light-bake](../tests/light-bake.test.js), [recipe bake](../tests/agent-bake.test.js), [frame time](../bench/reference/frame-time.mjs), [lit-interior scene](../bench/reference/scenes.js) | #55, #57 || Rendering > Render Engines > Workbench | out of scope | A viewport engine for working by hand. | | || Rendering > Cameras | partial | Perspective, orthographic views, focal length, animated paths, depth of field from depth and camera motion blur, both repeatable per frame. Object motion blur and bokeh shapes are missing. | [camera-path](../tests/camera-path.test.js), [camera](../tests/camera.test.js), [render-passes](../tests/render-passes.test.js) | #54 || Rendering > Lights > Light Objects | partial | One directional light with a shadow, 8 point lights, 8 spot lights and 4 rectangular area lights. Point and spot lights can cast shadows from one 24-tile atlas (a point light takes 6 tiles, a spot light 1). Area lights use a representative point and cast no shadow. The directional shadow is a single map, not cascaded. | [lighting](../tests/lighting.test.js), `npm run reference` scene `spot-area` | #52 |diff --git a/scripts/agent-preview-browser.js b/scripts/agent-preview-browser.jsindex bfc34dab..c12aeb92 100644--- a/scripts/agent-preview-browser.js+++ b/scripts/agent-preview-browser.js@@ -69,7 +69,7 @@ function renderInfo(renderer) {}function hasPatternTextures(parts) {- return parts.some(part => part.material.boxMapScale);+ return parts.some(part => part.material.boxMapScale || part.material.emissiveMap);}// replaceParts streams only untextured parts, so a topology change around pattern textures takes a new renderer.diff --git a/scripts/agent-render-jobs.mjs b/scripts/agent-render-jobs.mjsindex 1e90ae65..1bd09793 100644--- a/scripts/agent-render-jobs.mjs+++ b/scripts/agent-render-jobs.mjs@@ -2,13 +2,25 @@ import { mkdir, open, readFile, writeFile, rename, unlink, rmdir, readdir, lstatimport { randomUUID, createHash } from 'node:crypto';import { isAbsolute, join, resolve } from 'node:path';-import { RENDER_PASS_NAMES, VIDEO_ENCODERS, AUDIO_FILE_PATTERN, MAXIMUM_VIDEO_SECONDS } from '../src/agent-scene-capabilities.js';+import { RENDER_PASS_NAMES, VIDEO_ENCODERS, AUDIO_FILE_PATTERN, MAXIMUM_VIDEO_SECONDS, MAXIMUM_JOB_SIDE, MAXIMUM_JOB_PIXELS } from '../src/agent-scene-capabilities.js';import { normalizeFilmTimeline, filmTimelineDuration } from '../src/film-timeline.js';const UUID =/^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/;const STATES = ['queued', 'running', 'finalizing', 'completed', 'cancelling', 'cancelled', 'failed', 'interrupted'];const TERMINAL = new Set(['completed', 'cancelled', 'failed', 'interrupted']);-const DEFAULT_LIMITS = Object.freeze({ maxRecords: 32, maxStoreBytes: 512 * 1024 ** 2, maxOutputBytes: 128 * 1024 ** 2, maxFrameBytes: 1024 ** 2, deadlineMs: 300000, cleanupMs: 5000 });+/** Hard ceiling on one job's elapsed time. The deadline below it grows with the job's frames and pixels. */+export const MAXIMUM_JOB_DEADLINE_MS = 30 * 60 * 1000;+const BASE_DEADLINE_MS = 60 * 1000;+const FRAME_ALLOWANCE_MS = 2000;+const REFERENCE_FRAME_PIXELS = 1024 * 576;+/** A 1920x1080 PNG of a busy scene runs to several MiB, so a frame may be up to 12 MiB. */+const DEFAULT_LIMITS = Object.freeze({ maxRecords: 32, maxStoreBytes: 512 * 1024 ** 2, maxOutputBytes: 128 * 1024 ** 2, maxFrameBytes: 12 * 1024 ** 2, deadlineMs: MAXIMUM_JOB_DEADLINE_MS, cleanupMs: 5000 });++/** 60 s plus 2 s per frame, scaled up for frames larger than 1024x576, never above the ceiling. */+export function jobDeadlineMs({ frameCount, width, height }, maximumMs = MAXIMUM_JOB_DEADLINE_MS) {+ const sizeScale = Math.max(1, (width * height) / REFERENCE_FRAME_PIXELS);+ return Math.min(maximumMs, Math.ceil(BASE_DEADLINE_MS + frameCount * FRAME_ALLOWANCE_MS * sizeScale));+}const MAXIMUM_JSON_BYTES = 1024 ** 2;const MAXIMUM_ASSET_BYTES = 16 * 1024 ** 2;/** Sibling folder of the job directories where the runtime keeps GLB exports; the store never reads or counts it. */@@ -60,8 +72,9 @@ function jsonCopy(value, maximum = MAXIMUM_JSON_BYTES) {function settingsFrom(input, clips, recipe) {objectKeys(input, ['kind', 'width', 'height', 'fps', 'duration', 'animation', 'motion', 'rendererTime', 'passes', 'timeline', 'audio', 'encoder'], 'settings');if (!['image', 'stills', 'video'].includes(input.kind)) throw new TypeError('kind must be image, stills or video.');- const width = boundedNumber(input.width, 64, 1024, 'width', true);- const height = boundedNumber(input.height, 64, 1024, 'height', true);+ const width = boundedNumber(input.width, 64, MAXIMUM_JOB_SIDE, 'width', true);+ const height = boundedNumber(input.height, 64, MAXIMUM_JOB_SIDE, 'height', true);+ if (width * height > MAXIMUM_JOB_PIXELS) throw new RangeError('width x height must not exceed 1920x1080 pixels.');if (input.kind === 'video' && (width % 2 || height % 2)) throw new RangeError('Video dimensions must be even.');const fps = boundedNumber(input.fps ?? 24, 1, 30, 'fps', true);const timelineStart = timelineStartFrom(input, recipe);@@ -390,7 +403,7 @@ export async function createAgentRenderJobs({ root, run, limits: inputLimits = {record.reason = job.failure;controller.abort(new Error(job.failure));persist(job).catch(() => {});- }, limits.deadlineMs);+ }, jobDeadlineMs(record.settings, limits.deadlineMs));const renamed = [];try {if (controller.signal.aborted) throw controller.signal.reason;diff --git a/scripts/agent-runtime.mjs b/scripts/agent-runtime.mjsindex 485dbe0c..e17eeb49 100644--- a/scripts/agent-runtime.mjs+++ b/scripts/agent-runtime.mjs@@ -6,7 +6,7 @@ import { dirname, isAbsolute, join } from 'node:path';import { createRequire } from 'node:module';import { fileURLToPath } from 'node:url';import packageMetadata from '../package.json' with { type: 'json' };-import { AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE, VIDEO_ENCODERS, MAXIMUM_VIDEO_SECONDS } from '../src/agent-scene-capabilities.js';+import { AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE, VIDEO_ENCODERS, MAXIMUM_VIDEO_SECONDS, MAXIMUM_JOB_SIDE, MAXIMUM_JOB_PIXELS, MAXIMUM_MEMORY_MIB } from '../src/agent-scene-capabilities.js';import { createAgentAssetCatalog } from './agent-asset-catalog.mjs';import { createAgentRenderJobs, EXPORT_DIRECTORY_NAME } from './agent-render-jobs.mjs';import { createFrameEncoder } from './frame-encoder.mjs';@@ -19,6 +19,8 @@ import { sessionProblem } from '../src/agent-errors.js';const SCENE_LIMITS = AGENT_SCENE_DEFAULT_LIMITS;const MAXIMUM_IMAGE_BYTES = 1024 * 1024;+// A job writes files, not MCP image responses, so a 1920x1080 PNG may be larger than an inline image.+const MAXIMUM_JOB_FRAME_BYTES = 12 * 1024 * 1024;// The object ID pass lists the part behind each ID in the job metrics; longer lists are cut and flagged.const MAXIMUM_OBJECT_NAMES = 1000;const MAXIMUM_QUEUED_CALLS = 16;@@ -45,8 +47,8 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memoif (!['gpu', 'cpu'].includes(backend)) {throw new RangeError('backend must be gpu or cpu.');}- if (!Number.isInteger(memory) || memory < 32 || memory > 256) {- throw new RangeError('memory must be an integer from 32 to 256 MiB.');+ if (!Number.isInteger(memory) || memory < 32 || memory > MAXIMUM_MEMORY_MIB) {+ throw new RangeError(`memory must be an integer from 32 to ${MAXIMUM_MEMORY_MIB} MiB.`);}if (browserPath !== undefined && (typeof browserPath !== 'string' || !existsSync(browserPath))) {throw new Error('The configured browser executable does not exist.');@@ -322,7 +324,7 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memoconst audio = settings.audio ? await prepareAudio(settings) : undefined;if (settings.kind === 'video') {encoder = createFrameEncoder({ executable: ffmpeg, output: join(directory, 'render.mp4.partial'),- fps: settings.fps, format: 'jpeg', signal, backend: settings.encoder === 'nvenc' ? 'gpu' : 'cpu',+ fps: settings.fps, format: 'jpeg', signal, maximumFrameBytes: MAXIMUM_JOB_FRAME_BYTES, backend: settings.encoder === 'nvenc' ? 'gpu' : 'cpu',audioArguments: settings.audio ? audioInputArguments(audio.path, settings.audio.offset) : [] });metrics.videoEncoder = settings.encoder === 'nvenc' ? 'h264_nvenc' : 'libx264';}@@ -356,7 +358,7 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memo...(settings.kind === 'video' ? { quality: 95 } : { optimizeForSpeed: true }) });const captureBytes = Buffer.from(captured.data, 'base64');metrics.captureSeconds += (performance.now() - captureStarted) / 1000;- if (captureBytes.length > MAXIMUM_IMAGE_BYTES) throw new Error('Captured job frame exceeded 1 MiB.');+ if (captureBytes.length > MAXIMUM_JOB_FRAME_BYTES) throw new Error('Captured job frame exceeded 12 MiB.');signal.throwIfAborted();return captureBytes;}@@ -463,6 +465,7 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memocommands: ['set-root', 'set-asset-node', 'set-motion', 'set-animation', 'set-material', 'set-camera', 'set-environment', 'set-effects', 'set-shadow'],},jobs: { configured: Boolean(jobRoot), kinds: ['image', 'stills', 'video'], passes: RENDER_PASS_NAMES, maximumActiveJobs: 1,+ maximumWidth: MAXIMUM_JOB_SIDE, maximumHeight: MAXIMUM_JOB_SIDE, maximumPixels: MAXIMUM_JOB_PIXELS,maximumDuration: MAXIMUM_VIDEO_SECONDS, maximumFps: 30, maximumFrames: 900, maximumStills: 8,encoder: 'H.264', encoders: VIDEO_ENCODERS, audio: Boolean(audioRoot), timeline: true, previewSuspendedDuringJob: true,glbExport: { maximumBytes: MAXIMUM_GLB_BYTES, maximumKept: MAXIMUM_KEPT_GLBS, maximumTextureSize: 4096 },diff --git a/scripts/frame-encoder.mjs b/scripts/frame-encoder.mjsindex b9ce029a..3db12bd4 100644--- a/scripts/frame-encoder.mjs+++ b/scripts/frame-encoder.mjs@@ -2,10 +2,13 @@ import { spawn } from 'node:child_process';import { stat } from 'node:fs/promises';import { performance } from 'node:perf_hooks';+/** Drain and finalization wait this long: below-normal priority jobs on a busy machine need more than 5 s. */+export const DEFAULT_ENCODER_TIMEOUT_MS = 30000;+/** One streamed frame at a time. The caller owns output publication and cleanup. */export function createFrameEncoder({ executable = 'ffmpeg', output, fps, format = 'jpeg', backend = 'cpu',audioArguments = [], signal, maximumFrameBytes = 1024 * 1024,- maximumOutputBytes = 128 * 1024 * 1024, timeoutMs = 5000 } = {}) {+ maximumOutputBytes = 128 * 1024 * 1024, timeoutMs = DEFAULT_ENCODER_TIMEOUT_MS } = {}) {if (typeof output !== 'string' || !output || !Number.isFinite(fps) || fps < 1 || fps > 60 ||!['jpeg', 'png'].includes(format) || !['cpu', 'gpu'].includes(backend)) {throw new TypeError('Encoder requires an output path, valid fps, format and backend.');diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjsindex cfce04fd..c76f395e 100644--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@ -7,7 +7,7 @@ import { resolve } from 'node:path';import { pathToFileURL } from 'node:url';import packageMetadata from '../package.json' with { type: 'json' };import { MODIFIER_OPERATIONS } from '../src/mesh-operations.js';-import { MATERIAL_PATTERN_TYPES, MATERIAL_MAPPINGS, LIGHTING_SETUP_NAMES, RENDER_PASS_NAMES, VIDEO_ENCODERS } from '../src/agent-scene-capabilities.js';+import { MATERIAL_PATTERN_TYPES, MATERIAL_MAPPINGS, LIGHTING_SETUP_NAMES, RENDER_PASS_NAMES, VIDEO_ENCODERS, MAXIMUM_JOB_SIDE, MAXIMUM_MEMORY_MIB } from '../src/agent-scene-capabilities.js';import { MATERIAL_LAYER_SCALAR_RANGES, MATERIAL_LAYER_COLOR_RANGES } from '../src/material-layers.js';const finite = z.number().min(-3.4028234663852886e38).max(3.4028234663852886e38);@@ -227,7 +227,7 @@ function primitiveGeometries(identified) {...(identified ? curveAndTextGeometries(id) : []),];}-const selectRule = z.record(z.string(), z.unknown()).describe('Face selection rule: {"all":true}, {"tag":"top"}, {"normal":[0,1,0],"maxAngle":10} (degrees), {"inside":{"min":[x,y,z],"max":[x,y,z]}} (face centroids), {"faces":[indices]}, {"and":[rules]}, {"or":[rules]}, {"not":rule}, {"grow":rule,"steps":1}, {"boundary":rule}, {"field":expression} (faces where a field expression is nonzero, evaluated at face centroids). Tags come from the base (top, bottom, side, left, right, front, back) and from earlier edits (<name>.cap, <name>.side, <name>.rim, or a tag op).');+const selectRule = z.record(z.string(), z.unknown()).describe('Face selection rule: {"all":true}, {"tag":"top"}, {"normal":[0,1,0],"maxAngle":10} (degrees), {"inside":{"min":[x,y,z],"max":[x,y,z]}} (centroids), {"faces":[indices]}, {"and":[rules]}, {"or":[rules]}, {"not":rule}, {"grow":rule,"steps":1}, {"boundary":rule}, {"field":expression} (nonzero at centroids). Tags: top, bottom, side, left, right, front, back, and <name>.cap, <name>.side, <name>.rim or a tag op.');const editName = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,47}$/).optional().describe('Prefix for the tags this edit creates. Defaults to <op>-<index>.');const edgeRule = z.record(z.string(), z.unknown()).describe('Edge rule: {"all":true}, {"angle":30}, {"along":[x,y,z]}, {"between":[faceRule,faceRule]}, {"boundaryOf":faceRule} or {"open":true} for boundary edges (also {"open":{"inside":{"min":[x,y,z],"max":[x,y,z]}}}).');const meshEdit = z.discriminatedUnion('op', [@@ -515,6 +515,7 @@ const recipe = z.strictObject({cloth: cloth.nullable().optional(),timeline: timelineReference.nullable().optional(),particles: z.record(z.string(), z.unknown()).nullable().optional().describe('Particle emitters and hair, seeked by motionTime. Fields: scene_capabilities particles.'),+ bake: z.record(z.string(), z.unknown()).nullable().optional().describe('Bounced light baked at build time. Fields: scene_capabilities bake.'),}).describe('Bounded scene recipe; the backend validates it.');const assetRecipe = z.strictObject({format: z.literal('67js.asset'),@@ -550,6 +551,7 @@ const operation = z.discriminatedUnion('type', [z.strictObject({ type: z.literal('set-cloth'), cloth: z.record(z.string(), z.unknown()).nullable() }),z.strictObject({ type: z.literal('set-timeline'), timeline: z.record(z.string(), z.unknown()).nullable() }),z.strictObject({ type: z.literal('set-particles'), particles: z.record(z.string(), z.unknown()).nullable() }),+ z.strictObject({ type: z.literal('set-bake'), bake: z.record(z.string(), z.unknown()).nullable() }),z.strictObject({ type: z.literal('set-environment'), environment }),z.strictObject({ type: z.literal('set-effects'), effects }),z.strictObject({ type: z.literal('set-shadow'), shadow }),@@ -571,8 +573,8 @@ const expectedRevision = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).deconst jobFields = { jobId: z.uuid().describe('Render job UUID returned by scene_render_submit or capabilities jobs.records.') };const renderSettings = z.strictObject({kind: z.enum(['image', 'stills', 'video']),- width: z.number().int().min(64).max(1024),- height: z.number().int().min(64).max(1024),+ width: z.number().int().min(64).max(MAXIMUM_JOB_SIDE),+ height: z.number().int().min(64).max(MAXIMUM_JOB_SIDE),fps: z.number().int().min(1).max(30).optional(),duration: z.number().min(0.1).max(60).optional(),animation: z.strictObject({ clip: z.number().int().min(0), start: z.number().min(0).max(3600).optional() }).optional(),@@ -702,12 +704,12 @@ export async function runMcpCli({ argumentsValue = process.argv.slice(2),const name = argumentsValue[index];const value = argumentsValue[index + 1];if (!['--backend', '--browser', '--memory', '--assets', '--jobs', '--ffmpeg', '--audio'].includes(name) || value === undefined) {- throw new Error('Use --backend cpu|gpu, --browser <local executable path>, --memory <32..256 MiB>, --assets <absolute GLB directory>, --jobs <absolute private output directory>, --ffmpeg <absolute executable>, and --audio <absolute folder of .wav, .mp3, .ogg or .flac files for video jobs>.');+ throw new Error(`Use --backend cpu|gpu, --browser <local executable path>, --memory <32..${MAXIMUM_MEMORY_MIB} MiB>, --assets <absolute GLB directory>, --jobs <absolute private output directory>, --ffmpeg <absolute executable>, and --audio <absolute folder of .wav, .mp3, .ogg or .flac files for video jobs>.`);}options[name.slice(2)] = name === '--memory' ? Number(value) : value;}- if (!['cpu', 'gpu'].includes(options.backend) || !Number.isInteger(options.memory) || options.memory < 32 || options.memory > 256) {- throw new Error('Backend must be cpu or gpu, and memory must be an integer from 32 to 256 MiB.');+ if (!['cpu', 'gpu'].includes(options.backend) || !Number.isInteger(options.memory) || options.memory < 32 || options.memory > MAXIMUM_MEMORY_MIB) {+ throw new Error(`Backend must be cpu or gpu, and memory must be an integer from 32 to ${MAXIMUM_MEMORY_MIB} MiB.`);}setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);const { createAgentRuntime } = await import('./agent-runtime.mjs');diff --git a/scripts/render-media.mjs b/scripts/render-media.mjsindex 9a07fd36..d0bf0356 100644--- a/scripts/render-media.mjs+++ b/scripts/render-media.mjs@@ -213,7 +213,7 @@ export async function renderMedia(values = process.argv.slice(2)) {const audioArguments = audioPath && existsSync(audioPath) ? ['-ss', String(start), '-i', audioPath] : [];encoder = createFrameEncoder({ executable: ffmpeg, output, fps, format: captureFormat,backend: encoderBackend, audioArguments, maximumFrameBytes: 64 * 1024 * 1024,- maximumOutputBytes: Number.MAX_SAFE_INTEGER, timeoutMs: 30000 });+ maximumOutputBytes: Number.MAX_SAFE_INTEGER });const frameCount = Math.ceil(duration * fps);const captureSequenceStarted = performance.now();for (let frame = 0; frame < frameCount; frame++) {diff --git a/scripts/smoke-mcp-package.mjs b/scripts/smoke-mcp-package.mjsindex 52abbcb7..692d65d5 100644--- a/scripts/smoke-mcp-package.mjs+++ b/scripts/smoke-mcp-package.mjs@@ -75,7 +75,7 @@ assert.match(help.stdout, /--assets/);const invalid = spawnSync(process.execPath, [cli, '--memory', '0'], { cwd: consumer, encoding: 'utf8', windowsHide: true });assert.equal(invalid.status, 1);assert.equal(invalid.stdout, '');-assert.match(invalid.stderr, /32 to 256/);+assert.match(invalid.stderr, /32 to 384/);const shim = join(consumer, 'node_modules', '.bin', process.platform === 'win32' ? '67js-mcp.cmd' : '67js-mcp');const shimVersion = process.platform === 'win32'? spawnSync('cmd.exe', ['/d', '/s', '/c', `""${shim}" --version"`], {diff --git a/skills/build-67js-scene/SKILL.md b/skills/build-67js-scene/SKILL.mdindex 8974539d..71ff593e 100644--- a/skills/build-67js-scene/SKILL.md+++ b/skills/build-67js-scene/SKILL.md@@ -50,6 +50,7 @@ Use `simplify-code` and `engineering-workflows` for implementation.- Things that fall, pile up or rest on an authored mesh (dropped objects, a ball in a bowl, a trigger zone) use the recipe `physics` section: bodies on root node IDs, `shape: 'trimesh'` on a fixed body so objects follow the mesh, `sensor: true` for triggers, `layer` and `collidesWith` for masks. Seek with `motionTime` like motion, and read `physics` from `scene_inspect` (resting times, contacts, sensor events) instead of guessing from a picture. Needs the optional peer `@dimforge/rapier3d-compat`; bodies bound to bones for ragdolls are not supported. See "Recipe physics" in the checkout's `docs/physics.md`.- Flags, curtains, capes and cloths draped over props use the recipe `cloth` section: a `grid` geometry node (flat sheet in XY, `segments` up to 64) listed in `sheets` with `pin` edges (`top`, `left`, a corner...), `wind` in m/s, and fixed `colliders` (`ball` or `box` fitted to their node). Seek with `motionTime`; a flag needs wind along its length (+x for a left pin), not across it. No peer needed, no self collision, no soft bodies. Units, defaults and limits are in `scene_capabilities` under `cloth`; see "Recipe cloth" in `docs/physics.md`.- Sparks, dust, embers, confetti and fur use the recipe `particles` section: a root node whose small low-poly geometry (a box) is the particle, in an emitter system with `seed`, `count` (at most 2000), `rate` (omit for one burst), `lifetime`, `speed`, `spread`, `drag`, `floor` and an `emitter` shape; a system with `type: "hair"` grows strands from a `surface` node. Seek with `motionTime`; the same seed and time give the same particles. The node transform does not move particles, and there is no collision beyond the floor, bounce or per-particle colour. Fields and limits are in `scene_capabilities` under `particles`; see "Recipe particles and hair" in `docs/physics.md`. Smoke, fire and browser liquid are not supported.+- A closed room, or any scene lit by point lights, is dark where the light does not reach. Add the recipe `bake` section (`{ "preset": "standard" }`, or `draft` to try fast, `fine` to finish) or the `set-bake` operation: it writes bounced light into lightmaps when the scene builds and reruns only when parts, lights, materials or the bake change. `scene_inspect` shows `bake.seconds` and `bake.skipped` (parts with maps, patterns, emission, alpha, skins or morphs are left as they were). It bakes the rest pose and no spot or area lights. Read `docs/light-bake.md`.- Agent procedural animation uses `docs/agent-motion.md` from release `0.7.0`. Author recipe tracks, then seek through `sampleMotion` or MCP `motionTime`.- Agent imported character motion uses `docs/agent-character-motion.md` from release `0.8.0`. Inspect source joints before authoring local tracks.- To pick between variants, fork each with `scene_apply` and a `branch` name (the scene and revision stay put), compare them in one `scene_review` with a `branch` per shot, then keep the winner with `scene_restore` and its `branch`. Add `labels: true` to `scene_look` or `scene_review` to match node names and lint problems to what the image shows. Docs: `docs/agent-review.md`.diff --git a/skills/render-67js-media/references/rendering.md b/skills/render-67js-media/references/rendering.mdindex 49e5e6b3..ca67e833 100644--- a/skills/render-67js-media/references/rendering.md+++ b/skills/render-67js-media/references/rendering.md@@ -31,6 +31,7 @@ For object images, `--assembly 1` explodes the model. The default value `0` asseEach option requires a value. Dimensions range from 64 to 4096 pixels.Memory ranges from 32 to 1024 MiB. Duration ranges from 0.1 to 120 seconds.+MCP render jobs (`scene_render_submit`) take up to 1920x1080 (each side up to 1920, at most that many pixels) and `--memory` up to 384 MiB. A 1920x1080 frame needs about 175 MiB of targets, so use `--memory 256` for it. A job gets 60 s plus 2 s per frame (more for frames above 1024x576), at most 30 minutes; the video encoder waits 30 s to drain and to finish.The video encoder can use `--encoder cpu` or `--encoder gpu` independently of the renderer backend.The hardware encoder requires NVENC. A failed encoder stops the export and reports its error.diff --git a/src/agent-bake.js b/src/agent-bake.jsnew file mode 100644index 00000000..a2bffd5f--- /dev/null+++ b/src/agent-bake.js@@ -0,0 +1,68 @@+import { bakeLightmaps } from './light-bake.js';+import { knownKeys, finiteNumber } from './agent-recipe-checks.js';+import { BAKE_PRESETS, BAKE_RANGES, BAKE_MAXIMUM_SECONDS } from './agent-scene-capabilities.js';++// Recipe `bake`: bounced light written into lightmaps when the scene builds. This module loads on demand, so scenes+// without a bake never download the ray tracer.++const BAKE_FIELDS = ['preset', 'samples', 'bounces', 'texelsPerUnit'];+const BAKED_MATERIAL_FIELDS = ['emission', 'emissiveColor', 'emissiveMap'];++/** Validates a recipe bake section and returns the plain, resolved form stored in the recipe (null clears it). */+export function normalizeAgentBake(input) {+ if (input === null || input === undefined) {+ return null;+ }+ knownKeys(input, BAKE_FIELDS, 'bake');+ if (input.preset !== undefined && !Object.hasOwn(BAKE_PRESETS, input.preset)) {+ throw new RangeError(`Bake preset must be one of ${Object.keys(BAKE_PRESETS).join(', ')}.`);+ }+ const resolved = { ...BAKE_PRESETS[input.preset ?? 'standard'] };+ for (const [field, [minimum, maximum]] of Object.entries(BAKE_RANGES)) {+ if (input[field] === undefined) {+ continue;+ }+ resolved[field] = finiteNumber(input[field], `Bake ${field}`, minimum, maximum);+ }+ for (const field of ['samples', 'bounces']) {+ if (!Number.isInteger(resolved[field])) {+ throw new RangeError(`Bake ${field} must be an integer.`);+ }+ }+ return resolved;+}++// The baked part keeps reading every other material field from the live material, so motion tracks still drive it.+function liveBakedMaterial(liveMaterial, bakedMaterial) {+ const output = {};+ for (const field of Object.keys(bakedMaterial)) {+ const source = BAKED_MATERIAL_FIELDS.includes(field) ? bakedMaterial : liveMaterial;+ Object.defineProperty(output, field, { enumerable: true, get: () => source[field] });+ }+ return Object.freeze(output);+}++/**+ * Bakes the parts at the world matrices given by name (a retained part's own matrix is only refreshed after a commit).+ * Returns the new parts, which share the originals' matrices so poses still move them, and a report: texels,+ * rayWork, seconds, skipped parts with reasons.+ */+export function bakeAgentParts(parts, worldMatrices, environment, settings) {+ const sunScale = environment.keyIntensity ?? 1;+ const lighting = {+ pointLights: environment.pointLights,+ keyColor: Array.from(environment.keyColor, channel => channel * sunScale),+ lightDirection: environment.lightDirection,+ };+ const snapshots = parts.map(part => ({ ...part, matrix: worldMatrices.get(part.name), material: { ...part.material } }));+ const { parts: bakedSnapshots, report } = bakeLightmaps(snapshots, lighting, { ...settings, maxSeconds: BAKE_MAXIMUM_SECONDS });+ const bakedParts = parts.map((part, index) => {+ if (bakedSnapshots[index] === snapshots[index]) {+ return part;+ }+ const { geometry, material } = bakedSnapshots[index];+ return Object.freeze({ ...part, geometry, material: liveBakedMaterial(part.material, material) });+ });+ return { parts: Object.freeze(bakedParts), report: { ...settings, texels: report.texels, rayWork: report.rayWork, seconds: report.seconds,+ bakedParts: report.parts.length, skipped: report.skipped } };+}diff --git a/src/agent-scene-capabilities.js b/src/agent-scene-capabilities.jsindex fc1db414..2aabbafc 100644--- a/src/agent-scene-capabilities.js+++ b/src/agent-scene-capabilities.js@@ -67,6 +67,22 @@ export const RENDER_PASS_NAMES = Object.freeze(['albedo', 'normal', 'emission',// extension, no drive or protocol syntax.export const VIDEO_ENCODERS = Object.freeze(['cpu', 'nvenc']);export const MAXIMUM_VIDEO_SECONDS = 60;+/** Recipe bake presets and ranges. A bake over 20 s fails the edit before the 30 s page deadline would close the runtime. */+export const BAKE_PRESETS = Object.freeze({+ draft: Object.freeze({ samples: 32, bounces: 1, texelsPerUnit: 3 }),+ standard: Object.freeze({ samples: 128, bounces: 2, texelsPerUnit: 6 }),+ fine: Object.freeze({ samples: 192, bounces: 2, texelsPerUnit: 7 }),+});+export const BAKE_RANGES = Object.freeze({ samples: [1, 256], bounces: [1, 3], texelsPerUnit: [1, 12] });+export const BAKE_MAXIMUM_SECONDS = 20;+/** Render job output: each side up to 1920 and never more pixels than 1920x1080 (portrait 1080x1920 fits). */+export const MAXIMUM_JOB_SIDE = 1920;+export const MAXIMUM_JOB_PIXELS = 1920 * 1080;+/**+ * Largest --memory value in MiB the MCP server accepts. Measured: a 1920x1080 frame needs about 175 MiB of targets+ * (planRenderSize estimate, 4 samples), Node RSS peaks under 180 MiB, so 384 leaves about 200 MiB for scene textures and geometry.+ */+export const MAXIMUM_MEMORY_MIB = 384;export const AUDIO_FILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}\.(wav|mp3|ogg|flac)$/;// Metres that depth pass values 0 to 65535 span, measured from the camera.export const RENDER_PASS_DEPTH_RANGE = 100;@@ -95,7 +111,7 @@ export const AGENT_SCENE_CAPABILITIES = Object.freeze({operations: Object.freeze(['set-node', 'set-material', 'set-camera', 'add-node', 'remove-node','add-geometry', 'remove-geometry', 'add-material', 'remove-material',- 'set-environment', 'set-effects', 'set-shadow', 'set-motion', 'set-armatures', 'set-physics', 'set-cloth', 'set-timeline', 'set-particles', 'edit-mesh', 'set-mesh-stack',+ 'set-environment', 'set-effects', 'set-shadow', 'set-motion', 'set-armatures', 'set-physics', 'set-cloth', 'set-timeline', 'set-particles', 'set-bake', 'edit-mesh', 'set-mesh-stack',]),materialTags: Object.freeze(['surface', 'unlit', 'liquid', 'foam']),alphaModes: RECIPE_ALPHA_MODES,@@ -172,6 +188,13 @@ export const AGENT_SCENE_CAPABILITIES = Object.freeze({notes: 'A particle is a pure function of seed, index and time; raising count keeps earlier ones. No collision but the floor, no bounce, rotation, colour or alpha; no hair collision, combing or clumping. Report: maxAlive and endsAt per system.',limits: Object.freeze({ maxSystems: 4, maxParticlesPerSystem: 2000, maxParticles: 4000, maxVertices: 100000, maxLifetime: 60 }),}),+ // Recipe bake: bounced light written into lightmaps at build time (src/light-bake.js, loaded on demand).+ bake: Object.freeze({+ fields: 'preset, or samples (1-256), bounces (1-3), texelsPerUnit (1-12) over it. Same recipe, same bytes.',+ presets: BAKE_PRESETS,+ notes: 'Bounced light from point lights and the key light, for closed rooms. Reruns only when parts, lights, materials or bake change, never on seek or camera. Skips parts with maps, pattern, emission, alpha, skin or morph (scene_inspect bake.skipped, bake.seconds). Spot and area lights, environment map and specular are not baked. Over 20 s fails the edit.',+ limits: Object.freeze({ maxSeconds: BAKE_MAXIMUM_SECONDS, maxPointLights: 8 }),+ }),motionLimits: Object.freeze({ maxTracks: 128, maxKeyframesPerTrack: 64, maxKeyframes: 2048, maxDuration: 30 }),});diff --git a/src/agent-scene-modules.js b/src/agent-scene-modules.jsindex b0e732b3..603ade6e 100644--- a/src/agent-scene-modules.js+++ b/src/agent-scene-modules.js@@ -11,6 +11,7 @@ const MODULE_LOADERS = {physics: () => import('./agent-physics.js'),cloth: () => import('./agent-cloth.js'),particles: () => import('./agent-particles.js'),+ bake: () => import('./agent-bake.js'),patterns: () => import('./material-patterns.js'),relations: () => import('./agent-relations.js'),timeline: () => import('./film-timeline.js'),@@ -30,6 +31,7 @@ const MODULE_MARKERS = {physics: ['"physics":{'],cloth: ['"cloth":{'],particles: ['"particles":{'],+ bake: ['"bake":{'],patterns: ['"pattern"'],relations: ['"relations":'],timeline: ['"timeline":{'],diff --git a/src/agent-scene.js b/src/agent-scene.jsindex 2b8375e5..3778e654 100644--- a/src/agent-scene.js+++ b/src/agent-scene.js@@ -599,7 +599,7 @@ function withDefaultMaterial(recipe) {function normalizeRecipe(input, limits) {let recipe = copiedJson(input, limits.maxRecipeBytes);- knownKeys(recipe, ['format', 'schemaVersion', 'geometries', 'materials', 'nodes', 'armatures', 'camera', 'environment', 'effects', 'shadow', 'motion', 'physics', 'cloth', 'timeline', 'particles'], 'recipe');+ knownKeys(recipe, ['format', 'schemaVersion', 'geometries', 'materials', 'nodes', 'armatures', 'camera', 'environment', 'effects', 'shadow', 'motion', 'physics', 'cloth', 'timeline', 'particles', 'bake'], 'recipe');if (recipe.format !== '67js.scene' || recipe.schemaVersion !== 1) {throw new RangeError('Expected 67js.scene schemaVersion 1.');}@@ -662,6 +662,9 @@ function normalizeRecipe(input, limits) {if (Object.hasOwn(recipe, 'particles')) {recipe.particles = agentSceneModule('particles').normalizeAgentParticles(recipe.particles, recipe);}+ if (Object.hasOwn(recipe, 'bake')) {+ recipe.bake = recipe.bake === null ? null : agentSceneModule('bake').normalizeAgentBake(recipe.bake);+ }recipe = copiedJson(recipe, limits.maxRecipeBytes);return recipe;}@@ -872,6 +875,7 @@ export function createAgentScene(input, inputLimits = {}) {let physicsBake = null;let clothBake = null;let particleBake = null;+ let lightBake = null;const skinCache = new Map();const checkpoints = new Map();@@ -964,8 +968,8 @@ export function createAgentScene(input, inputLimits = {}) {const handle = existing ?? materialHandle(snapshot);materialHandles.set(material.id, handle);}- const activeParts = new Map(state?.restParts.map(part => [part.name, part]) ?? []);- const preferredParts = new Map(preferred?.restParts.map(part => [part.name, part]) ?? []);+ const activeParts = new Map(state?.sourceRestParts.map(part => [part.name, part]) ?? []);+ const preferredParts = new Map(preferred?.sourceRestParts.map(part => [part.name, part]) ?? []);const nextParts = recipe.nodes.filter(node => node.geometry !== undefined).map(node => {const binding = skinBindings.get(node.id);const geometry = binding?.geometry ?? geometries.get(node.geometry);@@ -980,14 +984,19 @@ export function createAgentScene(input, inputLimits = {}) {});});retainedMatrices(nextParts);- const sameParts = state && state.restParts.length === nextParts.length &&- state.restParts.every((part, index) => part === nextParts[index]);- const restParts = sameParts ? state.restParts : Object.freeze(nextParts);+ const sameParts = state && state.sourceRestParts.length === nextParts.length &&+ state.sourceRestParts.every((part, index) => part === nextParts[index]);+ const sourceRestParts = sameParts ? state.sourceRestParts : Object.freeze(nextParts);+ const lightBakeResult = stageLightBake(recipe, sourceRestParts, graph);+ const restParts = lightBakeResult ? lightBakeResult.parts : sourceRestParts;const stagedState = {recipe, geometryRecords, geometries, graph, materialHandles,+ // Part identity decides what the next stage reuses, so it compares the parts as built, before any bake.+ sourceRestParts,parts: restParts, restParts,+ bakeReport: lightBakeResult ? { ...lightBakeResult.report, reused: lightBakeResult.reused } : null,// A renderer holding the deformed cloth parts of the old state needs the rest parts back as a topology change.- topologyChanged: Boolean(state && (!sameParts || state.parts !== state.restParts)),+ topologyChanged: Boolean(state && (restParts !== state.restParts || state.parts !== state.restParts)),stats: geometryStats(geometryRecords.values()),};stagedState.localBounds = localBounds;@@ -1003,6 +1012,24 @@ export function createAgentScene(input, inputLimits = {}) {return stagedState;}+ // A light bake costs seconds of ray tracing: it runs when the parts, the lights, the materials or the bake fields+ // change, and every other edit, seek or camera move reuses the last result.+ function stageLightBake(recipe, sourceRestParts, graph) {+ if (!recipe.bake) {+ return null;+ }+ const worldMatrices = new Map(sourceRestParts.map(part => [part.name, new Float32Array(graph.getNode(part.name).worldMatrix)]));+ const { pointLights, keyColor, keyIntensity, lightDirection } = recipe.environment;+ const key = JSON.stringify([recipe.bake, pointLights, keyColor, keyIntensity, lightDirection, recipe.materials,+ [...worldMatrices].map(([name, matrix]) => [name, Array.from(matrix)])]);+ if (lightBake?.key === key && lightBake.sourceRestParts === sourceRestParts) {+ return { ...lightBake, reused: true };+ }+ const baked = agentSceneModule('bake').bakeAgentParts(sourceRestParts, worldMatrices, recipe.environment, recipe.bake);+ lightBake = { key, sourceRestParts, parts: baked.parts, report: baked.report };+ return { ...lightBake, reused: false };+ }+// A bake costs a solver run, so an unchanged section on unchanged geometry reuses the last one.function stagePhysics(recipe, geometryRecords) {if (!recipe.physics) {@@ -1171,6 +1198,14 @@ export function createAgentScene(input, inputLimits = {}) {candidate.cloth = operation.cloth;continue;}+ if (operation.type === 'set-bake') {+ knownKeys(operation, ['type', 'bake'], 'operation');+ if (!Object.hasOwn(operation, 'bake')) {+ throw new TypeError('set-bake requires bake; use null to clear it.');+ }+ candidate.bake = operation.bake;+ continue;+ }if (operation.type === 'set-particles') {knownKeys(operation, ['type', 'particles'], 'operation');if (!Object.hasOwn(operation, 'particles')) {@@ -1288,7 +1323,7 @@ export function createAgentScene(input, inputLimits = {}) {fields = CAMERA_FIELDS;target = candidate.camera;} else {- throw new TypeError(`Unsupported operation type: ${operation.type}. Use one of set-node, set-material, set-camera, set-motion, set-physics, set-cloth, set-timeline, set-particles, set-environment, set-effects, set-shadow, add-node, add-geometry, add-material, remove-node, remove-geometry, remove-material, edit-mesh, set-mesh-stack.`);+ throw new TypeError(`Unsupported operation type: ${operation.type}. Use one of set-node, set-material, set-camera, set-motion, set-physics, set-cloth, set-timeline, set-particles, set-bake, set-environment, set-effects, set-shadow, add-node, add-geometry, add-material, remove-node, remove-geometry, remove-material, edit-mesh, set-mesh-stack.`);}knownKeys(operation, ['type', ...(operation.type === 'set-camera' ? [] : ['id']), ...fields], 'operation');if (!target) {@@ -1341,6 +1376,7 @@ export function createAgentScene(input, inputLimits = {}) {physics: state.physicsSampler ? state.physicsSampler.report() : null,...(state.clothSampler ? { cloth: state.clothSampler.report() } : {}),...(state.particleSampler ? { particles: state.particleSampler.report() } : {}),+ ...(state.bakeReport ? { bake: state.bakeReport } : {}),...(state.recipe.armatures ? { rig: rigReport(state.recipe, state.skinBindings) } : {}),boundsSpace: 'authored-base-world',...(diagnostics.length ? { diagnostics } : {}),@@ -1392,6 +1428,7 @@ export function createAgentScene(input, inputLimits = {}) {geometryRecords: new Map(state.geometryRecords),materialHandles: new Map(state.materialHandles),restParts: state.restParts,+ sourceRestParts: state.sourceRestParts,});return handle;},diff --git a/tests/agent-bake.test.js b/tests/agent-bake.test.jsnew file mode 100644index 00000000..2b7c9a1a--- /dev/null+++ b/tests/agent-bake.test.js@@ -0,0 +1,119 @@+import assert from 'node:assert/strict';+import test from 'node:test';+import { createAgentScene } from '../src/agent-scene.js';+import { normalizeAgentBake } from '../src/agent-bake.js';+import { BAKE_PRESETS } from '../src/agent-scene-capabilities.js';++function closedRoom(extra = {}) {+ const box = (id, translation, scale, material) => ({ id, geometry: 'box', material, translation, scale });+ return {+ format: '67js.scene', schemaVersion: 1,+ geometries: [{ id: 'box', type: 'box' }],+ materials: [+ { id: 'white', color: [0.8, 0.8, 0.8], roughness: 0.9 },+ { id: 'lamp', color: [1, 1, 1], emission: 2 },+ ],+ nodes: [+ box('floor', [0, -0.05, 0], [4, 0.1, 4], 'white'),+ box('ceiling', [0, 3.05, 0], [4, 0.1, 4], 'white'),+ box('back', [0, 1.5, -2.05], [4.2, 3.2, 0.1], 'white'),+ box('front', [0, 1.5, 2.05], [4.2, 3.2, 0.1], 'white'),+ box('left', [-2.05, 1.5, 0], [0.1, 3.2, 4.2], 'white'),+ box('right', [2.05, 1.5, 0], [0.1, 3.2, 4.2], 'white'),+ box('block', [-0.7, 0.6, -0.4], [1.2, 1.2, 1.2], 'white'),+ box('bulb', [0.9, 2.5, 0.6], [0.2, 0.2, 0.2], 'lamp'),+ ],+ camera: { eye: [0, 1.5, 1.9], target: [0, 1.4, -2], fov: 70, near: 0.05, far: 20 },+ environment: { pointLights: [{ position: [0, 2.7, 0], intensity: 14, radius: 0.1 }], keyIntensity: 0, fillIntensity: 0 },+ bake: { preset: 'draft' },+ ...extra,+ };+}++function closedRoomWithoutBake() {+ const { bake, ...recipe } = closedRoom();+ return recipe;+}++function lightmapBytes(part) {+ return Buffer.from(part.material.emissiveMap.image.data ?? part.material.emissiveMap.image.bytes);+}++test('bake presets and fields resolve to plain numbers within their ranges', () => {+ assert.deepEqual(normalizeAgentBake({ preset: 'fine' }), BAKE_PRESETS.fine);+ assert.deepEqual(normalizeAgentBake({}), BAKE_PRESETS.standard);+ assert.deepEqual(normalizeAgentBake({ preset: 'draft', samples: 48 }), { ...BAKE_PRESETS.draft, samples: 48 });+ assert.equal(normalizeAgentBake(null), null);+});++test('bake rejects hostile and out of range fields', () => {+ const hostile = [+ { preset: 'ultra' }, { samples: 0 }, { samples: 257 }, { samples: 1e9 }, { samples: NaN }, { samples: '64' },+ { samples: 2.5 }, { bounces: 4 }, { bounces: 1.5 }, { texelsPerUnit: 0.5 }, { texelsPerUnit: 13 },+ { maxSeconds: 600 }, { unknown: 1 }, [], 'standard', JSON.parse('{"__proto__":{"samples":1}}'),+ ];+ for (const input of hostile) {+ assert.throws(() => normalizeAgentBake(input), undefined, JSON.stringify(input));+ }+});++test('a recipe bake lights the room with lightmaps and reports its time and skipped parts', () => {+ const scene = createAgentScene(closedRoom());+ const bake = scene.inspect().bake;+ assert.equal(bake.reused, false);+ assert.ok(bake.seconds > 0);+ assert.ok(bake.texels > 0);+ assert.deepEqual(bake.skipped.map(entry => entry.name), ['bulb']);+ const floor = scene.parts.find(part => part.name === 'floor');+ assert.ok(floor.material.emissiveMap);+ assert.equal(floor.material.color[0], 0.8);+ const bulb = scene.parts.find(part => part.name === 'bulb');+ assert.equal(bulb.material.emissiveMap, undefined);+ assert.equal(createAgentScene(closedRoomWithoutBake()).parts.some(part => part.material.emissiveMap), false);+});++test('the same recipe gives the same lightmap bytes', () => {+ const first = createAgentScene(closedRoom());+ const second = createAgentScene(closedRoom());+ for (const name of ['floor', 'back', 'block']) {+ const firstBytes = lightmapBytes(first.parts.find(part => part.name === name));+ const secondBytes = lightmapBytes(second.parts.find(part => part.name === name));+ assert.ok(firstBytes.length > 0);+ assert.deepEqual(firstBytes, secondBytes);+ }+});++test('a camera edit, a motion seek and a look edit that leaves the lights reuse the bake', () => {+ const scene = createAgentScene(closedRoom({ motion: { duration: 1, tracks: [{ kind: 'node', id: 'bulb', property: 'translation', keyframes: [{ time: 0, value: [0.9, 2.5, 0.6] }, { time: 1, value: [0.9, 2.5, 0.4] }] }] } }));+ const first = scene.inspect().bake;+ const partsBefore = scene.parts.map(part => part.material.emissiveMap);+ scene.apply([{ type: 'set-camera', eye: [0.3, 1.5, 1.9] }], { expectedRevision: 0 });+ scene.sampleMotion(0.5);+ scene.apply([{ type: 'set-effects', effects: { exposure: 1.2 } }], { expectedRevision: 1 });+ const after = scene.inspect().bake;+ assert.equal(after.reused, true);+ assert.equal(after.seconds, first.seconds);+ assert.deepEqual(scene.parts.map(part => part.material.emissiveMap), partsBefore);+});++test('moving a part, changing a light or changing the bake runs it again, and clearing it removes the lightmaps', () => {+ const scene = createAgentScene(closedRoom());+ scene.apply([{ type: 'set-node', id: 'block', translation: [0.5, 0.6, -0.4] }], { expectedRevision: 0 });+ assert.equal(scene.inspect().bake.reused, false);+ scene.apply([{ type: 'set-environment', environment: { pointLights: [{ position: [0, 2.5, 0.5], intensity: 14, radius: 0.1 }] } }], { expectedRevision: 1 });+ assert.equal(scene.inspect().bake.reused, false);+ scene.apply([{ type: 'set-bake', bake: { preset: 'draft', samples: 40 } }], { expectedRevision: 2 });+ assert.equal(scene.inspect().bake.samples, 40);+ assert.equal(scene.inspect().bake.reused, false);+ scene.apply([{ type: 'set-bake', bake: null }], { expectedRevision: 3 });+ assert.equal(scene.inspect().bake, undefined);+ assert.equal(scene.parts.some(part => part.material.emissiveMap), false);+ assert.equal(scene.exportRecipe().bake, null);+});++test('a failed bake leaves the scene as it was', () => {+ const scene = createAgentScene(closedRoom());+ assert.throws(() => scene.apply([{ type: 'set-bake', bake: { samples: 5000 } }], { expectedRevision: 0 }));+ assert.equal(scene.revision, 0);+ assert.equal(scene.inspect().bake.samples, BAKE_PRESETS.draft.samples);+});diff --git a/tests/agent-render-jobs.test.js b/tests/agent-render-jobs.test.jsindex f518711f..cde83369 100644--- a/tests/agent-render-jobs.test.js+++ b/tests/agent-render-jobs.test.js@@ -166,6 +166,16 @@ test('deadline aborts a cooperative callback and close detects an uncooperativeawait hung.close();});+test('1920x1080 and 1080x1920 jobs are admitted', async context => {+ const root = await temporary(context);+ const controller = await createAgentRenderJobs({ root, limits, run: writeImage });+ for (const [width, height] of [[1920, 1080], [1080, 1920]]) {+ const { jobId } = await controller.submit({ ...request(), settings: { kind: 'image', width, height } });+ assert.equal((await terminal(controller, jobId)).settings.width, width);+ }+ await controller.close();+});+test('validation enforces range, geometry-independent storage limits and one pending frame', async context => {const root = await temporary(context);let calls = 0;@@ -176,7 +186,9 @@ test('validation enforces range, geometry-independent storage limits and one pen} });for (const settings of [{ kind: 'video', width: 65, height: 64 },- { kind: 'image', width: 1025, height: 64 },+ { kind: 'image', width: 1921, height: 64 },+ { kind: 'image', width: 1920, height: 1081 },+ { kind: 'image', width: 1920, height: 1920 },{ kind: 'video', width: 64, height: 64, fps: 31 },{ kind: 'video', width: 64, height: 64, duration: 61 },]) await assert.rejects(controller.submit({ ...request(), settings }));diff --git a/tests/agent-render-limits.test.js b/tests/agent-render-limits.test.jsnew file mode 100644index 00000000..5677092a--- /dev/null+++ b/tests/agent-render-limits.test.js@@ -0,0 +1,25 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { readFile } from 'node:fs/promises';+import { MAXIMUM_JOB_DEADLINE_MS, jobDeadlineMs } from '../scripts/agent-render-jobs.mjs';+import { DEFAULT_ENCODER_TIMEOUT_MS } from '../scripts/frame-encoder.mjs';++test('the encoder waits 30 seconds by default and no caller sets a different value', async () => {+ assert.equal(DEFAULT_ENCODER_TIMEOUT_MS, 30000);+ for (const file of ['../scripts/render-media.mjs', '../scripts/agent-runtime.mjs']) {+ const source = await readFile(new URL(file, import.meta.url), 'utf8');+ assert.doesNotMatch(source, /timeoutMs\s*:/, `${file} must use the shared encoder default.`);+ }+});++test('the job deadline grows with frames and pixels and never passes its ceiling', () => {+ const still = jobDeadlineMs({ frameCount: 1, width: 1920, height: 1080 });+ assert.ok(still > 60000 && still < 90000);+ // The film that missed five minutes on a loaded machine: 360 frames at 1024x576.+ assert.equal(jobDeadlineMs({ frameCount: 360, width: 1024, height: 576 }), 780000);+ assert.ok(jobDeadlineMs({ frameCount: 360, width: 1920, height: 1080 }) > jobDeadlineMs({ frameCount: 360, width: 1024, height: 576 }));+ assert.ok(jobDeadlineMs({ frameCount: 360, width: 64, height: 64 }) < jobDeadlineMs({ frameCount: 720, width: 64, height: 64 }));+ assert.equal(jobDeadlineMs({ frameCount: 900, width: 1920, height: 1080 }), MAXIMUM_JOB_DEADLINE_MS);+ assert.equal(jobDeadlineMs({ frameCount: 900, width: 1920, height: 1080 }, 5000), 5000);+ assert.equal(MAXIMUM_JOB_DEADLINE_MS, 30 * 60 * 1000);+});diff --git a/tests/agent-runtime.test.js b/tests/agent-runtime.test.jsindex 04b1ff50..5acfdfb7 100644--- a/tests/agent-runtime.test.js+++ b/tests/agent-runtime.test.js@@ -6,7 +6,7 @@ import { readFile } from 'node:fs/promises';import { createServer } from 'node:http';import { randomUUID } from 'node:crypto';import { createContext, Script } from 'node:vm';-import { AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE, VIDEO_ENCODERS, MAXIMUM_VIDEO_SECONDS } from '../src/agent-scene-capabilities.js';+import { AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE, VIDEO_ENCODERS, MAXIMUM_VIDEO_SECONDS, MAXIMUM_JOB_SIDE, MAXIMUM_JOB_PIXELS, MAXIMUM_MEMORY_MIB } from '../src/agent-scene-capabilities.js';import { audioInputArguments, createAudioLibrary, measureStreamSeconds } from '../scripts/job-audio.mjs';import { filmTimelineDuration, filmTimelineShotStarts, sampleFilmTimeline } from '../src/film-timeline.js';import { normalizeReview, REVIEW_LIMITS } from '../scripts/agent-review.mjs';@@ -99,7 +99,7 @@ async function reviewRuntimeHarness({ failShot, blockShot = false, oversize = faconst context = createContext({ createServer, randomUUID, existsSync: () => true,readFile: async () => '', packageMetadata: { version: 'test' },createRequire: () => ({ resolve: () => { throw new Error('no peer in tests'); } }),- AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE, VIDEO_ENCODERS, MAXIMUM_VIDEO_SECONDS,+ AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, RENDER_PASS_NAMES, RENDER_PASS_DEPTH_RANGE, VIDEO_ENCODERS, MAXIMUM_VIDEO_SECONDS, MAXIMUM_JOB_SIDE, MAXIMUM_JOB_PIXELS, MAXIMUM_MEMORY_MIB,audioInputArguments, createAudioLibrary, measureStreamSeconds, filmTimelineDuration, filmTimelineShotStarts, sampleFilmTimeline, normalizeReview, REVIEW_LIMITS, isPreviewHost, BRANCH_LIMITS, validateBranchName,chromium: { launch: async () => browser }, URL, Buffer, process, performance, setTimeout, clearTimeout,});@@ -250,7 +250,7 @@ test('runtime close promptly aborts a pending private review and skips source retest('invalid preview configuration rejects before any browser or renderer allocation', () => {assert.throws(() => createAgentRuntime({ backend: 'fake' }), /backend/);- for (const memory of [0, 31, 257, 64.5, NaN]) {+ for (const memory of [0, 31, 385, 1024, 64.5, NaN]) {assert.throws(() => createAgentRuntime({ memory }), /memory/);}assert.throws(() => createAgentRuntime({ browser: 'does-not-exist-browser.exe' }), /browser/);