Function: eventDetector()
eventDetector<
T>(type,detect):EventDetector<T>
Build an EventDetector. Pass the event name as the
literal first arg and the matching detect callback as the
second. TS infers T from the literal, narrows detect’s
signature accordingly, and types the return as
EventDetector<T>.
Build-time guarantees:
eventDetector("status2", ...)fails - the name isn’t in GenieChatEvent.eventDetector("status", attachmentArgsCallback)fails -"status"is message-scoped, sodetectmust take(GenieMessage, GenieMessage | undefined, string).- Returning a
ThinkingEvent-shaped fields object from a"status"detector fails - the return type is constrained toDetectorResult<"status">.
Lifecycle event names ("message", "result") resolve detect
to never and won’t compile, which is intentional: those have
no diff signature and are emitted directly by the chat driver.
Type Parameters
Section titled “Type Parameters”T extends "query" | "suggested_questions" | "text" | "status" | "message" | "question" | "attachment" | "thinking" | "statement" | "rows" | "result"
Parameters
Section titled “Parameters”T
detect
Section titled “detect”DetectFn<T>
Returns
Section titled “Returns”EventDetector<T>