@womp/spark-agent 5.6.1 → 5.7.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 (43) hide show
  1. package/README.md +424 -421
  2. package/dist/agent-run.d.ts +1 -1
  3. package/dist/agent.d.ts +2 -0
  4. package/dist/agent.js +3 -1
  5. package/dist/capabilities/geometry.js +14 -14
  6. package/dist/capabilities/materials.js +14 -14
  7. package/dist/capabilities/openscad-instructions.js +77 -77
  8. package/dist/capabilities/operations.js +28 -28
  9. package/dist/capabilities/scene.js +81 -81
  10. package/dist/capabilities/wompify.js +10 -10
  11. package/dist/client.d.ts +7 -0
  12. package/dist/client.js +14 -0
  13. package/dist/geometry/schemas/backend-schema.json +3393 -3393
  14. package/dist/geometry/schemas/flowir-dialect.json +1023 -1023
  15. package/dist/geometry.js +6 -6
  16. package/dist/goals.d.ts +43 -0
  17. package/dist/goals.js +37 -0
  18. package/dist/materials/recipes.js +266 -266
  19. package/dist/materials/reference.js +94 -94
  20. package/dist/materials/structure.js +10 -10
  21. package/dist/materials/surface-recipes.js +6 -6
  22. package/dist/prompt.js +74 -74
  23. package/dist/server/executor.d.ts +1 -1
  24. package/dist/server/executor.js +2 -0
  25. package/dist/server/express.js +18 -0
  26. package/dist/server/fixtures/materials/matte-blue.json +14 -14
  27. package/dist/server/fixtures/materials/polished-copper.json +14 -14
  28. package/dist/server/goal-evaluator.d.ts +29 -0
  29. package/dist/server/goal-evaluator.js +55 -0
  30. package/dist/server/index.d.ts +4 -0
  31. package/dist/server/index.js +4 -0
  32. package/dist/server/service.d.ts +17 -0
  33. package/dist/server/service.js +204 -5
  34. package/dist/server/sqlite-store.d.ts +2 -0
  35. package/dist/server/sqlite-store.js +45 -38
  36. package/dist/server/store.d.ts +2 -0
  37. package/dist/server/store.js +12 -3
  38. package/dist/server/types.d.ts +6 -0
  39. package/dist/ui.d.ts +7 -3
  40. package/dist/ui.js +3 -1
  41. package/dist/wompify.d.ts +11 -0
  42. package/dist/wompify.js +11 -2
  43. package/package.json +140 -140
package/dist/geometry.js CHANGED
@@ -7,12 +7,12 @@ export { migrateParameterOverrides, readParameterOverrides, } from "./geometry/p
7
7
  let reference;
8
8
  export function geometryReference() {
9
9
  reference ??= {
10
- rules: `Write one statement per line:
11
- param Float width = 20.0 min=1 max=100 step=1
12
- node box Primitive Type=Cube Position=Vec3(0.0,0.0,0.0) Rotation=Vec3(0.0,0.0,0.0) Size=width Roundness=0.0
13
- out Geometry=box.Geometry
14
- Use decimal components in Vec3 parameter/constant literals, e.g. Vec3(20.0,20.0,20.0). Output name is case-sensitive: Geometry.
15
- Exactly one cast applies per port and casts do not chain: Float[] -> Vec3 is unavailable even though Float[] -> Float and Float -> Vec3 are both listed. Build the vector with CombineXYZ instead.
10
+ rules: `Write one statement per line:
11
+ param Float width = 20.0 min=1 max=100 step=1
12
+ node box Primitive Type=Cube Position=Vec3(0.0,0.0,0.0) Rotation=Vec3(0.0,0.0,0.0) Size=width Roundness=0.0
13
+ out Geometry=box.Geometry
14
+ Use decimal components in Vec3 parameter/constant literals, e.g. Vec3(20.0,20.0,20.0). Output name is case-sensitive: Geometry.
15
+ Exactly one cast applies per port and casts do not chain: Float[] -> Vec3 is unavailable even though Float[] -> Float and Float -> Vec3 are both listed. Build the vector with CombineXYZ instead.
16
16
  ${flowir.renderDslRulesBlock()}`,
17
17
  catalog: flowir.renderSchemaBlock(flowirRegistry.getSchema()),
18
18
  };
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ import type { SparkRunSettings } from "./server/types.js";
3
+ export declare const MAX_GOAL_LENGTH = 4000;
4
+ export type SparkGoal = {
5
+ id: string;
6
+ objective: string;
7
+ status: "active" | "paused" | "completed" | "blocked" | "budget_limited";
8
+ settings: SparkRunSettings;
9
+ createdAt: string;
10
+ updatedAt: string;
11
+ turns: number;
12
+ tokensUsed: number;
13
+ maxTurns?: number;
14
+ idleTurns?: number;
15
+ tokenBudget?: number;
16
+ creditBudget?: number;
17
+ budget?: {
18
+ limit: number;
19
+ spent: number;
20
+ };
21
+ lastReason?: string;
22
+ /** The latest run allowed to evaluate or continue this goal. */
23
+ runId?: string;
24
+ };
25
+ export declare const sparkGoalCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ action: z.ZodLiteral<"set">;
27
+ objective: z.ZodString;
28
+ tokenBudget: z.ZodOptional<z.ZodNumber>;
29
+ creditBudget: z.ZodOptional<z.ZodNumber>;
30
+ maxTurns: z.ZodOptional<z.ZodNumber>;
31
+ }, z.core.$strip>, z.ZodObject<{
32
+ action: z.ZodEnum<{
33
+ status: "status";
34
+ pause: "pause";
35
+ resume: "resume";
36
+ clear: "clear";
37
+ }>;
38
+ }, z.core.$strip>], "action">;
39
+ export type SparkGoalCommand = z.infer<typeof sparkGoalCommandSchema>;
40
+ export declare function goalTokenCount(usage: unknown): number;
41
+ export declare const DEFAULT_GOAL_CREDITS = 50000;
42
+ /** Only the explicit slash command starts a goal; prose inside an ordinary message does not. */
43
+ export declare function parseSparkGoalCommand(text: string): SparkGoalCommand | undefined;
package/dist/goals.js ADDED
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ export const MAX_GOAL_LENGTH = 4_000;
3
+ export const sparkGoalCommandSchema = z.discriminatedUnion("action", [
4
+ z.object({
5
+ action: z.literal("set"),
6
+ objective: z.string().trim().min(1).max(MAX_GOAL_LENGTH),
7
+ tokenBudget: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
8
+ creditBudget: z.number().int().positive().max(1_000_000_000).optional(),
9
+ maxTurns: z.number().int().min(1).max(100).optional(),
10
+ }),
11
+ z.object({ action: z.enum(["status", "pause", "resume", "clear"]) }),
12
+ ]);
13
+ export function goalTokenCount(usage) {
14
+ if (!usage || typeof usage !== "object")
15
+ return 0;
16
+ const value = usage;
17
+ const total = value.totalTokens ?? ((value.inputTokens ?? 0) + (value.outputTokens ?? 0));
18
+ return Number.isSafeInteger(total) && total >= 0 ? total : 0;
19
+ }
20
+ export const DEFAULT_GOAL_CREDITS = 50_000;
21
+ /** Only the explicit slash command starts a goal; prose inside an ordinary message does not. */
22
+ export function parseSparkGoalCommand(text) {
23
+ const match = /^\/goal(?:\s+([\s\S]*))?$/i.exec(text.trim());
24
+ if (!match)
25
+ return undefined;
26
+ let objective = (match[1] ?? "").trim();
27
+ if (["status", "pause", "resume", "clear"].includes(objective.toLowerCase()))
28
+ return { action: objective.toLowerCase() };
29
+ objective = objective.replace(/^["Ҭ]([\s\S]*)["Ӭ]$/, "$1").trim();
30
+ const cap = /(?:[,;]?[\s]+)?cap\s+at\s+(\S+)\s+credits[.!]?$/i.exec(objective);
31
+ if (cap && !/^(?:\d+|\d{1,3}(?:,\d{3})+|\d{1,3}(?:\.\d{3})+)$/.test(cap[1]))
32
+ throw new Error("Use a whole number of credits, for example cap at 1000 credits.");
33
+ const creditBudget = cap ? Number(cap[1].replace(/[.,]/g, "")) : DEFAULT_GOAL_CREDITS;
34
+ if (cap)
35
+ objective = objective.slice(0, cap.index).trim().replace(/^["Ҭ]([\s\S]*)["Ӭ]$/, "$1").trim();
36
+ return sparkGoalCommandSchema.parse({ action: "set", objective, creditBudget });
37
+ }