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

34 lines (33 loc) • 2.2 kB
import type { NativeAnthropicToolDeclaration, NativeToolDeclarationsResult, Tool } from "../types/index.js"; /** * Convert a NeuroLink tool record into the wire-format a native * (non-AI-SDK) provider SDK expects. Absorbs the direct-Anthropic * provider's `toolsToAnthropic` — previously duplicated between the * streaming loop's pre-loop snapshot and its mid-turn discovery-hydration * call site (both in anthropic/client.ts). Gemini's `functionDeclarations` * shape was already centralized in `buildNativeToolDeclarations`; this * function is a thin facade over it so every native provider calls one * entry point. * * Scope note: Vertex's Claude-on-Vertex `input_schema` builder * (`buildAnthropicToolDeclaration` in googleVertex/client.ts) is * deliberately NOT routed through this function. Despite the superficial * similarity, it is not a byte-for-byte duplicate of `toolsToAnthropic`: it * strips the converted schema down to `{type, properties, required}` only * (dropping any other JSON-Schema keywords `convertZodToJsonSchema` may * produce), it always runs `inlineJsonSchema` (Anthropic-direct never has), * it prefers `parameters` over `inputSchema` (the opposite fallback order * from Anthropic-direct), and it has no `cache_control` support of its own * because Vertex applies cache breakpoints later via the separate * `applyVertexAnthropicCacheBreakpoints` pass. Collapsing these into one * shared implementation would risk a live tool-calling regression on one * provider or the other; see the Task 2 report for the full comparison. * * These are genuine TS overload declarations, not redeclarations: the base * `no-redeclare` ESLint rule doesn't understand the overload-signatures + * implementation pattern (the TS-aware `@typescript-eslint/no-redeclare` * variant would, but isn't enabled project-wide), so each signature below * is individually exempted. */ export declare function toNativeToolDeclarations(tools: Record<string, Tool>, format: "input_schema"): NativeAnthropicToolDeclaration[] | undefined; export declare function toNativeToolDeclarations(tools: Record<string, Tool>, format: "functionDeclarations"): NativeToolDeclarationsResult;