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

32 lines (31 loc) • 1.38 kB
import { buildNativeToolDeclarations } from "../providers/googleNativeGemini3/utils.js"; import { cacheControlOf } from "../providers/anthropic/cacheControl.js"; import { convertZodToJsonSchema } from "../utils/schemaConversion.js"; // eslint-disable-next-line no-redeclare -- TS overload implementation signature, not a redeclaration export function toNativeToolDeclarations(tools, format) { if (format === "functionDeclarations") { return buildNativeToolDeclarations(tools); } const entries = Object.entries(tools ?? {}); if (entries.length === 0) { return undefined; } return entries.map(([name, tool]) => { const t = tool; const rawSchema = t.inputSchema ?? t.parameters; const input_schema = (rawSchema ? convertZodToJsonSchema(rawSchema) : { type: "object", properties: {} }); // Honor a cache breakpoint the caller set on this tool. Closing the // stable prefix is a separate step: both Anthropic paths call // `withLastToolCacheBreakpoint` on the assembled array afterwards. const cc = cacheControlOf(tool); const declaration = { name, ...(t.description ? { description: t.description } : {}), input_schema, ...(cc ? { cache_control: cc } : {}), }; return declaration; }); }