effect-durable-agent 0.1.0-alpha.4 → 0.1.0-alpha.5

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 (77) hide show
  1. package/README.md +19 -18
  2. package/dist/{command-queues-CV7O-51r.d.ts → command-queues-Dwdf41mq.d.ts} +2 -2
  3. package/dist/{compaction-zbvLREI8.d.ts → compaction-DpHOf-g7.d.ts} +5 -5
  4. package/dist/{context-projection-n6Rdup0N.d.ts → context-projection-B4DWOZgi.d.ts} +3 -3
  5. package/dist/domain/command-queues.d.ts +1 -1
  6. package/dist/domain/context-projection.d.ts +1 -1
  7. package/dist/domain/message-transcript.d.ts +1 -1
  8. package/dist/domain/reduced-state.d.ts +1 -1
  9. package/dist/host/websocket-protocol.d.ts +26 -3
  10. package/dist/host/websocket-protocol.js +16 -4
  11. package/dist/host/websocket-protocol.js.map +1 -1
  12. package/dist/host/websocket-wire.d.ts +2 -2
  13. package/dist/host/websocket-wire.js +19 -2
  14. package/dist/host/websocket-wire.js.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/{message-transcript-DiOPBY3l.d.ts → message-transcript-CFn_D3MH.d.ts} +3 -3
  17. package/dist/{prompt-projector-C1IbkHr0.d.ts → prompt-projector-C2meuNrV.d.ts} +4 -4
  18. package/dist/{reducer-registry-CjSJBPKo.d.ts → reducer-registry-K9FqZq5-.d.ts} +2 -2
  19. package/dist/{runtime-DOgmAKsO.d.ts → runtime-5NEJngu3.d.ts} +10 -5
  20. package/dist/services/compaction.d.ts +1 -1
  21. package/dist/services/prompt-projector.d.ts +1 -1
  22. package/dist/services/reducer-registry.d.ts +1 -1
  23. package/dist/services/runtime-layer.d.ts +9 -9
  24. package/dist/services/runtime-layer.js +2 -2
  25. package/dist/services/runtime.d.ts +1 -1
  26. package/dist/services/runtime.js +6 -2
  27. package/dist/services/runtime.js.map +1 -1
  28. package/dist/services/session-query.d.ts +2 -2
  29. package/dist/services/session-query.js +20 -3
  30. package/dist/services/session-query.js.map +1 -1
  31. package/dist/services/session-state.d.ts +1 -1
  32. package/dist/services/session-state.js +1 -1
  33. package/dist/services/session-store.d.ts +1 -1
  34. package/dist/services/session-store.js +1 -1
  35. package/dist/services/sink-checkpoint-store.d.ts +1 -1
  36. package/dist/services/sink-registry.d.ts +1 -1
  37. package/dist/services/sink-registry.js +1 -1
  38. package/dist/services/span-names.d.ts +1 -1
  39. package/dist/services/span-names.js +1 -0
  40. package/dist/services/span-names.js.map +1 -1
  41. package/dist/services/tool-registry.d.ts +1 -1
  42. package/dist/services/websocket-delivery.d.ts +90 -0
  43. package/dist/services/websocket-delivery.js +221 -0
  44. package/dist/services/websocket-delivery.js.map +1 -0
  45. package/dist/{session-query-C-C4m1eq.d.ts → session-query-5oyZRaQL.d.ts} +16 -9
  46. package/dist/{session-state-CjOSvWbe.d.ts → session-state-CI1xeT6f.d.ts} +11 -11
  47. package/dist/{session-state-SStf0KUo.js → session-state-D7dqko7r.js} +3 -3
  48. package/dist/{session-state-SStf0KUo.js.map → session-state-D7dqko7r.js.map} +1 -1
  49. package/dist/{session-store-DZZUffUy.d.ts → session-store-BLg6UvZa.d.ts} +2 -2
  50. package/dist/{sink-checkpoint-store-BZmQFTRE.d.ts → sink-checkpoint-store-B9WNvDtY.d.ts} +2 -2
  51. package/dist/{sink-registry-D13eUO_c.js → sink-registry-BbmoI9uv.js} +17 -24
  52. package/dist/sink-registry-BbmoI9uv.js.map +1 -0
  53. package/dist/{sink-registry-Cf79ICdW.d.ts → sink-registry-CO3YPS1p.d.ts} +26 -14
  54. package/dist/testkit/layers.d.ts +10 -10
  55. package/dist/testkit/layers.js +3 -3
  56. package/dist/{tool-registry-B7Wona6N.d.ts → tool-registry-B8H1P6Pu.d.ts} +2 -2
  57. package/dist/{websocket-wire-QD2SquQE.d.ts → websocket-wire-DPxwY4G5.d.ts} +39 -10
  58. package/package.json +11 -23
  59. package/testing/offline-trace/README.md +2 -1
  60. package/CHANGELOG.md +0 -34
  61. package/CONTRIBUTING.md +0 -26
  62. package/SECURITY.md +0 -7
  63. package/dist/services/websocket-subscriber.d.ts +0 -54
  64. package/dist/services/websocket-subscriber.js +0 -190
  65. package/dist/services/websocket-subscriber.js.map +0 -1
  66. package/dist/sink-registry-D13eUO_c.js.map +0 -1
  67. package/docs/assets/architecture.svg +0 -216
  68. package/docs/assets/event-sequence.svg +0 -133
  69. package/docs/assets/gcp-trace.png +0 -0
  70. package/docs/assets/hero.svg +0 -33
  71. package/docs/message-steering.md +0 -831
  72. package/docs/releasing.md +0 -114
  73. package/docs/spec.md +0 -777
  74. package/docs/subagents.md +0 -725
  75. package/docs/testing.md +0 -64
  76. package/docs/ui-projection.md +0 -742
  77. package/docs/websocket-protocol.md +0 -639
@@ -0,0 +1,221 @@
1
+ import { SequenceNumber } from "../types/core.js";
2
+ import { EDAWebSocketErrorFrame, EDAWebSocketEventsFrame, EDAWebSocketHelloFrame, EDAWebSocketLaggedFrame, EDA_WEB_SOCKET_PROTOCOL_VERSION, EDA_WS_CLOSE_LAGGED, EDA_WS_CLOSE_PROTOCOL_ERROR, FrameId, laggedCloseReason } from "../host/websocket-protocol.js";
3
+ import * as Schema from "effect/Schema";
4
+ //#region src/services/websocket-delivery.ts
5
+ /** Slow subscriber reasons that intentionally close only the lagging socket. */
6
+ const SubscriberLagReason = Schema.Literals(["buffer-overflow", "ack-timeout"]);
7
+ /** Build the delivery state for a new connection or a post-eviction restore. */
8
+ const makeWebSocketDeliveryState = (input) => ({
9
+ subscriberId: input.subscriberId,
10
+ policy: input.policy,
11
+ coldRestored: input.coldRestored ?? false,
12
+ lastAckedSeq: input.resumeSeq,
13
+ lastAckedFrameId: 0,
14
+ lastSentFrameId: 0,
15
+ nextFrameId: 1,
16
+ sentDurableThroughSeq: input.resumeSeq,
17
+ inFlight: [],
18
+ pendingEphemeral: []
19
+ });
20
+ /** First frame for a freshly accepted connection. Cold restores never re-send hello. */
21
+ const deliveryHelloFrame = (state) => EDAWebSocketHelloFrame.make({
22
+ _tag: "hello",
23
+ protocolVersion: EDA_WEB_SOCKET_PROTOCOL_VERSION,
24
+ subscriberId: state.subscriberId,
25
+ resumeSeq: state.lastAckedSeq,
26
+ flowControl: state.policy
27
+ });
28
+ /**
29
+ * Deliver committed durable events read from the store.
30
+ *
31
+ * The store is the only buffer for durable events: frames are emitted while
32
+ * the ACK window has room and the remainder is requested again via
33
+ * `wantsCatchUpAfterSeq` once ACKs reopen the window.
34
+ */
35
+ const onDurableEvents = (state, events, head, nowMs) => {
36
+ const stale = staleAckResult(state, nowMs);
37
+ if (stale !== void 0) return stale;
38
+ let next = state;
39
+ const frames = [];
40
+ let batch = [];
41
+ const flushBatch = () => {
42
+ if (batch.length === 0) return;
43
+ const sent = sendEventsFrame(next, batch, nowMs);
44
+ if (sent.close !== void 0) return {
45
+ ...sent,
46
+ frames: [...frames, ...sent.frames]
47
+ };
48
+ next = sent.state;
49
+ frames.push(...sent.frames);
50
+ batch = [];
51
+ };
52
+ for (const event of events) {
53
+ if (event.event.durability === "durable" && event.position.seq <= next.sentDurableThroughSeq) continue;
54
+ if (batch.length === 0 && windowCapacity(next) <= 0) break;
55
+ batch.push(event);
56
+ if (batch.length >= next.policy.maxFrameEvents) {
57
+ const closed = flushBatch();
58
+ if (closed !== void 0) return closed;
59
+ }
60
+ }
61
+ const closed = flushBatch();
62
+ if (closed !== void 0) return closed;
63
+ return {
64
+ state: next,
65
+ frames,
66
+ ...windowCapacity(next) > 0 && next.sentDurableThroughSeq < head ? { wantsCatchUpAfterSeq: next.sentDurableThroughSeq } : {}
67
+ };
68
+ };
69
+ /**
70
+ * Deliver one live ephemeral event.
71
+ *
72
+ * Ephemeral events have no durable backing, so a bounded in-memory buffer
73
+ * holds them while the ACK window is full; overflow lag-closes only this
74
+ * subscriber, mirroring the previous streaming behavior.
75
+ */
76
+ const onEphemeralEvent = (state, event, nowMs) => {
77
+ const stale = staleAckResult(state, nowMs);
78
+ if (stale !== void 0) return stale;
79
+ if (windowCapacity(state) > 0 && state.pendingEphemeral.length === 0) return sendEventsFrame(state, [event], nowMs);
80
+ const pendingEphemeral = [...state.pendingEphemeral, event];
81
+ if (pendingEphemeral.length > state.policy.subscriberBufferCapacityEvents) return laggedResult(state, "buffer-overflow");
82
+ return {
83
+ state: {
84
+ ...state,
85
+ pendingEphemeral
86
+ },
87
+ frames: []
88
+ };
89
+ };
90
+ /** Apply one client ACK, reopen the window, and drain buffered ephemeral events. */
91
+ const onClientAck = (state, ack, nowMs) => {
92
+ const validated = state.coldRestored ? applyColdAck(state, ack) : applyWarmAck(state, ack);
93
+ if (validated._tag === "close") return validated.result;
94
+ if (validated._tag === "ignore") return {
95
+ state,
96
+ frames: []
97
+ };
98
+ let next = validated.state;
99
+ const frames = [];
100
+ while (next.pendingEphemeral.length > 0 && windowCapacity(next) > 0) {
101
+ const [head, ...rest] = next.pendingEphemeral;
102
+ const sent = sendEventsFrame({
103
+ ...next,
104
+ pendingEphemeral: rest
105
+ }, [head], nowMs);
106
+ if (sent.close !== void 0) return {
107
+ ...sent,
108
+ frames: [...frames, ...sent.frames],
109
+ persistSeq: validated.persistSeq
110
+ };
111
+ next = sent.state;
112
+ frames.push(...sent.frames);
113
+ }
114
+ const stale = staleAckResult(next, nowMs);
115
+ if (stale !== void 0) return {
116
+ ...stale,
117
+ frames: [...frames, ...stale.frames],
118
+ persistSeq: validated.persistSeq
119
+ };
120
+ return {
121
+ state: next,
122
+ frames,
123
+ persistSeq: validated.persistSeq,
124
+ ...windowCapacity(next) > 0 && next.pendingEphemeral.length === 0 ? { wantsCatchUpAfterSeq: next.sentDurableThroughSeq } : {}
125
+ };
126
+ };
127
+ const applyWarmAck = (state, ack) => {
128
+ if (ack.frameId <= state.lastAckedFrameId) return ack.durableThroughSeq > state.lastAckedSeq ? protocolClose(state, "Duplicate ACK attempted to advance durable seq") : { _tag: "ignore" };
129
+ if (ack.frameId > state.lastSentFrameId) return protocolClose(state, "ACK referenced an unsent frame");
130
+ if (ack.durableThroughSeq < state.lastAckedSeq) return protocolClose(state, "ACK durable seq moved backwards");
131
+ const acknowledged = state.inFlight.filter((frame) => frame.frameId <= ack.frameId);
132
+ if (acknowledged.length === 0) return protocolClose(state, "ACK referenced no in-flight frames");
133
+ const allowedDurableSeq = SequenceNumber.make(acknowledged.reduce((max, frame) => Math.max(max, frame.durableThroughSeq), state.lastAckedSeq));
134
+ if (ack.durableThroughSeq > allowedDurableSeq) return protocolClose(state, "ACK durable seq exceeded sent frame boundary");
135
+ return {
136
+ _tag: "apply",
137
+ persistSeq: ack.durableThroughSeq,
138
+ state: {
139
+ ...state,
140
+ inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),
141
+ lastAckedFrameId: ack.frameId,
142
+ lastAckedSeq: ack.durableThroughSeq
143
+ }
144
+ };
145
+ };
146
+ const applyColdAck = (state, ack) => {
147
+ if (ack.durableThroughSeq < state.lastAckedSeq) return { _tag: "ignore" };
148
+ const lastAckedSeq = SequenceNumber.make(Math.max(state.lastAckedSeq, ack.durableThroughSeq));
149
+ return {
150
+ _tag: "apply",
151
+ persistSeq: lastAckedSeq,
152
+ state: {
153
+ ...state,
154
+ inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),
155
+ lastAckedFrameId: Math.max(state.lastAckedFrameId, ack.frameId),
156
+ lastAckedSeq,
157
+ sentDurableThroughSeq: SequenceNumber.make(Math.max(state.sentDurableThroughSeq, lastAckedSeq))
158
+ }
159
+ };
160
+ };
161
+ const windowCapacity = (state) => state.policy.maxInFlightFrames - state.inFlight.length;
162
+ const sendEventsFrame = (state, events, nowMs) => {
163
+ const frameId = FrameId.make(state.nextFrameId);
164
+ const durableThroughSeq = SequenceNumber.make(events.reduce((max, event) => event.event.durability === "durable" ? Math.max(max, event.position.seq) : max, state.sentDurableThroughSeq));
165
+ const frame = EDAWebSocketEventsFrame.make({
166
+ _tag: "events",
167
+ frameId,
168
+ events,
169
+ durableThroughSeq
170
+ });
171
+ const encodedBytes = new TextEncoder().encode(JSON.stringify(frame)).byteLength;
172
+ if (encodedBytes > state.policy.maxFrameBytes) return protocolClose(state, `Encoded WebSocket frame exceeded maxFrameBytes (${encodedBytes} > ${state.policy.maxFrameBytes})`).result;
173
+ return {
174
+ state: {
175
+ ...state,
176
+ inFlight: [...state.inFlight, {
177
+ frameId,
178
+ durableThroughSeq,
179
+ sentAtMs: nowMs
180
+ }],
181
+ lastSentFrameId: frameId,
182
+ nextFrameId: frameId + 1,
183
+ sentDurableThroughSeq: durableThroughSeq
184
+ },
185
+ frames: [frame]
186
+ };
187
+ };
188
+ /** Lazily enforce the ACK deadline: no resident timer, checked on each transition. */
189
+ const staleAckResult = (state, nowMs) => {
190
+ return state.inFlight.some((frame) => frame.sentAtMs + state.policy.ackTimeoutMs <= nowMs) ? laggedResult(state, "ack-timeout") : void 0;
191
+ };
192
+ const laggedResult = (state, reason) => ({
193
+ state,
194
+ frames: [EDAWebSocketLaggedFrame.make({
195
+ _tag: "lagged",
196
+ resumeSeq: state.lastAckedSeq,
197
+ reason
198
+ })],
199
+ close: {
200
+ code: EDA_WS_CLOSE_LAGGED,
201
+ reason: laggedCloseReason(state.lastAckedSeq)
202
+ }
203
+ });
204
+ const protocolClose = (state, message) => ({
205
+ _tag: "close",
206
+ result: {
207
+ state,
208
+ frames: [EDAWebSocketErrorFrame.make({
209
+ _tag: "error",
210
+ message: message.slice(0, 120)
211
+ })],
212
+ close: {
213
+ code: EDA_WS_CLOSE_PROTOCOL_ERROR,
214
+ reason: "protocol"
215
+ }
216
+ }
217
+ });
218
+ //#endregion
219
+ export { SubscriberLagReason, deliveryHelloFrame, makeWebSocketDeliveryState, onClientAck, onDurableEvents, onEphemeralEvent };
220
+
221
+ //# sourceMappingURL=websocket-delivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket-delivery.js","names":[],"sources":["../../src/services/websocket-delivery.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { SequenceNumber } from \"../types/core\";\nimport type { PositionedEvent } from \"../types/events\";\nimport {\n EDA_WEB_SOCKET_PROTOCOL_VERSION,\n EDA_WS_CLOSE_LAGGED,\n EDA_WS_CLOSE_PROTOCOL_ERROR,\n EDAWebSocketEventsFrame,\n EDAWebSocketErrorFrame,\n EDAWebSocketHelloFrame,\n EDAWebSocketLaggedFrame,\n FrameId,\n SubscriberId,\n laggedCloseReason,\n type EDAWebSocketAckFrame,\n type EDAWebSocketFlowControl,\n type EDAWebSocketServerFrame,\n} from \"../host/websocket-protocol\";\n\n/** Slow subscriber reasons that intentionally close only the lagging socket. */\nexport const SubscriberLagReason = Schema.Literals([\"buffer-overflow\", \"ack-timeout\"]);\nexport type SubscriberLagReason = typeof SubscriberLagReason.Type;\n\n/** One sent-but-unacknowledged events frame. */\nexport interface InFlightFrame {\n readonly frameId: FrameId;\n readonly durableThroughSeq: SequenceNumber;\n readonly sentAtMs: number;\n}\n\n/**\n * In-memory delivery state for one accepted event WebSocket.\n *\n * This state is deliberately disposable: hibernation-capable hosts persist\n * only the acknowledged durable cursor in the socket attachment and rebuild\n * a cold state after isolate eviction. Nothing here owns a fiber, a timer,\n * or a stream; all progress is driven by explicit host calls.\n */\nexport interface EDAWebSocketDeliveryState {\n readonly subscriberId: SubscriberId;\n readonly policy: EDAWebSocketFlowControl;\n /**\n * True when this state was rebuilt from a persisted attachment after the\n * in-memory frame bookkeeping was lost. Frame-id validation is relaxed for\n * the remainder of the connection because pre-eviction frame ids are\n * unknowable; durable cursors stay strictly monotonic either way.\n */\n readonly coldRestored: boolean;\n readonly lastAckedSeq: SequenceNumber;\n readonly lastAckedFrameId: number;\n readonly lastSentFrameId: number;\n readonly nextFrameId: number;\n readonly sentDurableThroughSeq: SequenceNumber;\n readonly inFlight: ReadonlyArray<InFlightFrame>;\n readonly pendingEphemeral: ReadonlyArray<PositionedEvent>;\n}\n\n/** Close instruction for the host WebSocket boundary. */\nexport interface DeliveryClose {\n readonly code: number;\n readonly reason: string;\n}\n\n/** Result of one pure delivery transition. */\nexport interface EDAWebSocketDeliveryResult {\n readonly state: EDAWebSocketDeliveryState;\n /** Frames to send in order, including any final lagged/error frame before `close`. */\n readonly frames: ReadonlyArray<EDAWebSocketServerFrame>;\n /** When set, persist this acknowledged durable cursor to the socket attachment. */\n readonly persistSeq?: SequenceNumber;\n /** When set, send `frames` then close the socket and drop its state. */\n readonly close?: DeliveryClose;\n /** When set, the host should read a durable slice after this seq and call `onDurableEvents`. */\n readonly wantsCatchUpAfterSeq?: SequenceNumber;\n}\n\n/** Inputs for one fresh or cold-restored delivery state. */\nexport interface MakeDeliveryStateInput {\n readonly subscriberId: SubscriberId;\n readonly resumeSeq: SequenceNumber;\n readonly policy: EDAWebSocketFlowControl;\n readonly coldRestored?: boolean;\n}\n\n/** Build the delivery state for a new connection or a post-eviction restore. */\nexport const makeWebSocketDeliveryState = (\n input: MakeDeliveryStateInput,\n): EDAWebSocketDeliveryState => ({\n subscriberId: input.subscriberId,\n policy: input.policy,\n coldRestored: input.coldRestored ?? false,\n lastAckedSeq: input.resumeSeq,\n lastAckedFrameId: 0,\n lastSentFrameId: 0,\n nextFrameId: 1,\n sentDurableThroughSeq: input.resumeSeq,\n inFlight: [],\n pendingEphemeral: [],\n});\n\n/** First frame for a freshly accepted connection. Cold restores never re-send hello. */\nexport const deliveryHelloFrame = (state: EDAWebSocketDeliveryState): EDAWebSocketHelloFrame =>\n EDAWebSocketHelloFrame.make({\n _tag: \"hello\",\n protocolVersion: EDA_WEB_SOCKET_PROTOCOL_VERSION,\n subscriberId: state.subscriberId,\n resumeSeq: state.lastAckedSeq,\n flowControl: state.policy,\n });\n\n/**\n * Deliver committed durable events read from the store.\n *\n * The store is the only buffer for durable events: frames are emitted while\n * the ACK window has room and the remainder is requested again via\n * `wantsCatchUpAfterSeq` once ACKs reopen the window.\n */\nexport const onDurableEvents = (\n state: EDAWebSocketDeliveryState,\n events: ReadonlyArray<PositionedEvent>,\n head: SequenceNumber,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const stale = staleAckResult(state, nowMs);\n if (stale !== undefined) {\n return stale;\n }\n\n let next = state;\n const frames: EDAWebSocketServerFrame[] = [];\n let batch: PositionedEvent[] = [];\n\n const flushBatch = (): EDAWebSocketDeliveryResult | undefined => {\n if (batch.length === 0) {\n return undefined;\n }\n const sent = sendEventsFrame(next, batch, nowMs);\n if (sent.close !== undefined) {\n return { ...sent, frames: [...frames, ...sent.frames] };\n }\n next = sent.state;\n frames.push(...sent.frames);\n batch = [];\n return undefined;\n };\n\n for (const event of events) {\n if (event.event.durability === \"durable\" && event.position.seq <= next.sentDurableThroughSeq) {\n continue;\n }\n if (batch.length === 0 && windowCapacity(next) <= 0) {\n break;\n }\n batch.push(event);\n if (batch.length >= next.policy.maxFrameEvents) {\n const closed = flushBatch();\n if (closed !== undefined) {\n return closed;\n }\n }\n }\n const closed = flushBatch();\n if (closed !== undefined) {\n return closed;\n }\n\n return {\n state: next,\n frames,\n ...(windowCapacity(next) > 0 && next.sentDurableThroughSeq < head\n ? { wantsCatchUpAfterSeq: next.sentDurableThroughSeq }\n : {}),\n };\n};\n\n/**\n * Deliver one live ephemeral event.\n *\n * Ephemeral events have no durable backing, so a bounded in-memory buffer\n * holds them while the ACK window is full; overflow lag-closes only this\n * subscriber, mirroring the previous streaming behavior.\n */\nexport const onEphemeralEvent = (\n state: EDAWebSocketDeliveryState,\n event: PositionedEvent,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const stale = staleAckResult(state, nowMs);\n if (stale !== undefined) {\n return stale;\n }\n\n if (windowCapacity(state) > 0 && state.pendingEphemeral.length === 0) {\n return sendEventsFrame(state, [event], nowMs);\n }\n\n const pendingEphemeral = [...state.pendingEphemeral, event];\n if (pendingEphemeral.length > state.policy.subscriberBufferCapacityEvents) {\n return laggedResult(state, \"buffer-overflow\");\n }\n return { state: { ...state, pendingEphemeral }, frames: [] };\n};\n\n/** Apply one client ACK, reopen the window, and drain buffered ephemeral events. */\nexport const onClientAck = (\n state: EDAWebSocketDeliveryState,\n ack: EDAWebSocketAckFrame,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const validated = state.coldRestored ? applyColdAck(state, ack) : applyWarmAck(state, ack);\n if (validated._tag === \"close\") {\n return validated.result;\n }\n if (validated._tag === \"ignore\") {\n return { state, frames: [] };\n }\n\n let next = validated.state;\n const frames: EDAWebSocketServerFrame[] = [];\n while (next.pendingEphemeral.length > 0 && windowCapacity(next) > 0) {\n const [head, ...rest] = next.pendingEphemeral;\n const sent = sendEventsFrame({ ...next, pendingEphemeral: rest }, [head!], nowMs);\n if (sent.close !== undefined) {\n return {\n ...sent,\n frames: [...frames, ...sent.frames],\n persistSeq: validated.persistSeq,\n };\n }\n next = sent.state;\n frames.push(...sent.frames);\n }\n\n const stale = staleAckResult(next, nowMs);\n if (stale !== undefined) {\n return { ...stale, frames: [...frames, ...stale.frames], persistSeq: validated.persistSeq };\n }\n\n return {\n state: next,\n frames,\n persistSeq: validated.persistSeq,\n ...(windowCapacity(next) > 0 && next.pendingEphemeral.length === 0\n ? { wantsCatchUpAfterSeq: next.sentDurableThroughSeq }\n : {}),\n };\n};\n\ntype AckValidation =\n | { readonly _tag: \"ignore\" }\n | { readonly _tag: \"close\"; readonly result: EDAWebSocketDeliveryResult }\n | {\n readonly _tag: \"apply\";\n readonly state: EDAWebSocketDeliveryState;\n readonly persistSeq: SequenceNumber;\n };\n\nconst applyWarmAck = (\n state: EDAWebSocketDeliveryState,\n ack: EDAWebSocketAckFrame,\n): AckValidation => {\n if (ack.frameId <= state.lastAckedFrameId) {\n return ack.durableThroughSeq > state.lastAckedSeq\n ? protocolClose(state, \"Duplicate ACK attempted to advance durable seq\")\n : { _tag: \"ignore\" };\n }\n if (ack.frameId > state.lastSentFrameId) {\n return protocolClose(state, \"ACK referenced an unsent frame\");\n }\n if (ack.durableThroughSeq < state.lastAckedSeq) {\n return protocolClose(state, \"ACK durable seq moved backwards\");\n }\n const acknowledged = state.inFlight.filter((frame) => frame.frameId <= ack.frameId);\n if (acknowledged.length === 0) {\n return protocolClose(state, \"ACK referenced no in-flight frames\");\n }\n const allowedDurableSeq = SequenceNumber.make(\n acknowledged.reduce<number>(\n (max, frame) => Math.max(max, frame.durableThroughSeq),\n state.lastAckedSeq,\n ),\n );\n if (ack.durableThroughSeq > allowedDurableSeq) {\n return protocolClose(state, \"ACK durable seq exceeded sent frame boundary\");\n }\n return {\n _tag: \"apply\",\n persistSeq: ack.durableThroughSeq,\n state: {\n ...state,\n inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),\n lastAckedFrameId: ack.frameId,\n lastAckedSeq: ack.durableThroughSeq,\n },\n };\n};\n\nconst applyColdAck = (\n state: EDAWebSocketDeliveryState,\n ack: EDAWebSocketAckFrame,\n): AckValidation => {\n // Pre-eviction frame ids are unknowable, so only durable-cursor monotonicity\n // is enforced; stale re-ACKs are ignored instead of protocol-closed.\n if (ack.durableThroughSeq < state.lastAckedSeq) {\n return { _tag: \"ignore\" };\n }\n const lastAckedSeq = SequenceNumber.make(Math.max(state.lastAckedSeq, ack.durableThroughSeq));\n return {\n _tag: \"apply\",\n persistSeq: lastAckedSeq,\n state: {\n ...state,\n inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),\n lastAckedFrameId: Math.max(state.lastAckedFrameId, ack.frameId),\n lastAckedSeq,\n // A late ACK can prove delivery beyond what this cold state has sent;\n // never re-send durable events the client has already acknowledged.\n sentDurableThroughSeq: SequenceNumber.make(\n Math.max(state.sentDurableThroughSeq, lastAckedSeq),\n ),\n },\n };\n};\n\nconst windowCapacity = (state: EDAWebSocketDeliveryState): number =>\n state.policy.maxInFlightFrames - state.inFlight.length;\n\nconst sendEventsFrame = (\n state: EDAWebSocketDeliveryState,\n events: ReadonlyArray<PositionedEvent>,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const frameId = FrameId.make(state.nextFrameId);\n const durableThroughSeq = SequenceNumber.make(\n events.reduce<number>(\n (max, event) =>\n event.event.durability === \"durable\" ? Math.max(max, event.position.seq) : max,\n state.sentDurableThroughSeq,\n ),\n );\n const frame = EDAWebSocketEventsFrame.make({\n _tag: \"events\",\n frameId,\n events: events as [PositionedEvent, ...PositionedEvent[]],\n durableThroughSeq,\n });\n const encodedBytes = new TextEncoder().encode(JSON.stringify(frame)).byteLength;\n if (encodedBytes > state.policy.maxFrameBytes) {\n const close = protocolClose(\n state,\n `Encoded WebSocket frame exceeded maxFrameBytes (${encodedBytes} > ${state.policy.maxFrameBytes})`,\n );\n return close.result;\n }\n return {\n state: {\n ...state,\n inFlight: [...state.inFlight, { frameId, durableThroughSeq, sentAtMs: nowMs }],\n lastSentFrameId: frameId,\n nextFrameId: frameId + 1,\n sentDurableThroughSeq: durableThroughSeq,\n },\n frames: [frame],\n };\n};\n\n/** Lazily enforce the ACK deadline: no resident timer, checked on each transition. */\nconst staleAckResult = (\n state: EDAWebSocketDeliveryState,\n nowMs: number,\n): EDAWebSocketDeliveryResult | undefined => {\n const overdue = state.inFlight.some(\n (frame) => frame.sentAtMs + state.policy.ackTimeoutMs <= nowMs,\n );\n return overdue ? laggedResult(state, \"ack-timeout\") : undefined;\n};\n\nconst laggedResult = (\n state: EDAWebSocketDeliveryState,\n reason: SubscriberLagReason,\n): EDAWebSocketDeliveryResult => ({\n state,\n frames: [\n EDAWebSocketLaggedFrame.make({\n _tag: \"lagged\",\n resumeSeq: state.lastAckedSeq,\n reason,\n }),\n ],\n close: { code: EDA_WS_CLOSE_LAGGED, reason: laggedCloseReason(state.lastAckedSeq) },\n});\n\nconst protocolClose = (\n state: EDAWebSocketDeliveryState,\n message: string,\n): { readonly _tag: \"close\"; readonly result: EDAWebSocketDeliveryResult } => ({\n _tag: \"close\",\n result: {\n state,\n frames: [EDAWebSocketErrorFrame.make({ _tag: \"error\", message: message.slice(0, 120) })],\n close: { code: EDA_WS_CLOSE_PROTOCOL_ERROR, reason: \"protocol\" },\n },\n});\n"],"mappings":";;;;;AAqBA,MAAa,sBAAsB,OAAO,SAAS,CAAC,mBAAmB,aAAa,C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AAM;EAAqB,QAAQ,kBAAkB,MAAM,YAAY;CAAE;AACpF;AAEA,MAAM,iBACJ,OACA,aAC6E;CAC7E,MAAM;CACN,QAAQ;EACN;EACA,QAAQ,CAAC,uBAAuB,KAAK;GAAE,MAAM;GAAS,SAAS,QAAQ,MAAM,GAAG,GAAG;EAAE,CAAC,CAAC;EACvF,OAAO;GAAE,MAAM;GAA6B,QAAQ;EAAW;CACjE;AACF"}
@@ -1,11 +1,11 @@
1
1
  import { m as SequenceNumber } from "./core-CYT6DBaS.js";
2
2
  import { L as PositionedEvent } from "./events-Bb9-Cu-7.js";
3
- import { a as EDASessionStore, o as EDASessionStoreError } from "./session-store-DZZUffUy.js";
4
- import { S as ReducedState } from "./command-queues-CV7O-51r.js";
5
- import { t as DurableTranscriptMessage } from "./message-transcript-DiOPBY3l.js";
6
- import { u as LiveEventBus } from "./sink-registry-Cf79ICdW.js";
7
- import { i as EDAReducerStateSnapshot } from "./reducer-registry-CjSJBPKo.js";
8
- import { h as SessionState } from "./session-state-CjOSvWbe.js";
3
+ import { a as EDASessionStore, o as EDASessionStoreError } from "./session-store-BLg6UvZa.js";
4
+ import { S as ReducedState } from "./command-queues-Dwdf41mq.js";
5
+ import { t as DurableTranscriptMessage } from "./message-transcript-CFn_D3MH.js";
6
+ import { u as LiveEventBus } from "./sink-registry-CO3YPS1p.js";
7
+ import { i as EDAReducerStateSnapshot } from "./reducer-registry-K9FqZq5-.js";
8
+ import { h as SessionState } from "./session-state-CI1xeT6f.js";
9
9
  import * as Context from "effect/Context";
10
10
  import * as Effect from "effect/Effect";
11
11
  import * as Layer from "effect/Layer";
@@ -27,12 +27,19 @@ interface EDASessionQueryShape {
27
27
  readonly messages: () => Effect.Effect<ReadonlyArray<DurableTranscriptMessage>, EDASessionStoreError>;
28
28
  /** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */
29
29
  readonly eventsAfter: (afterSeq: SequenceNumber) => Effect.Effect<Stream.Stream<PositionedEvent, EDASessionStoreError>, EDASessionStoreError, Scope.Scope>;
30
+ /** Read one bounded committed durable slice after `afterSeq` plus the committed head. */
31
+ readonly eventsSlice: (afterSeq: SequenceNumber, limit: number) => Effect.Effect<EDASessionEventsSlice, EDASessionStoreError>;
32
+ }
33
+ /** Bounded committed durable replay slice for pull-based delivery. */
34
+ interface EDASessionEventsSlice {
35
+ readonly events: ReadonlyArray<PositionedEvent>;
36
+ readonly head: SequenceNumber;
30
37
  }
31
38
  declare const EDASessionQuery_base: Context.ServiceClass<EDASessionQuery, "@effect-durable-agent/EDASessionQuery", EDASessionQueryShape>;
32
39
  /** Read-only session query facade backed by authoritative SessionState plus durable backfill. */
33
40
  declare class EDASessionQuery extends EDASessionQuery_base {
34
- static readonly Live: Layer.Layer<EDASessionQuery, never, EDASessionStore | SessionState | LiveEventBus>;
41
+ static readonly Live: Layer.Layer<EDASessionQuery, never, SessionState | EDASessionStore | LiveEventBus>;
35
42
  }
36
43
  //#endregion
37
- export { EDASessionQueryShape as n, EDASessionSnapshot as r, EDASessionQuery as t };
38
- //# sourceMappingURL=session-query-C-C4m1eq.d.ts.map
44
+ export { EDASessionSnapshot as i, EDASessionQuery as n, EDASessionQueryShape as r, EDASessionEventsSlice as t };
45
+ //# sourceMappingURL=session-query-5oyZRaQL.d.ts.map
@@ -1,16 +1,16 @@
1
1
  import { r as EDACommand } from "./commands-Ce1ec6kH.js";
2
2
  import { D as DurableEventEnvelope, F as ModelSelectionPayload, I as NonNegativeInt, L as PositionedEvent, O as EphemeralEventEnvelope } from "./events-Bb9-Cu-7.js";
3
3
  import { kt as ToolCallCreatedEvent } from "./durable-B7M6TD_0.js";
4
- import { a as EDASessionStore, o as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-DZZUffUy.js";
5
- import { S as ReducedState } from "./command-queues-CV7O-51r.js";
4
+ import { a as EDASessionStore, o as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-BLg6UvZa.js";
5
+ import { S as ReducedState } from "./command-queues-Dwdf41mq.js";
6
+ import { s as EDASinkRegistry, u as LiveEventBus } from "./sink-registry-CO3YPS1p.js";
6
7
  import { t as IdGenerator } from "./id-generator-Ckl8_XWW.js";
7
8
  import { r as SessionContext, t as EventFactory } from "./event-factory-CLJcyymV.js";
8
9
  import { t as EDAKeepAlive } from "./keep-alive-Chl5SJxy.js";
9
- import { d as CompactionRunner } from "./compaction-zbvLREI8.js";
10
- import { s as EDASinkRegistry, u as LiveEventBus } from "./sink-registry-Cf79ICdW.js";
11
- import { i as EDAReducerStateSnapshot, n as EDAReducerRegistry } from "./reducer-registry-CjSJBPKo.js";
12
- import { r as EDAPromptProjector } from "./prompt-projector-C1IbkHr0.js";
13
- import { r as EDAToolRegistry } from "./tool-registry-B7Wona6N.js";
10
+ import { d as CompactionRunner } from "./compaction-DpHOf-g7.js";
11
+ import { i as EDAReducerStateSnapshot, n as EDAReducerRegistry } from "./reducer-registry-K9FqZq5-.js";
12
+ import { r as EDAPromptProjector } from "./prompt-projector-C2meuNrV.js";
13
+ import { r as EDAToolRegistry } from "./tool-registry-B8H1P6Pu.js";
14
14
  import * as Context from "effect/Context";
15
15
  import * as Effect from "effect/Effect";
16
16
  import * as Layer from "effect/Layer";
@@ -143,7 +143,7 @@ interface ToolExecutorShape {
143
143
  declare const ToolExecutor_base: Context.ServiceClass<ToolExecutor, "@effect-durable-agent/ToolExecutor", ToolExecutorShape>;
144
144
  /** Executes sealed framework-owned tool calls and commits tool lifecycle boundaries. */
145
145
  declare class ToolExecutor extends ToolExecutor_base {
146
- static readonly Live: Layer.Layer<ToolExecutor, never, IdGenerator | EventFactory | SessionContext | EDAToolRegistry>;
146
+ static readonly Live: Layer.Layer<ToolExecutor, never, EDAToolRegistry | IdGenerator | EventFactory | SessionContext>;
147
147
  }
148
148
  //#endregion
149
149
  //#region src/services/inference-runner.d.ts
@@ -291,7 +291,7 @@ interface InferenceRunnerShape {
291
291
  declare const InferenceRunner_base: Context.ServiceClass<InferenceRunner, "@effect-durable-agent/InferenceRunner", InferenceRunnerShape>;
292
292
  /** Owns provider inference streams and routes them into durable/live inference emissions. */
293
293
  declare class InferenceRunner extends InferenceRunner_base {
294
- static readonly Live: Layer.Layer<InferenceRunner, never, IdGenerator | EventFactory | EDAToolRegistry | LanguageModel.LanguageModel>;
294
+ static readonly Live: Layer.Layer<InferenceRunner, never, EDAToolRegistry | LanguageModel.LanguageModel | IdGenerator | EventFactory>;
295
295
  }
296
296
  //#endregion
297
297
  //#region src/services/turn-runner.d.ts
@@ -854,8 +854,8 @@ interface SessionStateShape extends SessionEventSink {
854
854
  declare const SessionState_base: Context.ServiceClass<SessionState, "@effect-durable-agent/SessionState", SessionStateShape>;
855
855
  /** Internal authoritative live state and root control loop for one session. */
856
856
  declare class SessionState extends SessionState_base {
857
- static readonly Live: Layer.Layer<SessionState, EDASessionStoreError, EDAPromptProjector | EDASessionStore | LiveEventBus | EDAKeepAlive | IdGenerator | EventFactory | TurnRunner | CompactionRunner | SessionContext | EDAReducerRegistry | EDASinkRegistry>;
857
+ static readonly Live: Layer.Layer<SessionState, EDASessionStoreError, EDASessionStore | LiveEventBus | EDAKeepAlive | IdGenerator | EventFactory | TurnRunner | CompactionRunner | EDAPromptProjector | SessionContext | EDAReducerRegistry | EDASinkRegistry>;
858
858
  }
859
859
  //#endregion
860
860
  export { ToolExecutor as S, SessionStateShape as _, SessionCommandCompleted as a, InferenceRunner as b, SessionCommandResult as c, SessionForkedCommand as d, SessionNoRunnableCommand as f, SessionStateError as g, SessionState as h, SessionCommandCancelled as i, SessionDrainProcessed as l, SessionRunInput as m, SessionCommandAdmissionConflict as n, SessionCommandFailed as o, SessionNoRunnableReason as p, SessionCommandAdmissionError as r, SessionCommandOutcome as s, EDASubmittable as t, SessionDrainResult as u, SessionStateSnapshotData as v, InferenceRunnerStreamPart as x, TurnRunner as y };
861
- //# sourceMappingURL=session-state-CjOSvWbe.d.ts.map
861
+ //# sourceMappingURL=session-state-CI1xeT6f.d.ts.map
@@ -2,6 +2,7 @@ import { CommandId, InferenceId, MessageId, Position, RunId, SequenceNumber, Sub
2
2
  import { CancelPendingMessageCommand, PromotePendingMessageCommand, ResumePendingMessagesCommand, StopTurnCommand, SubmitMessageCommand } from "./types/commands.js";
3
3
  import { makeEDARunTrace } from "./types/tracing.js";
4
4
  import { An as inferenceFailedEventType, Jn as toolCallRejectedEventType, Kn as toolCallCreatedEventType, Zn as turnFailedEventType, _r as SystemPromptText, br as UsagePayload, dr as FailurePayload, fr as ModelSelectionPayload, gn as commandAdmittedEventType, hr as ProviderPartId, kn as inferenceCompletedEventType, mr as PositionedEvent, pr as NonNegativeInt, vr as ToolName } from "./durable-DsV9PxZC.js";
5
+ import { n as EDASinkRegistry, r as LiveEventBus } from "./sink-registry-BbmoI9uv.js";
5
6
  import { a as encodeReducedStateCheckpoint, h as assertNeverError, i as decodeReducedStateCheckpoint, l as initialReducedState, m as assertNever, n as activeTurnIdentityForCommand, o as foldReducedState, p as reducedStateCheckpointEventSeqs, r as classifyRecoverableWork, s as frameworkReducedStateReducerName } from "./reduced-state-TMi7ISla.js";
6
7
  import { ContextProjection, emptyContextProjection } from "./domain/context-projection.js";
7
8
  import { CommittedDurableEvent, EDASessionStore, EDASessionStoreError, hasEDASessionStoreError } from "./services/session-store.js";
@@ -10,7 +11,6 @@ import { n as SessionContext, t as EventFactory } from "./event-factory-tcpLgdMN
10
11
  import { annotateEdaSpan, committedBatchAttributes, edaTraceContextFromSpan, eventBatchAttributes, toEdaExternalSpan, usageAttributes } from "./services/tracing.js";
11
12
  import { EDAKeepAlive } from "./services/keep-alive.js";
12
13
  import { CompactionRunner } from "./services/compaction.js";
13
- import { n as EDASinkRegistry, r as LiveEventBus } from "./sink-registry-D13eUO_c.js";
14
14
  import { EDAPromptProjector, buildEDAPrompt } from "./services/prompt-projector.js";
15
15
  import { EDAReducerRegistry, decodeReducerState, encodeReducerState, reducerSchemaVersion } from "./services/reducer-registry.js";
16
16
  import { EDAToolRegistry } from "./services/tool-registry.js";
@@ -20,12 +20,12 @@ import * as Layer from "effect/Layer";
20
20
  import * as Schema from "effect/Schema";
21
21
  import * as Stream from "effect/Stream";
22
22
  import * as Prompt from "effect/unstable/ai/Prompt";
23
+ import * as Ref from "effect/Ref";
23
24
  import * as Cause from "effect/Cause";
24
25
  import * as Clock from "effect/Clock";
25
26
  import * as Exit from "effect/Exit";
26
27
  import * as Fiber from "effect/Fiber";
27
28
  import * as Queue from "effect/Queue";
28
- import * as Ref from "effect/Ref";
29
29
  import * as Scope from "effect/Scope";
30
30
  import * as Semaphore from "effect/Semaphore";
31
31
  import * as LanguageModel from "effect/unstable/ai/LanguageModel";
@@ -2824,4 +2824,4 @@ const isSessionNoRunnableCommand = (result) => "_tag" in result && result._tag =
2824
2824
  //#endregion
2825
2825
  export { SessionCommandOutcome as a, SessionNoRunnableReason as c, TurnRunner as d, InferenceRunner as f, SessionCommandFailed as i, SessionRunInput as l, SessionCommandCancelled as n, SessionForkedCommand as o, ToolExecutor as p, SessionCommandCompleted as r, SessionNoRunnableCommand as s, SessionCommandAdmissionConflict as t, SessionState as u };
2826
2826
 
2827
- //# sourceMappingURL=session-state-SStf0KUo.js.map
2827
+ //# sourceMappingURL=session-state-D7dqko7r.js.map