import type { AgentSession } from '@earendil-works/pi-coding-agent'; import type { ImageContent } from '@earendil-works/pi-ai'; import type { AgentMessage } from '@earendil-works/pi-agent-core'; import { type TranscriptUserMessage } from '../inbound/attachment-pipeline.js'; export type EmbeddedSteerOptions = { images?: ImageContent[]; transcriptMessage?: TranscriptUserMessage; voiceAgentInstruction?: boolean; onHandled?: () => void; }; export type EmbeddedRunIdentity = { conversationId: string; transcriptId: string; runId: string; }; export type EmbeddedRunHandle = EmbeddedRunIdentity & { session: AgentSession; abort: () => Promise; }; export declare class EmbeddedRunConflictError extends Error { readonly conversationId: string; readonly activeRunId: string; constructor(conversationId: string, activeRunId: string); } export type EmbeddedRunLease = { signal: AbortSignal; prepareCommandWaits(): void; attach(session: AgentSession, abort: () => Promise): Promise; release(): void; }; export type EmbeddedRunCancellation = { signal: AbortSignal; release(): void; }; /** Owns one process-local execution lease per session while leaving steer/abort on the control plane. */ export declare class EmbeddedRunRegistry { private readonly byConversationId; private readonly prepared; reserveCancellation(identity: Pick): EmbeddedRunCancellation; acquire(identity: EmbeddedRunIdentity): EmbeddedRunLease; getByConversationId(conversationId: string): EmbeddedRunHandle | undefined; getCommandYieldSignal(conversationId: string, runId: string): AbortSignal | undefined; isActive(conversationId: string): boolean; abortByConversationId(conversationId: string, reason?: 'user_cancelled' | 'parent_cancelled', expectedRunId?: string): Promise; steerByConversationId(conversationId: string, text: string, expectedRunId?: string, options?: EmbeddedSteerOptions): Promise; restoreSteeringImages(conversationId: string, runId: string, messages: AgentMessage[]): AgentMessage[]; size(): number; } export declare function getEmbeddedCommandYieldSignal(): AbortSignal | undefined; export declare function restoreEmbeddedSteeringImages(conversationId: string, runId: string, messages: AgentMessage[]): AgentMessage[]; export declare function acquireEmbeddedRunLease(identity: EmbeddedRunIdentity): EmbeddedRunLease; export declare function reserveEmbeddedRunCancellation(identity: Pick): EmbeddedRunCancellation; export declare function getEmbeddedRunByConversationId(conversationId: string): EmbeddedRunHandle | undefined; export declare function isEmbeddedRunActive(conversationId: string): boolean; export declare function abortEmbeddedRun(conversationId: string, reason?: 'user_cancelled' | 'parent_cancelled', expectedRunId?: string): Promise; export declare function queueEmbeddedSteer(conversationId: string, text: string, expectedRunId?: string, options?: EmbeddedSteerOptions): Promise;