import { type ChatHistoryEntry } from './chat-process-manager.js'; import { type ChatMode, type ChatRuntimeId, type ChatStreamEvent } from './chat-runtime-adapters.js'; /** * Appends a synthetic `file_changes` event whenever `events` contains the * `tool_result` for a previously-seen file-writing `tool_call` — i.e. once the * write has actually completed, not merely been requested by the model. * `pendingFileWrites` is the caller's per-turn tool_call-id -> file-path map; * mutated in place so state persists across calls for the same turn (one * `tool_call`/`tool_result` pair usually arrives on different stdout lines). * * The frontend already has full wiring for this — ChatContext.tsx listens for * the SSE `file_changes` event and dispatches the `workspace-files-changed` * window event, which FileTree.tsx (and the @-mention list, diagrams page) * already listen for to quietly re-scan — this was the one missing link: * nothing on the backend ever emitted `file_changes` during a live turn, so * the file explorer only ever caught an agent's write on the next manual * Sync click. */ export declare function withFileChangeEvents(events: ChatStreamEvent[], pendingFileWrites: Map): ChatStreamEvent[]; export type ChatSessionStartInput = { sessionId: string; message: string; workspace: string; runtime: ChatRuntimeId; context?: string; model?: string; chatMode?: ChatMode; images?: Array; conversationId?: string; }; export type ChatSessionStreamInput = { sessionId: string; write: (event: string, data: string) => Promise; onAbort: (callback: () => void) => void; }; export declare class ChatSessionDriverError extends Error { readonly status: number; constructor(message: string, status?: number); } export type ChatSessionDriver = { id: ChatRuntimeId; start(input: ChatSessionStartInput): Promise | void; hasSession(sessionId: string): boolean; stream(input: ChatSessionStreamInput): Promise; getHistory(sessionId: string): ChatHistoryEntry[] | undefined; end(sessionId: string): boolean; stop(sessionId: string): boolean; }; export declare function registerChatSessionDriver(driver: ChatSessionDriver): void; export declare function getChatSessionDriver(runtime: ChatRuntimeId): ChatSessionDriver; export declare function getChatSessionDriverForSession(sessionId: string): ChatSessionDriver | undefined; export declare function listChatSessionDrivers(): ChatSessionDriver[]; export type TurnResult = { exitCode: number | null; stderr: string; aborted: boolean; }; /** * Decide whether a failed turn should trigger reactive context-overflow recovery: * a non-aborted, non-zero exit that produced no output, was not a user stop, and * whose stderr matches a "prompt too long" signal. */ export declare function shouldAttemptReactiveCompaction(sessionId: string, result: TurnResult, outputBuffer: string): boolean; /** * True when CLI stderr signals that a `--resume ` target no * longer exists — the transcript was pruned, deleted, or belongs to a session * the CLI's own retention has since removed. Deliberately permissive, same * rationale as isContextOverflowError: prefer a harmless extra fallback respawn * over missing a real "session gone" failure and surfacing a dead error. */ export declare function isResumeTargetLostError(text: string | null | undefined): boolean; /** * Decide whether a failed resume should retry via history-replay: a non-aborted, * non-zero exit that produced no output, was not a user stop, and whose stderr * matches a "resume target lost" signal. */ export declare function shouldAttemptResumeFallback(sessionId: string, result: TurnResult, outputBuffer: string): boolean;