CLI Internals
Message and Chunk Data Model
Understand how thread messages, assistant envelopes, and normalized chunks fit together.
OpenSana separates assistant message lifecycle from assistant chunk storage.
Main Pieces
cliThreads: thread-level queue and claim statecliMessages: user messages and assistant envelope recordscliMessageChunks: streamed assistant chunk rows
Why This Split Exists
Assistant responses are streamed incrementally, but the thread still needs stable message-level lifecycle state such as pending, streaming, completed, or failed.
Normalization
Raw chunks are normalized into event categories such as:
- text
- reasoning
- tool input
- tool output
- tool error
- metadata
- warning
- unknown
That normalized layer drives the web UI renderer.