import type { SessionMeta } from './types.js';
/**
 * What a node is in the graph, decided from real signals only:
 *   - `orchestrator` — it spawned at least one other session in this graph.
 *   - `teammate`     — an `agents teams` teammate (a `meta.json` record backs it).
 *   - `subagent`     — an SDK/`sdk-cli` spawn with no teammate record.
 *   - `session`      — an ordinary session: no children, not team-spawned.
 */
export type LineageRole = 'orchestrator' | 'teammate' | 'subagent' | 'session';
/**
 * How recently the node's session did anything, relative to `now`. This is a
 * RECENCY signal, not a verdict: nothing on `SessionMeta` records whether the
 * work succeeded, so the graph never claims "merged" or "crashed". A node that
 * opened a PR carries {@link LineageNode.prNumber}, which is a fact.
 */
export type LineageActivity = 'active' | 'idle' | 'stale';
/** One session in the lineage graph. */
export interface LineageNode {
    session: SessionMeta;
    id: string;
    shortId: string;
    agent: string;
    /** Teammate handle from its team record, when it has one. */
    handle?: string;
    /** Team name (`task_name`) from its team record, when it has one. */
    team?: string;
    /** Teammate launch mode (plan/edit/auto/skip) from its team record. */
    mode?: string;
    role: LineageRole;
    /** Hops from the root: 0 for the root itself. */
    depth: number;
    /** Indexed tool calls (`SessionMeta.toolCallCount`), 0 when unrecorded. */
    toolCount: number;
    /** Wall-clock span in ms (`SessionMeta.durationMs`), 0 when unrecorded. */
    durationMs: number;
    activity: LineageActivity;
    /** PR the session opened, when it opened one. */
    prNumber?: number;
    /** How many children this node has in this graph. */
    childCount: number;
}
/** A parent → child delegation edge, and which record established it. */
export interface LineageEdge {
    parent: string;
    child: string;
    /**
     * `parentSessionId` — the child's own team record named this orchestrator.
     * `teamSpawner`     — the child's record named none, but its whole team agreed
     *                     on one spawner (`groupSessionsByTeam.spawnerSessionId`).
     */
    source: 'parentSessionId' | 'teamSpawner';
}
/** The resolved delegation graph rooted at one session. */
export interface SessionLineage {
    rootId: string;
    /** The root first, then breadth-first; siblings ordered by spawn time. */
    nodes: LineageNode[];
    edges: LineageEdge[];
    /** Distinct team names across the graph, for the header line. */
    teams: string[];
    /**
     * Parent session ids a node pointed at that are not in the pool (the
     * orchestrator's transcript was never indexed, or the scan window cut it off).
     * Surfaced rather than dropped so a missing edge is never silent.
     */
    unresolvedParentIds: string[];
}
export interface BuildLineageOptions {
    /**
     * Which session the graph is about. The graph is always rooted at that
     * session's TOPMOST ancestor in the pool, so passing a child still renders its
     * whole team. Defaults to the first session in `sessions`.
     */
    rootId?: string;
    /** Epoch ms used to classify {@link LineageActivity}. Defaults to `Date.now()`. */
    now?: number;
    /** Last activity within this many ms is `active`. Default 5 minutes. */
    activeWithinMs?: number;
    /** Last activity within this many ms is `idle`; older is `stale`. Default 24 hours. */
    idleWithinMs?: number;
}
/**
 * Build the delegation graph rooted at one session.
 *
 * `sessions` is the discovery pool WITH team sessions included — team-origin
 * rows are hidden from the ordinary listing by default (`AGENTS.md` invariant 7),
 * so a caller that filters them out first would resolve an empty graph. It MUST
 * contain the `rootId` row (a root outside the pool throws rather than rooting
 * the graph somewhere else). The returned graph is the root's subtree: unrelated
 * sessions in the pool supply edges but never become nodes.
 */
export declare function buildLineage(sessions: SessionMeta[], options?: BuildLineageOptions): SessionLineage;
