/** * Persistence interfaces for `SessionManager` / `EpisodeManager`. * * The core-facing shape is intentionally thinner than the raw repositories * in `core/storage/repos/` — just the operations the session layer needs, * with session-friendly signatures. Tests inject in-memory fakes that * implement these interfaces without touching SQLite. * * The concrete `makeStorageBackedAdapters(...)` wires the real repos. */ import type { AgentKind, EpisodeId, SessionId } from "../../agent-contract/dto.js"; import type { makeEpisodesRepo, makeSessionsRepo } from "../storage/repos/index.js"; import type { EpochMs } from "../types.js"; export interface SessionRepo { upsertIfMissing(row: { id: SessionId; agent: AgentKind; ownerAgentKind?: AgentKind; ownerProfileId?: string; ownerWorkspaceId?: string | null; startedAt: EpochMs; lastSeenAt: EpochMs; meta: Record; }): void; touchLastSeen(id: SessionId, ts: EpochMs, metaPatch?: Record): void; getById(id: SessionId): { id: SessionId; agent: AgentKind; ownerAgentKind?: AgentKind; ownerProfileId?: string; ownerWorkspaceId?: string | null; startedAt: EpochMs; lastSeenAt: EpochMs; meta: Record; } | null; listRecent(limit?: number): Array<{ id: SessionId; agent: AgentKind; ownerAgentKind?: AgentKind; ownerProfileId?: string; ownerWorkspaceId?: string | null; startedAt: EpochMs; lastSeenAt: EpochMs; meta: Record; }>; deleteOlderThan(cutoffMs: EpochMs): number; } export interface EpisodesRepo { insert(row: { id: EpisodeId; sessionId: SessionId; ownerAgentKind?: AgentKind; ownerProfileId?: string; ownerWorkspaceId?: string | null; startedAt: EpochMs; endedAt: EpochMs | null; traceIds: string[]; rTask: number | null; status: "open" | "closed"; meta: Record; }): void; updateTraceIds(id: EpisodeId, traceIds: string[]): void; updateMeta(id: EpisodeId, metaPatch: Record): void; deleteById(id: EpisodeId): void; close(id: EpisodeId, endedAt: EpochMs, rTask?: number, meta?: Record): void; /** * Flip a closed episode back to `open` — V7 §0.1 "revision" path. * Idempotent for already-open episodes. */ reopen(id: EpisodeId, meta?: Record): void; getById(id: EpisodeId): unknown | null; getOpenForSession(sessionId: SessionId): unknown | null; } type SqliteSessions = ReturnType; type SqliteEpisodes = ReturnType; export declare function adaptSessionsRepo(sqlite: SqliteSessions): SessionRepo; export declare function adaptEpisodesRepo(sqlite: SqliteEpisodes): EpisodesRepo; export {}; //# sourceMappingURL=persistence.d.ts.map