@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
package/README.md CHANGED
@@ -8,7 +8,7 @@ execution use the same model loop. The host owns conversations, artifacts, autho
8
8
 
9
9
  ## Requirements
10
10
 
11
- - Node.js 22 or newer
11
+ - Node.js 22.13 or newer
12
12
  - AI SDK 7
13
13
  - `@ai-sdk/react` 4 for React clients
14
14
 
@@ -203,6 +203,8 @@ Configure the process with:
203
203
  - `ANTHROPIC_API_KEY`
204
204
  - `KAKAPO_URL` (defaults to `ws://127.0.0.1:5502`)
205
205
  - `PORT` (defaults to `8787`)
206
+ - `SPARK_STORAGE_PATH` (defaults to `.spark/spark.sqlite`)
207
+ - `SPARK_SCENE_IDENTITY` (optional stable identity for the scene behind `KAKAPO_URL`)
206
208
 
207
209
  The CLI automatically loads `.env` from its working directory when the file exists. Copy
208
210
  `.env.example` to `.env`, then add the provider key you intend to use. Existing process environment
@@ -211,6 +213,29 @@ variables take precedence over values loaded from the file.
211
213
  For repository development, `yarn dev` starts the Express server and Vite demo together. Open
212
214
  `http://127.0.0.1:5173`.
213
215
 
216
+ Standalone scene edits use the existing `scene_state_patch` command followed by `save_scene` after
217
+ the patch is acknowledged. The durable operation journal records the separate mutation and save
218
+ outcomes. A failed or unknown save stops that operation with an explicit error, retaining any
219
+ applied work without replay. The two commands are not an atomic transaction, and a renderer save
220
+ acknowledgement proves only renderer-local history, not durable backend storage.
221
+
222
+ The standalone server persists conversations, run streams, and screenshot bytes in SQLite. Only
223
+ one local process can execute against a database. After a terminated process is replaced, startup
224
+ preserves recorded output and marks abandoned queued/running runs incomplete without replaying
225
+ scene edits. Pending approvals remain pending. Full operation reconciliation and run continuation
226
+ are still being integrated. Node 22 reports an experimental warning for its built-in SQLite module.
227
+
228
+ Set `SPARK_SCENE_IDENTITY` only when the host can verify that the value names the same durable
229
+ scene across renderer reconnects. Without it, Spark uses a process-scoped identity and does not
230
+ authorize interrupted scene mutations to continue after a server restart.
231
+
232
+ `createStandaloneSparkAgentApp(options)` is asynchronous. Await it before listening, and call
233
+ `await app.dispose()` on shutdown to settle active runs and release storage ownership.
234
+
235
+ This development branch currently installs `kakapo-sdk` from the sibling checkout. Run `yarn build`
236
+ in `../kakapo-sdk` before installing Spark dependencies. A registry version must replace this local
237
+ dependency before release; no new package has been published by this migration.
238
+
214
239
  For the explicit fictional account profile, use `yarn dev:demo-account` or
215
240
  `spark-agent --profile demo-account`. It adds the `account` skill and `womp.account.read`
216
241
  beside the real local Kakapo scene API. Profile reads identify themselves as fictional fixtures;
@@ -218,6 +243,11 @@ credits, billing, orders, and other account services report unavailable. The def
218
243
  omits account entirely. Neither profile supplies fake generation jobs, imports, or billing permission.
219
244
  Embedded development servers can select `developmentProfile: "demo-account"` explicitly.
220
245
 
246
+ The same profile supplies two actual local material resources: `Development: Matte Blue` and
247
+ `Development: Polished Copper`. They are bundled JSON files under `src/server/fixtures/materials`
248
+ and imported through the normal SDK draft, not simulated scene effects. In `scene.edit`, await
249
+ `api.materialImport(name)`, then assign its numeric ID. The default profile has no library service.
250
+
221
251
  ## Run cost estimates
222
252
 
223
253
  Prompt caching is enabled for every listed model: Claude Opus 5 and Fable 5 use
@@ -284,25 +314,10 @@ yarn web:build
284
314
 
285
315
  Releases use a manual package publication; no separate release service is required.
286
316
 
287
- ### Migration to 1.0
288
-
289
- 1.0.0 is a breaking release: it removes `createKakapoSceneCapability`, `KakapoSceneApi`,
290
- `PrimitiveTypeValue`, and `createWompSceneApi` (the v1 scene-editing capability and its
291
- untested revision guard), in favor of consuming `@womp/scene-api` directly. Consumers of the
292
- removed API should switch to `createKakapoSceneHost` (from `/kakapo`) to open a Kakapo-backed
293
- `SceneHost`, and `createSceneCapability` (from the package root or `/capabilities`) to wrap that
294
- host as a Spark capability. `LightType`, `NodeType`, `OperationType`, and `PrimitiveType` are
295
- still available from `/kakapo`, re-exported from `@womp/scene-api`.
296
-
297
- The Publishing section below says to "use a new minor version for incompatible changes while the
298
- package is below 1.0" — this release is a deliberate departure from that convention: shipping the
299
- scene-API consolidation as 1.0.0 rather than a 0.x minor bump, to mark the removal of the
300
- duplicate v1 capability as a stable, intentional cutover rather than another pre-1.0 churn.
301
-
302
317
  ### Migration to 0.3
303
318
 
304
- - The package root is browser-safe. Import `KakapoRuntime` and `QuickJSJavaScriptExecutor` from
305
- `/kakapo` and `/quickjs` respectively.
319
+ - The package root is browser-safe. Import `KakapoRuntime`, `createWompSceneApi`, and its enums
320
+ from `/kakapo`, and `QuickJSJavaScriptExecutor` from `/quickjs`.
306
321
  - `runSparkAgent` takes the host's selected model, executor, capability composition, artifact
307
322
  resolver, and persistence hooks. The host owns connection setup and disposal. The model sees
308
323
  only `read_skill` and `execute_javascript`; domain methods live under the supplied `womp` APIs.
@@ -314,6 +329,14 @@ duplicate v1 capability as a stable, intentional cutover rather than another pre
314
329
  - Custom JavaScript executors must honor cancellation and host-owned user waits. Callback-based
315
330
  scene edits and artifact references work with both the native and QuickJS executors.
316
331
 
332
+ ### 0.3.1 context defaults
333
+
334
+ - The default input context budget is now 128,000 estimated tokens. Hosts can still
335
+ set `maxInputTokens` explicitly; this budget does not change the provider's context limit.
336
+ - Images, including images in tool results, use a 512-token estimate instead of the
337
+ general 8,192-token file allowance. Encoded media bytes remain excluded from text
338
+ estimates. Token accounting is heuristic; no API or storage migration is required.
339
+
317
340
  ### Publishing
318
341
 
319
342
  1. Choose an unused package version after checking `npm view @womp/spark-agent versions --json`.
@@ -344,5 +367,5 @@ duplicate v1 capability as a stable, intentional cutover rather than another pre
344
367
  - `src/server/` — service, storage contracts, Express adapter, artifacts, and standalone composition
345
368
  - `src/runtime.ts` — Kakapo scene connections and edit transactions
346
369
  - `src/quickjs-executor.ts` — isolated JavaScript execution and host bridge
347
- - `src/kakapo-capability.ts` — the Kakapo-backed `SceneHost` over `@womp/scene-api`
370
+ - `src/womp-scene-api.ts` — Womp-compatible Kakapo scene API
348
371
  - `web/src/App.tsx` — reference `useChat<SparkUIMessage>` application
@@ -0,0 +1,9 @@
1
+ import type { SparkCapability, SparkInvocationContext } from "../capabilities.js";
2
+ import type { SceneHealth } from "../scene-health.js";
3
+ export type WompHealthApi = {
4
+ read(objectIds: number[]): Promise<SceneHealth>;
5
+ };
6
+ export interface SceneHealthHost {
7
+ read(objectIds: number[], context: SparkInvocationContext): Promise<SceneHealth>;
8
+ }
9
+ export declare function createSceneHealthCapability(host: SceneHealthHost): SparkCapability<WompHealthApi>;
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ import { WOMP_HEALTH_DECLARATIONS } from "../generated/health-declarations.js";
3
+ export function createSceneHealthCapability(host) {
4
+ return {
5
+ skills: [
6
+ {
7
+ name: "scene-health",
8
+ version: "1",
9
+ description: "Required before scene checks or procedural edits: engine limits, empty Areas, fresh geometry feedback, and bounded repairs.",
10
+ instructions: `Before checking or editing a model, call womp.health.read([]) for current scene health. A health read is a snapshot and does not prove that the latest edit finished evaluating. Inspect scene edit receipts before claiming success.
11
+ For confirmed primitive or depth overflow, repair the same target while preserving design, dimensions, active parameter overrides, and unrelated objects. At most two geometry repairs are allowed per target in one logical run. Unverified feedback must not trigger blind regeneration or a claim that the model passed. Empty Areas may be pending, intentionally empty, mesh-only, or failed. Overflow flags take precedence over possibly stale counts. max_total_depth is a scene hierarchy limit, not measured Boolean depth.`,
12
+ declarations: WOMP_HEALTH_DECLARATIONS,
13
+ examples: ["print(await womp.health.read([]));"],
14
+ },
15
+ ],
16
+ createApi: (context) => ({
17
+ read: (objectIds) => {
18
+ const parsed = z
19
+ .array(z.number().int().positive())
20
+ .safeParse(objectIds);
21
+ if (parsed.success === false)
22
+ return Promise.reject(parsed.error);
23
+ return host.read(parsed.data, context);
24
+ },
25
+ }),
26
+ };
27
+ }
@@ -1,404 +1,2 @@
1
- /** Public Womp scene draft. Implementations preserve the editor's units and enum values. */
2
- export type WompSceneDraft = {
3
- scenePropertiesRead: () => {
4
- [key: string]: unknown;
5
- };
6
- setHdrName: (name: string) => void;
7
- setHdrMultiplier: (multiplier: number) => void;
8
- setHdrOrientation: (orientation: {
9
- x: number;
10
- y: number;
11
- }) => void;
12
- setBackgroundColor: (color: {
13
- r: number;
14
- g: number;
15
- b: number;
16
- }) => void;
17
- listHDRs: () => Array<string>;
18
- nodeSetLock: (id: number, locked: false | true) => void;
19
- nodeGetLock: (id: number) => false | true;
20
- nodeGetAABB: (id: number) => Promise<{
21
- min: {
22
- x: number;
23
- y: number;
24
- z: number;
25
- };
26
- max: {
27
- x: number;
28
- y: number;
29
- z: number;
30
- };
31
- }>;
32
- aabbCenter: (aabb: {
33
- min: {
34
- x: number;
35
- y: number;
36
- z: number;
37
- };
38
- max: {
39
- x: number;
40
- y: number;
41
- z: number;
42
- };
43
- }) => {
44
- x: number;
45
- y: number;
46
- z: number;
47
- };
48
- aabbRadius: (aabb: {
49
- min: {
50
- x: number;
51
- y: number;
52
- z: number;
53
- };
54
- max: {
55
- x: number;
56
- y: number;
57
- z: number;
58
- };
59
- }) => number;
60
- nodeResize: (id: number, dimensions: {
61
- x?: undefined | number;
62
- y?: undefined | number;
63
- z?: undefined | number;
64
- }) => Promise<void>;
65
- lookAt: (origin: {
66
- x: number;
67
- y: number;
68
- z: number;
69
- }, target: {
70
- x: number;
71
- y: number;
72
- z: number;
73
- }) => {
74
- x: number;
75
- y: number;
76
- z: number;
77
- };
78
- nodeChildren: (parentId: number) => Array<number>;
79
- nodeSetParent: (id: number, parentId: number, index?: undefined | number) => void;
80
- materialCreate: () => number;
81
- materialGetName: (id: number) => string;
82
- materialSetName: (id: number, name: string) => void;
83
- materialGetTier: (id: number) => number;
84
- materialSetTier: (id: number, tier: number) => void;
85
- materialGetColor: (id: number) => {
86
- r: number;
87
- g: number;
88
- b: number;
89
- };
90
- materialSetColor: (id: number, color: {
91
- r: number;
92
- g: number;
93
- b: number;
94
- }) => void;
95
- materialGetSecondaryColor: (id: number) => {
96
- r: number;
97
- g: number;
98
- b: number;
99
- };
100
- materialSetSecondaryColor: (id: number, color: {
101
- r: number;
102
- g: number;
103
- b: number;
104
- }) => void;
105
- materialGetSubsurfaceColor: (id: number) => {
106
- r: number;
107
- g: number;
108
- b: number;
109
- };
110
- materialSetSubsurfaceColor: (id: number, color: {
111
- r: number;
112
- g: number;
113
- b: number;
114
- }) => void;
115
- materialGetRoughness: (id: number) => number;
116
- materialSetRoughness: (id: number, value: number) => void;
117
- materialGetMetalness: (id: number) => number;
118
- materialSetMetalness: (id: number, value: number) => void;
119
- materialGetTransmittance: (id: number) => number;
120
- materialSetTransmittance: (id: number, value: number) => void;
121
- materialGetTranslucency: (id: number) => number;
122
- materialSetTranslucency: (id: number, value: number) => void;
123
- materialGetIor: (id: number) => number;
124
- materialSetIor: (id: number, value: number) => void;
125
- materialGetSheen: (id: number) => number;
126
- materialSetSheen: (id: number, value: number) => void;
127
- materialGetSheenRoughness: (id: number) => number;
128
- materialSetSheenRoughness: (id: number, value: number) => void;
129
- materialGetSpecularTint: (id: number) => number;
130
- materialSetSpecularTint: (id: number, value: number) => void;
131
- materialGetAbsorption: (id: number) => number;
132
- materialSetAbsorption: (id: number, value: number) => void;
133
- materialGetEmission: (id: number) => number;
134
- materialSetEmission: (id: number, value: number) => void;
135
- materialGetIridescence: (id: number) => number;
136
- materialSetIridescence: (id: number, value: number) => void;
137
- materialGetTranslucencyWeight: (id: number) => number;
138
- materialSetTranslucencyWeight: (id: number, value: number) => void;
139
- materialGetDispersion: (id: number) => number;
140
- materialSetDispersion: (id: number, value: number) => void;
141
- materialGetSurfaceOpacity: (id: number) => number;
142
- materialSetSurfaceOpacity: (id: number, value: number) => void;
143
- materialList: () => Array<number>;
144
- materialDelete: (id: number) => void;
145
- print: (...args: Array<unknown>) => void;
146
- nodeCreate: (type: number, parentId?: undefined | string | number) => number;
147
- nodeDelete: (id: number) => void;
148
- nodeClone: (id: number) => number;
149
- nodeList: () => Array<number>;
150
- _getParentId: (childId: number) => number;
151
- _getScaleProductUpTo: (nodeId: number, includeNodeSelfUnion: false | true) => number;
152
- curveGetClosed: (curveId: number) => false | true;
153
- curveSetClosed: (curveId: number, closed: false | true) => void;
154
- curvePointCount: (curveId: number) => number;
155
- curvePointAdd: (curveId: number, point?: {
156
- name?: undefined | string;
157
- pos?: undefined | {
158
- x?: unknown;
159
- y?: unknown;
160
- z?: unknown;
161
- };
162
- rot?: undefined | {
163
- x?: unknown;
164
- y?: unknown;
165
- z?: unknown;
166
- };
167
- size?: undefined | {
168
- x?: unknown;
169
- y?: unknown;
170
- z?: unknown;
171
- };
172
- fixed?: undefined | false | true;
173
- round?: undefined | number;
174
- handleIn?: undefined | {
175
- x?: unknown;
176
- y?: unknown;
177
- z?: unknown;
178
- };
179
- handleOut?: undefined | {
180
- x?: unknown;
181
- y?: unknown;
182
- z?: unknown;
183
- };
184
- materialId?: undefined | string | number;
185
- }) => number;
186
- curvePointInsert: (curveId: number, pointIndex: number, point?: {
187
- name?: undefined | string;
188
- pos?: undefined | {
189
- x?: unknown;
190
- y?: unknown;
191
- z?: unknown;
192
- };
193
- rot?: undefined | {
194
- x?: unknown;
195
- y?: unknown;
196
- z?: unknown;
197
- };
198
- size?: undefined | {
199
- x?: unknown;
200
- y?: unknown;
201
- z?: unknown;
202
- };
203
- fixed?: undefined | false | true;
204
- round?: undefined | number;
205
- handleIn?: undefined | {
206
- x?: unknown;
207
- y?: unknown;
208
- z?: unknown;
209
- };
210
- handleOut?: undefined | {
211
- x?: unknown;
212
- y?: unknown;
213
- z?: unknown;
214
- };
215
- materialId?: undefined | string | number;
216
- }) => number;
217
- curvePointRemove: (curveId: number, pointIndex: number) => void;
218
- curvePointGetName: (curveId: number, pointIndex: number) => string;
219
- curvePointSetName: (curveId: number, pointIndex: number, name: string) => void;
220
- curvePointGetPos: (curveId: number, pointIndex: number) => {
221
- x: number;
222
- y: number;
223
- z: number;
224
- };
225
- curvePointSetPos: (curveId: number, pointIndex: number, position: {
226
- x?: unknown;
227
- y?: unknown;
228
- z?: unknown;
229
- }) => void;
230
- curvePointGetRot: (curveId: number, pointIndex: number) => {
231
- x: number;
232
- y: number;
233
- z: number;
234
- };
235
- curvePointSetRot: (curveId: number, pointIndex: number, rotation: {
236
- x?: unknown;
237
- y?: unknown;
238
- z?: unknown;
239
- }) => void;
240
- curvePointGetSize: (curveId: number, pointIndex: number) => {
241
- x: number;
242
- y: number;
243
- z: number;
244
- };
245
- curvePointSetSize: (curveId: number, pointIndex: number, size: {
246
- x?: unknown;
247
- y?: unknown;
248
- z?: unknown;
249
- }) => void;
250
- curvePointGetFixed: (curveId: number, pointIndex: number) => false | true;
251
- curvePointSetFixed: (curveId: number, pointIndex: number, fixed: false | true) => void;
252
- curvePointGetHandleIn: (curveId: number, pointIndex: number) => {
253
- x: number;
254
- y: number;
255
- z: number;
256
- };
257
- curvePointSetHandleIn: (curveId: number, pointIndex: number, value: {
258
- x?: unknown;
259
- y?: unknown;
260
- z?: unknown;
261
- }) => void;
262
- curvePointGetHandleOut: (curveId: number, pointIndex: number) => {
263
- x: number;
264
- y: number;
265
- z: number;
266
- };
267
- curvePointSetHandleOut: (curveId: number, pointIndex: number, value: {
268
- x?: unknown;
269
- y?: unknown;
270
- z?: unknown;
271
- }) => void;
272
- curvePointGetRound: (curveId: number, pointIndex: number) => number;
273
- curvePointSetRound: (curveId: number, pointIndex: number, round: number) => void;
274
- curvePointGetMaterialId: (curveId: number, pointIndex: number) => number;
275
- curvePointSetMaterialId: (curveId: number, pointIndex: number, materialId: string | number) => void;
276
- NodeType: {
277
- Primitive: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
278
- Union: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
279
- Light: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
280
- Curve: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
281
- Group: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
282
- Text: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
283
- Field: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
284
- SVG: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
285
- Mesh: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
286
- Decal: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1003 | 2001 | 2002 | 2003;
287
- };
288
- listSuperMaterials: () => Array<string>;
289
- listFontFamilies: () => Array<{
290
- name: string;
291
- variants: Array<{
292
- weight: string;
293
- italic: false | true;
294
- }>;
295
- }>;
296
- PrimitiveType: {
297
- Sphere: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 1001;
298
- Cylinder: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 1001;
299
- Cube: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 1001;
300
- Cone: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 1001;
301
- Torus: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 1001;
302
- Pyramid: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 1001;
303
- };
304
- OperationType: {
305
- Subtract: number;
306
- Union: number;
307
- Stain: number;
308
- Intersect: number;
309
- };
310
- LightType: {
311
- Rect: 0 | 1 | 2;
312
- Sphere: 0 | 1 | 2;
313
- Distant: 0 | 1 | 2;
314
- };
315
- nodeGetType: (id: number) => number;
316
- nodeGetName: (id: number) => string;
317
- nodeSetName: (id: number, name: string) => void;
318
- nodeGetParentId: (id: number) => number;
319
- nodeGetPos: (id: number) => {
320
- x: number;
321
- y: number;
322
- z: number;
323
- };
324
- nodeSetPos: (id: number, pos: {
325
- x: number;
326
- y: number;
327
- z: number;
328
- }) => void;
329
- nodeGetRot: (id: number) => {
330
- x: number;
331
- y: number;
332
- z: number;
333
- };
334
- nodeSetRot: (id: number, rot: {
335
- x: number;
336
- y: number;
337
- z: number;
338
- }) => void;
339
- nodeGetSize: (id: number) => unknown;
340
- nodeSetSize: (id: number, size: unknown) => void;
341
- nodeGetHide: (id: number) => false | true;
342
- nodeSetHide: (id: number, hide: false | true) => void;
343
- nodeGetMaterialId: (id: number) => null | number;
344
- nodeSetMaterialId: (id: number, materialId: string | number) => void;
345
- nodeGetText: (id: number) => string;
346
- nodeSetText: (id: number, text: string) => void;
347
- nodeGetFont: (id: number) => string;
348
- nodeSetFont: (id: number, font: string) => void;
349
- nodeGetWeight: (id: number) => number;
350
- nodeSetWeight: (id: number, weight: number) => void;
351
- nodeGetItalic: (id: number) => false | true;
352
- nodeSetItalic: (id: number, italic: false | true) => void;
353
- nodeGetAlign: (id: number) => number;
354
- nodeSetAlign: (id: number, align: number) => void;
355
- nodeGetWrap: (id: number) => number;
356
- nodeSetWrap: (id: number, wrap: number) => void;
357
- nodeGetWidth: (id: number) => number;
358
- nodeSetWidth: (id: number, width: number) => void;
359
- nodeGetSpacing: (id: number) => number;
360
- nodeSetSpacing: (id: number, spacing: number) => void;
361
- nodeGetLineHeight: (id: number) => number;
362
- nodeSetLineHeight: (id: number, lineHeight: number) => void;
363
- nodeGetOp: (id: number) => number;
364
- nodeSetOp: (id: number, op: number) => void;
365
- nodeGetBlend: (id: number) => number;
366
- nodeSetBlend: (id: number, blend: number) => void;
367
- nodeGetRound: (id: number) => number;
368
- nodeSetRound: (id: number, round: number) => void;
369
- nodeGetColor: (id: number) => {
370
- r: number;
371
- g: number;
372
- b: number;
373
- };
374
- nodeSetColor: (id: number, color: {
375
- r?: unknown;
376
- g?: unknown;
377
- b?: unknown;
378
- x?: unknown;
379
- y?: unknown;
380
- z?: unknown;
381
- }) => void;
382
- nodeGetResolution: (id: number) => number;
383
- nodeSetResolution: (id: number, resolution: number) => void;
384
- nodeGetLightType: (id: number) => number;
385
- nodeSetLightType: (id: number, lightType: number) => void;
386
- nodeGetPower: (id: number) => number;
387
- nodeSetPower: (id: number, power: number) => void;
388
- nodeGetDensity: (id: number) => number;
389
- nodeSetDensity: (id: number, density: number) => void;
390
- nodeGetRoundness: (id: number) => number;
391
- nodeSetRoundness: (id: number, roundness: number) => void;
392
- nodeGetSmoothing: (id: number) => number;
393
- nodeSetSmoothing: (id: number, smoothing: number) => void;
394
- nodeGetPrimType: (id: number) => number;
395
- nodeSetPrimType: (id: number, prim: number) => void;
396
- nodeGetMirror: (id: number, slot: number) => {
397
- axis: "x" | "y" | "z" | "custom" | "disabled";
398
- planePosition: number;
399
- goop: number;
400
- };
401
- nodeSetMirror: (id: number, slot: number, axis: "x" | "y" | "z" | "disabled", planePosition?: number, goop?: number) => void;
402
- nodeGetThickness: (id: number) => number;
403
- nodeSetThickness: (id: number, thickness: number) => void;
404
- };
1
+ /** Canonical SDK-backed scene draft; declarations are generated from its implementation. */
2
+ export type { WompSceneApi as WompSceneDraft } from "../womp-scene-api.js";
@@ -2,7 +2,7 @@ import type { ArtifactRef, SparkCapability, SparkInvocationContext } from "../ca
2
2
  import type { WompSceneDraft } from "./scene-draft.js";
3
3
  export type SceneSnapshot = {
4
4
  revision: string;
5
- projectId: number;
5
+ projectId?: number;
6
6
  unitMultiplier: number;
7
7
  nodes: {
8
8
  id: number;
@@ -9,7 +9,7 @@ export function createSceneCapability(host) {
9
9
  skills: [
10
10
  {
11
11
  name: "scene-editing",
12
- version: "2",
12
+ version: "5",
13
13
  description: "Inspect the open scene and edit its objects, materials, curves, and environment.",
14
14
  instructions: `Read the scene first and keep its revision and object IDs. Call scene.edit(callback, expectedRevision)
15
15
  for one coherent undoable change. The callback receives a draft; all node/material/curve functions and enums
@@ -19,22 +19,31 @@ Preserve the existing scene unless asked to remove or replace content. Use seman
19
19
  known IDs when editing rather than creating duplicates. Distances follow the current project's units
20
20
  (read().unitMultiplier is 1 for millimetres, 0.1 for centimetres, approximately 0.0393701 for inches).
21
21
  Convert a dimension in millimetres to project units by multiplying it by read().unitMultiplier.
22
+ Area size is a dimensionless scale; Group size stays fixed at one. Light size has x/y dimensions.
23
+ Blend and mirror goop use millimetres regardless of project units. V1/V2 curve transforms are read-only;
24
+ edit their points instead. Handles and closure are available only on V3 Bezier curves.
22
25
  Rotations use degrees and colors use RGB values from 0 to 255. Use the exposed enums instead of guessing values.
26
+ For visible geometry color, create or clone a material, call materialSetColor, and assign it with nodeSetMaterialId.
27
+ nodeSetColor writes the node color field (used by lights); it does not replace a geometry object's material color.
28
+ Do not recolor a shared material unless every object using it should change. Create and assign the material in the same edit as the geometry.
23
29
  Create primitives, curves, and text inside Areas/Unions. Respect tree order for subtraction and intersection.
24
30
  Use groups for organization and unions for blended masses. Build silhouette and proportions before detail.
25
31
  For organic joins, overlap primitives and use appropriate blend; keep crisp accessories separate.
26
- Check font and material catalogs before selecting names. Library material assignments settle in the edit.
32
+ Check font, HDR, and material catalogs before selecting names. A host can explicitly report a catalog as
33
+ unavailable. Selecting an HDR resets its intensity; apply a custom intensity after selecting it.
34
+ For library materials, use listSuperMaterials(), then await materialImport(name) inside scene.edit and assign the returned numeric ID with nodeSetMaterialId or curvePointSetMaterialId. Await the import before returning from the edit; a failed import rolls back the draft.
27
35
  Filter large read results with JavaScript and print only useful details. Never dump the entire scene by default.
28
36
  After a major edit, capture a screenshot outside the transaction and emitImage its reference. To inspect a
29
37
  new object, frame its owning Area with screenshot({ targetId: areaId, view: 'isometric' }); omit these options
30
38
  to preserve the current camera view. Do not change a locked camera without the user's instruction. Verify silhouette,
31
39
  connections, openings, proportions, and materials before claiming completion. Renderer bounds and resize calls
32
- must finish before subsequent writes; inspect committed results when renderer state has not caught up.
40
+ must finish before subsequent writes. Inside scene.edit, complete renderer-backed bounds reads before the first
41
+ draft mutation; the SDK rejects them once the draft is dirty. Inspect committed results when renderer state has not caught up.
33
42
  A failed script can retain earlier committed effects. Use receipts and inspect unknown outcomes before retrying.`,
34
43
  declarations: WOMP_SCENE_DECLARATIONS,
35
44
  examples: [
36
45
  "const snapshot = await womp.scene.read(); print(snapshot.nodes.filter(node => /body/i.test(node.name)));",
37
- "const snapshot = await womp.scene.read(); const diameter = 20 * snapshot.unitMultiplier; const result = await womp.scene.edit(scene => { const areaId = scene.nodeCreate(scene.NodeType.Union, 0); const bodyId = scene.nodeCreate(scene.NodeType.Primitive, areaId); scene.nodeSetName(bodyId, '20 mm sphere'); scene.nodeSetPrimType(bodyId, scene.PrimitiveType.Sphere); scene.nodeSetSize(bodyId, { x: diameter, y: diameter, z: diameter }); scene.nodeSetPos(bodyId, { x: 0, y: diameter / 2, z: 0 }); return { areaId, bodyId }; }, snapshot.revision); print(result); await emitImage(await womp.scene.screenshot({ targetId: result.areaId, view: 'isometric' }));",
46
+ "const snapshot = await womp.scene.read(); const diameter = 20 * snapshot.unitMultiplier; const result = await womp.scene.edit(scene => { const areaId = scene.nodeCreate(scene.NodeType.Union, 0); const bodyId = scene.nodeCreate(scene.NodeType.Primitive, areaId); scene.nodeSetName(bodyId, '20 mm orange sphere'); scene.nodeSetPrimType(bodyId, scene.PrimitiveType.Sphere); scene.nodeSetSize(bodyId, { x: diameter, y: diameter, z: diameter }); scene.nodeSetPos(bodyId, { x: 0, y: diameter / 2, z: 0 }); const materialId = scene.materialCreate(); scene.materialSetColor(materialId, { r: 255, g: 128, b: 0 }); scene.nodeSetMaterialId(bodyId, materialId); return { areaId, bodyId }; }, snapshot.revision); print(result); await emitImage(await womp.scene.screenshot({ targetId: result.areaId, view: 'isometric' }));",
38
47
  ],
39
48
  },
40
49
  ],
@@ -11,9 +11,11 @@ export type { AssetImportsHost, MeshImportRequest, ImageImportRequest, AssetImpo
11
11
  export type { AssetsHost, AssetListOptions, ConversationAsset, AssetPage, WompAssetsApi, } from "./capabilities/assets.js";
12
12
  export type { OperationsHost, OperationType, OperationModel, OperationCatalog, OperationRequest, OperationJob, OperationStartResult, OperationWaitOptions, OperationWaitResult, OperationListOptions, OperationPage, WompOperationsApi, } from "./capabilities/operations.js";
13
13
  export type { AccountHost, AccountRead, AccountSection, AccountScope, AccountResult, AccountSnapshot, AccountPage, AccountProfile, AccountTeam, AccountCreditBalance, AccountSubscription, AccountBilling, AccountOrderItem, AccountOrder, AccountProject, AccountNotification, AccountWorkflow, WompAccountApi, } from "./capabilities/account.js";
14
- export type { KnowledgeAnswer, KnowledgeHost, WompKnowledgeApi } from "./capabilities/knowledge.js";
14
+ export type { KnowledgeAnswer, KnowledgeHost, WompKnowledgeApi, } from "./capabilities/knowledge.js";
15
15
  export { createOpenScadCapability } from "./capabilities/openscad.js";
16
16
  export { createGeometryCapability } from "./capabilities/geometry.js";
17
+ export { createSceneHealthCapability } from "./capabilities/health.js";
18
+ export type { SceneHealthHost, WompHealthApi } from "./capabilities/health.js";
17
19
  export { createFlowCapability } from "./capabilities/flow.js";
18
20
  export type { FlowHost, FlowSnapshot, FlowWrite, FlowWriteResult, WompFlowApi, } from "./capabilities/flow.js";
19
21
  export type { GeometryHost, GeometryTarget, GeometryInstance, GeometryParamValue, GeometryWrite, GeometryWriteResult, WompGeometryApi, } from "./capabilities/geometry.js";
@@ -5,6 +5,7 @@ export { createOperationsCapability } from "./capabilities/operations.js";
5
5
  export { createAssetsCapability } from "./capabilities/assets.js";
6
6
  export { createOpenScadCapability } from "./capabilities/openscad.js";
7
7
  export { createGeometryCapability } from "./capabilities/geometry.js";
8
+ export { createSceneHealthCapability } from "./capabilities/health.js";
8
9
  export { createFlowCapability } from "./capabilities/flow.js";
9
10
  /** The enabled bindings are also the only source of discoverable skills. */
10
11
  export function composeCapabilities(capabilities) {
package/dist/cli.js CHANGED
@@ -13,12 +13,30 @@ const port = Number.parseInt(process.env.PORT ?? "8787", 10);
13
13
  if (Number.isSafeInteger(port) === false || port < 1 || port > 65_535) {
14
14
  throw new Error("PORT must be an integer between 1 and 65535.");
15
15
  }
16
- const app = createStandaloneSparkAgentApp({
16
+ const app = await createStandaloneSparkAgentApp({
17
17
  openAiApiKey: process.env.OPENAI_API_KEY,
18
18
  anthropicApiKey: process.env.ANTHROPIC_API_KEY,
19
19
  kakapoUrl: process.env.KAKAPO_URL ?? "ws://127.0.0.1:5502",
20
20
  developmentProfile: values.profile,
21
+ storagePath: process.env.SPARK_STORAGE_PATH,
22
+ sceneIdentity: process.env.SPARK_SCENE_IDENTITY,
21
23
  });
22
- app.listen(port, "127.0.0.1", () => {
24
+ const server = app.listen(port, "127.0.0.1", () => {
23
25
  process.stdout.write(`Spark Agent server listening on http://127.0.0.1:${port}\n`);
24
26
  });
27
+ let closing = false;
28
+ async function close() {
29
+ if (closing)
30
+ return;
31
+ closing = true;
32
+ server.close();
33
+ await app.dispose();
34
+ server.closeAllConnections();
35
+ }
36
+ process.once("SIGINT", () => { void close(); });
37
+ process.once("SIGTERM", () => { void close(); });
38
+ server.once("error", (error) => {
39
+ console.error(error);
40
+ process.exitCode = 1;
41
+ void close();
42
+ });