import { type GjcSessionContext, type GjcSessionSource } from "./session-layout"; /** Window within which two activity timestamps are treated as an ambiguous tie. */ export declare const LATEST_SESSION_TIE_WINDOW_MS = 1000; export interface SessionIdSources { /** Raw `--session-id` value: `undefined` = flag absent; `""` = present-but-blank (invalid). */ flagValue?: string | undefined; payloadSessionId?: unknown; envSessionId?: string | undefined; } export declare class SessionResolutionError extends Error { readonly code: "blank_flag" | "unsafe_session" | "no_session" | "ambiguous" | "missing_for_write"; constructor(message: string, code: "blank_flag" | "unsafe_session" | "no_session" | "ambiguous" | "missing_for_write"); } interface ResolvedFromSources { gjcSessionId: string; source: GjcSessionSource; } /** * Resolve a session id from explicit sources only (flag -> payload -> env). * Returns `undefined` when none is present. A blank explicit flag throws. */ export declare function resolveSessionIdFromSources(sources: SessionIdSources): ResolvedFromSources | undefined; /** Resolve session context for a WRITE command. Errors when no explicit id is present. */ export declare function resolveGjcSessionForWrite(cwd: string, sources: SessionIdSources): GjcSessionContext; /** * Resolve session context for a READ/STATUS/CLEAR command. Falls back to the * latest active session by activity marker when no explicit id is present. */ export declare function resolveGjcSessionForRead(cwd: string, sources: SessionIdSources): Promise; /** * Scan `.gjc/_session-*` directories and select the most-recently-active one by * its activity marker. Never uses raw directory mtime. Throws on zero candidates * or an ambiguous tie. */ export declare function detectLatestSession(cwd: string): Promise; export interface ActivityMarkerInfo { writer: string; /** Relative generated path that was just written, for diagnostics. */ path?: string; } /** * Best-effort write of the per-session activity marker. State-command callers * MUST treat a thrown error as a command failure (auto-detect depends on it); * non-critical writers may swallow it. */ export declare function writeSessionActivityMarker(cwd: string, gjcSessionId: string, info: ActivityMarkerInfo): Promise; export {};