@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
27 lines (26 loc) • 1.59 kB
TypeScript
/**
* Direct Anthropic's adapter onto the shared agentic loop engine.
*
* Everything here is the wire-format half of the turn: building one Messages
* request, folding an SSE event sequence into content blocks, serializing tool
* results back into the conversation, and mapping the stop reason. The turn
* loop, the step cap, tool dispatch, retry and usage accumulation belong to
* `runAgenticLoop`.
*
* Two behaviours here are easy to lose in a migration and are called out
* because losing either is silent:
*
* - Thinking deltas ride the channel as `{ content: "", reasoning }`. The
* engine's chunk type carries `reasoning` for exactly this reason; a
* channel that only understood `content` would drop every thinking delta
* while the text path kept working.
* - `resolveToolOnMiss` is wired to real deferred-catalog hydration, not as
* interface decoration. The pre-migration loop resolves every tool call as
* `toolsRecord[name] ?? resolveDeferredTool(toolsRecord, name)`, which is
* how a cataloged tool the model calls without having loaded it via
* `search_tools` gets found. Dropping it would break those tools with a
* "Tool not found" that looks like a hallucination.
*/
import type Anthropic from "@anthropic-ai/sdk";
import type { AgenticLoopAdapter, AnthropicLoopAdapterConfig } from "../../types/index.js";
export declare function createAnthropicLoopAdapter<TMessage = Anthropic.Messages.MessageParam>(config: AnthropicLoopAdapterConfig<TMessage>): AgenticLoopAdapter<TMessage[], Anthropic.Messages.ContentBlockParam[]>;