import type * as LlmsProviders from "@cline/llms"; import type { AgentMode, AgentResult, RuntimeConfigExtensionKind } from "@cline/shared"; import type { HookEventPayload } from "../../hooks"; import type { CheckpointEntry } from "../../hooks/checkpoint-hooks"; import type { ProviderSettings } from "../../services/llms/provider-settings"; import type { SessionCompactionState } from "../../session/models/session-compaction"; import type { SessionManifest } from "../../session/models/session-manifest"; import type { SessionSource } from "../../types/common"; import type { CoreSessionConfig } from "../../types/config"; import type { CoreSessionEvent, SessionPendingPrompt } from "../../types/events"; import type { SessionRecord } from "../../types/sessions"; import type { RuntimeCapabilities } from "../capabilities"; import type { ConnectionUpdate } from "../config/connection-update"; export declare const SESSION_NOT_FOUND_ERROR_CODE = "session_not_found"; export declare class SessionNotFoundError extends Error { readonly sessionId?: string | undefined; readonly code = "session_not_found"; constructor(sessionId?: string | undefined, message?: string); } export declare function isSessionNotFoundError(error: unknown): error is SessionNotFoundError; type LocalOnlyCoreSessionConfigKeys = "hooks" | "logger" | "telemetry" | "extensionContext" | "extraTools" | "extensions" | "onTeamEvent" | "onConsecutiveMistakeLimitReached"; export type RuntimeSessionConfig = Omit & { checkpoint?: Omit, "createCheckpoint">; compaction?: Omit, "compact">; }; export type LocalRuntimeBootstrapConfig = Pick & { checkpoint?: Pick, "createCheckpoint"> & Partial>; compaction?: Pick, "compact"> & Partial>; }; export interface LocalRuntimeStartOptions { hooks?: LocalRuntimeBootstrapConfig["hooks"]; logger?: LocalRuntimeBootstrapConfig["logger"]; telemetry?: LocalRuntimeBootstrapConfig["telemetry"]; extensionContext?: LocalRuntimeBootstrapConfig["extensionContext"]; extraTools?: LocalRuntimeBootstrapConfig["extraTools"]; extensions?: LocalRuntimeBootstrapConfig["extensions"]; onTeamEvent?: LocalRuntimeBootstrapConfig["onTeamEvent"]; onConsecutiveMistakeLimitReached?: LocalRuntimeBootstrapConfig["onConsecutiveMistakeLimitReached"]; checkpoint?: LocalRuntimeBootstrapConfig["checkpoint"]; compaction?: LocalRuntimeBootstrapConfig["compaction"]; modelCatalogDefaults?: Partial>; userInstructionService?: import("../../extensions/config").UserInstructionConfigService; configExtensions?: RuntimeConfigExtensionKind[]; onTeamRestored?: () => void; } export interface StartSessionInput { config: RuntimeSessionConfig; source?: SessionSource; prompt?: string; interactive?: boolean; sessionMetadata?: Record; initialMessages?: LlmsProviders.Message[]; initialCompactionState?: SessionCompactionState; userImages?: string[]; userFiles?: string[]; /** * Host-local bootstrap options. These are intentionally isolated from the * transport-neutral runtime session config so all runtime hosts share the * same execution contract while still allowing host-specific preparation. */ localRuntime?: LocalRuntimeStartOptions; capabilities?: RuntimeCapabilities; toolPolicies?: import("@cline/shared").AgentConfig["toolPolicies"]; } export declare function splitCoreSessionConfig(config: CoreSessionConfig): { config: RuntimeSessionConfig; localRuntime?: LocalRuntimeStartOptions; }; export interface StartSessionResult { sessionId: string; manifest: SessionManifest; manifestPath: string; messagesPath: string; result?: AgentResult; } export interface SendSessionInput { sessionId: string; prompt: string; mode?: AgentMode; userImages?: string[]; userFiles?: string[]; delivery?: "queue" | "steer"; timeoutMs?: number; } export interface SessionAccumulatedUsage { inputTokens: number; outputTokens: number; cacheReadTokens: number; cacheWriteTokens: number; totalCost: number; } export interface SessionUsageSummary { usage?: SessionAccumulatedUsage; aggregateUsage?: SessionAccumulatedUsage; } export interface PendingPromptMutationResult { sessionId: string; prompts: SessionPendingPrompt[]; prompt?: SessionPendingPrompt; updated?: boolean; removed?: boolean; } export interface PendingPromptsListInput { sessionId: string; } export interface PendingPromptsUpdateInput { sessionId: string; promptId: string; prompt?: string; mode?: AgentMode; delivery?: "queue" | "steer"; } export interface PendingPromptsDeleteInput { sessionId: string; promptId: string; } export interface PendingPromptsServiceApi { list(input: PendingPromptsListInput): Promise; update(input: PendingPromptsUpdateInput): Promise; delete(input: PendingPromptsDeleteInput): Promise; } export interface PendingPromptsRuntimeService { readonly pendingPrompts: PendingPromptsServiceApi; } export interface SessionUsageRuntimeService { getAccumulatedUsage(sessionId: string): Promise; } export type SessionConnectionUpdate = ConnectionUpdate; export interface SessionModelRuntimeService { updateSessionModel(sessionId: string, modelId: string): Promise; } export interface SessionConnectionRuntimeService { updateSessionConnection(sessionId: string, updates: SessionConnectionUpdate): Promise; } export interface RuntimeHostSubscribeOptions { sessionId?: string; } export interface RestoreSessionInput { sessionId: string; checkpointRunCount: number; cwd?: string; restore?: { messages?: boolean; workspace?: boolean; omitCheckpointMessageFromSession?: boolean; }; start?: StartSessionInput; } export interface RestoreSessionResult { sessionId?: string; startResult?: StartSessionResult; messages?: LlmsProviders.Message[]; checkpoint: CheckpointEntry; } /** * RuntimeHost is the transport/runtime boundary for core session execution. * Callers must normalize broad local config into `RuntimeSessionConfig` * plus optional named `localRuntime` bootstrap fields before invoking a host. */ export interface RuntimeHost { readonly runtimeAddress?: string; startSession(input: StartSessionInput): Promise; runTurn(input: SendSessionInput): Promise; restoreSession(input: RestoreSessionInput): Promise; abort(sessionId: string, reason?: unknown): Promise; stopSession(sessionId: string): Promise; dispose(reason?: string): Promise; getSession(sessionId: string): Promise; listSessions(limit?: number): Promise; deleteSession(sessionId: string): Promise; updateSession(sessionId: string, updates: { prompt?: string | null; metadata?: Record | null; title?: string | null; }): Promise<{ updated: boolean; }>; updateSessionCompactionState(sessionId: string, state: SessionCompactionState): Promise<{ updated: boolean; }>; readSessionCompactionState(sessionId: string): Promise; readSessionMessages(sessionId: string): Promise; dispatchHookEvent(payload: HookEventPayload): Promise; subscribe(listener: (event: CoreSessionEvent) => void, options?: RuntimeHostSubscribeOptions): () => void; } export type RuntimeHostMode = "auto" | "local" | "hub" | "remote"; export {};