Type Alias: KnownSessionEvent
Makaio Framework / contracts/session / KnownSessionEvent
Type Alias: KnownSessionEvent
Section titled “Type Alias: KnownSessionEvent”KnownSessionEvent =
{ [K in RuntimeKnownSessionEventType]: SessionEventBase & { payload: SessionEventTypeMap[K]; type: K } }[RuntimeKnownSessionEventType]
Defined in: ../../../packages/contracts/src/session/types.ts:99
Narrowable discriminated union of core session event types.
Scoped to RuntimeKnownSessionEventType so the union precisely matches
what isKnownSessionEvent can confirm at runtime. Every variant carries
a literal type and the exact payload shape, enabling exhaustive
switch(event.type) narrowing without casts:
Example
Section titled “Example”if (isKnownSessionEvent(event)) { switch (event.type) { case 'turn.completed': console.log(event.payload.turnId); // narrowed, no cast break; }}Plugin events: extensions extend SessionEventTypeMap via declaration
merging, but their keys are excluded from this union because the runtime guard
only checks SESSION_EVENT_TYPES. Plugin events pass through the Zod catch-all
branch and return false from isKnownSessionEvent.
Type Composition
Section titled “Type Composition”KnownSessionEvent{ [K in RuntimeKnownSessionEventType]: SessionEventBase & { type: K; payload: SessionEventTypeMap[K]; }; }[RuntimeKnownSessionEventType]
Resolved Shape
Section titled “Resolved Shape”type KnownSessionEvent = { sessionId: string; eventId: string; timestamp: number; type: 'message' | 'user_message.sent' | 'user_message.acknowledged' | 'user_message.completed' | 'turn.started' | 'turn.completed' | 'agent.added' | 'branch.created' | 'branch.merged' | 'squash'; payload: { messageId: string; turnId: string | null; role: 'user' | 'assistant'; } | { sessionId: string; turnId: string; turnNumber: number; messageId: string; content: string | { blocks: { type: 'text'; content: string; } | { type: 'image'; source: { type: 'base64'; data: string; mimeType: string; } | { type: 'url'; url: string; mimeType?: string | undefined; }; } | { type: 'document'; source: { type: 'base64'; data: string; mimeType: string; } | { type: 'url'; url: string; mimeType?: string | undefined; }; } | { type: 'attachment'; fileName: string; filePath: string; source: { type: 'base64'; data: string; mimeType: string; } | { type: 'url'; url: string; mimeType?: string | undefined; }; attachmentType: 'file' | 'directory'; displayName?: string | undefined; } | { type: 'reasoning'; content: string; metadata?: Record<string, unknown> | undefined; } | { type: 'tool_call'; toolCallId: string; name: string; args: Record<string, unknown>; } | { type: 'tool_output'; toolCallId: string; output: string; isError?: boolean | undefined; } | Array<{ type: 'text'; content: string; } | { type: 'image'; source: { type: 'base64'; data: string; mimeType: string; } | { type: 'url'; url: string; mimeType?: string | undefined; }; } | { type: 'document'; source: { type: 'base64'; data: string; mimeType: string; } | { type: 'url'; url: string; mimeType?: string | undefined; }; } | { type: 'attachment'; fileName: string; filePath: string; source: { type: 'base64'; data: string; mimeType: string; } | { type: 'url'; url: string; mimeType?: string | undefined; }; attachmentType: 'file' | 'directory'; displayName?: string | undefined; } | { type: 'reasoning'; content: string; metadata?: Record<string, unknown> | undefined; } | { type: 'tool_call'; toolCallId: string; name: string; args: Record<string, unknown>; } | { type: 'tool_output'; toolCallId: string; output: string; isError?: boolean | undefined; }>; role?: 'user' | 'assistant' | 'system' | undefined; }; agentIds: Array<string>; source?: 'user' | 'system' | 'extension' | undefined; origin?: 'text' | 'voice' | 'compact' | undefined; } | { sessionId: string; turnId: string; turnNumber: number; messageId: string; agentId: string; } | { sessionId: string; turnId: string; turnNumber: number; messageId: string; agentId: string; outcome: 'error' | 'completed' | 'superseded' | 'merged' | 'cancelled' | 'rejected'; supersededBy?: string | undefined; mergedInto?: string | undefined; error?: string | undefined; } | { sessionId: string; turnId: string; messageId: string; agentIds: string[]; initiator?: import("@makaio/contracts").TurnInitiator; } | { sessionId: string; turnId: string; success: boolean; error?: string; initiator?: import("@makaio/contracts").TurnInitiator; } | { sessionId: string; adapterSessionId: string; agentId: string; adapterId: string; adapterName: string; role?: 'lead' | 'member'; model?: string; cwd?: string; } | { childSessionId: string; parentSessionId: string; kind: z.infer<typeof import("apps/website/.typedoc-entrypoints/contracts/session/index.js").BranchKindSchema>; forkPointMessageId?: string; } | { childSessionId: string; parentSessionId: string; resultJson?: string; resultMessageId?: string; } | { summaryJson: string; tokensBefore?: number; tokensAfter?: number; compressedMessageIds?: string[]; };};