/** * Slim event bridge: maps AgentDriver events to rendered console lines. * No React, no ink, no UI state — just event → string → callback. */ import type { SessionState } from "@skaile/workspaces"; import type { AgentSession } from "@skaile/workspaces/runner"; import type { TelemetryLogEntry } from "./telemetry.js"; /** * Handle returned by {@link createReplSession} for controlling an active REPL session. * * `state` reflects the current lifecycle state (`idle`, `active`, or `stopped`). * Call `send(text)` to forward a user message to the agent driver; the state * transitions to `active` until the driver emits `agent_end`. Call `stop()` to * terminate the driver and dispose of the underlying agent session. * * @docLink packages/tui/concepts#repl-session */ export interface ReplSessionHandle { readonly state: SessionState; send(text: string): void; stop(): void; } /** * Options for {@link createReplSession}. * * @param session - The agent session returned by `createAgentSession`. * @param onLine - Callback invoked with an ANSI-rendered string for each output line. * @param onLog - Callback invoked with a log string for each telemetry event (if verbose). * @param onStateChange - Callback invoked whenever the session state changes. * * @docLink packages/tui/concepts#repl-session */ export interface CreateReplSessionOpts { session: AgentSession; onLine?: (line: string) => void; onLog?: (line: string) => void; onStateChange?: (state: SessionState) => void; } /** * Create a slim event bridge that maps `AgentEvent` stream to rendered console lines. * * Subscribes to `agent-event` on the session driver and converts each event type * (`message_update`, `tool_call`, `error`, `agent_end`, `turn_end`, `subagent`) to * an `OutputLine`, renders it via {@link renderLine}, and forwards the string to * `opts.onLine`. Text content is buffered internally and flushed line-by-line as * newlines arrive. Returns a {@link ReplSessionHandle} for sending messages and * stopping the session. * * @param opts - Session, output callbacks, and state-change hook. * @returns Handle for sending messages and observing session state. * * @docLink packages/tui/concepts#repl-session */ export declare function createReplSession(opts: CreateReplSessionOpts): ReplSessionHandle; /** * Create a telemetry sink that pipes {@link TelemetryLogEntry} events to the log callback. * * Wraps {@link renderLog} so that only displayable entries (generation, span_end for * tool/turn, trace lifecycle) are forwarded. Entries that `renderLog` returns `null` * for are silently suppressed. The returned function is used in `startRepl` to drain * buffered telemetry and to wire up live forwarding during the session. * * @param onLog - Callback invoked with an ANSI-rendered log string. * @returns A function that accepts a `TelemetryLogEntry` and routes it to `onLog`. * * @docLink packages/tui/concepts#repl-session */ export declare function createTelemetrySink(onLog: (line: string) => void): (entry: TelemetryLogEntry) => void; //# sourceMappingURL=repl-session.d.ts.map