import type { VanaNetworkName } from "../../core/network.js"; import type { ResolvedNode } from "../../pdpp/host.js"; import type { OwnerBinding } from "./owner-binding.js"; import { type TunnelProcessDeps } from "./tunnel-process.js"; /** A server already answering on a local port, and who owns it. */ export interface RunningServer { url: string; owner: string | null; /** The server's own key address, when its health reports one. */ identity?: string | null; } /** Every server answering on the ports Desktop and the CLI use. */ export declare function findRunningServers(fetchImpl?: typeof fetch): Promise; /** A port whose neighbour is free too: the server's approval page takes port + 1. */ export declare function choosePort(requested?: number): Promise; /** * Claim a data dir for this process. A lock whose pid is gone is stale and is * taken over; a live one means a server is already running from that dir. */ export declare function acquireDataDirLock(dir: string): Promise<() => Promise>; /** One JSON line the server process writes on stdout. */ export interface ServerMessage { type: string; [key: string]: unknown; } export interface LocalServerHandle { url: string; port: number; accessToken: string; /** Resolves when the server process exits, for whatever reason. */ exited: Promise; /** Send one command line to the server process. */ send(command: Record): void; /** Every message from now on; returns an unsubscribe. */ onMessage(listener: (message: ServerMessage) => void): () => void; stop(): Promise; } /** The next message of one of `types`, or a timeout error. */ export declare function nextMessage(handle: Pick, types: string[], timeoutMs: number): Promise; /** * Start the pinned Personal Server as a foreground child process on the * managed Node, local only, and wait until it answers. */ export declare function startLocalServer(input: { network: VanaNetworkName; /** The owner's own data dir (resolveServerDataDir). */ dataDir: string; node: ResolvedNode; runtimeDir: string; binding: OwnerBinding; port: number; logPath: string; /** A tunnel client to run; absent = local only. */ frpcPath?: string | null; readyTimeoutMs?: number; /** Finding and stopping a tunnel client; real processes by default. */ tunnelProcesses?: TunnelProcessDeps; }): Promise; /** What the CLI remembers about a server it registered. */ export interface PublicMarker { serverAddress: string; serverUrl: string; registeredAt: string; } /** * A registered server stays public: registrations cannot be removed, so once * apps may look for it, every later start brings its tunnel back. */ export declare function readPublicMarker(dataDir: string): PublicMarker | null; export declare function writePublicMarker(dataDir: string, marker: PublicMarker): Promise; //# sourceMappingURL=server.d.ts.map