@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
37 lines (36 loc) • 1.88 kB
TypeScript
/**
* The set of top-level branches on a `StreamOptions` / `GenerateOptions`
* / `DynamicOptions` bag that downstream prep stages mutate. Listed here
* once so the runtime clone (`cloneOptionsForCallIsolation`) and any
* future test that wants to assert call isolation reference the same
* source of truth.
*
* If you add a new top-level field to `StreamOptions` that gets mutated
* by prepareStreamOptions / applyStreamOrchestration / RAG/MCP injection
* / memory retrieval / etc., add it here AND add an entry to
* `test/helpers/cloneOptions.test.ts` so the isolation guarantee gets
* exercised.
*
* Branches that are deliberately NOT cloned (and why):
* - `signal` / `abortSignal` — `AbortSignal` can't be `structuredClone`d
* and a shallow copy would strip the listener wiring.
* - `tools[name].execute` — function identity is used as a cache key
* downstream; cloning would break that.
* - schema objects (zod / JSON Schema) — large, frequently frozen,
* and not mutated by NeuroLink internals.
*/
export declare const CLONE_MUTABLE_OPTION_BRANCHES: readonly ["input", "context", "memory", "tools", "middleware", "rag", "csvOptions", "stt", "tts"];
/**
* Defensive call-isolation clone for stream() / generate()-shaped inputs.
*
* Shallow-clones the top-level options bag plus every branch listed in
* `CLONE_MUTABLE_OPTION_BRANCHES`. Caller-supplied objects can be reused
* across calls without accumulating cross-call mutations from
* prepareStreamOptions, applyStreamOrchestration, memory retrieval, or
* RAG/MCP tool injection.
*
* Unclonable / by-reference values are deliberately kept by-reference —
* cloning them would either fail outright (`structuredClone(AbortSignal)`)
* or strip behavior (function identity used as a cache key).
*/
export declare function cloneOptionsForCallIsolation<T>(options: T): T;