/** * Compute a structural diff between two state snapshots and return it * in JSON-Patch-shaped form (RFC 6902 subset: `add`, `remove`, * `replace`). * * Why JSON Patch shape: LLMs see this exact format in their training * data — it's the standard for describing object mutations on the * wire. The agent learns the schema implicitly and can answer "what * changed?" in a sentence by reading the ops. * * Why not unified-diff or per-binding dirty masks: the dirty mask * tracks what bindings need re-rendering, which is a layout concern. * The agent wants to know what *values* changed, which is a state * concern. Dirty masks miss field-level resolution; per-path JSON * Patch gives it. * * Cost is O(state size) per dispatch. For typical app states (a few * KB) that's microseconds. Apps with very large states (collections * of thousands of items) should subscribe to specific slices via * `query_state` / `wait_for_change` instead of reading full diffs. * * Path escaping follows JSON Pointer (RFC 6901): `/` becomes `~1`, * `~` becomes `~0`. The escape happens per-segment. */ export type JsonPatchOp = { op: 'add'; path: string; value: unknown; } | { op: 'remove'; path: string; } | { op: 'replace'; path: string; value: unknown; }; export type StateDiff = JsonPatchOp[]; /** * Compute the diff. Order of operations: removes first, then adds, * then replaces. This is RFC 6902's recommended order — the receiver * can apply ops sequentially without ambiguity. * * The implementation is a simple recursive walk; collection diffs * are positional (index-based for arrays, key-based for objects) * rather than structural (no LCS). Apps that pass identity-stable * collections (`[...prev, item]`-style appends) get clean diffs; * apps that rebuild arrays from scratch get noisy ones — same * tradeoff a React reconciler makes, and the same fix (stable keys * + push-don't-rebuild updates) applies. */ export declare function computeStateDiff(prev: unknown, next: unknown): StateDiff; //# sourceMappingURL=state-diff.d.ts.map