import type { AdapterId, NativeSession } from "../adapters/types.js"; import { AdapterRegistry } from "../adapters/registry.js"; import { type GroupXConfig, type TransportMode } from "../config.js"; import { McpBindingRegistry } from "../mcp/binding-registry.js"; import type { GroupXStore, RuntimeRecoveryResult } from "../storage/types.js"; export type ManagedAgentId = string; export type SessionManagerState = "idle" | "starting" | "ready" | "closing" | "closed"; export interface SessionResumePlan { stale: RuntimeRecoveryResult; nativeSessionIds: Partial>; } export interface ManagedSessionSnapshot { agentId: ManagedAgentId; actorId: string; adapterId: AdapterId; instanceId: string; bindingId: string; nativeSessionId?: string; protocol: string; transport: TransportMode; } export interface RestartSessionResult { actorId: string; previousInstanceId?: string; session: NativeSession; } export interface SessionManagerOptions { config: Pick; store: GroupXStore; adapters: AdapterRegistry; mcpBindings?: McpBindingRegistry; idFactory?: (kind: "instance" | "binding", agentId: ManagedAgentId) => string; protocolFor?: (agentId: ManagedAgentId, transport: TransportMode) => string; closeTimeoutMs?: number; /** Total attempts for transient native start/resume failures. */ startAttempts?: number; retryBaseMs?: number; onProgress?: (progress: SessionProgress) => void | Promise; } export type SessionProgress = { phase: "starting"; agentId: string; actorId: string; attempt: number; maxAttempts: number; continuity: "new_session" | "resume"; } | { phase: "retrying"; agentId: string; actorId: string; attempt: number; maxAttempts: number; continuity: "new_session" | "resume"; nextDelayMs: number; errorCode: string; } | { phase: "ready"; agentId: string; actorId: string; attempt: number; maxAttempts: number; continuity: "new_session" | "resumed" | "new_session_after_resume_failure"; } | { phase: "failed"; agentId: string; actorId: string; attempt: number; maxAttempts: number; continuity: "new_session" | "resume"; errorCode: string; }; /** Owns one selected-transport runtime session for each enabled configured Agent. */ export declare class AgentSessionManager { #private; constructor(options: SessionManagerOptions); get state(): SessionManagerState; get transport(): TransportMode; setStructuredMcpUrl(url: string): void; /** * Close stale process records and derive a bounded same-transport/same-cwd * native resume plan. The cwd capability is a continuity snapshot, not a * credential or security check. */ prepareRecovery(): SessionResumePlan; startAll(input?: { nativeSessionIds?: Partial>; }): Promise; resolve(input: { actorId: string; adapterId: AdapterId; }): NativeSession; get(actorId: string): NativeSession | undefined; list(): ManagedSessionSnapshot[]; /** Persist a native session id learned during a Direct (or late structured) turn. */ syncNativeSession(bindingId: string): void; restart(actorId: string): Promise; close(): Promise; } //# sourceMappingURL=session-manager.d.ts.map