a workflow · steps on a graph, the rule is an edge
export const bugTriageWorkflow = createWorkflow({
  id: 'bug-triage',
  inputSchema: bugReportSchema,
  outputSchema: triageOutputSchema,
})
  .then(createReportStep)
  .then(researchStep)
  .then(classifyStep)
  .branch([
    [isKind('not-a-bug'), replyStep],
    [isKind('simple-fix'), implementStep],
    [isKind('needs-human'), humanPathWorkflow],
  ])
  .then(finaliseStep)
  .commit()
a run · an endpoint, a cron, a queue, a test
// POST /api/triage
POST: async ({ request }) => {
  const { title, body } = await request.json()

  const run = await bugTriage().createRun()
  const stream = await run.stream({
    inputData: { title, body },
  })

  return streamToSSE(stream, { runId: run.runId })
}