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.
Files changed (136) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/README.md +131 -128
  3. package/SECURITY.md +3 -4
  4. package/dist/{command-queues-CQ9cwRP7.d.ts → command-queues-CV7O-51r.d.ts} +7 -6
  5. package/dist/{compaction-YayFKo_1.d.ts → compaction-zbvLREI8.d.ts} +8 -6
  6. package/dist/context-projection-n6Rdup0N.d.ts +140 -0
  7. package/dist/{core-Hv3cFydL.d.ts → core-CYT6DBaS.d.ts} +2 -2
  8. package/dist/domain/command-queues.d.ts +1 -1
  9. package/dist/domain/context-projection.d.ts +2 -0
  10. package/dist/domain/context-projection.js +32 -0
  11. package/dist/domain/context-projection.js.map +1 -0
  12. package/dist/domain/message-transcript.d.ts +1 -1
  13. package/dist/domain/reduced-state-schema.d.ts +2 -0
  14. package/dist/domain/reduced-state-schema.js +2 -1
  15. package/dist/domain/reduced-state-schema.js.map +1 -1
  16. package/dist/domain/reduced-state.d.ts +1 -1
  17. package/dist/domain/reduced-state.js +1 -1
  18. package/dist/{durable-DlScwmCy.d.ts → durable-B7M6TD_0.d.ts} +341 -2
  19. package/dist/{durable-C3Rz7kg3.js → durable-DsV9PxZC.js} +13 -2
  20. package/dist/durable-DsV9PxZC.js.map +1 -0
  21. package/dist/{keep-alive-DYDsH6qN.d.ts → event-factory-CLJcyymV.d.ts} +5 -29
  22. package/dist/{keep-alive-p8dIcSVy.js → event-factory-tcpLgdMN.js} +3 -10
  23. package/dist/event-factory-tcpLgdMN.js.map +1 -0
  24. package/dist/host/websocket-protocol.d.ts +229 -0
  25. package/dist/host/websocket-protocol.js +99 -0
  26. package/dist/host/websocket-protocol.js.map +1 -0
  27. package/dist/host/websocket-wire.d.ts +2 -2
  28. package/dist/host/websocket-wire.js +37 -20
  29. package/dist/host/websocket-wire.js.map +1 -1
  30. package/dist/{id-generator-C2Q15uZM.d.ts → id-generator-Ckl8_XWW.d.ts} +2 -2
  31. package/dist/index.d.ts +4 -4
  32. package/dist/index.js +2 -2
  33. package/dist/keep-alive-Chl5SJxy.d.ts +29 -0
  34. package/dist/{message-transcript-BCHdHAe2.d.ts → message-transcript-DiOPBY3l.d.ts} +3 -3
  35. package/dist/{prompt-projector-9_02lk5-.d.ts → prompt-projector-C1IbkHr0.d.ts} +15 -16
  36. package/dist/{reduced-state-C4nVVzz9.js → reduced-state-TMi7ISla.js} +20 -4
  37. package/dist/reduced-state-TMi7ISla.js.map +1 -0
  38. package/dist/{reducer-registry-C0svUa63.d.ts → reducer-registry-CjSJBPKo.d.ts} +2 -2
  39. package/dist/{runtime-C56FQxiL.d.ts → runtime-DOgmAKsO.d.ts} +7 -6
  40. package/dist/services/compaction.d.ts +1 -1
  41. package/dist/services/compaction.js +4 -3
  42. package/dist/services/compaction.js.map +1 -1
  43. package/dist/services/id-generator.d.ts +1 -1
  44. package/dist/services/keep-alive.d.ts +2 -0
  45. package/dist/services/keep-alive.js +13 -0
  46. package/dist/services/keep-alive.js.map +1 -0
  47. package/dist/services/prompt-projector.d.ts +2 -2
  48. package/dist/services/prompt-projector.js +20 -10
  49. package/dist/services/prompt-projector.js.map +1 -1
  50. package/dist/services/reducer-registry.d.ts +1 -1
  51. package/dist/services/runtime-layer.d.ts +58 -0
  52. package/dist/services/runtime-layer.js +42 -0
  53. package/dist/services/runtime-layer.js.map +1 -0
  54. package/dist/services/runtime.d.ts +1 -1
  55. package/dist/services/runtime.js +4 -3
  56. package/dist/services/runtime.js.map +1 -1
  57. package/dist/services/session-query.d.ts +1 -1
  58. package/dist/services/session-query.js +76 -1
  59. package/dist/services/session-query.js.map +1 -0
  60. package/dist/services/session-state.d.ts +2 -0
  61. package/dist/services/session-state.js +2 -0
  62. package/dist/services/session-store.d.ts +2 -2
  63. package/dist/services/session-store.js +181 -2
  64. package/dist/services/session-store.js.map +1 -0
  65. package/dist/services/sink-checkpoint-store.d.ts +2 -0
  66. package/dist/services/sink-checkpoint-store.js +49 -0
  67. package/dist/services/sink-checkpoint-store.js.map +1 -0
  68. package/dist/services/sink-registry.d.ts +1 -1
  69. package/dist/services/sink-registry.js +1 -1
  70. package/dist/services/tool-registry.d.ts +1 -1
  71. package/dist/services/websocket-subscriber.d.ts +54 -0
  72. package/dist/services/websocket-subscriber.js +190 -0
  73. package/dist/services/websocket-subscriber.js.map +1 -0
  74. package/dist/session-query-C-C4m1eq.d.ts +38 -0
  75. package/dist/{session-query-DlRo5Ufc.d.ts → session-state-CjOSvWbe.d.ts} +132 -40
  76. package/dist/{session-query-DOc1KanA.js → session-state-SStf0KUo.js} +43 -146
  77. package/dist/session-state-SStf0KUo.js.map +1 -0
  78. package/dist/{session-store-D2Ore1QC.d.ts → session-store-DZZUffUy.d.ts} +5 -94
  79. package/dist/sink-checkpoint-store-BZmQFTRE.d.ts +40 -0
  80. package/dist/{sink-registry-CIU0LD3m.d.ts → sink-registry-Cf79ICdW.d.ts} +11 -40
  81. package/dist/{sink-registry-CFC6xjsN.js → sink-registry-D13eUO_c.js} +9 -47
  82. package/dist/sink-registry-D13eUO_c.js.map +1 -0
  83. package/dist/testkit/layers.d.ts +14 -11
  84. package/dist/testkit/layers.js +8 -5
  85. package/dist/testkit/layers.js.map +1 -1
  86. package/dist/{tool-registry-CcnkAAQK.d.ts → tool-registry-B7Wona6N.d.ts} +3 -3
  87. package/dist/types/core.d.ts +1 -1
  88. package/dist/types/core.js +1 -1
  89. package/dist/types/core.js.map +1 -1
  90. package/dist/types/events/durable.d.ts +2 -2
  91. package/dist/types/events/durable.js +2 -2
  92. package/dist/types/events.d.ts +2 -2
  93. package/dist/types/events.js +2 -2
  94. package/dist/websocket-wire-QD2SquQE.d.ts +2244 -0
  95. package/docs/assets/architecture.svg +170 -60
  96. package/docs/assets/event-sequence.svg +68 -78
  97. package/docs/assets/hero.svg +33 -0
  98. package/docs/message-steering.md +1 -1
  99. package/docs/releasing.md +96 -39
  100. package/docs/spec.md +15 -12
  101. package/docs/websocket-protocol.md +35 -9
  102. package/package.json +55 -35
  103. package/dist/durable-C3Rz7kg3.js.map +0 -1
  104. package/dist/durable-object-runtime-B7jwBY2R.js +0 -1494
  105. package/dist/durable-object-runtime-B7jwBY2R.js.map +0 -1
  106. package/dist/durable-object-runtime-pWv0ohlz.d.ts +0 -257
  107. package/dist/durable-object-storage-Czy7IPrh.d.ts +0 -41
  108. package/dist/host/durable-object-runtime.d.ts +0 -2
  109. package/dist/host/durable-object-runtime.js +0 -2
  110. package/dist/host/durable-object-storage.d.ts +0 -2
  111. package/dist/host/durable-object-storage.js +0 -0
  112. package/dist/host/durable-object.d.ts +0 -83
  113. package/dist/host/durable-object.js +0 -191
  114. package/dist/host/durable-object.js.map +0 -1
  115. package/dist/keep-alive-p8dIcSVy.js.map +0 -1
  116. package/dist/reduced-state-C4nVVzz9.js.map +0 -1
  117. package/dist/session-query-DOc1KanA.js.map +0 -1
  118. package/dist/session-store-pYxQW9qh.js +0 -214
  119. package/dist/session-store-pYxQW9qh.js.map +0 -1
  120. package/dist/sink-registry-CFC6xjsN.js.map +0 -1
  121. package/dist/websocket-wire-DvOu_6BJ.d.ts +0 -16773
  122. package/examples/001-no-tools/README.md +0 -65
  123. package/examples/001-no-tools/worker.ts +0 -79
  124. package/examples/002-slack-bridge/README.md +0 -134
  125. package/examples/002-slack-bridge/events.ts +0 -115
  126. package/examples/002-slack-bridge/reducer.ts +0 -216
  127. package/examples/002-slack-bridge/scenario.test.ts +0 -223
  128. package/examples/002-slack-bridge/sinks.ts +0 -109
  129. package/examples/002-slack-bridge/worker.ts +0 -140
  130. package/examples/003-sandbox-lifecycle/README.md +0 -78
  131. package/examples/003-sandbox-lifecycle/events.ts +0 -203
  132. package/examples/003-sandbox-lifecycle/reducer.ts +0 -305
  133. package/examples/003-sandbox-lifecycle/scenario.test.ts +0 -202
  134. package/examples/_shared/event-id.ts +0 -12
  135. package/examples/_shared/http.ts +0 -27
  136. 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
- - Prepare the first public prerelease as `effect-durable-agent`
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
- > EDA is a Redux-inspired durable state-management layer for agentic applications, hosted on
4
- [Cloudflare Durable Objects](https://developers.cloudflare.com/durable-objects/).
3
+ ![EDA is a redux-inspired durable state management layer for agentic applications](./docs/assets/hero.svg)
4
+
5
+ [![npm version](https://img.shields.io/npm/v/effect-durable-agent)](https://www.npmjs.com/package/effect-durable-agent)
6
+ [![CI](https://github.com/advait/effect-durable-agent/actions/workflows/ci.yml/badge.svg)](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
- Your application describes how events like `SandboxStarted` and `ApprovalRequested` change its
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
- For example, a coding-agent session might record:
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
- ![An ordered EDA session history. Blue events belong to the EDA framework; orange events belong to the application.](./docs/assets/event-sequence.svg)
24
+ ![An ordered EDA session history where framework and application events share one sequence.](./docs/assets/event-sequence.svg)
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
- ## What this unlocks
39
+ Those events flow through the rest of the system as follows:
42
40
 
43
- ### Live state on every client
41
+ ![A numbered guide to EDA architecture: 1, commands enter the session runtime; 2, durable transitions form an ordered event log; 3, clients follow the live event stream; 4, pure reducers derive state; 5, state captures agent and product lifecycles; 6, pure UI and LLM context projections shape state for different consumers; 7, durable sinks deliver events to external systems.](./docs/assets/architecture.svg)
44
42
 
45
- EDA exposes serialized reducer snapshots and streams the ordered session history over a
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
- Every tab, embedded surface, or admin view follows the same durable session. Slow and disconnected
59
- clients catch up from their last acknowledged sequence instead of guessing which updates they
60
- missed.
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
- ### Durable side effects
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
- EDA makes side effects durable.
52
+ ### 2. Ordered event log: the definitive history of the state machine
65
53
 
66
- If `AssistantMessageCommitted` should post a result to Slack and Slack is temporarily unavailable,
67
- EDA retains the event and retries the delivery instead of losing it inside a failed callback.
68
- Durable sinks run independently of the main agent loop, preserve event order, and converge
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
- Delivery is at-least-once, so external operations still need stable idempotency keys. The important
73
- guarantee is that a transient process or network failure does not silently erase the work.
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
- See the [Slack bridge example](./examples/002-slack-bridge) for idempotent ingress, a custom reducer,
76
- and durable outbound delivery.
61
+ ### 3. Live event stream: reconnect without losing the session
77
62
 
78
- **Durable state. Durable side effects.**
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
- ### Agents survive deploys and failures
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
- Deploys and failures restart the application—not the session.
69
+ ### 4. Pure reducers: events become state
83
70
 
84
- EDA rebuilds framework and product state from durable history, repairs incomplete lifecycle
85
- boundaries, and transparently continues eligible in-progress work in a replacement run. Completed
86
- tool calls are not blindly repeated, queued commands remain durable, and reconnecting clients see
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
- ### Production sessions become UI fixtures
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
- Because application state is a pure projection of durable events, a production event sequence can
92
- become a test fixture.
78
+ ### 5. State: a cached view of durable history
93
79
 
94
- Replay it one event at a time through the same reducers, stop at any sequence, and assert exactly
95
- what the UI should show: the running tool card, the active sandbox, the pending approval, the
96
- completed delivery, or the recovered run. A difficult production session becomes a reproducible UI
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 package includes pure reducer tests, generated state-machine properties, canned-model journeys,
100
- crash-prefix simulations, and an [offline trace harness](./testing/offline-trace) that writes
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
- ### Tracing for every agent run
87
+ ### 6. Pure projections: UI state is not model context
104
88
 
105
- See what happened, in what order, and where the time went.
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
- EDA uses Effect spans across meaningful runtime boundaries, including command admission, runs,
108
- turns, model inference, tools, event streaming, durable sinks, and recovery. Trace context survives
109
- the durable boundaries that separate ingress, execution, and side effects, and Effect telemetry can
110
- be exported through OpenTelemetry to Google Cloud Trace or another existing backend.
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
- ![Google Cloud Trace view of an EDA session, showing agent turns, model inference, tool calls, sandbox execution, and an external integration in one timeline.](./docs/assets/gcp-trace.png)
97
+ ### 7. Durable sinks: callbacks that survive failure
113
98
 
114
- ### Built for Cloudflare Durable Objects
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's first host maps one session to one
117
- [Cloudflare Durable Object](https://developers.cloudflare.com/durable-objects/). The object is the
118
- durable coordinator for that session's state, execution, SQLite event log, live WebSockets, alarms,
119
- and sink cursors.
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
- This is an unusually natural fit:
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
- - Deterministic routing sends every request for a session to the same logical object
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
- Durable Objects are the first host, not the whole architecture. EDA's runtime depends on small
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
- ## Core concepts
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
- ![EDA architecture. Commands and application events enter a session runtime and durable event log, which feed reducers, reconnecting clients, durable sinks, recovery, replay, tests, and model context.](./docs/assets/architecture.svg)
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
- Effect owns the execution around this state machine: structured concurrency, streams, interruption,
137
- scoped resources, typed failures, retries, services, and tracing. The event history owns durable
138
- truth.
123
+ ### Durable side effects
139
124
 
140
- ### Durable and ephemeral events
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
- EDA's ordered event stream carries two types of events:
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
- - **Durable events** are persisted facts with a monotonically increasing per-session `seq`. They
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
- A durable event is published live only after storage commits it.
135
+ ### Agents survive deploys and failures
150
136
 
151
- ### Pure reducers
137
+ Deploys and failures restart the application—not the session.
152
138
 
153
- Reducers turn durable events into current state. EDA's framework reducer derives commands, runs,
154
- turns, messages, inference, and tool state. Applications register their own reducers for product
155
- state such as sandboxes, approvals, billing, or external delivery.
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
- Framework and application reducers fold the same ordered history. Their checkpoints accelerate
158
- startup and snapshots; the event log remains the source of truth.
144
+ ### Production sessions become UI fixtures
159
145
 
160
- ### Live event stream
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
- Clients begin with a reducer snapshot through sequence `N`, replay durable events after `N`, and
163
- then follow new durable and ephemeral events live. Sequence-based catch-up lets every connected
164
- view converge without coupling a slow client to agent execution.
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
- ### Durable sinks
155
+ ### Tracing for every agent run
167
156
 
168
- Durable sinks process committed events outside the main agent loop. Each sink preserves event
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
- ### Session runtime
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
- One session has at most one active run and turn. The runtime:
164
+ ![Google Cloud Trace view of an EDA session, showing agent turns, model inference, tool calls, sandbox execution, and an external integration in one timeline.](./docs/assets/gcp-trace.png)
165
+
166
+ ## Host-neutral core, pluggable deployment
175
167
 
176
- 1. Durably admits a command
177
- 2. Starts and traces the run, turn, and inference
178
- 3. Commits message and tool lifecycle facts
179
- 4. Folds framework and application reducers
180
- 5. Publishes positioned events to live clients
181
- 6. Drains durable sinks
182
- 7. Recovers from the durable history after a restart
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 EDA from npm:
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/host/durable-object"
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 Object host with one session per object and SQLite event storage
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
- After the standalone repository is public, use GitHub's private vulnerability reporting for
6
- `advait/effect-durable-agent`. Include the affected version, impact, reproduction steps, and any
7
- known mitigations. Maintainers will acknowledge the report and coordinate disclosure through that
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-Hv3cFydL.js";
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, tt as RecoveryContinuation } from "./durable-DlScwmCy.js";
6
- import { t as CommittedDurableEvent } from "./session-store-D2Ore1QC.js";
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 = 4;
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-CQ9cwRP7.d.ts.map
469
+ //# sourceMappingURL=command-queues-CV7O-51r.d.ts.map
@@ -1,7 +1,9 @@
1
- import { f as CompactionExecutorId, m as ContextProjection, o as EDASessionStoreError, p as CompactionPolicyId, r as DurableAppendEntry, t as CommittedDurableEvent } from "./session-store-D2Ore1QC.js";
2
- import { S as ReducedState } from "./command-queues-CQ9cwRP7.js";
3
- import { t as IdGenerator } from "./id-generator-C2Q15uZM.js";
4
- import { n as EventFactory, t as EDAKeepAlive } from "./keep-alive-DYDsH6qN.js";
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, IdGenerator | CompactionPolicy | CompactionExecutor | EventFactory | EDAKeepAlive>;
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-YayFKo_1.d.ts.map
146
+ //# sourceMappingURL=compaction-zbvLREI8.d.ts.map