/** * AgentEvent → SessionEvent mapping (D-P2-4, scope §3). * * The pi-agent-core `AgentEvent` runtime shape was verified before this * mapping was written (scope §7 risk): `agent_start, turn_start, * message_start, message_update×N, message_end, turn_end, agent_end` for a * text turn, with `tool_execution_start/update/end` interleaved for tool * turns. `message_update` carries the pi-ai `AssistantMessageEvent` whose * `type` discriminates the field-addressed delta (`text_delta`/`thinking_delta` * with `contentIndex`) — that `contentIndex` becomes the `partId` on the * OpenKai `delta` event. * * The mapping is a pure function: `mapAgentEvent(event) → SessionEvent[]`. * The transport owns `seq` assignment (monotonic) and `sessionId` injection so * this module stays side-effect-free and testable. */ import type { AgentEvent } from "@earendil-works/pi-agent-core"; import type { SessionEvent } from "./transport.js"; /** * Distributive Omit — `Omit` does not distribute over unions, so a plain * `Omit` collapses to the common keys only. This distributes * over each variant, preserving the discriminant fields. */ type DistributiveOmit = T extends any ? Omit : never; /** A SessionEvent with its `sessionId`/`seq` metadata stripped (caller fills them). */ export type StrippedSessionEvent = DistributiveOmit; /** * Map one {@link AgentEvent} to zero or more {@link StrippedSessionEvent}s. * The caller stamps `sessionId` and assigns `seq` (ascending from 1). * * Returns an array because `turn_end` emits a usage snapshot, an optional * `error` event (when the settled assistant message carries stopReason * "error" or an errorMessage), and a turn marker. The common case is exactly * one output event. */ export declare function mapAgentEvent(event: AgentEvent): StrippedSessionEvent[]; export {}; //# sourceMappingURL=events.d.ts.map