import type { StoredSession } from '@opensip-cli/contracts'; import type { ToolShortId } from '@opensip-cli/core'; import type { DataStore } from '@opensip-cli/datastore'; /** * A reference to one stored session: an explicit `ref` id, or the sentinel * `'latest'` (which requires a `tool` to disambiguate across tools). * * `cwdWithin` scopes the `'latest'` SELECTION to sessions whose stored `cwd` is * inside that root — the newest in-scope session wins over a newer foreign one. * It is IGNORED for an explicit id: explicit ids resolve globally, and enforcing * their scope is the caller's fail-closed responsibility. */ export type SessionReference = { readonly ref: 'latest'; readonly tool?: ToolShortId; readonly cwdWithin?: string; } | { readonly ref: string; readonly tool?: ToolShortId; readonly cwdWithin?: string; }; /** * The outcome of {@link resolveSession}: either the resolved `session`, or a * failure carrying a machine-readable `reason` and a human `detail`. */ export type SessionResolveResult = { readonly ok: true; readonly session: StoredSession; } | { readonly ok: false; readonly reason: 'not-found' | 'wrong-tool' | 'ambiguous-latest'; readonly detail: string; }; /** * Resolve a {@link SessionReference} against the datastore. `'latest'` returns * the most recent session for the given `tool` (and is ambiguous without one), * scoped to `cwdWithin` when provided; an explicit id is looked up directly and * optionally tool-checked, and IGNORES `cwdWithin` (its scoping is the caller's * fail-closed responsibility). Never throws — every failure is a * `{ ok: false, reason, detail }` result. */ export declare function resolveSession(datastore: DataStore, reference: SessionReference): SessionResolveResult; //# sourceMappingURL=resolve-session.d.ts.map