/** * Retained-child session registry — backs the `awaitInput` pause/resume flow. * * A subagent spawned with `retainSession: true` keeps its `EventLog` and * `ModeContext` alive after its first turn so a later `continue()` can append * an operator reply and run it again. The registry is a process-local map * keyed by child session id; entries are dropped on `continue` or `release`. * * Each entry records its `parentSession`, so {@link clearRetainedChildren} * drops only the children belonging to the session that is closing. The map is * process-wide (one per module), but a `Session.close()` must NOT wipe another * live session's paused children — that would break their `continue()` in any * host that runs >1 Session per process (the desktop in-process path, tests). */ import type { ModeContext, SessionId, SubagentSpec, TurnId } from '@moxxy/sdk'; import type { EventLog } from '../events/log.js'; import type { SessionRuntime } from '../session-runtime.js'; export interface RetainedChildSession { readonly label: string; readonly childSessionId: SessionId; readonly childTurnId: TurnId; readonly childLog: EventLog; readonly childCtx: ModeContext; readonly spec: SubagentSpec; readonly strategy: ReturnType[number]; readonly strategyName: string; readonly parentSession: SessionRuntime; readonly parentTurnId: TurnId; /** Cumulative provider token cost across this retained session's turns. */ tokensUsed?: number; /** Wall-clock ms when the entry was (re)registered — drives TTL eviction. */ readonly retainedAt?: number; } /** * Register (or re-register) a retained child. Returns the entries DROPPED by * this call — TTL-expired children plus any evicted to make room under the cap — * so the caller can surface a `subagent_warning` for each (a paused `awaitInput` * child whose `continue()` will now fail with "no retained subagent session"). * The registry has no SessionRuntime handle of its own, so it can't emit. */ export declare function registerRetainedChild(session: RetainedChildSession): RetainedChildSession[]; export declare function getRetainedChild(childSessionId: SessionId): RetainedChildSession | undefined; /** * Atomically claim a retained child for a `continue()` turn: remove it from the * registry and mark it busy, so a racing `continue()`/`release()` for the same * id can't observe the live entry and drive `strategy.run` over the same * childLog/childCtx concurrently. Returns `undefined` if the id is unknown or * already in flight. */ export declare function claimRetainedChild(childSessionId: SessionId): RetainedChildSession | undefined; /** Release a claim taken by {@link claimRetainedChild} (after the turn settles). */ export declare function unclaimRetainedChild(childSessionId: SessionId): void; export declare function releaseRetainedChild(childSessionId: SessionId): void; /** * Drop retained children. With a `parentSessionId`, drop ONLY the children * whose `parentSession` is that session — so one session's `close()` can't wipe * another live session's paused `awaitInput` children. Without an id (legacy / * test-teardown callers), clear everything. */ export declare function clearRetainedChildren(parentSessionId?: SessionId): void; //# sourceMappingURL=registry.d.ts.map