@womp/spark-agent 0.1.0 → 0.3.1

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 (113) hide show
  1. package/.env.example +4 -0
  2. package/README.md +303 -49
  3. package/dist/agent-tools.d.ts +30 -0
  4. package/dist/agent-tools.js +189 -0
  5. package/dist/agent.d.ts +34 -7
  6. package/dist/agent.js +223 -158
  7. package/dist/browser.d.ts +2 -0
  8. package/dist/browser.js +2 -0
  9. package/dist/capabilities/account.d.ts +216 -0
  10. package/dist/capabilities/account.js +63 -0
  11. package/dist/capabilities/asset-imports.d.ts +55 -0
  12. package/dist/capabilities/asset-imports.js +117 -0
  13. package/dist/capabilities/assets.d.ts +29 -0
  14. package/dist/capabilities/assets.js +48 -0
  15. package/dist/capabilities/flow.d.ts +29 -0
  16. package/dist/capabilities/flow.js +52 -0
  17. package/dist/capabilities/geometry.d.ts +48 -0
  18. package/dist/capabilities/geometry.js +51 -0
  19. package/dist/capabilities/knowledge.d.ts +11 -0
  20. package/dist/capabilities/knowledge.js +23 -0
  21. package/dist/capabilities/openscad-instructions.d.ts +1 -0
  22. package/dist/capabilities/openscad-instructions.js +81 -0
  23. package/dist/capabilities/openscad.d.ts +54 -0
  24. package/dist/capabilities/openscad.js +34 -0
  25. package/dist/capabilities/operations.d.ts +104 -0
  26. package/dist/capabilities/operations.js +145 -0
  27. package/dist/capabilities/scene-draft.d.ts +404 -0
  28. package/dist/capabilities/scene-draft.js +1 -0
  29. package/dist/capabilities/scene.d.ts +28 -0
  30. package/dist/capabilities/scene.js +51 -0
  31. package/dist/capabilities.d.ts +67 -0
  32. package/dist/capabilities.js +25 -0
  33. package/dist/cli.d.ts +2 -0
  34. package/dist/cli.js +24 -0
  35. package/dist/client.d.ts +43 -0
  36. package/dist/client.js +159 -0
  37. package/dist/context.d.ts +15 -0
  38. package/dist/context.js +266 -0
  39. package/dist/execution-lifetime.d.ts +32 -0
  40. package/dist/execution-lifetime.js +113 -0
  41. package/dist/executor.d.ts +6 -1
  42. package/dist/generated/account-declarations.d.ts +1 -0
  43. package/dist/generated/account-declarations.js +3 -0
  44. package/dist/generated/asset-import-declarations.d.ts +1 -0
  45. package/dist/generated/asset-import-declarations.js +3 -0
  46. package/dist/generated/assets-declarations.d.ts +1 -0
  47. package/dist/generated/assets-declarations.js +3 -0
  48. package/dist/generated/flow-declarations.d.ts +1 -0
  49. package/dist/generated/flow-declarations.js +3 -0
  50. package/dist/generated/geometry-declarations.d.ts +1 -0
  51. package/dist/generated/geometry-declarations.js +3 -0
  52. package/dist/generated/kakapo-declarations.d.ts +1 -0
  53. package/dist/generated/kakapo-declarations.js +3 -0
  54. package/dist/generated/knowledge-declarations.d.ts +1 -0
  55. package/dist/generated/knowledge-declarations.js +3 -0
  56. package/dist/generated/openscad-declarations.d.ts +1 -0
  57. package/dist/generated/openscad-declarations.js +3 -0
  58. package/dist/generated/operations-declarations.d.ts +1 -0
  59. package/dist/generated/operations-declarations.js +3 -0
  60. package/dist/generated/scene-declarations.d.ts +1 -0
  61. package/dist/generated/scene-declarations.js +3 -0
  62. package/dist/index.d.ts +7 -6
  63. package/dist/index.js +5 -3
  64. package/dist/kakapo-capability-api.d.ts +18 -0
  65. package/dist/kakapo-capability-api.js +1 -0
  66. package/dist/kakapo-capability.d.ts +6 -0
  67. package/dist/kakapo-capability.js +50 -0
  68. package/dist/kakapo-scene-skill.d.ts +1 -0
  69. package/dist/kakapo-scene-skill.js +54 -0
  70. package/dist/kakapo.d.ts +5 -0
  71. package/dist/kakapo.js +3 -0
  72. package/dist/local-transport.d.ts +11 -0
  73. package/dist/local-transport.js +15 -0
  74. package/dist/model-history.d.ts +5 -0
  75. package/dist/model-history.js +34 -0
  76. package/dist/model-options.d.ts +4 -0
  77. package/dist/model-options.js +25 -0
  78. package/dist/models.d.ts +3 -15
  79. package/dist/models.js +2 -16
  80. package/dist/native-executor.d.ts +5 -0
  81. package/dist/native-executor.js +92 -0
  82. package/dist/pricing.d.ts +3 -0
  83. package/dist/pricing.js +70 -0
  84. package/dist/prompt.d.ts +1 -1
  85. package/dist/prompt.js +19 -209
  86. package/dist/quickjs-executor.d.ts +13 -0
  87. package/dist/quickjs-executor.js +309 -0
  88. package/dist/runtime.d.ts +16 -5
  89. package/dist/runtime.js +61 -10
  90. package/dist/server/artifacts.d.ts +17 -0
  91. package/dist/server/artifacts.js +36 -0
  92. package/dist/server/demo-account.d.ts +3 -0
  93. package/dist/server/demo-account.js +38 -0
  94. package/dist/server/executor.d.ts +17 -0
  95. package/dist/server/executor.js +35 -0
  96. package/dist/server/express.d.ts +13 -0
  97. package/dist/server/express.js +159 -0
  98. package/dist/server/index.d.ts +8 -0
  99. package/dist/server/index.js +5 -0
  100. package/dist/server/service.d.ts +41 -0
  101. package/dist/server/service.js +402 -0
  102. package/dist/server/standalone.d.ts +9 -0
  103. package/dist/server/standalone.js +85 -0
  104. package/dist/server/store.d.ts +16 -0
  105. package/dist/server/store.js +70 -0
  106. package/dist/server/types.d.ts +53 -0
  107. package/dist/server/types.js +1 -0
  108. package/dist/types.d.ts +3 -27
  109. package/dist/ui.d.ts +224 -0
  110. package/dist/ui.js +71 -0
  111. package/dist/womp-scene-api.d.ts +195 -3
  112. package/dist/womp-scene-api.js +102 -73
  113. package/package.json +66 -10
@@ -1,4 +1,5 @@
1
- import type { FontFamily, KakapoAPI, SceneEdit } from "@womp/kakapo-sdk";
1
+ import type { FontFamily, KakapoAPI, SceneEdit, Vec3 } from "@womp/kakapo-sdk";
2
+ import { type MirrorAxis } from "./coordinates.js";
2
3
  export declare const NodeType: {
3
4
  readonly Primitive: 0;
4
5
  readonly Union: 1;
@@ -32,6 +33,29 @@ export declare const LightTypeValue: {
32
33
  readonly Sphere: 1;
33
34
  readonly Distant: 2;
34
35
  };
36
+ type Color3 = {
37
+ r: number;
38
+ g: number;
39
+ b: number;
40
+ };
41
+ type AABB = {
42
+ min: Vec3;
43
+ max: Vec3;
44
+ };
45
+ type MirrorState = {
46
+ axis: MirrorAxis | "custom" | "disabled";
47
+ planePosition: number;
48
+ goop: number;
49
+ };
50
+ type CurvePointInput = {
51
+ name?: string;
52
+ pos?: Vec3;
53
+ rot?: Vec3;
54
+ size?: Vec3;
55
+ fixed?: boolean;
56
+ round?: number;
57
+ materialId?: number | string;
58
+ };
35
59
  export type WompSceneApiContext = {
36
60
  scene: SceneEdit;
37
61
  engine: KakapoAPI;
@@ -50,5 +74,173 @@ export type WompSceneApiContext = {
50
74
  callAsync<T>(method: string, args: unknown[], action: () => Promise<T>): Promise<T>;
51
75
  print(...values: unknown[]): void;
52
76
  };
53
- export type WompSceneApi = Record<string, unknown>;
54
- export declare function createWompSceneApi(context: WompSceneApiContext): WompSceneApi;
77
+ export type WompSceneApi = ReturnType<typeof createWompSceneApi>;
78
+ declare function lookAt(origin: Vec3, target: Vec3): Vec3;
79
+ export declare function createWompSceneApi(context: WompSceneApiContext): {
80
+ NodeType: {
81
+ readonly Primitive: 0;
82
+ readonly Union: 1;
83
+ readonly Light: 2;
84
+ readonly Curve: 3;
85
+ readonly Group: 4;
86
+ readonly Text: 5;
87
+ readonly Field: 6;
88
+ readonly SVG: 7;
89
+ readonly Mesh: 8;
90
+ readonly Decal: 9;
91
+ readonly OpenSCAD: 10;
92
+ readonly Socket: 11;
93
+ } & Record<number, string>;
94
+ PrimitiveType: {
95
+ readonly Sphere: 0;
96
+ readonly Cylinder: 1;
97
+ readonly Cube: 2;
98
+ readonly Cone: 3;
99
+ readonly Torus: 4;
100
+ readonly Pyramid: 9;
101
+ } & Record<number, string>;
102
+ OperationType: {
103
+ readonly Subtract: 0;
104
+ readonly Union: 1;
105
+ readonly Stain: 2;
106
+ readonly Intersect: 3;
107
+ } & Record<number, string>;
108
+ LightType: {
109
+ readonly Rect: 0;
110
+ readonly Sphere: 1;
111
+ readonly Distant: 2;
112
+ } & Record<number, string>;
113
+ nodeCreate: (type: number, parentId?: number) => number;
114
+ nodeDelete: (id: number) => void;
115
+ nodeClone: (id: number) => number;
116
+ nodeList: () => number[];
117
+ nodeChildren: (parentId: number) => number[];
118
+ nodeSetParent: (id: number, parentId: number, index?: number) => void;
119
+ nodeGetType: (id: number) => number;
120
+ nodeGetName: (id: number) => string;
121
+ nodeSetName: (id: number, name: string) => void;
122
+ nodeGetParentId: (id: number) => number;
123
+ nodeGetPos: (id: number) => Vec3;
124
+ nodeSetPos: (id: number, position: Vec3) => void;
125
+ nodeGetRot: (id: number) => Vec3;
126
+ nodeSetRot: (id: number, rotation: Vec3) => void;
127
+ nodeGetSize: (id: number) => Vec3;
128
+ nodeSetSize: (id: number, sizeValue: Vec3) => void;
129
+ nodeGetHide: (id: number) => boolean;
130
+ nodeSetHide: (id: number, hidden: boolean) => void;
131
+ nodeGetOp: (id: number) => number;
132
+ nodeSetOp: (id: number, operation: number) => void;
133
+ nodeGetBlend: (id: number) => number;
134
+ nodeSetBlend: (id: number, blend: number) => void;
135
+ nodeGetRound: (id: number) => number;
136
+ nodeSetRound: (id: number, round: number) => void;
137
+ nodeGetColor: (id: number) => Color3;
138
+ nodeSetColor: (id: number, color: Color3 | Vec3) => void;
139
+ nodeGetMaterialId: (id: number) => number | null;
140
+ nodeSetMaterialId: (id: number, materialId: number) => void;
141
+ nodeGetResolution: (id: number) => number;
142
+ nodeSetResolution: (id: number, resolution: number) => void;
143
+ nodeGetLightType: (id: number) => number;
144
+ nodeSetLightType: (id: number, lightType: number) => void;
145
+ nodeGetPower: (id: number) => number;
146
+ nodeSetPower: (id: number, power: number) => void;
147
+ nodeGetText: (id: number) => string;
148
+ nodeSetText: (id: number, text: string) => void;
149
+ nodeGetFont: (id: number) => string;
150
+ nodeSetFont: (id: number, font: string) => void;
151
+ nodeGetWeight: (id: number) => number;
152
+ nodeSetWeight: (id: number, weight: number) => void;
153
+ nodeGetItalic: (id: number) => boolean;
154
+ nodeSetItalic: (id: number, italic: boolean) => void;
155
+ nodeGetAlign: (id: number) => number;
156
+ nodeSetAlign: (id: number, align: number) => void;
157
+ nodeGetWrap: (id: number) => number;
158
+ nodeSetWrap: (id: number, wrap: number) => void;
159
+ nodeGetWidth: (id: number) => number;
160
+ nodeSetWidth: (id: number, width: number) => void;
161
+ nodeGetSpacing: (id: number) => number;
162
+ nodeSetSpacing: (id: number, spacing: number) => void;
163
+ nodeGetLineHeight: (id: number) => number;
164
+ nodeSetLineHeight: (id: number, lineHeight: number) => void;
165
+ nodeGetDensity: (id: number) => number;
166
+ nodeSetDensity: (id: number, density: number) => void;
167
+ nodeGetRoundness: (id: number) => number;
168
+ nodeSetRoundness: (id: number, roundness: number) => void;
169
+ nodeGetSmoothing: (id: number) => number;
170
+ nodeSetSmoothing: (id: number, smoothing: number) => void;
171
+ nodeGetPrimType: (id: number) => number;
172
+ nodeSetPrimType: (id: number, primitive: number) => void;
173
+ nodeGetMirror: (id: number, slot: number) => MirrorState;
174
+ nodeSetMirror: (id: number, slot: number, axis: MirrorAxis | "disabled", planePosition?: number, goop?: number) => void;
175
+ nodeGetThickness: (id: number) => number;
176
+ nodeSetThickness: (id: number, thickness: number) => void;
177
+ curvePointCount: (curveId: number) => number;
178
+ curvePointAdd: (curveId: number, point?: CurvePointInput) => number;
179
+ curvePointInsert: (curveId: number, pointIndex: number, point?: CurvePointInput) => number;
180
+ curvePointRemove: (curveId: number, pointIndex: number) => void;
181
+ curvePointGetPos: (curveId: number, pointIndex: number) => Vec3;
182
+ curvePointSetPos: (curveId: number, pointIndex: number, position: Vec3) => void;
183
+ curvePointGetRot: (curveId: number, pointIndex: number) => Vec3;
184
+ curvePointSetRot: (curveId: number, pointIndex: number, rotation: Vec3) => void;
185
+ curvePointGetSize: (curveId: number, pointIndex: number) => Vec3;
186
+ curvePointSetSize: (curveId: number, pointIndex: number, sizeValue: Vec3) => void;
187
+ curvePointGetFixed: (curveId: number, pointIndex: number) => boolean;
188
+ curvePointSetFixed: (curveId: number, pointIndex: number, fixed: boolean) => void;
189
+ curvePointGetRound: (curveId: number, pointIndex: number) => number;
190
+ curvePointSetRound: (curveId: number, pointIndex: number, round: number) => void;
191
+ curvePointGetMaterialId: (curveId: number, pointIndex: number) => number | null;
192
+ curvePointSetMaterialId: (curveId: number, pointIndex: number, materialId: number) => void;
193
+ materialCreate: () => number;
194
+ materialDelete: (id: number) => void;
195
+ materialList: () => number[];
196
+ materialGetName: (id: number) => string;
197
+ materialSetName: (id: number, name: string) => void;
198
+ materialGetColor: (id: number) => Color3;
199
+ materialSetColor: (id: number, color: Color3) => void;
200
+ materialGetSecondaryColor: (id: number) => Color3;
201
+ materialSetSecondaryColor: (id: number, color: Color3) => void;
202
+ materialGetSubsurfaceColor: (id: number) => Color3;
203
+ materialSetSubsurfaceColor: (id: number, color: Color3) => void;
204
+ materialGetRoughness: (id: number) => number;
205
+ materialSetRoughness: (id: number, value: number) => void;
206
+ materialGetMetalness: (id: number) => number;
207
+ materialSetMetalness: (id: number, value: number) => void;
208
+ materialGetTransmittance: (id: number) => number;
209
+ materialSetTransmittance: (id: number, value: number) => void;
210
+ materialGetTranslucency: (id: number) => number;
211
+ materialSetTranslucency: (id: number, value: number) => void;
212
+ materialGetIor: (id: number) => number;
213
+ materialSetIor: (id: number, value: number) => void;
214
+ materialGetSheen: (id: number) => number;
215
+ materialSetSheen: (id: number, value: number) => void;
216
+ materialGetSheenRoughness: (id: number) => number;
217
+ materialSetSheenRoughness: (id: number, value: number) => void;
218
+ materialGetSpecularTint: (id: number) => number;
219
+ materialSetSpecularTint: (id: number, value: number) => void;
220
+ materialGetAbsorption: (id: number) => number;
221
+ materialSetAbsorption: (id: number, value: number) => void;
222
+ materialGetEmission: (id: number) => number;
223
+ materialSetEmission: (id: number, value: number) => void;
224
+ materialGetIridescence: (id: number) => number;
225
+ materialSetIridescence: (id: number, value: number) => void;
226
+ materialGetTranslucencyWeight: (id: number) => number;
227
+ materialSetTranslucencyWeight: (id: number, value: number) => void;
228
+ materialGetDispersion: (id: number) => number;
229
+ materialSetDispersion: (id: number, value: number) => void;
230
+ materialGetSurfaceOpacity: (id: number) => number;
231
+ materialSetSurfaceOpacity: (id: number, value: number) => void;
232
+ listFontFamilies: () => {
233
+ name: string;
234
+ variants: {
235
+ weight: string;
236
+ italic: boolean;
237
+ }[];
238
+ }[];
239
+ print: (...values: unknown[]) => void;
240
+ nodeGetAABB: (id: number) => Promise<AABB>;
241
+ nodeResize: (id: number, dimensions: Partial<Vec3>) => Promise<void>;
242
+ aabbCenter: (box: AABB) => Vec3;
243
+ aabbRadius: (box: AABB) => number;
244
+ lookAt: typeof lookAt;
245
+ };
246
+ export {};
@@ -105,10 +105,10 @@ function color1(value) {
105
105
  };
106
106
  }
107
107
  function runtimeEnum(values) {
108
- const result = { ...values };
108
+ const names = {};
109
109
  for (const [name, value] of Object.entries(values))
110
- result[value] = name;
111
- return result;
110
+ names[value] = name;
111
+ return { ...values, ...names };
112
112
  }
113
113
  function normalizePrimitiveSize(primitive, size) {
114
114
  switch (primitive) {
@@ -155,9 +155,9 @@ function lookAt(origin, target) {
155
155
  right = normalize(right);
156
156
  const correctedUp = cross(forward, right);
157
157
  return {
158
- x: Math.asin(clamp(correctedUp.z, -1, 1)) * 180 / Math.PI,
159
- y: Math.atan2(-right.z, forward.z) * 180 / Math.PI,
160
- z: Math.atan2(-correctedUp.x, correctedUp.y) * 180 / Math.PI,
158
+ x: (Math.asin(clamp(correctedUp.z, -1, 1)) * 180) / Math.PI,
159
+ y: (Math.atan2(-right.z, forward.z) * 180) / Math.PI,
160
+ z: (Math.atan2(-correctedUp.x, correctedUp.y) * 180) / Math.PI,
161
161
  };
162
162
  }
163
163
  function normalize(value) {
@@ -175,7 +175,7 @@ function cross(left, right) {
175
175
  }
176
176
  export function createWompSceneApi(context) {
177
177
  const { scene } = context;
178
- const actualParent = (parentId) => parentId === 0 ? context.rootId : parentId;
178
+ const actualParent = (parentId) => (parentId === 0 ? context.rootId : parentId);
179
179
  const publicParent = (parentId) => parentId === null || parentId === context.rootId ? 0 : parentId;
180
180
  const requireNode = (id) => {
181
181
  context.requireNode(id);
@@ -183,7 +183,9 @@ export function createWompSceneApi(context) {
183
183
  };
184
184
  const ancestorScale = (id, includeSelf = false) => {
185
185
  let total = 1;
186
- let current = includeSelf ? requireNode(id) : scene.getNode(requireNode(id).parentId ?? context.rootId);
186
+ let current = includeSelf
187
+ ? requireNode(id)
188
+ : scene.getNode(requireNode(id).parentId ?? context.rootId);
187
189
  const visited = new Set();
188
190
  while (current.id !== context.rootId && !visited.has(current.id)) {
189
191
  visited.add(current.id);
@@ -201,7 +203,10 @@ export function createWompSceneApi(context) {
201
203
  const hasCsgBaseBefore = (parentId, nodeId, index) => {
202
204
  const siblings = scene.getNodeChildren(parentId).filter(({ id }) => id !== nodeId);
203
205
  const targetIndex = index ?? siblings.length;
204
- return siblings.slice(0, targetIndex).some((sibling) => sibling.kind === "union" || sibling.kind === "group" ||
206
+ return siblings
207
+ .slice(0, targetIndex)
208
+ .some((sibling) => sibling.kind === "union" ||
209
+ sibling.kind === "group" ||
205
210
  ("operation" in sibling && sibling.operation === "union"));
206
211
  };
207
212
  const nodeSize = (id) => {
@@ -372,62 +377,70 @@ export function createWompSceneApi(context) {
372
377
  if (parent !== 0)
373
378
  context.requireNode(parent);
374
379
  const parentScale = parent === 0 || parent === context.rootId ? 1 : ancestorScale(parent, true);
375
- const properties = kind === "primitive" ? {
376
- color: { x: 1, y: 1, z: 1 },
377
- primitive: "sphere",
378
- operation: "union",
379
- blend: 0,
380
- round: 0,
381
- materialId: context.getDefaultMaterialId(),
382
- transform: {
383
- position: scale(toEnginePosition({ x: 0, y: 2, z: 0 }), 1 / parentScale),
384
- rotation: { x: 0, y: 0, z: 0 },
385
- scale: scale(toEngineDimensions({ x: 4, y: 4, z: 4 }), 1 / parentScale),
386
- },
387
- } : kind === "curve" ? {
388
- primitive: "sphere",
389
- operation: "union",
390
- blend: toEngineBlend(0.36),
391
- density: 80,
392
- roundness: 2,
393
- smoothing: 0.02,
394
- materialId: context.getDefaultMaterialId(),
395
- points: [
396
- {
380
+ const properties = kind === "primitive"
381
+ ? {
382
+ color: { x: 1, y: 1, z: 1 },
383
+ primitive: "sphere",
384
+ operation: "union",
385
+ blend: 0,
386
+ round: 0,
387
+ materialId: context.getDefaultMaterialId(),
388
+ transform: {
397
389
  position: scale(toEnginePosition({ x: 0, y: 2, z: 0 }), 1 / parentScale),
398
390
  rotation: { x: 0, y: 0, z: 0 },
399
391
  scale: scale(toEngineDimensions({ x: 4, y: 4, z: 4 }), 1 / parentScale),
400
- materialId: context.getDefaultMaterialId(),
401
- fixed: false,
402
- round: 0,
403
392
  },
404
- {
405
- position: scale(toEnginePosition({ x: 6, y: 2, z: 0 }), 1 / parentScale),
406
- rotation: { x: 0, y: 0, z: 0 },
407
- scale: scale(toEngineDimensions({ x: 4, y: 4, z: 4 }), 1 / parentScale),
393
+ }
394
+ : kind === "curve"
395
+ ? {
396
+ primitive: "sphere",
397
+ operation: "union",
398
+ blend: toEngineBlend(0.36),
399
+ density: 80,
400
+ roundness: 2,
401
+ smoothing: 0.02,
408
402
  materialId: context.getDefaultMaterialId(),
409
- fixed: false,
410
- round: 0,
411
- },
412
- ],
413
- } : kind === "text" ? {
414
- text: "Hello Womp",
415
- fontFamily: "Roboto",
416
- weight: 500,
417
- materialId: context.getDefaultMaterialId(),
418
- transform: {
419
- position: scale(toEnginePosition({ x: 0, y: 0.07, z: 0.58 }), 1 / parentScale),
420
- rotation: { x: 0, y: 0, z: 0 },
421
- scale: scale(toEngineDimensions({ x: 1.8, y: 1.8, z: 0.8 }), 1 / parentScale),
422
- },
423
- } : kind === "union" || kind === "group" ? {
424
- transform: {
425
- position: { x: 0, y: 0, z: 0 },
426
- rotation: { x: 0, y: 0, z: 0 },
427
- scale: { x: 1 / parentScale, y: 1, z: 1 },
428
- },
429
- ...(kind === "union" ? { resolution: 0.35 } : {}),
430
- } : {};
403
+ points: [
404
+ {
405
+ position: scale(toEnginePosition({ x: 0, y: 2, z: 0 }), 1 / parentScale),
406
+ rotation: { x: 0, y: 0, z: 0 },
407
+ scale: scale(toEngineDimensions({ x: 4, y: 4, z: 4 }), 1 / parentScale),
408
+ materialId: context.getDefaultMaterialId(),
409
+ fixed: false,
410
+ round: 0,
411
+ },
412
+ {
413
+ position: scale(toEnginePosition({ x: 6, y: 2, z: 0 }), 1 / parentScale),
414
+ rotation: { x: 0, y: 0, z: 0 },
415
+ scale: scale(toEngineDimensions({ x: 4, y: 4, z: 4 }), 1 / parentScale),
416
+ materialId: context.getDefaultMaterialId(),
417
+ fixed: false,
418
+ round: 0,
419
+ },
420
+ ],
421
+ }
422
+ : kind === "text"
423
+ ? {
424
+ text: "Hello Womp",
425
+ fontFamily: "Roboto",
426
+ weight: 500,
427
+ materialId: context.getDefaultMaterialId(),
428
+ transform: {
429
+ position: scale(toEnginePosition({ x: 0, y: 0.07, z: 0.58 }), 1 / parentScale),
430
+ rotation: { x: 0, y: 0, z: 0 },
431
+ scale: scale(toEngineDimensions({ x: 1.8, y: 1.8, z: 0.8 }), 1 / parentScale),
432
+ },
433
+ }
434
+ : kind === "union" || kind === "group"
435
+ ? {
436
+ transform: {
437
+ position: { x: 0, y: 0, z: 0 },
438
+ rotation: { x: 0, y: 0, z: 0 },
439
+ scale: { x: 1 / parentScale, y: 1, z: 1 },
440
+ },
441
+ ...(kind === "union" ? { resolution: 0.35 } : {}),
442
+ }
443
+ : {};
431
444
  const created = context.call("createNode", [{ kind, parentId: parent, properties }], () => scene.createNode({ kind, parentId: parent, properties }));
432
445
  context.trackNode(created.id);
433
446
  return created.id;
@@ -444,7 +457,9 @@ export function createWompSceneApi(context) {
444
457
  context.trackNode(clone.id);
445
458
  return clone.id;
446
459
  },
447
- nodeList: () => scene.listNodes().filter((node) => node.id !== context.rootId)
460
+ nodeList: () => scene
461
+ .listNodes()
462
+ .filter((node) => node.id !== context.rootId)
448
463
  .filter((node) => {
449
464
  try {
450
465
  context.requireNode(node.id);
@@ -453,8 +468,11 @@ export function createWompSceneApi(context) {
453
468
  catch {
454
469
  return false;
455
470
  }
456
- }).map((node) => node.id),
457
- nodeChildren: (parentId) => scene.getNodeChildren(actualParent(parentId)).filter((node) => {
471
+ })
472
+ .map((node) => node.id),
473
+ nodeChildren: (parentId) => scene
474
+ .getNodeChildren(actualParent(parentId))
475
+ .filter((node) => {
458
476
  try {
459
477
  context.requireNode(node.id);
460
478
  return true;
@@ -462,14 +480,17 @@ export function createWompSceneApi(context) {
462
480
  catch {
463
481
  return false;
464
482
  }
465
- }).map((node) => node.id),
483
+ })
484
+ .map((node) => node.id),
466
485
  nodeSetParent: (id, parentId, index) => {
467
486
  requireNode(id);
468
487
  const parent = actualParent(parentId);
469
488
  context.requireNode(parent);
470
489
  const node = requireNode(id);
471
- if (parent !== context.rootId && requireNode(parent).kind === "union" &&
472
- "operation" in node && node.operation !== "union") {
490
+ if (parent !== context.rootId &&
491
+ requireNode(parent).kind === "union" &&
492
+ "operation" in node &&
493
+ node.operation !== "union") {
473
494
  if (!hasCsgBaseBefore(parent, id, index)) {
474
495
  throw new Error("Subtract, Stain, and Intersect nodes must follow Union geometry in their parent Area");
475
496
  }
@@ -518,7 +539,9 @@ export function createWompSceneApi(context) {
518
539
  if (value !== "union" && node.parentId !== null) {
519
540
  const parent = scene.getNode(node.parentId);
520
541
  if (parent.kind === "union") {
521
- const index = scene.getNodeChildren(parent.id).findIndex(({ id: siblingId }) => siblingId === id);
542
+ const index = scene
543
+ .getNodeChildren(parent.id)
544
+ .findIndex(({ id: siblingId }) => siblingId === id);
522
545
  if (!hasCsgBaseBefore(parent.id, id, index)) {
523
546
  throw new Error("Subtract, Stain, and Intersect nodes must follow Union geometry in their parent Area");
524
547
  }
@@ -540,9 +563,7 @@ export function createWompSceneApi(context) {
540
563
  nodeSetRound: (id, round) => update(id, { round: clamp(finite(round, "round"), 0, 1) }),
541
564
  nodeGetColor: (id) => {
542
565
  const node = requireNode(id);
543
- return color255((node.kind === "primitive" || node.kind === "light")
544
- ? node.color
545
- : { x: 0, y: 0, z: 0 });
566
+ return color255(node.kind === "primitive" || node.kind === "light" ? node.color : { x: 0, y: 0, z: 0 });
546
567
  },
547
568
  nodeSetColor: (id, color) => update(id, { color: color1(color) }),
548
569
  nodeGetMaterialId: (id) => {
@@ -781,7 +802,10 @@ export function createWompSceneApi(context) {
781
802
  materialSetSurfaceOpacity: (id, value) => writeMaterial(id, { surfaceOpacity: clamp(finite(value, "surfaceOpacity"), 0, 1) }),
782
803
  listFontFamilies: () => context.fonts.map((family) => ({
783
804
  name: family.name,
784
- variants: family.fonts.map((font) => ({ weight: String(font.weight), italic: font.italic })),
805
+ variants: family.fonts.map((font) => ({
806
+ weight: String(font.weight),
807
+ italic: font.italic,
808
+ })),
785
809
  })),
786
810
  print: (...values) => context.print(...values),
787
811
  nodeGetAABB: getNodeAABB,
@@ -792,8 +816,13 @@ export function createWompSceneApi(context) {
792
816
  }
793
817
  const box = await getNodeAABB(id);
794
818
  const current = nodeSize(id);
795
- const axis = dimensions.x !== undefined ? "x" : dimensions.y !== undefined ? "y" :
796
- dimensions.z !== undefined ? "z" : undefined;
819
+ const axis = dimensions.x !== undefined
820
+ ? "x"
821
+ : dimensions.y !== undefined
822
+ ? "y"
823
+ : dimensions.z !== undefined
824
+ ? "z"
825
+ : undefined;
797
826
  if (!axis)
798
827
  return;
799
828
  const target = finite(dimensions[axis], `dimensions.${axis}`);
package/package.json CHANGED
@@ -1,16 +1,59 @@
1
1
  {
2
2
  "name": "@womp/spark-agent",
3
- "version": "0.1.0",
4
- "description": "Environment-neutral AI agent core for modeling Kakapo scenes",
3
+ "version": "0.3.1",
4
+ "description": "Portable skills-based AI agent with local and durable chat transports for Womp",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "spark-agent": "./dist/cli.js"
10
+ },
8
11
  "exports": {
12
+ "./browser": {
13
+ "types": "./dist/browser.d.ts",
14
+ "import": "./dist/browser.js",
15
+ "default": "./dist/browser.js"
16
+ },
17
+ "./capabilities": {
18
+ "types": "./dist/capabilities.d.ts",
19
+ "import": "./dist/capabilities.js",
20
+ "default": "./dist/capabilities.js"
21
+ },
22
+ "./kakapo": {
23
+ "types": "./dist/kakapo.d.ts",
24
+ "import": "./dist/kakapo.js",
25
+ "default": "./dist/kakapo.js"
26
+ },
27
+ "./quickjs": {
28
+ "types": "./dist/quickjs-executor.d.ts",
29
+ "import": "./dist/quickjs-executor.js",
30
+ "default": "./dist/quickjs-executor.js"
31
+ },
9
32
  ".": {
10
33
  "types": "./dist/index.d.ts",
11
34
  "import": "./dist/index.js",
12
35
  "default": "./dist/index.js"
13
36
  },
37
+ "./ui": {
38
+ "types": "./dist/ui.d.ts",
39
+ "import": "./dist/ui.js",
40
+ "default": "./dist/ui.js"
41
+ },
42
+ "./client": {
43
+ "types": "./dist/client.d.ts",
44
+ "import": "./dist/client.js",
45
+ "default": "./dist/client.js"
46
+ },
47
+ "./server": {
48
+ "types": "./dist/server/index.d.ts",
49
+ "import": "./dist/server/index.js",
50
+ "default": "./dist/server/index.js"
51
+ },
52
+ "./express": {
53
+ "types": "./dist/server/express.d.ts",
54
+ "import": "./dist/server/express.js",
55
+ "default": "./dist/server/express.js"
56
+ },
14
57
  "./package.json": "./package.json"
15
58
  },
16
59
  "files": [
@@ -20,7 +63,7 @@
20
63
  ],
21
64
  "sideEffects": false,
22
65
  "engines": {
23
- "node": ">=20"
66
+ "node": ">=22"
24
67
  },
25
68
  "repository": {
26
69
  "type": "git",
@@ -32,30 +75,43 @@
32
75
  "license": "MIT",
33
76
  "scripts": {
34
77
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
35
- "build": "yarn clean && tsc -p tsconfig.json",
78
+ "build": "yarn clean && node scripts/generate-skill-declarations.mjs && tsc -p tsconfig.json",
36
79
  "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p web/tsconfig.json",
37
80
  "lint": "yarn typecheck",
38
- "dev": "yarn build && vite --config web/vite.config.ts",
81
+ "dev": "yarn build && concurrently --kill-others \"yarn dev:server\" \"yarn dev:web\"",
82
+ "dev:server": "tsx src/cli.ts",
83
+ "dev:demo-account": "yarn build && concurrently --kill-others \"yarn dev:server --profile demo-account\" \"yarn dev:web\"",
84
+ "dev:web": "vite --config web/vite.config.ts",
85
+ "start": "node dist/cli.js",
39
86
  "web:build": "yarn build && tsc --noEmit -p web/tsconfig.json && vite build --config web/vite.config.ts",
40
- "test": "yarn build && tsx --tsconfig tsconfig.json --test test/**/*.test.ts && node --input-type=module -e \"await import('@womp/spark-agent')\"",
87
+ "test": "yarn build && tsx --tsconfig tsconfig.json --test test/**/*.test.ts && node --input-type=module -e \"await Promise.all([import('@womp/spark-agent'), import('@womp/spark-agent/ui'), import('@womp/spark-agent/client'), import('@womp/spark-agent/server'), import('@womp/spark-agent/express')])\"",
41
88
  "test:live": "tsx --tsconfig tsconfig.json test/womp-scene-api.live.ts",
42
89
  "prepack": "yarn build"
43
90
  },
44
91
  "dependencies": {
92
+ "@ai-sdk/anthropic": "4.0.50",
93
+ "@ai-sdk/openai": "4.0.63",
94
+ "@jitl/quickjs-wasmfile-release-sync": "0.32.0",
45
95
  "@womp/kakapo-sdk": "0.1.0",
46
- "ai": "^7.0.37",
47
- "zod": "^4.4.3"
96
+ "ai": "7.0.95",
97
+ "eventsource-parser": "^3.0.6",
98
+ "express": "^5.2.1",
99
+ "quickjs-emscripten-core": "0.32.0",
100
+ "zod": "4.5.4"
48
101
  },
49
102
  "devDependencies": {
50
- "@ai-sdk/anthropic": "^4.0.23",
51
- "@ai-sdk/openai": "^4.0.20",
103
+ "@ai-sdk/react": "^4.0.77",
104
+ "@types/express": "^5.0.5",
52
105
  "@types/node": "^24.0.0",
53
106
  "@types/react": "^19.2.17",
54
107
  "@types/react-dom": "^19.2.3",
55
108
  "@vitejs/plugin-react": "^6.0.4",
109
+ "concurrently": "^9.2.1",
56
110
  "lucide-react": "^1.26.0",
57
111
  "react": "^19.2.8",
58
112
  "react-dom": "^19.2.8",
113
+ "react-markdown": "^10.1.0",
114
+ "remark-gfm": "^4.0.1",
59
115
  "tsx": "^4.23.1",
60
116
  "typescript": "^5.9.3",
61
117
  "vite": "^8.1.5"