/** * Coerce a tool argument that is contractually a string array into a real * `string[]`, tolerating the shapes models/MCP clients send in practice. * * Some hosts deliver an array-typed param as a bare string (`"a.ts"`) or a * JSON-stringified array (`'["a.ts","b.ts"]'`) despite the declared schema. * A plain `args.files as string[]` cast then lies, and the first `.map`/ * iteration throws (`inputs.map is not a function`) before any validation can * report a clean error. This normalizes at the boundary so callers get a real * array (possibly empty) and never crash on a mistyped argument. * * Accepts: * - a string[] (non-string entries dropped, empties trimmed out) * - a JSON-stringified array of strings (`'["a","b"]'`) * - a single non-empty string (treated as a one-element array) * * Returns `[]` for null/undefined/empty/other shapes; the caller enforces any * "at least one" requirement and produces the user-facing error. */ export declare function coerceStringArray(value: unknown): string[]; /** * Coerce a string param that has a compatibility alias in another harness. * * Models cross-pollinate tool schemas between hosts (e.g. sending `filePath` to * Pi's `read`, whose schema field is `path`). Use this at the tool boundary to * accept the alias only when the declared field is absent. * * Conservative by design: * - if the declared field is present, its value wins unchanged — even if it is * malformed or empty. We never override an explicit schema field. * - the alias is accepted only when it is a non-empty string after trimming. * The original alias text is returned unchanged so paths containing spaces are * preserved byte-for-byte. */ export declare function coerceAliasedStringParam(value: unknown, aliasValue: unknown): string | undefined; /** * Coerce a polymorphic `string | string[]` tool argument (e.g. aft_outline's * `target`, which is a single path/URL OR an array of paths). Hosts deliver an * array as a JSON-stringified string (`'["a","b"]'`) despite the declared union, * which a naive consumer then treats as ONE literal path — aft_outline tried to * stat a file literally named `["src/a", "src/b"]` and failed. * * Returns: * - an array if `value` is already an array (non-string/empty entries dropped), * or a JSON-stringified array of strings; * - the original string otherwise (single path/URL — single-target semantics * are preserved, NOT split on spaces/commas). * Non-string, non-array input is returned as-is for the caller to reject. */ export declare function coerceTargetParam(value: unknown): string | string[]; /** * Coerce a tool argument that is contractually a boolean into a real boolean, * tolerating the shapes models send in practice. * * Like array and integer params (see `coerceStringArray` / `coerceOptionalInt`), * hosts deliver a boolean-typed param as the model's raw emitted value WITHOUT * coercing it to the declared schema type — and models non-deterministically * emit `true` as the string `"true"` (or `1` / `"1"`). A strict `args.x === true` * check then reads a stringified `"true"` as false, silently dropping the flag. * This bit `aft_delete`'s `recursive`: an agent passing `recursive: true` got * "is a directory, pass recursive: true" because the wire value was `"true"`. * * Conservative by design: only values that UNAMBIGUOUSLY mean true coerce to * true (`true`, case-insensitive `"true"`, `1`, `"1"`). Everything else — * `false`, `"false"`, `0`, `""`, `null`, `undefined`, objects — is `false`. A * false-negative just re-surfaces the original "pass the flag" error (safe); a * false-positive on a destructive gate like `recursive` would not be, so the * truthy set is kept tight rather than accepting arbitrary truthy values. * * Pass `defaultValue: true` only for contractually default-true options. In * that mode, missing values stay enabled and only explicit false-like values * (`false`, `0`, `"false"`, `"0"`) disable the option. */ export declare function coerceBoolean(value: unknown, defaultValue?: boolean): boolean; /** * Runtime coercion for agent-friendly sentinel handling. * * Some agents emit null / "" / 0 when they mean "param not provided". * Use this inside tool handlers BEFORE relying on the value. Returns * `undefined` for all empty sentinels; rejects out-of-bounds with a * clear message. * * Tool handlers that want sentinel tolerance must pass args through * this AFTER schema validation has accepted the value (or for fields * declared as `unknown`/`any` that bypass type validation). Host-specific * optional-integer schemas stay local to each plugin; this helper is the * shared runtime coercion. */ export declare function coerceOptionalInt(v: unknown, paramName: string, min: number, max: number): number | undefined; /** * True when a value represents "agent did not provide this param". * * GPT-family models send empty strings / empty arrays / null instead of * omitting optional params entirely. Use this BEFORE mutual-exclusion * checks so an empty `targets: []` or `url: ""` doesn't get counted as * present and trigger a misleading "X is mutually exclusive with Y" error. * * Treats undefined / null / "" / [] / {} as empty. Booleans and numbers * (including 0 and false) are NOT empty by themselves — only string and * collection sentinels qualify. */ export declare function isEmptyParam(value: unknown): boolean; //# sourceMappingURL=coerce.d.ts.map