Imperative agent workflows
Run a schedule, monitor in the web UI
bunx @frebreco/factory initimport { defineWorkflow, Schema } from "@frebreco/factory";
export default defineWorkflow("hello-world", { input: Schema.Struct({ task: Schema.String, }),
output: Schema.Struct({ prUrl: Schema.NullOr(Schema.String), }),
run: async (ctx, input) => { // Run a sandboxed agent await ctx.agent("implement", `Implement the following task: ${input.task}`);
// Create a PR const writeBack = await ctx.writeBack({ branch: "factory/hello-world", commitMessage: `${input.task}\n\nAutomated by the factory 'hello' workflow.`, prTitle: input.task, prBody: `Opened by factory.\n\nTask: ${input.task}`, });
return { prUrl: writeBack.prUrl }; },});Plain async TypeScript over a run context — ctx.agent, exec, writeBack, assert, output. No step graph, no DSL.
factory serve gives you HTTP + SSE, run admission and lifecycle, automatic dispatch, and sqlite persistence.
A React SPA to watch runs land: the event log, per-step transcripts, write-backs, and manual dispatch.