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

59 lines (58 loc) • 3.33 kB
/** * Task checklist primitive (N1) — session-scoped, compaction-proof. * * A long-running agent that plans in prose loses the plan the moment the * conversation is summarized. This keeps the plan OUT of the message list: * checklist state lives in a module-level Map keyed by sessionId, so * compaction — which only ever rewrites messages — cannot touch it. Every * `tasks_*` tool returns the WHOLE list, so the first call after a compaction * re-anchors the model for free; there is no re-injection machinery to get * wrong (N1.3 is satisfied structurally, not by a mechanism). * * The host reads the same state synchronously via `getChecklistState()`, which * is what makes a completeness gate ("no pending items may survive this * stage") one line of host code with no LLM in the loop. * * Registration is opt-in (`NeuroLink.registerTaskTools()`), and goes through * `host.registerTool()` so the tools land in the "user-defined" category — * the only one that reaches the LLM's tool schema. */ import type { NeuroLink } from "../neurolink.js"; import type { ChecklistCommandCountsSource, ChecklistDelegateCountsSource, ChecklistState, MCPExecutableTool } from "../types/index.js"; /** * Let the async-delegation primitive feed `delegatesPending` / `delegatesReady` * into every checklist result, so the model learns a worker finished from any * `tasks_list` — without this module importing delegation (which would make a * cycle) and without a polling loop. */ export declare function setChecklistDelegateCountsSource(source: ChecklistDelegateCountsSource | undefined): void; /** * Let the background-command primitive feed `commandsRunning` / * `commandsFinished` into every checklist result — the same notification * channel the delegate counters use, so the model learns "the build finished" * from any `tasks_list` without this module importing the command runtime * (which would make a cycle) and without a polling loop. */ export declare function setChecklistCommandCountsSource(source: ChecklistCommandCountsSource | undefined): void; /** * Which checklist a tool call belongs to. * * Execution context wins: a worker created with the shared tool registry runs * the host's registered tool closure but arrives with its OWN sessionId, and * that worker's checklist must not merge into its parent's. The host's * `setToolContext()` session is the next authority, and a per-host key is the * last resort so a host that never declared a session still gets ONE list * instead of a new one per call. */ export declare function resolveChecklistSessionId(host: NeuroLink, context?: unknown): string; /** Never throws: an unknown session simply has an empty checklist. */ export declare function getChecklistState(sessionId: string): ChecklistState; /** Drop one session's checklist. Returns whether there was one to drop. */ export declare function clearChecklistState(sessionId: string): boolean; /** * The three model-facing checklist tools, bound to `host` for session * resolution. Register them with `host.registerTool()` (see * `NeuroLink.registerTaskTools()`), never on the tool registry directly: * only the "user-defined" category reaches the LLM's tool schema. */ export declare function createChecklistTools(host: NeuroLink): Record<string, MCPExecutableTool>;