/** * Agim Agent (pi JSONL) session quarantine / retention. * * Agim's sticky routing lives in `~/.agim/sessions/*.json`, while the Agim * Agent conversation truth lives under `~/.agim/agim-sessions/` (JsonlSessionRepo). * `/new`, `switchAgent`, and META TTL mint a new `session.id` without touching * the old JSONL — orphans accumulate with prompts/tool I/O. * * Strategy (milestone C subset): * 1. Rename retired JSONL into `~/.agim/agim-session-quarantine/` (OUTSIDE * sessionsRoot so JsonlSessionRepo.list() never resurrects them). * 2. Wait for adapter sessionLocks to drain before moving (busy → deferred). * 3. Invalidate sessionMeta cache so a stale path cannot be reopened. * 4. Periodically sweep quarantine files older than the grace window. * 5. Boot inventory: quarantine JSONL ids with no matching Agim session meta. * * Env: * AGIM_AGENT_SESSION_QUARANTINE=off|on|inventory (default on) * AGIM_AGENT_SESSION_QUARANTINE_DAYS (default 7) * AGIM_AGENT_SESSION_RETENTION_SWEEP_MS (default 6h; 0 disables) * AGIM_AGENT_SESSION_RETIRE_WAIT_MS (default 30s busy wait) */ export type RetireReason = 'new' | 'switch' | 'meta_ttl' | 'orphan' | 'manual'; export type RetireResult = 'quarantined' | 'deferred' | 'skipped' | 'missing' | 'disabled'; export interface AgimAgentSessionHooks { isBusy?: (sessionId: string) => boolean; invalidateCache?: (sessionId: string) => void; } export interface LifecycleConfig { sessionsRoot: string; quarantineRoot: string; mode: 'off' | 'on' | 'inventory'; quarantineDays: number; sweepIntervalMs: number; retireWaitMs: number; retirePollMs: number; } export declare function resolveAgimAgentSessionsRoot(home?: string): string; export declare function resolveAgimAgentQuarantineRoot(home?: string): string; export declare function getAgimAgentSessionLifecycleConfig(): LifecycleConfig; /** Test / factory wiring. Pass `null` fields via override object only. */ export declare function configureAgimAgentSessionLifecycle(opts: { sessionsRoot?: string; quarantineRoot?: string; mode?: LifecycleConfig['mode']; quarantineDays?: number; sweepIntervalMs?: number; retireWaitMs?: number; retirePollMs?: number; hooks?: AgimAgentSessionHooks; }): void; /** Reset module state (unit tests). */ export declare function resetAgimAgentSessionLifecycleForTests(): void; /** Find active JSONL paths whose filename encodes `_${sessionId}.jsonl`. */ export declare function findActiveAgimAgentSessionFiles(sessionsRoot: string, sessionId: string): string[]; /** Collect session ids still referenced by Agim meta files on disk. */ export declare function listKnownAgimSessionIdsFromDisk(home?: string): Set; /** List every active JSONL session id under sessionsRoot (one-level walk). */ export declare function listActiveAgimAgentSessionIds(sessionsRoot: string): Map; /** * Retire one Agim Agent JSONL session into quarantine. * Safe to call fire-and-forget from `/new` / switch / META TTL. */ export declare function retireAgimAgentSession(sessionId: string, reason: RetireReason, opts?: { waitForIdle?: boolean; }): Promise; /** Fire-and-forget retire used by session manager /new and switch. */ export declare function scheduleRetireAgimAgentSession(sessionId: string | undefined, reason: RetireReason): void; export declare function sweepQuarantinedSessions(now?: number): Promise<{ deleted: number; }>; export declare function inventoryAndQuarantineOrphans(opts?: { dryRun?: boolean; knownSessionIds?: Iterable; home?: string; }): Promise<{ active: number; orphan: number; quarantined: number; }>; export declare function startAgimAgentSessionRetention(opts?: { runBootInventory?: boolean; knownSessionIds?: Iterable; }): void; export declare function stopAgimAgentSessionRetention(): void; //# sourceMappingURL=agim-agent-session-lifecycle.d.ts.map