@demlik/tea 0.14.0 → 0.16.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.
Files changed (116) hide show
  1. package/README.md +30 -7
  2. package/dist/agent/index.d.ts +49 -36
  3. package/dist/agent/index.js +12 -8
  4. package/dist/chunk-4LPY67E4.js +18 -0
  5. package/dist/chunk-4LPY67E4.js.map +1 -0
  6. package/dist/chunk-5XU6ZJO2.js +533 -0
  7. package/dist/chunk-5XU6ZJO2.js.map +1 -0
  8. package/dist/{chunk-AQ6ZIMEA.js → chunk-6NG4V5SB.js} +89 -115
  9. package/dist/chunk-6NG4V5SB.js.map +1 -0
  10. package/dist/{chunk-HYDWG35Q.js → chunk-7MGXQZPW.js} +11 -9
  11. package/dist/chunk-7MGXQZPW.js.map +1 -0
  12. package/dist/{chunk-BLJ2JQSH.js → chunk-BCTEOVOU.js} +3 -3
  13. package/dist/{chunk-BLJ2JQSH.js.map → chunk-BCTEOVOU.js.map} +1 -1
  14. package/dist/chunk-CH5KTOEZ.js +710 -0
  15. package/dist/chunk-CH5KTOEZ.js.map +1 -0
  16. package/dist/chunk-CIHSHLQX.js +64 -0
  17. package/dist/chunk-CIHSHLQX.js.map +1 -0
  18. package/dist/{chunk-Z2L3LSNV.js → chunk-EHUDXAKC.js} +246 -210
  19. package/dist/chunk-EHUDXAKC.js.map +1 -0
  20. package/dist/chunk-GOX2CYIM.js +380 -0
  21. package/dist/chunk-GOX2CYIM.js.map +1 -0
  22. package/dist/chunk-IVJP3GKJ.js +104 -0
  23. package/dist/chunk-IVJP3GKJ.js.map +1 -0
  24. package/dist/{chunk-F7FMAWLA.js → chunk-MVZS5FDM.js} +13 -6
  25. package/dist/chunk-MVZS5FDM.js.map +1 -0
  26. package/dist/{chunk-LYLTKJWM.js → chunk-MYNLY3HP.js} +9 -8
  27. package/dist/chunk-MYNLY3HP.js.map +1 -0
  28. package/dist/{chunk-I5MQMJDW.js → chunk-NSIAORRY.js} +20 -30
  29. package/dist/chunk-NSIAORRY.js.map +1 -0
  30. package/dist/{chunk-MYXFNWAJ.js → chunk-QNGYQMZB.js} +4 -4
  31. package/dist/chunk-QNGYQMZB.js.map +1 -0
  32. package/dist/chunk-WT5PBPLB.js +98 -0
  33. package/dist/chunk-WT5PBPLB.js.map +1 -0
  34. package/dist/{core-CTzMJ82M.d.ts → core-BbgtiXdg.d.ts} +231 -139
  35. package/dist/do/index.d.ts +37 -32
  36. package/dist/do/index.js +21 -14
  37. package/dist/do/index.js.map +1 -1
  38. package/dist/{durable-effects-B0-qGQDy.d.ts → durable-effects-7MTK_jnj.d.ts} +1 -1
  39. package/dist/effect/index.d.ts +151 -0
  40. package/dist/effect/index.js +98 -0
  41. package/dist/effect/index.js.map +1 -0
  42. package/dist/extension/index.d.ts +6 -7
  43. package/dist/extension/index.js +3 -2
  44. package/dist/extension/index.js.map +1 -1
  45. package/dist/flow/index.d.ts +68 -70
  46. package/dist/flow/index.js +32 -27
  47. package/dist/flow/index.js.map +1 -1
  48. package/dist/idempotency/index.d.ts +6 -7
  49. package/dist/idempotency/index.js +4 -2
  50. package/dist/{index-DJWIER_3.d.ts → index-7vV8xmsD.d.ts} +1 -1
  51. package/dist/{index-NjrT3fL2.d.ts → index-Bz5Rh9Ga.d.ts} +19 -96
  52. package/dist/index-CjFDUBeq.d.ts +207 -0
  53. package/dist/{index-6A7dB8f6.d.ts → index-CkFYA9Y6.d.ts} +14 -16
  54. package/dist/{index-B5BZ-_cT.d.ts → index-Cou86-GX.d.ts} +189 -108
  55. package/dist/{index-TvRb1KVf.d.ts → index-DU6JpQ8G.d.ts} +1 -1
  56. package/dist/{index-q0hXFeZ0.d.ts → index-Xufl55W8.d.ts} +286 -215
  57. package/dist/{index-4vZzljCD.d.ts → index-_dOR3xqA.d.ts} +57 -45
  58. package/dist/index.d.ts +181 -385
  59. package/dist/index.js +2 -1
  60. package/dist/jev/index.d.ts +147 -99
  61. package/dist/jev/index.js +329 -233
  62. package/dist/jev/index.js.map +1 -1
  63. package/dist/{machine-CdIcN2Xm.d.ts → machine-BQzTV8On.d.ts} +171 -280
  64. package/dist/machine-viz/index.d.ts +5 -5
  65. package/dist/machine-viz/index.js +8 -4
  66. package/dist/machine-viz/index.js.map +1 -1
  67. package/dist/mem/index.d.ts +3 -4
  68. package/dist/mem/index.js +2 -1
  69. package/dist/mem/index.js.map +1 -1
  70. package/dist/node/index.d.ts +119 -78
  71. package/dist/node/index.js +52 -38
  72. package/dist/node/index.js.map +1 -1
  73. package/dist/paginate/index.d.ts +27 -33
  74. package/dist/paginate/index.js +6 -4
  75. package/dist/parity/index.d.ts +4 -5
  76. package/dist/parity/index.js +3 -2
  77. package/dist/parity/index.js.map +1 -1
  78. package/dist/pbt/index.d.ts +2 -2
  79. package/dist/pbt/index.js +2 -1
  80. package/dist/pbt/index.js.map +1 -1
  81. package/dist/persistence/index.d.ts +6 -7
  82. package/dist/persistence/index.js +5 -3
  83. package/dist/promise/index.d.ts +186 -0
  84. package/dist/promise/index.js +5 -0
  85. package/dist/promise/index.js.map +1 -0
  86. package/dist/protocol-ClRZBhHQ.d.ts +53 -0
  87. package/dist/react/index.d.ts +36 -17
  88. package/dist/react/index.js +27 -4
  89. package/dist/react/index.js.map +1 -1
  90. package/dist/resilience/index.d.ts +63 -455
  91. package/dist/resilience/index.js +37 -483
  92. package/dist/resilience/index.js.map +1 -1
  93. package/dist/{runtime-types-LWDoi943.d.ts → runtime-types-CiVpC0HN.d.ts} +131 -388
  94. package/dist/testing/index.d.ts +165 -15
  95. package/dist/testing/index.js +104 -3
  96. package/dist/testing/index.js.map +1 -1
  97. package/dist/timing/index.d.ts +25 -22
  98. package/dist/timing/index.js +4 -3
  99. package/dist/timing/index.js.map +1 -1
  100. package/dist/{types-DP3f5NIl.d.ts → types-LxZxGYda.d.ts} +2 -2
  101. package/dist/work-queue/index.d.ts +5 -6
  102. package/package.json +18 -5
  103. package/dist/chunk-AQ6ZIMEA.js.map +0 -1
  104. package/dist/chunk-F2US5BW6.js +0 -72
  105. package/dist/chunk-F2US5BW6.js.map +0 -1
  106. package/dist/chunk-F7FMAWLA.js.map +0 -1
  107. package/dist/chunk-HUKZQX6U.js +0 -97
  108. package/dist/chunk-HUKZQX6U.js.map +0 -1
  109. package/dist/chunk-HYDWG35Q.js.map +0 -1
  110. package/dist/chunk-I5MQMJDW.js.map +0 -1
  111. package/dist/chunk-LYLTKJWM.js.map +0 -1
  112. package/dist/chunk-MYXFNWAJ.js.map +0 -1
  113. package/dist/chunk-RQULHGYH.js +0 -1804
  114. package/dist/chunk-RQULHGYH.js.map +0 -1
  115. package/dist/chunk-Z2L3LSNV.js.map +0 -1
  116. package/dist/index-DMCeMPMJ.d.ts +0 -272
@@ -1,23 +1,21 @@
1
- import { R as Runtime, C as CtxArg } from '../runtime-types-LWDoi943.js';
2
- import { C as Cmd, S as Sub, M as Machine, i as CmdValue, a as CmdOf, b as CmdDef } from '../core-CTzMJ82M.js';
3
- export { B as BatchWindow, b as BatchWindowConfig, c as BatchWindowExpired, d as BatchWindowKnob, a as BatchWindowSub, e as addItem, f as batchWindowExpired, g as createBatchWindow, i as initBatchWindow, o as onWindow, s as subsFor, h as subscribeBatchWindow } from '../index-4vZzljCD.js';
4
- export { a as FanOutConfig, b as FanOutDone, c as FanOutFailed, d as FanOutPorts, F as FanOutState, e as createFanOut, i as initFanOut, f as isComplete } from '../index-6A7dB8f6.js';
5
- export { E as EndedRun, M as MonitoredRunCmd, b as MonitoredRunConfig, c as MonitoredRunPorts, a as MonitoredRunState, d as MonitoredRunTimerMsg, R as RunFailure, S as StageResult, e as createMonitoredRun, l as liftRun } from '../index-NjrT3fL2.js';
1
+ import { R as Runtime, C as CtxArg } from '../runtime-types-CiVpC0HN.js';
2
+ import { C as Cmd, S as Sub, M as Machine, R as RunHandlers, b as CmdDef, T as TimerDeps, c as CmdOf } from '../core-BbgtiXdg.js';
3
+ export { B as BatchWindow, c as BatchWindowConfig, b as BatchWindowExpired, d as BatchWindowKnob, a as BatchWindowSub, e as addItem, f as batchWindowExpired, g as createBatchWindow, i as initBatchWindow, o as onWindow, s as subsFor, h as subscribeBatchWindow, t as timerFor } from '../index-_dOR3xqA.js';
4
+ export { a as FanOutConfig, b as FanOutDone, c as FanOutFailed, d as FanOutPorts, F as FanOutState, e as createFanOut, i as initFanOut, f as isComplete } from '../index-CkFYA9Y6.js';
5
+ export { E as EndedRun, M as MonitoredRunCmd, b as MonitoredRunConfig, a as MonitoredRunState, c as MonitoredRunTimerMsg, R as RunFailure, S as StageResult, d as createMonitoredRun, l as liftRun } from '../index-Bz5Rh9Ga.js';
6
6
  import { RetryState, AnyRetryPolicy, RetryPolicy } from '../retry-backoff/index.js';
7
7
  import { I as IdempotencyStore } from '../index-Bc40JWVl.js';
8
- import { a as DeadlineSub, T as TtlCache } from '../index-q0hXFeZ0.js';
9
- export { D as DeadlineExceeded, b as deadlineSub, s as subscribeDeadline } from '../index-q0hXFeZ0.js';
10
- import { C as CircuitConfig, c as RateLimitConfig, D as DeadlineConfig, d as ResilientPorts, F as FailMsg, S as SucceedMsg } from '../index-B5BZ-_cT.js';
8
+ import { a as DeadlineSub, T as TtlCache } from '../index-Xufl55W8.js';
9
+ import { f as CircuitConfig, l as RateLimitConfig, m as DeadlineConfig, b as ResilientTimerMsg } from '../index-Cou86-GX.js';
11
10
  import { PaginatedWalkState, PaginatedWalkTimerMsg, FetchPageCmd, PageErrMsg, PageOkMsg } from '../paginate/index.js';
12
- import { Q as QueueItem } from '../index-DJWIER_3.js';
13
- export { E as EnqueueInput } from '../index-DJWIER_3.js';
14
- import { D as DeliveryId, E as EffectLedgerEvent } from '../durable-effects-B0-qGQDy.js';
15
- export { a as EffectConfirmed, b as EffectOwed, e as emptyLedger } from '../durable-effects-B0-qGQDy.js';
11
+ import { Q as QueueItem } from '../index-7vV8xmsD.js';
12
+ export { E as EnqueueInput } from '../index-7vV8xmsD.js';
13
+ import { D as DeliveryId, E as EffectLedgerEvent } from '../durable-effects-7MTK_jnj.js';
14
+ export { a as EffectConfirmed, b as EffectOwed, e as emptyLedger } from '../durable-effects-7MTK_jnj.js';
16
15
  export { D as Debounced, d as debounce } from '../index-DHSUmQTR.js';
17
- export { c as SnapshotSavedMsg, S as SnapshotWriteCmd } from '../index-DMCeMPMJ.js';
18
- import 'better-result';
19
- import 'zod';
20
- import '../types-DP3f5NIl.js';
16
+ export { b as SnapshotSavedMsg, S as SnapshotWriteCmd } from '../index-CjFDUBeq.js';
17
+ import '@standard-schema/spec';
18
+ import '../types-LxZxGYda.js';
21
19
 
22
20
  /**
23
21
  * internal/flow/await-terminal — run a ONE-SHOT / decision-procedure machine to a
@@ -45,7 +43,7 @@ import '../types-DP3f5NIl.js';
45
43
  * this helper does NOT invent one; the caller names their own terminal states.
46
44
  *
47
45
  * The optional `timeoutMs` is a plain caller-boundary timer (not an in-loop
48
- * progress deadline — see `../deadline` / `../with-deadline` for that shape): it
46
+ * progress deadline — see `../deadline` for that shape): it
49
47
  * clears on resolve and REJECTS with the `instanceof`-checkable
50
48
  * {@link TerminalTimeoutError} if the deadline elapses first, never silently
51
49
  * resolving.
@@ -100,17 +98,21 @@ declare function awaitTerminal<S, M extends {
100
98
  * on BOTH the resolve and reject paths. Wraps {@link awaitTerminal}.
101
99
  *
102
100
  * The seed carries the machine's `ctx` (conditionally optional, exactly as
103
- * `run`'s `ctx` — a pure machine omits it) and the `msgs` to dispatch once
104
- * booted. A `timeoutMs` in `opts` bounds the await identically to `awaitTerminal`.
101
+ * `run`'s `ctx` — a pure machine omits it), the handlers `run` takes beside the
102
+ * machine (`interpret`, and `subscribe` when its Subs need runners), and the
103
+ * `msgs` to dispatch once
104
+ * booted. A `timeoutMs` in `opts` bounds the await identically to
105
+ * `awaitTerminal`.
105
106
  *
106
107
  * @param machine the machine to boot.
107
- * @param seed `{ ctx?, msgs }` — the boot context and the seed messages.
108
+ * @param seed `{ ctx?, interpret, subscribe?, msgs }` — the boot context, the
109
+ * handlers, and the seed messages.
108
110
  * @param isTerminal caller-supplied terminal predicate over the machine's state.
109
111
  * @param opts optional bounded `timeoutMs` deadline (see {@link AwaitTerminalOptions}).
110
112
  */
111
113
  declare function runToTerminal<S, M extends {
112
114
  type: string;
113
- }, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, seed: CtxArg<Ctx> & {
115
+ }, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, seed: CtxArg<Ctx> & NoInfer<RunHandlers<M, C, U, Ctx>> & {
114
116
  readonly msgs: readonly M[];
115
117
  }, isTerminal: (state: S) => boolean, opts?: AwaitTerminalOptions): Promise<S>;
116
118
 
@@ -176,7 +178,9 @@ declare function runToTerminal<S, M extends {
176
178
  * },
177
179
  *
178
180
  * // Subs — the knob owns the interval/backoff deadline:
179
- * subscriptions: (s) => poll.subs(s.poll),
181
+ * types: { ..., sub: {} as DeadlinesSub },
182
+ * subs: [deadlinesSub((s) => poll.subs(s.poll))],
183
+ * // at run: run(machine, { interpret, subscribe: { deadline: subscribeDeadline } })
180
184
  *
181
185
  * The cadence has exactly ONE source: the `everyMs` deadline Sub. `start`,
182
186
  * `tickResult`, and `tickErr` only RE-ARM the deadline (they emit no cadence
@@ -194,8 +198,8 @@ declare function runToTerminal<S, M extends {
194
198
  * verb body names the global RNG). `replay` reconstructs a poll run exactly.
195
199
  *
196
200
  * NOT a substrate primitive: it depends only on sibling subpaths
197
- * (`../deadline`, `../retry-backoff`, `../idempotency`) and the core `Cmd` /
198
- * `Sub` types. Internal since #48 — not published on any subpath; reached from
201
+ * (`../deadline`, `../retry-backoff`, `../idempotency`) and the core `Cmd`
202
+ * type. Internal since #48 — not published on any subpath; reached from
199
203
  * inside the package as `internal/flow/poller`. The L1 escape hatch is those
200
204
  * three siblings threaded by hand.
201
205
  */
@@ -218,7 +222,7 @@ interface PollerConfig<State, R> {
218
222
  * The stop predicate, read against the consumer's whole Model. When it
219
223
  * returns `true`, the poller is DONE: `subs` returns `[]` (the timer
220
224
  * disarms) and no further tick is scheduled. Pure — it must not read the
221
- * clock or mutate; the substrate calls it inside `subscriptions(state)`.
225
+ * clock or mutate; the consumer's reducer cell calls it (`untilHeld`).
222
226
  */
223
227
  readonly until: (state: State) => boolean;
224
228
  /**
@@ -335,22 +339,20 @@ type PollerGaveUp<R> = Extract<PollerState<R>, {
335
339
  phase: "gave_up";
336
340
  }>;
337
341
  /**
338
- * The poller Sub type — a `../deadline` Sub under a fixed id family. One id per
339
- * knob instance keeps the reconcile pass from churning the timer: the same id
340
- * across transitions means "same armed deadline", even as `nextAtMs` advances.
342
+ * The deadline the poller lists — a `../deadline` entry under the
343
+ * `poller:tick:` id family (see `pollerSubId`).
341
344
  */
342
345
  type PollerSub = DeadlineSub;
343
346
  /**
344
347
  * The knob handle returned by `createPoller`. Spread its hooks into your
345
348
  * machine: `init()` seeds the slice, `start(...)` arms the first tick,
346
349
  * `tickResult` / `tickErr` are the two update verbs, and `subs(...)` returns the
347
- * timer Sub while the poller is live.
350
+ * tick deadline while the poller is live.
348
351
  *
349
352
  * Pure-ops + subs module: there is no `handlers(ports)` cell. The poller's I/O
350
353
  * is the consumer's own `onTick` Cmd run by the consumer's `interpret` — the
351
- * knob never owns a port. (Compare `../deadline`, which ships a `subscribe`
352
- * cell; the poller reuses `../deadline`'s, so it has nothing of its own to
353
- * splice into `interpret`.)
354
+ * knob never owns a port. (Compare `../deadline`, which ships a `deadline`
355
+ * runner; the poller reuses it, so it has nothing of its own to hand `run`.)
354
356
  */
355
357
  interface Poller<State, R> {
356
358
  /** Seed the Model slice. Idle until `start(...)` arms the first tick. */
@@ -433,16 +435,16 @@ interface Poller<State, R> {
433
435
  */
434
436
  tickErr(state: PollerState<R>, error: unknown, at: number): readonly [PollerPolling<R> | PollerGaveUp<R>, readonly Cmd[]];
435
437
  /**
436
- * The pre-wired subscriptions cell. Returns the single tick-deadline Sub
437
- * while the poller is `"polling"` with an armed `nextAtMs`; returns `[]`
438
- * once `"done"` / `"gave_up"` (the timer disarms) or before `start`. Assign
439
- * directly: `subscriptions: (s) => poll.subs(s.poll)`.
438
+ * The tick deadline, listed while the poller is `"polling"` with an armed
439
+ * `nextAtMs`; `[]` once `"done"` / `"gave_up"` (the timer disarms) or before
440
+ * `start`. Declare it on the machine:
441
+ * `subs: [deadlinesSub((s) => poll.subs(s.poll))]`.
440
442
  *
441
- * The `DeadlineSub` it returns is consumed by `../deadline`'s
442
- * `subscribeDeadline` cell, which the consumer wires into `subscribe` —
443
- * the poller does not redraw the timer lifecycle.
443
+ * The list is armed by `../deadline`'s `subscribeDeadline` runner, which the
444
+ * consumer passes to `run` as `subscribe.deadline` — the poller does not
445
+ * redraw the timer lifecycle.
444
446
  */
445
- subs(state: PollerState<R>): readonly Sub[];
447
+ subs(state: PollerState<R>): readonly PollerSub[];
446
448
  }
447
449
  /**
448
450
  * Build a poller knob from `config`. Returns the hook bag to spread into a
@@ -583,54 +585,50 @@ interface ReconcilerState<Actual, Change, Page, Cursor = number> {
583
585
  /**
584
586
  * The actual-list page-fetch effect: the inherited `resilient_run` Cmd from
585
587
  * paginated-walk, whose `input` is the `Cursor` to fetch and whose `key` is the
586
- * fixed `PAGE_KEY`. The consumer's `handlers(ports)` interprets it.
588
+ * fixed `PAGE_KEY`. It is `Cmd.define`d; the handler you write fetches ONE page
589
+ * of the ACTUAL listing and returns `ok(page)` or
590
+ * `err({ _tag: "port_rejected", … })`.
587
591
  */
588
592
  type ScanPageCmd<Cursor> = FetchPageCmd<Cursor>;
589
- /** Page-settled Msgs the scan `handlers` port dispatches back (inherited verbatim). */
593
+ /** The page-settled Msgs the engine mints from that handler's outcome. */
590
594
  type ScanPageOkMsg<Page> = PageOkMsg<Page>;
591
595
  type ScanPageErrMsg = PageErrMsg;
592
596
  /** The scan retry / deadline timer Msg — inherited from paginated-walk. */
593
597
  type ReconcilerTimerMsg = PaginatedWalkTimerMsg;
594
- /**
595
- * Ports the consumer supplies to `handlers`. `run(cursor)` fetches ONE page of
596
- * the ACTUAL listing for the given cursor; throwing routes to `pageErr` (and
597
- * thus the scan backoff). Same shape as paginated-walk's port.
598
- */
599
- interface ReconcilerPorts<Cursor, Page> extends ResilientPorts<Cursor, Page> {
600
- }
601
598
  /**
602
599
  * Build a reconciler knob from `config`. `rng` is injected for the underlying
603
600
  * scan-retry jitter — pass a fixed `() => 0` in tests to pin backoff; defaults
604
601
  * to `Math.random` (read at the verb boundary inside resilient-call, never in a
605
602
  * reconciler verb). Inherited straight from paginated-walk.
606
603
  *
607
- * Returns the uniform L2 knob contract: `init()`, the verbs `scan` / `pageOk` /
608
- * `pageErr` / `planned` / `applyNext` / `applied` / `onTimer`, the derived
609
- * `isComplete`, `subs(state)`, and `handlers(ports)`.
604
+ * Returns plain functions: `init()`, the verbs `scan` / `pageOk` / `pageErr` /
605
+ * `planned` / `applyNext` / `applied` / `onTimer`, the derived `isComplete`,
606
+ * `deadlines(state)` / `timer(state)`, and the scan's page-fetch Cmd def
607
+ * (`scanPage`) to list in the machine's `cmds`.
610
608
  */
611
609
  declare function createReconciler<Actual, Desired, Page, Change, ApplyCmd extends Cmd = Cmd, Cursor = number>(config: ReconcilerConfig<Actual, Desired, Page, Change, ApplyCmd, Cursor>, rng?: () => number): {
610
+ /** The scan's page-fetch Cmd def — list it in the machine's `cmds`. */
611
+ scanPage: CmdDef<"resilient_run", {
612
+ readonly key: string;
613
+ readonly input: Cursor;
614
+ }, Page, {
615
+ readonly [detail: string]: unknown;
616
+ readonly _tag: "deadline_exceeded";
617
+ } | {
618
+ readonly [detail: string]: unknown;
619
+ readonly _tag: "port_rejected";
620
+ }>;
612
621
  init: () => ReconcilerState<Actual, Change, Page, Cursor>;
613
622
  scan: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
614
- pageOk: (s: ReconcilerState<Actual, Change, Page, Cursor>, page: Page, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
615
- pageErr: (s: ReconcilerState<Actual, Change, Page, Cursor>, error: unknown, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
623
+ pageOk: (s: ReconcilerState<Actual, Change, Page, Cursor>, msg: ScanPageOkMsg<Page>) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
624
+ pageErr: (s: ReconcilerState<Actual, Change, Page, Cursor>, msg: ScanPageErrMsg) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
616
625
  planned: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number, changes?: readonly Change[]) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
617
626
  applyNext: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
618
627
  applied: (s: ReconcilerState<Actual, Change, Page, Cursor>, change: Change, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
619
628
  onTimer: (s: ReconcilerState<Actual, Change, Page, Cursor>, msg: ReconcilerTimerMsg) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
620
629
  isComplete: (s: ReconcilerState<Actual, Change, Page, Cursor>) => boolean;
621
- subs: (s: ReconcilerState<Actual, Change, Page, Cursor>) => readonly DeadlineSub[];
622
- handlers: (ports: ReconcilerPorts<Cursor, Page>) => {
623
- resilient_run: (cmd: CmdValue<"resilient_run", {
624
- readonly key: string;
625
- readonly input: Cursor;
626
- }, {
627
- readonly [detail: string]: unknown;
628
- readonly _tag: "deadline_exceeded";
629
- } | {
630
- readonly [detail: string]: unknown;
631
- readonly _tag: "port_rejected";
632
- }, unknown>, ctx: Readonly<Record<never, never>>) => Promise<FailMsg | SucceedMsg<Page>>;
633
- };
630
+ deadlines: (s: ReconcilerState<Actual, Change, Page, Cursor>) => readonly DeadlineSub[];
631
+ timer: (s: ReconcilerState<Actual, Change, Page, Cursor>) => TimerDeps<ResilientTimerMsg<"resilient">> | null;
634
632
  };
635
633
  /**
636
634
  * Lift a knob result `[slice, cmds]` into a host `[State, cmds]` where the slice
@@ -1107,7 +1105,7 @@ declare function workflowActivityDef<A>(): CmdDef<"workflow_activity", {
1107
1105
  readonly id: DeliveryId;
1108
1106
  /** The opaque activity to perform. */
1109
1107
  readonly activity: A;
1110
- }, void, never, unknown>;
1108
+ }, undefined, never>;
1111
1109
  type ActivityCmd<A> = CmdOf<ReturnType<typeof workflowActivityDef<A>>>;
1112
1110
  /**
1113
1111
  * Dispatch a compensation (#125). Same shape + ledger discipline as
@@ -1125,7 +1123,7 @@ declare function workflowCompensationDef<A>(): CmdDef<"workflow_compensation", {
1125
1123
  readonly id: DeliveryId;
1126
1124
  /** The opaque compensating (inverse) activity to perform. */
1127
1125
  readonly compensation: A;
1128
- }, void, never, unknown>;
1126
+ }, undefined, never>;
1129
1127
  type CompensationCmd<A> = CmdOf<ReturnType<typeof workflowCompensationDef<A>>>;
1130
1128
  /** The Cmd union this module emits: forward activity dispatches AND (#125)
1131
1129
  * reverse compensation dispatches. The owed/confirmed ledger events are not
@@ -1292,4 +1290,4 @@ declare function createWorkflow<A, R, F>(restore?: {
1292
1290
  */
1293
1291
  declare function foldWorkflow<A, R, F>(steps: WorkflowSteps<A>, msgs: Iterable<WorkflowMsg<R, F>>): WorkflowState<A, R, F>;
1294
1292
 
1295
- export { type ActivityCmd, type ActivityErr, type ActivityOk, type AwaitTerminalOptions, type CompensatingWorkflow, type CompensationCmd, type CompensationErr, type CompensationFailedWorkflow, type CompensationOk, type CompletedStep, type CompletedWorkflow, DeadlineSub, DeliveryId, EffectLedgerEvent, type FailedCompensatedWorkflow, type FailedWorkflow, type InFlightActivity, type InFlightCompensation, type Poller, type PollerConfig, type PollerDone, type PollerGaveUp, type PollerPolling, type PollerState, type PollerSub, type ReconcilePhase, type ReconcilerConfig, type ReconcilerPorts, type ReconcilerState, type ReconcilerTimerMsg, type RunningWorkflow, type SagaConfig, type SagaPhase, type SagaState, type SagaStep, type ScanPageCmd, type ScanPageErrMsg, type ScanPageOkMsg, type StepId, TerminalTimeoutError, WORKFLOW_MSG_TYPES, WORKFLOW_STATUSES, type Workflow, type WorkflowCmd, type WorkflowMsg, type WorkflowMsgType, type WorkflowReducerStep, type WorkflowState, type WorkflowStatus, type WorkflowStep, type WorkflowSteps, awaitTerminal, createPoller, createReconciler, createSaga, createWorkflow, foldWorkflow, initSaga, isAborted, isCommitted, isCompensationFailed, isSettled, liftReconciler, routeWorkflowMsg, runToTerminal, workflowActivityDef, workflowCompensationDef };
1293
+ export { type ActivityCmd, type ActivityErr, type ActivityOk, type AwaitTerminalOptions, type CompensatingWorkflow, type CompensationCmd, type CompensationErr, type CompensationFailedWorkflow, type CompensationOk, type CompletedStep, type CompletedWorkflow, DeliveryId, EffectLedgerEvent, type FailedCompensatedWorkflow, type FailedWorkflow, type InFlightActivity, type InFlightCompensation, type Poller, type PollerConfig, type PollerDone, type PollerGaveUp, type PollerPolling, type PollerState, type PollerSub, type ReconcilePhase, type ReconcilerConfig, type ReconcilerState, type ReconcilerTimerMsg, type RunningWorkflow, type SagaConfig, type SagaPhase, type SagaState, type SagaStep, type ScanPageCmd, type ScanPageErrMsg, type ScanPageOkMsg, type StepId, TerminalTimeoutError, WORKFLOW_MSG_TYPES, WORKFLOW_STATUSES, type Workflow, type WorkflowCmd, type WorkflowMsg, type WorkflowMsgType, type WorkflowReducerStep, type WorkflowState, type WorkflowStatus, type WorkflowStep, type WorkflowSteps, awaitTerminal, createPoller, createReconciler, createSaga, createWorkflow, foldWorkflow, initSaga, isAborted, isCommitted, isCompensationFailed, isSettled, liftReconciler, routeWorkflowMsg, runToTerminal, workflowActivityDef, workflowCompensationDef };
@@ -1,19 +1,21 @@
1
- export { addItem, batchWindowExpired, createBatchWindow, initBatchWindow, onWindow, subsFor, subscribeBatchWindow } from '../chunk-F7FMAWLA.js';
1
+ import { createPaginatedWalk, PAGE_KEY } from '../chunk-NSIAORRY.js';
2
+ export { addItem, batchWindowExpired, createBatchWindow, initBatchWindow, onWindow, subsFor, subscribeBatchWindow, timerFor } from '../chunk-MVZS5FDM.js';
2
3
  export { debounce } from '../chunk-LFZUK6J2.js';
3
- import { createPaginatedWalk, PAGE_KEY } from '../chunk-I5MQMJDW.js';
4
4
  import { pendingEffectsLedger, foldLedger, survivingEffects } from '../chunk-6IQPODUF.js';
5
5
  export { emptyLedger } from '../chunk-6IQPODUF.js';
6
- export { createMonitoredRun, liftRun } from '../chunk-HYDWG35Q.js';
7
- export { createFanOut, initFanOut, isComplete } from '../chunk-MYXFNWAJ.js';
6
+ export { createMonitoredRun, liftRun } from '../chunk-7MGXQZPW.js';
7
+ import '../chunk-CIHSHLQX.js';
8
+ export { createFanOut, initFanOut, isComplete } from '../chunk-QNGYQMZB.js';
8
9
  import { idempotencyMemory } from '../chunk-PR6TB3BL.js';
9
10
  import { queueAdapter } from '../chunk-TXN2KFHF.js';
10
- import '../chunk-HUKZQX6U.js';
11
- import '../chunk-AQ6ZIMEA.js';
11
+ import '../chunk-6NG4V5SB.js';
12
12
  import { asRng, defaultRetryPolicy, initRetry, recordFailure, shouldRetry, nextDelayMs } from '../chunk-VBDU4JL6.js';
13
- import { deadlineSub, initCache, get, set } from '../chunk-F2US5BW6.js';
14
- export { deadlineSub, subscribeDeadline } from '../chunk-F2US5BW6.js';
15
- import { run, Cmd } from '../chunk-RQULHGYH.js';
16
- import { z } from 'zod';
13
+ import { undefinedOnly, unchecked } from '../chunk-4LPY67E4.js';
14
+ import { deadlineSub, initCache, get, set } from '../chunk-IVJP3GKJ.js';
15
+ import { run } from '../chunk-WT5PBPLB.js';
16
+ import '../chunk-5XU6ZJO2.js';
17
+ import '../chunk-GOX2CYIM.js';
18
+ import { Cmd } from '../chunk-CH5KTOEZ.js';
17
19
 
18
20
  // src/internal/flow/await-terminal/index.ts
19
21
  var TerminalTimeoutError = class extends Error {
@@ -67,10 +69,10 @@ function awaitTerminal(runtime, isTerminal, opts = {}) {
67
69
  });
68
70
  }
69
71
  async function runToTerminal(machine, seed, isTerminal, opts = {}) {
70
- const { msgs, ...ctxArg } = seed;
72
+ const { msgs, ...runOpts } = seed;
71
73
  const runtime = await run(
72
74
  machine,
73
- ctxArg
75
+ runOpts
74
76
  ).ready;
75
77
  try {
76
78
  const terminal = awaitTerminal(runtime, isTerminal, opts);
@@ -228,12 +230,13 @@ function createReconciler(config, rng = Math.random) {
228
230
  const next = { ...s, phase: "scanning", walk: w };
229
231
  return [next, cmds];
230
232
  }
231
- function pageOk(s, page, at) {
233
+ function pageOk(s, msg) {
234
+ const { value: page, at } = msg;
232
235
  if (s.phase !== "scanning") {
233
- const [w2] = walk.pageOk(s.walk, page, at);
236
+ const [w2] = walk.pageOk(s.walk, msg);
234
237
  return [withWalk(s, w2), []];
235
238
  }
236
- const [w, walkCmds] = walk.pageOk(s.walk, page, at);
239
+ const [w, walkCmds] = walk.pageOk(s.walk, msg);
237
240
  const actual = [...s.actual, ...config.itemsOf(page)];
238
241
  const scanned = { ...s, walk: w, actual };
239
242
  const cmds = walkCmds;
@@ -243,8 +246,8 @@ function createReconciler(config, rng = Math.random) {
243
246
  }
244
247
  return [scanned, cmds];
245
248
  }
246
- function pageErr(s, error, at) {
247
- const [w, cmds] = walk.pageErr(s.walk, error, at);
249
+ function pageErr(s, msg) {
250
+ const [w, cmds] = walk.pageErr(s.walk, msg);
248
251
  let next = withWalk(s, w);
249
252
  if (s.phase === "scanning" && w.resilience.calls[PAGE_KEY]?.phase === "failed") {
250
253
  next = { ...next, phase: "failed" };
@@ -311,13 +314,15 @@ function createReconciler(config, rng = Math.random) {
311
314
  function isComplete2(s) {
312
315
  return s.phase === "done";
313
316
  }
314
- function subs(s) {
315
- return walk.subs(s.walk);
317
+ function deadlines(s) {
318
+ return walk.deadlines(s.walk);
316
319
  }
317
- function handlers(ports) {
318
- return walk.handlers(ports);
320
+ function timer(s) {
321
+ return walk.timer(s.walk);
319
322
  }
320
323
  return {
324
+ /** The scan's page-fetch Cmd def — list it in the machine's `cmds`. */
325
+ scanPage: walk.fetch,
321
326
  init,
322
327
  scan,
323
328
  pageOk,
@@ -327,8 +332,8 @@ function createReconciler(config, rng = Math.random) {
327
332
  applied,
328
333
  onTimer,
329
334
  isComplete: isComplete2,
330
- subs,
331
- handlers
335
+ deadlines,
336
+ timer
332
337
  };
333
338
  }
334
339
  function liftReconciler(state, [slice, cmds]) {
@@ -506,15 +511,15 @@ var WORKFLOW_STATUSES = new Set(
506
511
  );
507
512
  function workflowActivityDef() {
508
513
  return Cmd.define("workflow_activity", {
509
- input: z.custom(),
510
- ok: z.void(),
514
+ input: unchecked(),
515
+ ok: undefinedOnly,
511
516
  err: []
512
517
  });
513
518
  }
514
519
  function workflowCompensationDef() {
515
520
  return Cmd.define("workflow_compensation", {
516
- input: z.custom(),
517
- ok: z.void(),
521
+ input: unchecked(),
522
+ ok: undefinedOnly,
518
523
  err: []
519
524
  });
520
525
  }