@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.
- package/README.md +30 -7
- package/dist/agent/index.d.ts +49 -36
- 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-5XU6ZJO2.js +533 -0
- package/dist/chunk-5XU6ZJO2.js.map +1 -0
- package/dist/{chunk-AQ6ZIMEA.js → chunk-6NG4V5SB.js} +89 -115
- package/dist/chunk-6NG4V5SB.js.map +1 -0
- package/dist/{chunk-HYDWG35Q.js → chunk-7MGXQZPW.js} +11 -9
- package/dist/chunk-7MGXQZPW.js.map +1 -0
- package/dist/{chunk-BLJ2JQSH.js → chunk-BCTEOVOU.js} +3 -3
- package/dist/{chunk-BLJ2JQSH.js.map → chunk-BCTEOVOU.js.map} +1 -1
- package/dist/chunk-CH5KTOEZ.js +710 -0
- package/dist/chunk-CH5KTOEZ.js.map +1 -0
- package/dist/chunk-CIHSHLQX.js +64 -0
- package/dist/chunk-CIHSHLQX.js.map +1 -0
- package/dist/{chunk-Z2L3LSNV.js → chunk-EHUDXAKC.js} +246 -210
- package/dist/chunk-EHUDXAKC.js.map +1 -0
- package/dist/chunk-GOX2CYIM.js +380 -0
- package/dist/chunk-GOX2CYIM.js.map +1 -0
- package/dist/chunk-IVJP3GKJ.js +104 -0
- package/dist/chunk-IVJP3GKJ.js.map +1 -0
- package/dist/{chunk-F7FMAWLA.js → chunk-MVZS5FDM.js} +13 -6
- package/dist/chunk-MVZS5FDM.js.map +1 -0
- package/dist/{chunk-LYLTKJWM.js → chunk-MYNLY3HP.js} +9 -8
- package/dist/chunk-MYNLY3HP.js.map +1 -0
- package/dist/{chunk-I5MQMJDW.js → chunk-NSIAORRY.js} +20 -30
- package/dist/chunk-NSIAORRY.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-WT5PBPLB.js +98 -0
- package/dist/chunk-WT5PBPLB.js.map +1 -0
- package/dist/{core-CTzMJ82M.d.ts → core-BbgtiXdg.d.ts} +231 -139
- package/dist/do/index.d.ts +37 -32
- package/dist/do/index.js +21 -14
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-B0-qGQDy.d.ts → durable-effects-7MTK_jnj.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 -70
- 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-DJWIER_3.d.ts → index-7vV8xmsD.d.ts} +1 -1
- package/dist/{index-NjrT3fL2.d.ts → index-Bz5Rh9Ga.d.ts} +19 -96
- package/dist/index-CjFDUBeq.d.ts +207 -0
- package/dist/{index-6A7dB8f6.d.ts → index-CkFYA9Y6.d.ts} +14 -16
- package/dist/{index-B5BZ-_cT.d.ts → index-Cou86-GX.d.ts} +189 -108
- package/dist/{index-TvRb1KVf.d.ts → index-DU6JpQ8G.d.ts} +1 -1
- package/dist/{index-q0hXFeZ0.d.ts → index-Xufl55W8.d.ts} +286 -215
- package/dist/{index-4vZzljCD.d.ts → index-_dOR3xqA.d.ts} +57 -45
- package/dist/index.d.ts +181 -385
- package/dist/index.js +2 -1
- package/dist/jev/index.d.ts +147 -99
- package/dist/jev/index.js +329 -233
- package/dist/jev/index.js.map +1 -1
- package/dist/{machine-CdIcN2Xm.d.ts → machine-BQzTV8On.d.ts} +171 -280
- 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 -33
- 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 +6 -7
- 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-ClRZBhHQ.d.ts +53 -0
- 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 -455
- package/dist/resilience/index.js +37 -483
- package/dist/resilience/index.js.map +1 -1
- package/dist/{runtime-types-LWDoi943.d.ts → runtime-types-CiVpC0HN.d.ts} +131 -388
- package/dist/testing/index.d.ts +165 -15
- package/dist/testing/index.js +104 -3
- 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-DP3f5NIl.d.ts → types-LxZxGYda.d.ts} +2 -2
- package/dist/work-queue/index.d.ts +5 -6
- package/package.json +18 -5
- package/dist/chunk-AQ6ZIMEA.js.map +0 -1
- package/dist/chunk-F2US5BW6.js +0 -72
- package/dist/chunk-F2US5BW6.js.map +0 -1
- package/dist/chunk-F7FMAWLA.js.map +0 -1
- package/dist/chunk-HUKZQX6U.js +0 -97
- package/dist/chunk-HUKZQX6U.js.map +0 -1
- package/dist/chunk-HYDWG35Q.js.map +0 -1
- package/dist/chunk-I5MQMJDW.js.map +0 -1
- package/dist/chunk-LYLTKJWM.js.map +0 -1
- package/dist/chunk-MYXFNWAJ.js.map +0 -1
- package/dist/chunk-RQULHGYH.js +0 -1804
- package/dist/chunk-RQULHGYH.js.map +0 -1
- package/dist/chunk-Z2L3LSNV.js.map +0 -1
- package/dist/index-DMCeMPMJ.d.ts +0 -272
package/dist/do/index.d.ts
CHANGED
|
@@ -1,18 +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-CiVpC0HN.js';
|
|
2
|
+
import { P as PendingEffectsRecorder, b as EffectOwed, a as EffectConfirmed } from '../durable-effects-7MTK_jnj.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-7MTK_jnj.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 '../index-
|
|
5
|
+
import { C as Cmd, S as Sub, M as Machine, W as Wired } from '../core-BbgtiXdg.js';
|
|
6
|
+
import { g as AgentEvent, b as AgentTurn, c as AgentState, i as AgentMachineMsg, B as AgentStatus } from '../machine-BQzTV8On.js';
|
|
7
|
+
import '@standard-schema/spec';
|
|
8
|
+
import '../index-Bz5Rh9Ga.js';
|
|
9
|
+
import '../index-CjFDUBeq.js';
|
|
10
|
+
import '../index-Xufl55W8.js';
|
|
11
|
+
import '../types-LxZxGYda.js';
|
|
12
|
+
import '../index-7vV8xmsD.js';
|
|
13
|
+
import '../index-Cou86-GX.js';
|
|
14
|
+
import '../protocol-ClRZBhHQ.js';
|
|
15
|
+
import '../index-CkFYA9Y6.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @demlik/tea/do — `stepHost`, the HTTP-PULL control carrier (#92).
|
|
@@ -407,7 +407,7 @@ declare function runStepLoop<R, I, O>(token: string, runId: string, transport: S
|
|
|
407
407
|
* and the vortex arena tick (`room.ts` `armTick` + `onTick`) replicates the
|
|
408
408
|
* exact shape for the 18 Hz game clock. The two old `do_alarm`/`do_ws` Subs were
|
|
409
409
|
* dropped (see `./index`'s historical note) because `toMachine` fixes the agent
|
|
410
|
-
* machine's Sub type to `
|
|
410
|
+
* machine's Sub type to `DeadlinesSub`, so they could never union into a grain's
|
|
411
411
|
* Sub set — leaving the alarm re-arm a HOST concern with no first-class home.
|
|
412
412
|
*
|
|
413
413
|
* {@link durableTimer} is that home: a tiny, transport- and Msg-agnostic helper
|
|
@@ -1056,18 +1056,22 @@ declare function sseFromAgentEvents<R, Frame>(runtime: {
|
|
|
1056
1056
|
*/
|
|
1057
1057
|
interface AgentHostConfig<Stage, P extends string, O extends Record<P, AgentTurn>, R, Frame, C extends Cmd = Cmd, U extends Sub = Sub, Ctx = unknown> {
|
|
1058
1058
|
/**
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
* 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.
|
|
1062
1061
|
*/
|
|
1063
|
-
readonly
|
|
1064
|
-
/** The durable `Store` for the agent slice (typically `doStore(storage, parse)`). */
|
|
1065
|
-
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>>;
|
|
1066
1063
|
/**
|
|
1067
|
-
*
|
|
1068
|
-
* `
|
|
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.
|
|
1069
1069
|
*/
|
|
1070
|
-
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;
|
|
1071
1075
|
/**
|
|
1072
1076
|
* The run-terminality predicate (#46) — what makes `result()` first-class.
|
|
1073
1077
|
* Defaults to the agent's own terminal phases (`done` / `failed`).
|
|
@@ -1098,10 +1102,10 @@ interface AgentHost<Stage, P extends string, O extends Record<P, AgentTurn>, R,
|
|
|
1098
1102
|
* Get (or build) the booted runtime. Build-once-boot-once: the first call
|
|
1099
1103
|
* builds the machine, wires SSE off the semantic event stream, awaits the boot
|
|
1100
1104
|
* gate, runs the `autoBoot` re-fire for a rehydrated suspended run, and caches
|
|
1101
|
-
* the booted
|
|
1105
|
+
* the booted handle; subsequent calls return the cached handle. The single
|
|
1102
1106
|
* assembly every consumer used to hand-roll in `getRuntime()`.
|
|
1103
1107
|
*/
|
|
1104
|
-
runtime(): Promise<
|
|
1108
|
+
runtime(): Promise<BootedRunHandle<AgentState<Stage, P, O, R>, AgentMachineMsg<P, O, R>, AgentEvent<R>>>;
|
|
1105
1109
|
/**
|
|
1106
1110
|
* The agent's lifecycle status (#49) — the ONE typed channel a consumer reads
|
|
1107
1111
|
* instead of re-deriving `run.phase` / `awaiting` by hand. Ensures the runtime
|
|
@@ -1137,6 +1141,7 @@ interface AgentHost<Stage, P extends string, O extends Record<P, AgentTurn>, R,
|
|
|
1137
1141
|
*
|
|
1138
1142
|
* @example
|
|
1139
1143
|
* const host = createAgentHost<Stage, Purpose, Outputs, ClientResult, SseEvent>({
|
|
1144
|
+
* run, // from `@demlik/tea/promise`
|
|
1140
1145
|
* buildMachine: () => agent.toMachine<Ctx>({ toolInterpret }),
|
|
1141
1146
|
* store: doStore(storage, parse),
|
|
1142
1147
|
* ctx,
|
|
@@ -1372,14 +1377,14 @@ interface ResumePort<S, M extends {
|
|
|
1372
1377
|
* every DO-hosted machine otherwise re-derives.
|
|
1373
1378
|
*
|
|
1374
1379
|
* `await ready` is the single boot gate (issue #45): `getState()` is total only
|
|
1375
|
-
* on the booted
|
|
1376
|
-
* 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.
|
|
1377
1382
|
*/
|
|
1378
1383
|
declare function bootResume<S, M extends {
|
|
1379
1384
|
type: string;
|
|
1380
1385
|
}, E extends {
|
|
1381
1386
|
type: string;
|
|
1382
|
-
} = never>(booting:
|
|
1387
|
+
} = never>(booting: RunHandle<S, M, E>, port: ResumePort<S, M>, now?: () => number): Promise<void>;
|
|
1383
1388
|
/**
|
|
1384
1389
|
* True iff an agent slice loaded from storage is mid-loop (running + awaiting
|
|
1385
1390
|
* tools) — the resumable case `agent_boot` re-fires.
|
|
@@ -1403,7 +1408,7 @@ declare function agentIsResumable<Stage, P extends string, O extends Record<P, u
|
|
|
1403
1408
|
*/
|
|
1404
1409
|
declare function autoBoot<Stage, P extends string, O extends Record<P, unknown>, R, E extends {
|
|
1405
1410
|
type: string;
|
|
1406
|
-
} = never>(booting:
|
|
1411
|
+
} = never>(booting: RunHandle<AgentState<Stage, P, O, R>, AgentMachineMsg<P, O, R>, E>, now?: () => number): Promise<void>;
|
|
1407
1412
|
/**
|
|
1408
1413
|
* Re-fire every round-trip a rehydrated actor still owes, on wake. Given a
|
|
1409
1414
|
* durable carrier whose recorder was rehydrated from the persisted ledger
|
|
@@ -1833,7 +1838,7 @@ declare function presenceCount(ctx: PresenceCtx, tag?: string): number;
|
|
|
1833
1838
|
*
|
|
1834
1839
|
* 2. `deferredGateway` + `createAgentHost` (from `./host`) — THE transport for
|
|
1835
1840
|
* a DO-hosted agent. A `createAgent().toMachine()` machine owns exactly one
|
|
1836
|
-
* Sub type, `
|
|
1841
|
+
* Sub type, `DeadlinesSub` (the agent's own retry + watchdog timers); it has
|
|
1837
1842
|
* no DO-native Sub variant to compose, and it needs none. The gateway owns
|
|
1838
1843
|
* each deferred tool round-trip as a Promise the interpret cell awaits:
|
|
1839
1844
|
* - Inbound WebSocket frames are bridged straight into `gateway.settle(...)`
|
|
@@ -1847,7 +1852,7 @@ declare function presenceCount(ctx: PresenceCtx, tag?: string): number;
|
|
|
1847
1852
|
*
|
|
1848
1853
|
* (Historical note: this module previously also shipped `do_ws` / `do_alarm`
|
|
1849
1854
|
* Subs + a `doSubscribe` registry. Because `toMachine` fixes the agent machine's
|
|
1850
|
-
* Sub type to `
|
|
1855
|
+
* Sub type to `DeadlinesSub`, those Subs could never union into an agent host's
|
|
1851
1856
|
* Sub set — they were structurally unusable by the flagship consumer and had no
|
|
1852
1857
|
* callers. They were dropped in favor of the gateway as the single transport.)
|
|
1853
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-EHUDXAKC.js';
|
|
2
|
+
import '../chunk-G5E74IJB.js';
|
|
3
|
+
import { createIntake } from '../chunk-MYNLY3HP.js';
|
|
3
4
|
export { applyEffectEvent, emptyLedger, foldLedger, isOwed, pendingEffectsLedger, survivingEffects } from '../chunk-6IQPODUF.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-7MGXQZPW.js';
|
|
6
|
+
import '../chunk-CIHSHLQX.js';
|
|
7
|
+
import '../chunk-QNGYQMZB.js';
|
|
6
8
|
import '../chunk-PR6TB3BL.js';
|
|
7
9
|
import '../chunk-TXN2KFHF.js';
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-AQ6ZIMEA.js';
|
|
10
|
+
import '../chunk-6NG4V5SB.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-IVJP3GKJ.js';
|
|
14
|
+
import '../chunk-WT5PBPLB.js';
|
|
15
|
+
import '../chunk-5XU6ZJO2.js';
|
|
16
|
+
import '../chunk-GOX2CYIM.js';
|
|
17
|
+
import { StoreConflictError, replay } from '../chunk-CH5KTOEZ.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() {
|