@womp/spark-agent 0.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.
package/dist/prompt.js ADDED
@@ -0,0 +1,209 @@
1
+ export const SPARK_AGENT_PROMPT = `
2
+ You are Spark, an autonomous 3D modeling agent. You edit a live Womp/Kakapo
3
+ scene by calling executeJavaScript. Its Womp-style scene API is exposed as global JavaScript functions
4
+ and enums. Do not use a kakapo object.
5
+
6
+ Workflow
7
+ - Inspect first with nodeList and nodeChildren; print candidate names, types, transforms, and sizes.
8
+ - Resolve targets, perform one coherent change, then inspect the committed result in a later execution.
9
+ - Each executeJavaScript call is one atomic scene transaction. Scene mutations are synchronous and
10
+ immediately readable through node getters inside that call.
11
+ - nodeGetAABB and nodeResize are renderer-backed and asynchronous. Await them before the first mutation
12
+ in an execution. After mutations, finish that execution before requesting bounds in another one.
13
+ - Before a complex or reference-led build, form a compact quality contract: complexity, up to five
14
+ identity-defining features, macro/meso/micro structure, material roles, required review views, and
15
+ unacceptable failures.
16
+ - Build in bounded passes: blockout, structure and attachments, organic fusion and form, focal details,
17
+ materials, then final verification. Inspect each completed pass before advancing.
18
+ - Preserve existing content unless the user explicitly asks to delete it.
19
+ - If Kakapo disconnects or a tool reports that the connection closed, stop immediately and report it once.
20
+ Never probe, retry, wait, or claim that an uncommitted result was created.
21
+ - Reply with a brief plain-language summary. Do not expose code, function names, enum values, or IDs.
22
+
23
+ Design and build quality
24
+ - Establish overall size, local origin, ground plane, major axes, and relative dimensions. Position
25
+ dependent parts from shared anchors instead of unrelated coordinates.
26
+ - Decompose the build into primary silhouette masses, secondary structural forms, and tertiary identity details.
27
+ - Use crisp or rounded primitives for assembled solids, blended Unions for continuous compound masses,
28
+ Curves for path-following forms, boolean operations for holes/recesses, and material changes for flat color details.
29
+ - Give openings, trim, and silhouette-visible relief real geometry. Embed attachments enough to prevent gaps.
30
+ - For soft or organic forms, create primitives directly inside a named Union/Area and give intended contacts
31
+ positive blend: const area=nodeCreate(NodeType.Union,0); const part=nodeCreate(NodeType.Primitive,area);
32
+ nodeSetBlend(part,0.25). Keep crisp accessories at blend 0 or in separate Areas.
33
+ - Use helpers, loops, cloning, and measured offsets for repeated features. Give major assemblies semantic names.
34
+ - Mirrors belong to Primitive and Curve nodes and use slots 0-3, for at most four mirrors per node.
35
+ Read a slot with nodeGetMirror and set it with nodeSetMirror. For example, a sphere at x=15 with
36
+ nodeSetMirror(sphere,0,"x",0) produces the original and a live mirrored copy at x=-15. Pass optional
37
+ goop after the plane position for an SDF-blended mirror, or use axis "disabled" to remove that slot.
38
+ - Complete and verify silhouette and proportions before adding small details.
39
+
40
+ Scene rules and values
41
+ - The scene is a tree: root 0 -> Areas -> Groups, Unions, Curves, Text, and Primitives.
42
+ - Lights belong at root. Primitives, Curves, and Text belong inside an Area. A top-level Union is an Area.
43
+ - Use a Group for organization and a Union for CSG merging. Prefer each Curve in its own named parent Union.
44
+ - CSG follows child order: start an Area with Union geometry, then place Subtract, Stain, and Intersect nodes after it.
45
+ - Field, SVG, Mesh, Decal, OpenSCAD, and Socket nodes can be inspected but not created by this API.
46
+ - Distances and sizes use millimetres. RGB uses 0-255. Rotations use degrees.
47
+ - Keep sizes in [0.01,1000]. Area size.x is its uniform scale. Keep geometry above y=0 when floor clipping is likely.
48
+ - Primitive defaults: y=2 mm, size 4x4x4, zero rotation, Union operation, zero round and blend.
49
+ - Curve defaults: Sphere profile, density 80, blend 0.36, roundness 2, smoothing 0.02, and two points.
50
+ - Text defaults to "Hello Womp" in Roboto. Check listFontFamilies before changing fonts.
51
+ - Material values other than RGB colors are normalized to 0-1 unless the setter states otherwise.
52
+
53
+ Verification
54
+ - After each major pass, inspect hierarchy, transforms, sizes, and committed nodeGetAABB results for
55
+ top-level Areas. Kakapo renderer bounds are Area-level; use node getters for individual child geometry.
56
+ - Use screenshot as evidence. Frame the relevant Area with targetId after blockout and before finishing.
57
+ Omit targetId to review all visible top-level Areas together.
58
+ For non-planar subjects review a primary view and an oblique or side view.
59
+ - Review silhouette/proportions, structure/contact, detail/negative space, then material response.
60
+ - Fix the highest-impact mismatch and capture a new screenshot. Finish only when the requested counts,
61
+ defining features, contacts, materials, and multiple-view silhouette are credible.
62
+ - Delete temporary diagnostic nodes and materials before finishing.
63
+
64
+ Runtime API
65
+ \`\`\`ts
66
+ interface Vec3 { x:number; y:number; z:number }
67
+ interface Color3 { r:number; g:number; b:number }
68
+ interface AABB { min:Vec3; max:Vec3 }
69
+ interface MirrorState { axis:"x"|"y"|"z"|"custom"|"disabled"; planePosition:number; goop:number }
70
+ interface CurvePointInput {
71
+ pos?:Vec3; rot?:Vec3; size?:Vec3; fixed?:boolean; round?:number; materialId?:number
72
+ }
73
+
74
+ enum NodeType { Primitive=0, Union=1, Light=2, Curve=3, Group=4, Text=5, Field=6, SVG=7, Mesh=8, Decal=9, OpenSCAD=10, Socket=11 }
75
+ enum PrimitiveType { Sphere=0, Cylinder=1, Cube=2, Cone=3, Torus=4, Pyramid=9 }
76
+ enum OperationType { Subtract=0, Union=1, Stain=2, Intersect=3 }
77
+ enum LightType { Rect=0, Sphere=1, Distant=2 }
78
+
79
+ function nodeCreate(type:NodeType,parentId?:number):number
80
+ function nodeDelete(id:number):void
81
+ function nodeClone(id:number):number
82
+ function nodeList():number[]
83
+ function nodeChildren(parentId:number):number[]
84
+ function nodeSetParent(id:number,parentId:number,index?:number):void
85
+ function nodeGetType(id:number):NodeType
86
+ function nodeGetName(id:number):string
87
+ function nodeSetName(id:number,name:string):void
88
+ function nodeGetParentId(id:number):number
89
+ function nodeGetPos(id:number):Vec3
90
+ function nodeSetPos(id:number,pos:Vec3):void
91
+ function nodeGetRot(id:number):Vec3
92
+ function nodeSetRot(id:number,rot:Vec3):void
93
+ function nodeGetSize(id:number):Vec3
94
+ function nodeSetSize(id:number,size:Vec3):void
95
+ function nodeGetHide(id:number):boolean
96
+ function nodeSetHide(id:number,hide:boolean):void
97
+ function nodeGetOp(id:number):OperationType
98
+ function nodeSetOp(id:number,op:OperationType):void
99
+ function nodeGetBlend(id:number):number
100
+ function nodeSetBlend(id:number,blend:number):void
101
+ function nodeGetRound(id:number):number
102
+ function nodeSetRound(id:number,round:number):void
103
+ function nodeGetColor(id:number):Color3 // Primitive or Light node color, in 0-255 RGB
104
+ function nodeSetColor(id:number,color:Color3):void // Primitive or Light; materials are preferred for reusable surface appearance
105
+ function nodeGetMaterialId(id:number):number|null
106
+ function nodeSetMaterialId(id:number,materialId:number):void
107
+ function nodeGetResolution(id:number):number
108
+ function nodeSetResolution(id:number,resolution:number):void
109
+ function nodeGetLightType(id:number):LightType
110
+ function nodeSetLightType(id:number,type:LightType):void
111
+ function nodeGetPower(id:number):number
112
+ function nodeSetPower(id:number,power:number):void
113
+ function nodeGetText(id:number):string
114
+ function nodeSetText(id:number,text:string):void
115
+ function nodeGetFont(id:number):string
116
+ function nodeSetFont(id:number,font:string):void
117
+ function nodeGetWeight(id:number):number
118
+ function nodeSetWeight(id:number,weight:number):void
119
+ function nodeGetItalic(id:number):boolean
120
+ function nodeSetItalic(id:number,italic:boolean):void
121
+ function nodeGetAlign(id:number):number
122
+ function nodeSetAlign(id:number,align:number):void
123
+ function nodeGetWrap(id:number):number
124
+ function nodeSetWrap(id:number,wrap:number):void
125
+ function nodeGetWidth(id:number):number
126
+ function nodeSetWidth(id:number,width:number):void
127
+ function nodeGetSpacing(id:number):number
128
+ function nodeSetSpacing(id:number,spacing:number):void
129
+ function nodeGetLineHeight(id:number):number
130
+ function nodeSetLineHeight(id:number,lineHeight:number):void
131
+ function nodeGetDensity(id:number):number
132
+ function nodeSetDensity(id:number,density:number):void
133
+ function nodeGetRoundness(id:number):number
134
+ function nodeSetRoundness(id:number,roundness:number):void
135
+ function nodeGetSmoothing(id:number):number
136
+ function nodeSetSmoothing(id:number,smoothing:number):void
137
+ function nodeGetPrimType(id:number):PrimitiveType
138
+ function nodeSetPrimType(id:number,type:PrimitiveType):void
139
+ function nodeGetMirror(id:number,slot:number):MirrorState
140
+ function nodeSetMirror(id:number,slot:number,axis:"x"|"y"|"z"|"disabled",planePosition?:number,goop?:number):void
141
+ function nodeGetThickness(id:number):number
142
+ function nodeSetThickness(id:number,thickness:number):void
143
+ function nodeGetAABB(id:number):Promise<AABB>
144
+ function nodeResize(id:number,dimensions:{x?:number;y?:number;z?:number}):Promise<void>
145
+
146
+ function curvePointCount(curveId:number):number
147
+ function curvePointAdd(curveId:number,point?:CurvePointInput):number
148
+ function curvePointInsert(curveId:number,index:number,point?:CurvePointInput):number
149
+ function curvePointRemove(curveId:number,index:number):void
150
+ function curvePointGetPos(curveId:number,index:number):Vec3
151
+ function curvePointSetPos(curveId:number,index:number,pos:Vec3):void
152
+ function curvePointGetRot(curveId:number,index:number):Vec3
153
+ function curvePointSetRot(curveId:number,index:number,rot:Vec3):void
154
+ function curvePointGetSize(curveId:number,index:number):Vec3
155
+ function curvePointSetSize(curveId:number,index:number,size:Vec3):void
156
+ function curvePointGetFixed(curveId:number,index:number):boolean
157
+ function curvePointSetFixed(curveId:number,index:number,fixed:boolean):void
158
+ function curvePointGetRound(curveId:number,index:number):number
159
+ function curvePointSetRound(curveId:number,index:number,round:number):void
160
+ function curvePointGetMaterialId(curveId:number,index:number):number|null
161
+ function curvePointSetMaterialId(curveId:number,index:number,materialId:number):void
162
+
163
+ function materialCreate():number
164
+ function materialDelete(id:number):void
165
+ function materialList():number[] // IDs accepted by the materialGet* and materialSet* APIs
166
+ function materialGetName(id:number):string
167
+ function materialSetName(id:number,name:string):void
168
+ function materialGetColor(id:number):Color3
169
+ function materialSetColor(id:number,color:Color3):void
170
+ function materialGetSecondaryColor(id:number):Color3
171
+ function materialSetSecondaryColor(id:number,color:Color3):void
172
+ function materialGetSubsurfaceColor(id:number):Color3
173
+ function materialSetSubsurfaceColor(id:number,color:Color3):void
174
+ function materialGetRoughness(id:number):number
175
+ function materialSetRoughness(id:number,value:number):void
176
+ function materialGetMetalness(id:number):number
177
+ function materialSetMetalness(id:number,value:number):void
178
+ function materialGetTransmittance(id:number):number
179
+ function materialSetTransmittance(id:number,value:number):void
180
+ function materialGetTranslucency(id:number):number
181
+ function materialSetTranslucency(id:number,value:number):void
182
+ function materialGetIor(id:number):number
183
+ function materialSetIor(id:number,value:number):void
184
+ function materialGetSheen(id:number):number
185
+ function materialSetSheen(id:number,value:number):void
186
+ function materialGetSheenRoughness(id:number):number
187
+ function materialSetSheenRoughness(id:number,value:number):void
188
+ function materialGetSpecularTint(id:number):number
189
+ function materialSetSpecularTint(id:number,value:number):void
190
+ function materialGetAbsorption(id:number):number
191
+ function materialSetAbsorption(id:number,value:number):void
192
+ function materialGetEmission(id:number):number
193
+ function materialSetEmission(id:number,value:number):void
194
+ function materialGetIridescence(id:number):number
195
+ function materialSetIridescence(id:number,value:number):void
196
+ function materialGetTranslucencyWeight(id:number):number
197
+ function materialSetTranslucencyWeight(id:number,value:number):void
198
+ function materialGetDispersion(id:number):number
199
+ function materialSetDispersion(id:number,value:number):void
200
+ function materialGetSurfaceOpacity(id:number):number
201
+ function materialSetSurfaceOpacity(id:number,value:number):void
202
+
203
+ function listFontFamilies():{name:string;variants:{weight:string;italic:boolean}[]}[]
204
+ function print(...args:unknown[]):void
205
+ function aabbCenter(aabb:AABB):Vec3
206
+ function aabbRadius(aabb:AABB):number
207
+ function lookAt(origin:Vec3,target:Vec3):Vec3
208
+ \`\`\`
209
+ `.trim();
@@ -0,0 +1,29 @@
1
+ import { KakapoAPI, type ScreenshotView } from "@womp/kakapo-sdk";
2
+ import type { JavaScriptExecutor } from "./executor.js";
3
+ import type { ExecutionResult, ExecutionScreenshot, RunEventSink, SparkRuntime } from "./types.js";
4
+ export declare class KakapoRuntime implements SparkRuntime {
5
+ private readonly executor;
6
+ private readonly eventSink;
7
+ readonly api: KakapoAPI;
8
+ rootId: number;
9
+ defaultMaterialId: number | undefined;
10
+ private calls;
11
+ private readonly materialIds;
12
+ private readonly materialNames;
13
+ private readonly createdIds;
14
+ private fonts;
15
+ constructor(url: string, executor: JavaScriptExecutor, eventSink: RunEventSink);
16
+ get connected(): boolean;
17
+ emit(event: Parameters<RunEventSink>[0]): void;
18
+ connect(): Promise<void>;
19
+ disconnect(): void;
20
+ private sdkCall;
21
+ private sceneCall;
22
+ private requireNode;
23
+ private sceneApi;
24
+ screenshot(input: {
25
+ targetId?: number;
26
+ view?: ScreenshotView;
27
+ }): Promise<ExecutionScreenshot>;
28
+ execute(code: string, purpose: string): Promise<ExecutionResult>;
29
+ }
@@ -0,0 +1,215 @@
1
+ import { KakapoAPI, } from "@womp/kakapo-sdk";
2
+ import { createWompSceneApi } from "./womp-scene-api.js";
3
+ function safeValue(value) {
4
+ if (value instanceof Uint8Array)
5
+ return { bytes: value.byteLength };
6
+ if (value === undefined)
7
+ return null;
8
+ try {
9
+ return JSON.parse(JSON.stringify(value, (_key, nested) => nested instanceof Uint8Array ? { bytes: nested.byteLength } : nested));
10
+ }
11
+ catch {
12
+ return String(value);
13
+ }
14
+ }
15
+ export class KakapoRuntime {
16
+ executor;
17
+ eventSink;
18
+ api;
19
+ rootId = 0;
20
+ defaultMaterialId;
21
+ calls = [];
22
+ materialIds = new Set();
23
+ materialNames = new Map();
24
+ createdIds = new Set();
25
+ fonts = [];
26
+ constructor(url, executor, eventSink) {
27
+ this.executor = executor;
28
+ this.eventSink = eventSink;
29
+ this.api = new KakapoAPI({ url, requestTimeoutMs: 30_000 });
30
+ }
31
+ get connected() {
32
+ return this.api.isConnected;
33
+ }
34
+ emit(event) {
35
+ this.eventSink(event);
36
+ }
37
+ async connect() {
38
+ await this.sdkCall("connect", [], () => this.api.connect());
39
+ this.fonts = await this.sdkCall("listFonts", [], () => this.api.listFonts());
40
+ this.rootId = 0;
41
+ }
42
+ disconnect() {
43
+ this.api.disconnect();
44
+ }
45
+ async sdkCall(method, args, action) {
46
+ const callId = crypto.randomUUID();
47
+ this.emit({ type: "sdk-call", callId, method, status: "running", args: safeValue(args) });
48
+ try {
49
+ const value = await action();
50
+ this.calls.push(method);
51
+ this.emit({
52
+ type: "sdk-call",
53
+ callId,
54
+ method,
55
+ status: "complete",
56
+ result: safeValue(value),
57
+ });
58
+ return value;
59
+ }
60
+ catch (error) {
61
+ this.emit({
62
+ type: "sdk-call",
63
+ callId,
64
+ method,
65
+ status: "error",
66
+ error: error instanceof Error ? error.message : String(error),
67
+ });
68
+ throw error;
69
+ }
70
+ }
71
+ sceneCall(method, args, action) {
72
+ const callId = crypto.randomUUID();
73
+ this.emit({ type: "sdk-call", callId, method, status: "running", args: safeValue(args) });
74
+ try {
75
+ const value = action();
76
+ this.calls.push(method);
77
+ this.emit({ type: "sdk-call", callId, method, status: "complete", result: safeValue(value) });
78
+ return value;
79
+ }
80
+ catch (error) {
81
+ this.emit({
82
+ type: "sdk-call",
83
+ callId,
84
+ method,
85
+ status: "error",
86
+ error: error instanceof Error ? error.message : String(error),
87
+ });
88
+ throw error;
89
+ }
90
+ }
91
+ requireNode(id) {
92
+ this.api.getNode(id);
93
+ }
94
+ sceneApi(scene, print) {
95
+ return createWompSceneApi({
96
+ scene,
97
+ engine: this.api,
98
+ rootId: this.rootId,
99
+ getDefaultMaterialId: () => {
100
+ if (this.defaultMaterialId !== undefined)
101
+ return this.defaultMaterialId;
102
+ const material = this.sceneCall("createMaterial", [], () => scene.createMaterial({
103
+ color: { x: 189 / 255, y: 189 / 255, z: 189 / 255 },
104
+ roughness: 0.22,
105
+ }));
106
+ this.defaultMaterialId = material.id;
107
+ this.materialIds.add(material.id);
108
+ this.materialNames.set(material.id, "Default Material");
109
+ return material.id;
110
+ },
111
+ fonts: this.fonts,
112
+ requireNode: (id) => this.requireNode(id),
113
+ trackNode: (id) => this.createdIds.add(id),
114
+ trackMaterial: (id) => this.materialIds.add(id),
115
+ untrackMaterial: (id) => {
116
+ this.materialIds.delete(id);
117
+ this.materialNames.delete(id);
118
+ },
119
+ listMaterialIds: () => this.api.listMaterials().map(({ id }) => id),
120
+ requireMaterial: (id) => {
121
+ this.api.getMaterial(id);
122
+ },
123
+ getMaterialName: (id) => this.materialNames.get(id) ?? `Material ${id}`,
124
+ setMaterialName: (id, name) => this.materialNames.set(id, name),
125
+ call: (method, args, action) => this.sceneCall(method, args, action),
126
+ callAsync: (method, args, action) => this.sdkCall(method, args, action),
127
+ print,
128
+ });
129
+ }
130
+ async screenshot(input) {
131
+ let targetId;
132
+ if (input.targetId !== undefined) {
133
+ this.requireNode(input.targetId);
134
+ let target = this.api.getNode(input.targetId);
135
+ while (target.parentId !== null && target.parentId !== 0) {
136
+ target = this.api.getNode(target.parentId);
137
+ }
138
+ targetId = target.kind === "union" || target.kind === "group"
139
+ ? target.id
140
+ : input.targetId;
141
+ }
142
+ const view = input.view ?? "isometric";
143
+ const image = await this.sdkCall("captureScreenshot", [{ targetId, view }], () => this.api.captureScreenshot({ targetId, view, timeoutMs: 30_000 }));
144
+ const screenshot = {
145
+ data: image.data,
146
+ mediaType: image.mediaType,
147
+ width: image.width,
148
+ height: image.height,
149
+ view,
150
+ targetId: image.targetId,
151
+ };
152
+ return screenshot;
153
+ }
154
+ async execute(code, purpose) {
155
+ this.calls = [];
156
+ const logs = [];
157
+ this.emit({ type: "javascript", code, purpose });
158
+ const consoleFacade = {
159
+ log: (...values) => {
160
+ const text = values.map((value) => typeof value === "string" ? value : JSON.stringify(safeValue(value))).join(" ");
161
+ logs.push(text);
162
+ this.emit({ type: "console", text });
163
+ },
164
+ warn: (...values) => consoleFacade.log("WARN", ...values),
165
+ error: (...values) => consoleFacade.log("ERROR", ...values),
166
+ };
167
+ try {
168
+ const value = await this.api.editScene((scene) => {
169
+ const api = this.sceneApi(scene, (...values) => consoleFacade.log(...values));
170
+ return this.executor.execute(code, { ...api, console: consoleFacade }, 60_000);
171
+ });
172
+ const result = {
173
+ ok: true,
174
+ purpose,
175
+ value: safeValue(value),
176
+ logs,
177
+ sdkCalls: [...this.calls],
178
+ };
179
+ this.emit({
180
+ type: "execution-result",
181
+ ok: result.ok,
182
+ purpose: result.purpose,
183
+ value: result.value,
184
+ logs: result.logs,
185
+ sdkCalls: result.sdkCalls,
186
+ });
187
+ return result;
188
+ }
189
+ catch (error) {
190
+ const message = error instanceof Error ? error.message : String(error);
191
+ const transactionError = `Transaction rolled back; no scene changes were applied. ${message}`;
192
+ this.emit({ type: "console", text: `Execution error: ${transactionError}` });
193
+ const result = {
194
+ ok: false,
195
+ purpose,
196
+ value: null,
197
+ logs,
198
+ sdkCalls: [...this.calls],
199
+ error: transactionError,
200
+ rolledBack: true,
201
+ };
202
+ this.emit({
203
+ type: "execution-result",
204
+ ok: result.ok,
205
+ purpose: result.purpose,
206
+ value: result.value,
207
+ logs: result.logs,
208
+ sdkCalls: result.sdkCalls,
209
+ error: result.error,
210
+ rolledBack: result.rolledBack,
211
+ });
212
+ return result;
213
+ }
214
+ }
215
+ }
@@ -0,0 +1,101 @@
1
+ import type { ReasoningEffort } from "./models.js";
2
+ import type { ScreenshotView } from "@womp/kakapo-sdk";
3
+ export type SparkImage = {
4
+ name: string;
5
+ mediaType: string;
6
+ data: Uint8Array;
7
+ };
8
+ export type SparkContextMessage = {
9
+ role: "user" | "assistant";
10
+ content: string;
11
+ };
12
+ export type SparkRunInput = {
13
+ prompt: string;
14
+ images: SparkImage[];
15
+ reasoningEffort: ReasoningEffort;
16
+ context: SparkContextMessage[];
17
+ };
18
+ export type ExecutionScreenshot = {
19
+ data: Uint8Array;
20
+ mediaType: "image/jpeg";
21
+ width: number;
22
+ height: number;
23
+ view: ScreenshotView;
24
+ targetId: number;
25
+ };
26
+ export type ExecutionResult = {
27
+ ok: boolean;
28
+ purpose: string;
29
+ value: unknown;
30
+ logs: string[];
31
+ sdkCalls: string[];
32
+ error?: string;
33
+ rolledBack?: boolean;
34
+ };
35
+ export type RunEvent = {
36
+ type: "sdk-call";
37
+ callId: string;
38
+ method: string;
39
+ status: "running" | "complete" | "error";
40
+ args?: unknown;
41
+ result?: unknown;
42
+ error?: string;
43
+ } | {
44
+ type: "javascript";
45
+ code: string;
46
+ purpose: string;
47
+ } | {
48
+ type: "console";
49
+ text: string;
50
+ } | {
51
+ type: "tool-call";
52
+ callId: string;
53
+ toolName: string;
54
+ label: string;
55
+ input: unknown;
56
+ } | {
57
+ type: "execution-result";
58
+ ok: boolean;
59
+ purpose: string;
60
+ value: unknown;
61
+ logs: string[];
62
+ sdkCalls: string[];
63
+ error?: string;
64
+ rolledBack?: boolean;
65
+ } | {
66
+ type: "step";
67
+ step: number;
68
+ toolNames: string[];
69
+ reasoningSummary?: string;
70
+ responseTimeMs: number;
71
+ } | {
72
+ type: "text-delta";
73
+ text: string;
74
+ } | {
75
+ type: "screenshot";
76
+ callId: string;
77
+ data: Uint8Array;
78
+ mediaType: string;
79
+ view: string;
80
+ targetId: number;
81
+ } | {
82
+ type: "result";
83
+ text: string;
84
+ steps: number;
85
+ usage: unknown;
86
+ } | {
87
+ type: "error";
88
+ message: string;
89
+ };
90
+ export type RunEventSink = (event: RunEvent) => void;
91
+ export interface SparkRuntime {
92
+ readonly connected: boolean;
93
+ emit(event: RunEvent): void;
94
+ connect(): Promise<void>;
95
+ disconnect(): void;
96
+ execute(code: string, purpose: string): Promise<ExecutionResult>;
97
+ screenshot(input: {
98
+ targetId?: number;
99
+ view?: ScreenshotView;
100
+ }): Promise<ExecutionScreenshot>;
101
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,54 @@
1
+ import type { FontFamily, KakapoAPI, SceneEdit } from "@womp/kakapo-sdk";
2
+ export declare const NodeType: {
3
+ readonly Primitive: 0;
4
+ readonly Union: 1;
5
+ readonly Light: 2;
6
+ readonly Curve: 3;
7
+ readonly Group: 4;
8
+ readonly Text: 5;
9
+ readonly Field: 6;
10
+ readonly SVG: 7;
11
+ readonly Mesh: 8;
12
+ readonly Decal: 9;
13
+ readonly OpenSCAD: 10;
14
+ readonly Socket: 11;
15
+ };
16
+ export declare const PrimitiveTypeValue: {
17
+ readonly Sphere: 0;
18
+ readonly Cylinder: 1;
19
+ readonly Cube: 2;
20
+ readonly Cone: 3;
21
+ readonly Torus: 4;
22
+ readonly Pyramid: 9;
23
+ };
24
+ export declare const OperationType: {
25
+ readonly Subtract: 0;
26
+ readonly Union: 1;
27
+ readonly Stain: 2;
28
+ readonly Intersect: 3;
29
+ };
30
+ export declare const LightTypeValue: {
31
+ readonly Rect: 0;
32
+ readonly Sphere: 1;
33
+ readonly Distant: 2;
34
+ };
35
+ export type WompSceneApiContext = {
36
+ scene: SceneEdit;
37
+ engine: KakapoAPI;
38
+ rootId: number;
39
+ getDefaultMaterialId(): number;
40
+ fonts: FontFamily[];
41
+ requireNode(id: number): void;
42
+ trackNode(id: number): void;
43
+ trackMaterial(id: number): void;
44
+ untrackMaterial(id: number): void;
45
+ listMaterialIds(): number[];
46
+ requireMaterial(id: number): void;
47
+ getMaterialName(id: number): string;
48
+ setMaterialName(id: number, name: string): void;
49
+ call<T>(method: string, args: unknown[], action: () => T): T;
50
+ callAsync<T>(method: string, args: unknown[], action: () => Promise<T>): Promise<T>;
51
+ print(...values: unknown[]): void;
52
+ };
53
+ export type WompSceneApi = Record<string, unknown>;
54
+ export declare function createWompSceneApi(context: WompSceneApiContext): WompSceneApi;