@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
22 lines (21 loc) • 1.39 kB
TypeScript
import type { AgenticLoopAdapter, AgenticLoopChunk, AgenticLoopOptions, AgenticLoopResult } from "../types/index.js";
/**
* Run one adapter-parameterized agentic tool-calling turn. Owns the
* maxSteps-bounded loop, generic tool dispatch (with an opt-in
* TOOL_NOT_FOUND/failure-strike breaker — see AgenticLoopAdapter.toolFailureBreaker),
* per-step usage accumulation, a single optional malformed-call retry,
* chunk emission through streamChannel, and a pre-first-chunk 429/5xx
* retry (via withProviderRetry) around every adapter.executeStep() call.
* The retry wrap is unconditional and adapter-agnostic — every migrated
* provider gets it for free, not just the ones that had a hand-rolled
* version before migration (see Verified Fact 4-adjacent note in Task 4
* Step 1 and the Risks & Rollback "Deliberate behavior changes" list for
* which families are gaining this for the first time). Everything
* wire-format-specific (building the request, parsing the SDK response,
* serializing tool results back into the conversation, mapping the raw
* stop reason) is delegated to `adapter`.
*/
export declare function runAgenticLoop<TConversation>(adapter: AgenticLoopAdapter<TConversation>, initialConversation: TConversation, options: AgenticLoopOptions): {
stream: AsyncIterable<AgenticLoopChunk>;
resultPromise: Promise<AgenticLoopResult<TConversation>>;
};