src/chat
Genie chat driver.
Drives a single turn against a Genie space from one content string;
multi-turn conversations are the caller’s job (thread the conversation_id
returned on each GenieMessage back into the next turn’s
options.conversationId).
Agent Mode SSE is the default transport. Its Responses-style reasoning, SQL,
query output, and final answer items are projected into GenieMessage
snapshots; agentMode: false retains the Conversation API polling path.
Two layers serve two kinds of consumer. The low-level layer yields every
observed GenieMessage (validated against GenieMessageSchema, falling back
to the raw snapshot on a schema miss) and owns cancellation, conversation
seeding, distinct-filtering, and SDK quirks; reach for it when you want the
raw stream. The
high-level layer wraps it and emits semantic, deduplicated { type, payload }
events (see GenieChatEvent), always closing a successful turn with a
terminal result event carrying the final GenieMessage; errors propagate
by throwing, with no error variant. Iterating UI / agent code that wants
every message verbatim takes the low-level stream; subscribers reacting to
“Genie is thinking about X” or “Genie produced text Y” take the event layer.