/**
 * Session-management primitives.
 *
 * Thin wrappers around the tmux runtime utilities and the on-disk
 * `~/.atomic/sessions/<workflowRunId>/` layout. Consumers (atomic CLI,
 * third-party CLIs, embedding TUIs) call these instead of touching tmux
 * commands or the status-writer schema directly.
 */
import { type SessionType, type TmuxSession } from "../runtime/tmux.ts";
import { readSnapshot, type WorkflowStatusSnapshot } from "../runtime/status-writer.ts";
import type { AgentType, SavedMessage } from "../types.ts";
/** Scope filter for session listings — chat sessions, workflow sessions, or both. */
export type SessionScope = "chat" | "workflow" | "all";
/** Single session entry returned by `listSessions` / `getSession`. */
export interface SessionInfo {
    /** Tmux session name (e.g. `atomic-wf-claude-ralph-a1b2c3d4`). */
    id: string;
    /** Session type derived from the name prefix. */
    type?: SessionType;
    /** Agent backend that owns this session. */
    agent?: string;
    /** ISO 8601 creation timestamp. */
    created: string;
    /** Whether a tmux client is currently attached. */
    attached: boolean;
}
/** Status snapshot persisted by the orchestrator at `~/.atomic/sessions/<id>/status.json`. */
export type StatusSnapshot = WorkflowStatusSnapshot;
/** Options for filtering `listSessions()`. */
export interface ListSessionsOptions {
    /** Restrict to one or more agent backends. */
    agent?: AgentType | readonly AgentType[];
    /** Restrict by session kind. Defaults to `"all"`. */
    scope?: SessionScope;
}
/**
 * Injectable dependencies for the session primitives.
 *
 * Defaults wire through to the real tmux/status-writer implementations.
 * Tests pass in mocks; embedding consumers can override the base directory
 * or swap the tmux backend (e.g. for psmux on Windows) without monkey-
 * patching the underlying modules.
 */
export interface SessionPrimitiveDeps {
    isTmuxInstalled: () => boolean;
    listAllTmuxSessions: () => readonly TmuxSession[];
    killSession: (id: string) => void;
    attachSession: (id: string) => void;
    detachClients: (id: string) => void;
    nextWindow: (id: string) => void;
    previousWindow: (id: string) => void;
    /** `target` is a tmux window target like `<session>:<index>`. */
    selectWindow: (target: string) => void;
    readSnapshot: typeof readSnapshot;
    /** Base directory for session artefacts. Defaults to `~/.atomic/sessions`. */
    sessionsBaseDir: string;
}
/**
 * List atomic-managed tmux sessions on the shared `atomic` socket.
 *
 * Returns an empty array when tmux is not installed or the server has no
 * sessions — never throws on the cold-start path.
 */
export declare function listSessions(options?: ListSessionsOptions, deps?: SessionPrimitiveDeps): SessionInfo[];
/** Look up a single session by id. Returns `undefined` when not found. */
export declare function getSession(id: string, deps?: SessionPrimitiveDeps): SessionInfo | undefined;
/**
 * Stop a running session. Best-effort: if the session is already gone
 * the underlying `tmux kill-session` is a no-op-equivalent.
 */
export declare function stopSession(id: string, deps?: SessionPrimitiveDeps): Promise<void>;
/**
 * Attach to a running session interactively. Only valid when the host
 * process has a TTY — otherwise the underlying tmux invocation will
 * complain that it can't take over the terminal.
 */
export declare function attachSession(id: string, deps?: SessionPrimitiveDeps): Promise<void>;
/**
 * Move the session's current-window pointer to the next window.
 * Mirrors the `Ctrl+\` keybinding bound inside an attached client.
 *
 * Pure navigation: never attaches. An already-attached client sees the
 * change live; if no client is watching, the session's current-window
 * pointer is updated silently and a subsequent `attachSession` will
 * land on the new window. Compose `nextWindow(id)` + `attachSession(id)`
 * if you want navigate-then-attach.
 */
export declare function nextWindow(id: string, deps?: SessionPrimitiveDeps): Promise<void>;
/**
 * Move the session's current-window pointer to the previous window.
 * Symmetrical counterpart to {@link nextWindow} — also pure navigation.
 */
export declare function previousWindow(id: string, deps?: SessionPrimitiveDeps): Promise<void>;
/**
 * Jump to the orchestrator window (window 0) of the target session.
 * Mirrors the `Ctrl+G` keybinding bound inside an attached client.
 *
 * For workflow sessions, window 0 hosts the orchestrator graph view;
 * for chat sessions, window 0 is the agent pane. Pure navigation —
 * never attaches.
 */
export declare function gotoOrchestrator(id: string, deps?: SessionPrimitiveDeps): Promise<void>;
/**
 * Detach every client currently attached to a session. The session
 * itself keeps running in the background — re-attach with
 * {@link attachSession} or `tmux -L atomic attach -t <id>`.
 *
 * Best-effort, idempotent: returns silently when tmux is missing, the
 * session is already gone, or no clients are attached.
 */
export declare function detachSession(id: string, deps?: SessionPrimitiveDeps): Promise<void>;
/**
 * Read the on-disk status snapshot for a workflow session. Returns
 * `null` when the orchestrator hasn't written one yet (the workflow
 * is still very early) or when the directory doesn't exist.
 */
export declare function getSessionStatus(id: string, deps?: SessionPrimitiveDeps): Promise<StatusSnapshot | null>;
/**
 * Read the saved native-message transcript for a single session inside
 * a workflow run. `id` is the tmux session id (`atomic-wf-...`); the
 * `sessionName` is the `name` passed to `ctx.stage({ name })` whose
 * messages were saved via `s.save(...)`.
 *
 * Returns an empty array when no transcript was persisted (e.g. the
 * workflow chose not to call `s.save`).
 */
export declare function getSessionTranscript(id: string, sessionName: string, deps?: SessionPrimitiveDeps): Promise<SavedMessage[]>;
//# sourceMappingURL=sessions.d.ts.map