import type { Json } from "./ids.js"; import { type ShapeType } from "./shape.js"; /** * v2 spec §3 — * the bounded reshape vocabulary: a small, pure, non-Turing projection * language over a STORED binding's `$reshape` chain. Exactly the spec's * families: pick, field-rename, map (asPoints/asOptions), format, template * (bounded object→string interpolation for display slots), and aggregates. * * NOT MODEL-FACING ANY MORE. The wire dialect cannot write a reshape: a * `{...}` gap in a screen document is a JavaScript expression, and JavaScript * already picks, renames, maps and reduces — a second projection language the * model has to learn buys nothing. What survives is the CANONICAL TREE * feature: a stored document may carry a chain, and three consumers still read * one — * - `validateTree` gates the canonical form via {@link findInvalidReshape} * (the vocabulary is enforceable at the format gate, not just at compile); * - the wire compiler flows tool shapes through {@link reshapeShape} * (genui/wire/shape-check.ts) to type-check such bindings; * - the renderer evaluates {@link applyReshape} on resolved data — total and * defensive, so a runtime mismatch becomes a contained data-shape notice, * never a broken render; * plus the Kit's code-land `reshape.*` bundle (`@vendoai/vendo/ui`), which is a * published function surface an island calls, not a dialect. */ /** v2 spec §3 — one reshape step in a binding's `$reshape` chain. */ export interface ReshapeStep { op: ReshapeOp; args: string[]; } /** v2 spec §3 — the closed op registry. FROZEN at this set (v3 spec §Dialect * retirement): pressure for a new op = a missing Kit prop or an island case. * Never add an op here. */ export declare const RESHAPE_OPS: readonly ["pick", "rename", "asPoints", "asOptions", "format", "template", "sum", "min", "max", "count"]; /** v2 spec §3 */ export type ReshapeOp = (typeof RESHAPE_OPS)[number]; /** v2 spec §3 — chain-length cap: bounded and non-Turing by construction. */ export declare const RESHAPE_MAX_STEPS = 8; /** The reductions {@link reduceNumeric} performs — the union of the stored * `$reshape` aggregates and the `$expr` aggregate calls. */ export type NumericReduction = "sum" | "average" | "min" | "max"; /** * The ONE numeric reduce in the codebase (blueprint §5.4: never two * implementations of `sum`). Both aggregate surfaces call it: the `$expr` * aggregates (genui/expr.ts) and the stored-document `$reshape` aggregates * below. `null` means "no values to reduce" — the callers differ on what that * means (`$expr` reports an issue, `$reshape` yields null), and `sum` of * nothing is 0 for both. */ export declare const reduceNumeric: (call: NumericReduction, numbers: readonly number[]) => number | null; /** v2 spec §3 — validate a `$reshape` chain. Null when valid. */ export declare const findInvalidReshapeSteps: (steps: unknown) => string | null; /** * v2 spec §3 — deep-walk a props value for `$reshape` members and validate * every chain against the closed vocabulary (the validateTree gate; same * walk discipline as fn-references' findInvalidActionReference). Returns the * first violation message, or null. */ export declare function findInvalidReshape(value: unknown): string | null; /** v2 spec §3 — the total runtime evaluation result. `ok: false` is the * contained data-shape-notice path, never a throw. */ export type ReshapeResult = { ok: true; value: Json | undefined; } | { ok: false; reason: string; }; /** * v2 spec §3 — evaluate a `$reshape` chain on resolved binding data. Total * and defensive: `undefined` in ⇒ ok/`undefined` out (loading is not a * mismatch); a type mismatch returns `ok: false` with a reason — the * renderer's contained data-shape notice — and never throws. */ export declare function applyReshape(value: Json | undefined, steps: readonly ReshapeStep[]): ReshapeResult; /** v2 spec §3 — a compile-time shape violation, with the missing/available * field lists the per-binding repair prompt needs. */ export interface ReshapeShapeError { message: string; missing?: string[]; available?: string[]; } /** v2 spec §3 — the result of flowing a shape through one step. */ export type ReshapeShapeResult = { ok: true; shape: ShapeType; } | { ok: false; error: ReshapeShapeError; }; /** * v2 spec §3 — flow a response shape through one reshape step (the wire * compiler's binding type-check). `json` regions stay defensive (no error); * a known-shape violation returns the typed error with missing/available * fields for the per-binding repair prompt. */ export declare function reshapeShape(shape: ShapeType, step: ReshapeStep): ReshapeShapeResult;