/** * @license * Copyright 2026 Qwen Team * SPDX-License-Identifier: Apache-2.0 */ import { type PeerFrame } from './frames.js'; /** Give up on a peer that accepts a connection and never drains it. */ export declare const SEND_TIMEOUT_MS = 5000; /** How long a reachability probe waits for a local socket to answer. */ export declare const PROBE_TIMEOUT_MS = 250; /** * Most sends in flight at once. Each holds a descriptor until it settles, * and receipts are drawn by traffic other processes control; past this, a * send fails with `EBUSY` rather than taking the process's descriptors. */ export declare const MAX_CONCURRENT_SENDS = 64; export declare class PeerSendError extends Error { /** The errno behind the failure, when there is one. */ readonly code: string | undefined; /** * True when the failure is this process's own limit rather than anything * at the other end: nothing was dialed and nothing was written. */ readonly local: boolean; constructor(message: string, /** The errno behind the failure, when there is one. */ code: string | undefined, options?: { local?: boolean; }); } /** * True for a path this process is willing to dial. * * An address is read from a file another process wrote, so it is input, * not fact: an absolute local path, or a local pipe on Windows. Nothing * relative, nothing that could reach another host. */ export declare function isLocalIpcPath(candidate: string): boolean; export interface SendPeerFrameOptions { /** * The token to present on the auth line: the recipient's `ipcToken`, or a * controller token. Leave it out for an inbox whose record advertises no * token. */ authToken?: string; timeoutMs?: number; } /** * Write one frame to `socketPath`. * * Resolving means the frame was written and the peer closed the connection * — not that anything acted on it. Receipts are what say that. * * Rejects with a {@link PeerSendError}. `ENOENT` and `ECONNREFUSED` mean the * address is stale; `EAGAIN` and `EBUSY` mean the peer is alive but busy; * `ETIMEDOUT` means it accepted the connection and stopped reading, and may * still read the frame later; `EMSGSIZE` means the frame was too long to * send at all. */ export declare function sendPeerFrame(socketPath: string, frame: PeerFrame, options?: SendPeerFrameOptions): Promise; /** * What a probe established. Only `dead` is a definitive negative; `unknown` * — a timeout, a permission error, descriptor exhaustion — establishes * nothing. */ export type PeerSocketVerdict = 'alive' | 'dead' | 'unknown'; /** * Dial `socketPath` and report what that established. * * A full listen backlog (`EAGAIN`, `EBUSY`) is a busy peer, so alive. A * missing path or a socket file nothing holds (`ENOENT`, `ECONNREFUSED`) is * dead: a socket file outlives a crash, and only a dial tells the two apart. */ export declare function probePeerSocketVerdict(socketPath: string): Promise;