arcflow GitHub

AI and agents

A model never sees a blank page: it gets the catalog of steps you registered, and whatever it writes is validated against them. When something is wrong, the issues go back with their JSON paths until the flow holds — which is why generated flows are runnable rather than plausible.

Generate

import { anthropicModel, generateFlow } from '@arcsig-labs/ai';

const { ok, flow, issues, attempts } = await generateFlow({
	registry,
	model: anthropicModel(),          // ANTHROPIC_API_KEY
	prompt: 'Every Monday at 9, fetch open invoices and post a summary to our webhook'
});

flow is ordinary flow JSON. attempts records each try with its raw text, issues and token usage, so you can see what the repair loop did.

Change an existing flow

import { editFlow, summarizeChanges } from '@arcsig-labs/ai';

const result = await editFlow({ registry, model, flow, instruction: 'Also tell me when the request fails' });
console.log(summarizeChanges(result.changes)); // "2 added, 1 changed"

changes lists what moved — enough to show a diff and let someone accept or reject it. Positions are ignored, so dragging a step is not a change.

Explain

explainFlow describes a flow in plain language, or answers a question about it — for a review comment, or for handing a flow to someone who did not build it.

Any model

ModelAdapter is text in, text out. anthropicModel() is included; anything else is a few lines.

const ollama: ModelAdapter = {
	name: 'llama3',
	async complete({ system, messages }) {
		const response = await fetch('http://localhost:11434/api/chat', {
			method: 'POST',
			body: JSON.stringify({ model: 'llama3', system, messages, stream: false })
		});
		return { text: (await response.json()).message.content };
	}
};

In the editor

With a key on the server, the canvas gets a prompt bar: describe a flow and it is built and validated in front of you, describe a change and it is applied, then Keep or Discard — on top of the normal undo history. With errors on the canvas the bar offers Fix problems, handing the model the issues and their paths; otherwise it offers Explain.

ANTHROPIC_API_KEY=sk-... npx -y -p @arcsig-labs/server -p @arcsig-labs/editor arcflow dev

The key stays on the server: the browser calls /api/ai/* and never holds one.

Agents (MCP)

Point Claude Code, Cursor or any MCP client at your steps and let it build and run flows:

claude mcp add arcflow -- npx -y @arcsig-labs/mcp --url http://127.0.0.1:8787
Tool
list_stepsEvery step with its settings and outputs — the only source of truth
validate_flowProblems with their JSON paths, without saving
test_flowA run in simulate mode: steps with a test mode report what they would do instead of doing it
patch_flowChanges one part of a flow at the path an issue reported, instead of rewriting the document
list_flows, get_flow, save_flowWhat is on the server, and new versions of it
run_flow, get_runRun a saved flow and read what happened, step by step

Without a server the first three still work, so an agent can draft and check a flow before anything is saved.