/** * Schema-driven repair of JSON-array literals handed to array flags (#60410). * * Every schema `array` parameter is registered as a Commander variadic * (`--name `, see addSchemaOption in index.ts) and nothing in the * CLI JSON-parses flag values. So `--sheet_names '["A","B"]'` reaches the * server as the ONE-element array `['["A","B"]']` — Google Sheets then created * a sheet literally named `["A","B"]` and every later `B!A1:..` write 400'd. * Agents write that shape because two sibling flags on the same command * (`--values`, `--initial_data`) document exactly it, and the server-side * repair from #47625 only covers those two. * * Contract: * - Only a value that is a single string, or a one-element array holding a * single string, whose trimmed text is a JSON array literal is touched. * `--names a b`, real arrays from --args-file and per-element JSON * objects (`--params '{"a":1}' '{"b":2}'`) are left alone. * - Text that merely starts with `[` but is not valid JSON (`[Draft]`) is a * legitimate value and passes through unchanged. * - A literal that parses but whose elements do not match the schema's * `items.type` is refused with an actionable error, and nothing is sent: * the caller clearly meant a JSON array, so forwarding the text (or * guessing a shape) would only move the failure server-side. * - Escape hatch for a value that genuinely IS JSON-array-shaped text (a * free-text answer such as `["yes","no"]`): put it in --args-file as a * real JSON array, `{"answer": ["[\"yes\",\"no\"]"]}`. JSON has no * shell ambiguity — an array there is an array and a string a string — * so arrays that arrive from the file are forwarded verbatim; only a * file STRING where the schema wants an array is repaired. */ export interface ArrayParameterLike { type: string | string[]; items?: { type?: string | string[]; }; } export type JsonArrayRepair = { kind: 'unchanged'; } | { kind: 'replaced'; value: unknown[]; } | { kind: 'error'; message: string; }; /** * Decide what to do with one array parameter's value. Pure; never throws. */ export declare function repairJsonArrayLiteral(name: string, value: unknown, param: ArrayParameterLike): JsonArrayRepair; export interface RepairJsonArrayArgsOptions { /** * Parameters whose current value is a real JSON array from --args-file. * Those arrays are forwarded verbatim (see the escape hatch above); a * string value under one of these keys is still repaired. */ literalArrayKeys?: ReadonlySet; } /** * Apply repairJsonArrayLiteral to every schema `array` parameter present in * `args`, in place. A parameter counts as an array parameter when `array` * appears anywhere in its `type` (a nullable `["null", "array"]` included). * Returns the first refusal message, or null when every value was accepted * (repaired or untouched). */ export declare function repairJsonArrayArgs(args: Record, props: Record, options?: RepairJsonArrayArgsOptions): string | null; //# sourceMappingURL=arrayArgs.d.ts.map