@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
53 lines (52 loc) • 2.67 kB
TypeScript
/**
* Peers this node may borrow capacity from.
*
* The borrower's half of peer sharing. Each entry is a lender's exposed proxy
* plus the share token they issued; the lender remains the authority on what
* that token may do, so nothing here tries to second-guess a grant's policy.
*
* Peer cooldowns are kept here rather than in `accountCooldown.ts` on purpose.
* A peer is not an account: its unavailability reasons are grant-shaped
* ("paused", "exhausted") rather than window-shaped, and the account cooldown
* store's Anthropic quota keying is documented as label-based, which a peer key
* has no business participating in.
*
* @module proxy/peerStore
*/
import type { ProxyPeer, ProxyPeerCooldownReason, ProxyPeerInput, ProxyPeerObservation, ProxyPeerPendingProvision } from "../types/index.js";
export declare function initPeerStore(peersFilePath: string): void;
export declare function listPeers(): Promise<ProxyPeer[]>;
export declare function getPeer(name: string): Promise<ProxyPeer | undefined>;
/**
* Peers worth trying right now, in the order they should be tried.
*
* Disabled and cooling peers are dropped rather than sorted last: a borrowed
* request is already the fallback path, and spending its latency budget on a
* peer that just said "paused" helps nobody.
*/
export declare function selectBorrowablePeers(now?: number): Promise<ProxyPeer[]>;
export declare function addPeer(input: ProxyPeerInput): Promise<ProxyPeer>;
export declare function removePeer(name: string): Promise<boolean>;
export declare function setPeerEnabled(name: string, enabled: boolean): Promise<ProxyPeer | undefined>;
export declare function updatePeer(name: string, patch: {
priority?: number;
note?: string;
url?: string;
token?: string;
receiptSecret?: string;
reciprocalPeer?: string;
lastReceiptSequence?: number;
/** `null` clears an outstanding provisioning request. */
pendingProvision?: ProxyPeerPendingProvision | null;
}): Promise<ProxyPeer | undefined>;
/** How long a peer should be left alone after this kind of refusal. */
export declare function peerCooldownMs(reason: ProxyPeerCooldownReason): number;
/**
* Park a peer after a refusal.
*
* `retryAfterSeconds` from the lender wins when it is longer than our default —
* the lender knows when its window turns over and we do not — up to a week.
*/
export declare function coolPeer(name: string, reason: ProxyPeerCooldownReason, retryAfterSeconds?: number): Promise<void>;
/** Clear a cooldown after a peer serves successfully. */
export declare function recordPeerSuccess(name: string, observation?: ProxyPeerObservation): Promise<void>;