/** * Canonical reconstruction of flattened tool-call arguments. * * Some upstream providers serialize array/object function-call arguments as * flattened, indexed keys on the wire. For example a tool called with * `{ keywords: ["a", "b"] }` arrives as `{ "keywords[0]": "a", "keywords[1]": "b" }`, * and `{ files: [{ path }] }` as `{ "files[0].path": "..." }`. * * This module is the single source of truth for turning those flattened keys * back into nested arrays/objects. The MCP `callTool` boundary * (provider-agnostic, bracket self-gating) delegates here so the * prototype-pollution guard lives in exactly one place. * * Security: argument keys cross a trust boundary (model/provider wire → tool / * MCP server validation). A key path that walks through `__proto__`, * `constructor`, or `prototype` could otherwise reach `Object.prototype` and * mutate it process-wide. Any key whose path contains such a segment — at any * position, including the final segment and a literal plain key — is dropped. */ /** * Parse a flattened key such as `a.b[0].c` into path segments * `["a", "b", 0, "c"]`. Returns `undefined` for a plain key with no `.`/`[`, or * for a malformed bracket expression (left untouched by the caller). */ export declare function parseFlattenedKeyPath(key: string): Array | undefined; /** * Reconstruct (unflatten) flattened keys into nested arrays/objects — for * example `"items[0]"` -> `{ items: [...] }` and `"parent.child"` -> * `{ parent: { child: ... } }`. `shouldSplit` decides, per key, whether it is a * flattened path (true) or an opaque literal key to be preserved (false); * callers apply their own gating/schema logic there. * * Prototype-pollution safe: a key whose parsed path contains `__proto__`, * `constructor`, or `prototype` (at any position) is dropped, as is a literal * plain key equal to one of those names. */ export declare function reconstructFlattenedKeys(args: Record, shouldSplit: (key: string) => boolean): Record; /** * Reconstruct flattened tool-call arguments into nested arrays/objects using * schema-aware disambiguation for dotted keys. * * - Bracket-indexed keys (`ids[0]`, `files[0].path`) are always reconstructed. * - Purely dotted keys (`parent.child`) are reconstructed only when the optional * `schema` marks their head segment as an object/array container property. * The presence of a bracket-indexed sibling does NOT force a pure dotted key * to split, so a literal property name such as `filter.name` survives intact * even when a sibling like `ids[0]` is present (issue #1496). * - Otherwise dotted keys are preserved verbatim — fixing the regression where a * literal property name like `filter.name` was silently corrupted. * * Returns the original reference unchanged when there is nothing to * reconstruct. Prototype-pollution safety is delegated to * {@link reconstructFlattenedKeys}. */ export declare function unflattenArgumentsWithSchema(args: Record, schema?: unknown): Record; //# sourceMappingURL=flattened-tool-arguments.d.ts.map