@demlik/tea 0.15.0 → 0.17.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/README.md +30 -7
- package/dist/agent/index.d.ts +49 -37
- package/dist/agent/index.js +12 -8
- package/dist/chunk-4LPY67E4.js +18 -0
- package/dist/chunk-4LPY67E4.js.map +1 -0
- package/dist/chunk-4NTCPTNQ.js +64 -0
- package/dist/chunk-4NTCPTNQ.js.map +1 -0
- package/dist/{chunk-3B5X7SBB.js → chunk-4PXNZ5UY.js} +11 -9
- package/dist/chunk-4PXNZ5UY.js.map +1 -0
- package/dist/{chunk-AYS5N6WY.js → chunk-6XBEYZME.js} +62 -172
- package/dist/chunk-6XBEYZME.js.map +1 -0
- package/dist/chunk-C4U5D5HP.js +380 -0
- package/dist/chunk-C4U5D5HP.js.map +1 -0
- package/dist/{chunk-QPEVCJ5Q.js → chunk-DFUEAA6L.js} +13 -6
- package/dist/chunk-DFUEAA6L.js.map +1 -0
- package/dist/{chunk-22POWGFA.js → chunk-GWWCCSDH.js} +46 -20
- package/dist/chunk-GWWCCSDH.js.map +1 -0
- package/dist/chunk-K4ETBNKS.js +733 -0
- package/dist/chunk-K4ETBNKS.js.map +1 -0
- package/dist/chunk-KWNCM6XM.js +539 -0
- package/dist/chunk-KWNCM6XM.js.map +1 -0
- package/dist/{chunk-V46HSVCK.js → chunk-LYVOGOBC.js} +3 -3
- package/dist/{chunk-V46HSVCK.js.map → chunk-LYVOGOBC.js.map} +1 -1
- package/dist/{chunk-VTQI2NHP.js → chunk-OPH6Y4UT.js} +9 -8
- package/dist/chunk-OPH6Y4UT.js.map +1 -0
- package/dist/{chunk-Q5CQTBFA.js → chunk-OYR7ENKU.js} +20 -30
- package/dist/chunk-OYR7ENKU.js.map +1 -0
- package/dist/{chunk-MYXFNWAJ.js → chunk-QNGYQMZB.js} +4 -4
- package/dist/chunk-QNGYQMZB.js.map +1 -0
- package/dist/chunk-QWIPH4YH.js +98 -0
- package/dist/chunk-QWIPH4YH.js.map +1 -0
- package/dist/{chunk-TCLBCERH.js → chunk-XBZQT2TD.js} +238 -212
- package/dist/chunk-XBZQT2TD.js.map +1 -0
- package/dist/{core-DnzqWy6u.d.ts → core-rDbOaJTN.d.ts} +236 -140
- package/dist/do/index.d.ts +37 -33
- package/dist/do/index.js +21 -14
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-CWzA-o2B.d.ts → durable-effects-CNaw97Be.d.ts} +1 -1
- package/dist/effect/index.d.ts +151 -0
- package/dist/effect/index.js +98 -0
- package/dist/effect/index.js.map +1 -0
- package/dist/extension/index.d.ts +6 -7
- package/dist/extension/index.js +3 -2
- package/dist/extension/index.js.map +1 -1
- package/dist/flow/index.d.ts +68 -59
- package/dist/flow/index.js +32 -27
- package/dist/flow/index.js.map +1 -1
- package/dist/idempotency/index.d.ts +6 -7
- package/dist/idempotency/index.js +4 -2
- package/dist/{index-KXqTRJyb.d.ts → index-BOrsbdAf.d.ts} +19 -96
- package/dist/{index-DrIRb_Ch.d.ts → index-B_BxplWi.d.ts} +1 -1
- package/dist/index-CWmsXNdX.d.ts +207 -0
- package/dist/{index-C2DwkjlP.d.ts → index-Cberb5Rr.d.ts} +57 -45
- package/dist/{index-CSyMYDAB.d.ts → index-CcrKLtse.d.ts} +1 -1
- package/dist/{index-CuNO9m8i.d.ts → index-Cx0F2M34.d.ts} +14 -16
- package/dist/{index-HSYgG2Yt.d.ts → index-DaX_P35Q.d.ts} +247 -211
- package/dist/{index-CA_7I5g9.d.ts → index-q1PoukOZ.d.ts} +137 -246
- package/dist/index.d.ts +121 -385
- package/dist/index.js +2 -1
- package/dist/jev/index.d.ts +133 -97
- package/dist/jev/index.js +205 -161
- package/dist/jev/index.js.map +1 -1
- package/dist/{machine-DGlPWCWI.d.ts → machine-BcfCFMYF.d.ts} +171 -288
- package/dist/machine-viz/index.d.ts +5 -5
- package/dist/machine-viz/index.js +8 -4
- package/dist/machine-viz/index.js.map +1 -1
- package/dist/mem/index.d.ts +3 -4
- package/dist/mem/index.js +2 -1
- package/dist/mem/index.js.map +1 -1
- package/dist/node/index.d.ts +119 -78
- package/dist/node/index.js +52 -38
- package/dist/node/index.js.map +1 -1
- package/dist/paginate/index.d.ts +27 -22
- package/dist/paginate/index.js +6 -4
- package/dist/parity/index.d.ts +4 -5
- package/dist/parity/index.js +3 -2
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +2 -2
- package/dist/pbt/index.js +2 -1
- package/dist/pbt/index.js.map +1 -1
- package/dist/persistence/index.d.ts +10 -12
- package/dist/persistence/index.js +5 -3
- package/dist/promise/index.d.ts +186 -0
- package/dist/promise/index.js +5 -0
- package/dist/promise/index.js.map +1 -0
- package/dist/{protocol-D8VbH-VH.d.ts → protocol-ClRZBhHQ.d.ts} +7 -8
- package/dist/react/index.d.ts +36 -17
- package/dist/react/index.js +27 -4
- package/dist/react/index.js.map +1 -1
- package/dist/resilience/index.d.ts +63 -456
- package/dist/resilience/index.js +37 -483
- package/dist/resilience/index.js.map +1 -1
- package/dist/{runtime-types-CMF13BBh.d.ts → runtime-types-B62Ucnxr.d.ts} +132 -389
- package/dist/testing/index.d.ts +33 -113
- package/dist/testing/index.js +39 -181
- package/dist/testing/index.js.map +1 -1
- package/dist/timing/index.d.ts +25 -22
- package/dist/timing/index.js +4 -3
- package/dist/timing/index.js.map +1 -1
- package/dist/{types-BseNPIhr.d.ts → types-DPm5YCDQ.d.ts} +2 -2
- package/dist/work-queue/index.d.ts +5 -6
- package/package.json +20 -7
- package/dist/chunk-22POWGFA.js.map +0 -1
- package/dist/chunk-3B5X7SBB.js.map +0 -1
- package/dist/chunk-66PY5WYF.js +0 -1816
- package/dist/chunk-66PY5WYF.js.map +0 -1
- package/dist/chunk-AYS5N6WY.js.map +0 -1
- package/dist/chunk-L3TND7LA.js +0 -97
- package/dist/chunk-L3TND7LA.js.map +0 -1
- package/dist/chunk-MYXFNWAJ.js.map +0 -1
- package/dist/chunk-Q5CQTBFA.js.map +0 -1
- package/dist/chunk-QPEVCJ5Q.js.map +0 -1
- package/dist/chunk-TCLBCERH.js.map +0 -1
- package/dist/chunk-VTQI2NHP.js.map +0 -1
- package/dist/index-ZCMhnVKN.d.ts +0 -272
package/dist/do/index.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { S as Store,
|
|
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, b as BootedRunHandle, E as EngineRun, c as RunHandle, F as FencedStore } from '../runtime-types-B62Ucnxr.js';
|
|
2
|
+
import { P as PendingEffectsRecorder, b as EffectOwed, a as EffectConfirmed } from '../durable-effects-CNaw97Be.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-CNaw97Be.js';
|
|
4
4
|
import { RetryPolicy, Rng } from '../retry-backoff/index.js';
|
|
5
|
-
import { C as Cmd, S as Sub, M as Machine,
|
|
6
|
-
import { g as AgentEvent, b as AgentTurn, c as AgentState, i as AgentMachineMsg,
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
import '../index-
|
|
10
|
-
import '../index-
|
|
11
|
-
import '../
|
|
12
|
-
import '../
|
|
13
|
-
import '../index-
|
|
14
|
-
import '../
|
|
15
|
-
import '../
|
|
16
|
-
import '../index-CuNO9m8i.js';
|
|
5
|
+
import { C as Cmd, S as Sub, M as Machine, W as Wired } from '../core-rDbOaJTN.js';
|
|
6
|
+
import { g as AgentEvent, b as AgentTurn, c as AgentState, i as AgentMachineMsg, B as AgentStatus } from '../machine-BcfCFMYF.js';
|
|
7
|
+
import '@standard-schema/spec';
|
|
8
|
+
import '../index-BOrsbdAf.js';
|
|
9
|
+
import '../index-CWmsXNdX.js';
|
|
10
|
+
import '../index-DaX_P35Q.js';
|
|
11
|
+
import '../types-DPm5YCDQ.js';
|
|
12
|
+
import '../index-CcrKLtse.js';
|
|
13
|
+
import '../index-q1PoukOZ.js';
|
|
14
|
+
import '../protocol-ClRZBhHQ.js';
|
|
15
|
+
import '../index-Cx0F2M34.js';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* @demlik/tea/do — `stepHost`, the HTTP-PULL control carrier (#92).
|
|
@@ -408,7 +407,7 @@ declare function runStepLoop<R, I, O>(token: string, runId: string, transport: S
|
|
|
408
407
|
* and the vortex arena tick (`room.ts` `armTick` + `onTick`) replicates the
|
|
409
408
|
* exact shape for the 18 Hz game clock. The two old `do_alarm`/`do_ws` Subs were
|
|
410
409
|
* dropped (see `./index`'s historical note) because `toMachine` fixes the agent
|
|
411
|
-
* machine's Sub type to `
|
|
410
|
+
* machine's Sub type to `DeadlinesSub`, so they could never union into a grain's
|
|
412
411
|
* Sub set — leaving the alarm re-arm a HOST concern with no first-class home.
|
|
413
412
|
*
|
|
414
413
|
* {@link durableTimer} is that home: a tiny, transport- and Msg-agnostic helper
|
|
@@ -1057,18 +1056,22 @@ declare function sseFromAgentEvents<R, Frame>(runtime: {
|
|
|
1057
1056
|
*/
|
|
1058
1057
|
interface AgentHostConfig<Stage, P extends string, O extends Record<P, AgentTurn>, R, Frame, C extends Cmd = Cmd, U extends Sub = Sub, Ctx = unknown> {
|
|
1059
1058
|
/**
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
* per-tool interpret here (`agent.toMachine({ toolInterpret })`).
|
|
1059
|
+
* The engine's `run` — `run` from `@demlik/tea/promise`, or any engine's. The
|
|
1060
|
+
* host imports no engine; it boots the machine through this.
|
|
1063
1061
|
*/
|
|
1064
|
-
readonly
|
|
1065
|
-
/** The durable `Store` for the agent slice (typically `doStore(storage, parse)`). */
|
|
1066
|
-
readonly store: Store<AgentState<Stage, P, O, R>>;
|
|
1062
|
+
readonly run: EngineRun<AgentState<Stage, P, O, R>, AgentMachineMsg<P, O, R>, C, U, Ctx, AgentEvent<R>>;
|
|
1067
1063
|
/**
|
|
1068
|
-
*
|
|
1069
|
-
* `
|
|
1064
|
+
* Build the wired agent machine and the handlers it runs under — its
|
|
1065
|
+
* `interpret` table and `subscribe` runners (a machine carries none — #278,
|
|
1066
|
+
* #279). Called once per host build (per activation), AFTER the previous
|
|
1067
|
+
* runtime — if any — was torn down. The consumer wires its per-tool interpret
|
|
1068
|
+
* here, and `agent.toMachine({ toolInterpret })` already returns exactly this.
|
|
1070
1069
|
*/
|
|
1071
|
-
readonly
|
|
1070
|
+
readonly buildMachine: () => Wired<AgentState<Stage, P, O, R>, AgentMachineMsg<P, O, R>, C, U, Ctx>;
|
|
1071
|
+
/** The durable `Store` for the agent slice (typically `doStore(storage, parse)`). */
|
|
1072
|
+
readonly store: Store<AgentState<Stage, P, O, R>>;
|
|
1073
|
+
/** The plain Ctx the machine threads to its interpret cells. */
|
|
1074
|
+
readonly ctx: Ctx;
|
|
1072
1075
|
/**
|
|
1073
1076
|
* The run-terminality predicate (#46) — what makes `result()` first-class.
|
|
1074
1077
|
* Defaults to the agent's own terminal phases (`done` / `failed`).
|
|
@@ -1099,10 +1102,10 @@ interface AgentHost<Stage, P extends string, O extends Record<P, AgentTurn>, R,
|
|
|
1099
1102
|
* Get (or build) the booted runtime. Build-once-boot-once: the first call
|
|
1100
1103
|
* builds the machine, wires SSE off the semantic event stream, awaits the boot
|
|
1101
1104
|
* gate, runs the `autoBoot` re-fire for a rehydrated suspended run, and caches
|
|
1102
|
-
* the booted
|
|
1105
|
+
* the booted handle; subsequent calls return the cached handle. The single
|
|
1103
1106
|
* assembly every consumer used to hand-roll in `getRuntime()`.
|
|
1104
1107
|
*/
|
|
1105
|
-
runtime(): Promise<
|
|
1108
|
+
runtime(): Promise<BootedRunHandle<AgentState<Stage, P, O, R>, AgentMachineMsg<P, O, R>, AgentEvent<R>>>;
|
|
1106
1109
|
/**
|
|
1107
1110
|
* The agent's lifecycle status (#49) — the ONE typed channel a consumer reads
|
|
1108
1111
|
* instead of re-deriving `run.phase` / `awaiting` by hand. Ensures the runtime
|
|
@@ -1138,6 +1141,7 @@ interface AgentHost<Stage, P extends string, O extends Record<P, AgentTurn>, R,
|
|
|
1138
1141
|
*
|
|
1139
1142
|
* @example
|
|
1140
1143
|
* const host = createAgentHost<Stage, Purpose, Outputs, ClientResult, SseEvent>({
|
|
1144
|
+
* run, // from `@demlik/tea/promise`
|
|
1141
1145
|
* buildMachine: () => agent.toMachine<Ctx>({ toolInterpret }),
|
|
1142
1146
|
* store: doStore(storage, parse),
|
|
1143
1147
|
* ctx,
|
|
@@ -1373,14 +1377,14 @@ interface ResumePort<S, M extends {
|
|
|
1373
1377
|
* every DO-hosted machine otherwise re-derives.
|
|
1374
1378
|
*
|
|
1375
1379
|
* `await ready` is the single boot gate (issue #45): `getState()` is total only
|
|
1376
|
-
* on the booted
|
|
1377
|
-
* it. `now` is injected (the sole boot clock read) so a test can pin it.
|
|
1380
|
+
* on the booted handle, so state cannot be inspected before boot populates
|
|
1381
|
+
* it. Takes any engine's {@link RunHandle}. `now` is injected (the sole boot clock read) so a test can pin it.
|
|
1378
1382
|
*/
|
|
1379
1383
|
declare function bootResume<S, M extends {
|
|
1380
1384
|
type: string;
|
|
1381
1385
|
}, E extends {
|
|
1382
1386
|
type: string;
|
|
1383
|
-
} = never>(booting:
|
|
1387
|
+
} = never>(booting: RunHandle<S, M, E>, port: ResumePort<S, M>, now?: () => number): Promise<void>;
|
|
1384
1388
|
/**
|
|
1385
1389
|
* True iff an agent slice loaded from storage is mid-loop (running + awaiting
|
|
1386
1390
|
* tools) — the resumable case `agent_boot` re-fires.
|
|
@@ -1404,7 +1408,7 @@ declare function agentIsResumable<Stage, P extends string, O extends Record<P, u
|
|
|
1404
1408
|
*/
|
|
1405
1409
|
declare function autoBoot<Stage, P extends string, O extends Record<P, unknown>, R, E extends {
|
|
1406
1410
|
type: string;
|
|
1407
|
-
} = never>(booting:
|
|
1411
|
+
} = never>(booting: RunHandle<AgentState<Stage, P, O, R>, AgentMachineMsg<P, O, R>, E>, now?: () => number): Promise<void>;
|
|
1408
1412
|
/**
|
|
1409
1413
|
* Re-fire every round-trip a rehydrated actor still owes, on wake. Given a
|
|
1410
1414
|
* durable carrier whose recorder was rehydrated from the persisted ledger
|
|
@@ -1834,7 +1838,7 @@ declare function presenceCount(ctx: PresenceCtx, tag?: string): number;
|
|
|
1834
1838
|
*
|
|
1835
1839
|
* 2. `deferredGateway` + `createAgentHost` (from `./host`) — THE transport for
|
|
1836
1840
|
* a DO-hosted agent. A `createAgent().toMachine()` machine owns exactly one
|
|
1837
|
-
* Sub type, `
|
|
1841
|
+
* Sub type, `DeadlinesSub` (the agent's own retry + watchdog timers); it has
|
|
1838
1842
|
* no DO-native Sub variant to compose, and it needs none. The gateway owns
|
|
1839
1843
|
* each deferred tool round-trip as a Promise the interpret cell awaits:
|
|
1840
1844
|
* - Inbound WebSocket frames are bridged straight into `gateway.settle(...)`
|
|
@@ -1848,7 +1852,7 @@ declare function presenceCount(ctx: PresenceCtx, tag?: string): number;
|
|
|
1848
1852
|
*
|
|
1849
1853
|
* (Historical note: this module previously also shipped `do_ws` / `do_alarm`
|
|
1850
1854
|
* Subs + a `doSubscribe` registry. Because `toMachine` fixes the agent machine's
|
|
1851
|
-
* Sub type to `
|
|
1855
|
+
* Sub type to `DeadlinesSub`, those Subs could never union into an agent host's
|
|
1852
1856
|
* Sub set — they were structurally unusable by the flagship consumer and had no
|
|
1853
1857
|
* callers. They were dropped in favor of the gateway as the single transport.)
|
|
1854
1858
|
*/
|
package/dist/do/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { status, agentBootMsg, agentEvents } from '../chunk-
|
|
2
|
-
import
|
|
1
|
+
import { status, agentBootMsg, agentEvents } from '../chunk-XBZQT2TD.js';
|
|
2
|
+
import '../chunk-G5E74IJB.js';
|
|
3
|
+
import { createIntake } from '../chunk-OPH6Y4UT.js';
|
|
3
4
|
export { applyEffectEvent, emptyLedger, foldLedger, isOwed, pendingEffectsLedger, survivingEffects } from '../chunk-6IQPODUF.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-4PXNZ5UY.js';
|
|
6
|
+
import '../chunk-4NTCPTNQ.js';
|
|
7
|
+
import '../chunk-QNGYQMZB.js';
|
|
6
8
|
import '../chunk-PR6TB3BL.js';
|
|
7
9
|
import '../chunk-TXN2KFHF.js';
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-AYS5N6WY.js';
|
|
10
|
+
import '../chunk-6XBEYZME.js';
|
|
10
11
|
import { defaultRetryPolicy, initRetry, recordFailure, shouldRetry, nextDelayMs } from '../chunk-VBDU4JL6.js';
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
-
import
|
|
12
|
+
import '../chunk-4LPY67E4.js';
|
|
13
|
+
import '../chunk-GWWCCSDH.js';
|
|
14
|
+
import '../chunk-QWIPH4YH.js';
|
|
15
|
+
import '../chunk-KWNCM6XM.js';
|
|
16
|
+
import '../chunk-C4U5D5HP.js';
|
|
17
|
+
import { StoreConflictError, replay } from '../chunk-K4ETBNKS.js';
|
|
14
18
|
|
|
15
19
|
// src/do/durable-timer.ts
|
|
16
20
|
function durableTimer(config) {
|
|
@@ -247,11 +251,13 @@ function createAgentHost(config) {
|
|
|
247
251
|
const isTerminal = config.terminal ?? ((s) => s.run.phase === "done" || s.run.phase === "failed" || s.run.phase === "cancelled");
|
|
248
252
|
let cached = null;
|
|
249
253
|
async function build() {
|
|
250
|
-
const
|
|
251
|
-
|
|
254
|
+
const wired = config.buildMachine();
|
|
255
|
+
const ctxArg = { ctx: config.ctx };
|
|
256
|
+
const booting = config.run(wired.machine, {
|
|
257
|
+
...wired,
|
|
258
|
+
...ctxArg,
|
|
252
259
|
store: config.store,
|
|
253
|
-
events: agentEvents()
|
|
254
|
-
terminal: isTerminal
|
|
260
|
+
events: agentEvents()
|
|
255
261
|
});
|
|
256
262
|
sseFromAgentEvents(booting, sse, config.toSseFrame);
|
|
257
263
|
await autoBoot(booting, now);
|
|
@@ -272,7 +278,8 @@ function createAgentHost(config) {
|
|
|
272
278
|
return status((await runtime()).getState());
|
|
273
279
|
},
|
|
274
280
|
async result() {
|
|
275
|
-
|
|
281
|
+
const state = (await runtime()).getState();
|
|
282
|
+
return isTerminal(state) ? state : void 0;
|
|
276
283
|
},
|
|
277
284
|
sse,
|
|
278
285
|
async reset() {
|