import type { AgentEvent, ErrorInfo, Guardrails, JsonObject, OwnershipScope, RunLedger, ToolCallContent, ToolDefinition, ToolEffectDeclaration, ToolEffectStore, ToolExecutionContext, ToolRegistry, ToolResult } from "./contracts.js"; import type { MiddlewareRegistry } from "./middleware.js"; import { type SecretRedactor } from "./redaction.js"; import { type DuplicateRegistrationOptions } from "./registry-options.js"; import type { RunLimitTracker } from "./run-limits.js"; import { type PermissionPolicy, type TrustPolicy } from "./security.js"; export interface ToolFilter { readonly allow?: readonly string[]; readonly deny?: readonly string[]; } export type ToolFilterInput = ToolFilter | readonly ToolFilter[]; export type ToolValidator = (tool: ToolDefinition, args: JsonObject, context: ToolExecutionContext) => undefined | string | ErrorInfo | Promise; export interface ToolArgumentValidationError { readonly path?: string; readonly message: string; } export interface ToolArgumentValidationResult { readonly ok: boolean; readonly errors?: readonly ToolArgumentValidationError[]; } export interface ToolArgumentValidator { validate(schema: JsonObject, value: unknown): ToolArgumentValidationResult; } export interface ToolParameterValidatorOptions { /** When a tool omits `parameters`. Default `"allow"` preserves pre-validation behavior. */ readonly missingSchema?: "allow" | "reject"; } /** Wrap a schema adapter as the existing `ToolValidator` seam used by dispatch and the agent runtime. */ export declare function createToolParameterValidator(validator: ToolArgumentValidator, options?: ToolParameterValidatorOptions): ToolValidator; export interface DispatchToolCallOptions { readonly call: ToolCallContent; readonly registry: ToolRegistry; readonly context: ToolExecutionContext; readonly filter?: ToolFilterInput; readonly middleware?: MiddlewareRegistry; readonly validate?: ToolValidator; /** Adapter-specific policy check immediately before the tool side effect. */ readonly beforeExecute?: (call: ToolCallContent, tool: ToolDefinition, context: ToolExecutionContext) => void | Promise; readonly emit?: (event: AgentEvent) => void | Promise; readonly secrets?: readonly (string | undefined)[]; readonly permission?: PermissionPolicy; readonly trust?: TrustPolicy; readonly redactor?: SecretRedactor; readonly ledger?: RunLedger; /** Optional shared recovery store. Only declared optional/required effects use it. */ readonly effectStore?: ToolEffectStore; readonly ownership?: OwnershipScope; /** Host-verified identity; asserted active before tool side effects when present. */ readonly identity?: import("./identity.js").AgentIdentity; /** Tool stages run after middleware normalization and before side effects/exposure. */ readonly guardrails?: Guardrails; /** Shared run tracker; direct hosts may supply one for their call scope. */ readonly limitTracker?: RunLimitTracker; } export interface ToolRegistryOptions extends DuplicateRegistrationOptions { } export declare function createToolRegistry(tools?: readonly ToolDefinition[], options?: ToolRegistryOptions): ToolRegistry; export declare function filterTools(tools: readonly ToolDefinition[], filter?: ToolFilterInput): readonly ToolDefinition[]; /** Cap matches tool-search index; run allow-lists never exceed the disclosed set. */ export declare const HARD_RUN_TOOL_NAMES = 1024; /** Restrictive clamp: keep listed order; names outside the grant are dropped (not thrown). */ export declare function clampTurnToolNames(listed: readonly ToolDefinition[], requested: readonly string[]): { readonly tools: readonly ToolDefinition[]; readonly dropped: readonly string[]; }; /** * Per-run allow-list. Omitted grant → unchanged list. Checkpointed grant cannot widen. * Fresh unknown names fail closed; resume drops names the current registry no longer has. */ export declare function selectRunTools(listed: readonly ToolDefinition[], requested: readonly string[] | undefined, checkpoint?: readonly string[]): { readonly tools: readonly ToolDefinition[]; readonly grant: readonly string[] | undefined; }; export declare function dispatchToolCall(options: DispatchToolCallOptions): Promise; export declare function resolveToolEffectDeclaration(tool: ToolDefinition, args: JsonObject, context: ToolExecutionContext): ToolEffectDeclaration | undefined;