@womp/spark-agent 0.1.0 → 0.3.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 (113) hide show
  1. package/.env.example +4 -0
  2. package/README.md +295 -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 +264 -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
package/dist/models.d.ts CHANGED
@@ -9,23 +9,11 @@ export type SparkModel = {
9
9
  reasoningEfforts: readonly ReasoningEffort[];
10
10
  };
11
11
  export declare const SPARK_MODELS: readonly [{
12
- readonly id: "gpt-5.6-sol";
13
- readonly label: "GPT-5.6 Sol";
12
+ readonly id: "gpt-6-astra";
13
+ readonly label: "GPT-6 Astra";
14
14
  readonly note: "Best OpenAI quality";
15
15
  readonly provider: "openai";
16
16
  readonly reasoningEfforts: readonly ["low", "medium", "high", "xhigh", "max"];
17
- }, {
18
- readonly id: "gpt-5.6-terra";
19
- readonly label: "GPT-5.6 Terra";
20
- readonly note: "Balanced OpenAI model";
21
- readonly provider: "openai";
22
- readonly reasoningEfforts: readonly ["low", "medium", "high", "xhigh", "max"];
23
- }, {
24
- readonly id: "gpt-5.6-luna";
25
- readonly label: "GPT-5.6 Luna";
26
- readonly note: "Fast OpenAI model";
27
- readonly provider: "openai";
28
- readonly reasoningEfforts: readonly ["low", "medium", "high", "xhigh", "max"];
29
17
  }, {
30
18
  readonly id: "claude-opus-5";
31
19
  readonly label: "Opus 5";
@@ -39,6 +27,6 @@ export declare const SPARK_MODELS: readonly [{
39
27
  readonly provider: "anthropic";
40
28
  readonly reasoningEfforts: readonly ["low", "medium", "high", "xhigh", "max"];
41
29
  }];
42
- export declare const DEFAULT_MODEL_ID: "gpt-5.6-sol";
30
+ export declare const DEFAULT_MODEL_ID: "gpt-6-astra";
43
31
  export declare function getSparkModel(id: string): SparkModel;
44
32
  export declare function resolveReasoningEffort(modelId: string, effort: string): ReasoningEffort;
package/dist/models.js CHANGED
@@ -14,26 +14,12 @@ const EXTENDED_REASONING_EFFORTS = [
14
14
  ];
15
15
  export const SPARK_MODELS = [
16
16
  {
17
- id: "gpt-5.6-sol",
18
- label: "GPT-5.6 Sol",
17
+ id: "gpt-6-astra",
18
+ label: "GPT-6 Astra",
19
19
  note: "Best OpenAI quality",
20
20
  provider: "openai",
21
21
  reasoningEfforts: EXTENDED_REASONING_EFFORTS,
22
22
  },
23
- {
24
- id: "gpt-5.6-terra",
25
- label: "GPT-5.6 Terra",
26
- note: "Balanced OpenAI model",
27
- provider: "openai",
28
- reasoningEfforts: EXTENDED_REASONING_EFFORTS,
29
- },
30
- {
31
- id: "gpt-5.6-luna",
32
- label: "GPT-5.6 Luna",
33
- note: "Fast OpenAI model",
34
- provider: "openai",
35
- reasoningEfforts: EXTENDED_REASONING_EFFORTS,
36
- },
37
23
  {
38
24
  id: "claude-opus-5",
39
25
  label: "Opus 5",
@@ -0,0 +1,5 @@
1
+ import type { JavaScriptExecutor, JavaScriptGlobals, JavaScriptUserWait } from "./executor.js";
2
+ /** Executes in the page realm. Timers and cancellation cannot preempt synchronous code. */
3
+ export declare class NativeJavaScriptExecutor implements JavaScriptExecutor {
4
+ execute(code: string, globals: JavaScriptGlobals, timeoutMs: number, signal?: AbortSignal, userWait?: JavaScriptUserWait): Promise<unknown>;
5
+ }
@@ -0,0 +1,92 @@
1
+ import { ExecutionBudget } from "./execution-lifetime.js";
2
+ /** Executes in the page realm. Timers and cancellation cannot preempt synchronous code. */
3
+ export class NativeJavaScriptExecutor {
4
+ async execute(code, globals, timeoutMs, signal, userWait) {
5
+ if (new TextEncoder().encode(code).byteLength > 256 * 1024) {
6
+ throw new Error("JavaScript exceeded the 262144 byte code limit.");
7
+ }
8
+ const budget = new ExecutionBudget(timeoutMs, signal, userWait);
9
+ const execution = { active: true, pending: [] };
10
+ const pending = new Set();
11
+ const failures = [];
12
+ let calls = 0;
13
+ const track = (value) => {
14
+ pending.add(value);
15
+ void value.then(() => pending.delete(value), (error) => {
16
+ failures.push(error);
17
+ pending.delete(value);
18
+ });
19
+ return value;
20
+ };
21
+ const requireActive = (lifetime) => {
22
+ signal?.throwIfAborted();
23
+ if (execution.active === false || lifetime.active === false) {
24
+ throw new Error("JavaScript callback or draft is no longer active.");
25
+ }
26
+ if (++calls > 10_000)
27
+ throw new Error("JavaScript exceeded the 10000 host call limit.");
28
+ };
29
+ const wrap = (value, lifetime) => {
30
+ if (typeof value === "function") {
31
+ return (...args) => {
32
+ requireActive(lifetime);
33
+ const invocation = { active: true, pending: [] };
34
+ const argumentsWithCallbacks = args.map((arg) => {
35
+ if (typeof arg !== "function")
36
+ return arg;
37
+ return (...callbackArgs) => {
38
+ requireActive(invocation);
39
+ return (async () => {
40
+ const result = await budget.runGuest(() => arg(...callbackArgs.map((item) => wrap(item, invocation))));
41
+ await Promise.all(invocation.pending);
42
+ return result;
43
+ })();
44
+ };
45
+ });
46
+ try {
47
+ const result = value(...argumentsWithCallbacks);
48
+ if (result instanceof Promise) {
49
+ const task = track(result.finally(() => {
50
+ invocation.active = false;
51
+ }));
52
+ lifetime.pending.push(task);
53
+ return task;
54
+ }
55
+ invocation.active = false;
56
+ return result;
57
+ }
58
+ catch (error) {
59
+ invocation.active = false;
60
+ throw error;
61
+ }
62
+ };
63
+ }
64
+ if (Array.isArray(value))
65
+ return value.map((item) => wrap(item, lifetime));
66
+ if (typeof value === "object" && value !== null && !(value instanceof Uint8Array)) {
67
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, wrap(item, lifetime)]));
68
+ }
69
+ return value;
70
+ };
71
+ try {
72
+ const names = Object.keys(globals);
73
+ const body = new Function(...names, `"use strict"; return (async () => {\n${code}\n})();`);
74
+ const result = await Promise.race([
75
+ budget.runGuest(() => body(...Object.values(globals).map((value) => wrap(value, execution)))),
76
+ budget.interrupted,
77
+ ]);
78
+ while (pending.size > 0) {
79
+ await Promise.race([Promise.allSettled([...pending]), budget.interrupted]);
80
+ }
81
+ if (failures.length > 0)
82
+ throw failures[0];
83
+ if (budget.expired())
84
+ throw budget.timeoutError();
85
+ return result;
86
+ }
87
+ finally {
88
+ execution.active = false;
89
+ budget.dispose();
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,3 @@
1
+ import type { LanguageModelUsage } from "ai";
2
+ import type { SparkStepCost } from "./ui.js";
3
+ export declare function calculateStepCost(modelId: string, usage: LanguageModelUsage): SparkStepCost;
@@ -0,0 +1,70 @@
1
+ // Standard, global, direct API rates in USD per million tokens, checked 2026-09-09.
2
+ const PRICES = {
3
+ "gpt-6-astra": {
4
+ input: 10, read: 1, write: 12.5, output: 50, longContext: 272_000,
5
+ source: "https://developers.openai.com/api/docs/models/gpt-6-astra",
6
+ },
7
+ "claude-opus-5": {
8
+ input: 5, read: 0.5, write: 6.25, output: 25,
9
+ source: "https://platform.claude.com/docs/en/models/opus-5/overview",
10
+ },
11
+ "claude-fable-5": {
12
+ input: 10, read: 1, write: 12.5, output: 50,
13
+ source: "https://platform.claude.com/docs/en/about-claude/pricing",
14
+ },
15
+ };
16
+ export function calculateStepCost(modelId, usage) {
17
+ const price = PRICES[modelId];
18
+ const result = {
19
+ modelId, pricingDate: "2026-09-09", source: price?.source,
20
+ totalUsd: null, lines: [],
21
+ };
22
+ const unavailable = (reason) => ({ ...result, reason });
23
+ if (price === undefined)
24
+ return unavailable("No verified pricing for this model.");
25
+ const input = usage.inputTokens;
26
+ const output = usage.outputTokens;
27
+ const read = usage.inputTokenDetails.cacheReadTokens;
28
+ const write = usage.inputTokenDetails.cacheWriteTokens ?? 0;
29
+ if (input === undefined || output === undefined || read === undefined) {
30
+ return unavailable("The provider did not report complete token usage.");
31
+ }
32
+ const uncached = input - read - write;
33
+ if ([input, output, read, write, uncached].some((value) => Number.isSafeInteger(value) === false || value < 0)) {
34
+ return unavailable("The provider reported inconsistent token usage.");
35
+ }
36
+ if (Array.isArray(usage.raw?.iterations) && usage.raw.iterations.length > 0) {
37
+ return unavailable("Provider sub-inference billing needs separate attribution.");
38
+ }
39
+ let hourWrite = 0;
40
+ if (modelId.startsWith("claude-") && write > 0) {
41
+ const cache = usage.raw?.cache_creation;
42
+ if (cache === null || typeof cache !== "object" || Array.isArray(cache)) {
43
+ return unavailable("Cache write duration was not reported.");
44
+ }
45
+ const fiveMinute = cache.ephemeral_5m_input_tokens;
46
+ 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) {
50
+ return unavailable("Cache write duration was not reported completely.");
51
+ }
52
+ hourWrite = oneHour;
53
+ }
54
+ const longContext = price.longContext !== undefined && input > price.longContext;
55
+ const inputMultiplier = longContext ? 2 : 1;
56
+ const outputMultiplier = longContext ? 1.5 : 1;
57
+ const line = (label, tokens, usdPerMillion) => ({
58
+ label, tokens, usdPerMillion, usd: tokens * usdPerMillion / 1_000_000,
59
+ });
60
+ result.lines = [
61
+ line("Uncached input", uncached, price.input * inputMultiplier),
62
+ line("Cache reads", read, price.read * inputMultiplier),
63
+ line("Cache writes", write - hourWrite, price.write * inputMultiplier),
64
+ line("1-hour cache writes", hourWrite, price.input * 2),
65
+ // Output totals already include billed reasoning tokens; never add them again.
66
+ line("Output (including reasoning)", output, price.output * outputMultiplier),
67
+ ].filter(({ tokens }) => tokens > 0);
68
+ result.totalUsd = result.lines.reduce((total, entry) => total + entry.usd, 0);
69
+ return result;
70
+ }
package/dist/prompt.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SPARK_AGENT_PROMPT: string;
1
+ export declare const SPARK_AGENT_PROMPT = "You are Spark, Womp's unified assistant.\nUse read_skill to discover the APIs needed for the user's request. Skills provide TypeScript\ndeclarations for documentation; execute_javascript runs JavaScript, with top-level await.\nOnly the listed capabilities are available. Reading a skill does not grant additional permissions.\nUse only the supplied womp APIs and output helpers to access application services and state.\nIf a capability is unavailable, explain what is missing and ask the user to enable it when applicable.\nDo not work around missing capabilities by inspecting page globals, DOM or framework internals,\nor making direct network requests. Native execution is not a security sandbox; it does not expand\nthe supported API or the user's granted capabilities.\nEach execution has fresh local variables. Keep stable object, job, and artifact references.\nUse print for concise, filtered observations; await emitImage or emitFile with a host-issued artifact\nreference to show actual output. Inspect the scene before editing and verify the committed result.\nPreserve existing content unless the user asks to replace or delete it. Use the latest target revision\nwhen a write requires one. Capabilities own transactions: an entire script is not atomic.\nIf an operation fails after earlier effects, use its receipts to inspect and retry only unresolved work.\nNever claim an uncertain commit rolled back. Never resubmit a job just because waiting timed out.\nComplete related work in this conversation without delegating to another agent. Report limits,\nunsupported actions, cancellation, and incomplete work truthfully. Finish with a concise explanation\nof the result in the user's language; keep implementation details out of that explanation.";
package/dist/prompt.js CHANGED
@@ -1,209 +1,19 @@
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();
1
+ export const SPARK_AGENT_PROMPT = `You are Spark, Womp's unified assistant.
2
+ Use read_skill to discover the APIs needed for the user's request. Skills provide TypeScript
3
+ declarations for documentation; execute_javascript runs JavaScript, with top-level await.
4
+ Only the listed capabilities are available. Reading a skill does not grant additional permissions.
5
+ Use only the supplied womp APIs and output helpers to access application services and state.
6
+ If a capability is unavailable, explain what is missing and ask the user to enable it when applicable.
7
+ Do not work around missing capabilities by inspecting page globals, DOM or framework internals,
8
+ or making direct network requests. Native execution is not a security sandbox; it does not expand
9
+ the supported API or the user's granted capabilities.
10
+ Each execution has fresh local variables. Keep stable object, job, and artifact references.
11
+ Use print for concise, filtered observations; await emitImage or emitFile with a host-issued artifact
12
+ reference to show actual output. Inspect the scene before editing and verify the committed result.
13
+ Preserve existing content unless the user asks to replace or delete it. Use the latest target revision
14
+ when a write requires one. Capabilities own transactions: an entire script is not atomic.
15
+ If an operation fails after earlier effects, use its receipts to inspect and retry only unresolved work.
16
+ Never claim an uncertain commit rolled back. Never resubmit a job just because waiting timed out.
17
+ Complete related work in this conversation without delegating to another agent. Report limits,
18
+ unsupported actions, cancellation, and incomplete work truthfully. Finish with a concise explanation
19
+ of the result in the user's language; keep implementation details out of that explanation.`;
@@ -0,0 +1,13 @@
1
+ import type { JavaScriptExecutor, JavaScriptGlobals, JavaScriptUserWait } from "./executor.js";
2
+ export type QuickJSExecutorOptions = {
3
+ memoryLimitBytes: number;
4
+ maxStackSizeBytes: number;
5
+ maxHostCalls: number;
6
+ maxBridgeBytes: number;
7
+ maxCodeBytes: number;
8
+ };
9
+ export declare class QuickJSJavaScriptExecutor implements JavaScriptExecutor {
10
+ private readonly options;
11
+ constructor(options?: Partial<QuickJSExecutorOptions>);
12
+ execute(code: string, globals: JavaScriptGlobals, timeoutMs: number, signal?: AbortSignal, userWait?: JavaScriptUserWait): Promise<unknown>;
13
+ }