/** * Session registry (postmaster) — register, deregister, and discover sessions. * Spec: §4.6 — Session Registry */ import type { Labels } from "@pi-orca/core"; export interface SessionEntry { sessionId: string; sessionPath: string; sessionName?: string; pid: number; registeredAt: string; agentTemplate?: string; labels?: Labels; } export interface RegisterSessionParams { sessionId: string; sessionPath: string; sessionName?: string; pid: number; agentTemplate?: string; labels?: Labels; projectSlug?: string; } /** * Load the session registry from disk. * * @param projectSlug - Optional project slug * @returns Array of session entries (empty if registry missing) */ export declare function loadRegistry(projectSlug?: string): Promise; /** * Save the session registry to disk. * * @param entries - Session entries to save * @param projectSlug - Optional project slug */ export declare function saveRegistry(entries: SessionEntry[], projectSlug?: string): Promise; /** * Register a session in the registry. * * Loads existing entries, checks for duplicates, appends if new, saves. * * @param params - Registration parameters */ export declare function registerSession(params: RegisterSessionParams): Promise; /** * Deregister a session from the registry. * * @param sessionId - Session ID to remove * @param projectSlug - Optional project slug */ export declare function deregisterSession(sessionId: string, projectSlug?: string): Promise; /** * Clean up dead sessions from the registry. * * Checks PID liveness for all entries. For SDK agents (those with * agentTemplate set), also checks heartbeat staleness against * polling.stuckThresholdSeconds (120s default). * * @param projectSlug - Optional project slug */ export declare function cleanupRegistry(projectSlug?: string): Promise; /** * List sessions with optional label filter. * * Runs cleanup first, then applies label filter. * * @param labelFilter - Optional label filter * @param projectSlug - Optional project slug * @returns Filtered session entries */ export declare function listSessions(labelFilter?: Labels, projectSlug?: string): Promise; /** * Refresh the current session's registry entry from a live `ctx.sessionManager`. * * The registry's `sessionName` is otherwise only updated by the idle poller, * which means a rename via `/name` won't be visible to other readers (like * the `/messages` sessions overlay) until the next poll tick. Call this * before any operation that reads the registry on behalf of the user, so * fresh names show up immediately. * * No-op if `ctx.sessionManager` is missing, the registry doesn't have an * entry for this session yet (the session_start handler hasn't run), or the * recorded name already matches. */ export declare function refreshOwnSessionName(ctx: any, projectSlug?: string): Promise; /** * Resolution result for a session lookup. * * `kind: "ok"` means we matched exactly one session; the entry is included * (may be a stub if matched via the `SessionManager.listAll()` fallback for a * session that isn't currently registered). * * `kind: "ambiguous"` means the input matched multiple candidates — caller * should disambiguate (typically by surfacing the candidate list to the user). * * `kind: "not_found"` means no match. */ export type SessionResolution = { kind: "ok"; entry: SessionEntry; } | { kind: "ambiguous"; candidates: SessionEntry[]; } | { kind: "not_found"; }; /** * Resolve a user-supplied session reference to a registered session entry. * * Resolution order (first match wins): * 1. Exact session-id match. * 2. Exact session-name match. * 3. Unique session-id prefix match. * 4. Unique session-name prefix match (case-insensitive). * * Ambiguous prefix matches return `kind: "ambiguous"`; no match returns * `kind: "not_found"`. * * Note: this only consults the project-local registry. Sessions on disk that * are not currently registered (e.g. inactive sessions in another project) * are not considered — the messages extension only delivers to registered * recipients. */ export declare function resolveSession(input: string, projectSlug?: string): Promise; //# sourceMappingURL=postmaster.d.ts.map