@womp/spark-agent 15.7.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +15 -8
- package/dist/agent.d.ts +2 -1
- package/dist/agent.js +1 -1
- package/dist/capabilities/asset-imports.js +13 -3
- package/dist/capabilities/project.d.ts +35 -0
- package/dist/capabilities/project.js +142 -0
- package/dist/capabilities/web.d.ts +20 -0
- package/dist/capabilities/web.js +25 -0
- package/dist/capabilities.d.ts +7 -2
- package/dist/generated/project-declarations.d.ts +1 -0
- package/dist/generated/project-declarations.js +3 -0
- package/dist/generated/web-declarations.d.ts +1 -0
- package/dist/generated/web-declarations.js +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/prompt.d.ts +4 -1
- package/dist/prompt.js +26 -3
- package/dist/public-capabilities.d.ts +21 -0
- package/dist/public-capabilities.js +6 -0
- package/dist/server/executor.d.ts +1 -1
- package/dist/spark-capabilities.d.ts +87 -0
- package/dist/spark-capabilities.js +67 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,48 @@ Notable changes to `@womp/spark-agent`, newest first. Versions follow
|
|
|
4
4
|
[Semantic Versioning](https://semver.org/). Add an entry with each version bump; describe what
|
|
5
5
|
changed for hosts and users, and how to migrate across breaking changes.
|
|
6
6
|
|
|
7
|
+
## 16.0.0 — 2026-11-02
|
|
8
|
+
|
|
9
|
+
Spark now owns every capability: its skills, prompt rules, which capabilities a run offers and how
|
|
10
|
+
they behave. Hosts supply services and run facts, so a bench given the same facts runs exactly what
|
|
11
|
+
production runs.
|
|
12
|
+
|
|
13
|
+
### Breaking
|
|
14
|
+
|
|
15
|
+
- `createSparkCapabilities({ hosts, facts })` is the only way to build a run's capabilities.
|
|
16
|
+
`facts` are crow's capability gates (`scene`, `health`, `geometry`, `openScad`, `flow`,
|
|
17
|
+
`flowRuns`, `operations`, `knowledge`, `account`, `web`) plus `projectBound`; `hosts` are the
|
|
18
|
+
service interfaces (`assets`, `imports`, `textureImports`, `operations`, `account`, `flow` with
|
|
19
|
+
`flowNodeCatalog`, `flowRuns`, `geometry`, `scene` with its `health`, `materials`, `openscad`,
|
|
20
|
+
`print`, `knowledge`, `web`, `project`). The composition order is unchanged. An enabled
|
|
21
|
+
capability without its host throws instead of being left out.
|
|
22
|
+
- `composeCapabilities`, `SparkCapability` and every `create*Capability` are no longer exported,
|
|
23
|
+
and `SparkCapabilities` cannot be built by hand. Scene scripts use
|
|
24
|
+
`createSceneScriptCapabilities(sceneHost)`.
|
|
25
|
+
- `runSparkAgent`'s `instructions` option is replaced by `unattended: true`, which adds the rules
|
|
26
|
+
for a run nobody attends after the agent prompt. `SPARK_AGENT_PROMPT` is no longer exported, and
|
|
27
|
+
`sparkSystemPrompt(skills, instructions, modelId)` is now `sparkSystemPrompt(skills, { modelId,
|
|
28
|
+
unattended })`.
|
|
29
|
+
|
|
30
|
+
### Moved from crow-backend
|
|
31
|
+
|
|
32
|
+
- The `web` skill (`womp.web.search`, `womp.web.fetchImage`) and its argument checks; crow keeps
|
|
33
|
+
the billed search and the image download behind `WebHost`.
|
|
34
|
+
- The `project-choice` skill (version 2, which also names print estimates among the tools that
|
|
35
|
+
ask for a project) and the project gate: with `hosts.project`, scene, screenshot, health, Geometry
|
|
36
|
+
Nodes, materials, OpenSCAD, print estimate and Flow calls, and imports into the scene, call
|
|
37
|
+
`ensureProject` first. Crow keeps choosing and binding the project behind `ProjectHost`.
|
|
38
|
+
- `finishImport` caps a wait over 30 s at 30 s and says to wait again, instead of rejecting it.
|
|
39
|
+
- The unattended (Flow node) rules, previously crow's `HEADLESS_INSTRUCTIONS`, word for word.
|
|
40
|
+
|
|
41
|
+
### Migration
|
|
42
|
+
|
|
43
|
+
Replace `composeCapabilities({ ... })` with `createSparkCapabilities({ hosts, facts })`, delete
|
|
44
|
+
host-written skills and wrappers listed above, and pass `unattended: true` instead of a headless
|
|
45
|
+
system prompt. Crow's `action-recovery` skill is dropped: crow never resumed an interrupted run, so
|
|
46
|
+
it always answered `operation: null`. The first turn after deploy misses the provider prompt cache
|
|
47
|
+
once, because the skills directory changes.
|
|
48
|
+
|
|
7
49
|
## 15.7.0 — 2026-11-02
|
|
8
50
|
|
|
9
51
|
Spark looks up the export steps with the help lookup when a user wants a file format, instead of
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ npm install @womp/spark-agent
|
|
|
22
22
|
|
|
23
23
|
- `@womp/spark-agent` — browser-safe model loop, two tools, persistence hooks, and shared contracts
|
|
24
24
|
- `@womp/spark-agent/browser` — native JavaScript executor and local chat transport
|
|
25
|
-
- `@womp/spark-agent/capabilities` —
|
|
25
|
+
- `@womp/spark-agent/capabilities` — `createSparkCapabilities` and the host service interfaces
|
|
26
26
|
- `@womp/spark-agent/kakapo` — direct Kakapo runtime and scene capability
|
|
27
27
|
- `@womp/spark-agent/quickjs` — optional isolated JavaScript executor
|
|
28
28
|
- `@womp/spark-agent/ui` — browser-safe UI message types, schemas, and model catalog
|
|
@@ -36,22 +36,29 @@ Kakapo, Express, or React at runtime.
|
|
|
36
36
|
## Running in a host application
|
|
37
37
|
|
|
38
38
|
`runSparkAgent` accepts a configured model, the stored conversation (`history`, compacted once it
|
|
39
|
-
is long) or model messages, an executor,
|
|
39
|
+
is long) or model messages, an executor, the run's capabilities, and an artifact resolver. It exposes exactly `read_skill` and `execute_javascript` to the model.
|
|
40
40
|
Skills carry instructions, declarations, and JavaScript examples. Kakapo skill declarations are
|
|
41
41
|
generated from its typed API at build time and packaged as JavaScript strings.
|
|
42
42
|
|
|
43
43
|
### System prompt and editor selection
|
|
44
44
|
|
|
45
|
-
Every
|
|
46
|
-
with nothing host-specific, so it stays identical across a conversation.
|
|
45
|
+
Every run sends `sparkSystemPrompt(skills)`: the shared agent prompt and the skills directory,
|
|
46
|
+
with nothing host-specific, so it stays identical across a conversation. A run nobody attends, such
|
|
47
|
+
as a Flow node's, passes `unattended: true` and gets the unattended rules after the agent prompt.
|
|
48
|
+
Hosts attach the editor
|
|
47
49
|
selection to the user message it was sent with as a `data-selection` part (`{ nodeIds }`). It is
|
|
48
50
|
not rendered as chat text; the model reads it as a short note on that message.
|
|
49
51
|
|
|
50
52
|
### Capabilities
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
Spark defines every skill. A host builds a run's capabilities with
|
|
55
|
+
`createSparkCapabilities({ hosts, facts })`: `hosts` implements the service interfaces (`SceneHost`,
|
|
56
|
+
`AccountHost`, `FlowHost`, ...), and `facts` says what the run's user and conversation allow
|
|
57
|
+
(`scene`, `operations`, `flow`, `projectBound`, ...). Spark decides from the facts which skills the
|
|
58
|
+
run offers and in which order, and binds each API under `womp`; an enabled capability without its
|
|
59
|
+
host throws. With `hosts.project`, a conversation with no project offers `project-choice` and every
|
|
60
|
+
project tool asks for a project first. Hosts cannot add skills or build a capability set by hand.
|
|
61
|
+
Every invocation receives a cancellation signal and an awaited `recordReceipt` hook. Host services
|
|
55
62
|
own their transactions and must check cancellation at their commit boundary.
|
|
56
63
|
|
|
57
64
|
For a real user interaction, call `context.waitForUser(label, async signal => ...)` outside mutation
|
|
@@ -63,7 +70,7 @@ Shared SDK scene adapters apply each edit directly to the scene and save it; not
|
|
|
63
70
|
or replayed. An edit that fails after it began throws `SceneOperationError`, whose `operation`
|
|
64
71
|
reports whether the edit was committed, rolled back or left uncertain.
|
|
65
72
|
|
|
66
|
-
`
|
|
73
|
+
`hosts.print: createSdkPrintHost({ editor, price })` backs `womp.printing.estimate`:
|
|
67
74
|
the engine measures the parts (`set_3dp_context`) and the host's `price` prices the measurement for
|
|
68
75
|
the run's user, as swan's print estimate does. A host that serializes the engine's print context with
|
|
69
76
|
other wall-thickness checks passes its own `requestPrintContext`.
|
package/dist/agent.d.ts
CHANGED
|
@@ -29,7 +29,8 @@ export type SparkAgentOptions = {
|
|
|
29
29
|
runId: string;
|
|
30
30
|
messageId: string;
|
|
31
31
|
signal?: AbortSignal;
|
|
32
|
-
|
|
32
|
+
/** No person attends the run (a Flow node's): the agent never asks, offers or waits. */
|
|
33
|
+
unattended?: boolean;
|
|
33
34
|
maxSteps?: number;
|
|
34
35
|
maxOutputTokens?: number;
|
|
35
36
|
executionTimeoutMs?: number;
|
package/dist/agent.js
CHANGED
|
@@ -141,7 +141,7 @@ export function runSparkAgent(options) {
|
|
|
141
141
|
controller,
|
|
142
142
|
write: (chunk) => writer.write(chunk),
|
|
143
143
|
});
|
|
144
|
-
const readSystem = () => sparkSystemPrompt(options.capabilities.skills, options.
|
|
144
|
+
const readSystem = () => sparkSystemPrompt(options.capabilities.skills, { modelId: options.modelId, unattended: options.unattended });
|
|
145
145
|
let messages = options.messages ?? [];
|
|
146
146
|
// Compaction before each later step; only for a stored conversation,
|
|
147
147
|
// where the compaction can be recorded.
|
|
@@ -14,8 +14,11 @@ const requestSchema = z
|
|
|
14
14
|
destination: z.enum(["scene", "library"]),
|
|
15
15
|
})
|
|
16
16
|
.strict();
|
|
17
|
+
/** The longest one finishImport waits; a longer request waits this long and says so. */
|
|
18
|
+
const MAX_IMPORT_WAIT_MS = 30_000;
|
|
19
|
+
const CAPPED_IMPORT_WAIT = `This call waited ${MAX_IMPORT_WAIT_MS} ms, the longest a single wait allows. Call finishImport again with the same key to keep waiting.`;
|
|
17
20
|
const waitSchema = z
|
|
18
|
-
.object({ timeoutMs: z.number().int().min(1).
|
|
21
|
+
.object({ timeoutMs: z.number().int().min(1).default(15_000) })
|
|
19
22
|
.strict();
|
|
20
23
|
const imageRequestSchema = requestSchema.extend({
|
|
21
24
|
kind: z.enum(["image-plane", "sticker"]),
|
|
@@ -112,9 +115,16 @@ or meshes. Image imports can fail or have an unknown outcome; do not blindly upl
|
|
|
112
115
|
context.signal.throwIfAborted();
|
|
113
116
|
return host.readImport(keySchema.parse(key), context);
|
|
114
117
|
},
|
|
115
|
-
finishImport: (key, options) => {
|
|
118
|
+
finishImport: async (key, options) => {
|
|
116
119
|
context.signal.throwIfAborted();
|
|
117
|
-
|
|
120
|
+
const importKey = keySchema.parse(key);
|
|
121
|
+
const { timeoutMs } = waitSchema.parse(options ?? {});
|
|
122
|
+
// A slow import is when the model asks for a longer wait; capping it
|
|
123
|
+
// rather than rejecting the call saves the step a rejection costs.
|
|
124
|
+
if (timeoutMs <= MAX_IMPORT_WAIT_MS)
|
|
125
|
+
return host.finishImport(importKey, { timeoutMs }, context);
|
|
126
|
+
const result = await host.finishImport(importKey, { timeoutMs: MAX_IMPORT_WAIT_MS }, context);
|
|
127
|
+
return { ...result, reason: [result.reason, CAPPED_IMPORT_WAIT].filter(Boolean).join(" ") };
|
|
118
128
|
},
|
|
119
129
|
}),
|
|
120
130
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SparkCapability, SparkInvocationContext } from "../capabilities.js";
|
|
2
|
+
import type { AssetImportsHost } from "./asset-imports.js";
|
|
3
|
+
import type { FlowHost } from "./flow.js";
|
|
4
|
+
import type { GeometryHost } from "./geometry.js";
|
|
5
|
+
import type { MaterialsHost } from "./materials.js";
|
|
6
|
+
import type { OpenScadHost } from "./openscad.js";
|
|
7
|
+
import type { PrintHost } from "./print.js";
|
|
8
|
+
import type { SceneHost } from "./scene.js";
|
|
9
|
+
/** The step a project tool names when it asks for the conversation's project. */
|
|
10
|
+
export type ProjectTool = "scene" | "screenshot" | "geometry" | "openscad" | "flow" | "asset-import";
|
|
11
|
+
/**
|
|
12
|
+
* A conversation that may have no project yet. The first project tool call of
|
|
13
|
+
* such a conversation asks the user to choose one.
|
|
14
|
+
*/
|
|
15
|
+
export interface ProjectHost {
|
|
16
|
+
/** Resolves once the conversation has a project; rejects with the sentence the call answers otherwise. */
|
|
17
|
+
ensureProject(context: SparkInvocationContext, tool: ProjectTool): Promise<void>;
|
|
18
|
+
/** The new project's name the user will be offered. */
|
|
19
|
+
suggestTitle(title: string): void;
|
|
20
|
+
}
|
|
21
|
+
export type WompProjectApi = {
|
|
22
|
+
/** Records the name offered for a new project. */
|
|
23
|
+
suggestTitle(title: string): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
/** Offered only while the conversation has no project. */
|
|
26
|
+
export declare function createProjectChoiceCapability(host: ProjectHost): SparkCapability<WompProjectApi>;
|
|
27
|
+
export declare function gateSceneHost(host: SceneHost, project: ProjectHost): SceneHost;
|
|
28
|
+
export declare function gateGeometryHost(host: GeometryHost, project: ProjectHost): GeometryHost;
|
|
29
|
+
export declare function gateMaterialsHost(host: MaterialsHost, project: ProjectHost): MaterialsHost;
|
|
30
|
+
export declare function gatePrintHost(host: PrintHost, project: ProjectHost): PrintHost;
|
|
31
|
+
export declare function gateOpenScadHost(host: OpenScadHost, project: ProjectHost): OpenScadHost;
|
|
32
|
+
/** A Flow call asks for the project before the host could refuse it for having no Flow graph. */
|
|
33
|
+
export declare function gateFlowHost(host: FlowHost, project: ProjectHost): FlowHost;
|
|
34
|
+
/** An import into the scene asks for the project; a library import needs none. */
|
|
35
|
+
export declare function gateAssetImportsHost(host: AssetImportsHost, project: ProjectHost): AssetImportsHost;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { WOMP_PROJECT_DECLARATIONS } from "../generated/project-declarations.js";
|
|
3
|
+
const title = z.string().trim().min(1, "A project name is required.").max(100);
|
|
4
|
+
/** Offered only while the conversation has no project. */
|
|
5
|
+
export function createProjectChoiceCapability(host) {
|
|
6
|
+
return {
|
|
7
|
+
skills: [
|
|
8
|
+
{
|
|
9
|
+
name: "project-choice",
|
|
10
|
+
version: "2",
|
|
11
|
+
description: "This conversation has no project yet; suggest the name of the new project the user may create.",
|
|
12
|
+
instructions: `The scene, screenshot, Geometry Nodes, parametric part, print estimate and Flow tools, and imports into the scene, ask the user to choose a project the first time one of them is called.
|
|
13
|
+
Call womp.project.suggestTitle once, before that first call, with a short name (at most 100 characters) for a new project that fits the request; the user sees it as the suggested name and can change it.
|
|
14
|
+
If the user chooses no project, that call fails with a sentence saying so; tell the user and carry on without the scene.`,
|
|
15
|
+
declarations: WOMP_PROJECT_DECLARATIONS,
|
|
16
|
+
examples: ['await womp.project.suggestTitle("Desk lamp");'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
createApi: () => ({
|
|
20
|
+
suggestTitle: async (value) => host.suggestTitle(title.parse(value)),
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// Each gated method asks for the project first, naming its step. Written out per
|
|
25
|
+
// method rather than proxied: a proxy would silently pass through a method the
|
|
26
|
+
// host interface grows later.
|
|
27
|
+
export function gateSceneHost(host, project) {
|
|
28
|
+
const health = host.health;
|
|
29
|
+
return {
|
|
30
|
+
...(health === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: {
|
|
33
|
+
async health(objectIds, context) {
|
|
34
|
+
await project.ensureProject(context, "scene");
|
|
35
|
+
return health(objectIds, context);
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
async access(callback, context) {
|
|
39
|
+
await project.ensureProject(context, "scene");
|
|
40
|
+
return host.access(callback, context);
|
|
41
|
+
},
|
|
42
|
+
async screenshot(options, context) {
|
|
43
|
+
await project.ensureProject(context, "screenshot");
|
|
44
|
+
return host.screenshot(options, context);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function gateGeometryHost(host, project) {
|
|
49
|
+
return {
|
|
50
|
+
async read(objectId, context) {
|
|
51
|
+
await project.ensureProject(context, "geometry");
|
|
52
|
+
return host.read(objectId, context);
|
|
53
|
+
},
|
|
54
|
+
async write(options, context) {
|
|
55
|
+
await project.ensureProject(context, "geometry");
|
|
56
|
+
return host.write(options, context);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function gateMaterialsHost(host, project) {
|
|
61
|
+
return {
|
|
62
|
+
async catalog(options, context) {
|
|
63
|
+
await project.ensureProject(context, "scene");
|
|
64
|
+
return host.catalog(options, context);
|
|
65
|
+
},
|
|
66
|
+
async read(materialId, context) {
|
|
67
|
+
await project.ensureProject(context, "scene");
|
|
68
|
+
return host.read(materialId, context);
|
|
69
|
+
},
|
|
70
|
+
async write(options, context) {
|
|
71
|
+
await project.ensureProject(context, "scene");
|
|
72
|
+
return host.write(options, context);
|
|
73
|
+
},
|
|
74
|
+
async readProgram(materialId, layerIndex, context) {
|
|
75
|
+
await project.ensureProject(context, "scene");
|
|
76
|
+
return host.readProgram(materialId, layerIndex, context);
|
|
77
|
+
},
|
|
78
|
+
async writeProgram(options, context) {
|
|
79
|
+
await project.ensureProject(context, "scene");
|
|
80
|
+
return host.writeProgram(options, context);
|
|
81
|
+
},
|
|
82
|
+
async status(context) {
|
|
83
|
+
await project.ensureProject(context, "scene");
|
|
84
|
+
return host.status(context);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function gatePrintHost(host, project) {
|
|
89
|
+
return {
|
|
90
|
+
async estimate(request, context) {
|
|
91
|
+
await project.ensureProject(context, "scene");
|
|
92
|
+
return host.estimate(request, context);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function gateOpenScadHost(host, project) {
|
|
97
|
+
return {
|
|
98
|
+
async read(objectId, context) {
|
|
99
|
+
await project.ensureProject(context, "openscad");
|
|
100
|
+
return host.read(objectId, context);
|
|
101
|
+
},
|
|
102
|
+
async create(options, context) {
|
|
103
|
+
await project.ensureProject(context, "openscad");
|
|
104
|
+
return host.create(options, context);
|
|
105
|
+
},
|
|
106
|
+
async update(options, context) {
|
|
107
|
+
await project.ensureProject(context, "openscad");
|
|
108
|
+
return host.update(options, context);
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** A Flow call asks for the project before the host could refuse it for having no Flow graph. */
|
|
113
|
+
export function gateFlowHost(host, project) {
|
|
114
|
+
return {
|
|
115
|
+
async read(context) {
|
|
116
|
+
await project.ensureProject(context, "flow");
|
|
117
|
+
return host.read(context);
|
|
118
|
+
},
|
|
119
|
+
async write(options, context) {
|
|
120
|
+
await project.ensureProject(context, "flow");
|
|
121
|
+
return host.write(options, context);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** An import into the scene asks for the project; a library import needs none. */
|
|
126
|
+
export function gateAssetImportsHost(host, project) {
|
|
127
|
+
return {
|
|
128
|
+
async importMesh(request, context) {
|
|
129
|
+
if (request.destination === "scene")
|
|
130
|
+
await project.ensureProject(context, "asset-import");
|
|
131
|
+
return host.importMesh(request, context);
|
|
132
|
+
},
|
|
133
|
+
async importImage(request, context) {
|
|
134
|
+
if (request.destination === "scene")
|
|
135
|
+
await project.ensureProject(context, "asset-import");
|
|
136
|
+
return host.importImage(request, context);
|
|
137
|
+
},
|
|
138
|
+
retryMeshImport: (request, context) => host.retryMeshImport(request, context),
|
|
139
|
+
readImport: (key, context) => host.readImport(key, context),
|
|
140
|
+
finishImport: (key, options, context) => host.finishImport(key, options, context),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ArtifactRef, SparkCapability, SparkInvocationContext } from "../capabilities.js";
|
|
2
|
+
export type WebSearchResult = {
|
|
3
|
+
answer: string;
|
|
4
|
+
sources: {
|
|
5
|
+
title: string;
|
|
6
|
+
url: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
export type WompWebApi = {
|
|
10
|
+
/** Searches the web and answers from what it found, with the pages it used. */
|
|
11
|
+
search(query: string): Promise<WebSearchResult>;
|
|
12
|
+
/** Downloads an image from a public http(s) URL into this conversation; emitImage(ref) shows it to you. */
|
|
13
|
+
fetchImage(url: string): Promise<ArtifactRef>;
|
|
14
|
+
};
|
|
15
|
+
/** The host bills searches and stores fetched images as conversation artifacts. */
|
|
16
|
+
export interface WebHost {
|
|
17
|
+
search(query: string, context: SparkInvocationContext): Promise<WebSearchResult>;
|
|
18
|
+
fetchImage(url: string, context: SparkInvocationContext): Promise<ArtifactRef>;
|
|
19
|
+
}
|
|
20
|
+
export declare function createWebCapability(host: WebHost): SparkCapability<WompWebApi>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { WOMP_WEB_DECLARATIONS } from "../generated/web-declarations.js";
|
|
3
|
+
export function createWebCapability(host) {
|
|
4
|
+
return {
|
|
5
|
+
skills: [
|
|
6
|
+
{
|
|
7
|
+
name: "web",
|
|
8
|
+
version: "1",
|
|
9
|
+
description: "Search the web, and fetch images from it to look at or use as references.",
|
|
10
|
+
instructions: `Use womp.web.search when the request depends on facts you do not know or that change: what a real place, building, product, person or object looks like, current information, specifications. It answers in prose with its sources.
|
|
11
|
+
Use womp.web.fetchImage with a direct image URL (from search sources or the user) to bring an image into this conversation; it returns an artifact reference: await emitImage(ref) to look at it, and pass it to a generation as a reference image.
|
|
12
|
+
Only public http(s) URLs work. Prefer one well-aimed search over many; every search is a billed model call.`,
|
|
13
|
+
declarations: WOMP_WEB_DECLARATIONS,
|
|
14
|
+
examples: [
|
|
15
|
+
'const found = await womp.web.search("What does 1 Main St, Springfield, IL look like? Describe the building.");\nprint(found.answer, found.sources);',
|
|
16
|
+
'const photo = await womp.web.fetchImage("https://example.com/photo.jpg");\nawait emitImage(photo);',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
createApi: (context) => ({
|
|
21
|
+
search: (query) => host.search(z.string().trim().min(1, "A search query is required.").parse(query), context),
|
|
22
|
+
fetchImage: (url) => host.fetchImage(z.string().trim().min(1, "An image URL is required.").parse(url), context),
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
}
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -59,10 +59,15 @@ export type SparkCapability<TApi extends object = object> = {
|
|
|
59
59
|
skills: readonly SparkSkill[];
|
|
60
60
|
createApi(context: SparkInvocationContext): TApi;
|
|
61
61
|
};
|
|
62
|
+
declare const composed: unique symbol;
|
|
63
|
+
/**
|
|
64
|
+
* A run's skills and `womp.*` globals. Only Spark composes one
|
|
65
|
+
* (`createSparkCapabilities`), so every skill a run can read is defined here.
|
|
66
|
+
*/
|
|
62
67
|
export type SparkCapabilities = {
|
|
63
|
-
|
|
64
|
-
skills: readonly SparkSkill[];
|
|
68
|
+
readonly skills: readonly SparkSkill[];
|
|
65
69
|
createApi(context: SparkInvocationContext): JavaScriptGlobals;
|
|
70
|
+
readonly [composed]: true;
|
|
66
71
|
};
|
|
67
72
|
/** The enabled bindings are also the only source of discoverable skills. */
|
|
68
73
|
export declare function composeCapabilities(capabilities: Record<string, SparkCapability>): SparkCapabilities;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WOMP_PROJECT_DECLARATIONS = "declare const womp: { project: { suggestTitle: ((title: string) => Promise<void>); } };\ndeclare function print(...values: unknown[]): void;\ndeclare function emitImage(ref: { id: string; mediaType: string; name?: string }, options?: { inspect?: boolean }): Promise<void>;\ndeclare function emitFile(ref: { id: string; mediaType: string; name?: string }): Promise<void>;\n";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Generated by scripts/generate-skill-declarations.mjs.
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
export const WOMP_PROJECT_DECLARATIONS = "declare const womp: { project: { suggestTitle: ((title: string) => Promise<void>); } };\ndeclare function print(...values: unknown[]): void;\ndeclare function emitImage(ref: { id: string; mediaType: string; name?: string }, options?: { inspect?: boolean }): Promise<void>;\ndeclare function emitFile(ref: { id: string; mediaType: string; name?: string }): Promise<void>;\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WOMP_WEB_DECLARATIONS = "declare const womp: { web: {\nsearch: ((query: string) => Promise<{ answer: string; sources: { title: string; url: string; }[]; }>);\nfetchImage: ((url: string) => Promise<{ id: string; mediaType: string; name?: string; }>);\n} };\ndeclare function print(...values: unknown[]): void;\ndeclare function emitImage(ref: { id: string; mediaType: string; name?: string }, options?: { inspect?: boolean }): Promise<void>;\ndeclare function emitFile(ref: { id: string; mediaType: string; name?: string }): Promise<void>;\n";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Generated by scripts/generate-skill-declarations.mjs.
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
export const WOMP_WEB_DECLARATIONS = "declare const womp: { web: {\nsearch: ((query: string) => Promise<{ answer: string; sources: { title: string; url: string; }[]; }>);\nfetchImage: ((url: string) => Promise<{ id: string; mediaType: string; name?: string; }>);\n} };\ndeclare function print(...values: unknown[]): void;\ndeclare function emitImage(ref: { id: string; mediaType: string; name?: string }, options?: { inspect?: boolean }): Promise<void>;\ndeclare function emitFile(ref: { id: string; mediaType: string; name?: string }): Promise<void>;\n";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ export { createSparkTools, type SparkPersistence, type SparkToolCall } from "./a
|
|
|
3
3
|
export { convertSparkMessages } from "./model-history.js";
|
|
4
4
|
export { applyCompaction, latestCompaction, type SparkCompactionLimits } from "./compaction.js";
|
|
5
5
|
export * from "./context-window.js";
|
|
6
|
-
export * from "./capabilities.js";
|
|
6
|
+
export * from "./public-capabilities.js";
|
|
7
7
|
export { createSdkSceneEditor, createSdkSceneHost, type SdkSceneEditor, type SdkSceneEditorOptions, type SdkSceneEditIdentity, type SdkSceneServices, } from "./sdk-scene-host.js";
|
|
8
8
|
export type { SceneOperation } from "./scene-operations.js";
|
|
9
9
|
export type { JavaScriptExecutor, JavaScriptGlobals, JavaScriptUserWait } from "./executor.js";
|
|
10
10
|
export { DEFAULT_MODEL_ID, getSparkModel, REASONING_EFFORT_LABELS, resolveReasoningEffort, SPARK_MODELS, } from "./models.js";
|
|
11
11
|
export type { ModelProvider, ReasoningEffort, SparkModel } from "./models.js";
|
|
12
|
-
export {
|
|
12
|
+
export { sparkSystemPrompt } from "./prompt.js";
|
|
13
13
|
export type { ExecutionResult, ExecutionScreenshot, SparkRuntimeEvent, SparkRuntimeEventSink, SparkContextMessage, SparkImage, SparkRunInput, SparkRuntime, } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { createSparkTools } from "./agent-tools.js";
|
|
|
3
3
|
export { convertSparkMessages } from "./model-history.js";
|
|
4
4
|
export { applyCompaction, latestCompaction } from "./compaction.js";
|
|
5
5
|
export * from "./context-window.js";
|
|
6
|
-
export * from "./capabilities.js";
|
|
6
|
+
export * from "./public-capabilities.js";
|
|
7
7
|
export { createSdkSceneEditor, createSdkSceneHost, } from "./sdk-scene-host.js";
|
|
8
8
|
export { DEFAULT_MODEL_ID, getSparkModel, REASONING_EFFORT_LABELS, resolveReasoningEffort, SPARK_MODELS, } from "./models.js";
|
|
9
|
-
export {
|
|
9
|
+
export { sparkSystemPrompt } from "./prompt.js";
|
package/dist/prompt.d.ts
CHANGED
|
@@ -6,4 +6,7 @@ export declare const SPARK_AGENT_PROMPT = "You are Spark, Womp's unified assista
|
|
|
6
6
|
* conversation that run on one model, or the provider's prompt cache misses; caches
|
|
7
7
|
* are per model, so naming the model costs no hits. Per-turn state travels in messages.
|
|
8
8
|
*/
|
|
9
|
-
export declare function sparkSystemPrompt(skills: readonly Pick<SparkSkill, "name" | "version" | "description">[],
|
|
9
|
+
export declare function sparkSystemPrompt(skills: readonly Pick<SparkSkill, "name" | "version" | "description">[], options?: {
|
|
10
|
+
modelId?: string;
|
|
11
|
+
unattended?: boolean;
|
|
12
|
+
}): string;
|
package/dist/prompt.js
CHANGED
|
@@ -128,6 +128,28 @@ scenes and text in every skill.
|
|
|
128
128
|
- When the subject is or looks like a child, refuse any sexual or sexualizing request.
|
|
129
129
|
- Refuse in one short sentence, such as "I can't help with sexual content." Do not explain, discuss
|
|
130
130
|
consent, lore or biology, or offer an alternative to the sexual request.`;
|
|
131
|
+
/**
|
|
132
|
+
* Added after the agent prompt for a run nobody attends, such as a Flow node's.
|
|
133
|
+
* A question there reports requires_action and the node cancels the run, so this
|
|
134
|
+
* overrides by name each part of the agent prompt that asks, offers, previews or waits.
|
|
135
|
+
*/
|
|
136
|
+
const UNATTENDED_PROMPT = `Unattended run
|
|
137
|
+
|
|
138
|
+
This request comes from a Flow node, not a person. Nobody can read a question or answer it, so
|
|
139
|
+
the rules below override everything above that asks, offers, previews or waits:
|
|
140
|
+
|
|
141
|
+
- Never ask the user anything, never offer choices or menus, and never wait for a reply.
|
|
142
|
+
- Where a question would have helped, choose the most sensible default yourself, carry on, and
|
|
143
|
+
state the assumption in one short line of your final answer.
|
|
144
|
+
- Do not stop at a preview. Carry the request all the way through to the result it asks for:
|
|
145
|
+
if the goal asks for a 3D model, make the model, not just an image of it.
|
|
146
|
+
- An attached image is the reference for the goal. Use it as the goal describes; do not ask
|
|
147
|
+
what to make of it.
|
|
148
|
+
- If something the goal needs is not available, do what you can and report the limitation in
|
|
149
|
+
the final answer instead of asking anyone to enable it.
|
|
150
|
+
- Your final message is what the Flow passes on to its next node. Make it the result itself:
|
|
151
|
+
the answer, or a concise description of what you made and where it is, not a question,
|
|
152
|
+
a plan, or a list of options.`;
|
|
131
153
|
/**
|
|
132
154
|
* Which chat model runs, among Spark's. Users name these models ("make it using astra");
|
|
133
155
|
* without them the agent took such a name for a generation model it did not have.
|
|
@@ -148,10 +170,11 @@ them is about the chat model, not a creation method: carry out the rest of the r
|
|
|
148
170
|
* conversation that run on one model, or the provider's prompt cache misses; caches
|
|
149
171
|
* are per model, so naming the model costs no hits. Per-turn state travels in messages.
|
|
150
172
|
*/
|
|
151
|
-
export function sparkSystemPrompt(skills,
|
|
173
|
+
export function sparkSystemPrompt(skills, options = {}) {
|
|
152
174
|
return [
|
|
153
|
-
|
|
154
|
-
|
|
175
|
+
SPARK_AGENT_PROMPT,
|
|
176
|
+
...(options.unattended ? [UNATTENDED_PROMPT] : []),
|
|
177
|
+
chatModelPrompt(options.modelId),
|
|
155
178
|
"Available skills (read before using their APIs):",
|
|
156
179
|
...skills.map(({ name, version, description }) => `- ${name} (${version}): ${description}`),
|
|
157
180
|
].join("\n\n");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { createSparkCapabilities, createSceneScriptCapabilities, type SparkHosts, type SparkRunFacts, } from "./spark-capabilities.js";
|
|
2
|
+
export type { ArtifactRef, ExecutionReceipt, SparkArtifactResolver, SparkCapabilities, SparkInvocationContext, SparkSkill, } from "./capabilities.js";
|
|
3
|
+
export type { WompSceneApi, SceneHost, SceneHealthHost, SceneSnapshot, SceneScreenshotOptions, } from "./capabilities/scene.js";
|
|
4
|
+
export type { WompSceneDraft } from "./capabilities/scene-draft.js";
|
|
5
|
+
export type { AssetImportsHost, MeshImportRequest, ImageImportRequest, AssetImportResult, MeshImportRetryRequest, AssetImportWaitOptions, WompAssetImportsApi, } from "./capabilities/asset-imports.js";
|
|
6
|
+
export type { AssetsHost, AssetListOptions, ConversationAsset, AssetPage, WompAssetsApi, } from "./capabilities/assets.js";
|
|
7
|
+
export type { OperationsHost, OperationType, OperationModel, OperationCatalog, OperationRequest, OperationJob, OperationStartResult, OperationGenerationResult, OperationWaitOptions, OperationWaitResult, OperationListOptions, OperationPage, WompOperationsApi, } from "./capabilities/operations.js";
|
|
8
|
+
export type { AccountHost, AccountRead, AccountSection, AccountScope, AccountResult, AccountSnapshot, AccountPage, AccountProfile, AccountTeam, AccountCreditBalance, AccountSubscription, AccountBilling, AccountOrderItem, AccountOrder, AccountProject, AccountNotification, AccountWorkflow, WompAccountApi, } from "./capabilities/account.js";
|
|
9
|
+
export type { KnowledgeAnswer, KnowledgeHost, WompKnowledgeApi } from "./capabilities/knowledge.js";
|
|
10
|
+
export type { PrintEstimate, PrintEstimateRequest, PrintEstimateUnavailableReason, PrintHost, PrintPrice, WompPrintApi, } from "./capabilities/print.js";
|
|
11
|
+
export type { FlowHost, FlowSnapshot, FlowWrite, FlowWriteResult, WompFlowApi } from "./capabilities/flow.js";
|
|
12
|
+
export { FLOW_RUN_WAIT_DEFAULT_SECONDS, FLOW_RUN_WAIT_MAX_SECONDS } from "./capabilities/flow-runs.js";
|
|
13
|
+
export type { FlowRunCancelled, FlowRunCopyDeleted, FlowRunDescription, FlowRunInput, FlowRunLive, FlowRunOutputNode, FlowRunFailedNode, FlowRunStarted, FlowRunStatus, FlowRunsHost, WompFlowRunsApi, } from "./capabilities/flow-runs.js";
|
|
14
|
+
export type { GeometryHost, GeometryTarget, GeometryInstance, GeometryParamValue, GeometryWrite, GeometryWriteResult, WompGeometryApi, } from "./capabilities/geometry.js";
|
|
15
|
+
export type { WompOpenScadApi, OpenScadHost, OpenScadTarget, OpenScadSource, OpenScadCreate, OpenScadUpdate, OpenScadValidation, OpenScadPrintability, OpenScadWriteResult, } from "./capabilities/openscad.js";
|
|
16
|
+
export type * from "./materials/types.js";
|
|
17
|
+
export type { MaterialInspectionOptions, MaterialInspectionResult, MaterialInspectionHost, MaterialStatus, MaterialsHost, WompMaterialsApi, } from "./capabilities/materials.js";
|
|
18
|
+
export type { TextureImportRequest, TextureImportResult, TextureImportsHost, WompTextureImportsApi, } from "./capabilities/texture-imports.js";
|
|
19
|
+
export { createTextureImportsHost, type TextureImportHostOptions } from "./texture-import-host.js";
|
|
20
|
+
export type { WebHost, WebSearchResult, WompWebApi } from "./capabilities/web.js";
|
|
21
|
+
export type { ProjectHost, ProjectTool, WompProjectApi } from "./capabilities/project.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The capability surface hosts see. Spark defines every skill and decides which
|
|
2
|
+
// a run offers (`createSparkCapabilities`); hosts implement the service
|
|
3
|
+
// interfaces below and never compose skills of their own.
|
|
4
|
+
export { createSparkCapabilities, createSceneScriptCapabilities, } from "./spark-capabilities.js";
|
|
5
|
+
export { FLOW_RUN_WAIT_DEFAULT_SECONDS, FLOW_RUN_WAIT_MAX_SECONDS } from "./capabilities/flow-runs.js";
|
|
6
|
+
export { createTextureImportsHost } from "./texture-import-host.js";
|
|
@@ -11,7 +11,7 @@ export type SparkRunExecutorOptions = {
|
|
|
11
11
|
/** When a run's conversation is compacted; see `SparkAgentOptions.compaction`. */
|
|
12
12
|
compaction?: SparkAgentOptions["compaction"];
|
|
13
13
|
resolveModel(settings: SparkRunSettings): ResolvedSparkModel | Promise<ResolvedSparkModel>;
|
|
14
|
-
createHost(context: SparkRunExecutionContext): Promise<Pick<SparkAgentOptions, "capabilities" | "executor" | "artifacts" | "persistence"> & {
|
|
14
|
+
createHost(context: SparkRunExecutionContext): Promise<Pick<SparkAgentOptions, "capabilities" | "executor" | "artifacts" | "persistence" | "unattended"> & {
|
|
15
15
|
dispose(): void;
|
|
16
16
|
}>;
|
|
17
17
|
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type SparkCapabilities } from "./capabilities.js";
|
|
2
|
+
import type { AccountHost } from "./capabilities/account.js";
|
|
3
|
+
import type { AssetImportsHost } from "./capabilities/asset-imports.js";
|
|
4
|
+
import { type AssetsHost } from "./capabilities/assets.js";
|
|
5
|
+
import { type FlowHost } from "./capabilities/flow.js";
|
|
6
|
+
import { type FlowRunsHost } from "./capabilities/flow-runs.js";
|
|
7
|
+
import { type GeometryHost } from "./capabilities/geometry.js";
|
|
8
|
+
import { type KnowledgeHost } from "./capabilities/knowledge.js";
|
|
9
|
+
import { type MaterialsHost } from "./capabilities/materials.js";
|
|
10
|
+
import { type OpenScadHost } from "./capabilities/openscad.js";
|
|
11
|
+
import { type OperationsHost } from "./capabilities/operations.js";
|
|
12
|
+
import { type PrintHost } from "./capabilities/print.js";
|
|
13
|
+
import { type ProjectHost } from "./capabilities/project.js";
|
|
14
|
+
import { type SceneHost } from "./capabilities/scene.js";
|
|
15
|
+
import type { TextureImportsHost } from "./capabilities/texture-imports.js";
|
|
16
|
+
import { type WebHost } from "./capabilities/web.js";
|
|
17
|
+
/**
|
|
18
|
+
* What the run's user and conversation allow. Each capability is offered only
|
|
19
|
+
* when its fact is true; absent is false.
|
|
20
|
+
*/
|
|
21
|
+
export type SparkRunFacts = {
|
|
22
|
+
/** Scene editing is on: `scene-editing` writes and `womp.materials`. */
|
|
23
|
+
scene?: boolean;
|
|
24
|
+
/** A scene can be read (scene editing, Geometry Nodes or parametric parts is on): `womp.scene` and print estimates. */
|
|
25
|
+
health?: boolean;
|
|
26
|
+
/** Geometry Nodes is on. */
|
|
27
|
+
geometry?: boolean;
|
|
28
|
+
/** Parametric parts (OpenSCAD) is on. */
|
|
29
|
+
openScad?: boolean;
|
|
30
|
+
/** Flow editing is on. Calls fail while no Flow canvas is open; the skill is offered either way. */
|
|
31
|
+
flow?: boolean;
|
|
32
|
+
/** The agent may start runs of the conversation's flow. */
|
|
33
|
+
flowRuns?: boolean;
|
|
34
|
+
/** Image and 3D generation. */
|
|
35
|
+
operations?: boolean;
|
|
36
|
+
/** Womp help documentation. */
|
|
37
|
+
knowledge?: boolean;
|
|
38
|
+
/** The user's account, credits, orders and projects. */
|
|
39
|
+
account?: boolean;
|
|
40
|
+
/** Web search and web images. */
|
|
41
|
+
web?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* False while the conversation has no project. With `hosts.project`, every
|
|
44
|
+
* project tool asks for one first, and `project-choice` is offered.
|
|
45
|
+
*/
|
|
46
|
+
projectBound?: boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The host services behind each capability. A host is required for every
|
|
50
|
+
* capability its fact enables; `assets` is offered whenever its host is given.
|
|
51
|
+
*/
|
|
52
|
+
export type SparkHosts = {
|
|
53
|
+
assets?: AssetsHost;
|
|
54
|
+
/** The `asset-import` half of `womp.assets`. */
|
|
55
|
+
imports?: AssetImportsHost;
|
|
56
|
+
/** The texture half of `womp.assets`. */
|
|
57
|
+
textureImports?: TextureImportsHost;
|
|
58
|
+
operations?: OperationsHost;
|
|
59
|
+
account?: AccountHost;
|
|
60
|
+
flow?: FlowHost;
|
|
61
|
+
/** The Flow node catalog the host's editor accepts, appended to `flow-graphs`. */
|
|
62
|
+
flowNodeCatalog?: string;
|
|
63
|
+
flowRuns?: FlowRunsHost;
|
|
64
|
+
geometry?: GeometryHost;
|
|
65
|
+
/** Its `health` is how the model reads scene health (`womp.scene.health`). */
|
|
66
|
+
scene?: SceneHost;
|
|
67
|
+
materials?: MaterialsHost;
|
|
68
|
+
openscad?: OpenScadHost;
|
|
69
|
+
print?: PrintHost;
|
|
70
|
+
knowledge?: KnowledgeHost;
|
|
71
|
+
web?: WebHost;
|
|
72
|
+
/** The conversation's project gate. Absent, project tools run ungated. */
|
|
73
|
+
project?: ProjectHost;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Spark's capability set for one run: which skills it offers, in which order,
|
|
77
|
+
* and how each behaves, from the run's facts. Hosts supply only services.
|
|
78
|
+
*/
|
|
79
|
+
export declare function createSparkCapabilities({ hosts, facts, }: {
|
|
80
|
+
hosts: SparkHosts;
|
|
81
|
+
facts: SparkRunFacts;
|
|
82
|
+
}): SparkCapabilities;
|
|
83
|
+
/**
|
|
84
|
+
* Scene scripts: JavaScript an outside model wrote against `womp.scene` alone,
|
|
85
|
+
* described by the same `scene-editing` skill a run reads.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createSceneScriptCapabilities(scene: SceneHost): SparkCapabilities;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { composeCapabilities } from "./capabilities.js";
|
|
2
|
+
import { createAssetsCapability } from "./capabilities/assets.js";
|
|
3
|
+
import { createAccountCapability } from "./capabilities/account.js";
|
|
4
|
+
import { createFlowCapability } from "./capabilities/flow.js";
|
|
5
|
+
import { createFlowRunsCapability } from "./capabilities/flow-runs.js";
|
|
6
|
+
import { createGeometryCapability } from "./capabilities/geometry.js";
|
|
7
|
+
import { createKnowledgeCapability } from "./capabilities/knowledge.js";
|
|
8
|
+
import { createMaterialsCapability } from "./capabilities/materials.js";
|
|
9
|
+
import { createOpenScadCapability } from "./capabilities/openscad.js";
|
|
10
|
+
import { createOperationsCapability } from "./capabilities/operations.js";
|
|
11
|
+
import { createPrintCapability } from "./capabilities/print.js";
|
|
12
|
+
import { createProjectChoiceCapability, gateAssetImportsHost, gateFlowHost, gateGeometryHost, gateMaterialsHost, gateOpenScadHost, gatePrintHost, gateSceneHost, } from "./capabilities/project.js";
|
|
13
|
+
import { createSceneCapability } from "./capabilities/scene.js";
|
|
14
|
+
import { createWebCapability } from "./capabilities/web.js";
|
|
15
|
+
import { geometryReference } from "./geometry.js";
|
|
16
|
+
function required(host, capability) {
|
|
17
|
+
if (host === undefined)
|
|
18
|
+
throw new Error(`The ${capability} capability is enabled but its host was not given.`);
|
|
19
|
+
return host;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Spark's capability set for one run: which skills it offers, in which order,
|
|
23
|
+
* and how each behaves, from the run's facts. Hosts supply only services.
|
|
24
|
+
*/
|
|
25
|
+
export function createSparkCapabilities({ hosts, facts, }) {
|
|
26
|
+
const project = hosts.project;
|
|
27
|
+
const gated = (host, gate) => host === undefined || project === undefined ? host : gate(host, project);
|
|
28
|
+
const scene = gated(hosts.scene, gateSceneHost);
|
|
29
|
+
const imports = gated(hosts.imports, gateAssetImportsHost);
|
|
30
|
+
// The key each capability is composed under is the `womp.*` global its skill
|
|
31
|
+
// names, and the composition order is the skill order in the system prompt.
|
|
32
|
+
const bindings = {
|
|
33
|
+
...(hosts.assets ? { assets: createAssetsCapability(hosts.assets, imports, hosts.textureImports) } : {}),
|
|
34
|
+
...(facts.operations ? { operations: createOperationsCapability(required(hosts.operations, "operations")) } : {}),
|
|
35
|
+
...(facts.account ? { account: createAccountCapability(required(hosts.account, "account")) } : {}),
|
|
36
|
+
...(facts.flow
|
|
37
|
+
? {
|
|
38
|
+
flow: createFlowCapability(gated(required(hosts.flow, "flow"), gateFlowHost), required(hosts.flowNodeCatalog, "flow")),
|
|
39
|
+
}
|
|
40
|
+
: {}),
|
|
41
|
+
...(facts.flowRuns ? { flowRuns: createFlowRunsCapability(required(hosts.flowRuns, "flowRuns")) } : {}),
|
|
42
|
+
...(facts.geometry
|
|
43
|
+
? { geometry: createGeometryCapability(gated(required(hosts.geometry, "geometry"), gateGeometryHost), geometryReference()) }
|
|
44
|
+
: {}),
|
|
45
|
+
...(facts.health ? { scene: createSceneCapability(required(scene, "scene")) } : {}),
|
|
46
|
+
...(facts.scene
|
|
47
|
+
? {
|
|
48
|
+
materials: createMaterialsCapability(gated(required(hosts.materials, "materials"), gateMaterialsHost), required(scene, "materials")),
|
|
49
|
+
}
|
|
50
|
+
: {}),
|
|
51
|
+
...(facts.openScad
|
|
52
|
+
? { openscad: createOpenScadCapability(gated(required(hosts.openscad, "openscad"), gateOpenScadHost)) }
|
|
53
|
+
: {}),
|
|
54
|
+
...(facts.health ? { printing: createPrintCapability(gated(required(hosts.print, "printing"), gatePrintHost)) } : {}),
|
|
55
|
+
...(facts.knowledge ? { knowledge: createKnowledgeCapability(required(hosts.knowledge, "knowledge")) } : {}),
|
|
56
|
+
...(facts.web ? { web: createWebCapability(required(hosts.web, "web")) } : {}),
|
|
57
|
+
...(project !== undefined && facts.projectBound === false ? { project: createProjectChoiceCapability(project) } : {}),
|
|
58
|
+
};
|
|
59
|
+
return composeCapabilities(bindings);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Scene scripts: JavaScript an outside model wrote against `womp.scene` alone,
|
|
63
|
+
* described by the same `scene-editing` skill a run reads.
|
|
64
|
+
*/
|
|
65
|
+
export function createSceneScriptCapabilities(scene) {
|
|
66
|
+
return composeCapabilities({ scene: createSceneCapability(scene) });
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@womp/spark-agent",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "Portable skills-based AI agent with local and durable chat transports for Womp",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"default": "./dist/browser.js"
|
|
19
19
|
},
|
|
20
20
|
"./capabilities": {
|
|
21
|
-
"types": "./dist/capabilities.d.ts",
|
|
22
|
-
"import": "./dist/capabilities.js",
|
|
23
|
-
"default": "./dist/capabilities.js"
|
|
21
|
+
"types": "./dist/public-capabilities.d.ts",
|
|
22
|
+
"import": "./dist/public-capabilities.js",
|
|
23
|
+
"default": "./dist/public-capabilities.js"
|
|
24
24
|
},
|
|
25
25
|
"./kakapo": {
|
|
26
26
|
"types": "./dist/kakapo.d.ts",
|