Get running in 5 minutes.
- Node.js 20+ or Bun 1.2+
- bun (recommended) or npm/yarn
bun add @open-scaffold/core @open-scaffold/server @open-scaffold/clientAgents are AI actors with a model, prompt, output schema, and state update function.
// agents.ts
import { agent } from "@open-scaffold/core"
import { z } from "zod"
export const worker = agent({
name: "worker",
model: "claude-sonnet-4-5",
output: z.object({
result: z.string()
}),
prompt: (state) => `Complete this task: ${state.task}`,
update: (output, draft) => {
draft.result = output.result
}
})Workflows combine agents into phases with explicit transitions.
// workflow.ts
import { workflow, phase } from "@open-scaffold/core"
import { worker } from "./agents"
export const myWorkflow = workflow({
name: "my-workflow",
initialState: { task: "", result: "" },
start: (input: string, draft) => {
draft.task = input
},
phases: {
work: { run: worker, next: "done" },
done: phase.terminal()
}
})Execute the workflow with observer callbacks to monitor progress.
// main.ts
import { run } from "@open-scaffold/core"
import { AnthropicProvider } from "@open-scaffold/server"
import { myWorkflow } from "./workflow"
const result = await run(myWorkflow, {
input: "Write a haiku about coding",
runtime: {
providers: { "claude-sonnet-4-5": AnthropicProvider() },
mode: "live"
},
observer: {
onStateChanged: (state, patches) => {
console.log("State updated:", patches)
},
onTextDelta: ({ agent, delta }) => {
process.stdout.write(delta)
},
onAgentCompleted: ({ agent, output, durationMs }) => {
console.log(`\n${agent} completed in ${durationMs}ms`)
}
}
})
console.log("Final result:", result.state.result)Add real-time UI with the client package.
// app.tsx
import { WorkflowProvider, useWorkflowState, useCreateSession } from "@open-scaffold/client"
function App() {
return (
<WorkflowProvider url="http://localhost:42069">
<WorkflowUI />
</WorkflowProvider>
)
}
function WorkflowUI() {
const state = useWorkflowState<{ task: string; result: string }>()
const createSession = useCreateSession()
return (
<div>
<button onClick={() => createSession("Hello!")}>Start</button>
{state && <p>Result: {state.result}</p>}
</div>
)
}-
Agent defined -- The
workeragent knows its model, how to prompt it, what output to expect (via Zod schema), and how to update workflow state with the result. -
Workflow composed -- The workflow defines initial state, how to apply input, and phases that sequence agent execution. The
workphase runs the agent, then transitions todone. -
Runtime executed -- The
run()function executes the workflow. Theruntimeconfig provides the AI provider and mode (livefor real API calls,playbackfor recorded responses). Observer callbacks stream progress in real-time. -
React connected -- The client package provides hooks that connect to a running server on port 42069, giving you reactive state updates in your UI.
| Document | Description |
|---|---|
| Concepts | Core mental models |
| Building Workflows | Agents, phases, workflows |
| React Integration | React hooks reference |
| API Reference | Complete type signatures |
| Architecture | How it works internally |