Files
joelhooks__joelclaw/packages/restate-lab/package.json
Joel Hooks 6b061ccbee restate-lab Level 3: human-in-the-loop approval with channel interface
Channel-agnostic notification interface (NotificationChannel) with Telegram and
Console implementations. Approval workflow uses ctx.promise('decision') for
durable blocking — survives worker kill and restart.

Full flow proven:
  1. Workflow sends Telegram message with inline keyboard buttons
  2. Worker killed (kill -9) while promise is suspended
  3. New worker starts — no replay, Restate holds the promise
  4. Human taps Approve on Telegram (button from dead process)
  5. Polling catches callback → resolves Restate promise
  6. Workflow replays on new PID, completes, sends outcome notification

Channel interface: types.ts defines NotificationChannel, Action, CallbackData
with encode/decode helpers. Telegram impl uses Bot API + long-polling (avoids
gateway webhook conflict). Console impl for local testing with CLI resolve.

Callback routing: button callback_data format restate:{service}:{workflowId}:{action}
decoded by channel listener → generic resolver → Restate workflow handler POST.
2026-03-05 07:38:59 -08:00

17 lines
398 B
JSON

{
"name": "@joelclaw/restate-lab",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"lab": "bun run src/index.ts",
"send": "bun run src/send.ts",
"send-approval": "bun run src/send-approval.ts",
"resolve": "bun run src/resolve.ts"
},
"dependencies": {
"@restatedev/restate-sdk": "^1.10.4",
"@restatedev/restate-sdk-clients": "^1.10.4"
}
}