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

70 lines (69 loc) • 3.57 kB
/** * YAML/JSON proxy configuration loader with environment variable resolution. * * Supports: * - Loading config from YAML or JSON files * - Environment variable interpolation: ${VAR_NAME} and ${VAR_NAME:-default} * - Multi-account proxy configurations * - Defaults for optional fields * * YAML parsing uses `js-yaml` when available (dynamic import), otherwise * falls back to JSON.parse. */ import type { LoadProxyConfigOptions, ProxyConfigFile, ProxyRoutingConfig } from "../types/index.js"; /** Default on-disk path used when `proxy start` is not given `--config`. */ export declare function defaultProxyConfigPath(): string; /** Resolve `--config` the same way `proxy start` / `proxy install` do. */ export declare function resolveProxyConfigPath(explicit?: string): string; /** * Replace all `${VAR}` / `${VAR:-default}` references in a string. * * Resolution order: * 1. Look up `VAR` in the provided env map (or process.env) * 2. If not found, use the `:-default` value when present * 3. If no default, leave the original `${VAR}` token so callers can detect * unresolved variables. */ export declare function resolveEnvVars(value: string, env?: Record<string, string | undefined>): string; /** * Validate the shape of a parsed proxy config. * Returns an array of human-readable error strings (empty = valid). */ export declare function validateProxyConfig(config: unknown): string[]; /** * Parse the optional `routing` section from a raw proxy config object. * * Extracts: * - `strategy` ("round-robin" | "fill-first") * - `model-mappings` / `modelMappings` — array of {from, to, provider} * - `fallback-chain` / `fallbackChain` — array of {provider, model, reasoningEffort?} * - `auto-fallback` / `autoFallback` — opt in to an unspecified provider * - `max-inflight-per-account` / `maxInflightPerAccount` — concurrency cap * - `passthroughModels` / `passthrough-models` — array of model IDs * - `quota-routing` / `quotaRouting` — quota-aware fill-first ordering * - `session-soft-limit` / `sessionSoftLimit` — proactive handoff threshold * - `session-reset-tolerance-ms` / `sessionResetToleranceMs` — reset bucket * - `account-allowlist` / `accountAllowlist` — allowed Anthropic account IDs * - `account-ranking` / `accountRanking` — expiry-first | headroom-first * - `prefer-primary` / `preferPrimary` — bias ranking toward primaryAccount * - `session-affinity` / `sessionAffinity` — sticky-session binding * - `session-affinity-idle-ttl-ms` / `sessionAffinityIdleTtlMs` — idle unbind * - `spill-inflight` / `spillInflight` — overflow threshold for sticky sessions * * Accepts both camelCase and kebab-case keys for YAML-friendliness. */ export declare function parseRoutingConfig(raw: Record<string, unknown> | undefined): Partial<ProxyRoutingConfig> | undefined; /** * Load and parse a proxy configuration file (YAML or JSON). * * @param filePath - Absolute or relative path to the config file. * @param options - Optional settings for env resolution. * @returns Parsed and validated ProxyConfigFile. * @throws When the file cannot be read, parsed, or fails validation. */ export declare function loadProxyConfig(filePath: string, options?: LoadProxyConfigOptions): Promise<ProxyConfigFile>; /** * Load proxy config from a raw string (YAML or JSON) instead of a file path. * Useful for testing or when config is stored in environment variables. */ export declare function parseProxyConfigString(content: string, options?: LoadProxyConfigOptions): Promise<ProxyConfigFile>;