import type { SessionLog, SessionRecordDraft } from '../../store/session-log/index.js'; import type { SessionId } from '../../types/ids/index.js'; import { type ChildSessionMeta } from '../../types/session/records.js'; /** * A child session, as its parent sees it (spec ยง4.2, "Children"). * * A delegated agent runs as a child session: its own log at * `/subagents/.jsonl`, a convenience document * `.meta.json` beside it, and, in the parent's log, a * `child_session_spawned` record when it starts and a `child_session_ended` * record when it settles. This module holds the pieces of that which do not * depend on who holds the parent's lease: the meta document, the ended * record derived from the child's own log, and the process-local lookup of * a live child's log. */ /** `child_session_ended`, as the parent's writer appends it. */ export type ChildSessionEndedDraft = Extract; /** * The parent's `child_session_ended` record for a child, read from the * child's own terminal record so the two cannot disagree: the status, stop * reason, answer message, usage and cost are copied from the settlement of * the child's last `turn_completed` or `turn_failed`. `null` while the child * has no settled turn. * * The draft carries no `turnId`. The parent's writer adds the spawning turn's * id when that turn is still open, and leaves it out otherwise (the child * belongs to the turn its `child_session_spawned` names). */ export declare function childSessionEnded(childLog: SessionLog): Promise; /** A `.meta.json` that belongs to another child or another parent. */ export declare class ChildSessionMetaOwnerError extends Error { readonly name = "ChildSessionMetaOwnerError"; } /** * Write `.meta.json`, atomically and with an owner check: an * existing document must name the same child, parent and parent turn, or the * write is refused rather than repointing it. The document is a convenience * only; the child's log wins on any disagreement. */ export declare function writeChildSessionMeta(path: string, meta: ChildSessionMeta): Promise; /** The meta document at `path`, or `null` when there is none. Throws on one that does not parse. */ export declare function readChildSessionMeta(path: string): Promise; /** Register a live child's log; the returned function removes it. */ export declare function registerChildSessionLog(log: SessionLog): () => void; /** The log of a child session running in this process, if there is one. */ export declare function childSessionLog(childSessionId: SessionId): SessionLog | undefined; //# sourceMappingURL=child-session.d.ts.map