import { ActorRef, isInitContinue, type Actor, type ActorId, type ChildSupervisionOptions, type InitContinue, type LinkRef, type TimerRef, type WatchRef } from "../actor.js"; import type { ActorSystem, SystemTimeouts } from "../actor_system.js"; import type { SpawnOptions } from "../actor_system.js"; import type { Authenticator } from "../auth.js"; import type { GossipOptions } from "../gossip_protocol.js"; import type { MailboxConfig } from "../mailbox.js"; import type { SupervisionOptions } from "../supervisor.js"; export type { InitContinue }; export { isInitContinue }; type CallHandlers = Record any>; type CastHandlers = Record void>; type ExtendHandlers any> = THandlers & { [P in K]: THandler; }; export type SupervisionConfig = SupervisionOptions; export type GossipConfig = GossipOptions; export interface ActorRegistry { } export type ExtractCalls = T extends ActorDefinition ? TCalls : {}; export type ExtractCasts = T extends ActorDefinition ? TCasts : {}; export type ActorRefFrom = T extends ActorDefinition ? TypedActorRef : ActorRef; export interface LocalConfig { type?: "local"; nodeId?: string; supervision?: SupervisionConfig; /** Default mailbox configuration for all actors in this system */ mailbox?: MailboxConfig; /** Configurable timeouts for actor operations */ timeouts?: SystemTimeouts; } /** * Options for waiting until the cluster reaches a ready state. * * Both `minMembers` and `nodes` can be specified simultaneously — the cluster * is considered ready only when ALL conditions are met. * * @example * ```typescript * // Wait for at least 3 members * await system.waitForCluster({ minMembers: 3 }); * * // Wait for specific nodes * await system.waitForCluster({ nodes: ["gateway", "worker-1"] }); * * // Both conditions (AND) * await system.waitForCluster({ minMembers: 3, nodes: ["gateway"], timeout: 15000 }); * ``` */ export interface WaitForClusterOptions { /** Wait until N total members (including self) have joined. Default: 2 */ minMembers?: number; /** Wait for these specific node IDs to appear in the cluster */ nodes?: string[]; /** Timeout in ms. Rejects with TimeoutError if not met. Default: 30000 */ timeout?: number; } export interface DistributedConfig { type: "distributed"; nodeId?: string; port?: number; ports?: { rpc: number; pub: number; gossip: number; }; bindAddress?: string; /** Address to advertise to peers for RPC/gossip connections. Use when the bind address (0.0.0.0) differs from the reachable address (e.g., public IP). Default: "127.0.0.1" */ advertiseAddress?: string; seedNodes: string[]; gossip?: GossipConfig; supervision?: SupervisionConfig; /** Shared secret (≥16 chars). Derives HMAC key for gossip + CurveZMQ keypair for transport. */ cookie?: string; /** HKDF salt for key derivation. Default: "libeam-v2". All nodes in a cluster must use the same salt. */ salt?: string; /** Custom gossip authenticator. Transport auth always uses cookie-derived CurveZMQ keys. */ auth?: Authenticator; /** * Wait for cluster readiness during createSystem(). Calls waitForCluster() internally. * If readiness is not achieved within the timeout, the system is shut down and createSystem rejects. */ ready?: WaitForClusterOptions; /** Roles this node fulfills (e.g., ["gateway", "worker"]). Propagated to peers via gossip. */ roles?: string[]; /** Default mailbox configuration for all actors in this system */ mailbox?: MailboxConfig; /** Configurable timeouts for actor operations */ timeouts?: SystemTimeouts; /** @internal Transport wrapper factory for testing (fault injection). Not part of public API. */ _wrapTransport?: (transport: import("../transport.js").Transport) => import("../transport.js").Transport; /** @internal GossipUDP wrapper factory for testing (fault injection). Not part of public API. */ _wrapGossipUDP?: (gossip: import("../gossip_udp.js").GossipUDP) => any; } /** * Operator-facing API for cookie rotation without restart. * Only available on distributed systems (undefined on local). * * Workflow: install(newCookie) on all nodes → use() on each node → remove() on all nodes. */ export interface Keyring { /** Add a new cookie to the keyring. Gossip accepts both old and new keys. No transport change. */ install(cookie: string): void; /** Switch to the installed cookie. Recreates transport sockets (brief reconnection window). */ use(): Promise; /** Remove the old cookie from the keyring. Only the active primary remains. */ remove(): void; /** List key fingerprints (SHA-256 hex strings). Never exposes raw cookies. */ list(): string[]; } export interface ActorContext { self: ActorRef; parent?: ActorRef; spawn(definition: ActorDefinition, options?: SpawnOptions): TypedActorRef; watch(ref: ActorRef): WatchRef; unwatch(ref: WatchRef): void; link(ref: ActorRef): LinkRef; unlink(ref: LinkRef): void; exit(reason?: string): void; setTrapExit(trap: boolean): void; getActorByName(name: K): Promise | null>; getActorByName(name: string): Promise; stash(): void; unstash(): void; unstashAll(): void; clearStash(): void; } export interface ActorBuilder { onCall any>(name: K, handler: THandler): this & ActorBuilder, TCasts>; onCast void>(name: K, handler: THandler): this & ActorBuilder>; onInfo(type: T, handler: (msg: any) => void): this; onTerminate(handler: () => void): this; onContinue(handler: (data: T) => void | Promise): this; sendAfter(message: any, delayMs: number): TimerRef; sendInterval(message: any, intervalMs: number): TimerRef; setIdleTimeout(timeoutMs: number): this; migratable(config: { getState: () => any; setState: (state: any) => void; }): this; childSupervision(options: ChildSupervisionOptions): this; } export type ActorDefinition = (new () => Actor) & { __type: "functional-actor"; factory: (ctx: ActorContext, self: ActorBuilder<{}, {}>, ...args: TArgs) => void | InitContinue | ActorBuilder; }; declare const ActorRefBase: new (id: ActorId, system: ActorSystem) => ActorRef; export declare class TypedActorRef extends ActorRefBase { call(method: K, ...args: Parameters): Promise>; call(method: keyof TCalls extends never ? string : never, ...args: any[]): Promise; call(message: any, timeout?: number): Promise; cast(method: K, ...args: Parameters): void; cast(method: keyof TCasts extends never ? string : never, ...args: any[]): void; cast(message: any): void; } //# sourceMappingURL=functional.d.ts.map