Skip to main content

Module sdk_event_queue

Module sdk_event_queue 

Source
Expand description

SDK event queue utilities. Translated from ~/claudecode/openclaudecode/src/utils/sdkEventQueue.ts

SDK events are emitted during headless/streaming sessions and drained by the CLI output layer. In TUI mode they are silently dropped to avoid queue buildup.

Structs§

DrainedSdkEvent
A drained SDK event with UUID and session ID appended.
SdkEvent
A single SDK event with all possible fields (matching TS union type).
SdkEventQueue
Thread-safe event queue for SDK communication.
SdkEventUsage
Usage statistics for task_progress events.
TaskProgressParams
Parameters for task_progress event emission.

Enums§

SdkEventType
A typed SDK event subtype.

Functions§

drain_sdk_events
Drain all pending SDK events and return them with uuid and session_id. Call this from the output layer (print.ts equivalent) to deliver events to SDK consumers.
emit_session_state_changed
Emit a session_state_changed SDK event. Mirrors notifySessionStateChanged — the ‘idle’ transition fires after heldBackResult flushes and the bg-agent do-while loop exits, serving as the authoritative “turn is over” signal for SDK consumers.
emit_task_progress
Emit a task_progress SDK event. Shared by background agents (per tool_use) and workflows (per flush batch).
emit_task_started
Emit a task_started SDK event. Called by register_task() when a new task is registered.
emit_task_terminated_sdk
Emit a task_notification SDK event for a task reaching a terminal state.
enqueue_sdk_event
Enqueue an SDK event. In TUI mode (interactive session), events are dropped to avoid queue buildup.