import type { ChatKitStore, ClientToolContinuationClaim, StoreContext } from '../chatkit/store'; import type { ClientEffect, ThreadItem, ThreadMetadata, ThreadRef, UserMessageItem } from '../chatkit/types'; import { type AgentRuntimeConfig } from './AgentRuntimeTypes'; import type { RunContextRetriever, RunExecutionBackend } from './RunExecutionBackend'; export type RunStateEvent = { type: 'item_added'; item: ThreadItem; } | { type: 'item_updated'; itemId: string; delta: string; } | { type: 'item_done'; item: ThreadItem; } | { type: 'client_effect'; effect: ClientEffect; } | { type: 'error'; code: string; message: string; }; export interface RunStateCenterOptions { store: ChatKitStore; enableAgentRuntime?: boolean; executionBackend?: RunExecutionBackend; contextRetriever?: RunContextRetriever; } export interface PreparedClientToolOutput { claim: ClientToolContinuationClaim; output: string; } /** * Run is the xpod-side state center for Agent execution. * * ChatKit and Task APIs are command surfaces. They hand execution to this * center, which persists first-class Run/RunStep facts through the configured * RunStore while projecting visible output back to Thread/Message. */ export declare class RunStateCenter { private readonly store; private readonly runStore?; private readonly enableAgentRuntime; private readonly executionBackend; private readonly contextRetriever?; constructor(options: RunStateCenterOptions); getAgentRuntimeConfig(thread: ThreadMetadata, context?: TContext): AgentRuntimeConfig | null; getDefaultAgentRuntimeConfig(context: TContext): AgentRuntimeConfig | null; private resolveRunnerProtocol; private resolveWorkspaceRef; startAgentRun(input: { thread: ThreadMetadata; userMessage: UserMessageItem; context: TContext; runtimeConfig: AgentRuntimeConfig; }): AsyncIterable; private retrieveRunContext; prepareClientToolOutput(input: { threadRef: ThreadRef; itemId: string; output: string; context: TContext; }): Promise; releaseClientToolOutput(prepared: PreparedClientToolOutput, context: TContext): Promise; completeClientToolOutput(input: { threadRef: ThreadRef; itemId: string; output: string; context: TContext; }): AsyncIterable; completePreparedClientToolOutput(prepared: PreparedClientToolOutput, context: TContext): AsyncIterable; private resolveRunStore; private createRun; private markRunStarted; private finishRun; private pauseRun; private projectRuntimeEvent; private checkCancellation; private stepTypeForTerminalStatus; private saveRun; private appendRunStep; private resolveThreadResource; private resolveRunResource; private resolveWaitingRunForToolOutput; private extractThreadIdFromRef; private threadCandidatesForRunLookup; private extractBaseRelativeThreadId; private buildContinuationPrompt; private resolveRuntimeConfigForContinuation; private isRunnerType; private resolveThreadStorageParent; private resolvePodBaseUrl; private createAssistantMessage; private finalizeAssistantMessage; private threadRefFromThread; private loadConversation; }