UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

32 lines (31 loc) • 2.13 kB
import { BridgeError } from "./protocol.js"; import type { HookPeer } from "./peers.js"; /** * Which peers did not answer, kept in memory by this process. Every peer request reports its outcome here; * only reads that poll or fan out (`peerRead`) act on it, so a dispatch, a hand-off or a link still dials. * * A peer that is off waits out its whole SSH timeout on every request. One linked computer asleep made * `/v1/sets` take 12 s and `/v1/computers` 8 s on each of the others (2026-11-19), every time the phone read * them. Once a peer is known to be off, reads answer with its last error at once until the wait is over: * `PEER_RETRY_FIRST_MS`, doubling per failed check to `PEER_RETRY_MAX_MS`. After the wait, one TCP connect to * its SSH port (no login) decides whether the next read dials. Any answer from its Hook forgets it. */ export declare const PEER_RETRY_FIRST_MS = 5000; export declare const PEER_RETRY_MAX_MS = 120000; /** SSH could not reach the peer. Failures inside a running wait are the same outage and do not lengthen it. */ export declare function peerDidNotAnswer(peer: HookPeer, error: BridgeError, now?: number): void; /** Its Hook answered (with a result or with its own error). */ export declare function peerAnswered(peer: HookPeer): void; /** * Our own wait ran out with no word from ssh, which says nothing about the peer: a slow report on a healthy * Hook ends the same way. A TCP connect to its SSH port tells the two apart, in the background. */ export declare function peerTimedOut(peer: HookPeer, offlineError: () => BridgeError): void; /** * The error a read of this peer should answer with instead of dialing, or nothing when it should dial. * Inside the wait: at once. After it: the TCP check runs (once, however many reads arrive) and the read gives * it `RECHECK_WAIT_MS`; a peer still off answers with the remembered error and a doubled wait. */ export declare function knownOffline(peer: HookPeer, now?: number): Promise<BridgeError | undefined>; /** An explicit refresh: every peer is dialed again on its next read. */ export declare function forgetOfflinePeers(): void;