Variable: GenieChatEventSchema
constGenieChatEventSchema:ZodDiscriminatedUnion<[ZodObject<{content:ZodString;conversation_id:ZodOptional<ZodString>;message_id:ZodOptional<ZodString>;space_id:ZodString;type:ZodLiteral<"question">; },$strip>,ZodObject<{conversation_id:ZodOptional<ZodString>;message:ZodObject<{attachments:ZodOptional<ZodArray<ZodObject<{attachment_id:ZodOptional<…>;attachment_type:ZodOptional<…>;query:ZodOptional<…>;suggested_questions:ZodOptional<…>;text:ZodOptional<…>; },$strip>>>;auto_regenerate_count:ZodOptional<ZodNumber>;content:ZodString;conversation_id:ZodString;created_timestamp:ZodOptional<ZodNumber>;error:ZodOptional<ZodObject<{error:ZodOptional<ZodString>;type:ZodOptional<ZodUnion<…>>; },$strip>>;feedback:ZodOptional<ZodObject<{rating:ZodOptional<ZodUnion<…>>; },$strip>>;id:ZodString;last_updated_timestamp:ZodOptional<ZodNumber>;message_id:ZodString;query_result:ZodOptional<ZodObject<{is_truncated:ZodOptional<ZodBoolean>;row_count:ZodOptional<ZodNumber>;statement_id:ZodOptional<ZodString>;statement_id_signature:ZodOptional<ZodString>; },$strip>>;space_id:ZodString;status:ZodOptional<ZodUnion<readonly [ZodLiteral<"ASKING_AI">,ZodLiteral<"CANCELLED">,ZodLiteral<"COMPLETED">,ZodLiteral<"EXECUTING_QUERY">,ZodLiteral<"FAILED">,ZodLiteral<"FETCHING_METADATA">,ZodLiteral<"FILTERING_CONTEXT">,ZodLiteral<"PENDING_WAREHOUSE">,ZodLiteral<"QUERY_RESULT_EXPIRED">,ZodLiteral<"SUBMITTED">]>>;user_id:ZodOptional<ZodNumber>; },$strip>;message_id:ZodOptional<ZodString>;space_id:ZodString;type:ZodLiteral<"message">; },$strip>,ZodObject<{conversation_id:ZodOptional<ZodString>;message_id:ZodOptional<ZodString>;previous_status:ZodOptional<ZodUnion<readonly [ZodLiteral<"ASKING_AI">,ZodLiteral<"CANCELLED">,ZodLiteral<"COMPLETED">,ZodLiteral<"EXECUTING_QUERY">,ZodLiteral<"FAILED">,ZodLiteral<"FETCHING_METADATA">,ZodLiteral<"FILTERING_CONTEXT">,ZodLiteral<"PENDING_WAREHOUSE">,ZodLiteral<"QUERY_RESULT_EXPIRED">,ZodLiteral<"SUBMITTED">]>>;space_id:ZodString;status:ZodUnion<readonly [ZodLiteral<"ASKING_AI">,ZodLiteral<"CANCELLED">,ZodLiteral<"COMPLETED">,ZodLiteral<"EXECUTING_QUERY">,ZodLiteral<"FAILED">,ZodLiteral<"FETCHING_METADATA">,ZodLiteral<"FILTERING_CONTEXT">,ZodLiteral<"PENDING_WAREHOUSE">,ZodLiteral<"QUERY_RESULT_EXPIRED">,ZodLiteral<"SUBMITTED">]>;type:ZodLiteral<"status">; },$strip>],"type">
Discriminated union yielded by genieEventChat. Each variant
is a single flat object with type as the discriminator and
the payload fields hoisted directly to the top level - no
payload wrapper. Consumers narrow on type and read fields
inline:
Example
Section titled “Example”for await (const event of genieEventChat(spaceId, "Top stores?")) { switch (event.type) { case "thinking": console.log(event.thought_type, event.text); break; case "result": console.log("done:", event.status); break; }}
Stream order per turn:
1. `question`, emitted with the first `message` yield (deferred so the assigned `message_id` is available), carrying the prompt this turn sent to Genie. 2. `message` for every poll yield (raw `GenieMessage` on `event.message`). 3. Any derived events the snapshot diff produced (`status`, `attachment`, `thinking`, `text`, `query`, `statement`, `rows`, `suggested_questions`) in that fixed order. 4. On the terminal snapshot, a final `result` event.
Errors propagate via the generator throwing (`try`/`catch` the`for await`), not via an `error` variant on this union.