@womp/spark-agent 1.0.1 → 2.1.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.
Files changed (89) hide show
  1. package/README.md +42 -19
  2. package/dist/capabilities/health.d.ts +9 -0
  3. package/dist/capabilities/health.js +27 -0
  4. package/dist/capabilities/scene-draft.d.ts +2 -404
  5. package/dist/capabilities/scene.d.ts +1 -1
  6. package/dist/capabilities/scene.js +13 -4
  7. package/dist/capabilities.d.ts +3 -1
  8. package/dist/capabilities.js +1 -0
  9. package/dist/cli.js +20 -2
  10. package/dist/client.js +15 -15
  11. package/dist/coordinates.d.ts +23 -0
  12. package/dist/coordinates.js +132 -0
  13. package/dist/generated/health-declarations.d.ts +1 -0
  14. package/dist/generated/health-declarations.js +3 -0
  15. package/dist/generated/scene-declarations.d.ts +1 -1
  16. package/dist/generated/scene-declarations.js +1 -1
  17. package/dist/geometry/backendRegistry.d.ts +37 -0
  18. package/dist/geometry/backendRegistry.js +61 -0
  19. package/dist/geometry/common.d.ts +26 -0
  20. package/dist/geometry/common.js +78 -0
  21. package/dist/geometry/compiler.d.ts +35 -0
  22. package/dist/geometry/compiler.js +115 -0
  23. package/dist/geometry/graph.d.ts +39 -0
  24. package/dist/geometry/graph.js +32 -0
  25. package/dist/geometry/index.d.ts +9 -0
  26. package/dist/geometry/index.js +12 -0
  27. package/dist/geometry/lift.d.ts +7 -0
  28. package/dist/geometry/lift.js +376 -0
  29. package/dist/geometry/lower.d.ts +9 -0
  30. package/dist/geometry/lower.js +363 -0
  31. package/dist/geometry/parameters.d.ts +23 -0
  32. package/dist/geometry/parameters.js +46 -0
  33. package/dist/geometry/schemas/backend-schema.json +3394 -0
  34. package/dist/geometry/schemas/flowir-dialect.json +976 -0
  35. package/dist/geometry/writeParamData.d.ts +18 -0
  36. package/dist/geometry/writeParamData.js +47 -0
  37. package/dist/geometry.d.ts +10 -0
  38. package/dist/geometry.js +19 -0
  39. package/dist/index.d.ts +2 -0
  40. package/dist/index.js +2 -0
  41. package/dist/kakapo.d.ts +9 -5
  42. package/dist/kakapo.js +7 -6
  43. package/dist/openscad.d.ts +85 -0
  44. package/dist/openscad.js +223 -0
  45. package/dist/pricing.js +9 -29
  46. package/dist/repair-state.d.ts +50 -0
  47. package/dist/repair-state.js +96 -0
  48. package/dist/runtime.d.ts +16 -36
  49. package/dist/runtime.js +132 -139
  50. package/dist/scene-environment.d.ts +25 -0
  51. package/dist/scene-environment.js +76 -0
  52. package/dist/scene-health.d.ts +49 -0
  53. package/dist/scene-health.js +176 -0
  54. package/dist/scene-metadata.d.ts +6 -0
  55. package/dist/scene-metadata.js +65 -0
  56. package/dist/scene-operations.d.ts +47 -0
  57. package/dist/scene-operations.js +126 -0
  58. package/dist/sdk-geometry-host.d.ts +12 -0
  59. package/dist/sdk-geometry-host.js +306 -0
  60. package/dist/sdk-openscad-host.d.ts +14 -0
  61. package/dist/sdk-openscad-host.js +296 -0
  62. package/dist/sdk-openscad-renderer.d.ts +11 -0
  63. package/dist/sdk-openscad-renderer.js +71 -0
  64. package/dist/sdk-scene-health-host.d.ts +4 -0
  65. package/dist/sdk-scene-health-host.js +13 -0
  66. package/dist/sdk-scene-host.d.ts +312 -0
  67. package/dist/sdk-scene-host.js +202 -0
  68. package/dist/sdk-scene-screenshot.d.ts +7 -0
  69. package/dist/sdk-scene-screenshot.js +17 -0
  70. package/dist/server/demo-scene-materials.d.ts +3 -0
  71. package/dist/server/demo-scene-materials.js +18 -0
  72. package/dist/server/express.js +2 -4
  73. package/dist/server/fixtures/materials/matte-blue.json +14 -0
  74. package/dist/server/fixtures/materials/polished-copper.json +14 -0
  75. package/dist/server/index.d.ts +2 -1
  76. package/dist/server/index.js +2 -1
  77. package/dist/server/service.d.ts +4 -0
  78. package/dist/server/service.js +26 -2
  79. package/dist/server/sqlite-store.d.ts +31 -0
  80. package/dist/server/sqlite-store.js +224 -0
  81. package/dist/server/standalone.d.ts +14 -1
  82. package/dist/server/standalone.js +160 -27
  83. package/dist/server/store.js +3 -1
  84. package/dist/types.d.ts +1 -1
  85. package/dist/womp-scene-api.d.ts +283 -0
  86. package/dist/womp-scene-api.js +974 -0
  87. package/package.json +22 -10
  88. package/dist/kakapo-capability.d.ts +0 -45
  89. package/dist/kakapo-capability.js +0 -169
@@ -0,0 +1,176 @@
1
+ import { z } from "zod";
2
+ export const MAX_GEOMETRY_REPAIR_ATTEMPTS = 2;
3
+ const HEALTH_TIMEOUT_MS = 15_000;
4
+ const count = z.number().finite().nonnegative();
5
+ export const sceneHealthObjectSchema = z.object({
6
+ num_prims: count,
7
+ flag_prim_overflow: count,
8
+ flag_depth_overflow: count,
9
+ flag_vox_overflow: count,
10
+ voxels: count,
11
+ });
12
+ export const thermometerSchema = z.object({
13
+ objects: z.record(z.string(), sceneHealthObjectSchema),
14
+ max_num_prims: count.positive(),
15
+ max_total_depth: count,
16
+ max_per_object: count.positive(),
17
+ total: count,
18
+ max_total: count.positive(),
19
+ assets_budget_used: count,
20
+ assets_budget_total: count.positive(),
21
+ mesh_instances_used: count.optional(),
22
+ mesh_instances_total: count.optional(),
23
+ decal_instances_used: count.optional(),
24
+ decal_instances_total: count.optional(),
25
+ field_instances_used: count.optional(),
26
+ field_instances_total: count.optional(),
27
+ });
28
+ export function unverifiedSceneHealth(affectedAreaIds, reason) {
29
+ return {
30
+ status: "unverified",
31
+ freshness: "unverified",
32
+ revisionVerified: false,
33
+ affectedAreaIds,
34
+ reason,
35
+ };
36
+ }
37
+ export function getSdkSceneAreaId(api, objectId) {
38
+ let node = api.getNode(objectId);
39
+ let areaId = node.kind === "union" ? node.id : objectId;
40
+ while (node.parentId !== null) {
41
+ node = api.getNode(node.parentId);
42
+ if (node.kind === "union")
43
+ areaId = node.id;
44
+ }
45
+ return String(areaId);
46
+ }
47
+ export function getSdkSceneAreaIds(api) {
48
+ return api
49
+ .listNodes({ kind: "union" })
50
+ .filter((node) => node.kind === "union" &&
51
+ getSdkSceneAreaId(api, node.id) === String(node.id))
52
+ .map((node) => String(node.id));
53
+ }
54
+ export function hasGeometryOverflow(health) {
55
+ if (health.thermometer === undefined || health.status === "unverified")
56
+ return false;
57
+ const thermometer = health.thermometer;
58
+ return health.affectedAreaIds.some((id) => {
59
+ const object = thermometer.objects[id];
60
+ return (object !== undefined &&
61
+ (object.flag_prim_overflow > 0 ||
62
+ object.flag_depth_overflow > 0 ||
63
+ object.num_prims >= thermometer.max_num_prims));
64
+ });
65
+ }
66
+ export function hasSceneResourcePressure(health) {
67
+ const thermometer = health.thermometer;
68
+ if (thermometer === undefined || health.status === "unverified")
69
+ return false;
70
+ if (thermometer.total >= thermometer.max_total ||
71
+ thermometer.assets_budget_used >= thermometer.assets_budget_total)
72
+ return true;
73
+ for (const [used, total] of [
74
+ [thermometer.mesh_instances_used, thermometer.mesh_instances_total],
75
+ [thermometer.decal_instances_used, thermometer.decal_instances_total],
76
+ [thermometer.field_instances_used, thermometer.field_instances_total],
77
+ ]) {
78
+ if (used !== undefined && total !== undefined && used >= total)
79
+ return true;
80
+ }
81
+ return Object.values(thermometer.objects).some((object) => object.flag_prim_overflow > 0 ||
82
+ object.flag_depth_overflow > 0 ||
83
+ object.flag_vox_overflow > 0 ||
84
+ object.num_prims >= thermometer.max_num_prims ||
85
+ object.voxels >= thermometer.max_per_object);
86
+ }
87
+ export function parseSceneHealth(response, affectedAreaIds) {
88
+ let value = response;
89
+ if (typeof response === "string") {
90
+ try {
91
+ value = JSON.parse(response);
92
+ }
93
+ catch {
94
+ return unverifiedSceneHealth(affectedAreaIds, "Incomplete thermometer response.");
95
+ }
96
+ }
97
+ const parsed = thermometerSchema.safeParse(value);
98
+ if (parsed.success === false)
99
+ return unverifiedSceneHealth(affectedAreaIds, "Incomplete thermometer response.");
100
+ const thermometer = parsed.data;
101
+ if (affectedAreaIds.some((id) => thermometer.objects[id] === undefined))
102
+ return unverifiedSceneHealth(affectedAreaIds, "The affected Area is not in the engine thermometer yet.");
103
+ const overflow = Object.values(thermometer.objects).some((object) => object.flag_prim_overflow > 0 ||
104
+ object.flag_depth_overflow > 0 ||
105
+ object.flag_vox_overflow > 0 ||
106
+ object.num_prims >= thermometer.max_num_prims);
107
+ const emptyAreaIds = Object.keys(thermometer.objects).filter((id) => thermometer.objects[id]?.num_prims === 0);
108
+ const emptyTarget = emptyAreaIds.some((id) => affectedAreaIds.length === 0 || affectedAreaIds.includes(id));
109
+ return {
110
+ status: overflow
111
+ ? "overflow"
112
+ : emptyTarget
113
+ ? "unverified"
114
+ : "within_limits",
115
+ freshness: "snapshot",
116
+ revisionVerified: false,
117
+ affectedAreaIds,
118
+ thermometer,
119
+ emptyAreaIds,
120
+ ...(emptyAreaIds.length > 0
121
+ ? {
122
+ reason: "These Areas have no evaluated primitive geometry. Zero counts and clear flags do not prove the model is working: output may be empty, pending, or failed.",
123
+ }
124
+ : {}),
125
+ };
126
+ }
127
+ export async function readSdkSceneHealth(api, affectedAreaIds, signal) {
128
+ let timeout;
129
+ let removeAbortListener;
130
+ try {
131
+ signal?.throwIfAborted();
132
+ const aborted = new Promise((_resolve, reject) => {
133
+ if (signal === undefined)
134
+ return;
135
+ const onAbort = () => reject(signal.reason);
136
+ signal.addEventListener("abort", onAbort, { once: true });
137
+ removeAbortListener = () => signal.removeEventListener("abort", onAbort);
138
+ });
139
+ return await Promise.race([
140
+ (async () => {
141
+ await api.waitForRenderer();
142
+ signal?.throwIfAborted();
143
+ return parseSceneHealth(await api.rpc("get_thermometer"), affectedAreaIds);
144
+ })(),
145
+ new Promise((resolve) => {
146
+ timeout = setTimeout(() => resolve(unverifiedSceneHealth(affectedAreaIds, "Scene health timed out.")), HEALTH_TIMEOUT_MS);
147
+ }),
148
+ aborted,
149
+ ]);
150
+ }
151
+ catch (error) {
152
+ return unverifiedSceneHealth(affectedAreaIds, String(error));
153
+ }
154
+ finally {
155
+ if (timeout !== undefined)
156
+ clearTimeout(timeout);
157
+ removeAbortListener?.();
158
+ }
159
+ }
160
+ export async function readStableSdkSceneHealth(api, affectedAreaIds, signal) {
161
+ try {
162
+ signal?.throwIfAborted();
163
+ const before = await api.getSceneRevision();
164
+ const health = await readSdkSceneHealth(api, affectedAreaIds, signal);
165
+ signal?.throwIfAborted();
166
+ await api.refreshScene();
167
+ signal?.throwIfAborted();
168
+ const after = await api.getSceneRevision();
169
+ if (before === after)
170
+ return health;
171
+ return unverifiedSceneHealth(affectedAreaIds, "The scene changed while reading its health.");
172
+ }
173
+ catch (error) {
174
+ return unverifiedSceneHealth(affectedAreaIds, String(error));
175
+ }
176
+ }
@@ -0,0 +1,6 @@
1
+ import type { JsonValue, SceneEdit } from "@womp/kakapo-sdk";
2
+ export declare function metadataObject(value: unknown): Record<string, JsonValue>;
3
+ export declare function readMaterialMetadata(scene: SceneEdit, id: number): Record<string, JsonValue>;
4
+ export declare function writeMaterialMetadata(scene: SceneEdit, id: number, changes: Record<string, JsonValue>): void;
5
+ export declare function removeMaterialMetadata(scene: SceneEdit, id: number): void;
6
+ export declare function shiftCurvePointMetadata(scene: SceneEdit, curveId: number, index: number, direction: 1 | -1): void;
@@ -0,0 +1,65 @@
1
+ export function metadataObject(value) {
2
+ return value !== null && typeof value === "object" && !Array.isArray(value)
3
+ ? value
4
+ : {};
5
+ }
6
+ export function readMaterialMetadata(scene, id) {
7
+ return metadataObject(metadataObject(scene.getSceneExt().materialsExt)[String(id)]);
8
+ }
9
+ export function writeMaterialMetadata(scene, id, changes) {
10
+ const materials = metadataObject(scene.getSceneExt().materialsExt);
11
+ scene.patchSceneExt([{
12
+ op: "add",
13
+ path: "/materialsExt",
14
+ value: { ...materials, [id]: { ...metadataObject(materials[String(id)]), ...changes } },
15
+ }]);
16
+ }
17
+ export function removeMaterialMetadata(scene, id) {
18
+ const materials = metadataObject(scene.getSceneExt().materialsExt);
19
+ if (!Object.hasOwn(materials, id))
20
+ return;
21
+ scene.patchSceneExt([{ op: "remove", path: `/materialsExt/${id}` }]);
22
+ }
23
+ export function shiftCurvePointMetadata(scene, curveId, index, direction) {
24
+ const shift = (value) => {
25
+ const result = {};
26
+ for (const [key, entry] of Object.entries(metadataObject(value))) {
27
+ const position = Number(key);
28
+ if (!Number.isInteger(position) || position < 0 || String(position) !== key) {
29
+ result[key] = entry;
30
+ continue;
31
+ }
32
+ if (direction === -1 && position === index)
33
+ continue;
34
+ result[position >= index ? position + direction : position] = entry;
35
+ }
36
+ return result;
37
+ };
38
+ const ext = scene.getSceneExt();
39
+ const curve = metadataObject(ext[String(curveId)]);
40
+ const points = shift(curve.pointsExt);
41
+ if (direction === 1) {
42
+ points[index] = {
43
+ locked: false,
44
+ libraryId: metadataObject(points[String(Math.max(0, index - 1))]).libraryId ?? -1,
45
+ name: `Point ${index + 1}`,
46
+ };
47
+ }
48
+ scene.patchSceneExt([{ op: "add", path: `/${curveId}`, value: { ...curve, pointsExt: points } }]);
49
+ const users = metadataObject(ext.perUserExt);
50
+ const updatedUsers = { ...users };
51
+ let changed = false;
52
+ for (const [userId, value] of Object.entries(users)) {
53
+ const user = metadataObject(value);
54
+ if (!Object.hasOwn(user, curveId))
55
+ continue;
56
+ const userCurve = metadataObject(user[String(curveId)]);
57
+ const userPoints = shift(userCurve.pointsExt);
58
+ if (direction === 1)
59
+ userPoints[index] = { selected: false };
60
+ updatedUsers[userId] = { ...user, [curveId]: { ...userCurve, pointsExt: userPoints } };
61
+ changed = true;
62
+ }
63
+ if (changed)
64
+ scene.patchSceneExt([{ op: "add", path: "/perUserExt", value: updatedUsers }]);
65
+ }
@@ -0,0 +1,47 @@
1
+ import { type JsonValue, type KakapoAPI, type SceneEdit, type SceneSaveResult } from "@womp/kakapo-sdk";
2
+ export type SceneEditResult = {
3
+ value: JsonValue;
4
+ } | {
5
+ empty: true;
6
+ };
7
+ export type SceneOperation = {
8
+ id: string;
9
+ targetKey: string;
10
+ expectedRevision: string;
11
+ resultRevision?: string;
12
+ revision: number;
13
+ status: "started" | "prepared" | "committed" | "rolled_back" | "unknown";
14
+ result?: SceneEditResult;
15
+ changed?: boolean;
16
+ error?: string;
17
+ save?: SceneSaveResult | {
18
+ status: "unknown" | "requested";
19
+ };
20
+ completedAt?: string;
21
+ };
22
+ export interface SceneOperationStore {
23
+ getSceneOperation(targetKey: string, id: string): Promise<SceneOperation | undefined>;
24
+ createSceneOperation(operation: SceneOperation): Promise<boolean>;
25
+ saveSceneOperation(operation: SceneOperation): Promise<SceneOperation>;
26
+ }
27
+ /** Resolve a journaled edit from a fresh renderer snapshot without executing its JavaScript. */
28
+ export declare function recoverSceneOperation(options: {
29
+ api: KakapoAPI;
30
+ store: SceneOperationStore;
31
+ targetKey: string;
32
+ id: string;
33
+ assertActive(): void | Promise<void>;
34
+ }): Promise<SceneOperation | undefined>;
35
+ /** The host owns connection/target validation and execution exclusivity. Never replays an existing edit. */
36
+ export declare function executeSceneOperation<T>(options: {
37
+ api: KakapoAPI;
38
+ store: SceneOperationStore;
39
+ operation: Pick<SceneOperation, "id" | "targetKey" | "expectedRevision">;
40
+ assertEditable(): void | Promise<void>;
41
+ edit(draft: SceneEdit): T | Promise<T>;
42
+ prepareCommit?(operation: SceneOperation): Promise<void>;
43
+ saveToRenderer?: boolean;
44
+ }): Promise<{
45
+ value: T;
46
+ operation: SceneOperation;
47
+ }>;
@@ -0,0 +1,126 @@
1
+ import { KakapoSceneCommitError } from "@womp/kakapo-sdk";
2
+ import { metadataObject } from "./scene-metadata.js";
3
+ function savedResult(value) {
4
+ if (value === undefined)
5
+ return { empty: true };
6
+ const active = new Set();
7
+ const validate = (item) => {
8
+ if (item === null || typeof item === "string" || typeof item === "boolean")
9
+ return;
10
+ if (typeof item === "number" && Number.isFinite(item))
11
+ return;
12
+ if (typeof item !== "object" || item === null ||
13
+ (!Array.isArray(item) && Object.getPrototypeOf(item) !== Object.prototype && Object.getPrototypeOf(item) !== null))
14
+ throw new Error("scene.edit must return JSON data or undefined");
15
+ if (active.has(item))
16
+ throw new Error("scene.edit cannot return cyclic data");
17
+ active.add(item);
18
+ for (const nested of Object.values(item))
19
+ validate(nested);
20
+ active.delete(item);
21
+ };
22
+ validate(value);
23
+ return { value: JSON.parse(JSON.stringify(value)) };
24
+ }
25
+ function resultValue(operation) {
26
+ if (!operation.result)
27
+ throw new Error("The saved scene operation result is missing");
28
+ return ("value" in operation.result ? structuredClone(operation.result.value) : undefined);
29
+ }
30
+ function committedIds(ext) {
31
+ const ids = metadataObject(ext.spark).committedSceneEdits;
32
+ return Array.isArray(ids) ? ids.filter((id) => typeof id === "string") : [];
33
+ }
34
+ function complete(operation, status) {
35
+ return { ...operation, status, completedAt: operation.completedAt ?? new Date().toISOString() };
36
+ }
37
+ /** Resolve a journaled edit from a fresh renderer snapshot without executing its JavaScript. */
38
+ export async function recoverSceneOperation(options) {
39
+ await options.assertActive();
40
+ const previous = await options.store.getSceneOperation(options.targetKey, options.id);
41
+ if (!previous || previous.status === "committed" || previous.status === "rolled_back")
42
+ return previous;
43
+ await options.api.refreshScene();
44
+ const ext = options.api.getSceneExt();
45
+ const revision = await options.api.getSceneRevision();
46
+ await options.assertActive();
47
+ const matches = previous.resultRevision !== undefined &&
48
+ previous.resultRevision === revision && committedIds(ext).includes(previous.id);
49
+ if ((previous.changed === false || matches) && previous.result) {
50
+ return options.store.saveSceneOperation(complete(previous, "committed"));
51
+ }
52
+ return previous;
53
+ }
54
+ /** The host owns connection/target validation and execution exclusivity. Never replays an existing edit. */
55
+ export async function executeSceneOperation(options) {
56
+ const { api, store, operation: identity } = options;
57
+ const savesScene = options.saveToRenderer === true;
58
+ await options.assertEditable();
59
+ const previous = await store.getSceneOperation(identity.targetKey, identity.id);
60
+ if (previous) {
61
+ if (previous.expectedRevision !== identity.expectedRevision)
62
+ throw new Error("Scene operation identity was reused with a different revision");
63
+ if ((previous.save !== undefined) !== savesScene)
64
+ throw new Error("Scene operation identity was reused with a different save policy");
65
+ if (previous.status === "committed")
66
+ return { value: resultValue(previous), operation: previous };
67
+ if (previous.status === "rolled_back")
68
+ throw new Error(previous.error ?? "Scene operation was rolled back");
69
+ const recovered = await recoverSceneOperation({
70
+ api, store, targetKey: identity.targetKey, id: identity.id, assertActive: options.assertEditable,
71
+ });
72
+ if (recovered?.status === "committed")
73
+ return { value: resultValue(recovered), operation: recovered };
74
+ throw new Error("Scene edit outcome is uncertain. Inspect the scene before making a new edit; this operation was not replayed.");
75
+ }
76
+ let operation = {
77
+ ...identity, revision: 0, status: "started",
78
+ ...(savesScene ? { save: { status: "unknown" } } : {}),
79
+ };
80
+ if (!await store.createSceneOperation(operation))
81
+ throw new Error("Scene operation is already in progress");
82
+ try {
83
+ const edit = async (draft) => {
84
+ await options.assertEditable();
85
+ if (await api.getSceneRevision() !== identity.expectedRevision)
86
+ throw new Error("Scene changed since inspection. Read the scene again before editing.");
87
+ const result = savedResult(await options.edit(draft));
88
+ await options.assertEditable();
89
+ const changed = await api.getSceneRevision() !== identity.expectedRevision;
90
+ if (changed) {
91
+ const spark = metadataObject(draft.getSceneExt().spark);
92
+ const ids = [...committedIds(api.getSceneExt()), identity.id].slice(-64);
93
+ draft.patchSceneExt([{ op: "add", path: "/spark", value: { ...spark, committedSceneEdits: ids } }]);
94
+ }
95
+ operation = await store.saveSceneOperation({
96
+ ...operation, status: "prepared", result, changed,
97
+ ...(changed ? { resultRevision: await api.getSceneRevision() } : {}),
98
+ ...(savesScene && !changed ? { save: { status: "not_needed" } } : {}),
99
+ });
100
+ await options.assertEditable();
101
+ if (changed)
102
+ await options.prepareCommit?.(operation);
103
+ await options.assertEditable();
104
+ };
105
+ if (options.saveToRenderer) {
106
+ const committed = await api.editSceneAndSave(edit);
107
+ operation = { ...operation, save: committed.save };
108
+ }
109
+ else {
110
+ await api.editScene(edit);
111
+ }
112
+ }
113
+ catch (error) {
114
+ const status = error instanceof KakapoSceneCommitError ? error.outcome
115
+ : "rolled_back";
116
+ await store.saveSceneOperation({
117
+ ...(status === "rolled_back" ? complete(operation, status) : { ...operation, status }),
118
+ error: error instanceof Error ? error.message : String(error),
119
+ ...(operation.save && status === "rolled_back" ? { save: { status: "not_needed" } } : {}),
120
+ });
121
+ throw error;
122
+ }
123
+ // Recovery requires both the operation marker and the exact prepared scene revision.
124
+ operation = await store.saveSceneOperation(complete(operation, "committed"));
125
+ return { value: resultValue(operation), operation };
126
+ }
@@ -0,0 +1,12 @@
1
+ import { type SdkSceneEditor } from "./sdk-scene-host.js";
2
+ import type { GeometryHost } from "./capabilities.js";
3
+ import { readStableSdkSceneHealth } from "./scene-health.js";
4
+ import { type RepairStateStore } from "./repair-state.js";
5
+ export type SdkGeometryHostOptions = {
6
+ editor: SdkSceneEditor;
7
+ repairs: RepairStateStore;
8
+ canGrow?: () => boolean;
9
+ onHealth?: (health: Awaited<ReturnType<typeof readStableSdkSceneHealth>>) => void;
10
+ onSelect?: (objectId: number) => void | Promise<void>;
11
+ };
12
+ export declare function createSdkGeometryHost(options: SdkGeometryHostOptions): GeometryHost;