import { S as SessionData } from './types-chunks/session-storage.d-Cci897iM.js';
import './types-chunks/types.d-mM8vqvhT.js';
import './types-chunks/types.d-B1uGoVTE.js';

/**
 * FEATURE_173 Part B (v0.7.42) — Session Management Public SDK.
 *
 * Thin facades over FileSessionStorage + discoverInstances. All methods
 * NEVER throw — missing sessions return null, blocked operations return
 * an error envelope, missing directories return empty arrays / no-op
 * watchers.
 *
 * The `@kodax-ai/kodax/session` SDK subpath re-exports this module.
 */

interface SessionSummary {
    readonly id: string;
    readonly title: string;
    readonly msgCount: number;
    readonly createdAt?: string;
    readonly runtimeInfo?: {
        workspaceRoot?: string;
        gitRoot?: string;
    };
}
interface ListSessionsOptions {
    /**
     * Alias for gitRoot; backwards-compat with KodaX Space terminology.
     * When provided, list() is scoped to sessions from this project root.
     */
    readonly projectRoot?: string;
    /**
     * Which session scopes to include.
     * - 'user' (default): only user-initiated sessions.
     * - 'managed-task-worker': only managed-task worker sessions.
     * - 'all': no scope filter.
     */
    readonly scope?: 'user' | 'managed-task-worker' | 'all';
    /**
     * Whether to include archived sessions (filename starts with `archived-`).
     * Default false — no archived sessions exist today; reserved for future use.
     */
    readonly includeArchived?: boolean;
    /** Maximum number of sessions to return. Default 50. */
    readonly limit?: number;
    /**
     * ISO date string — return only sessions whose createdAt is before this
     * timestamp. Applied after list + scope filtering.
     */
    readonly before?: string;
}
type WatchSessionsCallback = (event: {
    kind: 'change' | 'add' | 'remove';
    sessionId: string;
}) => void;
interface SessionManager {
    listSessions: typeof listSessions;
    loadSession: typeof loadSession;
    forkSession: typeof forkSession;
    rewindSession: typeof rewindSession;
    setActiveEntry: typeof setActiveEntry;
    deleteSession: typeof deleteSession;
    listRunningSessions: typeof listRunningSessions;
    watchSessions: typeof watchSessions;
}
/**
 * List sessions, optionally filtered by scope, limit, and date.
 * NEVER throws. Returns [] when the sessions directory is empty or missing.
 */
declare function listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]>;
/**
 * Load full session data by ID.
 * Returns null for a missing session. NEVER throws.
 */
declare function loadSession(id: string): Promise<SessionData | null>;
/**
 * Fork a session at an optional selector.
 * Returns null for a missing session. NEVER throws.
 */
declare function forkSession(id: string, opts?: {
    selector?: string;
    sessionId?: string;
    title?: string;
}): Promise<{
    sessionId: string;
    data: SessionData;
} | null>;
/**
 * Rewind a session to a previous user entry.
 * Returns null for a missing session. NEVER throws.
 */
declare function rewindSession(id: string, opts?: {
    selector?: string;
}): Promise<SessionData | null>;
/**
 * Set the active lineage entry by selector.
 * Returns null for a missing session. NEVER throws.
 */
declare function setActiveEntry(id: string, selector: string): Promise<SessionData | null>;
interface RunningSessionInfo {
    readonly pid: number;
    readonly startedAt: number;
    readonly cwd: string;
    /**
     * Reserved — FEATURE_125 heartbeat schema does not yet carry sessionId.
     * Will be populated in a future version once the state writer includes it.
     * Consumers MUST treat undefined as valid; do not assume a running session
     * always has a sessionId.
     */
    readonly sessionId: string | undefined;
}
/**
 * Returns live KodaX sibling instances (excluding this process).
 * Uses discoverInstances() from @kodax-ai/agent (FEATURE_125 Team Mode).
 * NEVER throws. Returns [] when no instances directory exists.
 */
declare function listRunningSessions(): Promise<RunningSessionInfo[]>;
type DeleteSessionResult = {
    ok: true;
} | {
    error: {
        code: 'session_running';
        runningProcess: {
            pid: number;
            startedAt: number;
        };
    };
};
/**
 * Delete a session by ID.
 * Returns { ok: true } on success (including when the session doesn't exist).
 * Returns an error envelope when the session is currently running.
 * NEVER throws.
 */
declare function deleteSession(id: string): Promise<DeleteSessionResult>;
/**
 * Watch the sessions directory for changes.
 * Returns { close() } that stops the watcher / poll interval.
 *
 * Platform branches:
 * - POSIX: fs.watch() with 100ms debounce.
 * - Windows: readdir poll every 1000ms, diffed against a snapshot.
 *
 * NEVER throws — if the directory doesn't exist the watcher is a no-op
 * until the directory is created.
 */
declare function watchSessions(cb: WatchSessionsCallback): {
    close: () => void;
};
/**
 * Factory that returns an object with all session management methods bound.
 *
 * The `sessionsDir` option is accepted for API surface completeness but is
 * ignored in v0.7.42 — FileSessionStorage reads KODAX_SESSIONS_DIR frozen at
 * module-load time. A per-instance directory override requires a substrate-
 * level `setAgentConfigHome()` call before import. The sessionsDir parameter
 * will be wired in a future version (v0.7.43 follow-up).
 */
declare function createSessionManager(opts?: {
    sessionsDir?: string;
}): SessionManager;

export { createSessionManager, deleteSession, forkSession, listRunningSessions, listSessions, loadSession, rewindSession, setActiveEntry, watchSessions };
export type { DeleteSessionResult, ListSessionsOptions, RunningSessionInfo, SessionManager, SessionSummary, WatchSessionsCallback };
