@demlik/tea 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +6 -6
- package/dist/authed-call/index.js +3 -3
- package/dist/await-terminal/index.d.ts +1 -1
- package/dist/await-terminal/index.js +1 -1
- package/dist/batch-window/index.d.ts +1 -1
- package/dist/batch-window/index.js +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/{chunk-S4O26D7B.js → chunk-2AHAR7CX.js} +3 -3
- package/dist/{chunk-S4O26D7B.js.map → chunk-2AHAR7CX.js.map} +1 -1
- package/dist/{chunk-WGGAMW7Y.js → chunk-5W7CNAHB.js} +6 -6
- package/dist/{chunk-WGGAMW7Y.js.map → chunk-5W7CNAHB.js.map} +1 -1
- package/dist/{chunk-IXBKFQH5.js → chunk-B5RAZVXW.js} +3 -3
- package/dist/{chunk-IXBKFQH5.js.map → chunk-B5RAZVXW.js.map} +1 -1
- package/dist/{chunk-BP2R7TPP.js → chunk-D4NJBQAH.js} +63 -18
- package/dist/chunk-D4NJBQAH.js.map +1 -0
- package/dist/{chunk-NPERUUUE.js → chunk-ET6QQNSQ.js} +3 -3
- package/dist/{chunk-NPERUUUE.js.map → chunk-ET6QQNSQ.js.map} +1 -1
- package/dist/{chunk-VBUCHVCV.js → chunk-FCKP6N7Y.js} +3 -3
- package/dist/{chunk-VBUCHVCV.js.map → chunk-FCKP6N7Y.js.map} +1 -1
- package/dist/{chunk-TPGASTFF.js → chunk-JXYYRKD6.js} +3 -3
- package/dist/{chunk-TPGASTFF.js.map → chunk-JXYYRKD6.js.map} +1 -1
- package/dist/{chunk-CAXMQJJ3.js → chunk-LJJV6ZD5.js} +3 -3
- package/dist/{chunk-CAXMQJJ3.js.map → chunk-LJJV6ZD5.js.map} +1 -1
- package/dist/{chunk-MVY5DAMF.js → chunk-SPWVPIFQ.js} +3 -3
- package/dist/{chunk-MVY5DAMF.js.map → chunk-SPWVPIFQ.js.map} +1 -1
- package/dist/{chunk-C6QC273X.js → chunk-SSHDBOXF.js} +3 -3
- package/dist/{chunk-C6QC273X.js.map → chunk-SSHDBOXF.js.map} +1 -1
- package/dist/{chunk-SK5JGUY7.js → chunk-TWDHNIY6.js} +3 -3
- package/dist/{chunk-SK5JGUY7.js.map → chunk-TWDHNIY6.js.map} +1 -1
- package/dist/deadline/index.js +1 -1
- package/dist/do/index.d.ts +1 -1
- package/dist/do/index.js +6 -6
- package/dist/extension/index.d.ts +1 -1
- package/dist/extension/index.js +2 -2
- package/dist/extension/react.js +2 -2
- package/dist/fan-out/index.d.ts +1 -1
- package/dist/idempotent-intake/index.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/llm-call/index.js +3 -3
- package/dist/machine-viz/index.js +1 -1
- package/dist/mem/index.d.ts +1 -1
- package/dist/monitored-run/index.d.ts +1 -1
- package/dist/monitored-run/index.js +3 -3
- package/dist/node/index.d.ts +1 -1
- package/dist/paginated-walk/index.js +3 -3
- package/dist/parity/index.d.ts +1 -1
- package/dist/parity/index.js +2 -2
- package/dist/pbt/index.js +2 -2
- package/dist/pbt/runners/index.js +2 -2
- package/dist/poller/index.js +1 -1
- package/dist/react/index.d.ts +8 -2
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/reconciler/index.js +3 -3
- package/dist/recorder/index.d.ts +1 -1
- package/dist/resilient-call/index.js +2 -2
- package/dist/{runtime-types-gsog27b6.d.ts → runtime-types-CukV8kMX.d.ts} +71 -2
- package/dist/saga/index.d.ts +1 -1
- package/dist/snapshot/index.js +2 -2
- package/dist/subs/index.d.ts +1 -1
- package/dist/subs/index.js +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/throttled-input/index.js +1 -1
- package/dist/token-refresh/index.js +2 -2
- package/dist/trace-replay/index.d.ts +1 -1
- package/dist/trace-replay/index.js +2 -2
- package/dist/with-deadline/index.js +1 -1
- package/dist/with-resilience/index.js +2 -2
- package/dist/with-telemetry/index.js +1 -1
- package/dist/work-queue/adapter.d.ts +1 -1
- package/dist/work-queue/index.d.ts +1 -1
- package/dist/work-queue/ops.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-BP2R7TPP.js.map +0 -1
package/dist/agent/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import '../rate-limit/index.js';
|
|
|
13
13
|
import '../retry-backoff/index.js';
|
|
14
14
|
import '../fan-out/index.js';
|
|
15
15
|
import '../work-queue/index.js';
|
|
16
|
-
import '../runtime-types-
|
|
16
|
+
import '../runtime-types-CukV8kMX.js';
|
|
17
17
|
import '../snapshot/index.js';
|
|
18
18
|
|
|
19
19
|
/**
|
package/dist/agent/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { COMPACTION_PURPOSE, agentBootMsg, agentEvents, agentTurnSchema, compactionSummarySchema, createAgent, isAgentTurn, isCompactionSummary, liftAgent, mergeInterpret, status } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
1
|
+
export { COMPACTION_PURPOSE, agentBootMsg, agentEvents, agentTurnSchema, compactionSummarySchema, createAgent, isAgentTurn, isCompactionSummary, liftAgent, mergeInterpret, status } from '../chunk-5W7CNAHB.js';
|
|
2
|
+
import '../chunk-LJJV6ZD5.js';
|
|
3
|
+
import '../chunk-FCKP6N7Y.js';
|
|
4
|
+
import '../chunk-SPWVPIFQ.js';
|
|
5
|
+
import '../chunk-B5RAZVXW.js';
|
|
6
6
|
import '../chunk-JELSZN25.js';
|
|
7
7
|
import '../chunk-D736QUGF.js';
|
|
8
8
|
export { deadlineSub, subscribeDeadline } from '../chunk-RMX4EOQK.js';
|
|
@@ -16,7 +16,7 @@ import '../chunk-LYLDCIPH.js';
|
|
|
16
16
|
import '../chunk-2YFLOCWX.js';
|
|
17
17
|
import '../chunk-ZJ5AOYBH.js';
|
|
18
18
|
import '../chunk-G5E74IJB.js';
|
|
19
|
-
import '../chunk-
|
|
19
|
+
import '../chunk-D4NJBQAH.js';
|
|
20
20
|
import '../chunk-PBDYW2TU.js';
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createTokenRefresh, refreshTokenCmd } from '../chunk-
|
|
2
|
-
import { createResilientCall } from '../chunk-
|
|
1
|
+
import { createTokenRefresh, refreshTokenCmd } from '../chunk-TWDHNIY6.js';
|
|
2
|
+
import { createResilientCall } from '../chunk-B5RAZVXW.js';
|
|
3
3
|
import '../chunk-JELSZN25.js';
|
|
4
4
|
export { deadlineSub, subscribeDeadline } from '../chunk-RMX4EOQK.js';
|
|
5
5
|
import '../chunk-Q2UM7BXU.js';
|
|
@@ -9,7 +9,7 @@ import '../chunk-2KNLKQVN.js';
|
|
|
9
9
|
import '../chunk-LYLDCIPH.js';
|
|
10
10
|
import '../chunk-2YFLOCWX.js';
|
|
11
11
|
import '../chunk-ZJ5AOYBH.js';
|
|
12
|
-
import '../chunk-
|
|
12
|
+
import '../chunk-D4NJBQAH.js';
|
|
13
13
|
import { without } from '../chunk-PBDYW2TU.js';
|
|
14
14
|
|
|
15
15
|
// src/authed-call/index.ts
|
|
@@ -3,7 +3,7 @@ export { Debounced, debounce } from '../debounce/index.js';
|
|
|
3
3
|
import { DeadlineSub, DeadlineExceeded } from '../deadline/index.js';
|
|
4
4
|
import { S as SubscribeHandler } from '../types-KbL3W1mj.js';
|
|
5
5
|
export { EnqueueInput } from '../work-queue/index.js';
|
|
6
|
-
import '../runtime-types-
|
|
6
|
+
import '../runtime-types-CukV8kMX.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @demlik/tea/batch-window — coalesce a stream of items into size- or
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { debounce } from '../chunk-J6527VRQ.js';
|
|
2
2
|
import { subscribeDeadline, deadlineExceeded, deadlineSub } from '../chunk-RMX4EOQK.js';
|
|
3
3
|
import '../chunk-2YFLOCWX.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-D4NJBQAH.js';
|
|
5
5
|
import '../chunk-PBDYW2TU.js';
|
|
6
6
|
|
|
7
7
|
// src/batch-window/index.ts
|
package/dist/cache/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { cacheEvictMsg, cacheEvictionSub, cacheEvictionSubscribe, evictExpired,
|
|
|
2
2
|
import '../chunk-LYLDCIPH.js';
|
|
3
3
|
import '../chunk-2YFLOCWX.js';
|
|
4
4
|
import '../chunk-ZJ5AOYBH.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-D4NJBQAH.js';
|
|
6
6
|
import '../chunk-PBDYW2TU.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { typeOf, indexPath, unionKeys, keyPath } from './chunk-EWJP3YYP.js';
|
|
2
|
-
import { replay } from './chunk-
|
|
2
|
+
import { replay } from './chunk-D4NJBQAH.js';
|
|
3
3
|
|
|
4
4
|
// src/trace-replay/index.ts
|
|
5
5
|
function replayTrace(machine, trace, ctx) {
|
|
@@ -49,5 +49,5 @@ function firstDivergence(expected, actual, path) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export { deepEqual, replayTrace };
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-2AHAR7CX.js.map
|
|
53
|
+
//# sourceMappingURL=chunk-2AHAR7CX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/trace-replay/index.ts"],"names":[],"mappings":";;;;AAqEO,SAAS,WAAA,CAOd,OAAA,EACA,KAAA,EACA,GAAA,E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AA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,EAAA,CAAG,QAAQ,CAAA,EAAA,EAAK;AAClC,MAAA,MAAM,CAAA,GAAI,eAAA,CAAgB,EAAA,CAAG,CAAC,CAAA,EAAG,EAAA,CAAG,CAAC,CAAA,EAAG,SAAA,CAAU,IAAA,EAAM,CAAC,CAAC,CAAA;AAC1D,MAAA,IAAI,CAAA,KAAM,MAAM,OAAO,CAAA;AAAA,IACzB;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,QAAA,EAAU;AACnB,IAAA,MAAM,EAAA,GAAK,QAAA;AACX,IAAA,MAAM,EAAA,GAAK,MAAA;AAIX,IAAA,KAAA,MAAW,GAAA,IAAO,SAAA,CAAU,EAAA,EAAI,EAAE,CAAA,EAAG;AACnC,MAAA,MAAM,CAAA,GAAI,eAAA,CAAgB,EAAA,CAAG,GAAG,CAAA,EAAG,EAAA,CAAG,GAAG,CAAA,EAAG,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAC,CAAA;AAC9D,MAAA,IAAI,CAAA,KAAM,MAAM,OAAO,CAAA;AAAA,IACzB;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAIA,EAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,MAAA,EAAO;AAClC","file":"chunk-S4O26D7B.js","sourcesContent":["// ---------------------------------------------------------------------------\n// trace-replay — replay a recorded Trace against a machine and diff the state.\n//\n// This is the back half of the record/replay feature. `../recorder` captures\n// a run (`loaded` + `msgs` + `finalState`); this module feeds that input\n// through the core `replay(machine, { msgs, ctx, loaded })` fold and asks:\n//\n// does the current reducer still produce the SAME final state for this\n// recorded input?\n//\n// Equal ⇒ the reducer is behavior-compatible with the recording. Diverged ⇒\n// the reducer changed for that input, and the divergence path\n// (`state.queue[2].status`) points at exactly the cell that drifted. This is\n// the regression / production-repro tool: record a prod incident, replay it\n// against the fixed reducer locally, confirm the fix changes the state at the\n// path you expected — or catch an unintended drift before it ships.\n//\n// Standalone by design. It imports ONLY the `Trace` type from `../recorder`\n// and the `replay` engine from `../index`. The deep-equal + first-divergence\n// path finder is self-contained (no external diff lib) — a richer pretty-diff\n// lands in `../devtools` later; trace-replay stays dependency-free so it can\n// run anywhere a machine runs (CI, a Worker, a Node script).\n// ---------------------------------------------------------------------------\n\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\nimport type { Trace } from \"../recorder\";\nimport { indexPath, keyPath, typeOf, unionKeys } from \"./state-walk\";\n\n/**\n * The outcome of {@link replayTrace}.\n *\n * @typeParam S - the machine's State type.\n */\nexport interface ReplayResult<S> {\n /** `true` iff the recomputed final state deep-equals the trace's `finalState`. */\n matches: boolean;\n /** The trace's recorded `finalState` — what the run originally produced. */\n expected: S;\n /** The state the current reducer produced for the same input. */\n actual: S;\n /**\n * Present iff `matches` is `false`. The FIRST point of divergence found by\n * a deterministic pre-order walk:\n * - `path` — a dotted/indexed access path from the state root, e.g.\n * `state.queue[2].status` or `state` for a root-level\n * scalar mismatch.\n * - `expected` — the recorded value at that path.\n * - `actual` — the recomputed value at that path.\n */\n divergence?: { path: string; expected: unknown; actual: unknown };\n}\n\n/**\n * Replay a recorded {@link Trace} against `machine` and diff the recomputed\n * final state against the recorded one.\n *\n * Runs the core pure fold `replay(machine, { msgs: trace.msgs, ctx,\n * loaded: trace.loaded })` — init + update only, never `interpret`, never a\n * `Store`, never a live subscription (see `replay` in ../index). The `ctx` is\n * supplied fresh by the caller: the trace is the INPUT (loaded + msgs); ctx is\n * the ENVIRONMENT the reducer runs against now.\n *\n * @param machine - the machine to replay against. Mutating its reducer (the\n * whole point of a regression check) is what makes a recorded\n * trace diverge.\n * @param trace - a Trace from `../recorder` (live `dump()` or a re-hydrated\n * `parseJSONL(...)`).\n * @param ctx - the runtime ctx, supplied fresh at replay time.\n */\nexport function replayTrace<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n trace: Trace<S, M>,\n ctx: Ctx,\n): ReplayResult<S> {\n const result = replay(machine, {\n msgs: trace.msgs,\n ctx,\n loaded: trace.loaded,\n });\n const actual = result.state;\n const expected = trace.finalState;\n\n const divergence = firstDivergence(expected, actual, \"state\");\n if (divergence === null) {\n return { matches: true, expected, actual };\n }\n return { matches: false, expected, actual, divergence };\n}\n\n/**\n * Order-insensitive structural deep-equality — the comparator the\n * record/replay lane owns, exposed so consumers (e.g. `@demlik/tea/parity`'s\n * `parityEqual`) reuse it rather than adding a fourth deep-compare. It is one\n * of three structural walkers in the package, divergent on purpose:\n * this `deepEqual` returns a boolean verdict (order-insensitive, for\n * replay/parity equality), `devtools`'s `diffState` returns a change list (for\n * a human-readable diff view), and `testing`'s `__deepEqual` is the assertion\n * helpers' internal compare — same shape, three jobs, not one to collapse.\n * `true` iff `a` and `b` are structurally equal under {@link firstDivergence}'s\n * walk (object keys compared order-insensitively, arrays index-by-index).\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n return firstDivergence(a, b, \"state\") === null;\n}\n\n// === deep-equal + first-divergence path finder ===\n//\n// One walk does both jobs: it returns the FIRST point where `expected` and\n// `actual` differ (as a path + the two values), or `null` when they are\n// deeply equal. \"First\" is defined by a deterministic pre-order traversal:\n// the node itself, then its children in a stable key order (array index\n// order; object keys sorted so the result does not depend on insertion\n// order — two states with the same data but different key order are equal,\n// and the reported path for a real mismatch is reproducible run-to-run).\n//\n// The path grammar (`typeOf`, `indexPath`/`keyPath` segments, `unionKeys`\n// order) is shared with devtools' `diffState` via `./state-walk`, so the two\n// walkers print the SAME path for the same cell by construction. Only the leaf\n// policy differs, on purpose: first-hit here, collect-all there.\n//\n// Scope: TEA state is plain JSON-shaped data (the substrate's __DEV__ guards\n// reject closures in Cmds, and states are conventionally serializable). So\n// the walk handles: primitives, null/undefined, arrays, and plain objects.\n// It treats other object kinds (Date, Map, Set, class instances) by reference\n// identity + a structural fallback via Object.entries — sufficient for the\n// JSON-shaped states this tool targets; a richer differ lives in ../devtools.\n\n/** A divergence record, or `null` when the two values are deeply equal. */\ntype Divergence = { path: string; expected: unknown; actual: unknown } | null;\n\nfunction firstDivergence(\n expected: unknown,\n actual: unknown,\n path: string,\n): Divergence {\n // Identity / primitive fast path. Handles same-reference, and equal\n // primitives. `Object.is` so NaN === NaN and +0 ≠ -0 (matches structural\n // equality intent better than ===).\n if (Object.is(expected, actual)) return null;\n\n const te = typeOf(expected);\n const ta = typeOf(actual);\n // Different kinds at this node (e.g. object vs array, number vs string,\n // present vs null) — this node IS the divergence.\n if (te !== ta) return { path, expected, actual };\n\n if (te === \"array\") {\n const ae = expected as unknown[];\n const aa = actual as unknown[];\n if (ae.length !== aa.length) {\n // Length mismatch reported at the array node itself — the shape differs,\n // which is more informative than an arbitrary element index.\n return { path, expected, actual };\n }\n for (let i = 0; i < ae.length; i++) {\n const d = firstDivergence(ae[i], aa[i], indexPath(path, i));\n if (d !== null) return d;\n }\n return null;\n }\n\n if (te === \"object\") {\n const oe = expected as Record<string, unknown>;\n const oa = actual as Record<string, unknown>;\n // Sorted union of keys for deterministic traversal. A key present in one\n // but absent in the other diverges at that child path (its value is\n // `undefined` on the missing side).\n for (const key of unionKeys(oe, oa)) {\n const d = firstDivergence(oe[key], oa[key], keyPath(path, key));\n if (d !== null) return d;\n }\n return null;\n }\n\n // Primitives (string/number/boolean/bigint/symbol/function) that failed the\n // Object.is fast path, or null/undefined that differ — this node diverges.\n return { path, expected, actual };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/trace-replay/index.ts"],"names":[],"mappings":";;;;AAqEO,SAAS,WAAA,CAOd,OAAA,EACA,KAAA,EACA,GAAA,EACiB;AACjB,EAAA,MAAM,MAAA,GAAS,OAAO,OAAA,EAAS;AAAA,IAC7B,MAAM,KAAA,CAAM,IAAA;AAAA,IACZ,GAAA;AAAA,IACA,QAAQ,KAAA,CAAM;AAAA,GACf,CAAA;AACD,EAAA,MAAM,SAAS,MAAA,CAAO,KAAA;AACtB,EAA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AAM,CAAC,CAAC,CAAA;AAC1D,MAAA,IAAI,CAAA,KAAM,MAAM,OAAO,CAAA;AAAA,IACzB;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,QAAA,EAAU;AACnB,IAAA,MAAM,EAAA,GAAK,QAAA;AACX,IAAA,MAAM,EAAA,GAAK,MAAA;AAIX,IAAA,KAAA,MAAW,GAAA,IAAO,SAAA,CAAU,EAAA,EAAI,EAAE,CAAA,EAAG;AACnC,MAAA,MAAM,CAAA,GAAI,eAAA,CAAgB,EAAA,CAAG,GAAG,CAAA,EAAG,EAAA,CAAG,GAAG,CAAA,EAAG,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAC,CAAA;AAC9D,MAAA,IAAI,CAAA,KAAM,MAAM,OAAO,CAAA;AAAA,IACzB;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAIA,EAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,MAAA,EAAO;AAClC","file":"chunk-2AHAR7CX.js","sourcesContent":["// ---------------------------------------------------------------------------\n// trace-replay — replay a recorded Trace against a machine and diff the state.\n//\n// This is the back half of the record/replay feature. `../recorder` captures\n// a run (`loaded` + `msgs` + `finalState`); this module feeds that input\n// through the core `replay(machine, { msgs, ctx, loaded })` fold and asks:\n//\n// does the current reducer still produce the SAME final state for this\n// recorded input?\n//\n// Equal ⇒ the reducer is behavior-compatible with the recording. Diverged ⇒\n// the reducer changed for that input, and the divergence path\n// (`state.queue[2].status`) points at exactly the cell that drifted. This is\n// the regression / production-repro tool: record a prod incident, replay it\n// against the fixed reducer locally, confirm the fix changes the state at the\n// path you expected — or catch an unintended drift before it ships.\n//\n// Standalone by design. It imports ONLY the `Trace` type from `../recorder`\n// and the `replay` engine from `../index`. The deep-equal + first-divergence\n// path finder is self-contained (no external diff lib) — a richer pretty-diff\n// lands in `../devtools` later; trace-replay stays dependency-free so it can\n// run anywhere a machine runs (CI, a Worker, a Node script).\n// ---------------------------------------------------------------------------\n\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\nimport type { Trace } from \"../recorder\";\nimport { indexPath, keyPath, typeOf, unionKeys } from \"./state-walk\";\n\n/**\n * The outcome of {@link replayTrace}.\n *\n * @typeParam S - the machine's State type.\n */\nexport interface ReplayResult<S> {\n /** `true` iff the recomputed final state deep-equals the trace's `finalState`. */\n matches: boolean;\n /** The trace's recorded `finalState` — what the run originally produced. */\n expected: S;\n /** The state the current reducer produced for the same input. */\n actual: S;\n /**\n * Present iff `matches` is `false`. The FIRST point of divergence found by\n * a deterministic pre-order walk:\n * - `path` — a dotted/indexed access path from the state root, e.g.\n * `state.queue[2].status` or `state` for a root-level\n * scalar mismatch.\n * - `expected` — the recorded value at that path.\n * - `actual` — the recomputed value at that path.\n */\n divergence?: { path: string; expected: unknown; actual: unknown };\n}\n\n/**\n * Replay a recorded {@link Trace} against `machine` and diff the recomputed\n * final state against the recorded one.\n *\n * Runs the core pure fold `replay(machine, { msgs: trace.msgs, ctx,\n * loaded: trace.loaded })` — init + update only, never `interpret`, never a\n * `Store`, never a live subscription (see `replay` in ../index). The `ctx` is\n * supplied fresh by the caller: the trace is the INPUT (loaded + msgs); ctx is\n * the ENVIRONMENT the reducer runs against now.\n *\n * @param machine - the machine to replay against. Mutating its reducer (the\n * whole point of a regression check) is what makes a recorded\n * trace diverge.\n * @param trace - a Trace from `../recorder` (live `dump()` or a re-hydrated\n * `parseJSONL(...)`).\n * @param ctx - the runtime ctx, supplied fresh at replay time.\n */\nexport function replayTrace<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n trace: Trace<S, M>,\n ctx: Ctx,\n): ReplayResult<S> {\n const result = replay(machine, {\n msgs: trace.msgs,\n ctx,\n loaded: trace.loaded,\n });\n const actual = result.state;\n const expected = trace.finalState;\n\n const divergence = firstDivergence(expected, actual, \"state\");\n if (divergence === null) {\n return { matches: true, expected, actual };\n }\n return { matches: false, expected, actual, divergence };\n}\n\n/**\n * Order-insensitive structural deep-equality — the comparator the\n * record/replay lane owns, exposed so consumers (e.g. `@demlik/tea/parity`'s\n * `parityEqual`) reuse it rather than adding a fourth deep-compare. It is one\n * of three structural walkers in the package, divergent on purpose:\n * this `deepEqual` returns a boolean verdict (order-insensitive, for\n * replay/parity equality), `devtools`'s `diffState` returns a change list (for\n * a human-readable diff view), and `testing`'s `__deepEqual` is the assertion\n * helpers' internal compare — same shape, three jobs, not one to collapse.\n * `true` iff `a` and `b` are structurally equal under {@link firstDivergence}'s\n * walk (object keys compared order-insensitively, arrays index-by-index).\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n return firstDivergence(a, b, \"state\") === null;\n}\n\n// === deep-equal + first-divergence path finder ===\n//\n// One walk does both jobs: it returns the FIRST point where `expected` and\n// `actual` differ (as a path + the two values), or `null` when they are\n// deeply equal. \"First\" is defined by a deterministic pre-order traversal:\n// the node itself, then its children in a stable key order (array index\n// order; object keys sorted so the result does not depend on insertion\n// order — two states with the same data but different key order are equal,\n// and the reported path for a real mismatch is reproducible run-to-run).\n//\n// The path grammar (`typeOf`, `indexPath`/`keyPath` segments, `unionKeys`\n// order) is shared with devtools' `diffState` via `./state-walk`, so the two\n// walkers print the SAME path for the same cell by construction. Only the leaf\n// policy differs, on purpose: first-hit here, collect-all there.\n//\n// Scope: TEA state is plain JSON-shaped data (the substrate's __DEV__ guards\n// reject closures in Cmds, and states are conventionally serializable). So\n// the walk handles: primitives, null/undefined, arrays, and plain objects.\n// It treats other object kinds (Date, Map, Set, class instances) by reference\n// identity + a structural fallback via Object.entries — sufficient for the\n// JSON-shaped states this tool targets; a richer differ lives in ../devtools.\n\n/** A divergence record, or `null` when the two values are deeply equal. */\ntype Divergence = { path: string; expected: unknown; actual: unknown } | null;\n\nfunction firstDivergence(\n expected: unknown,\n actual: unknown,\n path: string,\n): Divergence {\n // Identity / primitive fast path. Handles same-reference, and equal\n // primitives. `Object.is` so NaN === NaN and +0 ≠ -0 (matches structural\n // equality intent better than ===).\n if (Object.is(expected, actual)) return null;\n\n const te = typeOf(expected);\n const ta = typeOf(actual);\n // Different kinds at this node (e.g. object vs array, number vs string,\n // present vs null) — this node IS the divergence.\n if (te !== ta) return { path, expected, actual };\n\n if (te === \"array\") {\n const ae = expected as unknown[];\n const aa = actual as unknown[];\n if (ae.length !== aa.length) {\n // Length mismatch reported at the array node itself — the shape differs,\n // which is more informative than an arbitrary element index.\n return { path, expected, actual };\n }\n for (let i = 0; i < ae.length; i++) {\n const d = firstDivergence(ae[i], aa[i], indexPath(path, i));\n if (d !== null) return d;\n }\n return null;\n }\n\n if (te === \"object\") {\n const oe = expected as Record<string, unknown>;\n const oa = actual as Record<string, unknown>;\n // Sorted union of keys for deterministic traversal. A key present in one\n // but absent in the other diverges at that child path (its value is\n // `undefined` on the missing side).\n for (const key of unionKeys(oe, oa)) {\n const d = firstDivergence(oe[key], oa[key], keyPath(path, key));\n if (d !== null) return d;\n }\n return null;\n }\n\n // Primitives (string/number/boolean/bigint/symbol/function) that failed the\n // Object.is fast path, or null/undefined that differ — this node diverges.\n return { path, expected, actual };\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createMonitoredRun } from './chunk-
|
|
2
|
-
import { createLlmCall } from './chunk-
|
|
3
|
-
import { createResilientCall } from './chunk-
|
|
1
|
+
import { createMonitoredRun } from './chunk-LJJV6ZD5.js';
|
|
2
|
+
import { createLlmCall } from './chunk-FCKP6N7Y.js';
|
|
3
|
+
import { createResilientCall } from './chunk-B5RAZVXW.js';
|
|
4
4
|
import { MsgType } from './chunk-JELSZN25.js';
|
|
5
5
|
import { createFanOut, initFanOut } from './chunk-D736QUGF.js';
|
|
6
6
|
import { subscribeDeadline } from './chunk-RMX4EOQK.js';
|
|
7
|
-
import { defineMachine } from './chunk-
|
|
7
|
+
import { defineMachine } from './chunk-D4NJBQAH.js';
|
|
8
8
|
|
|
9
9
|
// src/agent/schema.ts
|
|
10
10
|
function schemaFromGuard(guard, name) {
|
|
@@ -515,5 +515,5 @@ function createAgent(config) {
|
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
export { COMPACTION_PURPOSE, agentBootMsg, agentEvents, agentTurnSchema, compactionSummarySchema, createAgent, isAgentTurn, isCompactionSummary, liftAgent, mergeInterpret, status };
|
|
518
|
-
//# sourceMappingURL=chunk-
|
|
519
|
-
//# sourceMappingURL=chunk-
|
|
518
|
+
//# sourceMappingURL=chunk-5W7CNAHB.js.map
|
|
519
|
+
//# sourceMappingURL=chunk-5W7CNAHB.js.map
|