UNPKG

@phren/cli

Version:

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

30 lines (29 loc) • 1.4 kB
import type { IncomingMessage } from "node:http"; /** Sockets one identity may hold per client kind, and in all. */ export declare const SOCKETS_PER_KIND = 16; export declare const SOCKETS_PER_IDENTITY = 32; /** Every identity together; the backstop if identities themselves multiply. */ export declare const SOCKETS_TOTAL = 128; /** * Who a WebSocket belongs to, from what the Hook itself trusts rather than a * client hint: a peer key's gateway rebuilds its request with `x-phren-origin: * peer` and the peer's fingerprint, so that is its own identity; everything * else arrives on the owner's local socket or the owner's SSH pipe and is the * owner. `x-phren-client` only picks a sub-pool inside the identity. */ export declare function socketIdentity(request: Pick<IncomingMessage, "headers">): string; export declare const socketKind: (request: Pick<IncomingMessage, "headers">) => string; /** Admits sockets oldest-first under the per-kind, per-identity and total caps. */ export declare class SocketBudget<S> { private readonly limits; private readonly entries; constructor(limits?: { kind: number; identity: number; total: number; }); /** Register a socket; returns the sockets to close to stay inside the caps. */ add(socket: S, identity: string, kind: string): S[]; remove(socket: S): void; count(identity?: string): number; }