/** * Translate Graph / substrate / CLI / validation errors into actionable hints. * * Audit Hervé-session §2: bare `error: ErrorInvalidIdMalformed: Id is * malformed.` had no remedy for the LLM — it had to guess where the bad ID * came from. This module is the centralised "what should I do about this" * lookup: pattern-match the error code (or, as a fallback, a substring of * the message) and surface a one-line hint plus a `source` classifier so * the LLM can branch on whether the failure is server-side, substrate-side, * CLI-side, or a Zod validation rejection. Surfaced through the standard * error envelope in both `--output json` (as `hint` / `source` fields) and * `--output text` (as `hint:` / `source:` lines under the existing `error:` * line). * * Audit Hervé-session §2 follow-up: the four error-envelope variants are * - `graph` — public Microsoft Graph API at /v1.0/ * - `substrate` — Microsoft-internal chat substrates (chatsvcagg / IC3). * Tagged at the infra layer with `substrateHttp{N}_{name}`. * - `cli` — CLI itself (Commander parser, CLI rewrites of Graph * errors via `cli_rewrite_*` and `cli_reject_*` codes) * - `validation` — Zod schema validation from use-cases (no `code` — pure * message-pattern fallback) * * Rule precedence: specific code matchers run FIRST, then message-pattern * fallbacks. The generic-validation rule sits LAST so it never overrides a * code-based remedy. * * The table is intentionally small and biased toward HIGH-FREQUENCY errors * an LLM actually hits. Adding more entries is cheap; the lookup is O(n) * on a tiny n. */ export type ErrorSource = 'graph' | 'substrate' | 'cli' | 'validation'; export type ErrorHint = { readonly hint: string; readonly source: ErrorSource; }; /** * First matching rule wins. Returns `undefined` when nothing in the table * matches — caller renders the bare error (the historical shape). */ export declare const findErrorHint: (message: string, code: string | undefined) => ErrorHint | undefined;