/** * S — State transform namespace. * * Factory methods returning composable state transforms. * Compose with .pipe() (chain) or .merge() (combine). * * Usage: * S.pick("key1", "key2") // keep only named keys * S.rename({ old: "new" }) // rename keys * S.default_({ x: 0 }) // fill missing keys * S.pick("a").pipe(S.set({b:1})) // chain transforms */ import type { State, StateTransform } from "../core/types.js"; /** A composable state transform descriptor. */ export declare class STransform { readonly name: string; readonly fn: StateTransform; readonly readsKeys: string[] | null; readonly writesKeys: string[] | null; constructor(name: string, fn: StateTransform, readsKeys?: string[] | null, writesKeys?: string[] | null); /** Chain: run this transform, then other on the result. */ pipe(other: STransform): STransform; /** Combine: both read same input, merge outputs. */ merge(other: STransform): STransform; /** Apply this transform to a state. */ apply(state: State): State; } /** * S namespace — state transform factories. * * All 24 methods from the Python S namespace are ported here. */ export declare class S { /** Keep only the named keys. */ static pick(...keys: string[]): STransform; /** Remove the named keys. */ static drop(...keys: string[]): STransform; /** Rename keys: S.rename({ oldName: "newName" }). */ static rename(mapping: Record): STransform; /** Apply a function to transform one key's value. */ static transform(key: string, fn: (value: unknown) => unknown): STransform; /** Derive new keys from full state. */ static compute(factories: Record unknown>): STransform; /** Merge multiple keys into a single key. */ static merge_(keys: string[], into: string, fn?: (values: Record) => unknown): STransform; /** Set explicit key-value pairs. */ static set(values: Record): STransform; /** Fill missing keys with defaults. */ static default_(defaults: Record): STransform; /** Capture user message into state[key]. */ static capture(key: string): STransform; /** Append current value of key to a running list (default: same key). */ static accumulate(key: string, into?: string): STransform; /** Increment a numeric counter in state. */ static counter(key: string, step?: number): STransform; /** Maintain a rolling history of a key's values. */ static history(key: string, maxSize?: number): STransform; /** Assert a state invariant. Throws if predicate fails. */ static guard(predicate: (state: State) => boolean, msg?: string): STransform; /** Assert that all named keys exist and are truthy. */ static require(...keys: string[]): STransform; /** Validate state against a schema (Zod or custom validator). */ static validate(schemaOrValidator: { parse: (v: unknown) => unknown; } | ((state: State) => boolean), _opts?: { strict?: boolean; }): STransform; /** Flatten a nested dict to dotted keys: { a: { b: 1 } } → { "a.b": 1 }. */ static flatten(key: string, separator?: string): STransform; /** Unflatten dotted keys to nested: { "a.b": 1 } → { a: { b: 1 } }. */ static unflatten(key: string, separator?: string): STransform; /** Zip parallel lists: S.zip("names", "scores", into: "pairs"). */ static zip(keys: string[], into: string): STransform; /** Group list items by a key function. */ static groupBy(itemsKey: string, keyFn: (item: unknown) => string, into: string): STransform; /** Conditional transform: apply only if predicate is true. */ static when(predicate: (state: State) => boolean, transform: STransform): STransform; /** Route to different transforms based on a state key value. */ static branch(key: string, routes: Record, fallback?: STransform): STransform; /** Pass-through (no-op). */ static identity(): STransform; /** Log selected state keys to stderr. */ static log(...keys: string[]): STransform; /** Bridge state keys → A2UI data model. */ static toUi(...keys: string[]): STransform; /** Bridge A2UI data model → state keys. */ static fromUi(...keys: string[]): STransform; } //# sourceMappingURL=state.d.ts.map