@womp/spark-agent 7.0.0 → 8.0.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.
@@ -133,7 +133,7 @@ function normalizePrimitiveSize(primitive, size) {
133
133
  function scale(value, amount) {
134
134
  return { x: value.x * amount, y: value.y * amount, z: value.z * amount };
135
135
  }
136
- function convertAABB(box, unitMultiplier) {
136
+ export function convertAABB(box, unitMultiplier) {
137
137
  return {
138
138
  min: {
139
139
  x: fromEnginePosition({ x: 0, y: 0, z: box.max.z }, unitMultiplier).x,
@@ -147,6 +147,41 @@ function convertAABB(box, unitMultiplier) {
147
147
  },
148
148
  };
149
149
  }
150
+ function sceneAncestorScale(reader, rootId, id, includeSelf = false) {
151
+ let total = 1;
152
+ let current = includeSelf
153
+ ? reader.requireNode(id)
154
+ : reader.getNode(reader.requireNode(id).parentId ?? rootId);
155
+ const visited = new Set();
156
+ while (current.id !== rootId && !visited.has(current.id)) {
157
+ visited.add(current.id);
158
+ if (current.kind === "union")
159
+ total *= current.transform.scale.x;
160
+ const parentId = current.parentId;
161
+ if (parentId === null || parentId === rootId)
162
+ break;
163
+ current = reader.getNode(parentId);
164
+ }
165
+ return total;
166
+ }
167
+ export function sceneNodePosition(reader, rootId, unitMultiplier, id) {
168
+ return fromEnginePosition(scale(reader.requireNode(id).transform.position, sceneAncestorScale(reader, rootId, id)), unitMultiplier);
169
+ }
170
+ export function sceneNodeRotation(reader, id) {
171
+ return convertRotationBasis(reader.requireNode(id).transform.rotation);
172
+ }
173
+ export function sceneNodeSize(reader, rootId, unitMultiplier, id) {
174
+ const node = reader.requireNode(id);
175
+ const parentScale = sceneAncestorScale(reader, rootId, id);
176
+ if (node.kind === "group")
177
+ return { x: 1, y: 1, z: 1 };
178
+ if (node.kind === "union") {
179
+ const size = node.transform.scale.x * parentScale;
180
+ return { x: size, y: size, z: size };
181
+ }
182
+ const size = fromEngineDimensions(scale(node.transform.scale, parentScale), unitMultiplier);
183
+ return node.kind === "primitive" ? normalizePrimitiveSize(node.primitive, size) : size;
184
+ }
150
185
  /** Align local +Z toward target. Both points are in the same parent-local coordinates. */
151
186
  function lookAt(origin, target) {
152
187
  if (![origin.x, origin.y, origin.z, target.x, target.y, target.z].every(Number.isFinite)) {
@@ -209,25 +244,10 @@ export function createWompSceneApi(context) {
209
244
  throw new Error("Curve V1 and V2 transforms are read-only");
210
245
  return node;
211
246
  };
212
- const ancestorScale = (id, includeSelf = false) => {
213
- let total = 1;
214
- let current = includeSelf
215
- ? requireNode(id)
216
- : scene.getNode(requireNode(id).parentId ?? context.rootId);
217
- const visited = new Set();
218
- while (current.id !== context.rootId && !visited.has(current.id)) {
219
- visited.add(current.id);
220
- if (current.kind === "union")
221
- total *= current.transform.scale.x;
222
- const parentId = current.parentId;
223
- if (parentId === null || parentId === context.rootId)
224
- break;
225
- current = scene.getNode(parentId);
226
- }
227
- return total;
228
- };
229
- const nodePosition = (id) => fromEnginePosition(scale(requireNode(id).transform.position, ancestorScale(id)), unitMultiplier);
230
- const nodeRotation = (id) => convertRotationBasis(requireNode(id).transform.rotation);
247
+ const reader = { requireNode, getNode: (id) => scene.getNode(id) };
248
+ const ancestorScale = (id, includeSelf = false) => sceneAncestorScale(reader, context.rootId, id, includeSelf);
249
+ const nodePosition = (id) => sceneNodePosition(reader, context.rootId, unitMultiplier, id);
250
+ const nodeRotation = (id) => sceneNodeRotation(reader, id);
231
251
  const hasCsgBaseBefore = (parentId, nodeId, index) => {
232
252
  const siblings = scene.getNodeChildren(parentId).filter(({ id }) => id !== nodeId);
233
253
  const targetIndex = index ?? siblings.length;
@@ -237,18 +257,7 @@ export function createWompSceneApi(context) {
237
257
  sibling.kind === "group" ||
238
258
  ("operation" in sibling && sibling.operation === "union"));
239
259
  };
240
- const nodeSize = (id) => {
241
- const node = requireNode(id);
242
- const parentScale = ancestorScale(id);
243
- if (node.kind === "group")
244
- return { x: 1, y: 1, z: 1 };
245
- if (node.kind === "union") {
246
- const size = node.transform.scale.x * parentScale;
247
- return { x: size, y: size, z: size };
248
- }
249
- const size = fromEngineDimensions(scale(node.transform.scale, parentScale), unitMultiplier);
250
- return node.kind === "primitive" ? normalizePrimitiveSize(node.primitive, size) : size;
251
- };
260
+ const nodeSize = (id) => sceneNodeSize(reader, context.rootId, unitMultiplier, id);
252
261
  const update = (id, changes) => {
253
262
  context.call("updateNode", [id, changes], () => scene.updateNode(id, changes));
254
263
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@womp/spark-agent",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
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",
@@ -113,7 +113,7 @@
113
113
  "@ai-sdk/google": "4.0.69",
114
114
  "@ai-sdk/openai": "4.0.63",
115
115
  "@jitl/quickjs-wasmfile-release-sync": "0.32.0",
116
- "@womp/flowir": "0.3.0",
116
+ "@womp/flowir": "0.5.0",
117
117
  "@womp/kakapo-sdk": "0.8.0",
118
118
  "ai": "7.0.95",
119
119
  "eventsource-parser": "^3.0.6",