Skip to Content
onedef

Without MCP

Drive runs from your own code, such as a web form, a Slack button, a queue or a test.

MCP is one way to drive a run. workflowRuns is the same thing for your own code: start a run, read its open question, answer it later.

import { workflowRuns } from '@onedef/elicitation-workflow'

const runs = workflowRuns(release, { runStore })

const state = await runs.start({ version: '2.1.0' })
// {
//   runId: 'run_…',
//   status: 'waiting',
//   waitingFor: { kind: 'human', name: 'elicit-1', message: 'Publish 2.1.0 (build-1)?', requestedSchema },
// }

Show the question however you like, and send the answer back with next. It can come minutes or days later, from another process:

await runs.next(state.runId, { action: 'accept', content: { channel: 'beta' } })
// → { runId, status: 'done', output: { released: true, … } }

What next takes depends on waitingFor.kind:

kindfromanswer
humanctx.elicitHumanInput{ action: 'accept' | 'decline' | 'cancel', content? }
approvalctx.approve{ approved: boolean, feedback?: string }
agentctx.elicitAgentInputa value matching waitingFor.schema

next(runId) with no answer just reports where the run is. A wrong answer throws RunError with code INVALID_INPUT, and the run stays where it was.

Examples of drivers

  • Web app: one route starts the run and saves the runId. A page renders a form from requestedSchema (a flat object of primitive fields). The submit handler calls next.
  • Slack or email: post the question with buttons. The button's webhook calls next, hours later, on whichever instance receives it.
  • Tests: start, assert on waitingFor, answer, assert on output.

Advanced: headless runs

A headless run is one that nobody will answer, such as a nightly job. MCP servers don't need this, because an MCP client can always answer.

await runs.start(input, { headless: true })

In a headless run:

result
ctx.elicitHumanInput{ action: 'cancel' }, as from a client that cannot show forms
ctx.elicitAgentInputthe run fails: nobody can answer it
ctx.approvewaits as usual; start returns status: 'waiting', and next can still answer it

To finish anyway, branch on ctx.headless and do the agent's work yourself:

const plan = ctx.headless
  ? await ctx.step('plan', () => myModel.plan(ctx.input.topic))
  : await ctx.elicitAgentInput('plan', { schema, instructions, data })

On this page