import { IrcBus } from "../../irc/bus.js"; import { type AdoptOptions, AgentLifecycleManager } from "../../registry/agent-lifecycle.js"; import { AgentRegistry } from "../../registry/agent-registry.js"; import { RemoteAgentSession } from "../remote-agent-session.js"; import type { ThreadService, WorkerPeer } from "../services.js"; import { type SessionOpened } from "../session-mirror.js"; /** Boot globals of {@link agentsThreadService}: main's singletons and this worker's session bridge. */ export interface AgentsThreadGlobals { readonly registry: AgentRegistry; readonly lifecycle: AgentLifecycleManager; readonly bus: IrcBus; readonly bridge: MainSessionBridge; } /** * Main-side endpoint of one worker's sessions: mirrors of the sessions homed * there, and the peer surface for sessions homed elsewhere. Also the * per-worker ledger of everything that must end when the worker dies. */ export declare class MainSessionBridge { #private; /** Aborts IRC waits the worker parked on main. */ readonly exited: AbortController; constructor(peer: WorkerPeer); /** Worker the bridge serves. */ get threadId(): WorkerPeer["threadId"]; /** Mirror of the open session `key` homed on this worker. */ session(key: string): RemoteAgentSession | undefined; /** A publisher opened a session: create and hold its canonical mirror. */ opened(opened: SessionOpened): void; /** A publisher closed its session (dispose began). */ closed(key: string, reason?: string): void; /** * Keep `stop` until it runs or the worker dies; returns it marked sync so * the worker can unsubscribe without a round trip of its own. */ track(stop: () => void): () => void; /** * Wrap a worker function as a main-side listener: delivery is async, and a * failed delivery (closed link, collected receiver) ends the subscription. */ forward(deliver: (...args: A) => unknown, subscribe: (listener: (...args: A) => void) => () => void): () => void; /** Live worker revivers adopted on main; test seam for ledger bounds. */ get reviverCount(): number; /** * Record a reviver this worker handed to `lifecycle` for `id`; returns the adopt options * to pass on, whose reviver holds the worker (and its idle shutdown off) while a revive * runs there. The record is dropped when the adoption lets go of the reviver. */ adopted(lifecycle: AgentLifecycleManager, id: string, opts: AdoptOptions): AdoptOptions; /** The worker died: see the module doc for the ordering. */ exit(reason: string): void; } /** Registry, awaits, lifecycle, IRC bus, and agent-session bridging; see the module doc. */ export declare const agentsThreadService: ThreadService;