/** * One attached session: an Agent, and everything projected from its log. * * The other half of the {@link Window} split. Every registration here is owned * by a {@link SessionScope} rather than by the plugin fiber, because all of it — * the slot views, the log projection, the spinner, the capability adapters — * describes THIS session and has to come down when the reader opens another. * * The scope comes down BEFORE the agent handle: a transcript listener still * subscribed while its own agent is torn down would project that teardown into * the transcript the reader is leaving. * @module dshline/attachment */ import type { AttachOutcome, AttachTarget } from './sessions/reopen.ts'; import type { Window } from './window.ts'; /** * Establish one attachment, and guarantee that a failed attempt takes * everything it acquired with it. * * The epoch below reaches its teardown only after `await switched`, which * resolves when the READER asks to leave. Everything initialization registered * before that point — the window's exit hook, the key dispatch, five live rows, * the ticker, every listener, and the Agent handle `attachTarget()` handed over * and cannot reach again — is therefore owned by an attempt that may never * finish. A throw anywhere in initialization therefore used to reject out of * `runWindowSessions` with all of it still live: the dead epoch kept painting, * kept consuming keystrokes, and its agent kept running beside the next one. * * So ownership is explicit, and released exactly once by whichever path reaches * it: the epoch's own teardown on a normal switch, or the catch below on a failed * establishment. The two releases are independently guarded — the scope is * idempotent by its own contract, the handle by the flag below — because an * epoch can fail BETWEEN its scope teardown and its handle teardown, and that * gap is exactly where a single shared flag would have decided the handle was * already gone. * @param w - the window to attach into. * @param outcome - the established Agent and the target it was created for. * @returns the target the reader chose next. * @throws the initialization failure, carrying any cleanup failure with it. */ export declare function attachSession(w: Window, outcome: AttachOutcome): Promise; //# sourceMappingURL=attachment.d.ts.map