effect-durable-agent 0.1.0-alpha.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +5 -5
  2. package/dist/assert-never-CoyUpoRB.js +18 -0
  3. package/dist/assert-never-CoyUpoRB.js.map +1 -0
  4. package/dist/{commands-Ce1ec6kH.d.ts → commands-BUquEZVP.d.ts} +31 -12
  5. package/dist/{compaction-BgDr5VJy.js → compaction-D7WJa899.js} +63 -13
  6. package/dist/compaction-D7WJa899.js.map +1 -0
  7. package/dist/{context-projection-n6Rdup0N.d.ts → context-projection-Bezx3drD.d.ts} +16 -40
  8. package/dist/{core-CYT6DBaS.d.ts → core-BcimKMIv.d.ts} +5 -3
  9. package/dist/delivery-B_LDTuIB.d.ts +3169 -0
  10. package/dist/delivery-BoF-NZbZ.js +507 -0
  11. package/dist/delivery-BoF-NZbZ.js.map +1 -0
  12. package/dist/domain/command-queues.d.ts +81 -2
  13. package/dist/domain/command-queues.js +1 -1
  14. package/dist/domain/command-queues.js.map +1 -1
  15. package/dist/domain/context-projection.d.ts +1 -1
  16. package/dist/domain/context-projection.js +1 -1
  17. package/dist/domain/context-projection.js.map +1 -1
  18. package/dist/domain/message-transcript.d.ts +36 -2
  19. package/dist/domain/message-transcript.js +10 -2
  20. package/dist/domain/message-transcript.js.map +1 -1
  21. package/dist/domain/model-usage.d.ts +1 -1
  22. package/dist/domain/model-usage.js +1 -1
  23. package/dist/domain/reduced-state-schema.d.ts +3 -992
  24. package/dist/domain/reduced-state-schema.js +126 -7
  25. package/dist/domain/reduced-state-schema.js.map +1 -1
  26. package/dist/domain/reduced-state.d.ts +2 -2
  27. package/dist/domain/reduced-state.js +937 -2
  28. package/dist/domain/reduced-state.js.map +1 -0
  29. package/dist/domain/run-scheduling.d.ts +2 -0
  30. package/dist/domain/run-scheduling.js +127 -0
  31. package/dist/domain/run-scheduling.js.map +1 -0
  32. package/dist/{durable-br2C1bWK.d.ts → durable-BXqwM70o.d.ts} +8983 -2800
  33. package/dist/{durable-BGFvX7Mh.js → durable-Da57Rcml.js} +243 -15
  34. package/dist/durable-Da57Rcml.js.map +1 -0
  35. package/dist/{envelope-DxQzo5rN.js → envelope-BSI_Xh-f.js} +31 -6
  36. package/dist/envelope-BSI_Xh-f.js.map +1 -0
  37. package/dist/{envelope-DkZyMIgp.d.ts → envelope-CJnPfbjC.d.ts} +121 -11
  38. package/dist/{event-factory-DTFdy0Cb.js → event-factory-BUoBwqAy.js} +7 -3
  39. package/dist/event-factory-BUoBwqAy.js.map +1 -0
  40. package/dist/{events-LZFNoESe.d.ts → events-AIIwZ6dS.d.ts} +139 -137
  41. package/dist/{id-generator-Ckl8_XWW.d.ts → id-generator-BKGoKjt-.d.ts} +3 -3
  42. package/dist/in-memory-E497WhtS.js +150 -0
  43. package/dist/in-memory-E497WhtS.js.map +1 -0
  44. package/dist/index.d.ts +8 -8
  45. package/dist/index.js +6 -6
  46. package/dist/interpreter-BwYN2PCC.js +1453 -0
  47. package/dist/interpreter-BwYN2PCC.js.map +1 -0
  48. package/dist/{keep-alive-Chl5SJxy.d.ts → keep-alive-_zFCUvt3.d.ts} +1 -2
  49. package/dist/{model-resolver-BPPJAsuh.d.ts → model-resolver-O8Kn27GH.d.ts} +11 -5
  50. package/dist/{model-usage-CdBEkTwU.d.ts → model-usage-mttrPN0j.d.ts} +2 -3
  51. package/dist/records-D0ZIAOzd.js +675 -0
  52. package/dist/records-D0ZIAOzd.js.map +1 -0
  53. package/dist/reduced-state-YbjpihEf.d.ts +52933 -0
  54. package/dist/reduced-state-schema-B9TYxkP9.d.ts +2338 -0
  55. package/dist/{reducer-registry-aFjz_ZLT.d.ts → reducer-registry-Bqn5B4JO.d.ts} +12 -6
  56. package/dist/run-scheduling-wakeup-DX2zRAxd.d.ts +24 -0
  57. package/dist/services/compaction.d.ts +2 -2
  58. package/dist/services/compaction.js +2 -2
  59. package/dist/services/decider.d.ts +2 -0
  60. package/dist/services/decider.js +97 -0
  61. package/dist/services/decider.js.map +1 -0
  62. package/dist/services/id-generator.d.ts +1 -1
  63. package/dist/services/id-generator.js +6 -12
  64. package/dist/services/id-generator.js.map +1 -1
  65. package/dist/services/keep-alive.d.ts +1 -1
  66. package/dist/services/keep-alive.js.map +1 -1
  67. package/dist/services/model-call.d.ts +15 -0
  68. package/dist/services/model-call.js +15 -0
  69. package/dist/services/model-call.js.map +1 -0
  70. package/dist/services/model-resolver.d.ts +1 -1
  71. package/dist/services/model-resolver.js +1 -1
  72. package/dist/services/model-resolver.js.map +1 -1
  73. package/dist/services/prompt-projector.d.ts +2 -2
  74. package/dist/services/prompt-projector.js +49 -5
  75. package/dist/services/prompt-projector.js.map +1 -1
  76. package/dist/services/reducer-registry.d.ts +1 -1
  77. package/dist/services/reducer-registry.js +19 -6
  78. package/dist/services/reducer-registry.js.map +1 -1
  79. package/dist/services/run-scheduler.d.ts +2 -2
  80. package/dist/services/run-scheduler.js +25 -2
  81. package/dist/services/run-scheduler.js.map +1 -0
  82. package/dist/services/run-scheduling-wakeup.d.ts +2 -0
  83. package/dist/services/run-scheduling-wakeup.js +13 -0
  84. package/dist/services/run-scheduling-wakeup.js.map +1 -0
  85. package/dist/services/runtime-layer.d.ts +21 -33
  86. package/dist/services/runtime-layer.js +24 -16
  87. package/dist/services/runtime-layer.js.map +1 -1
  88. package/dist/services/runtime.d.ts +1 -1
  89. package/dist/services/runtime.js +32 -20
  90. package/dist/services/runtime.js.map +1 -1
  91. package/dist/services/session-event-observer.d.ts +1 -1
  92. package/dist/services/session-event-observer.js.map +1 -1
  93. package/dist/services/session-query.d.ts +1 -1
  94. package/dist/services/session-query.js +57 -10
  95. package/dist/services/session-query.js.map +1 -1
  96. package/dist/services/session-state.d.ts +2 -2
  97. package/dist/services/session-state.js +2 -1
  98. package/dist/services/session-store.d.ts +2 -2
  99. package/dist/services/session-store.js +143 -38
  100. package/dist/services/session-store.js.map +1 -1
  101. package/dist/services/sink-checkpoint-store.d.ts +1 -1
  102. package/dist/services/sink-checkpoint-store.js +2 -1
  103. package/dist/services/sink-checkpoint-store.js.map +1 -1
  104. package/dist/services/sink-registry.d.ts +2 -2
  105. package/dist/services/sink-registry.js +1 -1
  106. package/dist/services/span-names.d.ts +1 -1
  107. package/dist/services/span-names.js +7 -1
  108. package/dist/services/span-names.js.map +1 -1
  109. package/dist/services/tool-registry.d.ts +2 -2
  110. package/dist/services/tool-registry.js +12 -3
  111. package/dist/services/tool-registry.js.map +1 -1
  112. package/dist/services/tracing.d.ts +3 -3
  113. package/dist/services/tracing.js +2 -2
  114. package/dist/services/tracing.js.map +1 -1
  115. package/dist/session-admission-WE8J_0z9.js +138 -0
  116. package/dist/session-admission-WE8J_0z9.js.map +1 -0
  117. package/dist/{session-event-observer-DaFMKKNc.d.ts → session-event-observer-BWQUJTcN.d.ts} +3 -3
  118. package/dist/{session-state-Bkc6u-Wr.js → session-state-D02LCVcC.js} +815 -170
  119. package/dist/session-state-D02LCVcC.js.map +1 -0
  120. package/dist/session-store-DaSHeg8Q.d.ts +3343 -0
  121. package/dist/{sink-checkpoint-store-M7qIxoSH.d.ts → sink-checkpoint-store-CUvIVvlZ.d.ts} +3 -4
  122. package/dist/sink-registry-AOjX5_A1.js +369 -0
  123. package/dist/sink-registry-AOjX5_A1.js.map +1 -0
  124. package/dist/subscription-BhwUmsl4.d.ts +966 -0
  125. package/dist/subscription-D7U4Tziv.js +505 -0
  126. package/dist/subscription-D7U4Tziv.js.map +1 -0
  127. package/dist/testkit/layers.d.ts +33 -23
  128. package/dist/testkit/layers.js +34 -19
  129. package/dist/testkit/layers.js.map +1 -1
  130. package/dist/testkit/transcript.d.ts +232 -0
  131. package/dist/testkit/transcript.js +1526 -0
  132. package/dist/testkit/transcript.js.map +1 -0
  133. package/dist/{tracing-BXHAkxkx.d.ts → tracing-BwjbF285.d.ts} +1 -2
  134. package/dist/transcript.d.ts +101 -0
  135. package/dist/transcript.js +107 -0
  136. package/dist/transcript.js.map +1 -0
  137. package/dist/types/commands.d.ts +2 -2
  138. package/dist/types/commands.js +8 -3
  139. package/dist/types/commands.js.map +1 -1
  140. package/dist/types/core.d.ts +2 -2
  141. package/dist/types/core.js +3 -1
  142. package/dist/types/core.js.map +1 -1
  143. package/dist/types/events/durable.d.ts +2 -2
  144. package/dist/types/events/durable.js +2 -2
  145. package/dist/types/events.d.ts +5 -5
  146. package/dist/types/events.js +3 -3
  147. package/dist/types/tracing.d.ts +1 -1
  148. package/dist/types/tracing.js.map +1 -1
  149. package/dist/websocket/events.d.ts +2 -0
  150. package/dist/websocket/events.js +2 -0
  151. package/dist/websocket.d.ts +2123 -2552
  152. package/dist/websocket.js +628 -442
  153. package/dist/websocket.js.map +1 -1
  154. package/dist/window-read-BELSkO-r.d.ts +113 -0
  155. package/dist/window-read-FJTCDaSq.js +264 -0
  156. package/dist/window-read-FJTCDaSq.js.map +1 -0
  157. package/package.json +41 -13
  158. package/dist/command-queues-DdDB_aYM.d.ts +0 -462
  159. package/dist/compaction-BgDr5VJy.js.map +0 -1
  160. package/dist/compaction-ch8z6G9x.d.ts +0 -165
  161. package/dist/durable-BGFvX7Mh.js.map +0 -1
  162. package/dist/envelope-DxQzo5rN.js.map +0 -1
  163. package/dist/event-factory-DTFdy0Cb.js.map +0 -1
  164. package/dist/event-factory-Di1jwQvm.d.ts +0 -87
  165. package/dist/index-BVVgDSdq.d.ts +0 -1
  166. package/dist/message-transcript-DQNlzxle.d.ts +0 -32
  167. package/dist/prompt-projector-f4ElyXCE.d.ts +0 -39
  168. package/dist/reduced-state-DF0-6mbR.js +0 -921
  169. package/dist/reduced-state-DF0-6mbR.js.map +0 -1
  170. package/dist/run-scheduler-CAt7dF6C.js +0 -21
  171. package/dist/run-scheduler-CAt7dF6C.js.map +0 -1
  172. package/dist/run-scheduler-xkhZyto5.d.ts +0 -44
  173. package/dist/runtime-DDSYP9jS.d.ts +0 -63
  174. package/dist/session-query-B72HY_0L.d.ts +0 -45
  175. package/dist/session-state-Bkc6u-Wr.js.map +0 -1
  176. package/dist/session-state-C9YLSAso.d.ts +0 -862
  177. package/dist/session-store-Cpi_NwTR.d.ts +0 -206
  178. package/dist/sink-registry-Bl-vQES6.d.ts +0 -133
  179. package/dist/sink-registry-NDgeyzO0.js +0 -272
  180. package/dist/sink-registry-NDgeyzO0.js.map +0 -1
  181. package/dist/tool-registry-BJaVNtw4.d.ts +0 -51
package/dist/websocket.js CHANGED
@@ -1,498 +1,684 @@
1
- import { Position, SequenceNumber } from "./types/core.js";
2
- import { h as UnixEpochMillis, i as EventEnvelope, u as PositionedEvent } from "./envelope-DxQzo5rN.js";
3
- import { V as EDADurableEvent } from "./durable-BGFvX7Mh.js";
4
- import { EDAEphemeralEvent } from "./types/events.js";
5
- import * as Effect from "effect/Effect";
1
+ import { SequenceNumber } from "./types/core.js";
2
+ import { E as TranscriptOrder, _ as TranscriptCursor } from "./records-D0ZIAOzd.js";
3
+ import { c as transcriptCoverageOf, i as TranscriptUpdate, n as TranscriptRequestId, r as TranscriptSubscriptionBase, t as TranscriptCoverage } from "./subscription-D7U4Tziv.js";
4
+ import { A as FrameId, B as EDAWebSocketWireFlowControl, C as EDAWebSocketServerFrame, D as EDA_WS_CLOSE_PROTOCOL_ERROR, E as EDA_WS_CLOSE_LAGGED, F as laggedCloseReason, G as EDAWebSocketWirePongFrame, H as EDAWebSocketWireHelloFrame, I as EDAFrameworkWebSocketEvent, J as EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, K as EDA_WEB_SOCKET_PING_MESSAGE, L as EDAWebSocketWireAckFrame, M as decodeEDAWebSocketClientMessage, N as defaultEDAWebSocketFlowControl, O as EDA_WS_CLOSE_SEND_FAILED, P as encodeEDAWebSocketServerFrame, R as EDAWebSocketWireClientFrame, S as EDAWebSocketPongFrame, T as EDA_WS_CLOSE_GOING_AWAY, U as EDAWebSocketWireLaggedFrame, V as EDAWebSocketWireHeartbeatFrame, W as EDAWebSocketWirePingFrame, X as makeEDAWebSocketWireProtocol, Y as edaFrameworkWebSocketWireProtocol, _ as EDAWebSocketFlowControl, a as checkpointWebSocketDeliveryState, b as EDAWebSocketLaggedFrame, c as onClientAck, d as onHostSuppressedFrame, f as restoreWebSocketDeliveryState, g as EDAWebSocketEventsFrame, h as EDAWebSocketErrorFrame, i as SubscriberLagReason, j as SubscriberId, k as EDA_WS_CLOSE_UNSUPPORTED_DATA, l as onDurableEvents, m as EDAWebSocketClientFrame, n as EDAWebSocketInFlightFrame, o as deliveryHelloFrame, p as EDAWebSocketAckFrame, q as EDA_WEB_SOCKET_PONG_MESSAGE, r as EDAWebSocketSuppressedRange, s as makeWebSocketDeliveryState, t as EDAWebSocketDeliveryCheckpoint, u as onEphemeralEvent, v as EDAWebSocketHeartbeatFrame, w as EDA_WEB_SOCKET_PROTOCOL_VERSION, x as EDAWebSocketPingFrame, y as EDAWebSocketHelloFrame, z as EDAWebSocketWireErrorFrame } from "./delivery-BoF-NZbZ.js";
6
5
  import * as Schema from "effect/Schema";
7
- //#region src/websocket/protocol.ts
8
- const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));
9
- const NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
10
- /** Current EDA live-event WebSocket wire protocol version. */
11
- const EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION = 1;
12
- /** Flow-control policy announced by the server in the hello frame. */
13
- const EDAWebSocketWireFlowControl = Schema.Struct({
14
- ackTimeoutMs: PositiveInt,
15
- /** Deprecated: servers no longer send heartbeat frames. Kept so deployed clients can decode hello. */
16
- heartbeatIntervalMs: PositiveInt,
17
- maxFrameBytes: PositiveInt,
18
- maxFrameEvents: PositiveInt,
19
- maxInFlightFrames: PositiveInt,
20
- /** Suggested client-originated ping cadence; absent on servers that still send heartbeats. */
21
- pingIntervalMs: Schema.optionalKey(PositiveInt),
22
- subscriberBufferCapacityEvents: PositiveInt
6
+ import * as Exit from "effect/Exit";
7
+ //#region src/websocket/transcript.ts
8
+ const PositiveInt$1 = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
9
+ const NonNegativeInt$1 = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
10
+ /**
11
+ * Transcript protocol major. A change of meaning that an older client would misread bumps it;
12
+ * a client that sees another major performs one bounded reload.
13
+ */
14
+ const EDA_TRANSCRIPT_PROTOCOL_MAJOR = 1;
15
+ /** Additive wire revision within a major; older clients drop fields they do not know. */
16
+ const EDA_TRANSCRIPT_WIRE_VERSION = 1;
17
+ /**
18
+ * The small, stable envelope a client decodes before any version-specific schema, from the
19
+ * socket hello and from the host's SSR data. Its shape never changes; everything else may.
20
+ */
21
+ const EDATranscriptNegotiation = Schema.Struct({
22
+ protocolMajor: PositiveInt$1,
23
+ wireVersion: PositiveInt$1,
24
+ /** Optional features this server speaks; clients ignore names they do not know. */
25
+ capabilities: Schema.Array(Schema.String)
23
26
  });
27
+ /** What this EDA release speaks. Hosts embed it in SSR data next to the transcript window. */
28
+ const edaTranscriptNegotiation = {
29
+ protocolMajor: 1,
30
+ wireVersion: 1,
31
+ capabilities: [
32
+ "window",
33
+ "page",
34
+ "retain",
35
+ "chunked-updates",
36
+ "active-content"
37
+ ]
38
+ };
39
+ /** Any value carrying the envelope under `negotiation`: a hello frame or SSR data. */
40
+ const NegotiationCarrier = Schema.Struct({ negotiation: EDATranscriptNegotiation });
41
+ const decodeNegotiationCarrier = Schema.decodeUnknownOption(NegotiationCarrier);
24
42
  /**
25
- * Canonical client liveness ping message.
26
- *
27
- * The exact string matters: hibernation-capable hosts register it with
28
- * WebSocket auto-response so the runtime answers without waking the object.
43
+ * Decode only the negotiation envelope from an untrusted hello frame or SSR payload and compare
44
+ * it with this client's major. Run before decoding anything version-specific.
45
+ */
46
+ const negotiateEDATranscript = (carrier, localMajor = 1) => {
47
+ const decoded = decodeNegotiationCarrier(carrier);
48
+ if (decoded._tag === "None") return { _tag: "Undecodable" };
49
+ const remote = decoded.value.negotiation;
50
+ return remote.protocolMajor === localMajor ? {
51
+ _tag: "Compatible",
52
+ remote
53
+ } : {
54
+ _tag: "MajorMismatch",
55
+ remote
56
+ };
57
+ };
58
+ /** WebSocket close code: the server lost volatile transfer state; reconnect and resubscribe. */
59
+ const EDA_WS_CLOSE_TRANSCRIPT_RESUBSCRIBE = 4009;
60
+ /** First frame on a transcript socket: the event-socket hello plus the negotiation envelope. */
61
+ const EDATranscriptHelloFrame = Schema.Struct({
62
+ ...EDAWebSocketWireHelloFrame.fields,
63
+ negotiation: EDATranscriptNegotiation
64
+ });
65
+ /** A transcript update that fits one frame. */
66
+ const EDATranscriptUpdateFrame = Schema.Struct({
67
+ _tag: Schema.Literal("transcript"),
68
+ frameId: PositiveInt$1,
69
+ update: TranscriptUpdate
70
+ });
71
+ /**
72
+ * One slice of an update too large for a frame. `data` slices concatenated in `index` order are
73
+ * the JSON of one `TranscriptUpdate`; the client applies it only after slice `count - 1` (the
74
+ * completion marker) and discards a transfer that is interrupted.
75
+ */
76
+ const EDATranscriptChunkFrame = Schema.Struct({
77
+ _tag: Schema.Literal("transcript-chunk"),
78
+ frameId: PositiveInt$1,
79
+ updateSeq: PositiveInt$1,
80
+ index: NonNegativeInt$1,
81
+ count: PositiveInt$1,
82
+ data: Schema.String
83
+ }).check(Schema.makeFilter((chunk) => chunk.index < chunk.count || "chunk index out of range"));
84
+ /** Every server frame a transcript socket may carry. */
85
+ const EDATranscriptServerFrame = Schema.Union([
86
+ EDATranscriptHelloFrame,
87
+ EDATranscriptUpdateFrame,
88
+ EDATranscriptChunkFrame,
89
+ EDAWebSocketWirePongFrame,
90
+ EDAWebSocketWireLaggedFrame,
91
+ EDAWebSocketWireErrorFrame
92
+ ]);
93
+ /**
94
+ * Start or restart the subscription. After SSR, `range` is what the page rendered, `tail` its
95
+ * `!hasNewer`, and `since` its `throughSeq`; a reconnecting client sends what it last applied.
96
+ * Without `range` the server replies with the latest `count` records.
29
97
  */
30
- const EDA_WEB_SOCKET_PING_MESSAGE = "{\"_tag\":\"ping\"}";
31
- /** Canonical server pong message paired with {@link EDA_WEB_SOCKET_PING_MESSAGE}. */
32
- const EDA_WEB_SOCKET_PONG_MESSAGE = "{\"_tag\":\"pong\"}";
33
- /** Client liveness ping; hosts answer with a pong and never ACK-track it. */
34
- const EDAWebSocketWirePingFrame = Schema.Struct({ _tag: Schema.Literal("ping") });
35
- /** Server liveness pong; clients may ignore it and must not ACK it. */
36
- const EDAWebSocketWirePongFrame = Schema.Struct({ _tag: Schema.Literal("pong") });
37
- const EDAWebSocketWireHelloFrame = Schema.Struct({
38
- _tag: Schema.Literal("hello"),
39
- protocolVersion: Schema.Literal(1),
40
- subscriberId: Schema.NonEmptyString,
41
- resumeSeq: NonNegativeInt,
42
- flowControl: EDAWebSocketWireFlowControl
98
+ const EDATranscriptSubscribeFrame = Schema.Struct({
99
+ _tag: Schema.Literal("subscribe"),
100
+ requestId: Schema.optionalKey(TranscriptRequestId),
101
+ range: Schema.optionalKey(TranscriptCoverage),
102
+ tail: Schema.optionalKey(Schema.Boolean),
103
+ since: Schema.optionalKey(SequenceNumber),
104
+ count: Schema.optionalKey(PositiveInt$1)
43
105
  });
44
- const EDAWebSocketWireHeartbeatFrame = Schema.Struct({
45
- _tag: Schema.Literal("heartbeat"),
46
- serverTimeMs: NonNegativeInt,
47
- durableThroughSeq: NonNegativeInt
106
+ /** Extend the coverage from its edge: `cursor` is the coverage's `from` (before) or `to` (after). */
107
+ const EDATranscriptPageFrame = Schema.Struct({
108
+ _tag: Schema.Literal("page"),
109
+ requestId: Schema.optionalKey(TranscriptRequestId),
110
+ direction: Schema.Literals(["before", "after"]),
111
+ cursor: TranscriptCursor,
112
+ count: PositiveInt$1
48
113
  });
49
- const EDAWebSocketWireLaggedFrame = Schema.Struct({
50
- _tag: Schema.Literal("lagged"),
51
- resumeSeq: NonNegativeInt,
52
- reason: Schema.Literals(["buffer-overflow", "ack-timeout"])
114
+ /** Narrow the coverage to a span inside it, so the server stops sending changes outside it. */
115
+ const EDATranscriptRetainFrame = Schema.Struct({
116
+ _tag: Schema.Literal("retain"),
117
+ requestId: Schema.optionalKey(TranscriptRequestId),
118
+ from: TranscriptCursor,
119
+ to: TranscriptCursor
53
120
  });
54
- const EDAWebSocketWireErrorFrame = Schema.Struct({
55
- _tag: Schema.Literal("error"),
56
- message: Schema.String
121
+ /** A client request; each is answered by exactly one update, in arrival order. */
122
+ const EDATranscriptRequestFrame = Schema.Union([
123
+ EDATranscriptSubscribeFrame,
124
+ EDATranscriptPageFrame,
125
+ EDATranscriptRetainFrame
126
+ ]);
127
+ /** Every client frame a transcript socket accepts. */
128
+ const EDATranscriptClientFrame = Schema.Union([
129
+ EDAWebSocketWireAckFrame,
130
+ EDAWebSocketWirePingFrame,
131
+ EDATranscriptSubscribeFrame,
132
+ EDATranscriptPageFrame,
133
+ EDATranscriptRetainFrame
134
+ ]);
135
+ const encodeUpdate = Schema.encodeSync(TranscriptUpdate);
136
+ const encodeServerFrame = Schema.encodeSync(EDATranscriptServerFrame);
137
+ /** Serialize one update once; frames embed this text, chunks slice it. */
138
+ const encodeEDATranscriptUpdate = (update) => JSON.stringify(encodeUpdate(update));
139
+ /** Serialize a non-update server frame. */
140
+ const encodeEDATranscriptServerFrame = (frame) => JSON.stringify(encodeServerFrame(frame));
141
+ /** The single-frame form of an encoded update. */
142
+ const edaTranscriptUpdateFrameText = (frameId, encodedUpdate) => `{"_tag":"transcript","frameId":${frameId},"update":${encodedUpdate}}`;
143
+ /** One chunk frame of an encoded update. */
144
+ const edaTranscriptChunkFrameText = (input) => `{"_tag":"transcript-chunk","frameId":${input.frameId},"updateSeq":${input.updateSeq},"index":${input.index},"count":${input.count},"data":${JSON.stringify(input.data)}}`;
145
+ const textEncoder = new TextEncoder();
146
+ /** UTF-8 byte length of a string. */
147
+ const utf8ByteLength = (text) => textEncoder.encode(text).byteLength;
148
+ /** Bytes a chunk frame spends besides its data, with generous room for large numbers. */
149
+ const chunkFrameOverheadBytes = 160;
150
+ /** Control characters JSON writes as a two-byte escape (`\b`, `\t`, `\n`, `\f`, `\r`). */
151
+ const shortEscapes = /* @__PURE__ */ new Set([
152
+ 8,
153
+ 9,
154
+ 10,
155
+ 12,
156
+ 13
157
+ ]);
158
+ /** UTF-8 bytes one UTF-16 code unit costs inside a JSON string literal. */
159
+ const jsonStringUnitBytes = (code) => {
160
+ if (code === 34 || code === 92) return 2;
161
+ if (code < 32) return shortEscapes.has(code) ? 2 : 6;
162
+ if (code < 128) return 1;
163
+ if (code < 2048) return 2;
164
+ if (code >= 55296 && code <= 57343) return 6;
165
+ return 3;
166
+ };
167
+ /**
168
+ * Split an encoded update into chunk data that each fit a frame of `maxFrameBytes`, never
169
+ * splitting a surrogate pair.
170
+ */
171
+ const splitEDATranscriptUpdate = (encodedUpdate, maxFrameBytes) => {
172
+ const budget = Math.max(16, maxFrameBytes - chunkFrameOverheadBytes);
173
+ const chunks = [];
174
+ let start = 0;
175
+ let bytes = 0;
176
+ for (let index = 0; index < encodedUpdate.length; index += 1) {
177
+ const code = encodedUpdate.charCodeAt(index);
178
+ const pair = code >= 55296 && code <= 56319 && index + 1 < encodedUpdate.length ? encodedUpdate.charCodeAt(index + 1) : void 0;
179
+ const isPair = pair !== void 0 && pair >= 56320 && pair <= 57343;
180
+ const cost = isPair ? 4 : jsonStringUnitBytes(code);
181
+ if (bytes + cost > budget && index > start) {
182
+ chunks.push(encodedUpdate.slice(start, index));
183
+ start = index;
184
+ bytes = 0;
185
+ }
186
+ bytes += cost;
187
+ if (isPair) index += 1;
188
+ }
189
+ if (start < encodedUpdate.length || chunks.length === 0) chunks.push(encodedUpdate.slice(start));
190
+ return chunks;
191
+ };
192
+ //#endregion
193
+ //#region src/websocket/transcript-client.ts
194
+ /** A client that has rendered nothing yet. */
195
+ const emptyEDATranscriptClientState = {
196
+ window: void 0,
197
+ lastFrameId: 0,
198
+ appliedUpdateSeq: 0,
199
+ assembling: void 0
200
+ };
201
+ /** Seed a client from the window its page was server-rendered with. */
202
+ const edaTranscriptClientFromWindow = (window) => ({
203
+ ...emptyEDATranscriptClientState,
204
+ window: {
205
+ incarnation: window.incarnation,
206
+ version: window.version,
207
+ throughSeq: window.throughSeq,
208
+ coverage: transcriptCoverageOf(window),
209
+ hasOlder: window.hasOlder,
210
+ hasNewer: window.hasNewer,
211
+ readiness: window.readiness,
212
+ records: window.records,
213
+ dependencies: window.dependencies,
214
+ activeContent: window.activeContent ?? []
215
+ }
57
216
  });
58
- const EDAWebSocketWireAckFrame = Schema.Struct({
59
- _tag: Schema.Literal("ack"),
60
- frameId: PositiveInt,
61
- durableThroughSeq: NonNegativeInt
217
+ /**
218
+ * Prepare for a new socket: per-socket counters restart and any partial transfer is discarded.
219
+ * The applied window is kept; the next `subscribe` asks for changes since it.
220
+ */
221
+ const edaTranscriptClientReconnected = (state) => ({
222
+ ...emptyEDATranscriptClientState,
223
+ window: state.window
62
224
  });
63
- const EDAWebSocketWireClientFrame = Schema.Union([EDAWebSocketWireAckFrame, EDAWebSocketWirePingFrame]);
64
- /** Complete framework-owned event union present on every EDA WebSocket. */
65
- const EDAFrameworkWebSocketEvent = Schema.Union([EDADurableEvent, EDAEphemeralEvent]);
66
- const makeEDAWebSocketDomainSchemas = (event) => {
67
- const positionedEvent = Schema.Struct({
68
- position: Position,
69
- event
225
+ const decodeUpdateFrame = Schema.decodeUnknownExit(EDATranscriptUpdateFrame);
226
+ const decodeChunkFrame = Schema.decodeUnknownExit(EDATranscriptChunkFrame);
227
+ const decodeUpdate = Schema.decodeUnknownExit(TranscriptUpdate);
228
+ const peek = (value) => {
229
+ if (typeof value !== "object" || value === null) return {};
230
+ const tag = "_tag" in value && typeof value._tag === "string" ? value._tag : void 0;
231
+ const frameId = "frameId" in value && typeof value.frameId === "number" && Number.isInteger(value.frameId) ? value.frameId : void 0;
232
+ return {
233
+ ...tag === void 0 ? {} : { tag },
234
+ ...frameId === void 0 ? {} : { frameId }
235
+ };
236
+ };
237
+ /** Apply one server text message. Frames must arrive in frame-id order without gaps. */
238
+ const applyEDATranscriptServerMessage = (state, message) => {
239
+ let json;
240
+ try {
241
+ json = JSON.parse(message);
242
+ } catch {
243
+ return resubscribe(state, "malformed server message");
244
+ }
245
+ const { tag, frameId } = peek(json);
246
+ switch (tag) {
247
+ case "hello": return {
248
+ state,
249
+ outcome: {
250
+ _tag: "Hello",
251
+ negotiation: negotiateEDATranscript(json)
252
+ }
253
+ };
254
+ case "pong": return {
255
+ state,
256
+ outcome: { _tag: "Ignored" }
257
+ };
258
+ case "lagged":
259
+ case "error": return resubscribe(state, `server sent ${tag}`);
260
+ }
261
+ if (frameId === void 0) return {
262
+ state,
263
+ outcome: { _tag: "Ignored" }
264
+ };
265
+ if (frameId !== state.lastFrameId + 1) return resubscribe(state, "frame gap");
266
+ const received = {
267
+ ...state,
268
+ lastFrameId: frameId
269
+ };
270
+ if (tag === "transcript") {
271
+ const decoded = decodeUpdateFrame(json);
272
+ if (Exit.isFailure(decoded)) return resubscribe(state, "undecodable update");
273
+ if (received.assembling !== void 0) return resubscribe(state, "update interrupted a transfer");
274
+ return applyUpdate(received, decoded.value.update);
275
+ }
276
+ if (tag === "transcript-chunk") {
277
+ const decoded = decodeChunkFrame(json);
278
+ if (Exit.isFailure(decoded)) return resubscribe(state, "undecodable chunk");
279
+ const chunk = decoded.value;
280
+ const assembling = received.assembling ?? {
281
+ updateSeq: chunk.updateSeq,
282
+ count: chunk.count,
283
+ data: []
284
+ };
285
+ if (assembling.updateSeq !== chunk.updateSeq || assembling.count !== chunk.count || assembling.data.length !== chunk.index) return resubscribe(state, "interrupted chunked transfer");
286
+ const data = [...assembling.data, chunk.data];
287
+ if (data.length < chunk.count) {
288
+ const next = {
289
+ ...received,
290
+ assembling: {
291
+ ...assembling,
292
+ data
293
+ }
294
+ };
295
+ return {
296
+ state: next,
297
+ outcome: { _tag: "Partial" },
298
+ ack: ackOf(next)
299
+ };
300
+ }
301
+ let updateJson;
302
+ try {
303
+ updateJson = JSON.parse(data.join(""));
304
+ } catch {
305
+ return resubscribe(state, "malformed chunked update");
306
+ }
307
+ const update = decodeUpdate(updateJson);
308
+ if (Exit.isFailure(update) || update.value.updateSeq !== chunk.updateSeq) return resubscribe(state, "undecodable chunked update");
309
+ return applyUpdate({
310
+ ...received,
311
+ assembling: void 0
312
+ }, update.value);
313
+ }
314
+ return {
315
+ state: received,
316
+ outcome: { _tag: "Ignored" },
317
+ ack: ackOf(received)
318
+ };
319
+ };
320
+ const resubscribe = (state, reason) => ({
321
+ state: {
322
+ ...state,
323
+ assembling: void 0
324
+ },
325
+ outcome: {
326
+ _tag: "Resubscribe",
327
+ reason
328
+ }
329
+ });
330
+ const ackOf = (state) => ({
331
+ _tag: "ack",
332
+ frameId: state.lastFrameId,
333
+ durableThroughSeq: state.appliedUpdateSeq === 0 ? 0 : state.window?.throughSeq ?? 0,
334
+ appliedUpdateSeq: state.appliedUpdateSeq
335
+ });
336
+ const orderKeyOf = (record) => "position" in record && record.position !== void 0 ? {
337
+ ...record.position,
338
+ recordId: record.id
339
+ } : void 0;
340
+ const covered = (coverage, record) => {
341
+ const key = orderKeyOf(record);
342
+ return coverage !== void 0 && key !== void 0 && TranscriptOrder(coverage.from, key) <= 0 && TranscriptOrder(key, coverage.to) <= 0;
343
+ };
344
+ const applyUpdate = (state, update) => {
345
+ if (update.updateSeq !== state.appliedUpdateSeq + 1) return resubscribe(state, "update gap");
346
+ const previous = state.window;
347
+ if (update.mode === "patch" && (previous === void 0 || previous.incarnation !== update.incarnation || previous.version !== update.version)) return resubscribe(state, "patch without its base");
348
+ const base = update.mode === "patch" ? previous : void 0;
349
+ const topLevel = new Map((base?.records ?? []).map((record) => [record.id, record]));
350
+ for (const record of update.records) topLevel.set(record.id, record);
351
+ const records = [...topLevel.values()].filter((record) => covered(update.coverage, record)).sort((left, right) => {
352
+ const leftKey = orderKeyOf(left);
353
+ const rightKey = orderKeyOf(right);
354
+ return leftKey === void 0 || rightKey === void 0 ? 0 : TranscriptOrder(leftKey, rightKey);
70
355
  });
71
- const eventsFrame = Schema.Struct({
72
- _tag: Schema.Literal("events"),
73
- frameId: PositiveInt,
74
- events: Schema.NonEmptyArray(positionedEvent),
75
- durableThroughSeq: NonNegativeInt
356
+ const dependencyMap = new Map((base?.dependencies ?? []).map((record) => [record.id, record]));
357
+ for (const record of update.dependencies) dependencyMap.set(record.id, record);
358
+ const dependencies = update.dependencyIds.flatMap((id) => {
359
+ const record = dependencyMap.get(id);
360
+ return record === void 0 ? [] : [record];
76
361
  });
362
+ if (dependencies.length !== update.dependencyIds.length) return resubscribe(state, "patch referenced a dependency the client does not hold");
363
+ const window = {
364
+ incarnation: update.incarnation,
365
+ version: update.version,
366
+ throughSeq: update.throughSeq,
367
+ coverage: update.coverage,
368
+ hasOlder: update.hasOlder,
369
+ hasNewer: update.hasNewer,
370
+ readiness: update.readiness,
371
+ records,
372
+ dependencies,
373
+ activeContent: update.readiness._tag !== "Ready" ? [] : update.activeContent ?? base?.activeContent ?? []
374
+ };
375
+ const next = {
376
+ ...state,
377
+ window,
378
+ appliedUpdateSeq: update.updateSeq,
379
+ assembling: void 0
380
+ };
77
381
  return {
78
- event,
79
- positionedEvent,
80
- eventsFrame,
81
- serverFrame: Schema.Union([
82
- EDAWebSocketWireHelloFrame,
83
- eventsFrame,
84
- EDAWebSocketWireHeartbeatFrame,
85
- EDAWebSocketWirePongFrame,
86
- EDAWebSocketWireLaggedFrame,
87
- EDAWebSocketWireErrorFrame
88
- ])
382
+ state: next,
383
+ outcome: {
384
+ _tag: "Applied",
385
+ updateSeq: update.updateSeq,
386
+ ...update.requestId === void 0 ? {} : { requestId: update.requestId }
387
+ },
388
+ ack: ackOf(next)
389
+ };
390
+ };
391
+ /**
392
+ * The request a client sends first on every socket: changes since the window it holds over the
393
+ * span it holds, or the latest `count` records when it holds none.
394
+ */
395
+ const edaTranscriptSubscribeRequest = (state, options) => {
396
+ const window = state.window;
397
+ const extra = {
398
+ ...options?.count === void 0 ? {} : { count: options.count },
399
+ ...options?.requestId === void 0 ? {} : { requestId: options.requestId }
400
+ };
401
+ return window?.coverage === void 0 ? {
402
+ _tag: "subscribe",
403
+ ...extra
404
+ } : {
405
+ _tag: "subscribe",
406
+ range: window.coverage,
407
+ tail: !window.hasNewer,
408
+ since: window.throughSeq,
409
+ ...extra
89
410
  };
90
411
  };
91
- makeEDAWebSocketDomainSchemas(EventEnvelope);
92
- const makeEDAWebSocketWireProtocolFromEventSchema = (event) => {
93
- const domain = makeEDAWebSocketDomainSchemas(event);
94
- const encodeDomainServerFrame = Schema.encodeSync(domain.serverFrame);
95
- const encodeUnknownDomainServerFrame = Schema.encodeUnknownSync(domain.serverFrame);
96
- const encodeServerFrame = (frame) => JSON.stringify(encodeDomainServerFrame(frame));
412
+ /** Page from the held coverage's edge, or `undefined` when there is nothing to page from. */
413
+ const edaTranscriptPageRequest = (state, direction, count, requestId) => {
414
+ const coverage = state.window?.coverage;
415
+ if (coverage === void 0) return void 0;
97
416
  return {
98
- domain,
99
- wire: {
100
- event: Schema.toEncoded(domain.event),
101
- positionedEvent: Schema.toEncoded(domain.positionedEvent),
102
- eventsFrame: Schema.toEncoded(domain.eventsFrame),
103
- serverFrame: Schema.toEncoded(domain.serverFrame),
104
- clientFrame: EDAWebSocketWireClientFrame
105
- },
106
- encodeServerFrame,
107
- host: { encodeServerFrame: (frame) => JSON.stringify(encodeUnknownDomainServerFrame(frame)) }
417
+ _tag: "page",
418
+ direction,
419
+ cursor: direction === "before" ? coverage.from : coverage.to,
420
+ count,
421
+ ...requestId === void 0 ? {} : { requestId }
108
422
  };
109
423
  };
110
- /** Strict framework-only protocol used when an app registers no custom events. */
111
- const edaFrameworkWebSocketWireProtocol = makeEDAWebSocketWireProtocolFromEventSchema(EDAFrameworkWebSocketEvent);
112
424
  /**
113
- * Bind the generic EDA WebSocket transport to one app's custom event schema.
114
- *
115
- * Framework durable and ephemeral events are included automatically. Future EDA
116
- * apps register only their custom events. Servers use the returned domain schemas
117
- * and typed encoder; external consumers decode with the wire schemas. Pass the
118
- * returned `host` adapter to the selected host package.
425
+ * Keep only the top-level records from `fromIndex` to `toIndex` (inclusive) of the held window;
426
+ * the server confirms with an update whose coverage is the narrowed span.
119
427
  */
120
- const makeEDAWebSocketWireProtocol = (options) => makeEDAWebSocketWireProtocolFromEventSchema(Schema.Union([EDAFrameworkWebSocketEvent, options.appEvents]));
121
- //#endregion
122
- //#region src/websocket/messages.ts
123
- /** Current EDA live-event WebSocket protocol version. */
124
- const EDA_WEB_SOCKET_PROTOCOL_VERSION = 1;
125
- /** WebSocket close code used when a subscriber cannot keep up with live delivery. */
126
- const EDA_WS_CLOSE_LAGGED = 4008;
127
- /** WebSocket close code used for normal host-driven shutdown. */
128
- const EDA_WS_CLOSE_GOING_AWAY = 1001;
129
- /** WebSocket close code used for malformed client protocol messages. */
130
- const EDA_WS_CLOSE_PROTOCOL_ERROR = 1002;
131
- /** WebSocket close code used when the host cannot send a frame. */
132
- const EDA_WS_CLOSE_SEND_FAILED = 1011;
133
- /** WebSocket close code used for unsupported binary messages. */
134
- const EDA_WS_CLOSE_UNSUPPORTED_DATA = 1003;
135
- /** Live subscriber identity persisted in WebSocket attachments. */
136
- const SubscriberId = Schema.NonEmptyString.pipe(Schema.brand("SubscriberId"));
137
- /** Per-connection monotonically increasing server frame id. */
138
- const FrameId = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("FrameId"));
139
- /** Flow-control policy announced by the server in the hello frame. */
140
- const EDAWebSocketFlowControl = EDAWebSocketWireFlowControl;
141
- /** Default bounded policy sized for fast model deltas and large durable tool/message events. */
142
- const defaultEDAWebSocketFlowControl = {
143
- ackTimeoutMs: 3e4,
144
- heartbeatIntervalMs: 1e4,
145
- maxFrameBytes: 256 * 1024,
146
- maxFrameEvents: 1,
147
- maxInFlightFrames: 16,
148
- pingIntervalMs: 3e4,
149
- subscriberBufferCapacityEvents: 2048
428
+ const edaTranscriptRetainRequest = (state, fromIndex, toIndex, requestId) => {
429
+ const window = state.window;
430
+ const from = window?.records[fromIndex];
431
+ const to = window?.records[toIndex];
432
+ const fromKey = from === void 0 ? void 0 : orderKeyOf(from);
433
+ const toKey = to === void 0 ? void 0 : orderKeyOf(to);
434
+ if (window === void 0 || fromKey === void 0 || toKey === void 0) return void 0;
435
+ const scope = {
436
+ incarnation: window.incarnation,
437
+ version: window.version
438
+ };
439
+ return {
440
+ _tag: "retain",
441
+ from: {
442
+ ...scope,
443
+ ...fromKey,
444
+ anchorSeq: SequenceNumber.make(fromKey.anchorSeq)
445
+ },
446
+ to: {
447
+ ...scope,
448
+ ...toKey,
449
+ anchorSeq: SequenceNumber.make(toKey.anchorSeq)
450
+ },
451
+ ...requestId === void 0 ? {} : { requestId }
452
+ };
150
453
  };
151
- /** First server frame; announces protocol and flow-control policy. */
152
- const EDAWebSocketHelloFrame = Schema.Struct({
153
- ...EDAWebSocketWireHelloFrame.fields,
154
- subscriberId: SubscriberId,
155
- resumeSeq: SequenceNumber
156
- });
157
- /** Ordered positioned events delivered to the client. */
158
- const EDAWebSocketEventsFrame = Schema.Struct({
159
- _tag: Schema.Literal("events"),
160
- frameId: FrameId,
161
- events: Schema.NonEmptyArray(PositionedEvent),
162
- durableThroughSeq: SequenceNumber
454
+ //#endregion
455
+ //#region src/websocket/transcript-delivery.ts
456
+ const PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
457
+ const NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
458
+ /** A chunked update whose frames are not all sent yet; its chunk data is volatile. */
459
+ const EDATranscriptTransfer = Schema.Struct({
460
+ updateSeq: PositiveInt,
461
+ throughSeq: SequenceNumber,
462
+ count: PositiveInt,
463
+ nextIndex: NonNegativeInt
163
464
  });
164
465
  /**
165
- * Deprecated idle server keepalive frame.
466
+ * Everything a transcript socket needs to resume after hibernation, persisted in its attachment
467
+ * before every send and after every applied ACK.
166
468
  *
167
- * Servers no longer send heartbeats; the schema remains so deployed clients
168
- * keep decoding the server frame union. Liveness is client-originated via
169
- * {@link EDAWebSocketPingFrame} and the host-level auto-response pong.
469
+ * Transport receipts (`inFlight`, `lastAckedFrameId`) bound frames in flight exactly as on an
470
+ * event socket. The applied cut (`appliedUpdateSeq`, `appliedThroughSeq`) is the last update the
471
+ * client applied completely. `subscription` is the base the next update is planned against, and
472
+ * `requests` are client requests not yet answered. A persisted `transfer` means chunk data was
473
+ * staged in memory; a socket restored with one cannot finish it and is closed.
170
474
  */
171
- const EDAWebSocketHeartbeatFrame = Schema.Struct({
172
- ...EDAWebSocketWireHeartbeatFrame.fields,
173
- serverTimeMs: UnixEpochMillis,
174
- durableThroughSeq: SequenceNumber
175
- });
176
- /** Client liveness ping; hosts answer with a pong and never ACK-track it. */
177
- const EDAWebSocketPingFrame = EDAWebSocketWirePingFrame;
178
- /** Server liveness pong; clients may ignore it and must not ACK it. */
179
- const EDAWebSocketPongFrame = EDAWebSocketWirePongFrame;
180
- /** Optional final frame sent before a lag-close. */
181
- const EDAWebSocketLaggedFrame = Schema.Struct({
182
- ...EDAWebSocketWireLaggedFrame.fields,
183
- resumeSeq: SequenceNumber
184
- });
185
- /** Optional final frame sent before a protocol/internal close. */
186
- const EDAWebSocketErrorFrame = EDAWebSocketWireErrorFrame;
187
- /** Server-to-client application frame union. */
188
- const EDAWebSocketServerFrame = Schema.Union([
189
- EDAWebSocketHelloFrame,
190
- EDAWebSocketEventsFrame,
191
- EDAWebSocketHeartbeatFrame,
192
- EDAWebSocketPongFrame,
193
- EDAWebSocketLaggedFrame,
194
- EDAWebSocketErrorFrame
195
- ]);
196
- /** Client acknowledgement after applying a server frame. */
197
- const EDAWebSocketAckFrame = Schema.Struct({
198
- ...EDAWebSocketWireAckFrame.fields,
199
- frameId: FrameId,
200
- durableThroughSeq: SequenceNumber
201
- });
202
- /** Client-to-server application frame union. */
203
- const EDAWebSocketClientFrame = Schema.Union([EDAWebSocketAckFrame, EDAWebSocketPingFrame]);
204
- /** Serialize a server frame for a text WebSocket message. */
205
- const encodeEDAWebSocketServerFrame = (frame, protocol) => (protocol ?? edaFrameworkWebSocketWireProtocol.host).encodeServerFrame(frame);
206
- /** Decode an inbound text WebSocket message at the host boundary. */
207
- const decodeEDAWebSocketClientMessage = (input) => Effect.try({
208
- try: () => JSON.parse(input),
209
- catch: (error) => error
210
- }).pipe(Effect.flatMap((json) => Schema.decodeUnknownEffect(EDAWebSocketWireClientFrame)(json)), Effect.flatMap((frame) => Schema.decodeUnknownEffect(EDAWebSocketClientFrame)(frame)));
211
- /** Short close reason that fits the WebSocket protocol reason limit. */
212
- const laggedCloseReason = (seq) => `lag;seq=${seq}`;
213
- //#endregion
214
- //#region src/websocket/delivery.ts
215
- /** Slow subscriber reasons that intentionally close only the lagging socket. */
216
- const SubscriberLagReason = Schema.Literals(["buffer-overflow", "ack-timeout"]);
217
- /** One sent-but-unacknowledged events frame. */
218
- const EDAWebSocketInFlightFrame = Schema.Struct({
219
- frameId: FrameId,
220
- durableThroughSeq: SequenceNumber,
221
- sentAtMs: Schema.Number
222
- });
223
- /** Compact consecutive host-suppressed receipts blocked by a visible ACK. */
224
- const EDAWebSocketSuppressedRange = Schema.Struct({
225
- fromFrameId: FrameId,
226
- throughFrameId: FrameId,
227
- durableThroughSeq: SequenceNumber
228
- });
229
- /** Complete delivery bookkeeping persisted in the WebSocket attachment. */
230
- const EDAWebSocketDeliveryCheckpoint = Schema.Struct({
231
- lastAckedSeq: SequenceNumber,
232
- lastAckedFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
233
- lastSentFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
234
- nextFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
235
- sentDurableThroughSeq: SequenceNumber,
236
- inFlight: Schema.Array(EDAWebSocketInFlightFrame),
237
- /** Host-projected receipts waiting behind an earlier client-visible ACK. */
238
- suppressed: Schema.optionalKey(Schema.Array(EDAWebSocketSuppressedRange))
475
+ const EDATranscriptDeliveryCheckpoint = Schema.Struct({
476
+ lastAckedFrameId: NonNegativeInt,
477
+ nextFrameId: PositiveInt,
478
+ inFlight: Schema.Array(Schema.Struct({
479
+ frameId: PositiveInt,
480
+ sentAtMs: Schema.Number
481
+ })),
482
+ nextUpdateSeq: PositiveInt,
483
+ completedUpdateSeq: NonNegativeInt,
484
+ completedThroughSeq: SequenceNumber,
485
+ appliedUpdateSeq: NonNegativeInt,
486
+ appliedThroughSeq: SequenceNumber,
487
+ transfer: Schema.optionalKey(EDATranscriptTransfer),
488
+ subscription: Schema.optionalKey(TranscriptSubscriptionBase),
489
+ requests: Schema.Array(EDATranscriptRequestFrame)
239
490
  });
240
- /** Build delivery state for a newly accepted connection. */
241
- const makeWebSocketDeliveryState = (input) => ({
242
- subscriberId: input.subscriberId,
243
- policy: input.policy,
244
- lastAckedSeq: input.resumeSeq,
491
+ const defaultEDATranscriptDeliveryLimits = {
492
+ maxStagedBytes: 8388608,
493
+ maxPendingRequests: 4
494
+ };
495
+ /** Delivery state for a newly accepted transcript socket. */
496
+ const makeTranscriptDeliveryState = (policy) => ({
497
+ policy,
245
498
  lastAckedFrameId: 0,
246
- lastSentFrameId: 0,
247
499
  nextFrameId: 1,
248
- sentDurableThroughSeq: input.resumeSeq,
249
500
  inFlight: [],
250
- suppressed: [],
251
- pendingEphemeral: []
252
- });
253
- /** Rebuild exact ACK bookkeeping from a hibernating WebSocket attachment. */
254
- const restoreWebSocketDeliveryState = (input) => ({
255
- subscriberId: input.subscriberId,
256
- policy: input.policy,
257
- ...input.checkpoint,
258
- pendingEphemeral: [],
259
- suppressed: input.checkpoint.suppressed ?? []
501
+ nextUpdateSeq: 1,
502
+ completedUpdateSeq: 0,
503
+ completedThroughSeq: SequenceNumber.make(0),
504
+ appliedUpdateSeq: 0,
505
+ appliedThroughSeq: SequenceNumber.make(0),
506
+ requests: [],
507
+ staged: []
260
508
  });
261
- /** Project in-memory delivery state into the attachment-safe checkpoint. */
262
- const checkpointWebSocketDeliveryState = (state) => ({
263
- lastAckedSeq: state.lastAckedSeq,
509
+ /**
510
+ * Restore a hibernated transcript socket. A socket that was mid-transfer lost its staged chunks
511
+ * with the isolate and cannot resume: the caller closes it and the client resubscribes.
512
+ */
513
+ const restoreTranscriptDeliveryState = (policy, checkpoint) => checkpoint.transfer === void 0 ? {
514
+ _tag: "Restored",
515
+ state: {
516
+ ...checkpoint,
517
+ policy,
518
+ staged: []
519
+ }
520
+ } : { _tag: "TransferLost" };
521
+ /** The attachment-safe part of the state. */
522
+ const checkpointTranscriptDelivery = (state) => ({
264
523
  lastAckedFrameId: state.lastAckedFrameId,
265
- lastSentFrameId: state.lastSentFrameId,
266
524
  nextFrameId: state.nextFrameId,
267
- sentDurableThroughSeq: state.sentDurableThroughSeq,
268
525
  inFlight: state.inFlight,
269
- ...state.suppressed.length === 0 ? {} : { suppressed: state.suppressed }
270
- });
271
- /** First frame for a freshly accepted connection. Restores never re-send hello. */
272
- const deliveryHelloFrame = (state) => EDAWebSocketHelloFrame.make({
273
- _tag: "hello",
274
- protocolVersion: EDA_WEB_SOCKET_PROTOCOL_VERSION,
275
- subscriberId: state.subscriberId,
276
- resumeSeq: state.lastAckedSeq,
277
- flowControl: state.policy
526
+ nextUpdateSeq: state.nextUpdateSeq,
527
+ completedUpdateSeq: state.completedUpdateSeq,
528
+ completedThroughSeq: state.completedThroughSeq,
529
+ appliedUpdateSeq: state.appliedUpdateSeq,
530
+ appliedThroughSeq: state.appliedThroughSeq,
531
+ ...state.transfer === void 0 ? {} : { transfer: state.transfer },
532
+ ...state.subscription === void 0 ? {} : { subscription: state.subscription },
533
+ requests: state.requests
278
534
  });
279
- /** Deliver committed durable events read from the store. */
280
- const onDurableEvents = (state, events, head, nowMs) => {
281
- const stale = staleAckResult(state, nowMs);
282
- if (stale !== void 0) return stale;
283
- let next = state;
284
- const frames = [];
285
- let batch = [];
286
- const flushBatch = () => {
287
- if (batch.length === 0) return;
288
- const sent = sendEventsFrame(next, batch, nowMs);
289
- next = sent.state;
290
- frames.push(sent.frame);
291
- batch = [];
292
- };
293
- for (const event of events) {
294
- if (event.event.durability === "durable" && event.position.seq <= next.sentDurableThroughSeq) continue;
295
- if (batch.length === 0 && windowCapacity(next) <= 0) break;
296
- batch.push(event);
297
- if (batch.length >= next.policy.maxFrameEvents) flushBatch();
298
- }
299
- flushBatch();
300
- return sentResult(next, frames, windowCapacity(next) > 0 && next.sentDurableThroughSeq < head ? next.sentDurableThroughSeq : void 0);
301
- };
302
- /** Deliver one live ephemeral event, buffering only while this isolate is active. */
303
- const onEphemeralEvent = (state, event, nowMs) => {
304
- const stale = staleAckResult(state, nowMs);
305
- if (stale !== void 0) return stale;
306
- if (windowCapacity(state) > 0 && state.pendingEphemeral.length === 0) {
307
- const sent = sendEventsFrame(state, [event], nowMs);
308
- return sentResult(sent.state, [sent.frame]);
309
- }
310
- const pendingEphemeral = [...state.pendingEphemeral, event];
311
- if (pendingEphemeral.length > state.policy.subscriberBufferCapacityEvents) return laggedResult(state, "buffer-overflow");
312
- return {
313
- state: {
314
- ...state,
315
- pendingEphemeral
316
- },
317
- actions: []
318
- };
319
- };
320
- /** Apply one client ACK, reopen the window, and drain buffered ephemeral events. */
321
- const onClientAck = (state, ack, nowMs) => {
322
- const validated = applyAck(state, ack);
323
- if (validated._tag === "close") return validated.result;
324
- if (validated._tag === "ignore") return {
325
- state,
326
- actions: []
327
- };
328
- return reopenDeliveryWindow(validated.state, nowMs);
329
- };
535
+ /** Frames that may be sent before the client's next receipt. */
536
+ const transcriptDeliveryCapacity = (state) => state.policy.maxInFlightFrames - state.inFlight.length;
537
+ /** Lazily enforced ACK deadline: no resident timer, checked on each transition. */
538
+ const transcriptAckTimedOut = (state, nowMs) => state.inFlight.some((frame) => frame.sentAtMs + state.policy.ackTimeoutMs <= nowMs);
330
539
  /**
331
- * Apply one exact host-suppressed receipt without cumulatively ACKing any
332
- * earlier client-visible frame.
540
+ * Start sending one planned update, captured from its own snapshot.
541
+ *
542
+ * `subscription` becomes the base for the next update immediately: nothing else is sent until
543
+ * this update's last frame is, so the client can only apply later updates on top of it. An
544
+ * update within the frame limit is one frame; a larger one is chunked and as many chunks as
545
+ * flow control allows are sent now, the rest staged.
333
546
  */
334
- const onHostSuppressedFrame = (state, frame, nowMs) => {
335
- const receipt = state.inFlight.find((candidate) => candidate.frameId === frame.frameId);
336
- if (receipt === void 0 || receipt.durableThroughSeq !== frame.durableThroughSeq) return protocolClose(state, "Host suppressed an unknown frame receipt").result;
337
- return reopenDeliveryWindow(advanceSuppressedReceipts({
547
+ const startTranscriptUpdate = (state, input, limits, nowMs) => {
548
+ if (state.transfer !== void 0) throw new Error("A transcript update cannot start while another is being transferred");
549
+ if (input.update.updateSeq !== state.nextUpdateSeq) throw new Error("A transcript update must carry the socket's next update seq");
550
+ const updateSeq = input.update.updateSeq;
551
+ const advanced = {
338
552
  ...state,
339
- inFlight: state.inFlight.filter((candidate) => candidate.frameId !== frame.frameId),
340
- suppressed: insertSuppressedReceipt(state.suppressed, receipt)
341
- }), nowMs);
553
+ nextUpdateSeq: updateSeq + 1,
554
+ subscription: input.subscription
555
+ };
556
+ const single = edaTranscriptUpdateFrameText(state.nextFrameId, input.encodedUpdate);
557
+ if (utf8ByteLength(single) <= state.policy.maxFrameBytes) return {
558
+ _tag: "Sending",
559
+ ...sendFrames({
560
+ ...advanced,
561
+ completedUpdateSeq: updateSeq,
562
+ completedThroughSeq: input.update.throughSeq
563
+ }, [single], nowMs)
564
+ };
565
+ const bytes = utf8ByteLength(input.encodedUpdate);
566
+ if (bytes > limits.maxStagedBytes) return {
567
+ _tag: "TooLarge",
568
+ bytes
569
+ };
570
+ const chunks = splitEDATranscriptUpdate(input.encodedUpdate, state.policy.maxFrameBytes);
571
+ return {
572
+ _tag: "Sending",
573
+ ...pumpTranscriptTransfer({
574
+ ...advanced,
575
+ transfer: {
576
+ updateSeq,
577
+ throughSeq: input.update.throughSeq,
578
+ count: chunks.length,
579
+ nextIndex: 0
580
+ },
581
+ staged: chunks
582
+ }, nowMs)
583
+ };
342
584
  };
343
- const reopenDeliveryWindow = (state, nowMs) => {
585
+ /** Send staged chunks of the transfer in progress while flow control allows. */
586
+ const pumpTranscriptTransfer = (state, nowMs) => {
344
587
  let next = state;
345
588
  const frames = [];
346
- while (next.pendingEphemeral.length > 0 && windowCapacity(next) > 0) {
347
- const [head, ...rest] = next.pendingEphemeral;
348
- if (head === void 0) break;
349
- const sent = sendEventsFrame({
589
+ while (next.transfer !== void 0 && transcriptDeliveryCapacity(next) > 0) {
590
+ const transfer = next.transfer;
591
+ const [data, ...rest] = next.staged;
592
+ if (data === void 0) break;
593
+ const text = edaTranscriptChunkFrameText({
594
+ frameId: next.nextFrameId,
595
+ updateSeq: transfer.updateSeq,
596
+ index: transfer.nextIndex,
597
+ count: transfer.count,
598
+ data
599
+ });
600
+ const nextIndex = transfer.nextIndex + 1;
601
+ const done = nextIndex === transfer.count;
602
+ const { transfer: _sent, ...withoutTransfer } = next;
603
+ const sent = sendFrames(done ? {
604
+ ...withoutTransfer,
605
+ staged: [],
606
+ completedUpdateSeq: transfer.updateSeq,
607
+ completedThroughSeq: transfer.throughSeq
608
+ } : {
350
609
  ...next,
351
- pendingEphemeral: rest
352
- }, [head], nowMs);
610
+ staged: rest,
611
+ transfer: {
612
+ ...transfer,
613
+ nextIndex
614
+ }
615
+ }, [text], nowMs);
353
616
  next = sent.state;
354
- frames.push(sent.frame);
617
+ frames.push(...sent.frames);
355
618
  }
356
- const stale = staleAckResult(next, nowMs);
357
- if (stale !== void 0) return stale;
358
- return sentResult(next, frames, windowCapacity(next) > 0 && next.pendingEphemeral.length === 0 ? next.sentDurableThroughSeq : void 0, true);
619
+ return {
620
+ state: next,
621
+ frames
622
+ };
359
623
  };
360
- const applyAck = (state, ack) => {
361
- if (ack.frameId <= state.lastAckedFrameId) return ack.durableThroughSeq > state.lastAckedSeq ? protocolClose(state, "Duplicate ACK attempted to advance durable seq") : { _tag: "ignore" };
362
- if (ack.frameId > state.lastSentFrameId) return protocolClose(state, "ACK referenced an unsent frame");
363
- if (ack.durableThroughSeq < state.lastAckedSeq) return protocolClose(state, "ACK durable seq moved backwards");
364
- const acknowledgedVisible = state.inFlight.filter((frame) => frame.frameId <= ack.frameId);
365
- if (acknowledgedVisible.length === 0) return protocolClose(state, "ACK referenced no in-flight frames");
366
- if (state.suppressed.some((range) => range.fromFrameId <= ack.frameId && ack.frameId <= range.throughFrameId)) return protocolClose(state, "ACK referenced a host-suppressed frame");
367
- const acknowledgedSuppressed = state.suppressed.filter((range) => range.throughFrameId <= ack.frameId);
368
- const acknowledged = [...acknowledgedVisible, ...acknowledgedSuppressed];
369
- const allowedDurableSeq = SequenceNumber.make(acknowledged.reduce((max, receipt) => Math.max(max, receipt.durableThroughSeq), state.lastAckedSeq));
370
- if (ack.durableThroughSeq > allowedDurableSeq) return protocolClose(state, "ACK durable seq exceeded sent frame boundary");
624
+ const sendFrames = (state, texts, nowMs) => {
625
+ const inFlight = texts.map((_, index) => ({
626
+ frameId: state.nextFrameId + index,
627
+ sentAtMs: nowMs
628
+ }));
371
629
  return {
372
- _tag: "apply",
373
- state: advanceSuppressedReceipts({
630
+ state: {
374
631
  ...state,
375
- inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),
376
- lastAckedFrameId: ack.frameId,
377
- lastAckedSeq: ack.durableThroughSeq,
378
- suppressed: state.suppressed.filter((range) => range.throughFrameId > ack.frameId)
379
- })
632
+ inFlight: [...state.inFlight, ...inFlight],
633
+ nextFrameId: state.nextFrameId + texts.length
634
+ },
635
+ frames: texts
380
636
  };
381
637
  };
382
- const advanceSuppressedReceipts = (state) => {
383
- let lastAckedFrameId = state.lastAckedFrameId;
384
- let lastAckedSeq = state.lastAckedSeq;
385
- let consumed = 0;
386
- for (const range of state.suppressed) {
387
- if (range.fromFrameId !== lastAckedFrameId + 1) break;
388
- lastAckedFrameId = range.throughFrameId;
389
- lastAckedSeq = SequenceNumber.make(Math.max(lastAckedSeq, range.durableThroughSeq));
390
- consumed += 1;
391
- }
392
- return consumed === 0 ? state : {
393
- ...state,
394
- lastAckedFrameId,
395
- lastAckedSeq,
396
- suppressed: state.suppressed.slice(consumed)
638
+ /**
639
+ * Apply one ACK. The receipt frees flow-control capacity cumulatively; the applied cut may only
640
+ * name an update whose frames were all sent, and never moves backwards.
641
+ */
642
+ const onTranscriptAck = (state, ack) => {
643
+ const appliedUpdateSeq = ack.appliedUpdateSeq ?? state.appliedUpdateSeq;
644
+ const advancesApplied = appliedUpdateSeq > state.appliedUpdateSeq;
645
+ if (ack.frameId <= state.lastAckedFrameId) return advancesApplied ? {
646
+ _tag: "ProtocolError",
647
+ message: "Duplicate ACK attempted to advance the applied cut"
648
+ } : { _tag: "Ignored" };
649
+ if (ack.frameId >= state.nextFrameId) return {
650
+ _tag: "ProtocolError",
651
+ message: "ACK referenced an unsent frame"
652
+ };
653
+ if (appliedUpdateSeq < state.appliedUpdateSeq) return {
654
+ _tag: "ProtocolError",
655
+ message: "ACK applied cut moved backwards"
656
+ };
657
+ if (appliedUpdateSeq > state.completedUpdateSeq) return {
658
+ _tag: "ProtocolError",
659
+ message: "ACK applied an incomplete update"
660
+ };
661
+ if (advancesApplied && appliedUpdateSeq === state.completedUpdateSeq && ack.durableThroughSeq !== state.completedThroughSeq) return {
662
+ _tag: "ProtocolError",
663
+ message: "ACK applied cut names another update's seq"
397
664
  };
398
- };
399
- const insertSuppressedReceipt = (ranges, receipt) => {
400
- const inserted = [...ranges, EDAWebSocketSuppressedRange.make({
401
- fromFrameId: receipt.frameId,
402
- throughFrameId: receipt.frameId,
403
- durableThroughSeq: receipt.durableThroughSeq
404
- })].sort((left, right) => left.fromFrameId - right.fromFrameId);
405
- const compacted = [];
406
- for (const range of inserted) {
407
- const previous = compacted.at(-1);
408
- if (previous === void 0 || range.fromFrameId > previous.throughFrameId + 1) {
409
- compacted.push(range);
410
- continue;
411
- }
412
- compacted[compacted.length - 1] = EDAWebSocketSuppressedRange.make({
413
- fromFrameId: previous.fromFrameId,
414
- throughFrameId: FrameId.make(Math.max(previous.throughFrameId, range.throughFrameId)),
415
- durableThroughSeq: SequenceNumber.make(Math.max(previous.durableThroughSeq, range.durableThroughSeq))
416
- });
417
- }
418
- return compacted;
419
- };
420
- const windowCapacity = (state) => state.policy.maxInFlightFrames - state.inFlight.length;
421
- const sendEventsFrame = (state, events, nowMs) => {
422
- const [first, ...rest] = events;
423
- if (first === void 0) throw new Error("Cannot send an empty events frame");
424
- const frameId = FrameId.make(state.nextFrameId);
425
- const durableThroughSeq = SequenceNumber.make(events.reduce((max, event) => event.event.durability === "durable" ? Math.max(max, event.position.seq) : max, state.sentDurableThroughSeq));
426
- const frame = EDAWebSocketEventsFrame.make({
427
- _tag: "events",
428
- frameId,
429
- events: [first, ...rest],
430
- durableThroughSeq
431
- });
432
665
  return {
666
+ _tag: "Applied",
433
667
  state: {
434
668
  ...state,
435
- inFlight: [...state.inFlight, {
436
- frameId,
437
- durableThroughSeq,
438
- sentAtMs: nowMs
439
- }],
440
- lastSentFrameId: frameId,
441
- nextFrameId: frameId + 1,
442
- sentDurableThroughSeq: durableThroughSeq
443
- },
444
- frame
669
+ lastAckedFrameId: ack.frameId,
670
+ inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),
671
+ appliedUpdateSeq,
672
+ appliedThroughSeq: advancesApplied ? SequenceNumber.make(ack.durableThroughSeq) : state.appliedThroughSeq
673
+ }
445
674
  };
446
675
  };
447
- const sentResult = (state, frames, catchUpAfterSeq, stateChanged = frames.length > 0) => ({
448
- state,
449
- actions: [
450
- ...stateChanged ? [{ _tag: "Persist" }] : [],
451
- ...frames.length > 0 ? [{
452
- _tag: "Send",
453
- frames
454
- }] : [],
455
- ...catchUpAfterSeq === void 0 ? [] : [{
456
- _tag: "ReadEventPage",
457
- afterSeq: catchUpAfterSeq
458
- }]
459
- ]
460
- });
461
- /** Lazily enforce the ACK deadline: no resident timer, checked on each transition. */
462
- const staleAckResult = (state, nowMs) => state.inFlight.some((frame) => frame.sentAtMs + state.policy.ackTimeoutMs <= nowMs) ? laggedResult(state, "ack-timeout") : void 0;
463
- const laggedResult = (state, reason) => ({
464
- state,
465
- actions: [{
466
- _tag: "Send",
467
- frames: [EDAWebSocketLaggedFrame.make({
468
- _tag: "lagged",
469
- resumeSeq: state.lastAckedSeq,
470
- reason
471
- })]
472
- }, {
473
- _tag: "Close",
474
- code: EDA_WS_CLOSE_LAGGED,
475
- reason: laggedCloseReason(state.lastAckedSeq)
476
- }]
477
- });
478
- const protocolClose = (state, message) => ({
479
- _tag: "close",
480
- result: {
481
- state,
482
- actions: [{
483
- _tag: "Send",
484
- frames: [EDAWebSocketErrorFrame.make({
485
- _tag: "error",
486
- message: message.slice(0, 120)
487
- })]
488
- }, {
489
- _tag: "Close",
490
- code: EDA_WS_CLOSE_PROTOCOL_ERROR,
491
- reason: "protocol"
492
- }]
493
- }
494
- });
676
+ /** Queue one client request, or report that the client exceeded its request bound. */
677
+ const enqueueTranscriptRequest = (state, request, limits) => state.requests.length >= limits.maxPendingRequests ? void 0 : {
678
+ ...state,
679
+ requests: [...state.requests, request]
680
+ };
495
681
  //#endregion
496
- export { EDAFrameworkWebSocketEvent, EDAWebSocketAckFrame, EDAWebSocketClientFrame, EDAWebSocketDeliveryCheckpoint, EDAWebSocketErrorFrame, EDAWebSocketEventsFrame, EDAWebSocketFlowControl, EDAWebSocketHeartbeatFrame, EDAWebSocketHelloFrame, EDAWebSocketInFlightFrame, EDAWebSocketLaggedFrame, EDAWebSocketPingFrame, EDAWebSocketPongFrame, EDAWebSocketServerFrame, EDAWebSocketSuppressedRange, EDAWebSocketWireAckFrame, EDAWebSocketWireClientFrame, EDAWebSocketWireErrorFrame, EDAWebSocketWireFlowControl, EDAWebSocketWireHeartbeatFrame, EDAWebSocketWireHelloFrame, EDAWebSocketWireLaggedFrame, EDAWebSocketWirePingFrame, EDAWebSocketWirePongFrame, EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE, EDA_WEB_SOCKET_PROTOCOL_VERSION, EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, EDA_WS_CLOSE_GOING_AWAY, EDA_WS_CLOSE_LAGGED, EDA_WS_CLOSE_PROTOCOL_ERROR, EDA_WS_CLOSE_SEND_FAILED, EDA_WS_CLOSE_UNSUPPORTED_DATA, FrameId, SubscriberId, SubscriberLagReason, checkpointWebSocketDeliveryState, decodeEDAWebSocketClientMessage, defaultEDAWebSocketFlowControl, deliveryHelloFrame, edaFrameworkWebSocketWireProtocol, encodeEDAWebSocketServerFrame, laggedCloseReason, makeEDAWebSocketWireProtocol, makeWebSocketDeliveryState, onClientAck, onDurableEvents, onEphemeralEvent, onHostSuppressedFrame, restoreWebSocketDeliveryState };
682
+ export { EDAFrameworkWebSocketEvent, EDATranscriptChunkFrame, EDATranscriptClientFrame, EDATranscriptDeliveryCheckpoint, EDATranscriptHelloFrame, EDATranscriptNegotiation, EDATranscriptPageFrame, EDATranscriptRequestFrame, EDATranscriptRetainFrame, EDATranscriptServerFrame, EDATranscriptSubscribeFrame, EDATranscriptTransfer, EDATranscriptUpdateFrame, EDAWebSocketAckFrame, EDAWebSocketClientFrame, EDAWebSocketDeliveryCheckpoint, EDAWebSocketErrorFrame, EDAWebSocketEventsFrame, EDAWebSocketFlowControl, EDAWebSocketHeartbeatFrame, EDAWebSocketHelloFrame, EDAWebSocketInFlightFrame, EDAWebSocketLaggedFrame, EDAWebSocketPingFrame, EDAWebSocketPongFrame, EDAWebSocketServerFrame, EDAWebSocketSuppressedRange, EDAWebSocketWireAckFrame, EDAWebSocketWireClientFrame, EDAWebSocketWireErrorFrame, EDAWebSocketWireFlowControl, EDAWebSocketWireHeartbeatFrame, EDAWebSocketWireHelloFrame, EDAWebSocketWireLaggedFrame, EDAWebSocketWirePingFrame, EDAWebSocketWirePongFrame, EDA_TRANSCRIPT_PROTOCOL_MAJOR, EDA_TRANSCRIPT_WIRE_VERSION, EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE, EDA_WEB_SOCKET_PROTOCOL_VERSION, EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, EDA_WS_CLOSE_GOING_AWAY, EDA_WS_CLOSE_LAGGED, EDA_WS_CLOSE_PROTOCOL_ERROR, EDA_WS_CLOSE_SEND_FAILED, EDA_WS_CLOSE_TRANSCRIPT_RESUBSCRIBE, EDA_WS_CLOSE_UNSUPPORTED_DATA, FrameId, SubscriberId, SubscriberLagReason, applyEDATranscriptServerMessage, checkpointTranscriptDelivery, checkpointWebSocketDeliveryState, decodeEDAWebSocketClientMessage, defaultEDATranscriptDeliveryLimits, defaultEDAWebSocketFlowControl, deliveryHelloFrame, edaFrameworkWebSocketWireProtocol, edaTranscriptChunkFrameText, edaTranscriptClientFromWindow, edaTranscriptClientReconnected, edaTranscriptNegotiation, edaTranscriptPageRequest, edaTranscriptRetainRequest, edaTranscriptSubscribeRequest, edaTranscriptUpdateFrameText, emptyEDATranscriptClientState, encodeEDATranscriptServerFrame, encodeEDATranscriptUpdate, encodeEDAWebSocketServerFrame, enqueueTranscriptRequest, laggedCloseReason, makeEDAWebSocketWireProtocol, makeTranscriptDeliveryState, makeWebSocketDeliveryState, negotiateEDATranscript, onClientAck, onDurableEvents, onEphemeralEvent, onHostSuppressedFrame, onTranscriptAck, pumpTranscriptTransfer, restoreTranscriptDeliveryState, restoreWebSocketDeliveryState, splitEDATranscriptUpdate, startTranscriptUpdate, transcriptAckTimedOut, transcriptDeliveryCapacity, utf8ByteLength };
497
683
 
498
684
  //# sourceMappingURL=websocket.js.map