UNPKG

@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

58 lines (57 loc) • 3 kB
/** * Credentials a lender provisioned onto this device, and the leases that keep * them legitimate. * * This is the borrower's half of **complete** sharing. The credential itself * lives in the normal token store and is routed like any other account — that is * the point, since it survives the lender being offline. What lives here is the * proof that the lender still consents, and the machinery to keep it fresh. * * **The enforcement is cooperative and the code should say so.** A resident * credential sits on a machine its holder controls, and the token store is * obfuscated rather than encrypted. Someone determined to bypass this can. What * these checks buy is that the honest path is also the correct one: a borrower * running the shipped software stops when the lender says stop, and stops on its * own if the lender becomes unreachable for longer than the lease allows. * * @module proxy/residentGrants */ import type { ProxyResidentGrant, ProxyShareLease, ProxyShareLeaseVerdict } from "../types/index.js"; export declare function initResidentGrants(filePath: string): void; export declare function listResidentGrants(): Promise<ProxyResidentGrant[]>; export declare function getResidentGrantForAccount(accountKeyOrLabel: string): Promise<ProxyResidentGrant | undefined>; export declare function saveResidentGrant(grant: ProxyResidentGrant): Promise<void>; export declare function removeResidentGrant(accountLabel: string): Promise<boolean>; /** * May this resident account serve right now? * * Returns `undefined` for an account that is not resident at all — the node's * own credentials, which answer to nobody. */ export declare function evaluateResidentAccount(accountKeyOrLabel: string, now?: number): Promise<ProxyShareLeaseVerdict | undefined>; /** Accumulate spend the borrower owes the lender an account of. */ export declare function recordResidentSpend(accountLabel: string, coins: number): Promise<void>; /** * Check in with a lender: report what was spent, collect a fresh lease. * * Reporting happens **before** the new lease is stored, and the counters are * only drawn down once the lender has acknowledged them — a heartbeat that * fails halfway leaves the spend to be reported again rather than losing it. * * A `stop` answer is honored immediately by clearing the lease's grace: the * lender has said no, and there is nothing to wait out. */ export declare function heartbeatResidentGrant(resident: ProxyResidentGrant, now?: number): Promise<{ ok: boolean; stopped: boolean; detail: string; }>; /** * Check in with every lender whose heartbeat is due. * * Best-effort by design: a lender being unreachable is the case the offline * grace exists for, not an error to surface. */ export declare function heartbeatDueResidentGrants(now?: number): Promise<void>; /** The lease a resident account is currently operating under. */ export declare function residentLease(resident: ProxyResidentGrant): ProxyShareLease;