@womp/spark-agent 0.3.1 → 1.0.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.
package/dist/pricing.js CHANGED
@@ -1,23 +1,36 @@
1
1
  // Standard, global, direct API rates in USD per million tokens, checked 2026-09-09.
2
2
  const PRICES = {
3
3
  "gpt-6-astra": {
4
- input: 10, read: 1, write: 12.5, output: 50, longContext: 272_000,
4
+ input: 10,
5
+ read: 1,
6
+ write: 12.5,
7
+ output: 50,
8
+ longContext: 272_000,
5
9
  source: "https://developers.openai.com/api/docs/models/gpt-6-astra",
6
10
  },
7
11
  "claude-opus-5": {
8
- input: 5, read: 0.5, write: 6.25, output: 25,
12
+ input: 5,
13
+ read: 0.5,
14
+ write: 6.25,
15
+ output: 25,
9
16
  source: "https://platform.claude.com/docs/en/models/opus-5/overview",
10
17
  },
11
18
  "claude-fable-5": {
12
- input: 10, read: 1, write: 12.5, output: 50,
19
+ input: 10,
20
+ read: 1,
21
+ write: 12.5,
22
+ output: 50,
13
23
  source: "https://platform.claude.com/docs/en/about-claude/pricing",
14
24
  },
15
25
  };
16
26
  export function calculateStepCost(modelId, usage) {
17
27
  const price = PRICES[modelId];
18
28
  const result = {
19
- modelId, pricingDate: "2026-09-09", source: price?.source,
20
- totalUsd: null, lines: [],
29
+ modelId,
30
+ pricingDate: "2026-09-09",
31
+ source: price?.source,
32
+ totalUsd: null,
33
+ lines: [],
21
34
  };
22
35
  const unavailable = (reason) => ({ ...result, reason });
23
36
  if (price === undefined)
@@ -44,9 +57,13 @@ export function calculateStepCost(modelId, usage) {
44
57
  }
45
58
  const fiveMinute = cache.ephemeral_5m_input_tokens;
46
59
  const oneHour = cache.ephemeral_1h_input_tokens;
47
- if (typeof fiveMinute !== "number" || typeof oneHour !== "number" ||
48
- Number.isSafeInteger(fiveMinute) === false || Number.isSafeInteger(oneHour) === false ||
49
- fiveMinute < 0 || oneHour < 0 || fiveMinute + oneHour !== write) {
60
+ if (typeof fiveMinute !== "number" ||
61
+ typeof oneHour !== "number" ||
62
+ Number.isSafeInteger(fiveMinute) === false ||
63
+ Number.isSafeInteger(oneHour) === false ||
64
+ fiveMinute < 0 ||
65
+ oneHour < 0 ||
66
+ fiveMinute + oneHour !== write) {
50
67
  return unavailable("Cache write duration was not reported completely.");
51
68
  }
52
69
  hourWrite = oneHour;
@@ -55,7 +72,10 @@ export function calculateStepCost(modelId, usage) {
55
72
  const inputMultiplier = longContext ? 2 : 1;
56
73
  const outputMultiplier = longContext ? 1.5 : 1;
57
74
  const line = (label, tokens, usdPerMillion) => ({
58
- label, tokens, usdPerMillion, usd: tokens * usdPerMillion / 1_000_000,
75
+ label,
76
+ tokens,
77
+ usdPerMillion,
78
+ usd: (tokens * usdPerMillion) / 1_000_000,
59
79
  });
60
80
  result.lines = [
61
81
  line("Uncached input", uncached, price.input * inputMultiplier),
package/dist/runtime.d.ts CHANGED
@@ -1,17 +1,43 @@
1
- import { KakapoAPI, type ScreenshotView } from "@womp/kakapo-sdk";
1
+ import { KakapoAPI, type FontFamily, type Scene } from "@womp/kakapo-sdk";
2
+ import type { ScreenshotView } from "@womp/kakapo-sdk";
3
+ import type { SceneStore, SceneTransaction } from "@womp/scene-api";
4
+ import { type KakapoEngine } from "@womp/scene-api/adapters/kakapo";
2
5
  import type { JavaScriptExecutor } from "./executor.js";
3
6
  import type { ExecutionResult, ExecutionScreenshot, SparkRuntimeEventSink, SparkRuntime } from "./types.js";
4
- import { type WompSceneApi } from "./womp-scene-api.js";
5
- import type { SparkInvocationContext } from "./capabilities.js";
7
+ import type { WompSceneDraft } from "./capabilities/scene-draft.js";
8
+ /**
9
+ * The `@womp/scene-api` seams over one Kakapo engine session, built once and
10
+ * reused for every read and every transaction.
11
+ *
12
+ * WHY `editScene` IS OPENED AND IMMEDIATELY CLOSED. `createKakapoSceneStore`
13
+ * needs a `SceneEdit`, and the only way to obtain one from a Kakapo engine is
14
+ * inside `editScene()`'s callback. The handle stays usable for every later
15
+ * transaction because its closures re-read the engine's current scene at call
16
+ * time rather than capturing a document eagerly -- which is also why `scene()`
17
+ * below is a fresh read each call and not a cached snapshot. Same construction
18
+ * as `@womp/spark-agent-host`'s `KakapoSparkRuntime.connect()`.
19
+ */
20
+ export type KakapoSceneSeams = {
21
+ store: SceneStore;
22
+ transaction: SceneTransaction;
23
+ /** The engine's CURRENT scene document, for `kakapoSceneRevision`. */
24
+ scene(): Scene;
25
+ };
26
+ export declare function composeKakapoSceneSeams(engine: KakapoEngine, fonts?: FontFamily[]): Promise<KakapoSceneSeams>;
27
+ /**
28
+ * `createSceneApi` returns `Record<string, unknown>` (its `SceneScriptApi`), so
29
+ * naming it as the draft the capability declares takes one cast. It is not a
30
+ * blind one: `test/kakapo-capability.test.ts`'s "the generated skill documents
31
+ * the exact executable draft surface" asserts set equality between
32
+ * `WompSceneDraft`'s members and the functions this object actually exposes, in
33
+ * both directions, so a drift on either side fails a test rather than surfacing
34
+ * as a `TypeError` inside a model-authored script.
35
+ */
36
+ export declare function asSceneDraft(api: Record<string, unknown>): WompSceneDraft;
6
37
  export declare class KakapoRuntime implements SparkRuntime {
7
38
  readonly api: KakapoAPI;
8
- rootId: number;
9
- defaultMaterialId: number | undefined;
10
39
  private calls;
11
- private readonly materialIds;
12
- private readonly materialNames;
13
- private readonly createdIds;
14
- private fonts;
40
+ private seams;
15
41
  private readonly executor;
16
42
  private eventSink;
17
43
  constructor(url: string);
@@ -23,15 +49,8 @@ export declare class KakapoRuntime implements SparkRuntime {
23
49
  connect(): Promise<void>;
24
50
  disconnect(): void;
25
51
  private sdkCall;
26
- private sceneCall;
27
- private requireNode;
52
+ private requireSeams;
28
53
  private sceneApi;
29
- inspect(): Promise<{
30
- revision: string;
31
- scene: import("@womp/kakapo-sdk").Scene;
32
- }>;
33
- private sceneRevision;
34
- edit<T>(callback: (draft: WompSceneApi) => Promise<T> | T, expectedRevision: string, context: SparkInvocationContext): Promise<T>;
35
54
  screenshot(input: {
36
55
  targetId?: number;
37
56
  view?: ScreenshotView;
package/dist/runtime.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { KakapoAPI } from "@womp/kakapo-sdk";
2
+ import { createSceneApi } from "@womp/scene-api";
3
+ import { createKakapoSceneStore, createKakapoTransaction, } from "@womp/scene-api/adapters/kakapo";
2
4
  import { QuickJSJavaScriptExecutor } from "./quickjs-executor.js";
3
- import { createWompSceneApi } from "./womp-scene-api.js";
4
5
  function safeValue(value) {
5
6
  if (value instanceof Uint8Array)
6
7
  return { bytes: value.byteLength };
@@ -13,15 +14,73 @@ function safeValue(value) {
13
14
  return String(value);
14
15
  }
15
16
  }
17
+ /**
18
+ * Kakapo has no library-material concept, so `pending` stays absent -- the
19
+ * "backing with no queue" case `@womp/scene-api`'s `MaterialCatalog` documents.
20
+ * `nodeSetMaterialId` with a NAME still fails loudly rather than silently
21
+ * dropping the assignment.
22
+ */
23
+ const KAKAPO_MATERIAL_CATALOG = {
24
+ listSuperMaterialNames: () => [],
25
+ };
26
+ export async function composeKakapoSceneSeams(engine, fonts) {
27
+ // Prefetched because `listFonts()` is an async RPC while the seam's
28
+ // `listFontFamilies` is synchronous.
29
+ const resolved = fonts ?? (await engine.listFonts());
30
+ let captured;
31
+ await engine.editScene((scene) => {
32
+ captured = scene;
33
+ });
34
+ if (captured === undefined) {
35
+ throw new Error("engine.editScene() resolved without invoking its callback.");
36
+ }
37
+ const edit = captured;
38
+ return {
39
+ store: createKakapoSceneStore(edit, engine, { fonts: resolved }),
40
+ transaction: createKakapoTransaction(engine),
41
+ scene: () => edit.getScene(),
42
+ };
43
+ }
44
+ /**
45
+ * `createSceneApi` returns `Record<string, unknown>` (its `SceneScriptApi`), so
46
+ * naming it as the draft the capability declares takes one cast. It is not a
47
+ * blind one: `test/kakapo-capability.test.ts`'s "the generated skill documents
48
+ * the exact executable draft surface" asserts set equality between
49
+ * `WompSceneDraft`'s members and the functions this object actually exposes, in
50
+ * both directions, so a drift on either side fails a test rather than surfacing
51
+ * as a `TypeError` inside a model-authored script.
52
+ */
53
+ export function asSceneDraft(api) {
54
+ return api;
55
+ }
56
+ /**
57
+ * Records every WRITE method invoked on `store`, in call order, once the call
58
+ * has succeeded -- the `sdkCalls` the old per-call `sceneCall` wrapper
59
+ * reported. Read methods (`get*`/`list*`/`child*`) were never routed through it
60
+ * either, and are excluded so `sdkCalls` says what the script CHANGED rather
61
+ * than what it merely inspected. Ported from `@womp/spark-agent-host`.
62
+ */
63
+ function trackedStore(store, calls) {
64
+ const readPrefixes = ["get", "list", "child"];
65
+ return new Proxy(store, {
66
+ get(target, property, receiver) {
67
+ const value = Reflect.get(target, property, receiver);
68
+ if (typeof value !== "function" || typeof property !== "string")
69
+ return value;
70
+ if (readPrefixes.some((prefix) => property.startsWith(prefix)))
71
+ return value.bind(target);
72
+ return (...args) => {
73
+ const result = value.apply(target, args);
74
+ calls.push(property);
75
+ return result;
76
+ };
77
+ },
78
+ });
79
+ }
16
80
  export class KakapoRuntime {
17
81
  api;
18
- rootId = 0;
19
- defaultMaterialId;
20
82
  calls = [];
21
- materialIds = new Set();
22
- materialNames = new Map();
23
- createdIds = new Set();
24
- fonts = [];
83
+ seams;
25
84
  executor;
26
85
  eventSink;
27
86
  constructor(url, executorOrEventSink, eventSink) {
@@ -45,15 +104,21 @@ export class KakapoRuntime {
45
104
  }
46
105
  async connect() {
47
106
  await this.sdkCall("connect", [], () => this.api.connect());
48
- this.fonts = await this.sdkCall("listFonts", [], () => this.api.listFonts());
49
- this.rootId = 0;
107
+ const fonts = await this.sdkCall("listFonts", [], () => this.api.listFonts());
108
+ this.seams = await composeKakapoSceneSeams(this.api, fonts);
50
109
  }
51
110
  disconnect() {
52
111
  this.api.disconnect();
53
112
  }
54
113
  async sdkCall(method, args, action) {
55
114
  const callId = crypto.randomUUID();
56
- this.emit({ type: "sdk-call", callId, method, status: "running", args: safeValue(args) });
115
+ this.emit({
116
+ type: "sdk-call",
117
+ callId,
118
+ method,
119
+ status: "running",
120
+ args: safeValue(args),
121
+ });
57
122
  try {
58
123
  const value = await action();
59
124
  this.calls.push(method);
@@ -77,111 +142,23 @@ export class KakapoRuntime {
77
142
  throw error;
78
143
  }
79
144
  }
80
- sceneCall(method, args, action) {
81
- const callId = crypto.randomUUID();
82
- this.emit({ type: "sdk-call", callId, method, status: "running", args: safeValue(args) });
83
- try {
84
- const value = action();
85
- this.calls.push(method);
86
- this.emit({ type: "sdk-call", callId, method, status: "complete", result: safeValue(value) });
87
- return value;
88
- }
89
- catch (error) {
90
- this.emit({
91
- type: "sdk-call",
92
- callId,
93
- method,
94
- status: "error",
95
- error: error instanceof Error ? error.message : String(error),
96
- });
97
- throw error;
145
+ requireSeams(caller) {
146
+ if (this.seams === undefined) {
147
+ throw new Error(`${caller}: connect() must resolve before the scene can be reached.`);
98
148
  }
149
+ return this.seams;
99
150
  }
100
- requireNode(id) {
101
- this.api.getNode(id);
102
- }
103
- sceneApi(scene, print) {
104
- return createWompSceneApi({
105
- scene,
106
- engine: this.api,
107
- rootId: this.rootId,
108
- getDefaultMaterialId: () => {
109
- if (this.defaultMaterialId !== undefined)
110
- return this.defaultMaterialId;
111
- const material = this.sceneCall("createMaterial", [], () => scene.createMaterial({
112
- color: { x: 189 / 255, y: 189 / 255, z: 189 / 255 },
113
- roughness: 0.22,
114
- }));
115
- this.defaultMaterialId = material.id;
116
- this.materialIds.add(material.id);
117
- this.materialNames.set(material.id, "Default Material");
118
- return material.id;
119
- },
120
- fonts: this.fonts,
121
- requireNode: (id) => this.requireNode(id),
122
- trackNode: (id) => this.createdIds.add(id),
123
- trackMaterial: (id) => this.materialIds.add(id),
124
- untrackMaterial: (id) => {
125
- this.materialIds.delete(id);
126
- this.materialNames.delete(id);
127
- },
128
- listMaterialIds: () => this.api.listMaterials().map(({ id }) => id),
129
- requireMaterial: (id) => {
130
- this.api.getMaterial(id);
131
- },
132
- getMaterialName: (id) => this.materialNames.get(id) ?? `Material ${id}`,
133
- setMaterialName: (id, name) => this.materialNames.set(id, name),
134
- call: (method, args, action) => this.sceneCall(method, args, action),
135
- callAsync: (method, args, action) => this.sdkCall(method, args, action),
151
+ sceneApi(seams, print) {
152
+ return createSceneApi({
153
+ store: trackedStore(seams.store, this.calls),
154
+ transaction: seams.transaction,
155
+ catalog: KAKAPO_MATERIAL_CATALOG,
136
156
  print,
137
157
  });
138
158
  }
139
- async inspect() {
140
- await this.api.refreshScene();
141
- return { revision: await this.sceneRevision(), scene: this.api.getScene() };
142
- }
143
- async sceneRevision() {
144
- const bytes = new TextEncoder().encode(JSON.stringify(this.api.getScene()));
145
- const digest = await crypto.subtle.digest("SHA-256", bytes);
146
- return Array.from(new Uint8Array(digest), (value) => value.toString(16).padStart(2, "0")).join("");
147
- }
148
- async edit(callback, expectedRevision, context) {
149
- let callbackCompleted = false;
150
- let changed = false;
151
- const receipt = {
152
- id: crypto.randomUUID(),
153
- capability: "scene",
154
- operation: "edit",
155
- };
156
- let value;
157
- try {
158
- value = await this.api.editScene(async (scene) => {
159
- context.signal.throwIfAborted();
160
- if ((await this.sceneRevision()) !== expectedRevision) {
161
- throw new Error("Scene changed since inspection. Read the scene again before editing.");
162
- }
163
- const result = await callback(this.sceneApi(scene, () => undefined));
164
- context.signal.throwIfAborted();
165
- changed = (await this.sceneRevision()) !== expectedRevision;
166
- callbackCompleted = true;
167
- return result;
168
- });
169
- }
170
- catch (error) {
171
- await context.recordReceipt({
172
- ...receipt,
173
- status: callbackCompleted ? "unknown" : "rolled_back",
174
- });
175
- throw error;
176
- }
177
- if (changed)
178
- await context.recordReceipt({ ...receipt, status: "committed" });
179
- return value;
180
- }
181
159
  async screenshot(input) {
182
160
  let targetId;
183
161
  if (input.targetId !== undefined) {
184
- this.requireNode(input.targetId);
185
162
  let target = this.api.getNode(input.targetId);
186
163
  while (target.parentId !== null && target.parentId !== 0) {
187
164
  target = this.api.getNode(target.parentId);
@@ -201,6 +178,7 @@ export class KakapoRuntime {
201
178
  return screenshot;
202
179
  }
203
180
  async execute(code, purpose) {
181
+ const seams = this.requireSeams("execute");
204
182
  this.calls = [];
205
183
  const logs = [];
206
184
  this.emit({ type: "javascript", code, purpose });
@@ -215,11 +193,15 @@ export class KakapoRuntime {
215
193
  warn: (...values) => consoleFacade.log("WARN", ...values),
216
194
  error: (...values) => consoleFacade.log("ERROR", ...values),
217
195
  };
218
- try {
219
- const value = await this.api.editScene((scene) => {
220
- const api = this.sceneApi(scene, (...values) => consoleFacade.log(...values));
221
- return this.executor.execute(code, { ...api, console: consoleFacade }, 60_000);
222
- });
196
+ let value;
197
+ const globals = {
198
+ ...this.sceneApi(seams, (...values) => consoleFacade.log(...values)),
199
+ console: consoleFacade,
200
+ };
201
+ const failure = await seams.transaction.run(async () => {
202
+ value = await this.executor.execute(code, globals, 60_000);
203
+ });
204
+ if (failure === null) {
223
205
  const result = {
224
206
  ok: true,
225
207
  purpose,
@@ -237,30 +219,30 @@ export class KakapoRuntime {
237
219
  });
238
220
  return result;
239
221
  }
240
- catch (error) {
241
- const message = error instanceof Error ? error.message : String(error);
242
- const transactionError = `Transaction rolled back; no scene changes were applied. ${message}`;
243
- this.emit({ type: "console", text: `Execution error: ${transactionError}` });
244
- const result = {
245
- ok: false,
246
- purpose,
247
- value: null,
248
- logs,
249
- sdkCalls: [...this.calls],
250
- error: transactionError,
251
- rolledBack: true,
252
- };
253
- this.emit({
254
- type: "execution-result",
255
- ok: result.ok,
256
- purpose: result.purpose,
257
- value: result.value,
258
- logs: result.logs,
259
- sdkCalls: result.sdkCalls,
260
- error: result.error,
261
- rolledBack: result.rolledBack,
262
- });
263
- return result;
264
- }
222
+ const transactionError = `Transaction rolled back; no scene changes were applied. ${failure.message}`;
223
+ this.emit({
224
+ type: "console",
225
+ text: `Execution error: ${transactionError}`,
226
+ });
227
+ const result = {
228
+ ok: false,
229
+ purpose,
230
+ value: null,
231
+ logs,
232
+ sdkCalls: [...this.calls],
233
+ error: transactionError,
234
+ rolledBack: true,
235
+ };
236
+ this.emit({
237
+ type: "execution-result",
238
+ ok: result.ok,
239
+ purpose: result.purpose,
240
+ value: result.value,
241
+ logs: result.logs,
242
+ sdkCalls: result.sdkCalls,
243
+ error: result.error,
244
+ rolledBack: result.rolledBack,
245
+ });
246
+ return result;
265
247
  }
266
248
  }
@@ -44,10 +44,12 @@ export function createSparkAgentRouter(options) {
44
44
  });
45
45
  router.post("/conversations", async (request, response) => {
46
46
  const ownerId = await resolveOwnerId(request);
47
- const body = z.object({
47
+ const body = z
48
+ .object({
48
49
  id: z.string().min(1).optional(),
49
50
  title: z.string().max(200).optional(),
50
- }).parse(request.body ?? {});
51
+ })
52
+ .parse(request.body ?? {});
51
53
  const conversation = await options.service.createConversation(ownerId, body);
52
54
  response.status(201).json({ conversation });
53
55
  });
@@ -4,5 +4,5 @@ export { createSparkRunExecutor, type ResolvedSparkModel, type SparkRunExecutorO
4
4
  export { SparkAgentService, SparkServiceError } from "./service.js";
5
5
  export type { SubmitSparkMessageInput } from "./service.js";
6
6
  export { MemorySparkAgentStore } from "./store.js";
7
- export { createStandaloneSparkAgentApp, type StandaloneSparkAgentOptions, } from "./standalone.js";
7
+ export { createStandaloneSparkAgentApp, type StandaloneSparkAgentOptions } from "./standalone.js";
8
8
  export type { SparkAgentStore, SparkConversation, SparkConversationSummary, SparkRun, SparkRunExecutionContext, SparkRunExecutor, SparkRunSettings, } from "./types.js";
@@ -2,4 +2,4 @@ export { MemorySparkArtifactStore } from "./artifacts.js";
2
2
  export { createSparkRunExecutor, } from "./executor.js";
3
3
  export { SparkAgentService, SparkServiceError } from "./service.js";
4
4
  export { MemorySparkAgentStore } from "./store.js";
5
- export { createStandaloneSparkAgentApp, } from "./standalone.js";
5
+ export { createStandaloneSparkAgentApp } from "./standalone.js";
@@ -3,9 +3,9 @@ import { createOpenAI } from "@ai-sdk/openai";
3
3
  import express from "express";
4
4
  import { getSparkModel, SPARK_MODELS } from "../models.js";
5
5
  import { KakapoRuntime } from "../runtime.js";
6
- import { composeCapabilities, createAccountCapability } from "../capabilities.js";
6
+ import { composeCapabilities, createAccountCapability, createSceneCapability, } from "../capabilities.js";
7
7
  import { createDemoAccountHost } from "./demo-account.js";
8
- import { createKakapoSceneCapability } from "../kakapo-capability.js";
8
+ import { createKakapoSceneHost } from "../kakapo-capability.js";
9
9
  import { QuickJSJavaScriptExecutor } from "../quickjs-executor.js";
10
10
  import { sparkModelOptions } from "../model-options.js";
11
11
  import { MemorySparkArtifactStore } from "./artifacts.js";
@@ -25,7 +25,13 @@ export function createStandaloneSparkAgentApp(options) {
25
25
  return {
26
26
  executor: new QuickJSJavaScriptExecutor(),
27
27
  capabilities: composeCapabilities({
28
- scene: createKakapoSceneCapability(runtime, (image) => artifactStore.write(context.ownerId, image)),
28
+ // The unified surface: the same `SceneHost` contract, the same
29
+ // `scene-editing` v2 skill and the same `@womp/scene-api` functions
30
+ // the browser runs on, rather than this package's retired second
31
+ // scene layer.
32
+ scene: createSceneCapability(createKakapoSceneHost(runtime.api, {
33
+ saveImage: (image) => artifactStore.write(context.ownerId, image),
34
+ })),
29
35
  ...(options.developmentProfile === "demo-account"
30
36
  ? { account: createAccountCapability(createDemoAccountHost()) }
31
37
  : {}),
@@ -63,8 +63,6 @@ export class MemorySparkAgentStore {
63
63
  const chunks = this.chunks.get(runId);
64
64
  if (chunks === undefined)
65
65
  throw new Error(`Run ${runId} does not exist.`);
66
- return chunks
67
- .filter(({ sequence }) => sequence > afterSequence)
68
- .map(copy);
66
+ return chunks.filter(({ sequence }) => sequence > afterSequence).map(copy);
69
67
  }
70
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@womp/spark-agent",
3
- "version": "0.3.1",
3
+ "version": "1.0.1",
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",
@@ -84,15 +84,16 @@
84
84
  "dev:web": "vite --config web/vite.config.ts",
85
85
  "start": "node dist/cli.js",
86
86
  "web:build": "yarn build && tsc --noEmit -p web/tsconfig.json && vite build --config web/vite.config.ts",
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')])\"",
88
- "test:live": "tsx --tsconfig tsconfig.json test/womp-scene-api.live.ts",
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'), import('@womp/spark-agent/kakapo')])\"",
88
+ "test:live": "tsx --tsconfig tsconfig.json test/kakapo-runtime.live.ts",
89
89
  "prepack": "yarn build"
90
90
  },
91
91
  "dependencies": {
92
92
  "@ai-sdk/anthropic": "4.0.50",
93
93
  "@ai-sdk/openai": "4.0.63",
94
94
  "@jitl/quickjs-wasmfile-release-sync": "0.32.0",
95
- "@womp/kakapo-sdk": "0.1.0",
95
+ "@womp/kakapo-sdk": "0.2.0",
96
+ "@womp/scene-api": "0.2.0",
96
97
  "ai": "7.0.95",
97
98
  "eventsource-parser": "^3.0.6",
98
99
  "express": "^5.2.1",
@@ -108,6 +109,8 @@
108
109
  "@vitejs/plugin-react": "^6.0.4",
109
110
  "concurrently": "^9.2.1",
110
111
  "lucide-react": "^1.26.0",
112
+ "prettier": "^3.8.1",
113
+ "pretty-quick": "^4.2.2",
111
114
  "react": "^19.2.8",
112
115
  "react-dom": "^19.2.8",
113
116
  "react-markdown": "^10.1.0",
package/.env.example DELETED
@@ -1,4 +0,0 @@
1
- OPENAI_API_KEY=
2
- ANTHROPIC_API_KEY=
3
- KAKAPO_URL=ws://127.0.0.1:5502
4
- PORT=8787
@@ -1,22 +0,0 @@
1
- import type { Transform, Vec3 } from "@womp/kakapo-sdk";
2
- export declare const INTERNAL_UNITS_PER_MM: number;
3
- export declare const WOMP_BLEND_MULTIPLIER = 55;
4
- export declare const MAX_ENGINE_BLEND = 500;
5
- export declare const MAX_GOOP_MM: number;
6
- export declare const MAX_MIRROR_GOOP_MM = 1000;
7
- export declare function toEnginePosition(value: Vec3): Vec3;
8
- export declare function fromEnginePosition(value: Vec3): Vec3;
9
- export declare function toEngineDimensions(value: Vec3): Vec3;
10
- export declare function fromEngineDimensions(value: Vec3): Vec3;
11
- export declare function convertRotationBasis(value: Vec3): Vec3;
12
- export declare function toEngineTransform(input: {
13
- position?: Vec3;
14
- rotation?: Vec3;
15
- dimensions?: Vec3;
16
- }): Partial<Transform>;
17
- export declare function toEngineBlend(goopMm: number): number;
18
- export declare function fromEngineBlend(blend: number): number;
19
- export declare function toEngineMirrorGoop(goopMm: number): number;
20
- export type MirrorAxis = "x" | "y" | "z";
21
- export declare function toEngineMirrorRotation(axis: MirrorAxis): Vec3;
22
- export declare function fromEngineMirrorRotation(rotation: Vec3): MirrorAxis | undefined;