import type { AgentSession } from "../session/agent-session.js"; import type { AgentSessionHandle } from "../session/agent-session-handle.js"; import type { ThreadId } from "./identity.js"; /** Wire identity of an agent session: its home thread and instance key. */ export interface SessionToken { readonly home: ThreadId; readonly key: string; } /** * Record a session constructed on this thread and notify session observers * (the worker's publisher). Called once, at the end of the `AgentSession` * constructor, before the session can be referenced anywhere else. */ export declare function registerLocalSession(session: AgentSession): void; /** The live session homed on this thread under `key`. */ export declare function findLocalSession(key: string): AgentSession | undefined; /** Whether `value` is a session registered on this thread (identity, not shape). */ export declare function isRegisteredLocalSession(value: unknown): value is AgentSession; /** Observe sessions constructed on this thread from now on; returns the unsubscribe function. */ export declare function onLocalSessionRegistered(listener: (session: AgentSession) => void): () => void; /** The canonical handle for a session homed on another thread, while anyone holds it. */ export declare function findRemoteSession(key: string): AgentSessionHandle | undefined; /** Make `handle` the canonical handle for `key`, held weakly. */ export declare function rememberRemoteSession(key: string, handle: AgentSessionHandle): void; /** Make `handle` canonical for `key` and keep it alive until {@link releaseRemoteSession}. */ export declare function holdRemoteSession(key: string, handle: AgentSessionHandle): void; /** Drop the strong hold on `key`; the handle stays canonical while referenced elsewhere. */ export declare function releaseRemoteSession(key: string): void;