/** Session directory IO exposed to the picker, /delete, and /export. * * The kernel persistence seam has NO deletion API by design — logs accumulate * "until removed externally" — so removal is planned, layout-checked, and * lease-guarded here before any file is touched. Every read goes through the * in-process session-query engine, so this module stays free of `app.ts` and * of the Ink tree. * * @module @deepseek-ai/dsh-code/runner/session-io */ import { type SessionDeletionPersistence, type SessionDirectoryOptions, type SessionQueryService, type SessionRow } from '../session/session-directory.ts'; /** * The persistence surface this module needs: the JSONL backend's public * session root plus its per-session write handles. Typing the narrow shape * instead of the upstream service keeps the IO injectable from a test double. */ export interface SessionIoPersistence extends SessionDeletionPersistence { /** JSONL backend plugin config carrying the session root, when exposed. */ readonly config?: { readonly root?: unknown; }; } /** Services the session IO closes over. */ export interface SessionIoServices { /** In-process session-query engine; absent in profiles without one. */ readonly sessionQuery?: SessionQueryService; /** The durable persistence service; absent in profiles without one. */ readonly persistence?: SessionIoPersistence; /** The session currently visible in the UI (self-deletion guard). */ readonly activeSessionId: () => string | undefined; } /** Session directory reads and the guarded /delete operation. */ export interface SessionIo { /** Project the session directory for the picker (query-filtered). */ readonly loadSessions: (options: SessionDirectoryOptions, signal?: AbortSignal) => Promise; /** Delete one session subtree, returning the outcome line. */ readonly deleteSession: (id: string) => Promise; /** Render one session's whole transcript as export Markdown. */ readonly loadSessionTranscript: (id: string, signal?: AbortSignal) => Promise; } /** Maximum session artifact directories inspected at once by the picker. */ export declare const SESSION_ARTIFACT_READ_CONCURRENCY = 16; /** * Map a collection with a fixed worker count while preserving input order. * The picker may own thousands of persisted sessions; an unbounded * `Promise.all` turns those into one filesystem burst and can exhaust handles * on Windows or remote filesystems. * * @internal Exported for the deterministic concurrency regression. */ export declare function mapConcurrent(items: readonly T[], concurrency: number, mapper: (item: T, index: number) => Promise): Promise; /** * Bind the session IO to one runner's services. * @param services - the query engine, persistence, and the live-session probe. * @returns the picker/delete/export reads used by the app bridge. */ export declare function createSessionIo(services: SessionIoServices): SessionIo;