Khala Phase 3: Workflow engine — ThreadDO + JSONata moderator #128
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #119
Objective
Core workflow engine using Durable Objects + JSONata moderator.
Tasks
3.1 Workflow Registry
Create
packages/khala/src/workflows.ts:CloudRoletype:{ prompt: string }CloudWorkflowDeftype:{ name, roles: Record<string, CloudRole>, moderator: string }registerWorkflow()andgetWorkflow()3.2 ThreadDO
Create
packages/khala/src/thread-do.ts:POST /start— init thread, run moderator for first turn, create taskPOST /response— validate claim_id, append message, run moderator → next task or ENDGET /messages— query with filters (role, since, step, last){ role }or{ role: "__end__" }3.3 Wire into Worker
Modify
src/index.ts:ThreadDOclassPOST /workflows/:name/threads— create thread → DOPOST /threads/:id/response— forward to DOGET /threads/:id/messages— query messagesGET /threads/:id— thread statusReferences
docs/plans/2026-04-25-khala-mvp.md(Task 3.1-3.3)