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

26 lines (25 loc) • 1.26 kB
/** * toolEndEmitter — shared helper for emitting `tool:end` events from * AI-SDK `onStepFinish` callbacks. * * Pipeline B (metrics aggregator) listens for `tool:end` on the NeuroLink * EventEmitter. When tools are executed by the AI SDK internally (via * `generateText` / `streamText`) the SDK calls `onStepFinish` with the * completed tool results. Without this helper those results are silently * stored but never surfaced as `tool:end` events, leaving Pipeline B with * zero tool spans for AI-SDK-driven tool calls (gaps G5 and S2). * * @module utils/toolEndEmitter */ import type { NeuroLinkEvents, StepToolResult, TypedEventEmitter } from "../types/index.js"; /** * Emit a `tool:end` event for every completed tool result in an * `onStepFinish` callback. * * @param emitter - The NeuroLink event emitter (obtained via * `neurolink.getEventEmitter()`). When `undefined` the function is a * no-op so callers need not guard every call site. * @param toolResults - The `toolResults` array from `onStepFinish`. When * `undefined` or empty the function is a no-op. */ export declare function emitToolEndFromStepFinish(emitter: TypedEventEmitter<NeuroLinkEvents> | undefined, toolResults: StepToolResult[] | undefined): void;