/** * Parameter aliases: `def fetch(baseUrl | url: string)`. * * An alias is a misspelling the tool forgives. It is not a second name * for the parameter. This module is the one place that answers "which * parameter does this key name, and did it get there through an alias?". * The type checker, the synthesizer, and the runtime all call it, so the * answer cannot drift between them. See * `docs/dev/language/parameter-aliases.md`. * * The functions here are pure and never throw. `resolveNamed` in * `lib/runtime/agencyFunction.ts` is the only place that decides what a * correction or a conflict means for a given caller. */ /** The shape both the static `FunctionParameter` and the runtime * `FuncParam` share, which is all this module needs. */ export type NamedParameter = { name: string; aliases?: string[]; }; export type ParameterMatch = { param: NamedParameter; viaAlias: boolean; }; /** One key renamed to its canonical name. */ export type AliasCorrection = { from: string; to: string; }; export type CanonicalKeysResult = { /** The arguments with alias keys renamed. On a conflict, the arguments * exactly as given. */ args: Record; corrections: AliasCorrection[]; /** The conflict sentence when two keys name one parameter, else null. */ conflict: string | null; }; /** The parameter a caller's key names: the canonical name wins, then an * alias. Null when the key names nothing. */ export declare function parameterForKey(params: readonly NamedParameter[], key: string): ParameterMatch | null; /** The one sentence every layer uses when Agency code writes an alias. * With `fn`, the call is named: `'url' is an alias of 'baseUrl' in call * to 'fetch'; use 'baseUrl'.` */ export declare function aliasHint(key: string, canonical: string, fn?: string): string; /** The conflict sentence when two keys land on one parameter. The keys * are named in the order the caller wrote them. */ export declare function aliasConflictMessage(first: string, second: string, canonical: string, fn?: string): string; /** * Rename every alias key in `args` to its canonical name. * * Keys that name nothing pass through untouched, so a true typo still * reaches the caller's own unknown-argument error. An alias key whose * value is null counts as absent: it is dropped, not renamed, and never * conflicts, because a model sends null for a parameter it means to leave * out. The function is idempotent: canonical input comes back equal with * no corrections. */ export declare function canonicalKeys(args: Record, params: readonly NamedParameter[], fn?: string): CanonicalKeysResult;