/** * Parameter reading utilities — safe extraction of tool parameters. * * Reimplemented from OpenClaw's parameter reading system. * Supports both camelCase and snake_case parameter names, trimming, * type coercion, and required/optional semantics. * * Original source: openclaw/src/agents/tools/common.ts (MIT license) * * @module */ /** * Thrown when a tool receives invalid input parameters. */ export declare class ToolInputError extends Error { readonly status: number; constructor(message: string); } /** * Thrown when a tool call is not authorized. */ export declare class ToolAuthorizationError extends ToolInputError { readonly status = 403; constructor(message: string); } export interface StringParamOptions { required?: boolean; trim?: boolean; label?: string; allowEmpty?: boolean; } /** * Read a string parameter from tool arguments. * * Supports both camelCase and snake_case keys. Trims whitespace by default. * * @param params - The raw parameter object from the tool call. * @param key - The parameter name (camelCase). * @param options - Reading options. * @returns The string value, or undefined if not present and not required. * @throws ToolInputError if required and missing. */ export declare function readStringParam(params: Record, key: string, options?: StringParamOptions & { required: true; }): string; export declare function readStringParam(params: Record, key: string, options?: StringParamOptions): string | undefined; export interface NumberParamOptions { required?: boolean; integer?: boolean; label?: string; } /** * Read a number parameter from tool arguments. * * @param params - The raw parameter object. * @param key - The parameter name. * @param options - Reading options. * @returns The number value, or undefined if not present and not required. * @throws ToolInputError if required and missing, or if the value isn't a valid number. */ export declare function readNumberParam(params: Record, key: string, options?: NumberParamOptions & { required: true; }): number; export declare function readNumberParam(params: Record, key: string, options?: NumberParamOptions): number | undefined; export interface BooleanParamOptions { /** Throw ToolInputError if the parameter is absent. */ required?: boolean; /** Value to return when absent and not required. Defaults to `false`. */ defaultValue?: boolean; /** Human-readable name used in error messages. Defaults to `key`. */ label?: string; } /** * Read a boolean parameter from tool arguments. * * Supports both camelCase and snake_case keys. Coerces string `"true"` / `"1"` * to `true` and everything else to `false` via `Boolean()`. * * Accepts either the legacy positional `defaultValue` (third arg as `boolean`) * or a {@link BooleanParamOptions} object for structured access including * `required: true`. * * @param params - The raw parameter object. * @param key - The parameter name (camelCase). * @param optionsOrDefault - Options object or legacy positional default value. * @returns The boolean value, or `defaultValue` if absent and not required. * @throws ToolInputError if `required: true` and the parameter is absent. */ export declare function readBooleanParam(params: Record, key: string, optionsOrDefault: BooleanParamOptions & { required: true; }): boolean; export declare function readBooleanParam(params: Record, key: string, optionsOrDefault?: boolean | BooleanParamOptions): boolean; /** * Read a string array parameter. Auto-wraps a single string into an array. * * @param params - The raw parameter object. * @param key - The parameter name. * @param options - Reading options. * @returns A string array, or undefined if not present and not required. * @throws ToolInputError if required and missing. */ export declare function readStringArrayParam(params: Record, key: string, options?: { required?: boolean; label?: string; }): string[] | undefined; /** * Assert that required parameters are present. * * @param params - The raw parameter object. * @param required - List of required parameter names. * @throws ToolInputError if any required parameter is missing. */ export declare function assertRequiredParams(params: Record, required: string[]): void; //# sourceMappingURL=params.d.ts.map