KuralleThreadAgent
Generic production Durable Object: deploy one class and create one named
instance per authenticated (tenantId, threadId) pair.
Extends
Section titled “Extends”KuralleAgent<Env,State>
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
|
|
|
|
|
|
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new KuralleThreadAgent<Env, State>(ctx, env): KuralleThreadAgent<Env, State>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”KuralleThreadAgent<Env, State>
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”onChatMessage()
Section titled “onChatMessage()”onChatMessage(onFinish, options?): Promise<Response>;Called by CF when a chat message arrives.
CF has already:
- Received the WebSocket message from the client
- Parsed and validated it
- Persisted the user message to cf_ai_chat_agent_messages
- Populated this.messages with the full conversation history
We:
- Create a BridgeSessionStore (CF messages + orchestration state)
- Build and run Kuralle Runtime
- Return an SSE Response
CF then:
- Reads the SSE stream via _reply()
- Builds assistant message parts via applyChunkToParts()
- Persists the assistant message
- Broadcasts to all connected clients
- Handles stream resumability
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Section titled “Returns”Promise<Response>
Inherited from
Section titled “Inherited from”onRequest()
Section titled “onRequest()”onRequest(request): Promise<Response>;HTTP endpoint handler. Adds Kuralle-specific endpoints on top of CF’s defaults.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Promise<Response>
Overrides
Section titled “Overrides”runScheduledKuralleJob()
Section titled “runScheduledKuralleJob()”runScheduledKuralleJob(job): Promise<void>;DO-alarm callback for scheduled jobs. Wake jobs run an agent-initiated
turn and persist + broadcast the assistant reply through CF’s machinery
(same path as resumeWithSignal); other job kinds go to
onScheduledJob for subclasses to handle.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Promise<void>