mirror of
https://github.com/joelhooks/joelclaw.git
synced 2026-09-19 01:24:04 +08:00
6b061ccbee
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.
17 lines
398 B
JSON
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"
|
|
}
|
|
}
|