export { readLinuxBootIdentity, readProcessStartIdentity, } from '../utils/process-identity.js'; export interface AncestorSessionContext { sessionId: string; turnId?: string; dispatchAttempt?: number; } export interface AuthenticatedAncestorSessionContext extends AncestorSessionContext { markerPid: number; procStart: string; } export declare class SessionMarkerAuthenticationError extends Error { constructor(message: string); } /** * Strong marker lookup for authority-bearing commands. Unlike the legacy * read/reply resolver, this requires the worker's JSON procStart binding and * verifies it against the live ancestor process before returning identity. */ export declare function findAuthenticatedAncestorSessionContext(dataDir: string, startPid?: number): AuthenticatedAncestorSessionContext | null; /** * Walk the process tree looking for a CLI-pid marker written by the botmux * worker. Legacy markers contain just the session id; new markers are JSON and * also carry the current inbound turn id so long-lived CLI processes can route * `botmux send` to the correct topic alias on the 2nd/Nth turn. * * A matched marker is honored only when `isTrustworthyAncestorMarker` clears it * against `envSessionId` (the caller threads in the inherited BOTMUX_SESSION_ID; * resolveSessionContext and the v3 relay client both pass it explicitly). When * omitted, only the procStart birth-stamp check applies — the function never * reads the ambient global env itself, so it stays pure and its callers decide * what "ground truth" is. An untrustworthy marker — empty, a recycled PID, or a * different session than the authoritative env — is skipped and the walk keeps * climbing; a genuine ancestor marker may sit higher, and if none does the caller * falls back to the env id. */ export declare function findAncestorSessionContext(dataDir: string, startPid?: number, envSessionId?: string): AncestorSessionContext | null; /** * Resolve the owning session for an in-session subcommand (`botmux send`, etc.). * * Primary signal: the process-tree marker walk above — it carries the fresh * per-turn turnId, so it's preferred whenever it resolves a session id. * * Fallback: `BOTMUX_SESSION_ID` from the environment. The marker walk depends on * an unbroken ancestry between this process and the CLI's spawn pid. That link * is severed whenever the subcommand runs in a detached/backgrounded process * (`run_in_background`, `nohup`, `&`, `setsid` → reparented to init/pid 1), * nested deeper than the 8-level walk, or under a separate pid-namespace — in all * of which the marker walk returns null even though we ARE inside a botmux * session. The worker injects `BOTMUX_SESSION_ID` into the CLI's env, and every * descendant inherits it regardless of reparenting, so it stays correct. The * session id never changes after spawn, so this fallback can't route to the wrong * session; turnId is intentionally omitted (env can't be refreshed per-turn for a * long-lived CLI — callers fall back to `BOTMUX_TURN_ID` when they need it). */ export declare function resolveSessionContext(dataDir: string, envSessionId: string | undefined, startPid?: number, originChannelId?: string | undefined): AncestorSessionContext | null; //# sourceMappingURL=session-marker.d.ts.map