import type { AgentMessage, ThinkingLevel } from '@earendil-works/pi-agent-core'; import type { InMemoryTranscriptRuntime } from '../../agent/embedded/transcript-runtime.js'; import { type ExternalSessionBinding } from '../../agent/external/index.js'; import type { SessionAgentConfig } from '../../session/config-types.js'; import type { TranscriptStoredRow } from '../../session/session-context-for-llm.js'; import type { SessionMetadata } from '../../session/types.js'; import type { CreateSideChatInput, SideChatConfig, SideChatStatus, SideChatView } from './types.js'; export interface SideChatExternalBindingState { agentId: string; binding: ExternalSessionBinding; syncedRowCount: number; } export interface SideChatPromotionSnapshot { id: string; parentMetadata: SessionMetadata; parentConfig: SessionAgentConfig | null; context: SideChatView['context']; config: SideChatConfig; contextMessages: AgentMessage[]; conversationRows: TranscriptStoredRow[]; externalBinding?: SideChatExternalBindingState; } export interface SideChatExecutionSnapshot { id: string; parentConversationId: string; runtime: InMemoryTranscriptRuntime; parentMetadata: SessionMetadata; parentConfig: SessionAgentConfig | null; workspacePath: string; config: SideChatConfig; externalBinding?: SideChatExternalBindingState; } export declare class SideChatError extends Error { readonly code: 'INVALID_REQUEST' | 'NOT_FOUND' | 'PARENT_NOT_FOUND' | 'LIMIT_REACHED' | 'CAPACITY_REACHED' | 'CONFLICT' | 'EXPIRED'; readonly reason?: "idle" | "waiting" | undefined; constructor(message: string, code: 'INVALID_REQUEST' | 'NOT_FOUND' | 'PARENT_NOT_FOUND' | 'LIMIT_REACHED' | 'CAPACITY_REACHED' | 'CONFLICT' | 'EXPIRED', reason?: "idle" | "waiting" | undefined); } export interface EphemeralSideChatManagerOptions { getParentMetadata: (conversationId: string) => Promise; getParentConfig?: (conversationId: string) => Promise; loadParentMessages: (conversationId: string) => Promise; getDefaultModelRef: (conversationId: string) => string | Promise; getDefaultThinkingLevel?: (conversationId: string) => ThinkingLevel | Promise; getSessionModelRef?: (conversationId: string) => string; getSessionThinkingLevel?: (conversationId: string) => ThinkingLevel; getWorkspacePath: (metadata: SessionMetadata) => string; idleTtlMs?: number; maxPerClient?: number; maxTotal?: number; now?: () => number; startSweepTimer?: boolean; onBeforeDispose?: (sideChatId: string, clientInstanceId: string, messages: AgentMessage[]) => void | Promise; onExpired?: (sideChatId: string, clientInstanceId: string, reason: 'idle' | 'waiting') => void; } export declare class EphemeralSideChatManager { private readonly options; private readonly entries; private readonly reservations; private readonly expired; private readonly disposals; private stopped; private readonly now; private readonly idleTtlMs; private readonly maxPerClient; private readonly maxTotal; private readonly sweepTimer; constructor(options: EphemeralSideChatManagerOptions); create(input: CreateSideChatInput): Promise; private createEntry; get(id: string, clientInstanceId: string): SideChatView; getRuntime(id: string, clientInstanceId: string): InMemoryTranscriptRuntime; getExecutionSnapshot(id: string, clientInstanceId: string): SideChatExecutionSnapshot; setExternalBinding(id: string, clientInstanceId: string, state: SideChatExternalBindingState | undefined): void; getMessages(id: string, clientInstanceId: string): AgentMessage[]; beginPromotion(id: string, clientInstanceId: string): SideChatPromotionSnapshot; cancelPromotion(id: string, clientInstanceId: string): void; updateConfig(id: string, clientInstanceId: string, patch: Partial> & { serviceTier?: string | null; }): SideChatView; patchConfig(id: string, clientInstanceId: string, patch: { agentId?: string; modelRef?: string; thinkingLevel?: ThinkingLevel; serviceTier?: string | null; }): Promise; heartbeat(id: string, clientInstanceId: string): SideChatView; extend(id: string, clientInstanceId: string): SideChatView; setStatus(id: string, clientInstanceId: string, status: SideChatStatus, runId?: string): SideChatView; waitForInput(id: string, clientInstanceId: string, clarification: NonNullable, status?: 'waiting-input' | 'waiting-approval'): void; dispose(id: string, clientInstanceId: string): Promise; disposePromoted(id: string, clientInstanceId: string): Promise; private disposeEntry; disposeClient(clientInstanceId: string): Promise; sweepExpired(at?: number): Promise; disposeAll(): Promise; private requireEntry; private isExpired; private expireEntry; private pruneExpiredRecords; private toView; private touchEntry; private runBeforeDispose; } export declare function parseThinkingLevel(value: unknown): ThinkingLevel | undefined;