@demlik/tea 0.11.0 → 0.13.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 +6 -5
- package/dist/agent/index.js +11 -11
- package/dist/authed-call/index.d.ts +3 -2
- package/dist/authed-call/index.js +7 -7
- package/dist/await-terminal/index.d.ts +3 -2
- package/dist/await-terminal/index.js +2 -2
- package/dist/batch-window/index.d.ts +4 -3
- package/dist/batch-window/index.js +3 -3
- package/dist/cache/index.d.ts +3 -2
- package/dist/cache/index.js +4 -4
- package/dist/chart/index.d.ts +4 -3
- package/dist/chart/index.js +2 -2
- package/dist/chart/inspect/index.d.ts +5 -4
- package/dist/chart/inspect/index.js +3 -3
- package/dist/chart/inspect/react.d.ts +6 -5
- package/dist/chart/inspect/react.js +5 -5
- package/dist/chart/lane/index.d.ts +7 -6
- package/dist/chart/lane/index.js +6 -6
- package/dist/chart/lane/react.d.ts +6 -5
- package/dist/chart/lane/react.js +7 -7
- package/dist/chart/lane/viewer/assets/{chunk-5RXB4S5H-IPzIfiJ6.js → chunk-5RXB4S5H-CcNtpUd7.js} +1 -1
- package/dist/chart/lane/viewer/assets/{classDiagram-v2-OCEON4UE-DnUXz1Pv.js → classDiagram-v2-OCEON4UE-D4uAiFr8.js} +1 -1
- package/dist/chart/lane/viewer/assets/{dagre-VZM6K2ZE-Og2UIoWg.js → dagre-VZM6K2ZE-831qZcA8.js} +1 -1
- package/dist/chart/lane/viewer/assets/{index-sP-6AD57.css → index-9SkH5NA3.css} +1 -1
- package/dist/chart/lane/viewer/assets/{index-Obj05Jex.js → index-Bgt4sXpW.js} +4 -4
- package/dist/chart/lane/viewer/assets/{kanban-definition-27J2QSJJ-CxkCxJUN.js → kanban-definition-27J2QSJJ-G7PaPzy-.js} +1 -1
- package/dist/chart/lane/viewer/assets/{mindmap-definition-FAOFIHXS-DvgvXZhp.js → mindmap-definition-FAOFIHXS-CGj9nrVk.js} +1 -1
- package/dist/chart/lane/viewer/assets/{stateDiagram-OKZ733FA-CIZQWK5X.js → stateDiagram-OKZ733FA-B_88AzBS.js} +1 -1
- package/dist/chart/lane/viewer/assets/{stateDiagram-v2-UEYNNEHI-Sm6p0NoR.js → stateDiagram-v2-UEYNNEHI-CR5gcgq6.js} +1 -1
- package/dist/chart/lane/viewer/assets/{timeline-definition-Z64GVDOM-CV3KwSb-.js → timeline-definition-Z64GVDOM-CCv52MfY.js} +1 -1
- package/dist/chart/lane/viewer/index.html +2 -2
- package/dist/chart/report/index.d.ts +5 -4
- package/dist/chart/report/index.js +4 -4
- package/dist/{chunk-ZF6WDK2D.js → chunk-3I52QZZ5.js} +7 -7
- package/dist/{chunk-ZF6WDK2D.js.map → chunk-3I52QZZ5.js.map} +1 -1
- package/dist/{chunk-ZD6PNZBK.js → chunk-3ZAFFRRB.js} +3 -3
- package/dist/{chunk-ZD6PNZBK.js.map → chunk-3ZAFFRRB.js.map} +1 -1
- package/dist/{chunk-4KTWLPL5.js → chunk-4EQZ76JC.js} +3 -3
- package/dist/{chunk-4KTWLPL5.js.map → chunk-4EQZ76JC.js.map} +1 -1
- package/dist/{chunk-EUF7XOEE.js → chunk-4KLG43GY.js} +6 -6
- package/dist/{chunk-EUF7XOEE.js.map → chunk-4KLG43GY.js.map} +1 -1
- package/dist/{chunk-JER5O7PQ.js → chunk-7FRZ2CT2.js} +15 -7
- package/dist/chunk-7FRZ2CT2.js.map +1 -0
- package/dist/{chunk-ZCL7SCBK.js → chunk-CIQG5L42.js} +5 -5
- package/dist/{chunk-ZCL7SCBK.js.map → chunk-CIQG5L42.js.map} +1 -1
- package/dist/{chunk-TP5UPGLY.js → chunk-CLM6ERNO.js} +3 -3
- package/dist/{chunk-TP5UPGLY.js.map → chunk-CLM6ERNO.js.map} +1 -1
- package/dist/{chunk-ND3DH6KM.js → chunk-COS5MSTO.js} +3 -3
- package/dist/{chunk-ND3DH6KM.js.map → chunk-COS5MSTO.js.map} +1 -1
- package/dist/{chunk-JP5D6GSL.js → chunk-CRPZJVD2.js} +4 -4
- package/dist/{chunk-JP5D6GSL.js.map → chunk-CRPZJVD2.js.map} +1 -1
- package/dist/{chunk-SUST46KO.js → chunk-D62FDQKE.js} +3 -3
- package/dist/{chunk-SUST46KO.js.map → chunk-D62FDQKE.js.map} +1 -1
- package/dist/{chunk-JGVL3WPL.js → chunk-DGE4PV4A.js} +3 -3
- package/dist/{chunk-JGVL3WPL.js.map → chunk-DGE4PV4A.js.map} +1 -1
- package/dist/{chunk-WLGO64WC.js → chunk-DMYGQB4O.js} +4 -4
- package/dist/{chunk-WLGO64WC.js.map → chunk-DMYGQB4O.js.map} +1 -1
- package/dist/{chunk-A56OR5RF.js → chunk-L57ZOT5K.js} +3 -3
- package/dist/{chunk-A56OR5RF.js.map → chunk-L57ZOT5K.js.map} +1 -1
- package/dist/{chunk-5KJKJOFC.js → chunk-NR7BU22N.js} +3 -3
- package/dist/{chunk-5KJKJOFC.js.map → chunk-NR7BU22N.js.map} +1 -1
- package/dist/{chunk-7V4EVLZA.js → chunk-O4MVQTEJ.js} +4 -4
- package/dist/{chunk-7V4EVLZA.js.map → chunk-O4MVQTEJ.js.map} +1 -1
- package/dist/{chunk-B5VXOFMZ.js → chunk-OOYD44JI.js} +54 -3
- package/dist/chunk-OOYD44JI.js.map +1 -0
- package/dist/{chunk-7SVIRMC6.js → chunk-RH5EFRVJ.js} +3 -3
- package/dist/{chunk-7SVIRMC6.js.map → chunk-RH5EFRVJ.js.map} +1 -1
- package/dist/{chunk-3JU6657S.js → chunk-VYFAZN3F.js} +3 -3
- package/dist/{chunk-3JU6657S.js.map → chunk-VYFAZN3F.js.map} +1 -1
- package/dist/chunk-XGELA764.js +163 -0
- package/dist/chunk-XGELA764.js.map +1 -0
- package/dist/{chunk-I5OV65MS.js → chunk-YUXP55T2.js} +3 -3
- package/dist/{chunk-I5OV65MS.js.map → chunk-YUXP55T2.js.map} +1 -1
- package/dist/{chunk-E6GEDSF4.js → chunk-YWIKDKHY.js} +3 -3
- package/dist/{chunk-E6GEDSF4.js.map → chunk-YWIKDKHY.js.map} +1 -1
- package/dist/{chunk-5EHLEUTL.js → chunk-ZSUUOEPL.js} +51 -6
- package/dist/chunk-ZSUUOEPL.js.map +1 -0
- package/dist/{core-Bjc0bS8j.d.ts → core-Co0LWkIA.d.ts} +190 -3
- package/dist/deadline/index.d.ts +3 -2
- package/dist/deadline/index.js +3 -3
- package/dist/do/index.d.ts +12 -8
- package/dist/do/index.js +11 -11
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-D8SqU_if.d.ts → durable-effects-C6uwzjb5.d.ts} +1 -1
- package/dist/extension/index.d.ts +3 -2
- package/dist/extension/index.js +3 -3
- package/dist/extension/react.js +3 -3
- package/dist/extension/subs/index.d.ts +3 -2
- package/dist/fan-out/index.d.ts +3 -2
- package/dist/{fold-Blbhru48.d.ts → fold-BJPdjc9w.d.ts} +1 -1
- package/dist/{graph-CcjWZVrd.d.ts → graph-B3L5e0N1.d.ts} +1 -1
- package/dist/idempotent-intake/index.d.ts +3 -2
- package/dist/index.d.ts +14 -6
- package/dist/index.js +2 -2
- package/dist/journal/index.d.ts +373 -0
- package/dist/journal/index.js +3 -0
- package/dist/journal/index.js.map +1 -0
- package/dist/llm-call/index.d.ts +3 -2
- package/dist/llm-call/index.js +8 -8
- package/dist/{machine-0OmPvsy_.d.ts → machine-BtFWQmmq.d.ts} +1 -1
- package/dist/machine-viz/index.d.ts +2 -1
- package/dist/machine-viz/index.js +2 -2
- package/dist/mem/index.d.ts +3 -2
- package/dist/monitored-run/index.d.ts +4 -3
- package/dist/monitored-run/index.js +5 -5
- package/dist/node/index.d.ts +31 -3
- package/dist/node/index.js +92 -3
- package/dist/node/index.js.map +1 -1
- package/dist/paginated-walk/index.d.ts +3 -2
- package/dist/paginated-walk/index.js +7 -7
- package/dist/parity/index.d.ts +3 -2
- package/dist/parity/index.js +3 -3
- package/dist/pbt/arbitraries/index.d.ts +2 -1
- package/dist/pbt/index.d.ts +2 -1
- package/dist/pbt/index.js +3 -3
- package/dist/pbt/runners/index.d.ts +2 -1
- package/dist/pbt/runners/index.js +3 -3
- package/dist/poller/index.d.ts +3 -2
- package/dist/poller/index.js +3 -3
- package/dist/prediction/index.d.ts +2 -1
- package/dist/prediction/index.js +2 -2
- package/dist/pure/index.d.ts +2 -1
- package/dist/pure/index.js +2 -2
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/reconciler/index.d.ts +3 -2
- package/dist/reconciler/index.js +7 -7
- package/dist/recorder/index.d.ts +3 -2
- package/dist/{reducer-BqyoVyBG.d.ts → reducer-4GNR6b8B.d.ts} +2 -2
- package/dist/resilient-call/index.d.ts +3 -2
- package/dist/resilient-call/index.js +6 -6
- package/dist/{run-BVeqJDBF.d.ts → run-pAcmBpah.d.ts} +3 -3
- package/dist/{runtime-types-Bxc637bp.d.ts → runtime-types-CNLmhWif.d.ts} +17 -2
- package/dist/saga/index.d.ts +3 -2
- package/dist/{samples-DCt6nF8H.d.ts → samples-B3My5oh2.d.ts} +1 -1
- package/dist/snapshot/index.d.ts +2 -1
- package/dist/snapshot/index.js +3 -3
- package/dist/subs/index.d.ts +4 -3
- package/dist/subs/index.js +3 -3
- package/dist/testing/index.d.ts +3 -2
- package/dist/testing/index.js +2 -2
- package/dist/throttled-input/index.d.ts +3 -2
- package/dist/throttled-input/index.js +6 -6
- package/dist/token-refresh/index.d.ts +2 -1
- package/dist/token-refresh/index.js +3 -3
- package/dist/trace-replay/index.d.ts +3 -2
- package/dist/trace-replay/index.js +3 -3
- package/dist/{types-D7u9DkH7.d.ts → types-XS_miRnB.d.ts} +1 -1
- package/dist/with-deadline/index.d.ts +2 -1
- package/dist/with-deadline/index.js +2 -2
- package/dist/with-resilience/index.d.ts +3 -2
- package/dist/with-resilience/index.js +6 -6
- package/dist/with-telemetry/index.d.ts +2 -1
- package/dist/with-telemetry/index.js +2 -2
- package/dist/work-queue/adapter.d.ts +3 -2
- package/dist/work-queue/index.d.ts +3 -2
- package/dist/work-queue/ops.d.ts +3 -2
- package/dist/workflow/index.d.ts +4 -3
- package/package.json +11 -4
- package/dist/chunk-5EHLEUTL.js.map +0 -1
- package/dist/chunk-B5VXOFMZ.js.map +0 -1
- package/dist/chunk-JER5O7PQ.js.map +0 -1
|
@@ -1,3 +1,151 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @demlik/tea — pure-core leaf (ADR 0006).
|
|
5
|
+
*
|
|
6
|
+
* This is the runtime-free pure core of the substrate. It holds the
|
|
7
|
+
* client-prediction fold seam (`foldMsgs`), the form reader
|
|
8
|
+
* (`formOf`/`detectUpdateForm`), and the pure type vocabulary (`Machine`,
|
|
9
|
+
* `Reducer`, `Transitions`, `Cmd`, `Sub`, `Port`, …).
|
|
10
|
+
*
|
|
11
|
+
* **Dependency direction (the actual decoupling):** this module imports
|
|
12
|
+
* NOTHING from the runtime — no `better-result`, no `run`/host/`Store`. The
|
|
13
|
+
* runtime (`run`, the host, interpret, `Store`, subscribe — all in
|
|
14
|
+
* `../index.ts`) imports *from* here; never the reverse. The
|
|
15
|
+
* `@demlik/tea/pure` subpath re-exports this surface, and
|
|
16
|
+
* `pure/import-graph.test.ts` is the regression fence asserting the pure
|
|
17
|
+
* entrypoint's import graph never reaches `run`.
|
|
18
|
+
*
|
|
19
|
+
* The one external name it reaches for is zod's TYPE surface (`import type`),
|
|
20
|
+
* erased at compile time — `Cmd.define` accepts zod schemas, and the parse
|
|
21
|
+
* against them happens at the interpret edge in `../run.ts`, never here.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
type NeedsOf<C> = C extends {
|
|
25
|
+
readonly __r?: infer R;
|
|
26
|
+
} ? R : unknown;
|
|
27
|
+
/** The `E` union one Cmd can settle with; `unknown` for an untyped Cmd. */
|
|
28
|
+
type ErrorsOf<C> = C extends {
|
|
29
|
+
readonly __e?: infer E;
|
|
30
|
+
} ? E : unknown;
|
|
31
|
+
type UnionToIntersection<U> = (U extends unknown ? (u: U) => void : never) extends (u: infer I) => void ? I : never;
|
|
32
|
+
/**
|
|
33
|
+
* The `ctx` a machine's whole Cmd union requires: every Cmd's `R`, intersected.
|
|
34
|
+
* `run` types its `ctx` as `Ctx & RequiredCtx<C>`, so handing a machine whose
|
|
35
|
+
* Cmds need `{ http }` to a `run` whose ctx lacks it is a compile error.
|
|
36
|
+
*/
|
|
37
|
+
type RequiredCtx<C> = UnionToIntersection<NeedsOf<C>>;
|
|
38
|
+
/** The shape every settled failure has (ADR 0011): a plain `_tag` record. */
|
|
39
|
+
type Tagged = {
|
|
40
|
+
readonly _tag: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* One declared failure per tag. Distributive, so `TaggedError<"a" | "b">` is
|
|
44
|
+
* the two-arm union a `switch (error._tag)` narrows; the index signature lets a
|
|
45
|
+
* settle site carry detail beside the tag (`{ _tag: "timeout", afterMs }`).
|
|
46
|
+
*/
|
|
47
|
+
type TaggedError<Tag extends string> = Tag extends string ? {
|
|
48
|
+
readonly _tag: Tag;
|
|
49
|
+
readonly [detail: string]: unknown;
|
|
50
|
+
} : never;
|
|
51
|
+
/**
|
|
52
|
+
* The kernel-minted failure: a handler returned a `_ok` value the Cmd's `ok`
|
|
53
|
+
* schema rejects. Plain data, so it folds into Model like any settled error;
|
|
54
|
+
* `issues` is zod's issue list flattened to `path` + `message` strings.
|
|
55
|
+
*/
|
|
56
|
+
type MalformedResult = {
|
|
57
|
+
readonly _tag: "malformed_result";
|
|
58
|
+
readonly issues: ReadonlyArray<{
|
|
59
|
+
readonly path: string;
|
|
60
|
+
readonly message: string;
|
|
61
|
+
}>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The payload a constructor accepts: a plain record spread beside `type`. A
|
|
65
|
+
* `type` key is refused at the type level — it would overwrite the discriminant.
|
|
66
|
+
*/
|
|
67
|
+
type CmdInput = {
|
|
68
|
+
readonly type?: never;
|
|
69
|
+
} & Record<string, unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* Phantom carrier for a Cmd's `R`. `Cmd.needs<{ http: Http }>()` is how a
|
|
72
|
+
* declaration names the `Ctx` slice its handler reads — a type, not a value, so
|
|
73
|
+
* nothing is constructed and nothing is checked at runtime.
|
|
74
|
+
*/
|
|
75
|
+
type Needs<R> = {
|
|
76
|
+
readonly __r?: R;
|
|
77
|
+
};
|
|
78
|
+
/** The value `Cmd.define("fetch", …)` builds: `{ type: "fetch", ...input }`. */
|
|
79
|
+
type CmdValue<Name extends string, Input extends CmdInput, E extends Tagged, R> = Cmd<Name, E | MalformedResult, R> & Readonly<Input>;
|
|
80
|
+
type SettledOk<Name extends string, C, Ok> = {
|
|
81
|
+
readonly type: `${Name}_ok`;
|
|
82
|
+
readonly cmd: C;
|
|
83
|
+
readonly value: Ok;
|
|
84
|
+
/** Stamped by the runtime at the interpret edge (`run`'s `clock`). */
|
|
85
|
+
readonly at: number;
|
|
86
|
+
};
|
|
87
|
+
type SettledErr<Name extends string, C, E extends Tagged> = {
|
|
88
|
+
readonly type: `${Name}_err`;
|
|
89
|
+
readonly cmd: C;
|
|
90
|
+
readonly error: E | MalformedResult;
|
|
91
|
+
/** Stamped by the runtime at the interpret edge (`run`'s `clock`). */
|
|
92
|
+
readonly at: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* What `Cmd.define` returns: the Cmd builder itself (`fetch({ url })`), with
|
|
96
|
+
* the minted Msg builders and the declaration hung on it. `E` here is the
|
|
97
|
+
* DECLARED tag union; the settled `_err` arm widens it by `MalformedResult`.
|
|
98
|
+
*
|
|
99
|
+
* `ok` / `err` take an optional `at` for minting OUTSIDE the runtime (a
|
|
100
|
+
* `replay` log, a unit test); inside `run` the interpret edge stamps it from
|
|
101
|
+
* the clock, so a handler never reads `Date.now()` itself.
|
|
102
|
+
*/
|
|
103
|
+
interface CmdDef<Name extends string, Input extends CmdInput, Ok, E extends Tagged, R> {
|
|
104
|
+
(input: Input): CmdValue<Name, Input, E, R>;
|
|
105
|
+
/** The `type` discriminant of every Cmd this builds. */
|
|
106
|
+
readonly cmdType: Name;
|
|
107
|
+
readonly okType: `${Name}_ok`;
|
|
108
|
+
readonly errType: `${Name}_err`;
|
|
109
|
+
readonly ok: (cmd: CmdValue<Name, Input, E, R>, value: Ok, at?: number) => SettledOk<Name, CmdValue<Name, Input, E, R>, Ok>;
|
|
110
|
+
readonly err: (cmd: CmdValue<Name, Input, E, R>, error: E, at?: number) => SettledErr<Name, CmdValue<Name, Input, E, R>, E>;
|
|
111
|
+
readonly schema: {
|
|
112
|
+
readonly input: z.ZodType<Input>;
|
|
113
|
+
readonly ok: z.ZodType<Ok>;
|
|
114
|
+
};
|
|
115
|
+
/** The declared `_tag` list, verbatim. */
|
|
116
|
+
readonly errTags: ReadonlyArray<E["_tag"]>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The declaration-erased view the runtime reads: which `type` a def builds,
|
|
120
|
+
* which two Msg types it settles with, and the `ok` schema the edge parses
|
|
121
|
+
* against. Every `CmdDef<…>` is one of these structurally.
|
|
122
|
+
*/
|
|
123
|
+
type AnyCmdDef = {
|
|
124
|
+
readonly cmdType: string;
|
|
125
|
+
readonly okType: string;
|
|
126
|
+
readonly errType: string;
|
|
127
|
+
readonly schema: {
|
|
128
|
+
readonly ok: z.ZodType;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
/** The Cmd value a def (or a union of defs) builds. */
|
|
132
|
+
type CmdOf<D extends AnyCmdDef> = D extends ((input: never) => infer C extends Cmd) ? C : never;
|
|
133
|
+
/**
|
|
134
|
+
* The settled-Msg union a def (or a union of defs) mints: `<name>_ok` carrying
|
|
135
|
+
* `value`, `<name>_err` carrying `error`. `defineMachine({ cmds })` folds this
|
|
136
|
+
* into the machine's `M` so the user never spells the effect half of it.
|
|
137
|
+
*/
|
|
138
|
+
type Settled<D extends AnyCmdDef> = D extends CmdDef<infer Name, infer Input, infer Ok, infer E, infer R> ? SettledOk<Name, CmdValue<Name, Input, E, R>, Ok> | SettledErr<Name, CmdValue<Name, Input, E, R>, E> : never;
|
|
139
|
+
/** The `Ok` a def's handler must produce. */
|
|
140
|
+
type OkOf<D extends AnyCmdDef> = D extends CmdDef<infer _Name, infer _Input, infer Ok, infer _E, infer _R> ? Ok : never;
|
|
141
|
+
/** The DECLARED failure union a def's handler may settle with. */
|
|
142
|
+
type ErrOf<D extends AnyCmdDef> = D extends CmdDef<infer _Name, infer _Input, infer _Ok, infer E, infer _R> ? E : never;
|
|
143
|
+
declare function defineCmd<const Name extends string, Input extends CmdInput, Ok, const Tags extends readonly string[], R = unknown>(name: Name, spec: {
|
|
144
|
+
readonly input: z.ZodType<Input>;
|
|
145
|
+
readonly ok: z.ZodType<Ok>;
|
|
146
|
+
readonly err: Tags;
|
|
147
|
+
readonly needs?: Needs<R>;
|
|
148
|
+
}): CmdDef<Name, Input, Ok, TaggedError<Tags[number]>, R>;
|
|
1
149
|
type SyncReturn<S, C extends Cmd> = readonly [S, readonly C[]] & {
|
|
2
150
|
readonly then?: never;
|
|
3
151
|
};
|
|
@@ -71,10 +219,39 @@ type Transitions<S extends {
|
|
|
71
219
|
}>) => SyncReturn<S, C>;
|
|
72
220
|
};
|
|
73
221
|
};
|
|
74
|
-
type Cmd<T extends string = string> = {
|
|
222
|
+
type Cmd<T extends string = string, E = unknown, R = unknown> = {
|
|
75
223
|
readonly type: T;
|
|
224
|
+
/** Phantom — the `_tag` union this Cmd can settle with. Never assigned. */
|
|
225
|
+
readonly __e?: E;
|
|
226
|
+
/** Phantom — the `Ctx` slice this Cmd's handler needs. Never assigned. */
|
|
227
|
+
readonly __r?: R;
|
|
76
228
|
};
|
|
77
229
|
declare const Cmd: {
|
|
230
|
+
/**
|
|
231
|
+
* Declare a typed Cmd constructor (ADR 0014). Returns the builder —
|
|
232
|
+
* `fetch({ url })` yields `{ type: "fetch", url }` — carrying the minted Msg
|
|
233
|
+
* builders `fetch.ok(cmd, value)` / `fetch.err(cmd, error)` and the
|
|
234
|
+
* declaration the runtime edge parses against. `Settled<typeof fetch>` is
|
|
235
|
+
* the two-arm Msg union it settles with; `defineMachine({ cmds: [fetch] })`
|
|
236
|
+
* folds that union into the machine's `M`.
|
|
237
|
+
*
|
|
238
|
+
* const fetch = Cmd.define("fetch", {
|
|
239
|
+
* input: z.object({ url: z.string() }),
|
|
240
|
+
* ok: z.object({ status: z.number(), body: z.string() }),
|
|
241
|
+
* err: ["not_found", "timeout"],
|
|
242
|
+
* needs: Cmd.needs<{ http: Http }>(),
|
|
243
|
+
* });
|
|
244
|
+
*
|
|
245
|
+
* `err` is the `_tag` list the handler may settle with; the runtime adds
|
|
246
|
+
* `malformed_result` for an `_ok` value the `ok` schema rejects. `needs`
|
|
247
|
+
* names the `Ctx` slice the handler reads — `run` refuses a ctx without it.
|
|
248
|
+
*/
|
|
249
|
+
readonly define: typeof defineCmd;
|
|
250
|
+
/**
|
|
251
|
+
* Name a Cmd's `R` — the `Ctx` slice its handler reads. A phantom: nothing
|
|
252
|
+
* is built, nothing is checked at runtime; the type is what `run` reads.
|
|
253
|
+
*/
|
|
254
|
+
readonly needs: <R>() => Needs<R>;
|
|
78
255
|
/**
|
|
79
256
|
* The empty Cmd array. Typed `readonly never[]` so it's assignable to any
|
|
80
257
|
* `readonly C[]` for any `C extends Cmd`. Use in `init` returns and
|
|
@@ -215,7 +392,9 @@ type Interpret<M extends {
|
|
|
215
392
|
}, C extends Cmd, Ctx> = {
|
|
216
393
|
[K in C["type"]]: (cmd: Extract<C, {
|
|
217
394
|
type: K;
|
|
218
|
-
}>, ctx: Ctx &
|
|
395
|
+
}>, ctx: Ctx & NeedsOf<Extract<C, {
|
|
396
|
+
type: K;
|
|
397
|
+
}>> & PortEmitter, dispatch?: (msg: M) => void) => Promise<M | void>;
|
|
219
398
|
};
|
|
220
399
|
type InterpretDetached<C extends Cmd, Allowed extends {
|
|
221
400
|
type: string;
|
|
@@ -247,6 +426,14 @@ type Machine<S, M extends {
|
|
|
247
426
|
* pointer to the alternatives).
|
|
248
427
|
*/
|
|
249
428
|
init: (loaded: S | null, ctx: Ctx) => readonly [S, readonly C[]];
|
|
429
|
+
/**
|
|
430
|
+
* The typed Cmd constructors this machine emits (`Cmd.define`). Declared
|
|
431
|
+
* through `defineMachine({ cmds })`, which derives `C` and the settled half
|
|
432
|
+
* of `M` from them; the runtime reads the list to parse each handler's
|
|
433
|
+
* `_ok` value against its `ok` schema and stamp `at` at the interpret edge.
|
|
434
|
+
* A machine of hand-written Cmds omits it and runs exactly as before.
|
|
435
|
+
*/
|
|
436
|
+
readonly cmds?: readonly AnyCmdDef[];
|
|
250
437
|
update: Reducer<S, M, C> | ([S] extends [{
|
|
251
438
|
type: string;
|
|
252
439
|
}] ? Transitions<S, M, C> : never);
|
|
@@ -323,4 +510,4 @@ declare function foldMsgs<S, M extends {
|
|
|
323
510
|
type: string;
|
|
324
511
|
}, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, base: S, msgs: readonly M[]): S;
|
|
325
512
|
|
|
326
|
-
export { Cmd as C, type DepKeyedSub as D, type Interpret as I, type Machine as M, NoCellError as N, type PortEmitter as P, type
|
|
513
|
+
export { type AnyCmdDef as A, applyCellChecked as B, Cmd as C, type DepKeyedSub as D, type ErrOf as E, describeMachine as F, detectUpdateForm as G, foldMsgs as H, type Interpret as I, foldUpdates as J, formOf as K, msgKeysOf as L, type Machine as M, NoCellError as N, type OkOf as O, type PortEmitter as P, structuralHash as Q, type RequiredCtx as R, type Sub as S, type Transitions as T, type UpdateForm as U, subId as V, type Port as a, type SubId as b, type Reducer as c, type Settled as d, type CmdOf as e, type NeedsOf as f, type InterpretDetached as g, type CmdDef as h, type CmdInput as i, type CmdValue as j, type ContextFree as k, type Dispose as l, type ErrorsOf as m, type Identity as n, type MachineShape as o, type MalformedResult as p, type Needs as q, type NoCtx as r, type SettledErr as s, type SettledOk as t, type Subscribe as u, type SyncReturn as v, type Tagged as w, type TaggedError as x, acceptsOf as y, applyCell as z };
|
package/dist/deadline/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { S as Sub, b as SubId } from '../core-
|
|
2
|
-
import { S as SubscribeHandler } from '../types-
|
|
1
|
+
import { S as Sub, b as SubId } from '../core-Co0LWkIA.js';
|
|
2
|
+
import { S as SubscribeHandler } from '../types-XS_miRnB.js';
|
|
3
|
+
import 'zod';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @demlik/tea/deadline — a one-shot Sub that fires when an ABSOLUTE wall-clock
|
package/dist/deadline/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { deadlineExceeded, deadlineSub, setTimeoutArmTimer, subscribeDeadline, subscribeWith } from '../chunk-
|
|
1
|
+
export { deadlineExceeded, deadlineSub, setTimeoutArmTimer, subscribeDeadline, subscribeWith } from '../chunk-DGE4PV4A.js';
|
|
2
2
|
import '../chunk-2YFLOCWX.js';
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-ZSUUOEPL.js';
|
|
4
|
+
import '../chunk-OOYD44JI.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { S as Store, R as Runtime, B as BootingRuntime } from '../runtime-types-
|
|
2
|
-
import { P as PendingEffectsRecorder, b as EffectOwed, a as EffectConfirmed } from '../durable-effects-
|
|
3
|
-
export { D as DeliveryId, E as EffectLedgerEvent, O as OwedEffect, c as PendingEffectsLedger, d as applyEffectEvent, e as emptyLedger, f as foldLedger, i as isOwed, p as pendingEffectsLedger, s as survivingEffects } from '../durable-effects-
|
|
1
|
+
import { S as Store, R as Runtime, B as BootingRuntime } from '../runtime-types-CNLmhWif.js';
|
|
2
|
+
import { P as PendingEffectsRecorder, b as EffectOwed, a as EffectConfirmed } from '../durable-effects-C6uwzjb5.js';
|
|
3
|
+
export { D as DeliveryId, E as EffectLedgerEvent, O as OwedEffect, c as PendingEffectsLedger, d as applyEffectEvent, e as emptyLedger, f as foldLedger, i as isOwed, p as pendingEffectsLedger, s as survivingEffects } from '../durable-effects-C6uwzjb5.js';
|
|
4
4
|
import { RetryPolicy, Rng } from '../retry-backoff/index.js';
|
|
5
|
-
import { C as Cmd, S as Sub, M as Machine } from '../core-
|
|
6
|
-
import { k as AgentEvent, A as AgentTurn, s as AgentState, p as AgentMachineMsg, t as AgentStatus } from '../machine-
|
|
5
|
+
import { C as Cmd, S as Sub, M as Machine, R as RequiredCtx } from '../core-Co0LWkIA.js';
|
|
6
|
+
import { k as AgentEvent, A as AgentTurn, s as AgentState, p as AgentMachineMsg, t as AgentStatus } from '../machine-BtFWQmmq.js';
|
|
7
7
|
import 'better-result';
|
|
8
|
+
import 'zod';
|
|
8
9
|
import '../llm-call/index.js';
|
|
9
10
|
import '../resilient-call/index.js';
|
|
10
11
|
import '../cache/index.js';
|
|
11
|
-
import '../types-
|
|
12
|
+
import '../types-XS_miRnB.js';
|
|
12
13
|
import '../circuit-breaker/index.js';
|
|
13
14
|
import '../deadline/index.js';
|
|
14
15
|
import '../protocol-B5YmJr0d.js';
|
|
@@ -1067,8 +1068,11 @@ interface AgentHostConfig<Stage, P extends string, O extends Record<P, AgentTurn
|
|
|
1067
1068
|
readonly buildMachine: () => Machine<AgentState<Stage, P, O, R>, AgentMachineMsg<P, O, R>, C, U, Ctx>;
|
|
1068
1069
|
/** The durable `Store` for the agent slice (typically `doStore(storage, parse)`). */
|
|
1069
1070
|
readonly store: Store<AgentState<Stage, P, O, R>>;
|
|
1070
|
-
/**
|
|
1071
|
-
|
|
1071
|
+
/**
|
|
1072
|
+
* The Ctx the machine threads to its interpret cells — checked against
|
|
1073
|
+
* `buildMachine`'s, plus every typed Cmd's `R` (what `run` itself demands).
|
|
1074
|
+
*/
|
|
1075
|
+
readonly ctx: Ctx & RequiredCtx<C>;
|
|
1072
1076
|
/**
|
|
1073
1077
|
* The run-terminality predicate (#46) — what makes `result()` first-class.
|
|
1074
1078
|
* Defaults to the agent's own terminal phases (`done` / `failed`).
|
package/dist/do/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { status, agentBootMsg, agentEvents } from '../chunk-
|
|
1
|
+
import { status, agentBootMsg, agentEvents } from '../chunk-3I52QZZ5.js';
|
|
2
2
|
export { applyEffectEvent, emptyLedger, foldLedger, isOwed, pendingEffectsLedger, survivingEffects } from '../chunk-25LBDCBC.js';
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-DMYGQB4O.js';
|
|
4
|
+
import '../chunk-COS5MSTO.js';
|
|
5
|
+
import '../chunk-O4MVQTEJ.js';
|
|
6
|
+
import '../chunk-4KLG43GY.js';
|
|
7
7
|
import '../chunk-JELSZN25.js';
|
|
8
8
|
import '../chunk-D736QUGF.js';
|
|
9
9
|
import { createIntake } from '../chunk-ZVJZ72HY.js';
|
|
10
|
-
import '../chunk-
|
|
10
|
+
import '../chunk-RH5EFRVJ.js';
|
|
11
|
+
import '../chunk-DGE4PV4A.js';
|
|
11
12
|
import { defaultRetryPolicy, initRetry, recordFailure, shouldRetry, nextDelayMs } from '../chunk-Q2UM7BXU.js';
|
|
12
13
|
import '../chunk-S2EGRPCM.js';
|
|
13
14
|
import '../chunk-BYQUGDD3.js';
|
|
14
15
|
import '../chunk-K575PT4S.js';
|
|
15
16
|
import '../chunk-UF4MZSLT.js';
|
|
16
|
-
import '../chunk-
|
|
17
|
+
import '../chunk-G5E74IJB.js';
|
|
17
18
|
import '../chunk-MU6MCIAC.js';
|
|
18
19
|
import '../chunk-FV3Z5MBE.js';
|
|
19
|
-
import '../chunk-
|
|
20
|
+
import '../chunk-VYFAZN3F.js';
|
|
20
21
|
import '../chunk-2YFLOCWX.js';
|
|
21
22
|
import '../chunk-ZJ5AOYBH.js';
|
|
22
|
-
import '../chunk-
|
|
23
|
-
import
|
|
24
|
-
import '../chunk-B5VXOFMZ.js';
|
|
23
|
+
import { replay, run } from '../chunk-ZSUUOEPL.js';
|
|
24
|
+
import '../chunk-OOYD44JI.js';
|
|
25
25
|
|
|
26
26
|
// src/do/durable-timer.ts
|
|
27
27
|
function durableTimer(config) {
|