@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
331 lines (330 loc) • 9.88 kB
TypeScript
import type { AllToolsMap, FileToolRootPolicy, BasicToolsMap, FilesystemToolsMap, Tool, UtilityToolsMap } from "../types/index.js";
/**
* Vertex location for the websearchGrounding tool:
* NEUROLINK_WEBSEARCH_LOCATION, else `global`.
*
* Deliberately does NOT inherit GOOGLE_VERTEX_LOCATION. The search models are
* served only from the `global`, `us` and `eu` endpoints — never from a single
* region — so inheriting a regional value produces a 404 for the model rather
* than a working search. That is not hypothetical: a deployment pinned to
* us-east5 for Claude-on-Vertex sent web search to us-east5 too and every
* query failed with NOT_FOUND.
*
* Set NEUROLINK_WEBSEARCH_LOCATION to `us` or `eu` where the multi-region
* endpoints are required, e.g. for data residency.
*/
export declare function resolveWebsearchLocation(): string;
/** Model for websearchGrounding — NEUROLINK_WEBSEARCH_MODEL, else the default. */
export declare function resolveWebsearchModel(): string;
/**
* The generateContent request for a web search. Google Search grounding is
* requested natively through `config.tools`.
*/
export declare function buildWebsearchRequest(model: string, query: string, maxWords: number): {
model: string;
contents: {
role: string;
parts: {
text: string;
}[];
}[];
config: {
tools: {
googleSearch: {};
}[];
};
};
/**
* Display domain for one grounding chunk.
*
* Blank `domain` values count as absent, and the uri fallback is guarded by
* `URL.canParse` — an unparseable provider uri would otherwise throw and take
* the entire search down with it.
*/
export declare function resolveGroundingDomain(web: {
uri?: string;
domain?: string;
}): string;
/**
* Map grounding chunks onto search results, capped at `limitedResults`.
* Returns an empty array when there is no usable grounding metadata, which the
* caller replaces with a single synthesised result.
*/
export declare function buildWebsearchResults(groundingMetadata: {
groundingChunks?: {
web?: {
uri?: string;
title?: string;
domain?: string;
};
}[];
} | undefined, searchContent: string, limitedResults: number): {
title: string;
url: string;
snippet: string;
domain: string;
}[];
/**
* Direct tool definitions that work immediately with Gemini/AI SDK.
* These bypass MCP complexity and provide reliable agent functionality.
*
* `createDirectAgentTools` builds a fresh set bound to `policy`; the shared
* `directAgentTools` below keeps the working-directory default.
*/
export declare function createDirectAgentTools(policy: FileToolRootPolicy): {
getCurrentTime: Tool<{
timezone?: string | undefined;
}, {
success: boolean;
time: string;
timezone: string;
iso: string;
timestamp?: undefined;
error?: undefined;
} | {
success: boolean;
time: string;
iso: string;
timestamp: number;
timezone?: undefined;
error?: undefined;
} | {
success: boolean;
error: string;
time?: undefined;
timezone?: undefined;
iso?: undefined;
timestamp?: undefined;
}>;
readFile: Tool;
listDirectory: Tool;
calculateMath: Tool<{
expression: string;
precision: number;
}, {
success: boolean;
error: string;
expression?: undefined;
result?: undefined;
type?: undefined;
} | {
success: boolean;
expression: string;
result: any;
type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
error?: undefined;
} | {
success: boolean;
error: string;
expression: string;
result?: undefined;
type?: undefined;
}>;
writeFile: Tool;
analyzeCSV: Tool;
websearchGrounding: Tool<{
query: string;
maxResults: number;
maxWords: number;
}, {
success: boolean;
error: string;
requiredEnvVars: string[];
query?: undefined;
searchResults?: undefined;
rawContent?: undefined;
totalResults?: undefined;
provider?: undefined;
model?: undefined;
responseTime?: undefined;
timestamp?: undefined;
grounded?: undefined;
} | {
success: boolean;
error: string;
query: string;
requiredEnvVars?: undefined;
searchResults?: undefined;
rawContent?: undefined;
totalResults?: undefined;
provider?: undefined;
model?: undefined;
responseTime?: undefined;
timestamp?: undefined;
grounded?: undefined;
} | {
success: boolean;
query: string;
searchResults: {
title: string;
url: string;
snippet: string;
domain: string;
}[];
rawContent: string;
totalResults: number;
provider: string;
model: string;
responseTime: number;
timestamp: number;
grounded: boolean;
error?: undefined;
requiredEnvVars?: undefined;
} | {
success: boolean;
error: string;
query: string;
provider: string;
requiredEnvVars?: undefined;
searchResults?: undefined;
rawContent?: undefined;
totalResults?: undefined;
model?: undefined;
responseTime?: undefined;
timestamp?: undefined;
grounded?: undefined;
}>;
};
/**
* Bash command execution tool - exported separately for opt-in use.
*
* SECURITY: This tool is NOT included in directAgentTools by default.
* It must be explicitly enabled via:
* - Environment variable: NEUROLINK_ENABLE_BASH_TOOL=true
* - Config: toolConfig.enableBashTool = true
*
* Import this directly when you need bash execution capabilities:
* import { bashTool } from '../agent/directTools.js';
*/
export declare function createBashTool(policy: FileToolRootPolicy): Tool;
/** The opt-in bash tool with the working-directory default. */
export declare const bashTool: Tool;
export declare const directAgentTools: {
getCurrentTime: Tool<{
timezone?: string | undefined;
}, {
success: boolean;
time: string;
timezone: string;
iso: string;
timestamp?: undefined;
error?: undefined;
} | {
success: boolean;
time: string;
iso: string;
timestamp: number;
timezone?: undefined;
error?: undefined;
} | {
success: boolean;
error: string;
time?: undefined;
timezone?: undefined;
iso?: undefined;
timestamp?: undefined;
}>;
readFile: Tool;
listDirectory: Tool;
calculateMath: Tool<{
expression: string;
precision: number;
}, {
success: boolean;
error: string;
expression?: undefined;
result?: undefined;
type?: undefined;
} | {
success: boolean;
expression: string;
result: any;
type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
error?: undefined;
} | {
success: boolean;
error: string;
expression: string;
result?: undefined;
type?: undefined;
}>;
writeFile: Tool;
analyzeCSV: Tool;
websearchGrounding: Tool<{
query: string;
maxResults: number;
maxWords: number;
}, {
success: boolean;
error: string;
requiredEnvVars: string[];
query?: undefined;
searchResults?: undefined;
rawContent?: undefined;
totalResults?: undefined;
provider?: undefined;
model?: undefined;
responseTime?: undefined;
timestamp?: undefined;
grounded?: undefined;
} | {
success: boolean;
error: string;
query: string;
requiredEnvVars?: undefined;
searchResults?: undefined;
rawContent?: undefined;
totalResults?: undefined;
provider?: undefined;
model?: undefined;
responseTime?: undefined;
timestamp?: undefined;
grounded?: undefined;
} | {
success: boolean;
query: string;
searchResults: {
title: string;
url: string;
snippet: string;
domain: string;
}[];
rawContent: string;
totalResults: number;
provider: string;
model: string;
responseTime: number;
timestamp: number;
grounded: boolean;
error?: undefined;
requiredEnvVars?: undefined;
} | {
success: boolean;
error: string;
query: string;
provider: string;
requiredEnvVars?: undefined;
searchResults?: undefined;
rawContent?: undefined;
totalResults?: undefined;
model?: undefined;
responseTime?: undefined;
timestamp?: undefined;
grounded?: undefined;
}>;
};
/**
* Get a subset of tools for specific use cases with improved type safety
*/
export declare function getToolsForCategory(category: "basic"): BasicToolsMap;
export declare function getToolsForCategory(category: "filesystem"): FilesystemToolsMap;
export declare function getToolsForCategory(category: "utility"): UtilityToolsMap;
export declare function getToolsForCategory(category: "all"): AllToolsMap;
/**
* Get tool names for validation
*/
export declare function getAvailableToolNames(): string[];
/**
* Validate that all tools have proper structure
*/
export declare function validateToolStructure(): boolean;