effect-durable-agent 0.1.0-alpha.1 → 0.1.0-alpha.4
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/CHANGELOG.md +25 -1
- package/README.md +131 -128
- package/SECURITY.md +3 -4
- package/dist/{command-queues-CQ9cwRP7.d.ts → command-queues-CV7O-51r.d.ts} +7 -6
- package/dist/{compaction-YayFKo_1.d.ts → compaction-zbvLREI8.d.ts} +8 -6
- package/dist/context-projection-n6Rdup0N.d.ts +140 -0
- package/dist/{core-Hv3cFydL.d.ts → core-CYT6DBaS.d.ts} +2 -2
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/context-projection.d.ts +2 -0
- package/dist/domain/context-projection.js +32 -0
- package/dist/domain/context-projection.js.map +1 -0
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/reduced-state-schema.d.ts +2 -0
- package/dist/domain/reduced-state-schema.js +2 -1
- package/dist/domain/reduced-state-schema.js.map +1 -1
- package/dist/domain/reduced-state.d.ts +1 -1
- package/dist/domain/reduced-state.js +1 -1
- package/dist/{durable-DlScwmCy.d.ts → durable-B7M6TD_0.d.ts} +341 -2
- package/dist/{durable-C3Rz7kg3.js → durable-DsV9PxZC.js} +13 -2
- package/dist/durable-DsV9PxZC.js.map +1 -0
- package/dist/{keep-alive-DYDsH6qN.d.ts → event-factory-CLJcyymV.d.ts} +5 -29
- package/dist/{keep-alive-p8dIcSVy.js → event-factory-tcpLgdMN.js} +3 -10
- package/dist/event-factory-tcpLgdMN.js.map +1 -0
- package/dist/host/websocket-protocol.d.ts +229 -0
- package/dist/host/websocket-protocol.js +99 -0
- package/dist/host/websocket-protocol.js.map +1 -0
- package/dist/host/websocket-wire.d.ts +2 -2
- package/dist/host/websocket-wire.js +37 -20
- package/dist/host/websocket-wire.js.map +1 -1
- package/dist/{id-generator-C2Q15uZM.d.ts → id-generator-Ckl8_XWW.d.ts} +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/keep-alive-Chl5SJxy.d.ts +29 -0
- package/dist/{message-transcript-BCHdHAe2.d.ts → message-transcript-DiOPBY3l.d.ts} +3 -3
- package/dist/{prompt-projector-9_02lk5-.d.ts → prompt-projector-C1IbkHr0.d.ts} +15 -16
- package/dist/{reduced-state-C4nVVzz9.js → reduced-state-TMi7ISla.js} +20 -4
- package/dist/reduced-state-TMi7ISla.js.map +1 -0
- package/dist/{reducer-registry-C0svUa63.d.ts → reducer-registry-CjSJBPKo.d.ts} +2 -2
- package/dist/{runtime-C56FQxiL.d.ts → runtime-DOgmAKsO.d.ts} +7 -6
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/compaction.js +4 -3
- package/dist/services/compaction.js.map +1 -1
- package/dist/services/id-generator.d.ts +1 -1
- package/dist/services/keep-alive.d.ts +2 -0
- package/dist/services/keep-alive.js +13 -0
- package/dist/services/keep-alive.js.map +1 -0
- package/dist/services/prompt-projector.d.ts +2 -2
- package/dist/services/prompt-projector.js +20 -10
- package/dist/services/prompt-projector.js.map +1 -1
- package/dist/services/reducer-registry.d.ts +1 -1
- package/dist/services/runtime-layer.d.ts +58 -0
- package/dist/services/runtime-layer.js +42 -0
- package/dist/services/runtime-layer.js.map +1 -0
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +4 -3
- package/dist/services/runtime.js.map +1 -1
- package/dist/services/session-query.d.ts +1 -1
- package/dist/services/session-query.js +76 -1
- package/dist/services/session-query.js.map +1 -0
- package/dist/services/session-state.d.ts +2 -0
- package/dist/services/session-state.js +2 -0
- package/dist/services/session-store.d.ts +2 -2
- package/dist/services/session-store.js +181 -2
- package/dist/services/session-store.js.map +1 -0
- package/dist/services/sink-checkpoint-store.d.ts +2 -0
- package/dist/services/sink-checkpoint-store.js +49 -0
- package/dist/services/sink-checkpoint-store.js.map +1 -0
- package/dist/services/sink-registry.d.ts +1 -1
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/services/websocket-subscriber.d.ts +54 -0
- package/dist/services/websocket-subscriber.js +190 -0
- package/dist/services/websocket-subscriber.js.map +1 -0
- package/dist/session-query-C-C4m1eq.d.ts +38 -0
- package/dist/{session-query-DlRo5Ufc.d.ts → session-state-CjOSvWbe.d.ts} +132 -40
- package/dist/{session-query-DOc1KanA.js → session-state-SStf0KUo.js} +43 -146
- package/dist/session-state-SStf0KUo.js.map +1 -0
- package/dist/{session-store-D2Ore1QC.d.ts → session-store-DZZUffUy.d.ts} +5 -94
- package/dist/sink-checkpoint-store-BZmQFTRE.d.ts +40 -0
- package/dist/{sink-registry-CIU0LD3m.d.ts → sink-registry-Cf79ICdW.d.ts} +11 -40
- package/dist/{sink-registry-CFC6xjsN.js → sink-registry-D13eUO_c.js} +9 -47
- package/dist/sink-registry-D13eUO_c.js.map +1 -0
- package/dist/testkit/layers.d.ts +14 -11
- package/dist/testkit/layers.js +8 -5
- package/dist/testkit/layers.js.map +1 -1
- package/dist/{tool-registry-CcnkAAQK.d.ts → tool-registry-B7Wona6N.d.ts} +3 -3
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.js +1 -1
- package/dist/types/core.js.map +1 -1
- package/dist/types/events/durable.d.ts +2 -2
- package/dist/types/events/durable.js +2 -2
- package/dist/types/events.d.ts +2 -2
- package/dist/types/events.js +2 -2
- package/dist/websocket-wire-QD2SquQE.d.ts +2244 -0
- package/docs/assets/architecture.svg +170 -60
- package/docs/assets/event-sequence.svg +68 -78
- package/docs/assets/hero.svg +33 -0
- package/docs/message-steering.md +1 -1
- package/docs/releasing.md +96 -39
- package/docs/spec.md +15 -12
- package/docs/websocket-protocol.md +35 -9
- package/package.json +55 -35
- package/dist/durable-C3Rz7kg3.js.map +0 -1
- package/dist/durable-object-runtime-B7jwBY2R.js +0 -1494
- package/dist/durable-object-runtime-B7jwBY2R.js.map +0 -1
- package/dist/durable-object-runtime-pWv0ohlz.d.ts +0 -257
- package/dist/durable-object-storage-Czy7IPrh.d.ts +0 -41
- package/dist/host/durable-object-runtime.d.ts +0 -2
- package/dist/host/durable-object-runtime.js +0 -2
- package/dist/host/durable-object-storage.d.ts +0 -2
- package/dist/host/durable-object-storage.js +0 -0
- package/dist/host/durable-object.d.ts +0 -83
- package/dist/host/durable-object.js +0 -191
- package/dist/host/durable-object.js.map +0 -1
- package/dist/keep-alive-p8dIcSVy.js.map +0 -1
- package/dist/reduced-state-C4nVVzz9.js.map +0 -1
- package/dist/session-query-DOc1KanA.js.map +0 -1
- package/dist/session-store-pYxQW9qh.js +0 -214
- package/dist/session-store-pYxQW9qh.js.map +0 -1
- package/dist/sink-registry-CFC6xjsN.js.map +0 -1
- package/dist/websocket-wire-DvOu_6BJ.d.ts +0 -16773
- package/examples/001-no-tools/README.md +0 -65
- package/examples/001-no-tools/worker.ts +0 -79
- package/examples/002-slack-bridge/README.md +0 -134
- package/examples/002-slack-bridge/events.ts +0 -115
- package/examples/002-slack-bridge/reducer.ts +0 -216
- package/examples/002-slack-bridge/scenario.test.ts +0 -223
- package/examples/002-slack-bridge/sinks.ts +0 -109
- package/examples/002-slack-bridge/worker.ts +0 -140
- package/examples/003-sandbox-lifecycle/README.md +0 -78
- package/examples/003-sandbox-lifecycle/events.ts +0 -203
- package/examples/003-sandbox-lifecycle/reducer.ts +0 -305
- package/examples/003-sandbox-lifecycle/scenario.test.ts +0 -202
- package/examples/_shared/event-id.ts +0 -12
- package/examples/_shared/http.ts +0 -27
- package/examples/_shared/openai.ts +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Effect Durable Agent will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
## 0.1.0-alpha.4
|
|
8
|
+
|
|
9
|
+
- Let applications project instruction and data messages from current reducer state into each model prompt
|
|
10
|
+
- Build prompts only after turn input selection is committed into durable reducer state
|
|
11
|
+
- Split the host-neutral runtime, Cloudflare Durable Objects host, and celld host into lockstep packages
|
|
12
|
+
- Add shared real-runtime conformance tests for workerd and celld, including RPC, persistence,
|
|
13
|
+
hard-restart recovery, durable idempotency, WebSocket resume/ACK, and warm/cold session recreation
|
|
14
|
+
- Encode Effect Schema values explicitly at Durable Object RPC boundaries
|
|
15
|
+
|
|
16
|
+
## 0.1.0-alpha.3
|
|
17
|
+
|
|
18
|
+
- Publish the state-projected prompt context and WebSocket schema changes from the unpublished `0.1.0-alpha.2` package
|
|
19
|
+
- Pin prerelease publication to the npm `alpha` dist-tag
|
|
20
|
+
|
|
21
|
+
## 0.1.0-alpha.2
|
|
22
|
+
|
|
23
|
+
- Let applications project instruction and data messages from current reducer state into each model prompt
|
|
24
|
+
- Build prompts only after turn input selection is committed into durable reducer state
|
|
25
|
+
- Separate WebSocket protocol schemas into explicit domain and wire surfaces
|
|
26
|
+
- Add a typed domain-frame encoder, a host adapter for app-event narrowing, and transformation
|
|
27
|
+
round-trip coverage
|
|
28
|
+
|
|
5
29
|
## 0.1.0-alpha.1
|
|
6
30
|
|
|
7
|
-
-
|
|
31
|
+
- Publish the first public prerelease as `effect-durable-agent`
|
|
8
32
|
- Ship compiled ESM and TypeScript declarations for every supported subpath
|
|
9
33
|
- Add isolated package-consumer validation for Cloudflare Workers
|
|
10
34
|
- Add MIT licensing and trusted-publishing release automation
|
package/README.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# effect-durable-agent
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/effect-durable-agent)
|
|
6
|
+
[](https://github.com/advait/effect-durable-agent/actions/workflows/ci.yml)
|
|
5
7
|
|
|
6
8
|
## Why?
|
|
7
9
|
|
|
@@ -14,16 +16,12 @@ Tool execution constantly changes what that application needs to represent: `San
|
|
|
14
16
|
event that transitions the application's state machine**. Product state and agent state coexist in
|
|
15
17
|
the same event sequence.
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
state. EDA records them in one durable history, giving agent state and product state a shared source
|
|
19
|
-
of truth. It streams those same events to clients. Each client uses them to update its local state,
|
|
20
|
-
so every view converges on the durable session state—even across tabs and reconnects.
|
|
21
|
-
|
|
22
|
-
## One state machine for the whole application
|
|
19
|
+
## How EDA works
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
EDA models the agent and the surrounding product as one application state machine. For example, a
|
|
22
|
+
coding-agent session might record:
|
|
25
23
|
|
|
26
|
-

|
|
27
25
|
|
|
28
26
|
Framework events and product events are not separate channels. They form the same history and
|
|
29
27
|
transition the same application state.
|
|
@@ -38,161 +36,165 @@ EDA supplies the framework events and reducers for commands, runs, turns, messag
|
|
|
38
36
|
tool calls. Applications add their own typed events and reducers for sandboxes, approvals, billing,
|
|
39
37
|
external conversations, delivery state, or anything else the product needs to represent.
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
Those events flow through the rest of the system as follows:
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+

|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
reconnect-safe WebSocket protocol. In a server-side rendering (SSR) flow, the server renders state
|
|
47
|
-
through sequence `N`; the browser hydrates from that snapshot, follows events after `N`, and applies
|
|
48
|
-
its application projection as they arrive.
|
|
49
|
-
|
|
50
|
-
```text
|
|
51
|
-
server snapshot through N
|
|
52
|
-
+
|
|
53
|
-
streamed events after N
|
|
54
|
-
=
|
|
55
|
-
current client state
|
|
56
|
-
```
|
|
43
|
+
### 1. Session runtime: one state machine for the entire application
|
|
57
44
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
User commands and application events enter one centralized session runtime. It manages the entire
|
|
46
|
+
application state machine: agent lifecycles such as runs, inference, and tool calls coexist with
|
|
47
|
+
product lifecycles such as sandboxes, approvals, and external delivery.
|
|
61
48
|
|
|
62
|
-
|
|
49
|
+
Every transition therefore has one owner and one place to be recorded, rather than leaving session
|
|
50
|
+
state scattered across callbacks, workers, and unrelated stores.
|
|
63
51
|
|
|
64
|
-
|
|
52
|
+
### 2. Ordered event log: the definitive history of the state machine
|
|
65
53
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
eventually. Each sink tracks its own persisted cursor, advances only after successful processing,
|
|
70
|
-
and retries failures with backoff.
|
|
54
|
+
When the state machine transitions, EDA records an event durably and assigns it the next sequence
|
|
55
|
+
number for that session. Read in order, those events definitively describe how the application
|
|
56
|
+
evolved.
|
|
71
57
|
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
The event log—not an in-memory object or cached snapshot—is the source of truth. Current state,
|
|
59
|
+
client updates, recovery, tests, and external delivery are all derived from that ordered history.
|
|
74
60
|
|
|
75
|
-
|
|
76
|
-
and durable outbound delivery.
|
|
61
|
+
### 3. Live event stream: reconnect without losing the session
|
|
77
62
|
|
|
78
|
-
|
|
63
|
+
Live clients subscribe to the event stream over a reconnect-safe WebSocket protocol. Each client
|
|
64
|
+
tracks the last durable sequence it has applied.
|
|
79
65
|
|
|
80
|
-
|
|
66
|
+
When a slow or disconnected client returns, it provides that sequence, receives every committed
|
|
67
|
+
event after it, and then continues live.
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
### 4. Pure reducers: events become state
|
|
83
70
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
the recovery transitions before new live activity.
|
|
71
|
+
Framework and application reducers fold the ordered event history to produce current state.
|
|
72
|
+
Framework events update agent lifecycles; application events update product lifecycles; both
|
|
73
|
+
contribute to the same state model.
|
|
88
74
|
|
|
89
|
-
|
|
75
|
+
Reducers are pure: given the same starting state and event, they produce the same next state. That
|
|
76
|
+
makes every state transition explicit, replayable, and testable.
|
|
90
77
|
|
|
91
|
-
|
|
92
|
-
become a test fixture.
|
|
78
|
+
### 5. State: a cached view of durable history
|
|
93
79
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
test instead of a story in a bug report.
|
|
80
|
+
The reducers produce a complete snapshot of framework and application state through a known
|
|
81
|
+
sequence number. EDA caches that snapshot in host-provided durable storage so reads and restarts do
|
|
82
|
+
not need to replay the entire history from the beginning.
|
|
98
83
|
|
|
99
|
-
The
|
|
100
|
-
|
|
101
|
-
durable and live event artifacts.
|
|
84
|
+
The cache is an optimization, not a second source of truth. If it is missing or incompatible, EDA
|
|
85
|
+
can rebuild it from the event log; the application is ultimately defined by its ordered events.
|
|
102
86
|
|
|
103
|
-
###
|
|
87
|
+
### 6. Pure projections: UI state is not model context
|
|
104
88
|
|
|
105
|
-
|
|
89
|
+
State is not the final representation consumed by either people or models. The UI is a pure
|
|
90
|
+
projection of state, and the LLM context is a separate pure projection of that same state.
|
|
106
91
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
92
|
+
The UI can preserve tool progress, approvals, sandbox status, and rich product history while the
|
|
93
|
+
LLM context selects and compacts only what the model should see. Applications can model each
|
|
94
|
+
consumer honestly instead of collapsing both into one constrained representation. See the
|
|
95
|
+
[UI projection guide](./docs/ui-projection.md) for the projection contract.
|
|
111
96
|
|
|
112
|
-
|
|
97
|
+
### 7. Durable sinks: callbacks that survive failure
|
|
113
98
|
|
|
114
|
-
|
|
99
|
+
Framework and application events often need to trigger side effects in external systems: post to
|
|
100
|
+
Slack, write to a database, or notify another service. Handling them in ordinary callbacks makes
|
|
101
|
+
delivery depend on the health of the current process.
|
|
115
102
|
|
|
116
|
-
EDA
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
103
|
+
EDA handles this with durable sinks, which behave like durable callbacks over committed session
|
|
104
|
+
history. EDA delivers events to each sink in sequence order, persists its progress, retries
|
|
105
|
+
failures, and resumes after application restarts. Sinks run independently of the application loop,
|
|
106
|
+
so external delivery does not block application progress. Durable retries let external systems
|
|
107
|
+
converge on committed session history with eventual-consistency guarantees.
|
|
120
108
|
|
|
121
|
-
|
|
109
|
+
Delivery is at-least-once, so external operations must be idempotent. Each durable event carries a
|
|
110
|
+
stable event ID that, together with its session ID, provides the operation's idempotency key.
|
|
122
111
|
|
|
123
|
-
|
|
124
|
-
- Per-object SQLite stores the ordered history beside the runtime that owns it
|
|
125
|
-
- WebSockets terminate at the same boundary that owns the state
|
|
126
|
-
- Alarms wake evicted sessions for recovery, keep-alive, and sink draining
|
|
112
|
+
## What this unlocks
|
|
127
113
|
|
|
128
|
-
|
|
129
|
-
storage, scheduling, identity, and live-delivery boundaries that another platform can implement
|
|
130
|
-
with equivalent semantics.
|
|
114
|
+
### Live state on every client
|
|
131
115
|
|
|
132
|
-
|
|
116
|
+
Every tab, embedded surface, and admin view follows the same durable session. If one client loses
|
|
117
|
+
its connection or falls behind, it returns to the current state instead of resetting the session or
|
|
118
|
+
guessing which updates it missed.
|
|
133
119
|
|
|
134
|
-
|
|
120
|
+
Server-side rendering does not require a second state model. The server can render a durable
|
|
121
|
+
snapshot, and the browser can continue from that exact point as new events arrive.
|
|
135
122
|
|
|
136
|
-
|
|
137
|
-
scoped resources, typed failures, retries, services, and tracing. The event history owns durable
|
|
138
|
-
truth.
|
|
123
|
+
### Durable side effects
|
|
139
124
|
|
|
140
|
-
|
|
125
|
+
If `AssistantMessageCommitted` should post a result to Slack and Slack is unavailable, the agent
|
|
126
|
+
keeps moving. When Slack recovers, it receives the committed events and converges with the session
|
|
127
|
+
history. External availability stays off the application's critical path without sacrificing
|
|
128
|
+
reliable delivery.
|
|
141
129
|
|
|
142
|
-
|
|
130
|
+
See the [Slack bridge example](./packages/cloudflare/examples/002-slack-bridge) for idempotent
|
|
131
|
+
ingress, a custom reducer, and durable outbound delivery.
|
|
143
132
|
|
|
144
|
-
|
|
145
|
-
drive reducers, recovery, reconnect, tests, and durable sinks
|
|
146
|
-
- **Ephemeral events** carry live-only details such as text deltas, reasoning deltas, and speculative
|
|
147
|
-
tool parameters. They are positioned against the current durable head but are not durable truth
|
|
133
|
+
**Durable state. Durable side effects.**
|
|
148
134
|
|
|
149
|
-
|
|
135
|
+
### Agents survive deploys and failures
|
|
150
136
|
|
|
151
|
-
|
|
137
|
+
Deploys and failures restart the application—not the session.
|
|
152
138
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
139
|
+
EDA rebuilds framework and product state from durable history, repairs incomplete lifecycle
|
|
140
|
+
boundaries, and transparently continues eligible in-progress work in a replacement run. Completed
|
|
141
|
+
tool calls are not blindly repeated, queued commands remain durable, and reconnecting clients see
|
|
142
|
+
the recovery transitions before new live activity.
|
|
156
143
|
|
|
157
|
-
|
|
158
|
-
startup and snapshots; the event log remains the source of truth.
|
|
144
|
+
### Production sessions become UI fixtures
|
|
159
145
|
|
|
160
|
-
|
|
146
|
+
A production event sequence can become a test fixture. Replay it one event at a time, stop at any
|
|
147
|
+
sequence, and assert exactly what the UI should show: the running tool card, the active sandbox, the
|
|
148
|
+
pending approval, the completed delivery, or the recovered run.
|
|
161
149
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
150
|
+
A difficult production session becomes a reproducible UI test instead of a story in a bug report.
|
|
151
|
+
The package includes pure reducer tests, generated state-machine properties, canned-model journeys,
|
|
152
|
+
crash-prefix simulations, and an [offline trace harness](./testing/offline-trace) that writes durable
|
|
153
|
+
and live event artifacts.
|
|
165
154
|
|
|
166
|
-
###
|
|
155
|
+
### Tracing for every agent run
|
|
167
156
|
|
|
168
|
-
|
|
169
|
-
ordering, tracks an independent durable cursor, and advances only after successful processing.
|
|
170
|
-
Failures retry with backoff, so external systems converge eventually without blocking the agent.
|
|
157
|
+
See what happened, in what order, and where the time went.
|
|
171
158
|
|
|
172
|
-
|
|
159
|
+
EDA uses Effect spans across meaningful runtime boundaries, including command admission, runs,
|
|
160
|
+
turns, model inference, tools, event streaming, durable sinks, and recovery. Trace context survives
|
|
161
|
+
the durable boundaries that separate ingress, execution, and side effects, and Effect telemetry can
|
|
162
|
+
be exported through OpenTelemetry to Google Cloud Trace or another existing backend.
|
|
173
163
|
|
|
174
|
-
|
|
164
|
+

|
|
165
|
+
|
|
166
|
+
## Host-neutral core, pluggable deployment
|
|
175
167
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
168
|
+
EDA separates its state machine and Effect service graph from the platform that provides durable
|
|
169
|
+
storage, scheduling, identity, and live WebSockets. Applications select one host package:
|
|
170
|
+
|
|
171
|
+
| Package | Responsibility |
|
|
172
|
+
| --- | --- |
|
|
173
|
+
| `effect-durable-agent` | Host-independent commands, events, reducers, runtime, and adapter contracts. |
|
|
174
|
+
| `effect-durable-agent-cloudflare` | Cloudflare Durable Objects, SQLite, alarms, RPC, and hibernatable WebSockets. |
|
|
175
|
+
| `effect-durable-agent-celld` | [celld](https://celld.dev/) deployment of the Durable Objects contract on your infrastructure. |
|
|
176
|
+
|
|
177
|
+
All three packages are released together with the same version. A host and core from different
|
|
178
|
+
versions are not a supported combination; keep the versions identical when upgrading.
|
|
183
179
|
|
|
184
180
|
## Get started
|
|
185
181
|
|
|
186
|
-
Install
|
|
182
|
+
Install the core and one host from the public alpha channel:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pnpm add effect-durable-agent@alpha effect-durable-agent-cloudflare@alpha
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
For celld, select its host package at the same version instead:
|
|
187
189
|
|
|
188
190
|
```bash
|
|
189
|
-
pnpm add effect-durable-agent@alpha
|
|
191
|
+
pnpm add effect-durable-agent@alpha effect-durable-agent-celld@alpha
|
|
190
192
|
```
|
|
191
193
|
|
|
192
|
-
The smallest host is a concrete Durable Object subclass:
|
|
194
|
+
The smallest Cloudflare host is a concrete Durable Object subclass:
|
|
193
195
|
|
|
194
196
|
```ts
|
|
195
|
-
import { EDASessionDurableObject } from "effect-durable-agent
|
|
197
|
+
import { EDASessionDurableObject } from "effect-durable-agent-cloudflare"
|
|
196
198
|
|
|
197
199
|
export class MyAgentSession extends EDASessionDurableObject<MyEnv> {
|
|
198
200
|
constructor(ctx: DurableObjectState, env: MyEnv) {
|
|
@@ -208,19 +210,9 @@ Start with the executable examples:
|
|
|
208
210
|
|
|
209
211
|
| Example | What it demonstrates |
|
|
210
212
|
| --- | --- |
|
|
211
|
-
| [`001-no-tools`](./examples/001-no-tools) | Minimal Durable Object session and durable command admission. |
|
|
212
|
-
| [`002-slack-bridge`](./examples/002-slack-bridge) | Idempotent ingress, application events and reducers, and a retrying durable sink. |
|
|
213
|
-
| [`003-sandbox-lifecycle`](./examples/003-sandbox-lifecycle) | Tool and product events reduced into one UI model, including snapshot-to-stream handoff. |
|
|
214
|
-
|
|
215
|
-
## Why Effect?
|
|
216
|
-
|
|
217
|
-
Agent sessions combine long-running model streams, concurrent tools, interruption, cleanup, retries,
|
|
218
|
-
external services, and observability. EDA uses [Effect](https://effect.website/) so those concerns
|
|
219
|
-
share one structured execution model rather than a collection of detached promises and callbacks.
|
|
220
|
-
|
|
221
|
-
Effect is the implementation foundation, not the product pitch. The reason to use EDA is the
|
|
222
|
-
durable application model; Effect is what lets the runtime execute that model with scoped resources,
|
|
223
|
-
typed boundaries, structured concurrency, and first-class tracing.
|
|
213
|
+
| [`001-no-tools`](./packages/cloudflare/examples/001-no-tools) | Minimal Durable Object session and durable command admission. |
|
|
214
|
+
| [`002-slack-bridge`](./packages/cloudflare/examples/002-slack-bridge) | Idempotent ingress, application events and reducers, and a retrying durable sink. |
|
|
215
|
+
| [`003-sandbox-lifecycle`](./packages/cloudflare/examples/003-sandbox-lifecycle) | Tool and product events reduced into one UI model, including snapshot-to-stream handoff. |
|
|
224
216
|
|
|
225
217
|
## Why EDA instead of another agent SDK or framework?
|
|
226
218
|
|
|
@@ -276,7 +268,7 @@ client catch-up, restart recovery, production-derived UI fixtures, and durable s
|
|
|
276
268
|
## Capabilities
|
|
277
269
|
|
|
278
270
|
- Effect-native agent runtime with command, run, turn, inference, message, and tool lifecycles
|
|
279
|
-
- Cloudflare Durable
|
|
271
|
+
- Pluggable Cloudflare Durable Objects and celld hosts with one session per object and SQLite event storage
|
|
280
272
|
- Typed custom durable application events and pure application reducers
|
|
281
273
|
- Reducer checkpoints and serialized snapshots
|
|
282
274
|
- Reconnect-safe event streaming with sequence resume and WebSocket ACK flow control
|
|
@@ -289,6 +281,16 @@ client catch-up, restart recovery, production-derived UI fixtures, and durable s
|
|
|
289
281
|
- Trace propagation and Effect span instrumentation across runtime boundaries
|
|
290
282
|
- Queue, steer, interrupt, stop, and idempotent command admission
|
|
291
283
|
|
|
284
|
+
## Why Effect?
|
|
285
|
+
|
|
286
|
+
Agent sessions combine long-running model streams, concurrent tools, interruption, cleanup, retries,
|
|
287
|
+
external services, and observability. EDA uses [Effect](https://effect.website/) so those concerns
|
|
288
|
+
share one structured execution model rather than a collection of detached promises and callbacks.
|
|
289
|
+
|
|
290
|
+
Effect is the implementation foundation, not the product pitch. The reason to use EDA is the
|
|
291
|
+
durable application model; Effect is what lets the runtime execute that model with scoped resources,
|
|
292
|
+
typed boundaries, structured concurrency, and first-class tracing.
|
|
293
|
+
|
|
292
294
|
## Documentation
|
|
293
295
|
|
|
294
296
|
- [Current implementation](./docs/spec.md)
|
|
@@ -297,6 +299,7 @@ client catch-up, restart recovery, production-derived UI fixtures, and durable s
|
|
|
297
299
|
- [Message steering](./docs/message-steering.md)
|
|
298
300
|
- [UI projection proposal](./docs/ui-projection.md)
|
|
299
301
|
- [Subagents proposal](./docs/subagents.md)
|
|
302
|
+
- [Maintainer release guide](./docs/releasing.md)
|
|
300
303
|
|
|
301
304
|
## Contributing and license
|
|
302
305
|
|
package/SECURITY.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Please do not report security vulnerabilities in public issues.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
private thread.
|
|
5
|
+
Use [GitHub's private vulnerability reporting](https://github.com/advait/effect-durable-agent/security/advisories/new).
|
|
6
|
+
Include the affected package version, impact, reproduction steps, and any known mitigations.
|
|
7
|
+
Maintainers will acknowledge the report and coordinate disclosure through that private thread.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as SummaryId, i as ContextVersion, l as InferenceId, m as SequenceNumber, n as CommandId, p as RunId, r as CompactionId, u as MessageId, v as ToolCallId, y as TurnId } from "./core-
|
|
1
|
+
import { _ as SummaryId, i as ContextVersion, l as InferenceId, m as SequenceNumber, n as CommandId, p as RunId, r as CompactionId, u as MessageId, v as ToolCallId, y as TurnId } from "./core-CYT6DBaS.js";
|
|
2
2
|
import { r as EDACommand, u as UserMessageContent } from "./commands-Ce1ec6kH.js";
|
|
3
3
|
import { n as EDARunTrace, t as EDAEventTrace } from "./tracing-BXHAkxkx.js";
|
|
4
4
|
import { B as SystemPromptText, P as FailurePayload, R as ProviderPartId, U as UsagePayload, V as ToolName } from "./events-Bb9-Cu-7.js";
|
|
5
|
-
import { r as AssistantMessageContent,
|
|
6
|
-
import { t as CommittedDurableEvent } from "./session-store-
|
|
5
|
+
import { r as AssistantMessageContent, rt as RecoveryContinuation } from "./durable-B7M6TD_0.js";
|
|
6
|
+
import { t as CommittedDurableEvent } from "./session-store-DZZUffUy.js";
|
|
7
7
|
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
8
8
|
|
|
9
9
|
//#region src/domain/reduced-state.d.ts
|
|
@@ -188,7 +188,8 @@ type MessageRecord = {
|
|
|
188
188
|
readonly messageId: MessageId;
|
|
189
189
|
readonly runId: RunId;
|
|
190
190
|
readonly turnId: TurnId;
|
|
191
|
-
readonly inferenceId: InferenceId;
|
|
191
|
+
readonly inferenceId: InferenceId; /** True when the assistant message originated outside this EDA session. */
|
|
192
|
+
readonly imported?: true;
|
|
192
193
|
readonly content: AssistantMessageContent;
|
|
193
194
|
readonly createdAtMs?: number;
|
|
194
195
|
readonly promptParts?: ReadonlyArray<Prompt.AssistantMessagePart>;
|
|
@@ -316,7 +317,7 @@ declare const initialReducedState: ReducedState;
|
|
|
316
317
|
/** Reserved reducer checkpoint name for the framework-owned `ReducedState`. */
|
|
317
318
|
declare const frameworkReducedStateReducerName = "_eda.framework.reduced-state";
|
|
318
319
|
/** Schema version for the framework-owned `ReducedState` checkpoint payload. */
|
|
319
|
-
declare const frameworkReducedStateReducerSchemaVersion =
|
|
320
|
+
declare const frameworkReducedStateReducerSchemaVersion = 5;
|
|
320
321
|
/** JSON payload stored for the framework-owned reduced-state reducer checkpoint. */
|
|
321
322
|
type ReducedStateCheckpointCommandRecord = Omit<CommandRecord, "command">;
|
|
322
323
|
type SystemMessageRecord = Extract<MessageRecord, {
|
|
@@ -465,4 +466,4 @@ declare const emptyCommandQueues: CommandQueues;
|
|
|
465
466
|
declare const deriveCommandQueues: (state: CommandQueueSource) => CommandQueues;
|
|
466
467
|
//#endregion
|
|
467
468
|
export { RunTerminal as A, activeTurnIdentityForCommand as B, ReducedStateCheckpointCommandRecord as C, ReducedStateCheckpointToolDecision as D, ReducedStateCheckpointToolCallRecord as E, ToolDecision as F, frameworkReducedStateReducerName as G, decodeReducedStateCheckpoint as H, ToolTerminal as I, pendingCommands as J, frameworkReducedStateReducerSchemaVersion as K, TurnRecord as L, TokenConsumptionState as M, TokenUsageTotals as N, ReducedStateCheckpointToolTerminal as O, ToolCallRecord as P, TurnTerminal as R, ReducedState as S, ReducedStateCheckpointPayload as T, encodeReducedStateCheckpoint as U, classifyRecoverableWork as V, foldReducedState as W, reduceCommittedEvents as X, pendingStopCommand as Y, reducedStateCheckpointEventSeqs as Z, LifecycleTiming as _, deriveCommandQueues as a, RecoverableWork as b, ActiveTurnIdentity as c, CompactionRecord as d, CompactionTerminal as f, LifecycleFailure as g, InferenceTerminal as h, PendingUserMessage as i, StopRequestRecord as j, RunRecord as k, CommandRecord as l, InferenceRecord as m, CommandQueues as n, emptyCommandQueues as o, ContextRecord as p, initialReducedState as q, PendingSteeringMessage as r, ActiveCommandEvidence as s, CommandQueueSource as t, CommandTerminal as u, MessageRecord as v, ReducedStateCheckpointMessageRecord as w, RecoveryContinuationRecord as x, PendingCommand as y, activeCommand as z };
|
|
468
|
-
//# sourceMappingURL=command-queues-
|
|
469
|
+
//# sourceMappingURL=command-queues-CV7O-51r.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { i as ContextProjection, n as CompactionPolicyId, t as CompactionExecutorId } from "./context-projection-n6Rdup0N.js";
|
|
2
|
+
import { o as EDASessionStoreError, r as DurableAppendEntry, t as CommittedDurableEvent } from "./session-store-DZZUffUy.js";
|
|
3
|
+
import { S as ReducedState } from "./command-queues-CV7O-51r.js";
|
|
4
|
+
import { t as IdGenerator } from "./id-generator-Ckl8_XWW.js";
|
|
5
|
+
import { t as EventFactory } from "./event-factory-CLJcyymV.js";
|
|
6
|
+
import { t as EDAKeepAlive } from "./keep-alive-Chl5SJxy.js";
|
|
5
7
|
import * as Context from "effect/Context";
|
|
6
8
|
import * as Effect from "effect/Effect";
|
|
7
9
|
import * as Layer from "effect/Layer";
|
|
@@ -137,8 +139,8 @@ interface CompactionRunnerShape {
|
|
|
137
139
|
declare const CompactionRunner_base: Context.ServiceClass<CompactionRunner, "@effect-durable-agent/CompactionRunner", CompactionRunnerShape>;
|
|
138
140
|
/** Framework-owned compaction lifecycle runner. */
|
|
139
141
|
declare class CompactionRunner extends CompactionRunner_base {
|
|
140
|
-
static readonly Live: Layer.Layer<CompactionRunner, never,
|
|
142
|
+
static readonly Live: Layer.Layer<CompactionRunner, never, EDAKeepAlive | IdGenerator | EventFactory | CompactionExecutor | CompactionPolicy>;
|
|
141
143
|
}
|
|
142
144
|
//#endregion
|
|
143
145
|
export { defaultCompactionRetainTailTokens as _, CompactionExecutorShape as a, CompactionPolicy as c, CompactionRunner as d, CompactionRunnerInput as f, defaultCompactionMinSummarizableTokens as g, defaultCompactionCharsPerToken as h, CompactionExecutorInput as i, CompactionPolicyInput as l, LanguageModelSummaryCompactionExecutorOptions as m, CompactionError as n, CompactionOutput as o, CompactionRunnerShape as p, CompactionExecutor as r, CompactionPlan as s, ApproximateTokenThresholdCompactionPolicyOptions as t, CompactionPolicyShape as u, defaultCompactionThresholdTokens as v };
|
|
144
|
-
//# sourceMappingURL=compaction-
|
|
146
|
+
//# sourceMappingURL=compaction-zbvLREI8.d.ts.map
|