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

153 lines (152 loc) • 8.1 kB
import type { SpanModelRequest } from "../types/index.js"; export declare const ATTR: { readonly GEN_AI_SYSTEM: "gen_ai.system"; readonly GEN_AI_MODEL: "gen_ai.request.model"; readonly GEN_AI_OPERATION: "gen_ai.operation.name"; readonly GEN_AI_OBSERVATION: "gen_ai.observation.type"; readonly GEN_AI_INPUT_TOKENS: "gen_ai.usage.input_tokens"; readonly GEN_AI_OUTPUT_TOKENS: "gen_ai.usage.output_tokens"; readonly GEN_AI_FINISH_REASON: "gen_ai.response.finish_reason"; readonly GEN_AI_COST_USD: "gen_ai.cost_usd"; readonly GEN_AI_TOOL_NAME: "gen_ai.tool.name"; readonly GEN_AI_TEMPERATURE: "gen_ai.request.temperature"; readonly GEN_AI_MAX_TOKENS: "gen_ai.request.max_tokens"; readonly NL_PROVIDER: "sdk.provider"; readonly NL_MODEL: "sdk.model"; readonly NL_STREAM_MODE: "stream_mode"; readonly NL_TOOL_COUNT: "tool_count"; readonly NL_MESSAGE_COUNT: "message_count"; readonly NL_HAS_TOOLS: "has_tools"; readonly NL_INPUT_LENGTH: "input_length"; readonly NL_OUTPUT_LENGTH: "output_length"; readonly NL_REQUEST_ID: "request_id"; readonly NL_PATH: "path"; readonly NL_HAS_MEMORY: "has_conversation_memory"; readonly NL_COST: "cost"; readonly NL_STRUCTURED_OUTPUT: "structured_output"; readonly NL_HAS_FALLBACK: "has_fallback"; readonly MCP_SERVER_ID: "mcp.server_id"; readonly MCP_TOOL_NAME: "mcp.tool_name"; readonly MCP_TIMEOUT_MS: "mcp.timeout_ms"; readonly MCP_TRANSPORT: "mcp.transport"; readonly MCP_CIRCUIT_STATE: "mcp.circuit_state"; readonly SESSION_ID: "session.id"; readonly USER_ID: "user.id"; readonly MEMORY_TYPE: "memory.type"; readonly MESSAGE_COUNT: "message.count"; readonly CONTENT_LENGTH: "content.length"; readonly RAG_FILE_COUNT: "rag.file_count"; readonly RAG_STRATEGY: "rag.strategy"; readonly RAG_CHUNK_SIZE: "rag.chunk_size"; readonly RAG_TOP_K: "rag.top_k"; readonly RAG_RESULT_COUNT: "rag.result_count"; readonly MSG_COUNT: "message.build.count"; readonly MSG_HAS_IMAGES: "message.has_images"; readonly MSG_HAS_FILES: "message.has_files"; readonly MSG_HAS_SYSTEM_PROMPT: "message.has_system_prompt"; readonly MSG_TOTAL_CONTENT_LENGTH: "message.total_content_length"; readonly MSG_IS_MULTIMODAL: "message.is_multimodal"; readonly FILE_NAME: "file.name"; readonly FILE_MIMETYPE: "file.mimetype"; readonly FILE_SIZE_BYTES: "file.size_bytes"; readonly FILE_CATEGORY: "file.category"; readonly FILE_OUTPUT_LENGTH: "file.output_length"; readonly FILE_SUCCESS: "file.success"; readonly FILE_PROCESSOR_USED: "file.processor_used"; readonly FILE_CONFIDENCE: "file.detection_confidence"; readonly FILE_HAS_IMAGES: "file.has_images"; readonly FILE_IMAGE_COUNT: "file.image_count"; readonly FILE_ERROR: "file.error"; readonly FILE_SKIPPED_REASON: "file.skipped_reason"; readonly FILE_TOTAL_COUNT: "file.total_count"; readonly FILE_INCLUDED_COUNT: "file.included_count"; readonly FILE_CONTENT_TYPE: "file.content_type"; readonly VIDEO_DURATION_SEC: "video.duration_sec"; readonly VIDEO_WIDTH: "video.width"; readonly VIDEO_HEIGHT: "video.height"; readonly VIDEO_CODEC: "video.codec"; readonly VIDEO_AUDIO_CODEC: "video.audio_codec"; readonly VIDEO_FORMAT: "video.format"; readonly VIDEO_BITRATE: "video.bitrate"; readonly VIDEO_KEYFRAMES_EXTRACTED: "video.keyframes_extracted"; readonly VIDEO_TARGET_FRAMES: "video.target_frames"; readonly VIDEO_INTERVAL_SEC: "video.interval_sec"; readonly VIDEO_FRAME_QUALITY: "video.frame_quality"; readonly VIDEO_FRAME_RESIZE_PX: "video.frame_resize_px"; readonly VIDEO_FRAMES_RESIZED: "video.frames_resized"; readonly VIDEO_TOTAL_FRAME_BYTES: "video.total_frame_bytes"; readonly VIDEO_HAS_SUBTITLES: "video.has_subtitles"; readonly VIDEO_SUBTITLE_LENGTH: "video.subtitle_length"; readonly VIDEO_TEXT_CONTENT_LENGTH: "video.text_content_length"; readonly VIDEO_HAS_METADATA: "video.has_metadata"; readonly VIDEO_HAS_KEYFRAMES: "video.has_keyframes"; readonly VIDEO_TEMP_PATH: "video.temp_path"; readonly VIDEO_BYTES_WRITTEN: "video.bytes_written"; readonly VIDEO_WRITE_DURATION_MS: "video.write_duration_ms"; readonly VIDEO_STEP: "video.step"; readonly CONTEXT_STAGE: "context.compaction_stage"; readonly CONTEXT_TOKENS_BEFORE: "context.tokens_before"; readonly CONTEXT_TOKENS_AFTER: "context.tokens_after"; readonly MW_COUNT: "middleware.count"; readonly MW_NAMES: "middleware.names"; readonly AR_TAG: "autoresearch.tag"; readonly AR_BRANCH: "autoresearch.branch"; readonly AR_PHASE: "autoresearch.phase"; readonly AR_PHASE_FROM: "autoresearch.phase_from"; readonly AR_PHASE_TO: "autoresearch.phase_to"; readonly AR_RUN_COUNT: "autoresearch.run_count"; readonly AR_KEEP_COUNT: "autoresearch.keep_count"; readonly AR_STATUS: "autoresearch.status"; readonly AR_METRIC: "autoresearch.metric"; readonly AR_BEST_METRIC: "autoresearch.best_metric"; readonly AR_DIRECTION: "autoresearch.metric_direction"; readonly AR_COMMIT: "autoresearch.commit"; readonly AR_DURATION_MS: "autoresearch.duration_ms"; readonly AR_DESCRIPTION: "autoresearch.description"; readonly AR_ERROR_CODE: "autoresearch.error_code"; }; /** Default ceiling for serialized span attribute values. */ export declare const SPAN_ATTRIBUTE_MAX_CHARS = 40000; /** * The ceiling in force: `NEUROLINK_SPAN_ATTRIBUTE_MAX_CHARS` when it is a * positive whole number (raised to the minimum if lower), otherwise the * default. Read on every call, so a change applies to the next span. */ export declare function spanAttributeMaxChars(): number; /** * @description Returns a copy of a value with credentials masked: values under keys such as `access_token`, `password`, `authorization` or `set-cookie`, bearer tokens, and `name=value` credentials inside text. Purely numeric values after a credential-looking name (e.g. `max_tokens: 4096`) are left alone. * @param value {JsonValue | object} - Content to redact; objects and arrays are walked recursively. * @returns {JsonValue | object} A redacted copy, serializing exactly as the input when nothing in it is sensitive. * @throws {Error} When the value cannot be walked; tracing callers use `spanContentAttribute`, which turns that into an omitted value. */ export declare function redactSpanContent(value: unknown): unknown; /** * `spanJsonAttribute` for content a person or model wrote or a tool returned * (arguments, results, answers), with credentials masked first. Use the plain * form for metadata such as usage counts and server ids. * * A structured value over the cap is shortened by cutting every string to a * per-string budget in one walk, tightening the budget only if the result * still does not fit, so the attribute stays valid JSON instead of ending * mid-token. */ export declare function spanContentAttribute(value: unknown, maxChars?: number): string; /** * Serialize an arbitrary value for a span attribute, hard-capped at * `maxChars` so a pathological prompt or tool result can't put megabytes * on a single span. Strings pass through unserialized; everything else is * JSON-stringified with a String() fallback for circular structures. */ export declare function spanJsonAttribute(value: unknown, maxChars?: number): string; /** * Serialize a model request for a span attribute without losing the * conversation to the cap. * * A head cut keeps the system prompt and drops everything after it, so a long * system prompt hides every message, the user's question included. Here the * prompt, the current question and this turn's newest messages are budgeted * first, earlier messages are dropped whole and counted, and the system prompt * gets whatever room is left. A tool result is never kept without the call it * answers. The result is always valid JSON. */ export declare function spanModelRequestAttribute(rawRequest: SpanModelRequest, maxChars?: number): string;