OrchestrationStore
Lightweight store for Kuralle orchestration state, keyed by session id.
This is NOT a SessionStore. CF owns message persistence via its cf_ai_chat_agent_messages table. This store only tracks the state Kuralle needs for multi-agent orchestration within a specific call / logical session:
- currentAgent: which agent is active
- workingMemory: key-value context injected into prompts
- agentStates: per-agent state (flow node, extraction data, etc.)
- handoffHistory: agent-to-agent transfer log
Keyed by sessionId, so multiple calls into the same DO get isolated
orchestration state (fresh flow node per call, independent handoff history).
DO-scoped state that should survive across calls (Gemini resumption handle,
long-term memory facts) belongs in this.state, not here.
Earlier versions used a hardcoded 'default' sentinel, collapsing every
call in a DO into the same row. That was fine for single-call demos but
caused cross-call state leaks (flow stuck at confirm on the 2nd call).
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OrchestrationStore(sql): OrchestrationStore;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”OrchestrationStore
Methods
Section titled “Methods”cleanup()
Section titled “cleanup()”cleanup(maxAgeMs): Promise<number>;Garbage-collect rows older than maxAgeMs. Call from an alarm or on
DO wake to keep the table bounded when users don’t explicitly end calls.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Promise<number>
clear()
Section titled “clear()”clear(id): Promise<void>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Promise<void>
get(id): Promise< | OrchestrationState| null>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Promise<
| OrchestrationState
| null>
save()
Section titled “save()”save(id, state): Promise<void>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Section titled “Returns”Promise<void>