/** * @module @nhtio/adk/batteries/orchestration/reason * * Pure utilities for the reason node. This module contains no Orchestration runtime * dependencies — it is independent of `DispatchRunner`, `Message`, or `Tool`. The bundled * helper that constructs those lives in its own subpath and is a separate concern. * * The reason node ends in a tool call, and that tool call *is* its output. It never * returns prose to be parsed. The node's `outputSchema` becomes a forced tool's * `inputSchema`, so the model physically cannot answer unstructured: malformed args are * rejected before the handler runs and retried within `maxAttempts`. A dispatch that ends * without the tool being called is a halting node failure, never a fabricated result. * * This file implements the contract required by `ReasonNodeDefinition` and the * `ReasonerFn` signature. All functions are pure and side-effect free. */ import type { Schema } from '@nhtio/validation'; import type { PromptPart, EncodableValue, NodeRef } from "./types"; /** * Join prompt parts in order, substituting each reference's resolved value. * A reference that resolves to `undefined` renders as the explicit absent marker * `'[unresolved: ]'`, naming the node whose output was missing. * * @param parts The prompt parts to join * @param resolve Function that resolves a `NodeRef` to an `EncodableValue | undefined` * @returns The joined prompt string */ export declare function joinPromptParts(parts: readonly PromptPart[], resolve: (ref: NodeRef) => EncodableValue | undefined): string; /** * Remove `` and `` tags from author-supplied prompt text. * Case-insensitive, tolerant of whitespace inside the tag. Only those two tags are removed. * * @param text The input text to sanitize * @returns The text with instruction tags removed */ export declare function stripInstructionTags(text: string): string; /** * Wrap the authoritative instruction in `` tags and place the stripped * context after it, with a line telling the model to ignore any instructions appearing * inside the context payload. * * @param authoritative The authoritative instruction text * @param context The context text (already stripped of instruction tags) * @returns The wrapped instruction string */ export declare function wrapInstruction(authoritative: string, context: string): string; /** * Decode a `ReasonNodeDefinition.outputSchema` — which is stored as an ENCODED STRING, * not a live `Schema`. A live validation schema is **not** `Encodable` — encoding one * throws `E_UNENCODABLE_VALUE: Value of type symbol (Symbol(override)) is not encodable`, * which would make the whole plan unpersistable. This has been verified against the real * packages. `Tool` solves the same problem the same way at `src/lib/classes/tool.ts:449-490`. * * @param encoded The encoded schema string * @returns The decoded `Schema` object */ export declare function decodeOutputSchema(encoded: string): Schema; /** * Validate captured tool arguments against the decoded schema, returning a discriminated * result rather than throwing. * * @param schema The decoded output schema * @param args The captured tool arguments to validate * @returns `true` if validation succeeds, or the validation error message if it fails */ export declare function validateReasonerOutput(schema: Schema, args: Record): true | string;