import type { VerboseLevel } from "../auto-reply/thinking.js"; export type KoiEventStream = "lifecycle" | "tool" | "assistant" | "error" | (string & {}); export declare function runWithRunId(runId: string, fn: () => T): T; export declare function getCurrentRunId(): string | undefined; export type KoiEventPayload = { runId: string; seq: number; stream: KoiEventStream; ts: number; data: Record; sessionKey?: string; }; export type KoiRunContext = { sessionKey?: string; verboseLevel?: VerboseLevel; isHeartbeat?: boolean; /** * Koi id of the speaker actually answering this run. For * single-speaker turns this is the session's koi. For multi-koi * broadcast turns this is the specific companion driving this run * — the gateway uses it to tag chat-final payloads so the UI can * render the right name + avatar per assistant message. */ speakerKoiId?: string; }; export declare function registerKoiRunContext(runId: string, context: KoiRunContext): void; export declare function getKoiRunContext(runId: string): KoiRunContext | undefined; export declare function clearKoiRunContext(runId: string): void; /** Has a terminal lifecycle event (phase "end" | "error") already fired for * this run? Used to avoid double-emitting a backstop terminal. */ export declare function hasEmittedRunTerminal(runId: string): boolean; /** * Clear the "terminal emitted" mark for a run WITHOUT dropping its context * (sessionKey/seq stay). Model fallback shares ONE runId across attempts, so a * non-final attempt's terminal marks the run ended and suppresses the real * exhaustion-point error terminal. Calling this at the top of each new attempt * says "the previous attempt's terminal was not the run's final word" — so the * backstop can still emit exactly one honest terminal after fallover exhausts. */ export declare function clearRunTerminal(runId: string): void; export declare function resetKoiRunContextForTest(): void; export declare function emitKoiEvent(event: Omit): void; export declare function onKoiEvent(listener: (evt: KoiEventPayload) => void): () => boolean;