import { TurnContext } from "./contracts/turn_runner_context"; import type { RawDispatchContext } from "./contracts/dispatch_context"; import type { DispatchPipelineMiddlewareFn, DispatchExecutorFn, DispatchRunnerFunctionalHookRegistrations, DispatchRunnerObservabilityHookRegistrations } from "./types/dispatch_runner"; /** * Plain input object supplied to {@link DispatchRunner.dispatch}. * * @remarks * Exactly one of `source` or `raw` is required: * * - `source` — switches to the **derived path**. The runner snapshots primitives from the * provided {@link @nhtio/adk!TurnContext}, wires all fetch/refresh/mutation callbacks to delegate to it, * forwards emits back to its buses, and bubbles mutations to its Sets at the end of every * iteration. * * - `raw` — switches to the **standalone path**. The runner constructs an {@link @nhtio/adk!DispatchContext} * directly from the provided raw input. No parent relationship exists; mutations are not bubbled. * * The `executor` is the user-provided callback that performs the actual LLM API call between the * input and output middleware pipelines on every iteration. */ export interface RawDispatchRunnerInput { /** Source {@link @nhtio/adk!TurnContext} to derive the execution context from. Mutually exclusive with `raw`. */ source?: TurnContext; /** Raw input for a standalone {@link @nhtio/adk!DispatchContext}. Mutually exclusive with `source`. */ raw?: Omit; /** User-provided callback that makes the LLM API call. Invoked between input and output pipelines on every iteration. */ executor: DispatchExecutorFn; /** Input middleware functions, executed in order before the executor on every iteration. */ turnInputPipeline?: DispatchPipelineMiddlewareFn[]; /** Output middleware functions, executed in order after the executor on every iteration. */ turnOutputPipeline?: DispatchPipelineMiddlewareFn[]; /** Optional functional hook registrations: message, thought, toolCall. */ hooks?: DispatchRunnerFunctionalHookRegistrations; /** Optional observability hook registrations: lifecycle events + tool execution + error. */ observers?: DispatchRunnerObservabilityHookRegistrations; } /** * Runs a single dispatch iteration of an agentic turn: it drives the executor through the * input/output middleware pipelines, emitting functional and observability hook events along the * way. Construction is gated — obtain one via the static {@link DispatchRunner.dispatch} entry * point rather than `new`. */ export declare class DispatchRunner { #private; /** * Returns `true` if `value` is a {@link DispatchRunner} instance. * * @remarks * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety. * * @param value - The value to test. * @returns `true` when `value` is a {@link DispatchRunner} instance. */ static isDispatchRunner(value: unknown): value is DispatchRunner; /** * Dispatches a single LLM execution. * * @remarks * Constructs an {@link @nhtio/adk!DispatchContext} (derived from `source` or from `raw`), runs the * iteration loop, and resolves when middleware/executor signals completion via `ctx.ack()` or * the abort signal fires. Rejects with the nack error when middleware/executor calls * `ctx.nack(err)`. Pipeline and executor errors are wrapped, surfaced on the observability * `error` hook, and re-thrown. * * @param input - The dispatch input. Provide either `source` (derived path) or `raw` (standalone). * @throws {@link @nhtio/adk!E_INVALID_LLM_DISPATCH_INPUT} when the input does not satisfy validation, or * when neither `source` nor `raw` is provided, or when both are provided. */ static dispatch(input: RawDispatchRunnerInput): Promise; }