skills
The skills namespace is the engine's plugin surface for LLM-driven and file-processing operations. A "skill" is a registered handler that takes user input (a file, a prompt, or both) and produces graph mutations, chat replies, or both.
Skills are how the host wires in capabilities like "import this CSV with smart column mapping", "summarise this subgraph", or "ask an LLM to suggest connections between selected nodes" — without baking any specific provider or workflow into the engine.
Registering a skill
api.skills.register({
id: "csv-import",
label: "Import CSV",
accepts: { files: ["text/csv"] },
async execute(input, ctx) {
const text = await input.file!.text();
const { nodes, edges } = parseCsv(text);
await ctx.nodes.add(nodes);
await ctx.edges.add(edges);
return { message: `Imported ${nodes.length} nodes` };
},
});
Each skill carries an id, a human-readable label, and an accepts descriptor that tells the host what input the skill can process (file MIME types, prose only, both). The execute(input, ctx) function receives the user-supplied input and a context object exposing the relevant API surfaces (nodes, edges, current selection, etc.).
Running a skill
The host can invoke registered skills directly:
const result = await api.skills.execute("csv-import", {
file: fileFromInput,
});
apply(skillId, input) is the convenience wrapper that also pipes the result back through the chat history when the host has a chat UI wired up.
File-driven shortcut
For drag-and-drop / file-upload UI, processFile(file) auto-selects the first registered skill whose accepts.files matches the file's MIME type and dispatches it:
container.ondrop = async (e) => {
for (const file of e.dataTransfer.files) {
await api.skills.processFile(file);
}
};
If no registered skill matches, processFile returns null and emits no event.
Configuring a skill
configure(skillId, config) updates a skill's per-instance state — e.g. setting an LLM API key, choosing a model, supplying a column-mapping override for the next CSV. Configuration is opaque to the engine; it's passed to the skill's execute as input.config.
Result subscription
Skills can emit progress and intermediate results. onResult(skillId, handler) subscribes to that stream and returns an unsubscribe function:
const unsub = api.skills.onResult("csv-import", (chunk) => {
progressBar.update(chunk.fraction);
});
// later
unsub();
This is how chat-style skills stream LLM tokens back to the host without each skill needing its own event bus.