import type { AiMessage, AiResponse, AiToolCall, CancelCause, DecisionVerdict, HistorySummaryRecord, Injection, LLMBehaviorResult, LLMContextRequest, LLMContextSnapshot, LlmClient, Observation, StepDecision, StepRecord, Tokenizer, ToolPolicy, ToolSpecLite, WorkEvent } from './types'; import type { JsonValue } from './types'; /** Per-call context handed to `ToolManager.callTool`: the run's interrupt / finish signals and deadline. */ export interface ToolCallCtx { /** Aborts on interrupt or once the run deadline passed (not on a graceful finish). */ readonly signal: AbortSignal; /** Epoch ms by which the run's wallclock budget ends, if any. */ readonly deadline_ms?: number; /** The cause currently in force, if any (`deadline` only once it passed). */ cause(): CancelCause | undefined; /** Resolves when the call should stop: interrupt, graceful finish or deadline. */ cancelled(): Promise; /** Resolves on interrupt or deadline only. */ cancelledHard(): Promise; } /** A dispatch infrastructure failure (`Err(ToolDispatchError)`); `effect_unknown` whenever the call may have started. */ export declare class ToolDispatchException extends Error { readonly effect_unknown: boolean; constructor(message: string, effectUnknown: boolean); } /** * Effect-side dispatcher. Resolves with a terminal observation (`error` is a * business failure the model can react to); rejects with a * `ToolDispatchException` for an infrastructure failure. On resume a call of * an unfinished batch is dispatched again with the same `call_id`: the * manager looks for the earlier work first and answers `unresolved` instead * of running a non-idempotent tool again. */ export interface ToolManager { callTool(call: AiToolCall, ctx: ToolCallCtx): Promise; listToolSpecs(): ToolSpecLite[]; } /** Policy gate; a rejection (a thrown message) is fed back as a correctable error. */ export interface PolicyEngine { gateToolCalls(request: LLMContextRequest, calls: AiToolCall[]): Promise; gateActionCalls?(request: LLMContextRequest, calls: AiToolCall[]): Promise; } export interface WorklogSink { emit(event: WorkEvent): void | Promise; } /** * The host's checkpoint hook, always called with the outer snapshot: * `beforeToolCall` before every tool call / action, `beforeInference` at * every inference boundary (resolve with an injection to add input; reject * to stop the run with a checkpoint error). */ export interface CheckpointHook { beforeToolCall?(snapshot: LLMContextSnapshot): Promise; beforeInference(snapshot: LLMContextSnapshot): Promise; validateReport?(snapshot: LLMContextSnapshot, result: LLMBehaviorResult, stepIndex: number): Promise; reviewDecision?(snapshot: LLMContextSnapshot, result: LLMBehaviorResult, stepIndex: number, decision: StepDecision): Promise; } /** Host check of a reply that met the reply contract's schema; reject with the message the model should fix. */ export interface OutputValidator { validate(reply: JsonValue): Promise; } /** Behavior loop: structured parser for model responses (rejects with the parse error). */ export interface LLMResultParser { parse(response: AiResponse): LLMBehaviorResult; } /** Behavior loop: renders sedimented steps back into messages for the next inference. */ export interface StepRenderer { render(step: StepRecord): [AiMessage, AiMessage]; renderInherited?(step: StepRecord): AiMessage; renderSummary?(summary: HistorySummaryRecord): AiMessage; /** The sedimented history; without it: summaries, then each step (another behavior's as inherited records). */ renderHistory?(steps: StepRecord[], currentBehavior: string, summaries: HistorySummaryRecord[]): AiMessage[]; } export declare const MAX_INJECTIONS_PER_BOUNDARY = 4; export interface LLMContextDeps { llm: LlmClient; tools: ToolManager; policy?: PolicyEngine; worklog?: WorklogSink; tokenizer?: Tokenizer; resultParser?: LLMResultParser; stepRenderer?: StepRenderer; checkpointHook?: CheckpointHook; outputValidator?: OutputValidator; } export interface ResolvedDeps { llm: LlmClient; tools: ToolManager; policy: PolicyEngine; worklog: WorklogSink; tokenizer: Tokenizer; resultParser?: LLMResultParser; stepRenderer?: StepRenderer; checkpointHook?: CheckpointHook; outputValidator?: OutputValidator; } export declare const allowAllPolicy: PolicyEngine; export declare const noopWorklog: WorklogSink; export declare function resolveDeps(d: LLMContextDeps): ResolvedDeps; /** Specs the adapter may advertise, filtered by `ToolPolicy.mode` / `whitelist`. */ export declare function resolveToolSpecs(policy: ToolPolicy, tools: ToolManager): ToolSpecLite[]; //# sourceMappingURL=deps.d.ts.map