/** * Remote Substrate, Durable Identity Manager * * Implements globally unique, stable identifiers for * sessionId, taskId, and agentId that survive transport changes and reconnects. * * The identity manager maintains the canonical set of IDs for a remote * substrate instance. Reconnects do not change these IDs, only explicit * refresh calls (for new tasks) increment the generation counter. */ import type { DurableIdentity } from './types.js'; /** Serializable snapshot for persistence across process restarts. */ export interface IdentitySnapshot { readonly sessionId: string; readonly taskId: string; readonly agentId: string; readonly createdAt: number; readonly generation: number; } /** * DurableIdentityManager, creates and maintains stable IDs across reconnects. * * Once created, the sessionId is permanent for the lifetime of this manager. * The taskId and agentId can be refreshed (incrementing generation) when * starting a new remote task, but remain stable across reconnects within * the same task. * * @example * ```ts * const identity = new DurableIdentityManager(); * // sessionId/taskId/agentId are stable, safe to pass across reconnects * const { sessionId, taskId } = identity.current; * * // After reconnect, same IDs * await reconnect(); * identity.current.sessionId === sessionId; // true * * // Starting a new task, refresh task/agent IDs * identity.refreshTaskIdentity(); * identity.current.taskId !== taskId; // true * ``` */ export declare class DurableIdentityManager { private _current; constructor(snapshot?: IdentitySnapshot); /** * The current durable identity snapshot. * * This reference is stable across reconnects, the same object is returned * until `refreshTaskIdentity()` is called. */ get current(): DurableIdentity; /** * Refresh the task and agent identifiers for a new remote task. * * The sessionId is preserved. The generation counter increments. * Call this when starting a new task on the remote substrate, * not when reconnecting to an existing task. * * @returns The new durable identity. */ refreshTaskIdentity(): DurableIdentity; /** * Serialize the current identity for persistence. * * Store the snapshot and pass it to the constructor on restart to * restore identity continuity across process restarts. * * @returns A plain-object snapshot safe for JSON serialization. */ toSnapshot(): IdentitySnapshot; /** * Restore identity from a plain snapshot object. * * Use this when rehydrating a remote substrate after a process restart. * This is equivalent to constructing with a snapshot but can be called * on an existing instance. * * @param snapshot - Previously serialized identity snapshot. */ restoreFromSnapshot(snapshot: IdentitySnapshot): void; } //# sourceMappingURL=identity.d.ts.map