@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
55 lines (54 loc) • 2.89 kB
TypeScript
/**
* Implicit `.env` bootstrap for the CLI, and an explicit one for SDK hosts.
*
* Who loads `.env`:
*
* - The **CLI** loads `<cwd>/.env` at startup (or `DOTENV_CONFIG_PATH`),
* because a terminal session in a project directory is the use case the
* file exists for. `NEUROLINK_DOTENV=0` turns that off.
* - The **SDK** does not. Importing a library must not read the working
* directory: a dependency that runs inside an untrusted checkout would
* otherwise pick up that checkout's `.env`. A host that wants the old
* behaviour calls `loadDotenv()` itself, or starts the process with
* `NEUROLINK_DOTENV=1` in the real environment (the variable cannot come
* from the file it enables).
*
* What is refused even when a file is loaded. dotenv never overrides a
* variable that is already set, but it sets every one that is not — and
* among those are the variables that decide *where* a request goes: the
* provider `*_BASE_URL` / `*_ENDPOINT(S)` overrides, `NEUROLINK_*_DIR`
* directories, and `DOTENV_CONFIG_PATH`. A `.env` that supplies one of them
* can redirect a key exported in the shell to a host of its choosing. So,
* for exactly those names, the file has to be trustworthy: owned by the
* current user and not group/world-writable. Otherwise they are deleted
* again and named on stderr. When they are kept, a one-line notice says
* which ones the file set.
*
* `DOTENV_CONFIG_PATH` is honoured because a direct `config()` call does not
* read it on its own (only dotenv's `dotenv/config` preload does), and the
* test strip `DOTENV_CONFIG_PATH=/dev/null` depends on it (#1744).
*/
import type { DotenvBootstrapOptions, DotenvBootstrapResult } from "../types/index.js";
/** `0` / `false` disables every implicit load; `1` / `true` opts the SDK in. */
export declare const DOTENV_TOGGLE_ENV = "NEUROLINK_DOTENV";
/**
* Names whose value decides where traffic or file access goes. Built from
* the provider descriptors at load time as well (see
* `collectDescriptorEndpointEnvNames`); this pattern is the floor that
* holds even when the descriptors cannot be imported.
*/
export declare const ENDPOINT_OVERRIDE_ENV_PATTERN: RegExp;
/** True when `NEUROLINK_DOTENV` explicitly opts an SDK import into loading. */
export declare function isSdkDotenvOptIn(): boolean;
/**
* Load `.env` into `process.env` under the rules in this module's header and
* report what happened. Never throws: a missing dotenv module degrades to
* "nothing loaded".
*/
export declare function loadProcessDotenv(options?: DotenvBootstrapOptions): Promise<DotenvBootstrapResult>;
/**
* Explicit opt-in for SDK hosts that want `.env` loaded the way the CLI does,
* with the same endpoint-override checks. Call it before constructing
* `NeuroLink`.
*/
export declare function loadDotenv(options?: DotenvBootstrapOptions): Promise<DotenvBootstrapResult>;