import type { Tool } from './tool';
export interface ToolCoercion {
path: string;
before: unknown;
after: unknown;
}
export interface ToolValidationMetadata {
coerced: boolean;
coercions: ToolCoercion[];
}
export interface ToolValidationSuccess {
ok: true;
value: Input;
metadata: ToolValidationMetadata;
}
export interface ToolValidationFailure {
ok: false;
error: ToolValidationError;
}
/**
* Field-level validation error kinds
*/
export type FieldErrorKind = 'missing' | 'invalid' | 'wrong_type';
/**
* Structured field-level validation error
* Format: field name + error type (e.g., "email: invalid")
*/
export interface FieldValidationError {
/** Field path (e.g., "email" or "address.city") */
field: string;
/** Error kind: missing, invalid, or wrong_type */
kind: FieldErrorKind;
/** Human-readable error message */
message: string;
/** Expected type or format (for wrong_type/invalid) */
expected?: string;
/** Actual value or type received (for wrong_type) */
actual?: string;
}
export interface ToolValidationError {
message: string;
/** Legacy string-based issues for backward compatibility */
issues: string[];
/** Structured field-level errors for model self-correction */
fieldErrors?: FieldValidationError[];
stack?: string;
coercions?: ToolCoercion[];
}
export interface ToolValidationResult {
result: ToolValidationSuccess | ToolValidationFailure;
}
export interface ToolValidationOutcome {
output: Input;
metadata: ToolValidationMetadata;
}
export declare function decodeToolInputs(tool: Tool, input: unknown): ToolValidationResult;
export declare function getDecodedToolInputs(tool: Tool, input: unknown): ToolValidationOutcome;
export declare function validateToolSchema(tool: Pick & {
readonly schema?: {
readonly input?: unknown;
};
}): void;
export declare function wrapToolExecution(tool: Tool, execute: (args: Input) => Promise