Skip to content

event

Pure event-detection for genieEventChat. Given two GenieMessage snapshots (current + prior) and the surrounding space_id, derive the semantic deltas (status transitions, new attachments, new thoughts, SQL emission, warehouse submission, row-count progress, follow-up suggestions, text deltas) and yield them as typed GenieChatEvents.

Detectors are built through a single typed factory that ties each event’s name to its scope (whole-message vs per-attachment) and payload shape, so a misnamed event or a payload that doesn’t match its event fails to compile. An orchestrator walks the snapshot diff and yields every detector that fires in a stable order (status first, then per-attachment field deltas) so a subscriber that logs events as they arrive sees a sensible sequence.

The module is intentionally pure: no EventEmitter, no this, no I/O, no module-level mutable state. The message and result events are NOT derived here - they belong to the chat lifecycle layer (the genieEventChat driver) because they track per-yield / per-turn-completion semantics rather than a field-level snapshot diff.