export interface OwnerIdentity { pid: number; startedAt: string; sessionKey: string; pidStartTime?: string; token: string; } export interface WatchStartOptions { root: string; me: string; sessionKey: string; bridgeDir: string; attached: boolean; tui: boolean; available: boolean; isTrusted: (from: string) => boolean; isContinuationTrusted?: (from: string) => boolean; emit: (payload: { envelopes: Array>; activeId: string | null; triggerTurn: boolean; urgentTrusted: boolean; promotionReason?: 'urgent' | 'continuation' | 'deferred' | 'resume' | null; }) => Promise; onMigration?: (migration: Record) => Promise; onSecondary?: (owner: OwnerIdentity | null) => Promise; onFatal?: (error: unknown) => Promise; heartbeat?: (options: { root: string; me: string; status?: string }) => void | Promise; } export interface WatchLifecycle { start(options: WatchStartOptions): Promise<{ status: string; owner: boolean; identity?: OwnerIdentity; key?: string; error?: unknown }>; stop(options: { root: string; me: string; sessionKey: string; clearActiveId?: boolean }): Promise<{ owner: boolean; stopped: boolean; identity?: OwnerIdentity }>; ownerMutation( options: { root: string; me: string; sessionKey: string; attached?: boolean }, operation: () => T | Promise, ): Promise<{ owner: false } | { owner: true; value: T }>; owns(options: { root: string; me: string; sessionKey: string }): Promise; inspect(root: string, me: string): { key: string; root: string; me: string; sessionKey: string; identity: OwnerIdentity } | null; size(): number; } export function watcherKey(root: string, me: string): string; export function createWatchLifecycle(options?: Record): WatchLifecycle;