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

80 lines (79 loc) • 2.95 kB
/** * Proxy file path resolver. * * In normal mode, all paths resolve under ~/.neurolink/. * In dev mode (--dev), writable paths resolve under <cwd>/.neurolink-dev/ * so a local dev proxy never touches the global proxy's state. * * Read-only paths (like .env) always point to the global location * since credentials must be shared. * * NOTE: Claude Code header snapshots (~/.neurolink/header-snapshots/) are * not redirected in dev mode. They are only written when a real Claude Code * client connects, which typically does not happen during dev testing. */ import { homedir } from "node:os"; import { join } from "node:path"; /** * The state files, named once. * * Each name used to appear three times — dev branch, home branch, and the * resolver's fallback — which is three places to keep in step and two chances * to write a dev proxy's state into the global directory. */ const FILE_NAMES = { quota: "account-quotas.json", cooldown: "account-cooldowns.json", stats: "proxy-usage-stats.json", grants: "proxy-grants.json", ledger: "proxy-share-ledger.json", peers: "proxy-peers.json", residentGrants: "proxy-resident-grants.json", shareAudit: "proxy-share-audit.json", provisioning: "proxy-share-provisioning.json", receipts: "proxy-share-receipts.json", notes: "proxy-share-notes.json", }; export function resolveProxyPaths(dev) { const base = dev ? join(process.cwd(), ".neurolink-dev") : join(homedir(), ".neurolink"); return { stateDir: base, logsDir: join(base, "logs"), quotaFile: join(base, FILE_NAMES.quota), cooldownFile: join(base, FILE_NAMES.cooldown), statsFile: join(base, FILE_NAMES.stats), grantsFile: join(base, FILE_NAMES.grants), ledgerFile: join(base, FILE_NAMES.ledger), peersFile: join(base, FILE_NAMES.peers), isDev: dev, }; } export function resolveProxyUsageStatsPath(paths) { return paths.statsFile ?? join(paths.stateDir, FILE_NAMES.stats); } export function resolveProxyGrantsPath(paths) { return paths.grantsFile ?? join(paths.stateDir, FILE_NAMES.grants); } export function resolveProxyLedgerPath(paths) { return paths.ledgerFile ?? join(paths.stateDir, FILE_NAMES.ledger); } export function resolveProxyPeersPath(paths) { return paths.peersFile ?? join(paths.stateDir, FILE_NAMES.peers); } export function resolveProxyResidentGrantsPath(paths) { return join(paths.stateDir, FILE_NAMES.residentGrants); } export function resolveProxyShareAuditPath(paths) { return join(paths.stateDir, FILE_NAMES.shareAudit); } export function resolveProxyProvisioningPath(paths) { return join(paths.stateDir, FILE_NAMES.provisioning); } export function resolveProxyReceiptsPath(paths) { return join(paths.stateDir, FILE_NAMES.receipts); } export function resolveProxyNotesPath(paths) { return join(paths.stateDir, FILE_NAMES.notes); }