/** The failure kinds an error can declare about itself. */ export type FailureKind = 'planning' | 'argument'; /** * A plan that cannot be salvaged. Carries the failure kind so the benchmark's * taxonomy can classify it without pattern-matching the message text — that * coupling made the messages untranslatable, because translating one silently * turned a planning error into an execution error. */ export declare class PlanSchemaError extends Error { readonly kind: FailureKind; constructor(kind: FailureKind, message: string); } /** * The failure kind an error declares about itself, if it declares one. * * Read off the error rather than matched by class, so a new typed error survives both the * round wrapper in `agent.ts` and the benchmark's classification without a branch in either * — the round wrapper used to know only about `PlanSchemaError`, which is how a * `SheetNotFoundError` came back as a plain `Error` and got classified as an execution * failure. An error with no kind returns `undefined` and falls back to the text heuristics. */ export declare function declaredKind(error: unknown): FailureKind | undefined; import type { ExcelOperation } from './operations.ts'; import type { PlanStep } from './agent.ts'; import type { WorkbookAssertion } from './verifier.ts'; /** * Aliases for enum values that are not English, or that name the concept rather * than the constant. Deliberately small and one-to-one: an alias that could mean * two allowed values is not an alias, it is a guess, and a guess here writes a * valid-looking wrong value into somebody's workbook. */ export declare const ENUM_ALIASES: Record>; export declare const REQUIRED_ARRAYS: Record; /** * Fields the schema marks `required: true` and that this pass must therefore reject * when they are absent. Kept next to the code that enforces it, but exported so * `tests/plan-schema.test.ts` can hold it against `excelOperationSchema` — the two * drifted once (the four structure ops' `row`/`count` were required in the schema and * unenforced here), and a missing row count used to reach the handler as `undefined`, * pass `count < 1`, and silently delete nothing. */ export declare const REQUIRED_NUMBERS: Record; export interface SanitizedPlan { steps: PlanStep[]; notes: string[]; } /** * Normalize planner-produced assertions into WorkbookAssertions (Verifier 2.0): * keep only fully-formed entries, coerce ids to strings, and drop style-only * assertions that carry no checkable property. Invalid-but-salvageable fields * are repaired; entries with neither an id nor any expected value are dropped. */ export declare function sanitizeAssertions(assertions: unknown, sheetNames: string[]): { assertions: WorkbookAssertion[]; notes: string[]; }; /** * Validate and repair a planner-produced plan before execution. Salvageable * issues are fixed in place (sheet prefix, missing sheet, array wrapping, * alias fields, cell values); unsalvageable issues throw so the agent loop * can feed the exact message back to the planner for a corrected plan. */ /** * Sheet name → normalised header text → column letter. * * Built from the workbook profile, which is already in hand before planning, and * only for headers that are unambiguous within their sheet: when two columns share * a header the entry is dropped rather than picked, because guessing which one was * meant is how a plausible-looking wrong answer gets written into someone's file. */ export type HeaderIndex = Record>; /** Normalise a header the way a reader would: trim, collapse spaces, case-fold. */ export declare function normalizeHeader(header: string): string; export declare function buildHeaderIndex(sheets: Array<{ sheet: string; columns: Array<{ column: string; header: string | null; }>; }>): HeaderIndex; export declare function sanitizePlan(steps: PlanStep[], sheetNames: string[], headers?: HeaderIndex): SanitizedPlan; /** * Run the same validation and salvage the planner path uses, for an operations * array that arrived straight from a tool call rather than from the planner. * * `excel_operate` and `excel_workflow` hand the model's array to the executor * directly, and the executor assumes it is already well-formed. So a model that * omitted a nested field reached a handler and crashed with * `TypeError: Cannot read properties of undefined (reading 'toUpperCase')`, * where the planner gets the actionable `sortRange 的 keys[0].column 缺失`. * Reusing this function rather than writing a second validator is deliberate: * one rule with two implementations drifts. */ export declare function sanitizeOperations(operations: ExcelOperation[], sheetNames: string[]): ExcelOperation[]; //# sourceMappingURL=plan-schema.d.ts.map