import { type SessionLocator, SessionPaths } from '../../session/paths.js'; import { InMemorySessionTokenBudgetStore, type SessionTokenBudgetStore } from '../../store/budget/index.js'; import { type CheckpointLogView, InMemorySessionCheckpointStore, type SessionCheckpointStore } from '../../store/checkpoint/index.js'; import { InMemorySessionLog, type SessionLog } from '../../store/session-log/index.js'; import type { ChildSessionStorage } from '../../types/agent/task.js'; import type { SessionId } from '../../types/ids/index.js'; /** What an in-memory session keeps beside its log. */ interface HeldState { readonly checkpoints: InMemorySessionCheckpointStore; readonly tokenBudgets: InMemorySessionTokenBudgetStore; } /** Where one session's log, checkpoints, ledger and child sessions go. */ export interface SessionStorage { readonly log: SessionLog; /** The project layout, when the session is on disk. */ readonly paths: SessionPaths | undefined; /** `/`, beside the log, when the log is on disk. */ readonly sessionDir: string | undefined; readonly checkpoints: SessionCheckpointStore; /** Ledgers of root turns, keyed by (rootSessionId, rootTurnId). */ readonly tokenBudget: SessionTokenBudgetStore; /** What a delegated child session is told; `undefined` leaves it alone. */ readonly children: ChildSessionStorage | undefined; } export interface SessionStorageInput { readonly sessionId: SessionId; /** The delegating session, for a child session's default log location. */ readonly parentSessionId?: SessionId; readonly sessionLog?: SessionLog; readonly paths?: SessionPaths; readonly checkpointStore?: SessionCheckpointStore; readonly tokenBudgetStore?: SessionTokenBudgetStore; /** The directory the project slug is derived from when no `paths` is given. */ readonly workingDirectory?: string; } /** * The one answer to "where does this session's state live", read by every * place that opens a session log, a checkpoint store or a token ledger. * * - **Log.** An explicit `sessionLog` wins. Otherwise the log at `paths` * (default: `SessionPaths` under `resolveNamzuHome()` for the working * directory's project). * - **Checkpoints and ledger.** An explicit store wins. Otherwise a session * whose log is an {@link InMemorySessionLog} and which names no `paths` * keeps both in memory, beside its log; every other session keeps them on * disk under `/checkpoints/` and `/budgets/`. * - **Children.** An in-memory session hands that choice to its delegated * children, so a child does not fall back to a disk tree its parent never * asked for; a session on disk hands down its layout, so its children's * logs nest under its session directory. */ export declare function resolveSessionStorage(input: SessionStorageInput): Promise; /** * The locator of a session named without its log: a root session sits at the * top of the project; a child session sits under its parent, wherever the * parent is. The parent's own place is found on disk, so a grandchild nests * under every ancestor and not beside its parent at the top level. A parent * with no log in the layout yet is taken to be a root session. */ export declare function locateSession(paths: SessionPaths, sessionId: SessionId, parentSessionId?: SessionId): Promise; /** `SessionPaths` for the working directory's project under `resolveNamzuHome()`. */ export declare function defaultSessionPaths(workingDirectory?: string): Promise; /** * @internal What an in-memory session holds beside its log right now, for * tests that assert where its state went. */ export declare function heldSessionState(log: InMemorySessionLog): HeldState | undefined; /** * The checkpoint store's view of one session log: whether a checkpoint was * committed, whether the prefix it covers is intact, and which checkpoints * an open decision still references. */ export declare function checkpointLogView(log: SessionLog): CheckpointLogView; export {}; //# sourceMappingURL=session-storage.d.ts.map