import type { ChildLike } from "@yanlinglabs/winter-agent-sdk/messaging"; import type { SeamContext } from "../seams/context.js"; import type { DirectoryResolution, DirectoryResolutionContext, RuntimeDirectory } from "../seams/directory.js"; import type { RuntimeDirectoryEntry } from "../seams/directory-store.js"; import type { DeliveryOutcome, GlobalAgentMessage, ListedRuntimeObject, SerializedRuntimeAddress } from "../seams/messaging-contract.js"; import { type RuntimeDirectoryRecoveryHooks, type RuntimeDirectoryRetention } from "./recovery.js"; /** What a caller may configure. Every field has an answer that is correct when it is absent. */ export interface RuntimeDirectoryOptions extends RuntimeDirectoryRecoveryHooks { /** Injected so a test never races a real clock. */ now?: () => number; /** * How a `ChildLike` built from a directory row delivers, for the two doors that interface requires. * * The router core never uses them (it calls `adapter.steerChild`/`resumeChild` and reads `ChildLike` * only for `status()` and its record) — see `entryToChildLike`. Absent means those two doors answer * a typed non-retryable `unavailable` rather than throwing, so a caller that used the interface it * was handed gets an outcome instead of a crash. */ deliverToChild?: (entry: RuntimeDirectoryEntry, message: GlobalAgentMessage) => Promise; /** * WS-10 §13's caps on the two durable sinks, applied by `recover()` at step 6 (Lane B fix r1, n3). * * ABSENT MEANS BOTH SINKS KEEP EVERYTHING — see `RuntimeDirectoryRetention`: forgetting a released * name lease changes what a model is told about a name it can no longer reach, so the router will * not choose a horizon for a host that did not state one. */ retention?: RuntimeDirectoryRetention; } /** * The directory, plus the two views the messaging router needs and the seam does not name. * * `RuntimeDirectory` is what `RuntimeSdk.directory` exposes; a host needs nothing more. The router * lives in the same package and needs the SAME snapshot resolution used, or its listing and its * resolution could disagree about a row that changed between two `load()` calls. */ export interface RuntimeDirectoryHandle extends RuntimeDirectory { /** One consistent read of the store, with the caller-scoped views built from it. */ snapshot(caller: { owningSessionId: string; }): Promise; /** Resolve against an ALREADY-TAKEN snapshot — the router resolves and delivers over one read. */ resolveIn(snapshot: DirectorySnapshot, to: string, context: DirectoryResolutionContext): Promise; } export interface DirectorySnapshot { /** Every entry the store held at the moment of the read. */ readonly entries: readonly RuntimeDirectoryEntry[]; readonly byAddress: ReadonlyMap; /** WS-10 §11's resolution input: this caller's own children, as the shared `ChildLike` boundary. */ readonly children: readonly ChildLike[]; /** Every object this caller may ADDRESS (includes exited sessions — WS-15 §6.2 has a row for them). */ readonly resolvable: readonly ListedRuntimeObject[]; /** Every object a listing may SHOW (WS-10 §10.2 — never an exited session). */ readonly listable: readonly ListedRuntimeObject[]; } export declare function createRuntimeDirectory(context: SeamContext, options?: RuntimeDirectoryOptions): RuntimeDirectoryHandle;