@womp/spark-agent 17.9.0 → 17.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,46 @@ Notable changes to `@womp/spark-agent`, newest first. Versions follow
4
4
  [Semantic Versioning](https://semver.org/). Add an entry with each version bump; describe what
5
5
  changed for hosts and users, and how to migrate across breaking changes.
6
6
 
7
+ ## 17.11.0 — 2026-12-06
8
+
9
+ ### Added
10
+
11
+ - `womp.scene.estimateReferenceCamera({ views })` estimates the one camera setup a set of reference views
12
+ (front, right, back, left) was taken with: side-view turn toward the front, look-down and distance in
13
+ subject heights, or no perspective. It asks the run's model twice, without tools, at high reasoning
14
+ effort, averages the answers, and fixes the camera for those pictures. On 12 test renders with known
15
+ cameras the side turn is within about 0.5° and the look-down within about 1°. It takes about 3 minutes
16
+ and runs as a service wait, outside the JavaScript time budget.
17
+ - `womp.scene.compareToReferences({ views, ids, bands })` measures the build against every view from that
18
+ fixed camera, estimating it first when needed, so only the shape differs.
19
+ - `SparkInvocationContext.look`: one tool-less call to the run's model with labelled images, for
20
+ capabilities. `createSparkTools` provides it when given the run's `model`; `createSparkAgent` passes it.
21
+
22
+ ### Changed
23
+
24
+ - `compareToReference` accepts the full screenshot `fit`, including `projection` and
25
+ `horizontalFovDegrees`, and no longer flattens the direction to level, so a reference taken from above
26
+ or with perspective is matched from its own camera.
27
+ - Comparison screenshots are captured on a flat green matte (`SceneScreenshotOptions.matte`) and the
28
+ scene's backdrop is restored after, so the build's outline keys cleanly against floors and shadows.
29
+
30
+ ## 17.10.0 — 2026-12-03
31
+
32
+ ### Added
33
+
34
+ - Misuse check, `@womp/spark-agent/misuse`: tells a message asking Spark for 3D work from one that
35
+ repurposes Spark as a general-purpose model (a block posing as a system, host or tool channel,
36
+ a new name or job, file and shell markers for another program, instructions to ignore Spark's
37
+ own, another agent's transcripts, or unrelated general work). It exports the Jev question
38
+ (`SPARK_MISUSE_QUESTION`, asked under `SPARK_MISUSE_QUESTION_KEY` with `SPARK_MISUSE_MODEL`), the
39
+ state Jev classifies (`sparkMisuseState`: the final message alone, its middle left out when long,
40
+ nothing for messages under 100 characters), `readSparkMisuseDecision` and `sparkMisuseFlagged`
41
+ (Jev's `repurpose` probability at or above `MISUSE_FLAG_PROBABILITY`). Hosts call Jev and record
42
+ the flag; crow runs it on every submit.
43
+ - `yarn misuse-bench` (`misuse-bench` bin): runs the labelled cases in `src/misuse-bench-cases.ts`
44
+ through Jev and reports recall, the false-positive rate, the `repurpose` probability on each label
45
+ and both rates at each candidate threshold; `--gate` for CI, `--replay` to rescore a report.
46
+
7
47
  ## 17.9.0 — 2026-12-02
8
48
 
9
49
  ### Added
package/README.md CHANGED
@@ -318,34 +318,30 @@ the case does not expect. Model calls are paid; the full set costs about $0.10 o
318
318
  ## Measure build quality
319
319
 
320
320
  `yarn quality-bench` builds cases from `bench/quality/cases/` (split into `tune` and `holdout`),
321
- renders standardized same-camera views (fixed 3/4, 4 sides, 5-view turntable, 2×2 grid, and case
322
- close-ups), counts deterministic SDF structure (top-level Areas, same-material seams, Cubes, curves,
321
+ renders standardized same-camera views (fixed 3/4, 4 sides, 5-view turntable and a 2×2 grid),
322
+ counts deterministic SDF structure (top-level Areas, same-material seams, Cubes, curves,
323
323
  curve ribbing depth, floating clusters), and exports one full-resolution lossless PNG comparison
324
324
  sheet per repeat (`sheet-run-<n>.png`) alongside `report.json`, `report.md`, and `results.csv`.
325
- AI vision judges are opt-in via `--judge` (default `false`); blinded order-swapped pairwise
326
- comparisons between two runs use `--ab`.
325
+ Blinded order-swapped pairwise comparisons between two runs use `--ab`.
327
326
 
328
327
  ```sh
329
328
  git lfs pull # case images are stored in git LFS
330
329
  yarn quality-bench # every case, 2 repeats, 32 builds at once
331
330
  yarn quality-bench --only kiko,retro-car --repeat 1 --output .spark/quality/my-run
332
- yarn quality-bench --split tune --judge # run tune split with AI vision judges
331
+ yarn quality-bench --split tune # run the tune split
333
332
  yarn quality-bench --sheet .spark/quality/my-run # regenerate sheet-run-<n>.png without rebuilding
334
333
  yarn quality-bench --ab .spark/quality/cand --baseline .spark/quality/base
335
334
  ```
336
335
 
337
336
  Builds share one Kakapo through an in-process `kakapo-mux` (below). If Kakapo starts with an empty
338
337
  scene, the bench seeds a minimal root scene automatically. Each build, with its `scene.json`,
339
- renders, timings, and optional judge answers, is saved under
338
+ renders and timings, is saved under
340
339
  `.spark/quality/<timestamp>/<case>/run-<n>/`. With `--baseline <report.json>`, `report.md` adds
341
340
  each metric's change and marks changes beyond two standard errors. `--score-only <run-dir>`
342
- re-renders and scores saved `scene.json` files to recover after a Kakapo crash.
341
+ recounts structure and renders missing views from saved `scene.json` files after a Kakapo crash.
343
342
 
344
- A case is a directory with `case.json` (`id`, `split`, `prompt`, `images`, `reference`, `parts`,
345
- `checks`) and its images. Check views frame a band of the build's height (`band`) or the parts
346
- whose names match a pattern (`match`, optionally one `half`), from the side the build faces turned
347
- by `turn` degrees, with a `label` that tells the judge what it shows. See `src/quality-bench.ts`
348
- for the fields.
343
+ A case is a directory with `case.json` (`id`, `split`, `prompt`, `images`, `reference`) and its
344
+ images. See `src/quality-bench.ts` for the fields.
349
345
 
350
346
  ### Share one Kakapo between benches
351
347
 
@@ -1,4 +1,4 @@
1
- import { type Tool } from "ai";
1
+ import { generateText, type LanguageModel, type Tool } from "ai";
2
2
  import type { ExecutionReceipt, SparkArtifactResolver, SparkCapabilities } from "./capabilities.js";
3
3
  import type { JavaScriptExecutor } from "./executor.js";
4
4
  import { type SparkGoalRequest, type SparkGoalResult } from "./goals.js";
@@ -28,6 +28,9 @@ export type SparkToolOptions = {
28
28
  /** Present when the host runs goals: the model then has `goal`. */
29
29
  handleGoal?: SparkGoalHandler;
30
30
  write(chunk: SparkUIMessageChunk): void;
31
+ /** The run's model, for capabilities that ask it one-off questions (`look`). */
32
+ model?: LanguageModel;
33
+ providerOptions?: Parameters<typeof generateText>[0]["providerOptions"];
31
34
  };
32
35
  type SparkTool<Name extends keyof SparkUITools> = Tool<SparkUITools[Name]["input"], SparkUITools[Name]["output"]>;
33
36
  type SparkCoreTools = {
@@ -1,9 +1,39 @@
1
- import { tool } from "ai";
1
+ import { generateText, tool } from "ai";
2
2
  import { z } from "zod";
3
3
  import { boundedResultText, canonicalJsonValue } from "./bounded-output.js";
4
4
  import { completedInputString } from "./tool-input-label.js";
5
5
  import { UserWait } from "./execution-lifetime.js";
6
6
  import { GOAL_MORE_TRIES, sparkGoalRequestSchema } from "./goals.js";
7
+ /** One tool-less call to the run's model with labelled images. */
8
+ async function look(options, request, signal) {
9
+ if (!options.model)
10
+ throw new Error("This run has no model to look with.");
11
+ const given = options.providerOptions ?? {};
12
+ const effort = request.effort;
13
+ // The run's provider options with only the reasoning effort changed.
14
+ const providerOptions = effort ? {
15
+ ...given,
16
+ ...(given.openai ? { openai: { ...given.openai, reasoningEffort: effort } } : {}),
17
+ ...(given.anthropic ? { anthropic: { ...given.anthropic, effort } } : {}),
18
+ ...(given.google ? { google: { ...given.google, thinkingConfig: { ...given.google.thinkingConfig, thinkingLevel: effort } } } : {}),
19
+ } : given;
20
+ const result = await generateText({
21
+ model: options.model,
22
+ providerOptions,
23
+ abortSignal: signal,
24
+ messages: [{
25
+ role: "user",
26
+ content: [
27
+ { type: "text", text: request.prompt },
28
+ ...request.images.flatMap(image => [
29
+ { type: "text", text: `Image: ${image.label}` },
30
+ { type: "file", data: image.data, mediaType: image.mediaType },
31
+ ]),
32
+ ],
33
+ }],
34
+ });
35
+ return { text: result.text, inputTokens: result.usage.inputTokens, outputTokens: result.usage.outputTokens };
36
+ }
7
37
  function errorMessage(error) {
8
38
  return error instanceof Error ? error.message : String(error);
9
39
  }
@@ -181,6 +211,7 @@ export function createSparkTools(options) {
181
211
  toolCallId,
182
212
  signal,
183
213
  resolveArtifact: (reference) => options.artifacts.resolve(reference),
214
+ ...(options.model ? { look: (request) => look(options, request, signal) } : {}),
184
215
  waitForService: (label, action) => serviceWait.wait(signal, async () => {
185
216
  context.reportStatus("running", label);
186
217
  try {
@@ -41,6 +41,8 @@ export type SceneScreenshotOptions = {
41
41
  * the camera with `fitSceneCamera`; one that does not captures `camera` as given.
42
42
  */
43
43
  fitted?: SceneScreenshotFitted;
44
+ /** Capture on a flat green backdrop so the subject's outline keys cleanly; the scene's backdrop is restored after. */
45
+ matte?: boolean;
44
46
  };
45
47
  /** Frame objects or a box instead of placing the camera by hand. */
46
48
  export type SceneScreenshotFit = {
@@ -67,10 +69,10 @@ export type SceneReferenceComparisonRequest = {
67
69
  /** A picture of the subject seen straight on from `fit.direction`, such as an attached front, side or back view. */
68
70
  reference: ArtifactRef;
69
71
  /**
70
- * What to frame and from where; orthographic. Defaults to every visible object from the front, {x: 0, y: 0, z: 1}.
71
- * The build is always seen level, from the direction's horizontal part, so the floor stays out of its outline.
72
+ * What to frame and the camera the reference picture was taken with: its direction (turn and elevation) and lens
73
+ * (projection, horizontalFovDegrees). Defaults to every visible object, level and orthographic from the front.
72
74
  */
73
- fit?: Omit<SceneScreenshotFit, "projection" | "horizontalFovDegrees">;
75
+ fit?: SceneScreenshotFit;
74
76
  /** Horizontal bands the outlines are split into, top to bottom, 2 to 40; defaults to 10. */
75
77
  bands?: number;
76
78
  };
@@ -80,15 +82,50 @@ export type SceneReferenceComparisonRequest = {
80
82
  * fractions of the outline's height; centres are + toward the picture's right.
81
83
  */
82
84
  export type SceneReferenceComparison = SilhouetteComparison & {
83
- /** The orthographic screenshot that was compared; emitImage it to look. */
85
+ /** The screenshot that was compared, on a flat backdrop; emitImage it to look. */
84
86
  screenshot: ArtifactRef;
85
87
  };
88
+ /** One camera setup shared by every view of a reference set, described as a photographer would, independent of cropping. */
89
+ export type SceneReferenceCamera = {
90
+ /** Degrees each side view is turned from straight side-on toward the subject's front (+Z); 0 for exact side views. */
91
+ sideTurnDegrees: number;
92
+ /** Degrees the camera looks down at the subject; negative looks up. */
93
+ lookDownDegrees: number;
94
+ /** Camera distance from the subject's centre in subject heights; null for pictures with no perspective. */
95
+ distanceInHeights: number | null;
96
+ };
97
+ export type SceneReferencesComparisonRequest = {
98
+ /** The reference pictures and which nominal view each is: front (+Z), back, right (seen from -X) or left (from +X). */
99
+ views: {
100
+ reference: ArtifactRef;
101
+ view: "front" | "back" | "right" | "left";
102
+ }[];
103
+ /** Objects to frame; defaults to every visible object. */
104
+ ids?: number[];
105
+ /** Horizontal bands the outlines are split into, 2 to 40; defaults to 10. */
106
+ bands?: number;
107
+ };
108
+ export type SceneReferencesComparison = {
109
+ /** Mean overlap over the views. */
110
+ overlap: number;
111
+ /** The camera the views were measured from. */
112
+ camera: SceneReferenceCamera;
113
+ views: (SceneReferenceComparison & {
114
+ view: string;
115
+ })[];
116
+ };
86
117
  export type WompSceneApi = {
87
118
  health(objectIds?: number[]): Promise<SceneHealth>;
88
119
  access<T>(callback: (draft: WompSceneDraft) => T | Promise<T>): Promise<T>;
89
120
  screenshot(options?: SceneScreenshotRequest): Promise<ArtifactRef>;
90
121
  /** Measures how the build's outline differs from a reference picture taken from a known direction. */
91
122
  compareToReference(request: SceneReferenceComparisonRequest): Promise<SceneReferenceComparison>;
123
+ /** Estimates, from the pictures alone, the one camera setup every view of a reference set was taken with, and fixes it for later comparisons. */
124
+ estimateReferenceCamera(request: {
125
+ views: SceneReferencesComparisonRequest["views"];
126
+ }): Promise<SceneReferenceCamera>;
127
+ /** Measures the build against every view of a reference set from one shared camera setup. */
128
+ compareToReferences(request: SceneReferencesComparisonRequest): Promise<SceneReferencesComparison>;
92
129
  };
93
130
  export interface SceneHealthHost {
94
131
  read(objectIds: number[], context: SparkInvocationContext): Promise<SceneHealth>;
@@ -164,7 +201,19 @@ export declare const screenshotOptions: z.ZodObject<{
164
201
  horizontalFovDegrees: z.ZodOptional<z.ZodNumber>;
165
202
  unitMultiplier: z.ZodNumber;
166
203
  }, z.core.$strict>>;
204
+ matte: z.ZodOptional<z.ZodBoolean>;
167
205
  }, z.core.$strict>;
206
+ /** Fixes camera for these reference pictures, so every later comparison of any of them measures from it. */
207
+ export declare function fixReferenceCamera(fixed: Map<string, SceneReferenceCamera>, referenceIds: string[], camera: SceneReferenceCamera): SceneReferenceCamera;
208
+ /** The fit for one nominal view taken with a shared photographer camera, in Spark coordinates (front +Z). */
209
+ export declare function referenceViewFit(view: "front" | "back" | "right" | "left", camera: SceneReferenceCamera): SceneScreenshotFit;
210
+ type ReferenceView = "front" | "back" | "right" | "left";
211
+ /** The question the model is asked about the pictures: the orbit camera they were taken with. */
212
+ export declare function referenceCameraPrompt(views: ReferenceView[]): string;
213
+ /** The camera in one answer to referenceCameraPrompt, or undefined when it has none. */
214
+ export declare function parseReferenceCamera(text: string): SceneReferenceCamera | undefined;
215
+ /** The mean of several estimates; distance is averaged as perspective strength (1 / distance), with none counting as 0. */
216
+ export declare function averageReferenceCameras(cameras: SceneReferenceCamera[]): SceneReferenceCamera;
168
217
  /**
169
218
  * Camera fitted to `fitted` for a frame of `aspect` (width / height), in Womp scene coordinates and project units.
170
219
  * Hosts that know their capture aspect call this to refit a fitted screenshot.
@@ -48,28 +48,83 @@ export const screenshotOptions = z.object({
48
48
  horizontalFovDegrees: z.number().finite().optional(),
49
49
  unitMultiplier: z.number().finite().positive(),
50
50
  }).strict().optional(),
51
+ matte: z.boolean().optional(),
52
+ }).strict();
53
+ const screenshotFit = z.object({
54
+ ids: z.array(objectId).optional(),
55
+ box: cameraBox.optional(),
56
+ direction: cameraVector.optional(),
57
+ projection: cameraProjection.optional(),
58
+ horizontalFovDegrees: z.number().finite().gt(0).lt(180).optional(),
59
+ margin: z.number().finite().min(1).max(4).optional(),
51
60
  }).strict();
52
61
  const screenshotRequest = z.object({
53
62
  camera: explicitCamera.optional(),
54
- fit: z.object({
55
- ids: z.array(objectId).optional(),
56
- box: cameraBox.optional(),
57
- direction: cameraVector.optional(),
58
- projection: cameraProjection.optional(),
59
- horizontalFovDegrees: z.number().finite().gt(0).lt(180).optional(),
60
- margin: z.number().finite().min(1).max(4).optional(),
61
- }).strict().optional(),
63
+ fit: screenshotFit.optional(),
62
64
  }).strict().refine(value => !(value.camera && value.fit), "Pass either camera or fit, not both.");
63
65
  const comparisonRequest = z.object({
64
66
  reference: z.object({ id: z.string().min(1), mediaType: z.string(), name: z.string().optional() }).passthrough(),
65
- fit: z.object({
66
- ids: z.array(objectId).optional(),
67
- box: cameraBox.optional(),
68
- direction: cameraVector.optional(),
69
- margin: z.number().finite().min(1).max(4).optional(),
70
- }).strict().optional(),
67
+ fit: screenshotFit.optional(),
68
+ bands: z.number().int().min(2).max(40).optional(),
69
+ }).strict();
70
+ const multiComparisonRequest = z.object({
71
+ views: z.array(z.object({
72
+ reference: z.object({ id: z.string().min(1), mediaType: z.string(), name: z.string().optional() }).passthrough(),
73
+ view: z.enum(["front", "back", "right", "left"]),
74
+ }).strict()).min(1).max(8),
75
+ ids: z.array(objectId).optional(),
71
76
  bands: z.number().int().min(2).max(40).optional(),
72
77
  }).strict();
78
+ /** Fixes camera for these reference pictures, so every later comparison of any of them measures from it. */
79
+ export function fixReferenceCamera(fixed, referenceIds, camera) {
80
+ for (const id of referenceIds)
81
+ fixed.set(id, camera);
82
+ return camera;
83
+ }
84
+ /** The fit for one nominal view taken with a shared photographer camera, in Spark coordinates (front +Z). */
85
+ export function referenceViewFit(view, camera) {
86
+ const base = { front: [0, 1], back: [0, -1], right: [-1, 0], left: [1, 0] }[view];
87
+ const side = view === "right" || view === "left";
88
+ const turn = side ? (camera.sideTurnDegrees * Math.PI) / 180 : 0;
89
+ const x = base[0] * Math.cos(turn), z = Math.sin(turn) + base[1] * Math.cos(turn);
90
+ const direction = { x, y: Math.tan((camera.lookDownDegrees * Math.PI) / 180), z };
91
+ return camera.distanceInHeights === null
92
+ ? { direction, projection: "orthographic" }
93
+ : { direction, projection: "perspective", horizontalFovDegrees: (2 * Math.atan(1 / camera.distanceInHeights) * 180) / Math.PI };
94
+ }
95
+ const VIEW_LABEL = { front: "its front", right: "its right side", back: "its back", left: "its left side" };
96
+ /** The question the model is asked about the pictures: the orbit camera they were taken with. */
97
+ export function referenceCameraPrompt(views) {
98
+ return `These ${views.length} images show the same subject: ${views.map(v => VIEW_LABEL[v]).join(", ")}, all taken with one orbit camera aimed at the subject's middle.
99
+
100
+ Estimate that orbit camera. Reply with JSON only:
101
+ {"sideAzimuthDeg": angle of the side-view cameras measured from straight in front of the subject (90 = exact profile, less than 90 = moved toward the front), "elevationDeg": camera angle above the aim point, "distanceInHeights": camera distance from the aim point in subject heights (null if the images have no perspective), "verticalFovDeg": full vertical field of view}`;
102
+ }
103
+ /** The camera in one answer to referenceCameraPrompt, or undefined when it has none. */
104
+ export function parseReferenceCamera(text) {
105
+ try {
106
+ const a = JSON.parse(text.slice(text.indexOf("{"), text.lastIndexOf("}") + 1));
107
+ const azimuth = Number(a.sideAzimuthDeg), elevation = Number(a.elevationDeg);
108
+ const d = a.distanceInHeights === null || a.distanceInHeights === undefined ? null : Number(a.distanceInHeights);
109
+ if (!Number.isFinite(azimuth) || !Number.isFinite(elevation) || (d !== null && !(d > 0.3)))
110
+ return undefined;
111
+ const clamp = (x) => Math.max(-60, Math.min(60, x));
112
+ return { sideTurnDegrees: clamp(90 - azimuth), lookDownDegrees: clamp(elevation), distanceInHeights: d };
113
+ }
114
+ catch {
115
+ return undefined;
116
+ }
117
+ }
118
+ /** The mean of several estimates; distance is averaged as perspective strength (1 / distance), with none counting as 0. */
119
+ export function averageReferenceCameras(cameras) {
120
+ const mean = (f) => cameras.reduce((sum, c) => sum + f(c), 0) / cameras.length;
121
+ const perspective = mean(c => (c.distanceInHeights === null ? 0 : 1 / c.distanceInHeights));
122
+ return {
123
+ sideTurnDegrees: mean(c => c.sideTurnDegrees),
124
+ lookDownDegrees: mean(c => c.lookDownDegrees),
125
+ distanceInHeights: perspective > 0 ? 1 / perspective : null,
126
+ };
127
+ }
73
128
  const DEFAULT_FIT_DIRECTION = { x: 1, y: 0.65, z: 1 };
74
129
  const LIGHT = 2, GROUP = 4;
75
130
  /**
@@ -134,11 +189,13 @@ async function fitBoxes(draft, fit) {
134
189
  return boxes;
135
190
  }
136
191
  export function createSceneCapability(host) {
192
+ // The camera estimated for each reference picture, fixed for later comparisons; artifact ids are unique.
193
+ const referenceCameras = new Map();
137
194
  return {
138
195
  skills: [
139
196
  {
140
197
  name: "scene-editing",
141
- version: "80",
198
+ version: "81",
142
199
  description: "Inspect the open scene and edit its objects, materials, curves, and environment.",
143
200
  instructions: `Use womp.scene.access(callback) for both inspection and edits. Inspect targets inside each callback using scene.nodes({ name, type, parentId, ids, offset, limit }) and detailed getters; filters are optional, name is a case-insensitive substring, and results default to 100 (maximum 1000). Page with offset as needed. Inspection reflects changes made in the callback. scene.unitMultiplier gives project units. Do not reuse an earlier inspection as current state.
144
201
  Use womp.scene.health() to refresh whole-scene health or womp.scene.health(objectIds) to check specific objects (mapped to their owning Areas).
@@ -250,12 +307,16 @@ three-quarter view {x: 1, y: 0.65, z: 1}. The front faces +Z, so {x: 0, y: 0.1,
250
307
  {x: 1, y: 0.1, z: 0} shows the subject's own left side. projection defaults to orthographic; margin defaults to 1.1.
251
308
  To match a reference image's viewpoint, give fit the direction it was taken from with projection: 'perspective' and a
252
309
  horizontalFovDegrees matching its lens (narrower for a flatter, telephoto look).
253
- Several views of one subject, such as front, side and back views or a turnaround sheet, are near-orthographic and share
310
+ Several views of one subject, such as front, side and back views or a turnaround sheet, share
254
311
  one scale. Take heights from any view, widths and left-right positions from the front and back, and depths and
255
312
  front-to-back positions from the side views; a side view whose subject faces the picture's right edge shows its own
256
- right side, seen from -X. Measure the build against each straight-on view with compareToReference({ reference, fit:
257
- { direction } }) ({x: 0, y: 0, z: 1} front, {x: -1, y: 0, z: 0} its right side, {x: 0, y: 0, z: -1} back, {x: 1, y: 0, z: 0}
258
- its left side): it returns the outlines' overlap, width/height ratio and, per height band, both widths and centres as
313
+ right side, seen from -X. Several views of one subject were taken with one camera setup. Before building, call
314
+ estimateReferenceCamera({ views: [{ reference, view: 'front' | 'right' | 'back' | 'left' }, ...] }): it estimates that
315
+ camera from the pictures (sideTurnDegrees from side-on toward the front, lookDownDegrees, distanceInHeights; null for no
316
+ perspective) and fixes it for them. Allow for its turn, look-down and perspective when reading sizes off the pictures.
317
+ Measure the build against all views with compareToReferences({ views }), which measures from the fixed camera, so the
318
+ shape alone differs.
319
+ compareToReference({ reference, fit }) measures a single picture. Each view returns the outlines' overlap, width/height ratio and, per height band, both widths and centres as
259
320
  fractions of the height, so a band whose build width or centre differs from the reference's names the part to resize or
260
321
  move. reference is the view's artifact, such as an attached image's from womp.assets.list. Fix the largest
261
322
  differences, measure again, and look at the returned screenshot.
@@ -354,17 +415,49 @@ A failed script can retain earlier committed effects. Use receipts and inspect u
354
415
  const request = comparisonRequest.parse(input);
355
416
  if (!context.resolveArtifact)
356
417
  throw new Error("This host cannot read artifacts, so compareToReference is unavailable.");
357
- const { x, z } = request.fit?.direction ?? { x: 0, z: 1 };
358
- const length = Math.hypot(x, z);
359
- if (length < 1e-6)
360
- throw new Error("compareToReference needs a direction with a horizontal part, such as {x: 0, y: 0, z: 1} for the front.");
361
- const direction = { x: x / length, y: 0, z: z / length };
362
- const shot = await screenshot({ fit: { ...request.fit, direction, projection: "orthographic" } });
418
+ const shot = await screenshot({ fit: { direction: { x: 0, y: 0, z: 1 }, ...request.fit } }, true);
363
419
  const [reference, build] = await Promise.all([context.resolveArtifact(request.reference), context.resolveArtifact(shot)]);
364
- return { ...(await compareSilhouettes(reference.data, build.data, request.bands ?? 10)), screenshot: shot };
420
+ return { ...(await compareSilhouettes(reference.data, build.data, request.bands ?? 10, { matteBuild: true })), screenshot: shot };
421
+ },
422
+ estimateReferenceCamera: async (input) => {
423
+ const { views } = multiComparisonRequest.pick({ views: true }).parse(input);
424
+ return fixReferenceCamera(referenceCameras, views.map(v => v.reference.id), await estimateCamera(views));
425
+ },
426
+ compareToReferences: async (input) => {
427
+ const request = multiComparisonRequest.parse(input);
428
+ if (!context.resolveArtifact)
429
+ throw new Error("This host cannot read artifacts, so compareToReferences is unavailable.");
430
+ const ids = request.views.map(v => v.reference.id);
431
+ const camera = fixReferenceCamera(referenceCameras, ids, ids.map(id => referenceCameras.get(id)).find(Boolean) ?? (await estimateCamera(request.views)));
432
+ const views = [];
433
+ for (const { reference, view } of request.views) {
434
+ const shot = await screenshot({ fit: { ...referenceViewFit(view, camera), ...(request.ids ? { ids: request.ids } : {}) } }, true);
435
+ const [ref, build] = await Promise.all([context.resolveArtifact(reference), context.resolveArtifact(shot)]);
436
+ views.push({ view, ...(await compareSilhouettes(ref.data, build.data, request.bands ?? 10, { matteBuild: true })), screenshot: shot });
437
+ }
438
+ const overlap = views.reduce((sum, v) => sum + v.overlap, 0) / views.length;
439
+ return { overlap, camera, views };
365
440
  },
366
441
  };
367
- async function screenshot(options) {
442
+ // Two independent one-shot estimates, averaged: the model's error per call is mostly noise.
443
+ async function estimateCamera(views) {
444
+ const { resolveArtifact, look } = context;
445
+ if (!resolveArtifact || !look)
446
+ throw new Error("This host cannot show pictures to the model, so the reference camera cannot be estimated.");
447
+ const images = await Promise.all(views.map(async ({ reference, view }) => {
448
+ const { artifact, data } = await resolveArtifact(reference);
449
+ return { label: VIEW_LABEL[view], data, mediaType: artifact.mediaType };
450
+ }));
451
+ const prompt = referenceCameraPrompt(views.map(v => v.view));
452
+ // A few minutes of reasoning: a service wait, outside the JavaScript time budget.
453
+ const ask = () => Promise.all([0, 1].map(() => look({ prompt, images, effort: "high" })));
454
+ const answers = context.waitForService ? await context.waitForService("Estimating the reference camera", ask) : await ask();
455
+ const cameras = answers.map(a => parseReferenceCamera(a.text)).filter((c) => c !== undefined);
456
+ if (!cameras.length)
457
+ throw new Error("The camera could not be estimated from these pictures.");
458
+ return averageReferenceCameras(cameras);
459
+ }
460
+ async function screenshot(options, matte = false) {
368
461
  const request = screenshotRequest.parse(options ?? {});
369
462
  if (!request.fit)
370
463
  return host.screenshot(request.camera ? { camera: request.camera } : {}, context);
@@ -377,7 +470,7 @@ A failed script can retain earlier committed effects. Use receipts and inspect u
377
470
  margin: fit.margin ?? 1.1,
378
471
  ...(fit.projection === "perspective" ? { horizontalFovDegrees: fit.horizontalFovDegrees ?? 60 } : {}),
379
472
  };
380
- return host.screenshot({ camera: fitSceneCamera(fitted), fitted }, context);
473
+ return host.screenshot({ camera: fitSceneCamera(fitted), fitted, ...(matte ? { matte } : {}) }, context);
381
474
  }
382
475
  },
383
476
  };
@@ -52,6 +52,16 @@ export type ExecutionReceipt = {
52
52
  target?: Record<string, string | number>;
53
53
  details?: Record<string, unknown>;
54
54
  };
55
+ export type SparkLookRequest = {
56
+ prompt: string;
57
+ images: {
58
+ label: string;
59
+ data: Uint8Array;
60
+ mediaType: string;
61
+ }[];
62
+ /** Reasoning effort, where the model has it; defaults to the run's. */
63
+ effort?: "low" | "medium" | "high";
64
+ };
55
65
  export type SparkInvocationContext = {
56
66
  runId: string;
57
67
  toolCallId: string;
@@ -63,6 +73,12 @@ export type SparkInvocationContext = {
63
73
  artifact: SparkArtifact;
64
74
  data: Uint8Array;
65
75
  }>;
76
+ /** One call to the run's model with labelled images and a question, without tools or the conversation; returns its text and token usage. */
77
+ look?(request: SparkLookRequest): Promise<{
78
+ text: string;
79
+ inputTokens?: number;
80
+ outputTokens?: number;
81
+ }>;
66
82
  /** Trusted host wait; the host owns checkpointing and reconnecting its effect. */
67
83
  waitForService?<T>(label: string, action: (signal: AbortSignal) => Promise<T>): Promise<T>;
68
84
  /** Wait for an actual user interaction, outside mutation locks and service work. */
@@ -1 +1 @@
1
- export declare const WOMP_SCENE_DECLARATIONS = "declare const womp: { scene: {\nhealth: ((objectIds?: number[]) => Promise<{\nstatus: \"within_limits\" | \"overflow\" | \"unverified\";\nfreshness: \"unverified\" | \"snapshot\" | \"post_ack_event\";\nrevisionVerified: false;\naffectedAreaIds: string[];\nemptyAreaIds?: string[];\nthermometer?: {\nobjects: {\n[key: string]: {\nnum_prims: number;\nflag_prim_overflow: number;\nflag_depth_overflow: number;\nflag_vox_overflow: number;\nvoxels: number;\n};\n};\nmax_num_prims: number;\nmax_total_depth: number;\nmax_per_object: number;\ntotal: number;\nmax_total: number;\nassets_budget_used: number;\nassets_budget_total: number;\nmesh_instances_used?: number;\nmesh_instances_total?: number;\ndecal_instances_used?: number;\ndecal_instances_total?: number;\nfield_instances_used?: number;\nfield_instances_total?: number;\n};\nreason?: string;\n}>);\naccess: (<T>(callback: ((draft: {\nlistSuperMaterials: (() => string[]);\n_getParentId: ((childId: number) => number);\n_getScaleProductUpTo: ((nodeId: number, includeNodeSelfUnion?: boolean) => number);\nNodeType: {\nPrimitive: 0;\nUnion: 1;\nLight: 2;\nCurve: 3;\nGroup: 4;\nText: 5;\nField: 6;\nSVG: 7;\nMesh: 8;\nDecal: 9;\nOpenSCAD: 10;\nSocket: 11;\n} & { [key: number]: string; };\nPrimitiveType: { Sphere: 0; Cylinder: 1; Cube: 2; Cone: 3; Torus: 4; Pyramid: 9; Ellipsoid: 12; Capsule: 13; } & { [key: number]: string; };\nOperationType: { Subtract: 0; Union: 1; Stain: 2; Intersect: 3; } & { [key: number]: string; };\nLightType: { Rect: 0; Sphere: 1; Distant: 2; } & { [key: number]: string; };\nnodeCreate: ((type: number, parentId?: number) => number);\nnodeDelete: ((id: number) => void);\ncloneSubtree: ((id: number, options?: { parentId?: number; name?: string; index?: number; }) => Promise<number>);\nnodeList: (() => number[]);\nnodeChildren: ((parentId: number) => number[]);\nnodeSetParent: ((id: number, parentId: number, index?: number) => void);\nnodeGetType: ((id: number) => number);\nnodeGetName: ((id: number) => string);\nnodeSetName: ((id: number, name: string) => void);\nnodeGetParentId: ((id: number) => number);\nnodeGetPos: ((id: number) => { x: number; y: number; z: number; });\nnodeGetLock: ((id: number) => boolean);\nnodeSetLock: ((id: number, locked: boolean) => void);\nnodeSetPos: ((id: number, position: { x: number; y: number; z: number; }) => void);\nnodeGetRot: ((id: number) => { x: number; y: number; z: number; });\nnodeSetRot: ((id: number, rotation: { x: number; y: number; z: number; }) => void);\nnodeGetSize: ((id: number) => { x: number; y: number; } | { x: number; y: number; z: number; });\nnodeSetSize: ((id: number, sizeValue: { x: number; y: number; } | { x: number; y: number; z: number; }) => void);\nnodeGetSvgPaths: ((id: number) => {\nsegments: {\npoint: { x: number; y: number; };\nhandleIn: { x: number; y: number; };\nhandleOut: { x: number; y: number; };\n}[];\nclosed: boolean;\n}[]);\nnodeSetSvgPaths: ((id: number, paths: {\nsegments: {\npoint: { x: number; y: number; };\nhandleIn: { x: number; y: number; };\nhandleOut: { x: number; y: number; };\n}[];\nclosed: boolean;\n}[]) => void);\nnodeGetSvgDepth: ((id: number) => number);\nnodeSetSvgDepth: ((id: number, depth: number) => void);\nnodeGetHide: ((id: number) => boolean);\nnodeSetHide: ((id: number, hidden: boolean) => void);\nnodeGetOp: ((id: number) => number);\nnodeSetOp: ((id: number, operation: number) => void);\nnodeGetBlend: ((id: number) => number);\nnodeSetBlend: ((id: number, blend: number) => void);\nnodeGetRound: ((id: number) => number);\nnodeSetRound: ((id: number, round: number) => void);\nnodeGetColor: ((id: number) => { r: number; g: number; b: number; });\nnodeSetColor: ((id: number, rgb255: { x: number; y: number; z: number; } | { r: number; g: number; b: number; }) => void);\nnodeGetMaterialId: ((id: number) => null | number);\nnodeSetMaterialId: ((id: number, materialId: number) => void);\nnodeGetResolution: ((id: number) => number);\nnodeSetUnionResolution: ((unionId: number, resolution: number) => void);\nnodeGetLightType: ((id: number) => number);\nnodeSetLightType: ((id: number, lightType: number) => void);\nnodeGetPower: ((id: number) => number);\nnodeGetCollimation: ((id: number) => number);\nnodeSetCollimation: ((id: number, collimation: number) => void);\nnodeGetLightTextureFile: ((id: number) => string);\nnodeSetLightTextureFile: ((id: number, textureFile: string) => void);\nnodeSetPower: ((id: number, power: number) => void);\nnodeGetText: ((id: number) => string);\nnodeSetFacing: ((id: number, direction: { x: number; y: number; z: number; }) => void);\nnodeSetTextSize: ((id: number, size: { fontSize: number; depth: number; }) => void);\nnodeGetTextSize: ((id: number) => { fontSize: number; depth: number; });\nnodeSetText: ((id: number, text: string) => void);\nnodeGetFont: ((id: number) => string);\nnodeSetFont: ((id: number, font: string) => void);\nnodeGetWeight: ((id: number) => number);\nnodeSetWeight: ((id: number, weight: number) => void);\nnodeGetItalic: ((id: number) => boolean);\nnodeSetItalic: ((id: number, italic: boolean) => void);\nnodeGetAlign: ((id: number) => number);\nnodeSetAlign: ((id: number, align: number) => void);\nnodeGetWrap: ((id: number) => number);\nnodeSetWrap: ((id: number, wrap: number) => void);\nnodeGetWidth: ((id: number) => number);\nnodeSetWidth: ((id: number, width: number) => void);\nnodeGetSpacing: ((id: number) => number);\nnodeSetSpacing: ((id: number, spacing: number) => void);\nnodeGetLineHeight: ((id: number) => number);\nnodeSetLineHeight: ((id: number, lineHeight: number) => void);\nnodeGetDensity: ((id: number) => number);\nnodeSetDensity: ((id: number, density: number) => void);\nnodeGetRoundness: ((id: number) => number);\nnodeSetRoundness: ((id: number, roundness: number) => void);\nnodeGetSmoothing: ((id: number) => number);\nnodeSetSmoothing: ((id: number, smoothing: number) => void);\nnodeGetPrimType: ((id: number) => number);\nnodeSetPrimType: ((id: number, primitive: number) => void);\nnodeGetMirror: ((id: number, slot: number) => { axis: \"custom\" | \"x\" | \"y\" | \"z\" | \"disabled\"; planePosition: number; goop: number; });\nnodeSetMirror: ((id: number, slot: number, axis: \"x\" | \"y\" | \"z\" | \"disabled\", planePosition?: number, goop?: number) => void);\nnodeGetThickness: ((id: number) => number);\nnodeSetThickness: ((id: number, thickness: number) => void);\ncurveGetClosed: ((curveId: number) => boolean);\ncurveSetClosed: ((curveId: number, closed: boolean) => void);\ncurvePointGetHandleIn: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointGetHandleOut: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetHandleIn: ((curveId: number, pointIndex: number, value: { x: number; y: number; z: number; }) => void);\ncurvePointSetHandleOut: ((curveId: number, pointIndex: number, value: { x: number; y: number; z: number; }) => void);\ncurvePointCount: ((curveId: number) => number);\ncurvePointAdd: ((curveId: number, point: {\nname?: string;\npos?: { x: number; y: number; z: number; };\nrot?: { x: number; y: number; z: number; };\nsize?: { x: number; y: number; z: number; };\nhandleIn?: { x: number; y: number; z: number; };\nhandleOut?: { x: number; y: number; z: number; };\nfixed?: boolean;\nround?: number;\nmaterialId?: number;\n}, pointIndex?: number) => number);\ncurvePointRemove: ((curveId: number, pointIndex: number) => void);\ncurvePointGetName: ((curveId: number, pointIndex: number) => string);\ncurvePointSetName: ((curveId: number, pointIndex: number, name: string) => void);\ncurvePointGetPos: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetPos: ((curveId: number, pointIndex: number, position: { x: number; y: number; z: number; }) => void);\ncurvePointGetRot: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetRot: ((curveId: number, pointIndex: number, rotation: { x: number; y: number; z: number; }) => void);\ncurvePointGetSize: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetSize: ((curveId: number, pointIndex: number, sizeValue: { x: number; y: number; z: number; }) => void);\ncurvePointGetFixed: ((curveId: number, pointIndex: number) => boolean);\ncurvePointSetFixed: ((curveId: number, pointIndex: number, fixed: boolean) => void);\ncurvePointGetRound: ((curveId: number, pointIndex: number) => number);\ncurvePointSetRound: ((curveId: number, pointIndex: number, round: number) => void);\ncurvePointGetMaterialId: ((curveId: number, pointIndex: number) => null | number);\ncurvePointSetMaterialId: ((curveId: number, pointIndex: number, materialId: number) => void);\nmaterialImport: ((name: string) => Promise<number>);\nmaterialCreate: (() => number);\nmaterialDelete: ((id: number) => void);\nmaterialList: (() => number[]);\nmaterialGetName: ((id: number) => string);\nmaterialSetName: ((id: number, name: string) => void);\nmaterialGetTier: ((id: number) => number);\nmaterialSetTier: ((id: number, tier: number) => void);\nmaterialGetColor: ((id: number) => { r: number; g: number; b: number; });\nmaterialSetColor: ((id: number, rgb255: { r: number; g: number; b: number; }) => void);\nmaterialGetSecondaryColor: ((id: number) => { r: number; g: number; b: number; });\nmaterialSetSecondaryColor: ((id: number, rgb255: { r: number; g: number; b: number; }) => void);\nmaterialGetSubsurfaceColor: ((id: number) => { r: number; g: number; b: number; });\nmaterialSetSubsurfaceColor: ((id: number, rgb255: { r: number; g: number; b: number; }) => void);\nmaterialGetRoughness: ((id: number) => number);\nmaterialSetRoughness: ((id: number, value: number) => void);\nmaterialGetMetalness: ((id: number) => number);\nmaterialSetMetalness: ((id: number, value: number) => void);\nmaterialGetTransmittance: ((id: number) => number);\nmaterialSetTransmittance: ((id: number, value: number) => void);\nmaterialGetTranslucency: ((id: number) => number);\nmaterialSetTranslucency: ((id: number, value: number) => void);\nmaterialGetIor: ((id: number) => number);\nmaterialSetIor: ((id: number, value: number) => void);\nmaterialGetSheen: ((id: number) => number);\nmaterialSetSheen: ((id: number, value: number) => void);\nmaterialGetSheenRoughness: ((id: number) => number);\nmaterialSetSheenRoughness: ((id: number, value: number) => void);\nmaterialGetSpecularTint: ((id: number) => number);\nmaterialSetSpecularTint: ((id: number, value: number) => void);\nmaterialGetAbsorption: ((id: number) => number);\nmaterialSetAbsorption: ((id: number, value: number) => void);\nmaterialGetEmission: ((id: number) => number);\nmaterialSetEmission: ((id: number, value: number) => void);\nmaterialGetIridescence: ((id: number) => number);\nmaterialSetIridescence: ((id: number, value: number) => void);\nmaterialGetTranslucencyWeight: ((id: number) => number);\nmaterialSetTranslucencyWeight: ((id: number, value: number) => void);\nmaterialGetDispersion: ((id: number) => number);\nmaterialSetDispersion: ((id: number, value: number) => void);\nmaterialGetSurfaceOpacity: ((id: number) => number);\nmaterialSetSurfaceOpacity: ((id: number, value: number) => void);\nlistFontFamilies: (() => { name: string; variants: { weight: string; italic: boolean; }[]; }[]);\nprint: ((...values: unknown[]) => void);\nnodeGetAABB: ((id: number) => Promise<{ min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; }>);\nnodeResize: ((id: number, dimensions: { x?: number; y?: number; z?: number; }) => Promise<void>);\naabbCenter: ((box: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; }) => { x: number; y: number; z: number; });\naabbRadius: ((box: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; }) => number);\nlookAt: ((origin: { x: number; y: number; z: number; }, target: { x: number; y: number; z: number; }) => { x: number; y: number; z: number; });\nalignAxis: ((direction: { x: number; y: number; z: number; }, axis: \"x\" | \"y\" | \"z\") => { x: number; y: number; z: number; });\ncurveFit: ((points: { x: number; y: number; z: number; }[], options?: { tolerance?: number; closed?: boolean; }) => {\npos: { x: number; y: number; z: number; };\nhandleIn: { x: number; y: number; z: number; };\nhandleOut: { x: number; y: number; z: number; };\nindex: number;\n}[]);\ncameraReadDepthOfField: (() => {\nenabled: boolean;\nmode: \"physical\" | \"post-process\";\nfocusDistance: number;\naperturePercent: number;\nprojection: \"perspective\" | \"orthographic\";\n});\ncameraSetDepthOfField: ((input: {\nenabled?: boolean;\nmode?: \"physical\" | \"post-process\";\nfocusDistance?: number;\naperturePercent?: number;\n}) => void);\nscenePropertiesRead: (() => {\nhdr_name: undefined | string;\nhdr_multiplier: undefined | number;\nhdr_orientation: undefined | { x: number; y: number; };\nbackdrop_color1: undefined | { x: number; y: number; z: number; };\nbackdrop_color2: undefined | { x: number; y: number; z: number; };\nbackdrop_grad_offset: undefined | { x: number; y: number; };\n});\nlistHDRs: (() => string[]);\nsetHdrName: ((name: string) => void);\nsetHdrMultiplier: ((multiplier: number) => void);\nsetHdrOrientation: ((orientation: { x: number; y: number; }) => void);\nsetBackgroundColor: ((rgb255: { r: number; g: number; b: number; }) => void);\nunitMultiplier: number;\nnodes: ((options?: {\nids?: number[];\ntype?: number;\nparentId?: number;\nname?: string;\noffset?: number;\nlimit?: number;\n}) => { id: number; name: string; type: number; parentId: number; }[]);\n}) => T | Promise<T>)) => Promise<T>);\nscreenshot: ((options?: {\ncamera?: {\nposition: { x: number; y: number; z: number; };\ntarget: { x: number; y: number; z: number; };\nprojection?: \"perspective\" | \"orthographic\";\nhorizontalFovDegrees?: number;\northographicWidth?: number;\n};\nfit?: {\nids?: number[];\nbox?: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; };\ndirection?: { x: number; y: number; z: number; };\nprojection?: \"perspective\" | \"orthographic\";\nhorizontalFovDegrees?: number;\nmargin?: number;\n};\n}) => Promise<{ id: string; mediaType: string; name?: string; }>);\ncompareToReference: ((request: {\nreference: { id: string; mediaType: string; name?: string; };\nfit?: {\nids?: number[];\nbox?: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; };\ndirection?: { x: number; y: number; z: number; };\nmargin?: number;\n};\nbands?: number;\n}) => Promise<{\noverlap: number;\naspect: { reference: number; build: number; };\nbands: {\nfrom: number;\nto: number;\nreferenceWidth: number;\nbuildWidth: number;\nreferenceCenter: number;\nbuildCenter: number;\n}[];\n} & { screenshot: { id: string; mediaType: string; name?: string; }; }>);\n} };\ndeclare function print(...values: unknown[]): void;\ndeclare function emitImage(ref: { id: string; mediaType: string; name?: string }, options?: { inspect?: boolean }): Promise<void>;\ndeclare function emitFile(ref: { id: string; mediaType: string; name?: string }): Promise<void>;\n";
1
+ export declare const WOMP_SCENE_DECLARATIONS = "declare const womp: { scene: {\nhealth: ((objectIds?: number[]) => Promise<{\nstatus: \"within_limits\" | \"overflow\" | \"unverified\";\nfreshness: \"unverified\" | \"snapshot\" | \"post_ack_event\";\nrevisionVerified: false;\naffectedAreaIds: string[];\nemptyAreaIds?: string[];\nthermometer?: {\nobjects: {\n[key: string]: {\nnum_prims: number;\nflag_prim_overflow: number;\nflag_depth_overflow: number;\nflag_vox_overflow: number;\nvoxels: number;\n};\n};\nmax_num_prims: number;\nmax_total_depth: number;\nmax_per_object: number;\ntotal: number;\nmax_total: number;\nassets_budget_used: number;\nassets_budget_total: number;\nmesh_instances_used?: number;\nmesh_instances_total?: number;\ndecal_instances_used?: number;\ndecal_instances_total?: number;\nfield_instances_used?: number;\nfield_instances_total?: number;\n};\nreason?: string;\n}>);\naccess: (<T>(callback: ((draft: {\nlistSuperMaterials: (() => string[]);\n_getParentId: ((childId: number) => number);\n_getScaleProductUpTo: ((nodeId: number, includeNodeSelfUnion?: boolean) => number);\nNodeType: {\nPrimitive: 0;\nUnion: 1;\nLight: 2;\nCurve: 3;\nGroup: 4;\nText: 5;\nField: 6;\nSVG: 7;\nMesh: 8;\nDecal: 9;\nOpenSCAD: 10;\nSocket: 11;\n} & { [key: number]: string; };\nPrimitiveType: { Sphere: 0; Cylinder: 1; Cube: 2; Cone: 3; Torus: 4; Pyramid: 9; Ellipsoid: 12; Capsule: 13; } & { [key: number]: string; };\nOperationType: { Subtract: 0; Union: 1; Stain: 2; Intersect: 3; } & { [key: number]: string; };\nLightType: { Rect: 0; Sphere: 1; Distant: 2; } & { [key: number]: string; };\nnodeCreate: ((type: number, parentId?: number) => number);\nnodeDelete: ((id: number) => void);\ncloneSubtree: ((id: number, options?: { parentId?: number; name?: string; index?: number; }) => Promise<number>);\nnodeList: (() => number[]);\nnodeChildren: ((parentId: number) => number[]);\nnodeSetParent: ((id: number, parentId: number, index?: number) => void);\nnodeGetType: ((id: number) => number);\nnodeGetName: ((id: number) => string);\nnodeSetName: ((id: number, name: string) => void);\nnodeGetParentId: ((id: number) => number);\nnodeGetPos: ((id: number) => { x: number; y: number; z: number; });\nnodeGetLock: ((id: number) => boolean);\nnodeSetLock: ((id: number, locked: boolean) => void);\nnodeSetPos: ((id: number, position: { x: number; y: number; z: number; }) => void);\nnodeGetRot: ((id: number) => { x: number; y: number; z: number; });\nnodeSetRot: ((id: number, rotation: { x: number; y: number; z: number; }) => void);\nnodeGetSize: ((id: number) => { x: number; y: number; } | { x: number; y: number; z: number; });\nnodeSetSize: ((id: number, sizeValue: { x: number; y: number; } | { x: number; y: number; z: number; }) => void);\nnodeGetSvgPaths: ((id: number) => {\nsegments: {\npoint: { x: number; y: number; };\nhandleIn: { x: number; y: number; };\nhandleOut: { x: number; y: number; };\n}[];\nclosed: boolean;\n}[]);\nnodeSetSvgPaths: ((id: number, paths: {\nsegments: {\npoint: { x: number; y: number; };\nhandleIn: { x: number; y: number; };\nhandleOut: { x: number; y: number; };\n}[];\nclosed: boolean;\n}[]) => void);\nnodeGetSvgDepth: ((id: number) => number);\nnodeSetSvgDepth: ((id: number, depth: number) => void);\nnodeGetHide: ((id: number) => boolean);\nnodeSetHide: ((id: number, hidden: boolean) => void);\nnodeGetOp: ((id: number) => number);\nnodeSetOp: ((id: number, operation: number) => void);\nnodeGetBlend: ((id: number) => number);\nnodeSetBlend: ((id: number, blend: number) => void);\nnodeGetRound: ((id: number) => number);\nnodeSetRound: ((id: number, round: number) => void);\nnodeGetColor: ((id: number) => { r: number; g: number; b: number; });\nnodeSetColor: ((id: number, rgb255: { x: number; y: number; z: number; } | { r: number; g: number; b: number; }) => void);\nnodeGetMaterialId: ((id: number) => null | number);\nnodeSetMaterialId: ((id: number, materialId: number) => void);\nnodeGetResolution: ((id: number) => number);\nnodeSetUnionResolution: ((unionId: number, resolution: number) => void);\nnodeGetLightType: ((id: number) => number);\nnodeSetLightType: ((id: number, lightType: number) => void);\nnodeGetPower: ((id: number) => number);\nnodeGetCollimation: ((id: number) => number);\nnodeSetCollimation: ((id: number, collimation: number) => void);\nnodeGetLightTextureFile: ((id: number) => string);\nnodeSetLightTextureFile: ((id: number, textureFile: string) => void);\nnodeSetPower: ((id: number, power: number) => void);\nnodeGetText: ((id: number) => string);\nnodeSetFacing: ((id: number, direction: { x: number; y: number; z: number; }) => void);\nnodeSetTextSize: ((id: number, size: { fontSize: number; depth: number; }) => void);\nnodeGetTextSize: ((id: number) => { fontSize: number; depth: number; });\nnodeSetText: ((id: number, text: string) => void);\nnodeGetFont: ((id: number) => string);\nnodeSetFont: ((id: number, font: string) => void);\nnodeGetWeight: ((id: number) => number);\nnodeSetWeight: ((id: number, weight: number) => void);\nnodeGetItalic: ((id: number) => boolean);\nnodeSetItalic: ((id: number, italic: boolean) => void);\nnodeGetAlign: ((id: number) => number);\nnodeSetAlign: ((id: number, align: number) => void);\nnodeGetWrap: ((id: number) => number);\nnodeSetWrap: ((id: number, wrap: number) => void);\nnodeGetWidth: ((id: number) => number);\nnodeSetWidth: ((id: number, width: number) => void);\nnodeGetSpacing: ((id: number) => number);\nnodeSetSpacing: ((id: number, spacing: number) => void);\nnodeGetLineHeight: ((id: number) => number);\nnodeSetLineHeight: ((id: number, lineHeight: number) => void);\nnodeGetDensity: ((id: number) => number);\nnodeSetDensity: ((id: number, density: number) => void);\nnodeGetRoundness: ((id: number) => number);\nnodeSetRoundness: ((id: number, roundness: number) => void);\nnodeGetSmoothing: ((id: number) => number);\nnodeSetSmoothing: ((id: number, smoothing: number) => void);\nnodeGetPrimType: ((id: number) => number);\nnodeSetPrimType: ((id: number, primitive: number) => void);\nnodeGetMirror: ((id: number, slot: number) => { axis: \"custom\" | \"x\" | \"y\" | \"z\" | \"disabled\"; planePosition: number; goop: number; });\nnodeSetMirror: ((id: number, slot: number, axis: \"x\" | \"y\" | \"z\" | \"disabled\", planePosition?: number, goop?: number) => void);\nnodeGetThickness: ((id: number) => number);\nnodeSetThickness: ((id: number, thickness: number) => void);\ncurveGetClosed: ((curveId: number) => boolean);\ncurveSetClosed: ((curveId: number, closed: boolean) => void);\ncurvePointGetHandleIn: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointGetHandleOut: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetHandleIn: ((curveId: number, pointIndex: number, value: { x: number; y: number; z: number; }) => void);\ncurvePointSetHandleOut: ((curveId: number, pointIndex: number, value: { x: number; y: number; z: number; }) => void);\ncurvePointCount: ((curveId: number) => number);\ncurvePointAdd: ((curveId: number, point: {\nname?: string;\npos?: { x: number; y: number; z: number; };\nrot?: { x: number; y: number; z: number; };\nsize?: { x: number; y: number; z: number; };\nhandleIn?: { x: number; y: number; z: number; };\nhandleOut?: { x: number; y: number; z: number; };\nfixed?: boolean;\nround?: number;\nmaterialId?: number;\n}, pointIndex?: number) => number);\ncurvePointRemove: ((curveId: number, pointIndex: number) => void);\ncurvePointGetName: ((curveId: number, pointIndex: number) => string);\ncurvePointSetName: ((curveId: number, pointIndex: number, name: string) => void);\ncurvePointGetPos: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetPos: ((curveId: number, pointIndex: number, position: { x: number; y: number; z: number; }) => void);\ncurvePointGetRot: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetRot: ((curveId: number, pointIndex: number, rotation: { x: number; y: number; z: number; }) => void);\ncurvePointGetSize: ((curveId: number, pointIndex: number) => { x: number; y: number; z: number; });\ncurvePointSetSize: ((curveId: number, pointIndex: number, sizeValue: { x: number; y: number; z: number; }) => void);\ncurvePointGetFixed: ((curveId: number, pointIndex: number) => boolean);\ncurvePointSetFixed: ((curveId: number, pointIndex: number, fixed: boolean) => void);\ncurvePointGetRound: ((curveId: number, pointIndex: number) => number);\ncurvePointSetRound: ((curveId: number, pointIndex: number, round: number) => void);\ncurvePointGetMaterialId: ((curveId: number, pointIndex: number) => null | number);\ncurvePointSetMaterialId: ((curveId: number, pointIndex: number, materialId: number) => void);\nmaterialImport: ((name: string) => Promise<number>);\nmaterialCreate: (() => number);\nmaterialDelete: ((id: number) => void);\nmaterialList: (() => number[]);\nmaterialGetName: ((id: number) => string);\nmaterialSetName: ((id: number, name: string) => void);\nmaterialGetTier: ((id: number) => number);\nmaterialSetTier: ((id: number, tier: number) => void);\nmaterialGetColor: ((id: number) => { r: number; g: number; b: number; });\nmaterialSetColor: ((id: number, rgb255: { r: number; g: number; b: number; }) => void);\nmaterialGetSecondaryColor: ((id: number) => { r: number; g: number; b: number; });\nmaterialSetSecondaryColor: ((id: number, rgb255: { r: number; g: number; b: number; }) => void);\nmaterialGetSubsurfaceColor: ((id: number) => { r: number; g: number; b: number; });\nmaterialSetSubsurfaceColor: ((id: number, rgb255: { r: number; g: number; b: number; }) => void);\nmaterialGetRoughness: ((id: number) => number);\nmaterialSetRoughness: ((id: number, value: number) => void);\nmaterialGetMetalness: ((id: number) => number);\nmaterialSetMetalness: ((id: number, value: number) => void);\nmaterialGetTransmittance: ((id: number) => number);\nmaterialSetTransmittance: ((id: number, value: number) => void);\nmaterialGetTranslucency: ((id: number) => number);\nmaterialSetTranslucency: ((id: number, value: number) => void);\nmaterialGetIor: ((id: number) => number);\nmaterialSetIor: ((id: number, value: number) => void);\nmaterialGetSheen: ((id: number) => number);\nmaterialSetSheen: ((id: number, value: number) => void);\nmaterialGetSheenRoughness: ((id: number) => number);\nmaterialSetSheenRoughness: ((id: number, value: number) => void);\nmaterialGetSpecularTint: ((id: number) => number);\nmaterialSetSpecularTint: ((id: number, value: number) => void);\nmaterialGetAbsorption: ((id: number) => number);\nmaterialSetAbsorption: ((id: number, value: number) => void);\nmaterialGetEmission: ((id: number) => number);\nmaterialSetEmission: ((id: number, value: number) => void);\nmaterialGetIridescence: ((id: number) => number);\nmaterialSetIridescence: ((id: number, value: number) => void);\nmaterialGetTranslucencyWeight: ((id: number) => number);\nmaterialSetTranslucencyWeight: ((id: number, value: number) => void);\nmaterialGetDispersion: ((id: number) => number);\nmaterialSetDispersion: ((id: number, value: number) => void);\nmaterialGetSurfaceOpacity: ((id: number) => number);\nmaterialSetSurfaceOpacity: ((id: number, value: number) => void);\nlistFontFamilies: (() => { name: string; variants: { weight: string; italic: boolean; }[]; }[]);\nprint: ((...values: unknown[]) => void);\nnodeGetAABB: ((id: number) => Promise<{ min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; }>);\nnodeResize: ((id: number, dimensions: { x?: number; y?: number; z?: number; }) => Promise<void>);\naabbCenter: ((box: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; }) => { x: number; y: number; z: number; });\naabbRadius: ((box: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; }) => number);\nlookAt: ((origin: { x: number; y: number; z: number; }, target: { x: number; y: number; z: number; }) => { x: number; y: number; z: number; });\nalignAxis: ((direction: { x: number; y: number; z: number; }, axis: \"x\" | \"y\" | \"z\") => { x: number; y: number; z: number; });\ncurveFit: ((points: { x: number; y: number; z: number; }[], options?: { tolerance?: number; closed?: boolean; }) => {\npos: { x: number; y: number; z: number; };\nhandleIn: { x: number; y: number; z: number; };\nhandleOut: { x: number; y: number; z: number; };\nindex: number;\n}[]);\ncameraReadDepthOfField: (() => {\nenabled: boolean;\nmode: \"physical\" | \"post-process\";\nfocusDistance: number;\naperturePercent: number;\nprojection: \"perspective\" | \"orthographic\";\n});\ncameraSetDepthOfField: ((input: {\nenabled?: boolean;\nmode?: \"physical\" | \"post-process\";\nfocusDistance?: number;\naperturePercent?: number;\n}) => void);\nscenePropertiesRead: (() => {\nhdr_name: undefined | string;\nhdr_multiplier: undefined | number;\nhdr_orientation: undefined | { x: number; y: number; };\nbackdrop_color1: undefined | { x: number; y: number; z: number; };\nbackdrop_color2: undefined | { x: number; y: number; z: number; };\nbackdrop_grad_offset: undefined | { x: number; y: number; };\n});\nlistHDRs: (() => string[]);\nsetHdrName: ((name: string) => void);\nsetHdrMultiplier: ((multiplier: number) => void);\nsetHdrOrientation: ((orientation: { x: number; y: number; }) => void);\nsetBackgroundColor: ((rgb255: { r: number; g: number; b: number; }) => void);\nunitMultiplier: number;\nnodes: ((options?: {\nids?: number[];\ntype?: number;\nparentId?: number;\nname?: string;\noffset?: number;\nlimit?: number;\n}) => { id: number; name: string; type: number; parentId: number; }[]);\n}) => T | Promise<T>)) => Promise<T>);\nscreenshot: ((options?: {\ncamera?: {\nposition: { x: number; y: number; z: number; };\ntarget: { x: number; y: number; z: number; };\nprojection?: \"perspective\" | \"orthographic\";\nhorizontalFovDegrees?: number;\northographicWidth?: number;\n};\nfit?: {\nids?: number[];\nbox?: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; };\ndirection?: { x: number; y: number; z: number; };\nprojection?: \"perspective\" | \"orthographic\";\nhorizontalFovDegrees?: number;\nmargin?: number;\n};\n}) => Promise<{ id: string; mediaType: string; name?: string; }>);\ncompareToReference: ((request: {\nreference: { id: string; mediaType: string; name?: string; };\nfit?: {\nids?: number[];\nbox?: { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; };\ndirection?: { x: number; y: number; z: number; };\nprojection?: \"perspective\" | \"orthographic\";\nhorizontalFovDegrees?: number;\nmargin?: number;\n};\nbands?: number;\n}) => Promise<{\noverlap: number;\naspect: { reference: number; build: number; };\nbands: {\nfrom: number;\nto: number;\nreferenceWidth: number;\nbuildWidth: number;\nreferenceCenter: number;\nbuildCenter: number;\n}[];\n} & { screenshot: { id: string; mediaType: string; name?: string; }; }>);\nestimateReferenceCamera: ((request: {\nviews: {\nreference: { id: string; mediaType: string; name?: string; };\nview: \"front\" | \"back\" | \"right\" | \"left\";\n}[];\n}) => Promise<{ sideTurnDegrees: number; lookDownDegrees: number; distanceInHeights: null | number; }>);\ncompareToReferences: ((request: {\nviews: {\nreference: { id: string; mediaType: string; name?: string; };\nview: \"front\" | \"back\" | \"right\" | \"left\";\n}[];\nids?: number[];\nbands?: number;\n}) => Promise<{\noverlap: number;\ncamera: { sideTurnDegrees: number; lookDownDegrees: number; distanceInHeights: null | number; };\nviews: Array<{\noverlap: number;\naspect: { reference: number; build: number; };\nbands: {\nfrom: number;\nto: number;\nreferenceWidth: number;\nbuildWidth: number;\nreferenceCenter: number;\nbuildCenter: number;\n}[];\n} & { screenshot: { id: string; mediaType: string; name?: string; }; } & { view: string; }>;\n}>);\n} };\ndeclare function print(...values: unknown[]): void;\ndeclare function emitImage(ref: { id: string; mediaType: string; name?: string }, options?: { inspect?: boolean }): Promise<void>;\ndeclare function emitFile(ref: { id: string; mediaType: string; name?: string }): Promise<void>;\n";