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

37 lines (36 loc) • 1.96 kB
/** * Tool output preview generation. * Generates head/tail previews of large tool outputs for context-efficient LLM calls. * @module */ import type { ToolOutputPreviewOptions, ToolOutputPreviewResult } from "../types/index.js"; /** Default maximum preview size in bytes (50KB) */ export declare const DEFAULT_MAX_PREVIEW_BYTES: number; /** Default maximum preview lines */ export declare const DEFAULT_MAX_PREVIEW_LINES = 2000; /** Default head ratio (25% of preview budget) */ export declare const DEFAULT_HEAD_RATIO = 0.25; /** Tool name referenced in truncation notices for on-demand full-output access */ export declare const RETRIEVE_CONTEXT_TOOL_NAME = "retrieve_context"; /** Default tail ratio (75% of preview budget) */ export declare const DEFAULT_TAIL_RATIO = 0.75; /** * True when `generateToolOutputPreview` would actually shrink this output. * * Callers gate on this before paying for a preview. It exists so the gate and * the generator can never disagree: the budget is expressed in BYTES, and * testing it against `String.length` (UTF-16 code units) under-reports every * multibyte payload — CJK or emoji tool output would be judged small enough to * leave alone while the generator would have truncated it. Line count matters * for the same reason: a short-but-tall output exceeds `maxLines` alone. */ export declare function exceedsToolOutputPreviewBudget(output: string, options?: ToolOutputPreviewOptions): boolean; /** * Generate a head/tail preview of a tool output string. * If the output is within limits, returns it unchanged with truncated: false. * If over limits, keeps the first 25% and last 75% with an omission notice. * * Industry pattern: 25/75 head/tail split. Head captures schema/headers/structure, * tail captures the most recent and typically most relevant data. */ export declare function generateToolOutputPreview(output: string, options?: ToolOutputPreviewOptions): ToolOutputPreviewResult;