Get the project
Download the complete TypeScript project, extract it, and runnpm install in its directory. The archive includes this source, package.json, tsconfig.json, and a README.
To start manually in an empty directory:
Follow the execution
The Workflow defines the sequence.workflowDriver connects its steps to the harness. The runtime grants only the two named steps; an execution policy requires approval specifically for submission. The host supplies the decision.
Save as harness-workflow.ts:
harness-workflow.ts
Run both outcomes
workflow_step_failed. The second logs an approved decision, a completed result, one submission, and a state containing simulated-refund:order-42. A denied step is visible in the result; the caller decides whether that outcome should fail a larger job.
In the downloaded project, npm run check verifies types and npm start -- --approve runs the approved path.
Adapt it to your application
The command-line flag is a demonstration decision, not an authentication or approval UI. Move operator decisions into the host’s approval integration before exposing the workflow to users.
Troubleshoot and clean up
- Step denied before the callback: check the exact
workflow:<step-name>grant; permission and approval are separate decisions. - Invalid input: the driver accepts only the declared order ID field. It does not let the caller patch
eligibleorreceiptinto trusted state. - Budget exhausted after adding a limit: test the actual driver accounting. This fixed two-step example forbids model calls but leaves the aggregate tool-call budget unset; a function-step count is not a promise of identical budget consumption.
- Unknown payment outcome after adapting it: do not treat cancellation as a rollback. Follow recovery before retrying.
ApprovalManager in finally. It creates no persistent data. Next, add model-backed research or learn durable approvals.