Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Add --relations on|off to the agent suite and a cabinet resize task (part of #44)

Nguyen Xuan Ane47e6f6f351b
diff --git a/bench/agent-modeling/cabinet.mjs b/bench/agent-modeling/cabinet.mjs
new file mode 100644
index 00000000..022ba036
--- /dev/null
+++ b/bench/agent-modeling/cabinet.mjs
@@ -0,0 +1,98 @@
+// A cabinet of 10 parts hung on its body: a body, four feet, two doors with a handle each and a cornice. The relations
+// version states where each part sits against the body; the plain version holds the same absolute positions.
+// Resizing the cabinet moves every dependent part, which is the edit relations are meant to save.
+
+const FOOT_HEIGHT = 0.08;
+const FOOT_SIZE = 0.06;
+const FOOT_INSET = 0.04;
+const CORNICE_HEIGHT = 0.03;
+const CORNICE_OVERHANG = 0.02;
+const DOOR_THICKNESS = 0.02;
+const DOOR_MARGIN = 0.04;
+const HANDLE_SIZE = [0.02, 0.12, 0.02];
+const HANDLE_INSET = 0.04;
+const BODY_DEPTH = 0.5;
+
+function placed(withRelations, relations) {
+ return withRelations ? { relations } : {};
+}
+
+/** The cabinet for a body width and a total height (feet to cornice) in metres, body depth 0.5 m. */
+export function cabinetRecipe(width, height, withRelations) {
+ const bodyHeight = height - FOOT_HEIGHT - CORNICE_HEIGHT;
+ const bodyCentreY = FOOT_HEIGHT + bodyHeight / 2;
+ const frontZ = BODY_DEPTH / 2;
+ const parts = [
+ { id: 'body', geometry: 'block', scale: [width, bodyHeight, BODY_DEPTH], translation: [0, bodyCentreY, 0] },
+ ];
+ for (const [xName, xSign] of [['left', -1], ['right', 1]]) {
+ for (const [zName, zSign] of [['back', -1], ['front', 1]]) {
+ parts.push({
+ id: `foot-${xName}-${zName}`, geometry: 'block', scale: [FOOT_SIZE, FOOT_HEIGHT, FOOT_SIZE],
+ translation: [xSign * (width / 2 - FOOT_INSET - FOOT_SIZE / 2), FOOT_HEIGHT / 2, zSign * (BODY_DEPTH / 2 - FOOT_INSET - FOOT_SIZE / 2)],
+ ...placed(withRelations, [
+ { kind: 'gap', to: 'body', side: '-y' },
+ { kind: 'align', to: 'body', axis: 'x', at: xSign < 0 ? 'min' : 'max', offset: -xSign * FOOT_INSET },
+ { kind: 'align', to: 'body', axis: 'z', at: zSign < 0 ? 'min' : 'max', offset: -zSign * FOOT_INSET },
+ ]),
+ });
+ }
+ }
+ const doorHeight = bodyHeight - 2 * DOOR_MARGIN;
+ for (const [name, sign] of [['left', -1], ['right', 1]]) {
+ parts.push({
+ id: `door-${name}`, geometry: 'block', scale: [width / 2, doorHeight, DOOR_THICKNESS],
+ translation: [sign * width / 4, bodyCentreY, frontZ + DOOR_THICKNESS / 2],
+ ...placed(withRelations, [
+ { kind: 'gap', to: 'body', side: '+z' },
+ { kind: 'align', to: 'body', axis: 'x', at: sign < 0 ? 'min' : 'max', offset: 0 },
+ { kind: 'centered', to: 'body', axes: ['y'] },
+ ]),
+ });
+ parts.push({
+ id: `handle-${name}`, geometry: 'block', scale: HANDLE_SIZE,
+ translation: [sign * (HANDLE_INSET + HANDLE_SIZE[0] / 2), bodyCentreY, frontZ + DOOR_THICKNESS + HANDLE_SIZE[2] / 2],
+ ...placed(withRelations, [
+ { kind: 'gap', to: `door-${name}`, side: '+z' },
+ { kind: 'align', to: `door-${name}`, axis: 'x', at: sign < 0 ? 'max' : 'min', offset: sign < 0 ? -HANDLE_INSET : HANDLE_INSET },
+ { kind: 'centered', to: `door-${name}`, axes: ['y'] },
+ ]),
+ });
+ }
+ parts.push({
+ id: 'cornice', geometry: 'block', scale: [width + 2 * CORNICE_OVERHANG, CORNICE_HEIGHT, BODY_DEPTH + 2 * CORNICE_OVERHANG],
+ translation: [0, FOOT_HEIGHT + bodyHeight + CORNICE_HEIGHT / 2, 0],
+ ...placed(withRelations, [{ kind: 'attach', to: 'body', side: '+y' }]),
+ });
+ return {
+ format: '67js.scene', schemaVersion: 1,
+ geometries: [{ id: 'block', type: 'box', bevel: 0 }],
+ materials: [{ id: 'paint', color: [0.55, 0.5, 0.45] }],
+ nodes: parts.map(part => ({ material: 'paint', ...part })),
+ };
+}
+
+export const CABINET_START = cabinetRecipe(1, 1.8, true);
+export const CABINET_START_PLAIN = cabinetRecipe(1, 1.8, false);
+export const CABINET_FINAL = cabinetRecipe(1.3, 1.9, true);
+export const CABINET_FINAL_PLAIN = cabinetRecipe(1.3, 1.9, false);
+
+const touchPairs = [
+ ...['left-back', 'left-front', 'right-back', 'right-front'].map(name => ({ node: `foot-${name}`, against: 'body', side: '-y' })),
+ { node: 'door-left', against: 'body', side: '+z' },
+ { node: 'door-right', against: 'body', side: '+z' },
+ { node: 'handle-left', against: 'door-left', side: '+z' },
+ { node: 'handle-right', against: 'door-right', side: '+z' },
+ { node: 'cornice', against: 'body', side: '+y' },
+];
+
+/** Contact for every attached pair, plus where the parts must end up after the resize. */
+export const CABINET_CHECKS = [
+ { kind: 'lint' },
+ { kind: 'size', expected: [1.34, 1.9, 0.56] },
+ { kind: 'ground' },
+ ...touchPairs.map(pair => ({ kind: 'touches', ...pair })),
+ ...CABINET_FINAL.nodes
+ .filter(node => node.id !== 'body')
+ .map(node => ({ kind: 'centreAt', node: node.id, position: node.translation })),
+];
diff --git a/bench/agent-modeling/references.mjs b/bench/agent-modeling/references.mjs
index b5f4ec8b..ece5d7f5 100644
--- a/bench/agent-modeling/references.mjs
+++ b/bench/agent-modeling/references.mjs
@@ -10,6 +10,7 @@ import { KETTLE_RESIZED, KETTLE_RESIZED_PLAIN } from './kettle.mjs';
import { LAMP_SOLUTION } from './lamp.mjs';
import { GALLERY_SOLUTION } from './gallery.mjs';
import { DESK_FINAL, DESK_FINAL_PLAIN } from './desk.mjs';
+import { CABINET_FINAL, CABINET_FINAL_PLAIN } from './cabinet.mjs';
const material = [{ id: 'paint', color: [0.6, 0.55, 0.5] }];
@@ -171,6 +172,8 @@ export const REFERENCES = {
'kettle-resize-plain': KETTLE_RESIZED_PLAIN,
'desk-resize': DESK_FINAL,
'desk-resize-plain': DESK_FINAL_PLAIN,
+ 'cabinet-resize': CABINET_FINAL,
+ 'cabinet-resize-plain': CABINET_FINAL_PLAIN,
'chamfer-plate': scene(
[{
id: 'plate', type: 'mesh', base: { type: 'box', bevel: 0 }, edits: [
diff --git a/bench/agent-modeling/run.mjs b/bench/agent-modeling/run.mjs
index cedab3e0..76bae138 100644
--- a/bench/agent-modeling/run.mjs
+++ b/bench/agent-modeling/run.mjs
@@ -2,13 +2,15 @@
// server, then grades the recipe the agent exported.
//
// node bench/agent-modeling/run.mjs --claude <claude executable> [--model sonnet] [--tasks crate,bolt]
-// [--runs 3] [--budget 3] [--timeout 1200] [--label baseline] [--skill] [--branches off] [--resume <run name>]
+// [--runs 3] [--budget 3] [--timeout 1200] [--label baseline] [--skill] [--branches off] [--relations off] [--resume <run name>]
//
// --runs repeats every task that many times, each in a fresh session; the summary reports success rate, tool calls,
// tool errors, tokens and cost for the model and for each task.
// --resume continues a run that stopped early and skips the task attempts it already recorded. Pass the same --runs.
// --branches off starts the MCP server with --branches off: no branch field in any schema and no mention of variants in
// the instructions. Records carry branchCalls, the tool calls that passed a branch name, so a run shows whether agents used them.
+// --relations off does the same for relations: no relations field in the node schemas and no relations entry in
+// scene_capabilities. Records carry relationCalls, the tool calls that sent a relations list.
// --skill puts the build-67js-scene entry point and its mesh reference in the system prompt. That measures what the
// skill's knowledge is worth, not whether an agent would load the skill on its own.
//
@@ -40,6 +42,7 @@ const { values: options } = parseArgs({
label: { type: 'string', default: 'run' },
skill: { type: 'boolean', default: false },
branches: { type: 'string', default: 'on' },
+ relations: { type: 'string', default: 'on' },
resume: { type: 'string' },
},
});
@@ -58,7 +61,7 @@ async function skillPrompt() {
function mcpConfig(assetDirectory) {
return { mcpServers: { [MCP_SERVER_NAME]: {
command: process.execPath,
- args: [join(repository, 'scripts', 'mcp-server.mjs'), '--backend', 'gpu', '--memory', '192', '--branches', options.branches, ...(assetDirectory ? ['--assets', assetDirectory] : [])],
+ args: [join(repository, 'scripts', 'mcp-server.mjs'), '--backend', 'gpu', '--memory', '192', '--branches', options.branches, '--relations', options.relations, ...(assetDirectory ? ['--assets', assetDirectory] : [])],
} } };
}
@@ -102,7 +105,7 @@ function textOf(content) {
/** Tool calls, errors, the model, usage and the last exported recipe from a stream-json transcript. */
function readTranscript(output) {
- const summary = { model: null, toolCalls: 0, toolErrors: 0, toolsByName: {}, branchCalls: 0, pathQueries: 0, recipe: null, result: null };
+ const summary = { model: null, toolCalls: 0, toolErrors: 0, toolsByName: {}, branchCalls: 0, relationCalls: 0, pathQueries: 0, recipe: null, result: null };
const exportCalls = new Set();
for (const line of output.split('\n')) {
if (!line.trim().startsWith('{')) continue;
@@ -121,6 +124,8 @@ function readTranscript(output) {
if (block.name !== 'ToolSearch') summary.toolCalls++;
summary.toolsByName[name] = (summary.toolsByName[name] ?? 0) + 1;
if (block.input?.branch !== undefined || block.input?.shots?.some(shot => shot.branch !== undefined)) summary.branchCalls++;
+ // The recipe a task hands over may carry relations itself; only calls that send a non-empty list count.
+ if (JSON.stringify(block.input ?? {}).includes('"relations":[{')) summary.relationCalls++;
if (name.endsWith('scene_inspect') && block.input?.path !== undefined) summary.pathQueries++;
if (block.name === EXPORT_TOOL) exportCalls.add(block.id);
}
@@ -187,6 +192,7 @@ async function runTask(task, attempt, systemPromptAddition) {
toolErrors: transcript.toolErrors,
toolsByName: transcript.toolsByName,
branchCalls: transcript.branchCalls,
+ relationCalls: transcript.relationCalls,
pathQueries: transcript.pathQueries,
features: transcript.recipe ? recipeFeatures(transcript.recipe) : null,
look: transcript.recipe ? await scoreLookSafely(task.id, transcript.recipe, { imageDirectory: join(rawDirectory, 'look', String(attempt)) }) : null,
@@ -204,6 +210,7 @@ async function runTask(task, attempt, systemPromptAddition) {
}
if (!['on', 'off'].includes(options.branches)) throw new RangeError('--branches must be on or off');
+if (!['on', 'off'].includes(options.relations)) throw new RangeError('--relations must be on or off');
const tasks = options.tasks ? options.tasks.split(',').map(taskById) : TASKS;
await mkdir(rawDirectory, { recursive: true });
await mkdir(resultsDirectory, { recursive: true });
@@ -222,6 +229,7 @@ function summarize() {
date: new Date().toISOString(),
skill: options.skill,
branches: options.branches,
+ relations: options.relations,
runsPerTask: attempts,
passed: records.filter(record => record.pass).length,
tasks: records.length,
diff --git a/bench/agent-modeling/tasks.mjs b/bench/agent-modeling/tasks.mjs
index 4c9aa6f6..99054010 100644
--- a/bench/agent-modeling/tasks.mjs
+++ b/bench/agent-modeling/tasks.mjs
@@ -4,6 +4,7 @@
import { REFERENCES } from './references.mjs';
import { KETTLE_START, KETTLE_START_PLAIN } from './kettle.mjs';
import { DESK_START, DESK_START_PLAIN, DESK_CHECKS } from './desk.mjs';
+import { CABINET_START, CABINET_START_PLAIN, CABINET_CHECKS } from './cabinet.mjs';
import { LAMP_START, LAMP_PROMPT, LAMP_CHECKS } from './lamp.mjs';
import { GALLERY_START, GALLERY_PROMPT, GALLERY_CHECKS } from './gallery.mjs';
import { TERRAIN_TASKS } from './terrain.mjs';
@@ -64,6 +65,19 @@ const DESK_TASKS = [
{ id: 'desk-resize-plain', startRecipe: DESK_START_PLAIN, prompt: DESK_PROMPT, checks: DESK_CHECKS },
];
+// One resize of a 10-part cabinet. The plain start recipe is the one for comparing --relations on and off: the agent
+// either recomputes every dependent part or states the attachments itself.
+const CABINET_PROMPT = `The cabinet scene below has a body on four feet, two doors on its front (+Z) face that together cover the
+width of the body, a handle on each door, and a cornice on top. Make the cabinet 30% wider (body 1.3 m instead of 1 m) and
+10 cm taller (1.9 m from the ground to the top of the cornice, so only the body gets taller). Keep the body depth and the size
+of the feet, handles and cornice overhang. Afterwards the feet must still stand 0.04 m in from the body's corners, each
+door must still be half the body width, flush with its end of the body and centred in Y with a 0.04 m margin at top and bottom,
+each handle 0.04 m in from the middle seam of its door and centred in Y, and the cornice centred on top of the body.`;
+const CABINET_TASKS = [
+ { id: 'cabinet-resize', startRecipe: CABINET_START, prompt: CABINET_PROMPT, checks: CABINET_CHECKS },
+ { id: 'cabinet-resize-plain', startRecipe: CABINET_START_PLAIN, prompt: CABINET_PROMPT, checks: CABINET_CHECKS },
+];
+
const LONG_TASKS = [
{
id: 'chamfer-plate',
@@ -553,6 +567,7 @@ exported recipe is what gets graded.`,
{ id: 'render-pick', startRecipe: GALLERY_START, prompt: GALLERY_PROMPT, checks: GALLERY_CHECKS },
...KETTLE_TASKS,
...DESK_TASKS,
+ ...CABINET_TASKS,
{
id: 'robot-walk-wave',
assets: true,
diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjs
index 2a363b61..45a0a2e0 100644
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@ -565,8 +565,11 @@ function flatFieldsHint(operationType, wrapperKey) {
? `${operationType} takes its fields beside type, not inside ${wrapperKey}: {"type":"${operationType}","id":"<id>",...fields}. Move the fields of ${wrapperKey} up one level.`
: undefined;
}
-const operation = z.discriminatedUnion('type', [
- z.strictObject({ type: z.literal('set-node'), id: identifier, geometry: identifier.optional(), material: identifier.optional(), ...nodeFields }, { error: flatFieldsHint('set-node', 'node') }),
+const nodeOperations = (nodeFieldShape, nodeSchema) => [
+ z.strictObject({ type: z.literal('set-node'), id: identifier, geometry: identifier.optional(), material: identifier.optional(), ...nodeFieldShape }, { error: flatFieldsHint('set-node', 'node') }),
+ z.strictObject({ type: z.literal('add-node'), node: nodeSchema }),
+];
+const otherOperations = [
z.strictObject({ type: z.literal('set-material'), id: identifier, ...materialFields }, { error: flatFieldsHint('set-material', 'material') }),
z.strictObject({ type: z.literal('set-camera'), ...cameraFields }),
z.strictObject({ type: z.literal('set-motion'), motion: recipeMotionReference.nullable() }),
@@ -582,13 +585,22 @@ const operation = z.discriminatedUnion('type', [
z.strictObject({ type: z.literal('set-root'), translation: vector3.optional(), rotation: quaternion.optional(), scale: z.tuple([positive, positive, positive]).optional() }),
z.strictObject({ type: z.literal('set-asset-node'), id: identifier, translation: vector3.optional(), rotation: quaternion.optional(), scale: z.tuple([positive, positive, positive]).optional() }),
z.strictObject({ type: z.literal('set-animation'), clip: z.number().int().min(0).nullable().optional(), time: nonnegative.optional() }),
- z.strictObject({ type: z.literal('add-node'), node: nodeRecord }),
z.strictObject({ type: z.literal('remove-node'), id: identifier, recursive: z.boolean().optional().describe('Remove descendants too. Defaults to false; dangling children reject the batch.') }),
z.strictObject({ type: z.literal('add-geometry'), geometry }),
z.strictObject({ type: z.literal('remove-geometry'), id: identifier }),
z.strictObject({ type: z.literal('add-material'), material: z.strictObject({ id: identifier, tag: materialTag, ...materialFields }) }),
z.strictObject({ type: z.literal('remove-material'), id: identifier }),
-]);
+];
+const operation = z.discriminatedUnion('type', [...nodeOperations(nodeFields, nodeRecord), ...otherOperations]);
+// The same schemas without the relations field, for the benchmark switch --relations off.
+const { relations: _relationsField, ...nodeFieldsWithoutRelations } = nodeFields;
+const nodeRecordWithoutRelations = nodeRecord.omit({ relations: true });
+const recipeWithoutRelations = recipe.extend({ nodes: z.array(nodeRecordWithoutRelations).max(4096) });
+function withoutRelationsAdvice(capabilities) {
+ const { relations: _relationsAdvice, ...scene } = capabilities.scene;
+ return { ...capabilities, scene };
+}
+const operationWithoutRelations = z.discriminatedUnion('type', [...nodeOperations(nodeFieldsWithoutRelations, nodeRecordWithoutRelations), ...otherOperations]);
const branchName = z.string().regex(BRANCH_NAME_PATTERN).describe('Branch name, up to 24 characters.');
const labelsFlag = z.boolean().optional().describe('Draw part names, tags and lint problems on the image; returned with pixel positions.');
const sessionFields = { sessionId: z.uuid('sessionId is not a valid UUID. Leave it out to use the active scene.').optional().describe('Leave out: the active scene is used.') };
@@ -644,7 +656,7 @@ function jsonResult(value) {
return { content: [{ type: 'text', text: JSON.stringify(value) }], structuredContent: value };
}
-export function createAgentMcpServer(runtime, { version = packageMetadata.version, branches = true } = {}) {
+export function createAgentMcpServer(runtime, { version = packageMetadata.version, branches = true, relations = true } = {}) {
// Without branches the schemas carry no branch field and the instructions do not mention variants (a benchmark switch).
const branchField = branches ? { branch: branchName.optional().describe('Fork: store the result as this branch (up to 8), leaving the scene unchanged.') } : {};
const reviewBranchField = branches ? { branch: branchName.optional().describe('Render this scene_apply branch.') } : {};
@@ -684,15 +696,15 @@ export function createAgentMcpServer(runtime, { version = packageMetadata.versio
}
});
}
- register('scene_capabilities', 'Read supported recipe features and runtime budgets before authoring. Does not launch a browser.', z.strictObject({}), readOnly, async () => jsonResult(await runtime.capabilities()));
- register('scene_create', 'Create the single active render scene from a JSON recipe. Dispose an existing scene first.', z.strictObject({ recipe }), { ...edit, destructiveHint: false }, async argumentsValue => jsonResult(await runtime.create(argumentsValue)));
+ register('scene_capabilities', 'Read supported recipe features and runtime budgets before authoring. Does not launch a browser.', z.strictObject({}), readOnly, async () => jsonResult(relations ? await runtime.capabilities() : withoutRelationsAdvice(await runtime.capabilities())));
+ register('scene_create', 'Create the single active render scene from a JSON recipe. Dispose an existing scene first.', z.strictObject({ recipe: relations ? recipe : recipeWithoutRelations }), { ...edit, destructiveHint: false }, async argumentsValue => jsonResult(await runtime.create(argumentsValue)));
register('scene_asset_catalog', 'List content-bound GLB IDs from the configured local asset directory. No arbitrary paths or downloads.', z.strictObject({}), readOnly, async () => jsonResult(await runtime.assetCatalog()));
register('scene_create_asset', 'Create the active scene from a catalog GLB and editable asset recipe. Preserves supported maps, skins, morphs and clips. Dispose the existing scene first.', z.strictObject({ recipe: assetRecipe }), { ...edit, destructiveHint: false }, async argumentsValue => jsonResult(await runtime.createAsset(argumentsValue)));
register('scene_inspect', 'Read revision, counts and selected nodes. For a recipe with physics, the result lists body final positions, resting times, contacts and sensor enter/leave events. Bounds describe authored geometry rather than shader displacement.', z.strictObject({ ...sessionFields, ids: z.array(identifier).max(4096).optional().describe('Selected node IDs. Omit to inspect scene order.'), kind: z.enum(['meshes', 'hierarchy']).optional().describe('Imported assets only: hierarchy exposes stable source-node IDs and joints.'), offset: z.number().int().min(0).max(4096).optional().describe('Imported assets only: pagination offset.'), limit: z.number().int().min(1).max(4096).optional().describe('Maximum returned node records. Defaults to 64.'), includeBounds: z.boolean().optional().describe('Include world geometry bounds. Defaults to false.'), path: z.record(z.string(), z.unknown()).optional().describe('Walking route over a ground node, around holes: fields in scene_capabilities navigation.') }), readOnly, async argumentsValue => jsonResult(await runtime.inspect(argumentsValue)));
register('mesh_inspect', 'Check recipe geometries as polygon meshes: vertex, edge and face counts, triangles/quads/n-gons, connected and closed parts, face tags (top, bottom, side, left, right, front, back), bounds, and lint problems (non-manifold, inconsistent winding, inverted, degenerate, open, loose) with a suggested fix each. Also imported asset parts (mesh-0). Read-only and cached per geometry.', z.strictObject({ ...sessionFields, geometry: identifier.optional().describe('One geometry ID to check, as in mesh_edit.'), geometries: z.array(identifier).min(1).max(16).optional().describe('Geometry IDs to check. Omit both to check the first 16 geometries.') }), readOnly, async ({ geometry: geometryId, geometries, ...rest }) => jsonResult(await runtime.inspectMeshes({ ...rest, ...(geometries || geometryId ? { geometries: [...(geometries ?? []), ...(geometryId ? [geometryId] : [])] } : {}) })));
register('mesh_edit', 'Append edits to a recipe mesh geometry or an imported asset part such as mesh-0 (or replace its edit log), atomically like scene_apply: extrude, inset, delete, flip, translate with falloff, tag, loop cut, bevel, mirror, array, solidify, UV unwrap, set_position and displace with field expressions (math, noise, attributes), booleans with a primitive cutter, sculpt brush strokes and shrinkwrap onto a primitive. Edits that select no faces or break limits fail without changing the scene. Returns the new revision, render status and the mesh report with per-edit results.', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh, or an imported part such as mesh-0.'), edits: meshEdits.min(1), replace: z.boolean().optional().describe('Replace the whole edit log instead of appending.') }), edit, async argumentsValue => jsonResult(await runtime.editMesh(argumentsValue)));
register('mesh_stack', 'Set the non-destructive modifier stack of a recipe mesh geometry (ops and fields: scene_capabilities meshModifiers), evaluated after its edits, each prefix cached. apply: n moves the first n nodes into the edit log, as Blender\'s Apply modifier. Atomic like scene_apply. Returns the revision, render status and mesh report.', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh.'), stack: meshStack.optional().describe('The whole new stack. Omit to keep the current stack (for example with apply).'), apply: z.number().int().min(0).max(16).optional() }), edit, async argumentsValue => jsonResult(await runtime.setMeshStack(argumentsValue)));
- register('scene_apply', 'Atomically edit transforms, look, camera or materials. Procedural scenes support membership and set-motion authoring. Imported assets support set-root, set-asset-node, set-motion and absolute set-animation sampling. Successful batches increment revision once.', z.strictObject({ ...sessionFields, expectedRevision, operations: z.array(operation).min(1).max(256).describe('Node/material/camera/root/animation commands use flat fields. Motion, look patches and add commands contain nested records. Backend validates each scene mode before publication.'), ...branchField }), edit, async argumentsValue => jsonResult(await runtime.apply(argumentsValue)));
+ register('scene_apply', 'Atomically edit transforms, look, camera or materials. Procedural scenes support membership and set-motion authoring. Imported assets support set-root, set-asset-node, set-motion and absolute set-animation sampling. Successful batches increment revision once.', z.strictObject({ ...sessionFields, expectedRevision, operations: z.array(relations ? operation : operationWithoutRelations).min(1).max(256).describe('Node/material/camera/root/animation commands use flat fields. Motion, look patches and add commands contain nested records. Backend validates each scene mode before publication.'), ...branchField }), edit, async argumentsValue => jsonResult(await runtime.apply(argumentsValue)));
register('scene_look', 'Render the active scene as a bounded PNG, optionally with part labels. Optional authored motionTime seeks without changing revision; null restores the authored base pose. Omit to retain the last preview pose.', z.strictObject({ ...sessionFields, motionTime: z.number().min(0).max(3600).nullable().optional(), width: z.number().int().min(64).max(1024).default(768).describe('PNG width in pixels.'), height: z.number().int().min(64).max(1024).default(512).describe('PNG height in pixels.'), labels: labelsFlag }), readOnly, async argumentsValue => {
const { data, mimeType, metadata } = await runtime.look(argumentsValue);
return { content: [{ type: 'image', data, mimeType }, { type: 'text', text: JSON.stringify(metadata) }], structuredContent: metadata };
@@ -734,8 +746,8 @@ export async function runMcpCli({ argumentsValue = process.argv.slice(2),
for (let index = 0; index < argumentsValue.length; index += 2) {
const name = argumentsValue[index];
const value = argumentsValue[index + 1];
- if (!['--backend', '--browser', '--memory', '--assets', '--jobs', '--ffmpeg', '--audio', '--branches'].includes(name) || value === undefined) {
- 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>, --audio <absolute folder of .wav, .mp3, .ogg or .flac files for video jobs>, and --branches on|off (default on).`);
+ if (!['--backend', '--browser', '--memory', '--assets', '--jobs', '--ffmpeg', '--audio', '--branches', '--relations'].includes(name) || value === undefined) {
+ 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>, --audio <absolute folder of .wav, .mp3, .ogg or .flac files for video jobs>, --branches on|off and --relations on|off (both default on).`);
}
options[name.slice(2)] = name === '--memory' ? Number(value) : value;
}
@@ -744,7 +756,7 @@ export async function runMcpCli({ argumentsValue = process.argv.slice(2),
}
setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);
const { createAgentRuntime } = await import('./agent-runtime.mjs');
- const handle = serveStdio(() => createAgentMcpServer(createAgentRuntime({ ...options, previewUrl }), { version, branches: options.branches !== 'off' }), {
+ const handle = serveStdio(() => createAgentMcpServer(createAgentRuntime({ ...options, previewUrl }), { version, branches: options.branches !== 'off', relations: options.relations !== 'off' }), {
transport: new StdioServerTransport(process.stdin, process.stdout, { maxBufferSize: 2 * 1024 * 1024 }),
onerror: error => console.error(`67js MCP error: ${error.message}`),
});
diff --git a/tests/cabinet-tasks.test.js b/tests/cabinet-tasks.test.js
new file mode 100644
index 00000000..8e72060f
--- /dev/null
+++ b/tests/cabinet-tasks.test.js
@@ -0,0 +1,25 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { gradeRecipe } from '../bench/agent-modeling/check.mjs';
+import { taskById } from '../bench/agent-modeling/tasks.mjs';
+import { REFERENCES } from '../bench/agent-modeling/references.mjs';
+import { CABINET_START, CABINET_START_PLAIN } from '../bench/agent-modeling/cabinet.mjs';
+
+const failedKinds = grade => grade.results.filter(result => !result.pass).map(result => result.kind);
+
+test('the cabinet has 10 parts and the relations version differs from the plain one only by relations', () => {
+ assert.equal(CABINET_START.nodes.length, 10);
+ const stripped = CABINET_START.nodes.map(({ relations, ...node }) => node);
+ assert.deepEqual(stripped, CABINET_START_PLAIN.nodes);
+});
+
+test('both cabinet tasks accept their reference and reject a cabinet whose parts were left behind', async () => {
+ for (const id of ['cabinet-resize', 'cabinet-resize-plain']) {
+ assert.equal((await gradeRecipe(taskById(id), REFERENCES[id])).pass, true, id);
+ }
+ const bodyOnly = structuredClone(REFERENCES['cabinet-resize-plain']);
+ bodyOnly.nodes = bodyOnly.nodes.map(node => (node.id === 'body' ? node : structuredClone(CABINET_START_PLAIN.nodes.find(start => start.id === node.id))));
+ const failures = failedKinds(await gradeRecipe(taskById('cabinet-resize-plain'), bodyOnly));
+ assert.ok(failures.includes('touches'));
+ assert.ok(failures.includes('centreAt'));
+});
diff --git a/tests/mcp-tools.test.js b/tests/mcp-tools.test.js
index 0865900f..d554b943 100644
--- a/tests/mcp-tools.test.js
+++ b/tests/mcp-tools.test.js
@@ -441,6 +441,31 @@ test('branches off leaves the branch field and the variants advice out of the sc
assert.ok(!client.getInstructions().includes('branch'));
});
+test('relations off leaves the relations field and the relations capabilities out', async context => {
+ const runtime = { async close() {}, activeSessionId() { return null; }, async capabilities() { return { scene: { relations: { kinds: {} }, rigging: {} } }; } };
+ const clients = {};
+ for (const relations of [true, false]) {
+ const server = createAgentMcpServer(runtime, { relations });
+ const client = new Client({ name: `67js-relations-${relations}-test`, version: '1' });
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
+ await server.connect(serverTransport);
+ await client.connect(clientTransport);
+ context.after(async () => {
+ await client.close();
+ await server.close();
+ });
+ clients[relations] = client;
+ }
+ for (const toolName of ['scene_create', 'scene_apply']) {
+ const schemaOf = async relations => JSON.stringify((await clients[relations].listTools()).tools.find(candidate => candidate.name === toolName).inputSchema);
+ assert.ok((await schemaOf(true)).includes('"relations"'), `${toolName} offers relations by default`);
+ assert.ok(!(await schemaOf(false)).includes('"relations"'), `${toolName} must not offer relations`);
+ }
+ const capabilitiesOf = async relations => (await clients[relations].callTool({ name: 'scene_capabilities', arguments: {} })).structuredContent.scene;
+ assert.ok('relations' in await capabilitiesOf(true));
+ assert.deepEqual(Object.keys(await capabilitiesOf(false)), ['rigging']);
+});
+
test('SDK dynamic batches create resources, reject dangling edits, and restore scene membership', async context => {
const { client, sessionId } = await connect(context);
const call = (name, argumentsValue) => client.callTool({ name, arguments: argumentsValue });