effect-durable-agent 0.1.0-alpha.7 → 0.1.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{command-queues-C8muEqeQ.d.ts → command-queues-DdDB_aYM.d.ts} +11 -18
- package/dist/{compaction-D7W0-Ur1.d.ts → compaction-BEor3jKv.d.ts} +27 -8
- package/dist/compaction-BgDr5VJy.js +473 -0
- package/dist/compaction-BgDr5VJy.js.map +1 -0
- package/dist/{context-projection-C43pyxn2.d.ts → context-projection-n6Rdup0N.d.ts} +2 -2
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/context-projection.d.ts +1 -1
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/model-usage.d.ts +2 -0
- package/dist/domain/model-usage.js +59 -0
- package/dist/domain/model-usage.js.map +1 -0
- package/dist/domain/reduced-state-schema.d.ts +11 -17
- package/dist/domain/reduced-state-schema.js +6 -11
- package/dist/domain/reduced-state-schema.js.map +1 -1
- package/dist/domain/reduced-state.d.ts +3 -2
- package/dist/domain/reduced-state.js +3 -2
- package/dist/{durable-DsV9PxZC.js → durable-BGFvX7Mh.js} +17 -80
- package/dist/durable-BGFvX7Mh.js.map +1 -0
- package/dist/{durable-B7M6TD_0.d.ts → durable-br2C1bWK.d.ts} +247 -4
- package/dist/envelope-DkZyMIgp.d.ts +191 -0
- package/dist/envelope-DxQzo5rN.js +82 -0
- package/dist/envelope-DxQzo5rN.js.map +1 -0
- package/dist/{event-factory-tcpLgdMN.js → event-factory-DTFdy0Cb.js} +3 -2
- package/dist/{event-factory-tcpLgdMN.js.map → event-factory-DTFdy0Cb.js.map} +1 -1
- package/dist/{event-factory-CLJcyymV.d.ts → event-factory-pFzsPlDs.d.ts} +4 -4
- package/dist/{events-Bb9-Cu-7.d.ts → events-LZFNoESe.d.ts} +2 -188
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -3
- package/dist/{message-transcript-DsKTT47f.d.ts → message-transcript-DQNlzxle.d.ts} +3 -3
- package/dist/model-resolver-BPPJAsuh.d.ts +18 -0
- package/dist/model-usage-CdBEkTwU.d.ts +55 -0
- package/dist/{prompt-projector-hqPh5-NI.d.ts → prompt-projector-f4ElyXCE.d.ts} +4 -4
- package/dist/{reduced-state-TMi7ISla.js → reduced-state-DF0-6mbR.js} +25 -30
- package/dist/reduced-state-DF0-6mbR.js.map +1 -0
- package/dist/{reducer-registry--vQFATXb.d.ts → reducer-registry-aFjz_ZLT.d.ts} +2 -2
- package/dist/{runtime-DXvMCq-J.d.ts → runtime-DbTCb32-.d.ts} +6 -6
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/compaction.js +1 -426
- package/dist/services/model-resolver.d.ts +2 -0
- package/dist/services/model-resolver.js +17 -0
- package/dist/services/model-resolver.js.map +1 -0
- package/dist/services/prompt-projector.d.ts +1 -1
- package/dist/services/reducer-registry.d.ts +1 -1
- package/dist/services/runtime-layer.d.ts +14 -14
- package/dist/services/runtime-layer.js +8 -7
- package/dist/services/runtime-layer.js.map +1 -1
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +3 -2
- package/dist/services/runtime.js.map +1 -1
- package/dist/services/session-event-observer.d.ts +1 -1
- package/dist/services/session-query.d.ts +1 -1
- package/dist/services/session-query.js +3 -3
- package/dist/services/session-state.d.ts +1 -1
- package/dist/services/session-state.js +1 -1
- package/dist/services/session-store.d.ts +1 -1
- package/dist/services/session-store.js +2 -1
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/sink-checkpoint-store.d.ts +1 -1
- package/dist/services/sink-registry.d.ts +1 -1
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/services/tracing.d.ts +1 -1
- package/dist/{session-event-observer-D_aoFnQs.d.ts → session-event-observer-DaFMKKNc.d.ts} +2 -2
- package/dist/{session-query-lUZQpMvM.d.ts → session-query-l8xpJYp8.d.ts} +9 -9
- package/dist/{session-state-Bi3oEbJU.d.ts → session-state-YHFzOGDf.d.ts} +16 -16
- package/dist/{session-state-C4m0j6CJ.js → session-state-aIqe9CLa.js} +30 -39
- package/dist/session-state-aIqe9CLa.js.map +1 -0
- package/dist/{session-store-ofm8FFxs.d.ts → session-store-Cpi_NwTR.d.ts} +3 -3
- package/dist/{sink-checkpoint-store-BQVbI9DQ.d.ts → sink-checkpoint-store-M7qIxoSH.d.ts} +2 -2
- package/dist/{sink-registry-DH6uiEgP.js → sink-registry-NDgeyzO0.js} +4 -4
- package/dist/{sink-registry-DH6uiEgP.js.map → sink-registry-NDgeyzO0.js.map} +1 -1
- package/dist/{sink-registry-CE-hL7cB.d.ts → sink-registry-T1wOUuzq.d.ts} +9 -9
- package/dist/testkit/layers.d.ts +17 -14
- package/dist/testkit/layers.js +10 -8
- package/dist/testkit/layers.js.map +1 -1
- package/dist/{tool-registry-ClHdr_G5.d.ts → tool-registry-BJaVNtw4.d.ts} +3 -3
- package/dist/types/events/durable.d.ts +2 -2
- package/dist/types/events/durable.js +2 -2
- package/dist/types/events.d.ts +4 -3
- package/dist/types/events.js +3 -2
- package/dist/types/events.js.map +1 -1
- package/dist/websocket.d.ts +63 -2
- package/dist/websocket.js +2 -1
- package/dist/websocket.js.map +1 -1
- package/package.json +10 -1
- package/dist/durable-DsV9PxZC.js.map +0 -1
- package/dist/reduced-state-TMi7ISla.js.map +0 -1
- package/dist/services/compaction.js.map +0 -1
- package/dist/session-state-C4m0j6CJ.js.map +0 -1
package/dist/types/events.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { _ as UsagePayload, a as EventNamespace, b as schemaV1, c as FailurePayload, d as PositionedEvent, f as ProviderPartId, g as UnixEpochMillis, h as ToolName, i as EventEnvelope, l as ModelSelectionPayload, m as SystemPromptText, n as EphemeralEventEnvelope, o as EventType, p as SchemaVersion, r as EventDurability, s as EventTypeName, t as DurableEventEnvelope, u as NonNegativeInt, v as effectDurableAgentNamespace, y as makeEventType } from "../envelope-DkZyMIgp.js";
|
|
1
2
|
import { _ as parseEDATraceparent, a as EDATraceAttributes, c as EDATraceLink, d as makeEDAEventTrace, f as makeEDARunTrace, g as makeRootEDATraceMetadata, h as makeRootEDAEventTrace, i as EDATraceAttributeValue, l as EDATraceMetadata, m as makeEDATraceMetadataFromParent, n as EDARunTrace, o as EDATraceContext, p as makeEDATraceContext, r as EDASpanId, s as EDATraceId, t as EDAEventTrace, u as buildEDATraceparent } from "../tracing-BXHAkxkx.js";
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
4
|
-
export { AssistantMessageCommittedEvent, AssistantMessageCommittedPayload, AssistantMessageContent, AssistantMessageImportedEvent, AssistantMessageImportedPayload, AssistantPartialCommittedEvent, AssistantPartialCommittedPayload, AssistantPromptPart, AssistantPromptParts, BaseStateCreatedEvent, BaseStateCreatedPayload, BaseStateEvent, BaseStateFailedEvent, BaseStateFailedPayload, BaseStateRequestedEvent, BaseStateRequestedPayload, CommandAdmittedEvent, CommandAdmittedPayload, CommandCancelledEvent, CommandCancelledPayload, CommandCompletedEvent, CommandCompletedPayload, CommandEvent, CommandFailedEvent, CommandFailedPayload, CommandStartedEvent, CommandStartedPayload, CompactionCompletedEvent, CompactionCompletedPayload, CompactionFailedEvent, CompactionFailedPayload, CompactionRequestedEvent, CompactionRequestedPayload, CompactionStartedEvent, CompactionStartedPayload, ContextAndCompactionEvent, ContextProjectedEvent, ContextProjectedPayload, ContextRebasedEvent, ContextRebasedPayload, DurableEventEnvelope, EDADurableEvent, EDADurableEventV1, EDAEphemeralEvent, EDAEventTrace, EDARunTrace, EDASpanId, EDATraceAttributeValue, EDATraceAttributes, EDATraceContext, EDATraceId, EDATraceLink, EDATraceMetadata, EphemeralEventEnvelope, EventDurability, EventEnvelope, EventNamespace, EventType, EventTypeName, FailurePayload, InferenceCompletedEvent, InferenceCompletedPayload, InferenceEvent, InferenceFailedEvent, InferenceFailedPayload, InferenceStartedEvent, InferenceStartedPayload, MessageEvent, MessageQueuePausedEvent, MessageQueuePausedPayload, ModelSelectionPayload, ModelStreamEvent, NonNegativeInt, PendingMessagesPausedEvent, PendingMessagesPausedPayload, PositionedEvent, ProviderPartId, ReasoningDeltaEvent, ReasoningDeltaPayload, RecoveryCompletedEvent, RecoveryCompletedPayload, RecoveryContinuation, RecoveryEvent, RunCompletedEvent, RunCompletedPayload, RunEvent, RunFailedEvent, RunFailedPayload, RunInterruptedEvent, RunInterruptedPayload, RunStartedEvent, RunStartedPayload, RuntimeStatusEvent, SchemaVersion, SteeringMessageCancelledEvent, SteeringMessageCancelledPayload, SteeringMessageQueuedEvent, SteeringMessageQueuedPayload, StopControlEvent, StopTurnAppliedEvent, StopTurnAppliedPayload, StopTurnRequestedEvent, StopTurnRequestedPayload, SubscriberStatusEvent, SubscriberStatusKind, SubscriberStatusPayload, SummaryCreatedEvent, SummaryCreatedPayload, SystemMessageCommittedEvent, SystemMessageCommittedPayload, SystemPromptText, TextDeltaEvent, TextDeltaPayload, ToolCallCompletedEvent, ToolCallCompletedPayload, ToolCallCreatedEvent, ToolCallCreatedPayload, ToolCallEvent, ToolCallFailedEvent, ToolCallFailedPayload, ToolCallPromptPart, ToolCallRejectedEvent, ToolCallRejectedPayload, ToolCallRejectionFeedback, ToolCallRejectionReason, ToolCallStartedEvent, ToolCallStartedPayload, ToolFailurePromptPart, ToolName, ToolParamsDeltaEvent, ToolParamsDeltaPayload, ToolParamsEndEvent, ToolParamsEndPayload, ToolParamsStartEvent, ToolParamsStartPayload, ToolPromptPart, ToolRejectionPromptPart, ToolSuccessPromptPart, TraceStatusEvent, TraceStatusKind, TraceStatusPayload, TurnCompletedEvent, TurnCompletedPayload, TurnEvent, TurnFailedEvent, TurnFailedPayload, TurnStartedEvent, TurnStartedPayload, TurnStoppedEvent, TurnStoppedPayload, UnixEpochMillis, UsagePayload, UserMessageCancellationReason, UserMessageCancelledEvent, UserMessageCancelledPayload, UserMessageCommittedEvent, UserMessageCommittedPayload, UserMessageDisposition, UserMessagePromotedEvent, UserMessagePromotedPayload, UserMessageSubmittedEvent, UserMessageSubmittedPayload, assistantMessageCommittedEventType, assistantMessageImportedEventType, assistantPartialCommittedEventType, baseStateCreatedEventType, baseStateFailedEventType, baseStateRequestedEventType, buildEDATraceparent, commandAdmittedEventType, commandCancelledEventType, commandCompletedEventType, commandFailedEventType, commandStartedEventType, compactionCompletedEventType, compactionFailedEventType, compactionRequestedEventType, compactionStartedEventType, contextProjectedEventType, contextRebasedEventType, decodeUnknownEDADurableEvent, decodeUnknownEDADurableEventSync, effectDurableAgentNamespace, inferenceCompletedEventType, inferenceFailedEventType, inferenceStartedEventType, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEventType, makeRootEDAEventTrace, makeRootEDATraceMetadata, messageQueuePausedEventType, parseEDATraceparent, pendingMessagesPausedEventType, reasoningDeltaEventType, recoveryCompletedEventType, runCompletedEventType, runFailedEventType, runInterruptedEventType, runStartedEventType, schemaV1, steeringMessageCancelledEventType, steeringMessageQueuedEventType, stopTurnAppliedEventType, stopTurnRequestedEventType, subscriberStatusEventType, summaryCreatedEventType, systemMessageCommittedEventType, textDeltaEventType, toolCallCompletedEventType, toolCallCreatedEventType, toolCallFailedEventType, toolCallRejectedEventType, toolCallStartedEventType, toolParamsDeltaEventType, toolParamsEndEventType, toolParamsStartEventType, traceStatusEventType, turnCompletedEventType, turnFailedEventType, turnStartedEventType, turnStoppedEventType, userMessageCancelledEventType, userMessageCommittedEventType, userMessagePromotedEventType, userMessageSubmittedEventType };
|
|
3
|
+
import { $ as PendingMessagesPausedEvent, $n as turnFailedEventType, $t as TurnStoppedEvent, A as CompactionFailedEvent, An as inferenceCompletedEventType, At as ToolCallCreatedEvent, B as ContextRebasedPayload, Bn as sessionConfiguredEventType, Bt as ToolCallStartedEvent, C as CommandEvent, Cn as compactionFailedEventType, Ct as StopTurnRequestedPayload, D as CommandStartedPayload, Dn as contextRebasedEventType, Dt as SystemMessageCommittedPayload, E as CommandStartedEvent, En as contextProjectedEventType, Et as SystemMessageCommittedEvent, F as CompactionStartedPayload, Fn as recoveryCompletedEventType, Ft as ToolCallPromptPart, G as InferenceEvent, Gn as summaryCreatedEventType, Gt as ToolSuccessPromptPart, H as EDADurableEventV1, Hn as steeringMessageQueuedEventType, Ht as ToolFailurePromptPart, I as ContextAndCompactionEvent, In as runCompletedEventType, It as ToolCallRejectedEvent, J as InferenceStartedEvent, Jn as toolCallCreatedEventType, Jt as TurnEvent, K as InferenceFailedEvent, Kn as systemMessageCommittedEventType, Kt as TurnCompletedEvent, L as ContextProjectedEvent, Ln as runFailedEventType, Lt as ToolCallRejectedPayload, M as CompactionRequestedEvent, Mn as inferenceStartedEventType, Mt as ToolCallEvent, N as CompactionRequestedPayload, Nn as messageQueuePausedEventType, Nt as ToolCallFailedEvent, O as CompactionCompletedEvent, On as decodeUnknownEDADurableEvent, Ot as ToolCallCompletedEvent, P as CompactionStartedEvent, Pn as pendingMessagesPausedEventType, Pt as ToolCallFailedPayload, Q as MessageQueuePausedPayload, Qn as turnCompletedEventType, Qt as TurnStartedPayload, R as ContextProjectedPayload, Rn as runInterruptedEventType, Rt as ToolCallRejectionFeedback, S as CommandCompletedPayload, Sn as compactionCompletedEventType, St as StopTurnRequestedEvent, T as CommandFailedPayload, Tn as compactionStartedEventType, Tt as SummaryCreatedPayload, U as InferenceCompletedEvent, Un as stopTurnAppliedEventType, Ut as ToolPromptPart, V as EDADurableEvent, Vn as steeringMessageCancelledEventType, Vt as ToolCallStartedPayload, W as InferenceCompletedPayload, Wn as stopTurnRequestedEventType, Wt as ToolRejectionPromptPart, X as MessageEvent, Xn as toolCallRejectedEventType, Xt as TurnFailedPayload, Y as InferenceStartedPayload, Yn as toolCallFailedEventType, Yt as TurnFailedEvent, Z as MessageQueuePausedEvent, Zn as toolCallStartedEventType, Zt as TurnStartedEvent, _ as CommandAdmittedEvent, _n as commandAdmittedEventType, _t as SteeringMessageQueuedEvent, a as AssistantMessageImportedPayload, an as UserMessageCommittedPayload, ar as userMessageSubmittedEventType, at as RunCompletedEvent, b as CommandCancelledPayload, bn as commandFailedEventType, bt as StopTurnAppliedEvent, c as AssistantPromptPart, cn as UserMessagePromotedPayload, ct as RunFailedEvent, d as BaseStateCreatedPayload, dn as assistantMessageCommittedEventType, dt as RunInterruptedPayload, en as TurnStoppedPayload, er as turnStartedEventType, et as PendingMessagesPausedPayload, f as BaseStateEvent, fn as assistantMessageImportedEventType, ft as RunStartedEvent, g as BaseStateRequestedPayload, gn as baseStateRequestedEventType, gt as SteeringMessageCancelledPayload, h as BaseStateRequestedEvent, hn as baseStateFailedEventType, ht as SteeringMessageCancelledEvent, i as AssistantMessageImportedEvent, in as UserMessageCommittedEvent, ir as userMessagePromotedEventType, it as RecoveryEvent, j as CompactionFailedPayload, jn as inferenceFailedEventType, jt as ToolCallCreatedPayload, k as CompactionCompletedPayload, kn as decodeUnknownEDADurableEventSync, kt as ToolCallCompletedPayload, l as AssistantPromptParts, ln as UserMessageSubmittedEvent, lt as RunFailedPayload, m as BaseStateFailedPayload, mn as baseStateCreatedEventType, mt as SessionConfiguredEvent, n as AssistantMessageCommittedPayload, nn as UserMessageCancelledEvent, nr as userMessageCancelledEventType, nt as RecoveryCompletedPayload, o as AssistantPartialCommittedEvent, on as UserMessageDisposition, ot as RunCompletedPayload, p as BaseStateFailedEvent, pn as assistantPartialCommittedEventType, pt as RunStartedPayload, q as InferenceFailedPayload, qn as toolCallCompletedEventType, qt as TurnCompletedPayload, r as AssistantMessageContent, rn as UserMessageCancelledPayload, rr as userMessageCommittedEventType, rt as RecoveryContinuation, s as AssistantPartialCommittedPayload, sn as UserMessagePromotedEvent, st as RunEvent, t as AssistantMessageCommittedEvent, tn as UserMessageCancellationReason, tr as turnStoppedEventType, tt as RecoveryCompletedEvent, u as BaseStateCreatedEvent, un as UserMessageSubmittedPayload, ut as RunInterruptedEvent, v as CommandAdmittedPayload, vn as commandCancelledEventType, vt as SteeringMessageQueuedPayload, w as CommandFailedEvent, wn as compactionRequestedEventType, wt as SummaryCreatedEvent, x as CommandCompletedEvent, xn as commandStartedEventType, xt as StopTurnAppliedPayload, y as CommandCancelledEvent, yn as commandCompletedEventType, yt as StopControlEvent, z as ContextRebasedEvent, zn as runStartedEventType, zt as ToolCallRejectionReason } from "../durable-br2C1bWK.js";
|
|
4
|
+
import { C as toolParamsDeltaEventType, E as traceStatusEventType, S as textDeltaEventType, T as toolParamsStartEventType, _ as TraceStatusEvent, a as RuntimeStatusEvent, b as reasoningDeltaEventType, c as SubscriberStatusPayload, d as ToolParamsDeltaEvent, f as ToolParamsDeltaPayload, g as ToolParamsStartPayload, h as ToolParamsStartEvent, i as ReasoningDeltaPayload, l as TextDeltaEvent, m as ToolParamsEndPayload, n as ModelStreamEvent, o as SubscriberStatusEvent, p as ToolParamsEndEvent, r as ReasoningDeltaEvent, s as SubscriberStatusKind, t as EDAEphemeralEvent, u as TextDeltaPayload, v as TraceStatusKind, w as toolParamsEndEventType, x as subscriberStatusEventType, y as TraceStatusPayload } from "../events-LZFNoESe.js";
|
|
5
|
+
export { AssistantMessageCommittedEvent, AssistantMessageCommittedPayload, AssistantMessageContent, AssistantMessageImportedEvent, AssistantMessageImportedPayload, AssistantPartialCommittedEvent, AssistantPartialCommittedPayload, AssistantPromptPart, AssistantPromptParts, BaseStateCreatedEvent, BaseStateCreatedPayload, BaseStateEvent, BaseStateFailedEvent, BaseStateFailedPayload, BaseStateRequestedEvent, BaseStateRequestedPayload, CommandAdmittedEvent, CommandAdmittedPayload, CommandCancelledEvent, CommandCancelledPayload, CommandCompletedEvent, CommandCompletedPayload, CommandEvent, CommandFailedEvent, CommandFailedPayload, CommandStartedEvent, CommandStartedPayload, CompactionCompletedEvent, CompactionCompletedPayload, CompactionFailedEvent, CompactionFailedPayload, CompactionRequestedEvent, CompactionRequestedPayload, CompactionStartedEvent, CompactionStartedPayload, ContextAndCompactionEvent, ContextProjectedEvent, ContextProjectedPayload, ContextRebasedEvent, ContextRebasedPayload, DurableEventEnvelope, EDADurableEvent, EDADurableEventV1, EDAEphemeralEvent, EDAEventTrace, EDARunTrace, EDASpanId, EDATraceAttributeValue, EDATraceAttributes, EDATraceContext, EDATraceId, EDATraceLink, EDATraceMetadata, EphemeralEventEnvelope, EventDurability, EventEnvelope, EventNamespace, EventType, EventTypeName, FailurePayload, InferenceCompletedEvent, InferenceCompletedPayload, InferenceEvent, InferenceFailedEvent, InferenceFailedPayload, InferenceStartedEvent, InferenceStartedPayload, MessageEvent, MessageQueuePausedEvent, MessageQueuePausedPayload, ModelSelectionPayload, ModelStreamEvent, NonNegativeInt, PendingMessagesPausedEvent, PendingMessagesPausedPayload, PositionedEvent, ProviderPartId, ReasoningDeltaEvent, ReasoningDeltaPayload, RecoveryCompletedEvent, RecoveryCompletedPayload, RecoveryContinuation, RecoveryEvent, RunCompletedEvent, RunCompletedPayload, RunEvent, RunFailedEvent, RunFailedPayload, RunInterruptedEvent, RunInterruptedPayload, RunStartedEvent, RunStartedPayload, RuntimeStatusEvent, SchemaVersion, SessionConfiguredEvent, SteeringMessageCancelledEvent, SteeringMessageCancelledPayload, SteeringMessageQueuedEvent, SteeringMessageQueuedPayload, StopControlEvent, StopTurnAppliedEvent, StopTurnAppliedPayload, StopTurnRequestedEvent, StopTurnRequestedPayload, SubscriberStatusEvent, SubscriberStatusKind, SubscriberStatusPayload, SummaryCreatedEvent, SummaryCreatedPayload, SystemMessageCommittedEvent, SystemMessageCommittedPayload, SystemPromptText, TextDeltaEvent, TextDeltaPayload, ToolCallCompletedEvent, ToolCallCompletedPayload, ToolCallCreatedEvent, ToolCallCreatedPayload, ToolCallEvent, ToolCallFailedEvent, ToolCallFailedPayload, ToolCallPromptPart, ToolCallRejectedEvent, ToolCallRejectedPayload, ToolCallRejectionFeedback, ToolCallRejectionReason, ToolCallStartedEvent, ToolCallStartedPayload, ToolFailurePromptPart, ToolName, ToolParamsDeltaEvent, ToolParamsDeltaPayload, ToolParamsEndEvent, ToolParamsEndPayload, ToolParamsStartEvent, ToolParamsStartPayload, ToolPromptPart, ToolRejectionPromptPart, ToolSuccessPromptPart, TraceStatusEvent, TraceStatusKind, TraceStatusPayload, TurnCompletedEvent, TurnCompletedPayload, TurnEvent, TurnFailedEvent, TurnFailedPayload, TurnStartedEvent, TurnStartedPayload, TurnStoppedEvent, TurnStoppedPayload, UnixEpochMillis, UsagePayload, UserMessageCancellationReason, UserMessageCancelledEvent, UserMessageCancelledPayload, UserMessageCommittedEvent, UserMessageCommittedPayload, UserMessageDisposition, UserMessagePromotedEvent, UserMessagePromotedPayload, UserMessageSubmittedEvent, UserMessageSubmittedPayload, assistantMessageCommittedEventType, assistantMessageImportedEventType, assistantPartialCommittedEventType, baseStateCreatedEventType, baseStateFailedEventType, baseStateRequestedEventType, buildEDATraceparent, commandAdmittedEventType, commandCancelledEventType, commandCompletedEventType, commandFailedEventType, commandStartedEventType, compactionCompletedEventType, compactionFailedEventType, compactionRequestedEventType, compactionStartedEventType, contextProjectedEventType, contextRebasedEventType, decodeUnknownEDADurableEvent, decodeUnknownEDADurableEventSync, effectDurableAgentNamespace, inferenceCompletedEventType, inferenceFailedEventType, inferenceStartedEventType, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEventType, makeRootEDAEventTrace, makeRootEDATraceMetadata, messageQueuePausedEventType, parseEDATraceparent, pendingMessagesPausedEventType, reasoningDeltaEventType, recoveryCompletedEventType, runCompletedEventType, runFailedEventType, runInterruptedEventType, runStartedEventType, schemaV1, sessionConfiguredEventType, steeringMessageCancelledEventType, steeringMessageQueuedEventType, stopTurnAppliedEventType, stopTurnRequestedEventType, subscriberStatusEventType, summaryCreatedEventType, systemMessageCommittedEventType, textDeltaEventType, toolCallCompletedEventType, toolCallCreatedEventType, toolCallFailedEventType, toolCallRejectedEventType, toolCallStartedEventType, toolParamsDeltaEventType, toolParamsEndEventType, toolParamsStartEventType, traceStatusEventType, turnCompletedEventType, turnFailedEventType, turnStartedEventType, turnStoppedEventType, userMessageCancelledEventType, userMessageCommittedEventType, userMessagePromotedEventType, userMessageSubmittedEventType };
|
package/dist/types/events.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ToolCallId } from "./core.js";
|
|
2
2
|
import { EDAEventTrace, EDARunTrace, EDASpanId, EDATraceAttributeValue, EDATraceAttributes, EDATraceContext, EDATraceId, EDATraceLink, EDATraceMetadata, buildEDATraceparent, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeRootEDAEventTrace, makeRootEDATraceMetadata, parseEDATraceparent } from "./tracing.js";
|
|
3
|
-
import {
|
|
3
|
+
import { _ as effectDurableAgentNamespace, a as EventNamespace, c as ModelSelectionPayload, d as ProviderPartId, f as SchemaVersion, g as UsagePayload, h as UnixEpochMillis, i as EventEnvelope, l as NonNegativeInt, m as ToolName, n as EphemeralEventEnvelope, o as EventType, p as SystemPromptText, r as EventDurability, s as FailurePayload, t as DurableEventEnvelope, u as PositionedEvent, v as makeEventType, y as schemaV1 } from "../envelope-DxQzo5rN.js";
|
|
4
|
+
import { $ as PendingMessagesPausedEvent, $n as turnFailedEventType, $t as TurnStoppedEvent, A as CompactionFailedEvent, An as inferenceCompletedEventType, At as ToolCallCreatedEvent, B as ContextRebasedPayload, Bn as sessionConfiguredEventType, Bt as ToolCallStartedEvent, C as CommandEvent, Cn as compactionFailedEventType, Ct as StopTurnRequestedPayload, D as CommandStartedPayload, Dn as contextRebasedEventType, Dt as SystemMessageCommittedPayload, E as CommandStartedEvent, En as contextProjectedEventType, Et as SystemMessageCommittedEvent, F as CompactionStartedPayload, Fn as recoveryCompletedEventType, Ft as ToolCallPromptPart, G as InferenceEvent, Gn as summaryCreatedEventType, Gt as ToolSuccessPromptPart, H as EDADurableEventV1, Hn as steeringMessageQueuedEventType, Ht as ToolFailurePromptPart, I as ContextAndCompactionEvent, In as runCompletedEventType, It as ToolCallRejectedEvent, J as InferenceStartedEvent, Jn as toolCallCreatedEventType, Jt as TurnEvent, K as InferenceFailedEvent, Kn as systemMessageCommittedEventType, Kt as TurnCompletedEvent, L as ContextProjectedEvent, Ln as runFailedEventType, Lt as ToolCallRejectedPayload, M as CompactionRequestedEvent, Mn as inferenceStartedEventType, Mt as ToolCallEvent, N as CompactionRequestedPayload, Nn as messageQueuePausedEventType, Nt as ToolCallFailedEvent, O as CompactionCompletedEvent, On as decodeUnknownEDADurableEvent, Ot as ToolCallCompletedEvent, P as CompactionStartedEvent, Pn as pendingMessagesPausedEventType, Pt as ToolCallFailedPayload, Q as MessageQueuePausedPayload, Qn as turnCompletedEventType, Qt as TurnStartedPayload, R as ContextProjectedPayload, Rn as runInterruptedEventType, Rt as ToolCallRejectionFeedback, S as CommandCompletedPayload, Sn as compactionCompletedEventType, St as StopTurnRequestedEvent, T as CommandFailedPayload, Tn as compactionStartedEventType, Tt as SummaryCreatedPayload, U as InferenceCompletedEvent, Un as stopTurnAppliedEventType, Ut as ToolPromptPart, V as EDADurableEvent, Vn as steeringMessageCancelledEventType, Vt as ToolCallStartedPayload, W as InferenceCompletedPayload, Wn as stopTurnRequestedEventType, Wt as ToolRejectionPromptPart, X as MessageEvent, Xn as toolCallRejectedEventType, Xt as TurnFailedPayload, Y as InferenceStartedPayload, Yn as toolCallFailedEventType, Yt as TurnFailedEvent, Z as MessageQueuePausedEvent, Zn as toolCallStartedEventType, Zt as TurnStartedEvent, _ as CommandAdmittedEvent, _n as commandAdmittedEventType, _t as SteeringMessageQueuedEvent, a as AssistantMessageImportedPayload, an as UserMessageCommittedPayload, ar as userMessageSubmittedEventType, at as RunCompletedEvent, b as CommandCancelledPayload, bn as commandFailedEventType, bt as StopTurnAppliedEvent, c as AssistantPromptPart, cn as UserMessagePromotedPayload, ct as RunFailedEvent, d as BaseStateCreatedPayload, dn as assistantMessageCommittedEventType, dt as RunInterruptedPayload, en as TurnStoppedPayload, er as turnStartedEventType, et as PendingMessagesPausedPayload, f as BaseStateEvent, fn as assistantMessageImportedEventType, ft as RunStartedEvent, g as BaseStateRequestedPayload, gn as baseStateRequestedEventType, gt as SteeringMessageCancelledPayload, h as BaseStateRequestedEvent, hn as baseStateFailedEventType, ht as SteeringMessageCancelledEvent, i as AssistantMessageImportedEvent, in as UserMessageCommittedEvent, ir as userMessagePromotedEventType, it as RecoveryEvent, j as CompactionFailedPayload, jn as inferenceFailedEventType, jt as ToolCallCreatedPayload, k as CompactionCompletedPayload, kn as decodeUnknownEDADurableEventSync, kt as ToolCallCompletedPayload, l as AssistantPromptParts, ln as UserMessageSubmittedEvent, lt as RunFailedPayload, m as BaseStateFailedPayload, mn as baseStateCreatedEventType, mt as SessionConfiguredEvent, n as AssistantMessageCommittedPayload, nn as UserMessageCancelledEvent, nr as userMessageCancelledEventType, nt as RecoveryCompletedPayload, o as AssistantPartialCommittedEvent, on as UserMessageDisposition, or as ephemeralEventSchema, ot as RunCompletedPayload, p as BaseStateFailedEvent, pn as assistantPartialCommittedEventType, pt as RunStartedPayload, q as InferenceFailedPayload, qn as toolCallCompletedEventType, qt as TurnCompletedPayload, r as AssistantMessageContent, rn as UserMessageCancelledPayload, rr as userMessageCommittedEventType, rt as RecoveryContinuation, s as AssistantPartialCommittedPayload, sn as UserMessagePromotedEvent, st as RunEvent, t as AssistantMessageCommittedEvent, tn as UserMessageCancellationReason, tr as turnStoppedEventType, tt as RecoveryCompletedEvent, u as BaseStateCreatedEvent, un as UserMessageSubmittedPayload, ut as RunInterruptedEvent, v as CommandAdmittedPayload, vn as commandCancelledEventType, vt as SteeringMessageQueuedPayload, w as CommandFailedEvent, wn as compactionRequestedEventType, wt as SummaryCreatedEvent, x as CommandCompletedEvent, xn as commandStartedEventType, xt as StopTurnAppliedPayload, y as CommandCancelledEvent, yn as commandCompletedEventType, yt as StopControlEvent, z as ContextRebasedEvent, zn as runStartedEventType, zt as ToolCallRejectionReason } from "../durable-BGFvX7Mh.js";
|
|
4
5
|
import * as Schema from "effect/Schema";
|
|
5
6
|
//#region src/types/events/ephemeral.ts
|
|
6
7
|
/** Event type values for ephemeral model stream events. */
|
|
@@ -85,6 +86,6 @@ const RuntimeStatusEvent = Schema.Union([SubscriberStatusEvent, TraceStatusEvent
|
|
|
85
86
|
/** Built-in ephemeral event union for framework-owned live-only updates. */
|
|
86
87
|
const EDAEphemeralEvent = Schema.Union([ModelStreamEvent, RuntimeStatusEvent]);
|
|
87
88
|
//#endregion
|
|
88
|
-
export { AssistantMessageCommittedEvent, AssistantMessageCommittedPayload, AssistantMessageContent, AssistantMessageImportedEvent, AssistantMessageImportedPayload, AssistantPartialCommittedEvent, AssistantPartialCommittedPayload, AssistantPromptPart, AssistantPromptParts, BaseStateCreatedEvent, BaseStateCreatedPayload, BaseStateEvent, BaseStateFailedEvent, BaseStateFailedPayload, BaseStateRequestedEvent, BaseStateRequestedPayload, CommandAdmittedEvent, CommandAdmittedPayload, CommandCancelledEvent, CommandCancelledPayload, CommandCompletedEvent, CommandCompletedPayload, CommandEvent, CommandFailedEvent, CommandFailedPayload, CommandStartedEvent, CommandStartedPayload, CompactionCompletedEvent, CompactionCompletedPayload, CompactionFailedEvent, CompactionFailedPayload, CompactionRequestedEvent, CompactionRequestedPayload, CompactionStartedEvent, CompactionStartedPayload, ContextAndCompactionEvent, ContextProjectedEvent, ContextProjectedPayload, ContextRebasedEvent, ContextRebasedPayload, DurableEventEnvelope, EDADurableEvent, EDADurableEventV1, EDAEphemeralEvent, EDAEventTrace, EDARunTrace, EDASpanId, EDATraceAttributeValue, EDATraceAttributes, EDATraceContext, EDATraceId, EDATraceLink, EDATraceMetadata, EphemeralEventEnvelope, EventDurability, EventEnvelope, EventNamespace, EventType, FailurePayload, InferenceCompletedEvent, InferenceCompletedPayload, InferenceEvent, InferenceFailedEvent, InferenceFailedPayload, InferenceStartedEvent, InferenceStartedPayload, MessageEvent, MessageQueuePausedEvent, MessageQueuePausedPayload, ModelSelectionPayload, ModelStreamEvent, NonNegativeInt, PendingMessagesPausedEvent, PendingMessagesPausedPayload, PositionedEvent, ProviderPartId, ReasoningDeltaEvent, ReasoningDeltaPayload, RecoveryCompletedEvent, RecoveryCompletedPayload, RecoveryContinuation, RecoveryEvent, RunCompletedEvent, RunCompletedPayload, RunEvent, RunFailedEvent, RunFailedPayload, RunInterruptedEvent, RunInterruptedPayload, RunStartedEvent, RunStartedPayload, RuntimeStatusEvent, SchemaVersion, SteeringMessageCancelledEvent, SteeringMessageCancelledPayload, SteeringMessageQueuedEvent, SteeringMessageQueuedPayload, StopControlEvent, StopTurnAppliedEvent, StopTurnAppliedPayload, StopTurnRequestedEvent, StopTurnRequestedPayload, SubscriberStatusEvent, SubscriberStatusKind, SubscriberStatusPayload, SummaryCreatedEvent, SummaryCreatedPayload, SystemMessageCommittedEvent, SystemMessageCommittedPayload, SystemPromptText, TextDeltaEvent, TextDeltaPayload, ToolCallCompletedEvent, ToolCallCompletedPayload, ToolCallCreatedEvent, ToolCallCreatedPayload, ToolCallEvent, ToolCallFailedEvent, ToolCallFailedPayload, ToolCallPromptPart, ToolCallRejectedEvent, ToolCallRejectedPayload, ToolCallRejectionFeedback, ToolCallRejectionReason, ToolCallStartedEvent, ToolCallStartedPayload, ToolFailurePromptPart, ToolName, ToolParamsDeltaEvent, ToolParamsDeltaPayload, ToolParamsEndEvent, ToolParamsEndPayload, ToolParamsStartEvent, ToolParamsStartPayload, ToolPromptPart, ToolRejectionPromptPart, ToolSuccessPromptPart, TraceStatusEvent, TraceStatusKind, TraceStatusPayload, TurnCompletedEvent, TurnCompletedPayload, TurnEvent, TurnFailedEvent, TurnFailedPayload, TurnStartedEvent, TurnStartedPayload, TurnStoppedEvent, TurnStoppedPayload, UnixEpochMillis, UsagePayload, UserMessageCancellationReason, UserMessageCancelledEvent, UserMessageCancelledPayload, UserMessageCommittedEvent, UserMessageCommittedPayload, UserMessageDisposition, UserMessagePromotedEvent, UserMessagePromotedPayload, UserMessageSubmittedEvent, UserMessageSubmittedPayload, assistantMessageCommittedEventType, assistantMessageImportedEventType, assistantPartialCommittedEventType, baseStateCreatedEventType, baseStateFailedEventType, baseStateRequestedEventType, buildEDATraceparent, commandAdmittedEventType, commandCancelledEventType, commandCompletedEventType, commandFailedEventType, commandStartedEventType, compactionCompletedEventType, compactionFailedEventType, compactionRequestedEventType, compactionStartedEventType, contextProjectedEventType, contextRebasedEventType, decodeUnknownEDADurableEvent, decodeUnknownEDADurableEventSync, effectDurableAgentNamespace, inferenceCompletedEventType, inferenceFailedEventType, inferenceStartedEventType, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEventType, makeRootEDAEventTrace, makeRootEDATraceMetadata, messageQueuePausedEventType, parseEDATraceparent, pendingMessagesPausedEventType, reasoningDeltaEventType, recoveryCompletedEventType, runCompletedEventType, runFailedEventType, runInterruptedEventType, runStartedEventType, schemaV1, steeringMessageCancelledEventType, steeringMessageQueuedEventType, stopTurnAppliedEventType, stopTurnRequestedEventType, subscriberStatusEventType, summaryCreatedEventType, systemMessageCommittedEventType, textDeltaEventType, toolCallCompletedEventType, toolCallCreatedEventType, toolCallFailedEventType, toolCallRejectedEventType, toolCallStartedEventType, toolParamsDeltaEventType, toolParamsEndEventType, toolParamsStartEventType, traceStatusEventType, turnCompletedEventType, turnFailedEventType, turnStartedEventType, turnStoppedEventType, userMessageCancelledEventType, userMessageCommittedEventType, userMessagePromotedEventType, userMessageSubmittedEventType };
|
|
89
|
+
export { AssistantMessageCommittedEvent, AssistantMessageCommittedPayload, AssistantMessageContent, AssistantMessageImportedEvent, AssistantMessageImportedPayload, AssistantPartialCommittedEvent, AssistantPartialCommittedPayload, AssistantPromptPart, AssistantPromptParts, BaseStateCreatedEvent, BaseStateCreatedPayload, BaseStateEvent, BaseStateFailedEvent, BaseStateFailedPayload, BaseStateRequestedEvent, BaseStateRequestedPayload, CommandAdmittedEvent, CommandAdmittedPayload, CommandCancelledEvent, CommandCancelledPayload, CommandCompletedEvent, CommandCompletedPayload, CommandEvent, CommandFailedEvent, CommandFailedPayload, CommandStartedEvent, CommandStartedPayload, CompactionCompletedEvent, CompactionCompletedPayload, CompactionFailedEvent, CompactionFailedPayload, CompactionRequestedEvent, CompactionRequestedPayload, CompactionStartedEvent, CompactionStartedPayload, ContextAndCompactionEvent, ContextProjectedEvent, ContextProjectedPayload, ContextRebasedEvent, ContextRebasedPayload, DurableEventEnvelope, EDADurableEvent, EDADurableEventV1, EDAEphemeralEvent, EDAEventTrace, EDARunTrace, EDASpanId, EDATraceAttributeValue, EDATraceAttributes, EDATraceContext, EDATraceId, EDATraceLink, EDATraceMetadata, EphemeralEventEnvelope, EventDurability, EventEnvelope, EventNamespace, EventType, FailurePayload, InferenceCompletedEvent, InferenceCompletedPayload, InferenceEvent, InferenceFailedEvent, InferenceFailedPayload, InferenceStartedEvent, InferenceStartedPayload, MessageEvent, MessageQueuePausedEvent, MessageQueuePausedPayload, ModelSelectionPayload, ModelStreamEvent, NonNegativeInt, PendingMessagesPausedEvent, PendingMessagesPausedPayload, PositionedEvent, ProviderPartId, ReasoningDeltaEvent, ReasoningDeltaPayload, RecoveryCompletedEvent, RecoveryCompletedPayload, RecoveryContinuation, RecoveryEvent, RunCompletedEvent, RunCompletedPayload, RunEvent, RunFailedEvent, RunFailedPayload, RunInterruptedEvent, RunInterruptedPayload, RunStartedEvent, RunStartedPayload, RuntimeStatusEvent, SchemaVersion, SessionConfiguredEvent, SteeringMessageCancelledEvent, SteeringMessageCancelledPayload, SteeringMessageQueuedEvent, SteeringMessageQueuedPayload, StopControlEvent, StopTurnAppliedEvent, StopTurnAppliedPayload, StopTurnRequestedEvent, StopTurnRequestedPayload, SubscriberStatusEvent, SubscriberStatusKind, SubscriberStatusPayload, SummaryCreatedEvent, SummaryCreatedPayload, SystemMessageCommittedEvent, SystemMessageCommittedPayload, SystemPromptText, TextDeltaEvent, TextDeltaPayload, ToolCallCompletedEvent, ToolCallCompletedPayload, ToolCallCreatedEvent, ToolCallCreatedPayload, ToolCallEvent, ToolCallFailedEvent, ToolCallFailedPayload, ToolCallPromptPart, ToolCallRejectedEvent, ToolCallRejectedPayload, ToolCallRejectionFeedback, ToolCallRejectionReason, ToolCallStartedEvent, ToolCallStartedPayload, ToolFailurePromptPart, ToolName, ToolParamsDeltaEvent, ToolParamsDeltaPayload, ToolParamsEndEvent, ToolParamsEndPayload, ToolParamsStartEvent, ToolParamsStartPayload, ToolPromptPart, ToolRejectionPromptPart, ToolSuccessPromptPart, TraceStatusEvent, TraceStatusKind, TraceStatusPayload, TurnCompletedEvent, TurnCompletedPayload, TurnEvent, TurnFailedEvent, TurnFailedPayload, TurnStartedEvent, TurnStartedPayload, TurnStoppedEvent, TurnStoppedPayload, UnixEpochMillis, UsagePayload, UserMessageCancellationReason, UserMessageCancelledEvent, UserMessageCancelledPayload, UserMessageCommittedEvent, UserMessageCommittedPayload, UserMessageDisposition, UserMessagePromotedEvent, UserMessagePromotedPayload, UserMessageSubmittedEvent, UserMessageSubmittedPayload, assistantMessageCommittedEventType, assistantMessageImportedEventType, assistantPartialCommittedEventType, baseStateCreatedEventType, baseStateFailedEventType, baseStateRequestedEventType, buildEDATraceparent, commandAdmittedEventType, commandCancelledEventType, commandCompletedEventType, commandFailedEventType, commandStartedEventType, compactionCompletedEventType, compactionFailedEventType, compactionRequestedEventType, compactionStartedEventType, contextProjectedEventType, contextRebasedEventType, decodeUnknownEDADurableEvent, decodeUnknownEDADurableEventSync, effectDurableAgentNamespace, inferenceCompletedEventType, inferenceFailedEventType, inferenceStartedEventType, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEventType, makeRootEDAEventTrace, makeRootEDATraceMetadata, messageQueuePausedEventType, parseEDATraceparent, pendingMessagesPausedEventType, reasoningDeltaEventType, recoveryCompletedEventType, runCompletedEventType, runFailedEventType, runInterruptedEventType, runStartedEventType, schemaV1, sessionConfiguredEventType, steeringMessageCancelledEventType, steeringMessageQueuedEventType, stopTurnAppliedEventType, stopTurnRequestedEventType, subscriberStatusEventType, summaryCreatedEventType, systemMessageCommittedEventType, textDeltaEventType, toolCallCompletedEventType, toolCallCreatedEventType, toolCallFailedEventType, toolCallRejectedEventType, toolCallStartedEventType, toolParamsDeltaEventType, toolParamsEndEventType, toolParamsStartEventType, traceStatusEventType, turnCompletedEventType, turnFailedEventType, turnStartedEventType, turnStoppedEventType, userMessageCancelledEventType, userMessageCommittedEventType, userMessagePromotedEventType, userMessageSubmittedEventType };
|
|
89
90
|
|
|
90
91
|
//# sourceMappingURL=events.js.map
|
package/dist/types/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","names":[],"sources":["../../src/types/events/ephemeral.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { ToolCallId } from \"../core\";\nimport { ProviderPartId, ToolName, makeEventType } from \"./envelope\";\nimport { ephemeralEventSchema } from \"./internal\";\n\n/** Event type values for ephemeral model stream events. */\nexport const textDeltaEventType = makeEventType(\"TextDelta\");\nexport const reasoningDeltaEventType = makeEventType(\"ReasoningDelta\");\nexport const toolParamsStartEventType = makeEventType(\"ToolParamsStart\");\nexport const toolParamsDeltaEventType = makeEventType(\"ToolParamsDelta\");\nexport const toolParamsEndEventType = makeEventType(\"ToolParamsEnd\");\n\n/** Payload for live assistant text deltas. */\nexport const TextDeltaPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n delta: Schema.String,\n});\nexport type TextDeltaPayload = typeof TextDeltaPayload.Type;\nexport const TextDeltaEvent = ephemeralEventSchema(textDeltaEventType, TextDeltaPayload);\nexport type TextDeltaEvent = typeof TextDeltaEvent.Type;\n\n/** Payload for live assistant reasoning deltas. */\nexport const ReasoningDeltaPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n delta: Schema.String,\n});\nexport type ReasoningDeltaPayload = typeof ReasoningDeltaPayload.Type;\nexport const ReasoningDeltaEvent = ephemeralEventSchema(\n reasoningDeltaEventType,\n ReasoningDeltaPayload,\n);\nexport type ReasoningDeltaEvent = typeof ReasoningDeltaEvent.Type;\n\n/** Payload for the speculative start of streamed tool parameters. */\nexport const ToolParamsStartPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n toolCallId: ToolCallId,\n toolName: ToolName,\n providerExecuted: Schema.Boolean,\n});\nexport type ToolParamsStartPayload = typeof ToolParamsStartPayload.Type;\nexport const ToolParamsStartEvent = ephemeralEventSchema(\n toolParamsStartEventType,\n ToolParamsStartPayload,\n);\nexport type ToolParamsStartEvent = typeof ToolParamsStartEvent.Type;\n\n/** Payload for one speculative streamed tool parameter chunk. */\nexport const ToolParamsDeltaPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n toolCallId: ToolCallId,\n delta: Schema.String,\n});\nexport type ToolParamsDeltaPayload = typeof ToolParamsDeltaPayload.Type;\nexport const ToolParamsDeltaEvent = ephemeralEventSchema(\n toolParamsDeltaEventType,\n ToolParamsDeltaPayload,\n);\nexport type ToolParamsDeltaEvent = typeof ToolParamsDeltaEvent.Type;\n\n/** Payload for the speculative end of streamed tool parameters. */\nexport const ToolParamsEndPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n toolCallId: ToolCallId,\n});\nexport type ToolParamsEndPayload = typeof ToolParamsEndPayload.Type;\nexport const ToolParamsEndEvent = ephemeralEventSchema(\n toolParamsEndEventType,\n ToolParamsEndPayload,\n);\nexport type ToolParamsEndEvent = typeof ToolParamsEndEvent.Type;\n\n/** Ephemeral event union for live provider stream parts. */\nexport const ModelStreamEvent = Schema.Union([\n TextDeltaEvent,\n ReasoningDeltaEvent,\n ToolParamsStartEvent,\n ToolParamsDeltaEvent,\n ToolParamsEndEvent,\n]);\nexport type ModelStreamEvent = typeof ModelStreamEvent.Type;\n\n/** Event type values for ephemeral runtime status events. */\nexport const subscriberStatusEventType = makeEventType(\"SubscriberStatus\");\nexport const traceStatusEventType = makeEventType(\"TraceStatus\");\n\n/** Status values emitted by the live subscriber pipeline. */\nexport const SubscriberStatusKind = Schema.Literals([\n \"connected\",\n \"catching-up\",\n \"live\",\n \"lagging\",\n \"closed\",\n]);\nexport type SubscriberStatusKind = typeof SubscriberStatusKind.Type;\n\n/** Payload for live subscriber lifecycle and lag notifications. */\nexport const SubscriberStatusPayload = Schema.Struct({\n status: SubscriberStatusKind,\n reason: Schema.optionalKey(Schema.String),\n});\nexport type SubscriberStatusPayload = typeof SubscriberStatusPayload.Type;\nexport const SubscriberStatusEvent = ephemeralEventSchema(\n subscriberStatusEventType,\n SubscriberStatusPayload,\n);\nexport type SubscriberStatusEvent = typeof SubscriberStatusEvent.Type;\n\n/** Status values emitted by runtime tracing hooks. */\nexport const TraceStatusKind = Schema.Literals([\"span-started\", \"span-ended\", \"span-failed\"]);\nexport type TraceStatusKind = typeof TraceStatusKind.Type;\n\n/** Payload for live trace/status breadcrumbs that are never replayed durably. */\nexport const TraceStatusPayload = Schema.Struct({\n status: TraceStatusKind,\n spanName: Schema.NonEmptyString,\n details: Schema.optionalKey(Schema.Unknown),\n});\nexport type TraceStatusPayload = typeof TraceStatusPayload.Type;\nexport const TraceStatusEvent = ephemeralEventSchema(traceStatusEventType, TraceStatusPayload);\nexport type TraceStatusEvent = typeof TraceStatusEvent.Type;\n\n/** Ephemeral event union for live runtime status updates. */\nexport const RuntimeStatusEvent = Schema.Union([SubscriberStatusEvent, TraceStatusEvent]);\nexport type RuntimeStatusEvent = typeof RuntimeStatusEvent.Type;\n\n/** Built-in ephemeral event union for framework-owned live-only updates. */\nexport const EDAEphemeralEvent = Schema.Union([ModelStreamEvent, RuntimeStatusEvent]);\nexport type EDAEphemeralEvent = typeof EDAEphemeralEvent.Type;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.js","names":[],"sources":["../../src/types/events/ephemeral.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { ToolCallId } from \"../core\";\nimport { ProviderPartId, ToolName, makeEventType } from \"./envelope\";\nimport { ephemeralEventSchema } from \"./internal\";\n\n/** Event type values for ephemeral model stream events. */\nexport const textDeltaEventType = makeEventType(\"TextDelta\");\nexport const reasoningDeltaEventType = makeEventType(\"ReasoningDelta\");\nexport const toolParamsStartEventType = makeEventType(\"ToolParamsStart\");\nexport const toolParamsDeltaEventType = makeEventType(\"ToolParamsDelta\");\nexport const toolParamsEndEventType = makeEventType(\"ToolParamsEnd\");\n\n/** Payload for live assistant text deltas. */\nexport const TextDeltaPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n delta: Schema.String,\n});\nexport type TextDeltaPayload = typeof TextDeltaPayload.Type;\nexport const TextDeltaEvent = ephemeralEventSchema(textDeltaEventType, TextDeltaPayload);\nexport type TextDeltaEvent = typeof TextDeltaEvent.Type;\n\n/** Payload for live assistant reasoning deltas. */\nexport const ReasoningDeltaPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n delta: Schema.String,\n});\nexport type ReasoningDeltaPayload = typeof ReasoningDeltaPayload.Type;\nexport const ReasoningDeltaEvent = ephemeralEventSchema(\n reasoningDeltaEventType,\n ReasoningDeltaPayload,\n);\nexport type ReasoningDeltaEvent = typeof ReasoningDeltaEvent.Type;\n\n/** Payload for the speculative start of streamed tool parameters. */\nexport const ToolParamsStartPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n toolCallId: ToolCallId,\n toolName: ToolName,\n providerExecuted: Schema.Boolean,\n});\nexport type ToolParamsStartPayload = typeof ToolParamsStartPayload.Type;\nexport const ToolParamsStartEvent = ephemeralEventSchema(\n toolParamsStartEventType,\n ToolParamsStartPayload,\n);\nexport type ToolParamsStartEvent = typeof ToolParamsStartEvent.Type;\n\n/** Payload for one speculative streamed tool parameter chunk. */\nexport const ToolParamsDeltaPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n toolCallId: ToolCallId,\n delta: Schema.String,\n});\nexport type ToolParamsDeltaPayload = typeof ToolParamsDeltaPayload.Type;\nexport const ToolParamsDeltaEvent = ephemeralEventSchema(\n toolParamsDeltaEventType,\n ToolParamsDeltaPayload,\n);\nexport type ToolParamsDeltaEvent = typeof ToolParamsDeltaEvent.Type;\n\n/** Payload for the speculative end of streamed tool parameters. */\nexport const ToolParamsEndPayload = Schema.Struct({\n providerPartId: ProviderPartId,\n toolCallId: ToolCallId,\n});\nexport type ToolParamsEndPayload = typeof ToolParamsEndPayload.Type;\nexport const ToolParamsEndEvent = ephemeralEventSchema(\n toolParamsEndEventType,\n ToolParamsEndPayload,\n);\nexport type ToolParamsEndEvent = typeof ToolParamsEndEvent.Type;\n\n/** Ephemeral event union for live provider stream parts. */\nexport const ModelStreamEvent = Schema.Union([\n TextDeltaEvent,\n ReasoningDeltaEvent,\n ToolParamsStartEvent,\n ToolParamsDeltaEvent,\n ToolParamsEndEvent,\n]);\nexport type ModelStreamEvent = typeof ModelStreamEvent.Type;\n\n/** Event type values for ephemeral runtime status events. */\nexport const subscriberStatusEventType = makeEventType(\"SubscriberStatus\");\nexport const traceStatusEventType = makeEventType(\"TraceStatus\");\n\n/** Status values emitted by the live subscriber pipeline. */\nexport const SubscriberStatusKind = Schema.Literals([\n \"connected\",\n \"catching-up\",\n \"live\",\n \"lagging\",\n \"closed\",\n]);\nexport type SubscriberStatusKind = typeof SubscriberStatusKind.Type;\n\n/** Payload for live subscriber lifecycle and lag notifications. */\nexport const SubscriberStatusPayload = Schema.Struct({\n status: SubscriberStatusKind,\n reason: Schema.optionalKey(Schema.String),\n});\nexport type SubscriberStatusPayload = typeof SubscriberStatusPayload.Type;\nexport const SubscriberStatusEvent = ephemeralEventSchema(\n subscriberStatusEventType,\n SubscriberStatusPayload,\n);\nexport type SubscriberStatusEvent = typeof SubscriberStatusEvent.Type;\n\n/** Status values emitted by runtime tracing hooks. */\nexport const TraceStatusKind = Schema.Literals([\"span-started\", \"span-ended\", \"span-failed\"]);\nexport type TraceStatusKind = typeof TraceStatusKind.Type;\n\n/** Payload for live trace/status breadcrumbs that are never replayed durably. */\nexport const TraceStatusPayload = Schema.Struct({\n status: TraceStatusKind,\n spanName: Schema.NonEmptyString,\n details: Schema.optionalKey(Schema.Unknown),\n});\nexport type TraceStatusPayload = typeof TraceStatusPayload.Type;\nexport const TraceStatusEvent = ephemeralEventSchema(traceStatusEventType, TraceStatusPayload);\nexport type TraceStatusEvent = typeof TraceStatusEvent.Type;\n\n/** Ephemeral event union for live runtime status updates. */\nexport const RuntimeStatusEvent = Schema.Union([SubscriberStatusEvent, TraceStatusEvent]);\nexport type RuntimeStatusEvent = typeof RuntimeStatusEvent.Type;\n\n/** Built-in ephemeral event union for framework-owned live-only updates. */\nexport const EDAEphemeralEvent = Schema.Union([ModelStreamEvent, RuntimeStatusEvent]);\nexport type EDAEphemeralEvent = typeof EDAEphemeralEvent.Type;\n"],"mappings":";;;;;;;AAOA,MAAa,qBAAqB,cAAc,WAAW;AAC3D,MAAa,0BAA0B,cAAc,gBAAgB;AACrE,MAAa,2BAA2B,cAAc,iBAAiB;AACvE,MAAa,2BAA2B,cAAc,iBAAiB;AACvE,MAAa,yBAAyB,cAAc,eAAe;;AAGnE,MAAa,mBAAmB,OAAO,OAAO;CAC5C,gBAAgB;CAChB,OAAO,OAAO;AAChB,CAAC;AAED,MAAa,iBAAiB,qBAAqB,oBAAoB,gBAAgB;;AAIvF,MAAa,wBAAwB,OAAO,OAAO;CACjD,gBAAgB;CAChB,OAAO,OAAO;AAChB,CAAC;AAED,MAAa,sBAAsB,qBACjC,yBACA,qBACF;;AAIA,MAAa,yBAAyB,OAAO,OAAO;CAClD,gBAAgB;CAChB,YAAY;CACZ,UAAU;CACV,kBAAkB,OAAO;AAC3B,CAAC;AAED,MAAa,uBAAuB,qBAClC,0BACA,sBACF;;AAIA,MAAa,yBAAyB,OAAO,OAAO;CAClD,gBAAgB;CAChB,YAAY;CACZ,OAAO,OAAO;AAChB,CAAC;AAED,MAAa,uBAAuB,qBAClC,0BACA,sBACF;;AAIA,MAAa,uBAAuB,OAAO,OAAO;CAChD,gBAAgB;CAChB,YAAY;AACd,CAAC;AAED,MAAa,qBAAqB,qBAChC,wBACA,oBACF;;AAIA,MAAa,mBAAmB,OAAO,MAAM;CAC3C;CACA;CACA;CACA;CACA;AACF,CAAC;;AAID,MAAa,4BAA4B,cAAc,kBAAkB;AACzE,MAAa,uBAAuB,cAAc,aAAa;;AAG/D,MAAa,uBAAuB,OAAO,SAAS;CAClD;CACA;CACA;CACA;CACA;AACF,CAAC;;AAID,MAAa,0BAA0B,OAAO,OAAO;CACnD,QAAQ;CACR,QAAQ,OAAO,YAAY,OAAO,MAAM;AAC1C,CAAC;AAED,MAAa,wBAAwB,qBACnC,2BACA,uBACF;;AAIA,MAAa,kBAAkB,OAAO,SAAS;CAAC;CAAgB;CAAc;AAAa,CAAC;;AAI5F,MAAa,qBAAqB,OAAO,OAAO;CAC9C,QAAQ;CACR,UAAU,OAAO;CACjB,SAAS,OAAO,YAAY,OAAO,OAAO;AAC5C,CAAC;AAED,MAAa,mBAAmB,qBAAqB,sBAAsB,kBAAkB;;AAI7F,MAAa,qBAAqB,OAAO,MAAM,CAAC,uBAAuB,gBAAgB,CAAC;;AAIxF,MAAa,oBAAoB,OAAO,MAAM,CAAC,kBAAkB,kBAAkB,CAAC"}
|
package/dist/websocket.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { d as PositionedEvent, i as EventEnvelope } from "./envelope-DkZyMIgp.js";
|
|
1
2
|
import { m as SequenceNumber } from "./core-CYT6DBaS.js";
|
|
2
3
|
import { a as PromotePendingMessageCommand, c as SubmitMessageCommand, o as ResumePendingMessagesCommand, s as StopTurnCommand, t as CancelPendingMessageCommand } from "./commands-Ce1ec6kH.js";
|
|
3
|
-
import { A as EventEnvelope, L as PositionedEvent } from "./events-Bb9-Cu-7.js";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
6
|
|
|
@@ -89,7 +89,40 @@ type EDAWebSocketEventConsumerPolicy<Event extends {
|
|
|
89
89
|
readonly type: string;
|
|
90
90
|
}, Disposition> = Readonly<Record<Event["type"], Disposition>>;
|
|
91
91
|
/** Complete framework-owned event union present on every EDA WebSocket. */
|
|
92
|
-
declare const EDAFrameworkWebSocketEvent: Schema.Union<readonly [Schema.Union<readonly [Schema.
|
|
92
|
+
declare const EDAFrameworkWebSocketEvent: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
93
|
+
readonly namespace: Schema.Literal<string>;
|
|
94
|
+
readonly type: Schema.Literal<"SessionConfigured">;
|
|
95
|
+
readonly schemaVersion: Schema.Literal<number>;
|
|
96
|
+
readonly payload: Schema.Struct<{
|
|
97
|
+
readonly modelSelection: Schema.Struct<{
|
|
98
|
+
readonly provider: Schema.NonEmptyString;
|
|
99
|
+
readonly modelId: Schema.NonEmptyString;
|
|
100
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
101
|
+
}>;
|
|
102
|
+
}>;
|
|
103
|
+
readonly durability: Schema.Literal<"durable">;
|
|
104
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
105
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
106
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
107
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
108
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
109
|
+
readonly span: Schema.Struct<{
|
|
110
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
111
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
112
|
+
readonly sampled: Schema.Boolean;
|
|
113
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
114
|
+
}>;
|
|
115
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
116
|
+
readonly context: Schema.Struct<{
|
|
117
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
118
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
119
|
+
readonly sampled: Schema.Boolean;
|
|
120
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
121
|
+
}>;
|
|
122
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
123
|
+
}>>;
|
|
124
|
+
}>>;
|
|
125
|
+
}>, Schema.Union<readonly [Schema.Struct<{
|
|
93
126
|
readonly namespace: Schema.Literal<string>;
|
|
94
127
|
readonly type: Schema.Literal<"CommandAdmitted">;
|
|
95
128
|
readonly schemaVersion: Schema.Literal<number>;
|
|
@@ -1011,6 +1044,7 @@ declare const EDAFrameworkWebSocketEvent: Schema.Union<readonly [Schema.Union<re
|
|
|
1011
1044
|
readonly usage: Schema.optionalKey<Schema.Struct<{
|
|
1012
1045
|
readonly inputTokens: Schema.optionalKey<Schema.Int>;
|
|
1013
1046
|
readonly cachedInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1047
|
+
readonly cacheWriteInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1014
1048
|
readonly outputTokens: Schema.optionalKey<Schema.Int>;
|
|
1015
1049
|
readonly textTokens: Schema.optionalKey<Schema.Int>;
|
|
1016
1050
|
readonly reasoningTokens: Schema.optionalKey<Schema.Int>;
|
|
@@ -1147,6 +1181,7 @@ declare const EDAFrameworkWebSocketEvent: Schema.Union<readonly [Schema.Union<re
|
|
|
1147
1181
|
readonly usage: Schema.optionalKey<Schema.Struct<{
|
|
1148
1182
|
readonly inputTokens: Schema.optionalKey<Schema.Int>;
|
|
1149
1183
|
readonly cachedInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1184
|
+
readonly cacheWriteInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1150
1185
|
readonly outputTokens: Schema.optionalKey<Schema.Int>;
|
|
1151
1186
|
readonly textTokens: Schema.optionalKey<Schema.Int>;
|
|
1152
1187
|
readonly reasoningTokens: Schema.optionalKey<Schema.Int>;
|
|
@@ -1604,6 +1639,19 @@ declare const EDAFrameworkWebSocketEvent: Schema.Union<readonly [Schema.Union<re
|
|
|
1604
1639
|
readonly schemaVersion: Schema.Literal<number>;
|
|
1605
1640
|
readonly payload: Schema.Struct<{
|
|
1606
1641
|
readonly compactionId: Schema.brand<Schema.String, "CompactionId">;
|
|
1642
|
+
readonly modelSelection: Schema.optionalKey<Schema.Struct<{
|
|
1643
|
+
readonly provider: Schema.NonEmptyString;
|
|
1644
|
+
readonly modelId: Schema.NonEmptyString;
|
|
1645
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
1646
|
+
}>>;
|
|
1647
|
+
readonly usage: Schema.optionalKey<Schema.Struct<{
|
|
1648
|
+
readonly inputTokens: Schema.optionalKey<Schema.Int>;
|
|
1649
|
+
readonly cachedInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1650
|
+
readonly cacheWriteInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1651
|
+
readonly outputTokens: Schema.optionalKey<Schema.Int>;
|
|
1652
|
+
readonly textTokens: Schema.optionalKey<Schema.Int>;
|
|
1653
|
+
readonly reasoningTokens: Schema.optionalKey<Schema.Int>;
|
|
1654
|
+
}>>;
|
|
1607
1655
|
}>;
|
|
1608
1656
|
readonly durability: Schema.Literal<"durable">;
|
|
1609
1657
|
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
@@ -1670,6 +1718,19 @@ declare const EDAFrameworkWebSocketEvent: Schema.Union<readonly [Schema.Union<re
|
|
|
1670
1718
|
readonly code: Schema.optionalKey<Schema.String>;
|
|
1671
1719
|
readonly details: Schema.optionalKey<Schema.Unknown>;
|
|
1672
1720
|
}>;
|
|
1721
|
+
readonly modelSelection: Schema.optionalKey<Schema.Struct<{
|
|
1722
|
+
readonly provider: Schema.NonEmptyString;
|
|
1723
|
+
readonly modelId: Schema.NonEmptyString;
|
|
1724
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
1725
|
+
}>>;
|
|
1726
|
+
readonly usage: Schema.optionalKey<Schema.Struct<{
|
|
1727
|
+
readonly inputTokens: Schema.optionalKey<Schema.Int>;
|
|
1728
|
+
readonly cachedInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1729
|
+
readonly cacheWriteInputTokens: Schema.optionalKey<Schema.Int>;
|
|
1730
|
+
readonly outputTokens: Schema.optionalKey<Schema.Int>;
|
|
1731
|
+
readonly textTokens: Schema.optionalKey<Schema.Int>;
|
|
1732
|
+
readonly reasoningTokens: Schema.optionalKey<Schema.Int>;
|
|
1733
|
+
}>>;
|
|
1673
1734
|
}>;
|
|
1674
1735
|
readonly durability: Schema.Literal<"durable">;
|
|
1675
1736
|
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
package/dist/websocket.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Position, SequenceNumber } from "./types/core.js";
|
|
2
|
-
import {
|
|
2
|
+
import { h as UnixEpochMillis, i as EventEnvelope, u as PositionedEvent } from "./envelope-DxQzo5rN.js";
|
|
3
|
+
import { V as EDADurableEvent } from "./durable-BGFvX7Mh.js";
|
|
3
4
|
import { EDAEphemeralEvent } from "./types/events.js";
|
|
4
5
|
import * as Effect from "effect/Effect";
|
|
5
6
|
import * as Schema from "effect/Schema";
|
package/dist/websocket.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","names":[],"sources":["../src/websocket/protocol.ts","../src/websocket/messages.ts","../src/websocket/delivery.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { Position } from \"../types/core\";\nimport { EDADurableEvent, EDAEphemeralEvent, EventEnvelope } from \"../types/events\";\n\nconst PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));\nconst NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\n/** Current EDA live-event WebSocket wire protocol version. */\nexport const EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION = 1 as const;\n\n/** Flow-control policy announced by the server in the hello frame. */\nexport const EDAWebSocketWireFlowControl = Schema.Struct({\n ackTimeoutMs: PositiveInt,\n /** Deprecated: servers no longer send heartbeat frames. Kept so deployed clients can decode hello. */\n heartbeatIntervalMs: PositiveInt,\n maxFrameBytes: PositiveInt,\n maxFrameEvents: PositiveInt,\n maxInFlightFrames: PositiveInt,\n /** Suggested client-originated ping cadence; absent on servers that still send heartbeats. */\n pingIntervalMs: Schema.optionalKey(PositiveInt),\n subscriberBufferCapacityEvents: PositiveInt,\n});\nexport type EDAWebSocketWireFlowControl = typeof EDAWebSocketWireFlowControl.Type;\n\n/**\n * Canonical client liveness ping message.\n *\n * The exact string matters: hibernation-capable hosts register it with\n * WebSocket auto-response so the runtime answers without waking the object.\n */\nexport const EDA_WEB_SOCKET_PING_MESSAGE = '{\"_tag\":\"ping\"}';\n\n/** Canonical server pong message paired with {@link EDA_WEB_SOCKET_PING_MESSAGE}. */\nexport const EDA_WEB_SOCKET_PONG_MESSAGE = '{\"_tag\":\"pong\"}';\n\n/** Client liveness ping; hosts answer with a pong and never ACK-track it. */\nexport const EDAWebSocketWirePingFrame = Schema.Struct({\n _tag: Schema.Literal(\"ping\"),\n});\nexport type EDAWebSocketWirePingFrame = typeof EDAWebSocketWirePingFrame.Type;\n\n/** Server liveness pong; clients may ignore it and must not ACK it. */\nexport const EDAWebSocketWirePongFrame = Schema.Struct({\n _tag: Schema.Literal(\"pong\"),\n});\nexport type EDAWebSocketWirePongFrame = typeof EDAWebSocketWirePongFrame.Type;\n\nexport const EDAWebSocketWireHelloFrame = Schema.Struct({\n _tag: Schema.Literal(\"hello\"),\n protocolVersion: Schema.Literal(EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION),\n subscriberId: Schema.NonEmptyString,\n resumeSeq: NonNegativeInt,\n flowControl: EDAWebSocketWireFlowControl,\n});\nexport type EDAWebSocketWireHelloFrame = typeof EDAWebSocketWireHelloFrame.Type;\n\nexport const EDAWebSocketWireHeartbeatFrame = Schema.Struct({\n _tag: Schema.Literal(\"heartbeat\"),\n serverTimeMs: NonNegativeInt,\n durableThroughSeq: NonNegativeInt,\n});\nexport type EDAWebSocketWireHeartbeatFrame = typeof EDAWebSocketWireHeartbeatFrame.Type;\n\nexport const EDAWebSocketWireLaggedFrame = Schema.Struct({\n _tag: Schema.Literal(\"lagged\"),\n resumeSeq: NonNegativeInt,\n reason: Schema.Literals([\"buffer-overflow\", \"ack-timeout\"]),\n});\nexport type EDAWebSocketWireLaggedFrame = typeof EDAWebSocketWireLaggedFrame.Type;\n\nexport const EDAWebSocketWireErrorFrame = Schema.Struct({\n _tag: Schema.Literal(\"error\"),\n message: Schema.String,\n});\nexport type EDAWebSocketWireErrorFrame = typeof EDAWebSocketWireErrorFrame.Type;\n\nexport const EDAWebSocketWireAckFrame = Schema.Struct({\n _tag: Schema.Literal(\"ack\"),\n frameId: PositiveInt,\n durableThroughSeq: NonNegativeInt,\n});\nexport type EDAWebSocketWireAckFrame = typeof EDAWebSocketWireAckFrame.Type;\n\nexport const EDAWebSocketWireClientFrame = Schema.Union([\n EDAWebSocketWireAckFrame,\n EDAWebSocketWirePingFrame,\n]);\nexport type EDAWebSocketWireClientFrame = typeof EDAWebSocketWireClientFrame.Type;\n\n/** Exhaustive decision table for a concrete WebSocket event union. */\nexport type EDAWebSocketEventConsumerPolicy<\n Event extends { readonly type: string },\n Disposition,\n> = Readonly<Record<Event[\"type\"], Disposition>>;\n\n/** Complete framework-owned event union present on every EDA WebSocket. */\nexport const EDAFrameworkWebSocketEvent = Schema.Union([EDADurableEvent, EDAEphemeralEvent]);\nexport type EDAFrameworkWebSocketEvent = typeof EDAFrameworkWebSocketEvent.Type;\n\nconst makeEDAWebSocketDomainSchemas = <\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n>(\n event: EventSchema,\n) => {\n const positionedEvent = Schema.Struct({\n position: Position,\n event,\n });\n const eventsFrame = Schema.Struct({\n _tag: Schema.Literal(\"events\"),\n frameId: PositiveInt,\n events: Schema.NonEmptyArray(positionedEvent),\n durableThroughSeq: NonNegativeInt,\n });\n const serverFrame = Schema.Union([\n EDAWebSocketWireHelloFrame,\n eventsFrame,\n EDAWebSocketWireHeartbeatFrame,\n EDAWebSocketWirePongFrame,\n EDAWebSocketWireLaggedFrame,\n EDAWebSocketWireErrorFrame,\n ]);\n return { event, positionedEvent, eventsFrame, serverFrame };\n};\n\ntype EDAWebSocketDomainSchemas<\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n> = ReturnType<typeof makeEDAWebSocketDomainSchemas<EventSchema>>;\n\nconst EDAWebSocketHostDomain = makeEDAWebSocketDomainSchemas(EventEnvelope);\n\n/** Domain frame shape accepted by an app-bound encoder at the EDA host boundary. */\nexport type EDAWebSocketServerFrameInput = typeof EDAWebSocketHostDomain.serverFrame.Type;\n\n/** Minimal typed encoder surface consumed by an EDA host. */\nexport interface EDAWebSocketServerFrameEncoder {\n readonly encodeServerFrame: (frame: EDAWebSocketServerFrameInput) => string;\n}\n\n/** App-bound domain schemas, wire schemas, and encoders for protocol version 1. */\nexport interface EDAWebSocketWireProtocol<\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n> {\n /** Exact app-bound schemas whose `Type` values are used inside the server. */\n readonly domain: EDAWebSocketDomainSchemas<EventSchema>;\n /** Exact app-bound schemas whose `Type` values are the serialized JSON representation. */\n readonly wire: {\n readonly event: Schema.toEncoded<EventSchema>;\n readonly positionedEvent: Schema.toEncoded<\n EDAWebSocketDomainSchemas<EventSchema>[\"positionedEvent\"]\n >;\n readonly eventsFrame: Schema.toEncoded<EDAWebSocketDomainSchemas<EventSchema>[\"eventsFrame\"]>;\n readonly serverFrame: Schema.toEncoded<EDAWebSocketDomainSchemas<EventSchema>[\"serverFrame\"]>;\n readonly clientFrame: typeof EDAWebSocketWireClientFrame;\n };\n /** Serialize one exact app-bound domain frame to a JSON text message. */\n readonly encodeServerFrame: (\n frame: Schema.Schema.Type<EDAWebSocketDomainSchemas<EventSchema>[\"serverFrame\"]>,\n ) => string;\n /** Validate broad host frames against the app event union before serialization. */\n readonly host: EDAWebSocketServerFrameEncoder;\n}\n\nconst makeEDAWebSocketWireProtocolFromEventSchema = <\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n>(\n event: EventSchema,\n): EDAWebSocketWireProtocol<EventSchema> => {\n const domain = makeEDAWebSocketDomainSchemas(event);\n const encodeDomainServerFrame = Schema.encodeSync(domain.serverFrame);\n const encodeUnknownDomainServerFrame = Schema.encodeUnknownSync(domain.serverFrame);\n const encodeServerFrame = (frame: typeof domain.serverFrame.Type): string =>\n JSON.stringify(encodeDomainServerFrame(frame));\n const host: EDAWebSocketServerFrameEncoder = {\n encodeServerFrame: (frame) => JSON.stringify(encodeUnknownDomainServerFrame(frame)),\n };\n\n return {\n domain,\n wire: {\n event: Schema.toEncoded(domain.event),\n positionedEvent: Schema.toEncoded(domain.positionedEvent),\n eventsFrame: Schema.toEncoded(domain.eventsFrame),\n serverFrame: Schema.toEncoded(domain.serverFrame),\n clientFrame: EDAWebSocketWireClientFrame,\n },\n encodeServerFrame,\n host,\n };\n};\n\n/** Strict framework-only protocol used when an app registers no custom events. */\nexport const edaFrameworkWebSocketWireProtocol: EDAWebSocketWireProtocol<\n typeof EDAFrameworkWebSocketEvent\n> = makeEDAWebSocketWireProtocolFromEventSchema(EDAFrameworkWebSocketEvent);\n\n/**\n * Bind the generic EDA WebSocket transport to one app's custom event schema.\n *\n * Framework durable and ephemeral events are included automatically. Future EDA\n * apps register only their custom events. Servers use the returned domain schemas\n * and typed encoder; external consumers decode with the wire schemas. Pass the\n * returned `host` adapter to the selected host package.\n */\nexport const makeEDAWebSocketWireProtocol = <\n AppEventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n>(options: {\n readonly appEvents: AppEventSchema;\n}): EDAWebSocketWireProtocol<\n Schema.Union<readonly [typeof EDAFrameworkWebSocketEvent, AppEventSchema]>\n> =>\n makeEDAWebSocketWireProtocolFromEventSchema(\n Schema.Union([EDAFrameworkWebSocketEvent, options.appEvents]),\n );\n","import * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport {\n EDA_WEB_SOCKET_PING_MESSAGE,\n EDA_WEB_SOCKET_PONG_MESSAGE,\n EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION,\n EDAWebSocketWireAckFrame,\n EDAWebSocketWireClientFrame,\n EDAWebSocketWireErrorFrame,\n EDAWebSocketWireFlowControl,\n EDAWebSocketWireHeartbeatFrame,\n EDAWebSocketWireHelloFrame,\n EDAWebSocketWireLaggedFrame,\n EDAWebSocketWirePingFrame,\n EDAWebSocketWirePongFrame,\n edaFrameworkWebSocketWireProtocol,\n type EDAWebSocketServerFrameEncoder,\n} from \"./protocol\";\n\nexport { EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE };\n\nimport { SequenceNumber } from \"../types/core\";\nimport { PositionedEvent, UnixEpochMillis } from \"../types/events\";\n\n/** Current EDA live-event WebSocket protocol version. */\nexport const EDA_WEB_SOCKET_PROTOCOL_VERSION = EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION;\n\n/** WebSocket close code used when a subscriber cannot keep up with live delivery. */\nexport const EDA_WS_CLOSE_LAGGED = 4008;\n\n/** WebSocket close code used for normal host-driven shutdown. */\nexport const EDA_WS_CLOSE_GOING_AWAY = 1001;\n\n/** WebSocket close code used for malformed client protocol messages. */\nexport const EDA_WS_CLOSE_PROTOCOL_ERROR = 1002;\n\n/** WebSocket close code used when the host cannot send a frame. */\nexport const EDA_WS_CLOSE_SEND_FAILED = 1011;\n\n/** WebSocket close code used for unsupported binary messages. */\nexport const EDA_WS_CLOSE_UNSUPPORTED_DATA = 1003;\n\n/** Live subscriber identity persisted in WebSocket attachments. */\nexport const SubscriberId = Schema.NonEmptyString.pipe(Schema.brand(\"SubscriberId\"));\nexport type SubscriberId = typeof SubscriberId.Type;\n\n/** Per-connection monotonically increasing server frame id. */\nexport const FrameId = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(\n Schema.brand(\"FrameId\"),\n);\nexport type FrameId = typeof FrameId.Type;\n\n/** Flow-control policy announced by the server in the hello frame. */\nexport const EDAWebSocketFlowControl = EDAWebSocketWireFlowControl;\nexport type EDAWebSocketFlowControl = typeof EDAWebSocketFlowControl.Type;\n\n/** Default bounded policy sized for fast model deltas and large durable tool/message events. */\nexport const defaultEDAWebSocketFlowControl: EDAWebSocketFlowControl = {\n ackTimeoutMs: 30_000,\n // Deprecated wire-compat field: servers no longer schedule or send heartbeats.\n heartbeatIntervalMs: 10_000,\n maxFrameBytes: 256 * 1024,\n maxFrameEvents: 1,\n maxInFlightFrames: 16,\n pingIntervalMs: 30_000,\n subscriberBufferCapacityEvents: 2_048,\n};\n\n/** First server frame; announces protocol and flow-control policy. */\nexport const EDAWebSocketHelloFrame = Schema.Struct({\n ...EDAWebSocketWireHelloFrame.fields,\n subscriberId: SubscriberId,\n resumeSeq: SequenceNumber,\n});\nexport type EDAWebSocketHelloFrame = typeof EDAWebSocketHelloFrame.Type;\n\n/** Ordered positioned events delivered to the client. */\nexport const EDAWebSocketEventsFrame = Schema.Struct({\n _tag: Schema.Literal(\"events\"),\n frameId: FrameId,\n events: Schema.NonEmptyArray(PositionedEvent),\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketEventsFrame = typeof EDAWebSocketEventsFrame.Type;\n\n/**\n * Deprecated idle server keepalive frame.\n *\n * Servers no longer send heartbeats; the schema remains so deployed clients\n * keep decoding the server frame union. Liveness is client-originated via\n * {@link EDAWebSocketPingFrame} and the host-level auto-response pong.\n */\nexport const EDAWebSocketHeartbeatFrame = Schema.Struct({\n ...EDAWebSocketWireHeartbeatFrame.fields,\n serverTimeMs: UnixEpochMillis,\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketHeartbeatFrame = typeof EDAWebSocketHeartbeatFrame.Type;\n\n/** Client liveness ping; hosts answer with a pong and never ACK-track it. */\nexport const EDAWebSocketPingFrame = EDAWebSocketWirePingFrame;\nexport type EDAWebSocketPingFrame = typeof EDAWebSocketPingFrame.Type;\n\n/** Server liveness pong; clients may ignore it and must not ACK it. */\nexport const EDAWebSocketPongFrame = EDAWebSocketWirePongFrame;\nexport type EDAWebSocketPongFrame = typeof EDAWebSocketPongFrame.Type;\n\n/** Optional final frame sent before a lag-close. */\nexport const EDAWebSocketLaggedFrame = Schema.Struct({\n ...EDAWebSocketWireLaggedFrame.fields,\n resumeSeq: SequenceNumber,\n});\nexport type EDAWebSocketLaggedFrame = typeof EDAWebSocketLaggedFrame.Type;\n\n/** Optional final frame sent before a protocol/internal close. */\nexport const EDAWebSocketErrorFrame = EDAWebSocketWireErrorFrame;\nexport type EDAWebSocketErrorFrame = typeof EDAWebSocketErrorFrame.Type;\n\n/** Server-to-client application frame union. */\nexport const EDAWebSocketServerFrame = Schema.Union([\n EDAWebSocketHelloFrame,\n EDAWebSocketEventsFrame,\n EDAWebSocketHeartbeatFrame,\n EDAWebSocketPongFrame,\n EDAWebSocketLaggedFrame,\n EDAWebSocketErrorFrame,\n]);\nexport type EDAWebSocketServerFrame = typeof EDAWebSocketServerFrame.Type;\n\n/** Client acknowledgement after applying a server frame. */\nexport const EDAWebSocketAckFrame = Schema.Struct({\n ...EDAWebSocketWireAckFrame.fields,\n frameId: FrameId,\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketAckFrame = typeof EDAWebSocketAckFrame.Type;\n\n/** Client-to-server application frame union. */\nexport const EDAWebSocketClientFrame = Schema.Union([EDAWebSocketAckFrame, EDAWebSocketPingFrame]);\nexport type EDAWebSocketClientFrame = typeof EDAWebSocketClientFrame.Type;\n\n/** Serialize a server frame for a text WebSocket message. */\nexport const encodeEDAWebSocketServerFrame = (\n frame: EDAWebSocketServerFrame,\n protocol?: EDAWebSocketServerFrameEncoder,\n): string => (protocol ?? edaFrameworkWebSocketWireProtocol.host).encodeServerFrame(frame);\n\n/** Decode an inbound text WebSocket message at the host boundary. */\nexport const decodeEDAWebSocketClientMessage = (\n input: string,\n): Effect.Effect<EDAWebSocketClientFrame, unknown> =>\n Effect.try({\n try: () => JSON.parse(input) as unknown,\n catch: (error) => error,\n }).pipe(\n Effect.flatMap((json) => Schema.decodeUnknownEffect(EDAWebSocketWireClientFrame)(json)),\n Effect.flatMap((frame) => Schema.decodeUnknownEffect(EDAWebSocketClientFrame)(frame)),\n );\n\n/** Short close reason that fits the WebSocket protocol reason limit. */\nexport const laggedCloseReason = (seq: SequenceNumber): string => `lag;seq=${seq}`;\n","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 \"./messages\";\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 const EDAWebSocketInFlightFrame = Schema.Struct({\n frameId: FrameId,\n durableThroughSeq: SequenceNumber,\n sentAtMs: Schema.Number,\n});\nexport type EDAWebSocketInFlightFrame = typeof EDAWebSocketInFlightFrame.Type;\n\n/** Compact consecutive host-suppressed receipts blocked by a visible ACK. */\nexport const EDAWebSocketSuppressedRange = Schema.Struct({\n fromFrameId: FrameId,\n throughFrameId: FrameId,\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketSuppressedRange = typeof EDAWebSocketSuppressedRange.Type;\n\n/** Complete delivery bookkeeping persisted in the WebSocket attachment. */\nexport const EDAWebSocketDeliveryCheckpoint = Schema.Struct({\n lastAckedSeq: SequenceNumber,\n lastAckedFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n lastSentFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n nextFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),\n sentDurableThroughSeq: SequenceNumber,\n inFlight: Schema.Array(EDAWebSocketInFlightFrame),\n /** Host-projected receipts waiting behind an earlier client-visible ACK. */\n suppressed: Schema.optionalKey(Schema.Array(EDAWebSocketSuppressedRange)),\n});\nexport type EDAWebSocketDeliveryCheckpoint = typeof EDAWebSocketDeliveryCheckpoint.Type;\n\n/** In-memory delivery state for one accepted event WebSocket. */\nexport interface EDAWebSocketDeliveryState extends EDAWebSocketDeliveryCheckpoint {\n readonly subscriberId: SubscriberId;\n readonly policy: EDAWebSocketFlowControl;\n /** Ephemeral events are live-only and intentionally absent from the attachment. */\n readonly pendingEphemeral: ReadonlyArray<PositionedEvent>;\n readonly suppressed: ReadonlyArray<EDAWebSocketSuppressedRange>;\n}\n\n/** Explicit instructions emitted by the pure delivery state machine. */\nexport type EDAWebSocketDeliveryAction =\n | { readonly _tag: \"Persist\" }\n | { readonly _tag: \"Send\"; readonly frames: ReadonlyArray<EDAWebSocketServerFrame> }\n | { readonly _tag: \"ReadEventPage\"; readonly afterSeq: SequenceNumber }\n | { readonly _tag: \"Close\"; readonly code: number; readonly reason: string };\n\n/** Result of one pure delivery transition. */\nexport interface EDAWebSocketDeliveryResult {\n readonly state: EDAWebSocketDeliveryState;\n readonly actions: ReadonlyArray<EDAWebSocketDeliveryAction>;\n}\n\nexport interface MakeDeliveryStateInput {\n readonly subscriberId: SubscriberId;\n readonly resumeSeq: SequenceNumber;\n readonly policy: EDAWebSocketFlowControl;\n}\n\n/** Build delivery state for a newly accepted connection. */\nexport const makeWebSocketDeliveryState = (\n input: MakeDeliveryStateInput,\n): EDAWebSocketDeliveryState => ({\n subscriberId: input.subscriberId,\n policy: input.policy,\n lastAckedSeq: input.resumeSeq,\n lastAckedFrameId: 0,\n lastSentFrameId: 0,\n nextFrameId: 1,\n sentDurableThroughSeq: input.resumeSeq,\n inFlight: [],\n suppressed: [],\n pendingEphemeral: [],\n});\n\n/** Rebuild exact ACK bookkeeping from a hibernating WebSocket attachment. */\nexport const restoreWebSocketDeliveryState = (input: {\n readonly subscriberId: SubscriberId;\n readonly policy: EDAWebSocketFlowControl;\n readonly checkpoint: EDAWebSocketDeliveryCheckpoint;\n}): EDAWebSocketDeliveryState => ({\n subscriberId: input.subscriberId,\n policy: input.policy,\n ...input.checkpoint,\n pendingEphemeral: [],\n suppressed: input.checkpoint.suppressed ?? [],\n});\n\n/** Project in-memory delivery state into the attachment-safe checkpoint. */\nexport const checkpointWebSocketDeliveryState = (\n state: EDAWebSocketDeliveryState,\n): EDAWebSocketDeliveryCheckpoint => ({\n lastAckedSeq: state.lastAckedSeq,\n lastAckedFrameId: state.lastAckedFrameId,\n lastSentFrameId: state.lastSentFrameId,\n nextFrameId: state.nextFrameId,\n sentDurableThroughSeq: state.sentDurableThroughSeq,\n inFlight: state.inFlight,\n ...(state.suppressed.length === 0 ? {} : { suppressed: state.suppressed }),\n});\n\n/** First frame for a freshly accepted connection. 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/** Deliver committed durable events read from the store. */\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) return stale;\n\n let next = state;\n const frames: EDAWebSocketServerFrame[] = [];\n let batch: PositionedEvent[] = [];\n\n const flushBatch = (): void => {\n if (batch.length === 0) return;\n const sent = sendEventsFrame(next, batch, nowMs);\n next = sent.state;\n frames.push(sent.frame);\n batch = [];\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) break;\n batch.push(event);\n if (batch.length >= next.policy.maxFrameEvents) flushBatch();\n }\n flushBatch();\n\n return sentResult(\n next,\n frames,\n windowCapacity(next) > 0 && next.sentDurableThroughSeq < head\n ? next.sentDurableThroughSeq\n : undefined,\n );\n};\n\n/** Deliver one live ephemeral event, buffering only while this isolate is active. */\nexport const onEphemeralEvent = (\n state: EDAWebSocketDeliveryState,\n event: PositionedEvent,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const stale = staleAckResult(state, nowMs);\n if (stale !== undefined) return stale;\n\n if (windowCapacity(state) > 0 && state.pendingEphemeral.length === 0) {\n const sent = sendEventsFrame(state, [event], nowMs);\n return sentResult(sent.state, [sent.frame]);\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 }, actions: [] };\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 = applyAck(state, ack);\n if (validated._tag === \"close\") return validated.result;\n if (validated._tag === \"ignore\") return { state, actions: [] };\n\n return reopenDeliveryWindow(validated.state, nowMs);\n};\n\n/**\n * Apply one exact host-suppressed receipt without cumulatively ACKing any\n * earlier client-visible frame.\n */\nexport const onHostSuppressedFrame = (\n state: EDAWebSocketDeliveryState,\n frame: Pick<EDAWebSocketEventsFrame, \"durableThroughSeq\" | \"frameId\">,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const receipt = state.inFlight.find((candidate) => candidate.frameId === frame.frameId);\n if (receipt === undefined || receipt.durableThroughSeq !== frame.durableThroughSeq) {\n return protocolClose(state, \"Host suppressed an unknown frame receipt\").result;\n }\n const next = advanceSuppressedReceipts({\n ...state,\n inFlight: state.inFlight.filter((candidate) => candidate.frameId !== frame.frameId),\n suppressed: insertSuppressedReceipt(state.suppressed, receipt),\n });\n return reopenDeliveryWindow(next, nowMs);\n};\n\nconst reopenDeliveryWindow = (\n state: EDAWebSocketDeliveryState,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n let next = state;\n const frames: EDAWebSocketServerFrame[] = [];\n while (next.pendingEphemeral.length > 0 && windowCapacity(next) > 0) {\n const [head, ...rest] = next.pendingEphemeral;\n if (head === undefined) break;\n const sent = sendEventsFrame({ ...next, pendingEphemeral: rest }, [head], nowMs);\n next = sent.state;\n frames.push(sent.frame);\n }\n\n const stale = staleAckResult(next, nowMs);\n if (stale !== undefined) return stale;\n\n return sentResult(\n next,\n frames,\n windowCapacity(next) > 0 && next.pendingEphemeral.length === 0\n ? next.sentDurableThroughSeq\n : undefined,\n true,\n );\n};\n\ntype AckValidation =\n | { readonly _tag: \"ignore\" }\n | { readonly _tag: \"close\"; readonly result: EDAWebSocketDeliveryResult }\n | { readonly _tag: \"apply\"; readonly state: EDAWebSocketDeliveryState };\n\nconst applyAck = (state: EDAWebSocketDeliveryState, ack: EDAWebSocketAckFrame): 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 acknowledgedVisible = state.inFlight.filter((frame) => frame.frameId <= ack.frameId);\n if (acknowledgedVisible.length === 0) {\n return protocolClose(state, \"ACK referenced no in-flight frames\");\n }\n if (\n state.suppressed.some(\n (range) => range.fromFrameId <= ack.frameId && ack.frameId <= range.throughFrameId,\n )\n ) {\n return protocolClose(state, \"ACK referenced a host-suppressed frame\");\n }\n const acknowledgedSuppressed = state.suppressed.filter(\n (range) => range.throughFrameId <= ack.frameId,\n );\n const acknowledged = [...acknowledgedVisible, ...acknowledgedSuppressed];\n const allowedDurableSeq = SequenceNumber.make(\n acknowledged.reduce<number>(\n (max, receipt) => Math.max(max, receipt.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 state: advanceSuppressedReceipts({\n ...state,\n inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),\n lastAckedFrameId: ack.frameId,\n lastAckedSeq: ack.durableThroughSeq,\n suppressed: state.suppressed.filter((range) => range.throughFrameId > ack.frameId),\n }),\n };\n};\n\nconst advanceSuppressedReceipts = (state: EDAWebSocketDeliveryState): EDAWebSocketDeliveryState => {\n let lastAckedFrameId = state.lastAckedFrameId;\n let lastAckedSeq = state.lastAckedSeq;\n let consumed = 0;\n for (const range of state.suppressed) {\n if (range.fromFrameId !== lastAckedFrameId + 1) break;\n lastAckedFrameId = range.throughFrameId;\n lastAckedSeq = SequenceNumber.make(Math.max(lastAckedSeq, range.durableThroughSeq));\n consumed += 1;\n }\n return consumed === 0\n ? state\n : {\n ...state,\n lastAckedFrameId,\n lastAckedSeq,\n suppressed: state.suppressed.slice(consumed),\n };\n};\n\nconst insertSuppressedReceipt = (\n ranges: ReadonlyArray<EDAWebSocketSuppressedRange>,\n receipt: EDAWebSocketInFlightFrame,\n): ReadonlyArray<EDAWebSocketSuppressedRange> => {\n const inserted = [\n ...ranges,\n EDAWebSocketSuppressedRange.make({\n fromFrameId: receipt.frameId,\n throughFrameId: receipt.frameId,\n durableThroughSeq: receipt.durableThroughSeq,\n }),\n ].sort((left, right) => left.fromFrameId - right.fromFrameId);\n const compacted: EDAWebSocketSuppressedRange[] = [];\n for (const range of inserted) {\n const previous = compacted.at(-1);\n if (previous === undefined || range.fromFrameId > previous.throughFrameId + 1) {\n compacted.push(range);\n continue;\n }\n compacted[compacted.length - 1] = EDAWebSocketSuppressedRange.make({\n fromFrameId: previous.fromFrameId,\n throughFrameId: FrameId.make(Math.max(previous.throughFrameId, range.throughFrameId)),\n durableThroughSeq: SequenceNumber.make(\n Math.max(previous.durableThroughSeq, range.durableThroughSeq),\n ),\n });\n }\n return compacted;\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): { readonly state: EDAWebSocketDeliveryState; readonly frame: EDAWebSocketEventsFrame } => {\n const [first, ...rest] = events;\n if (first === undefined) throw new Error(\"Cannot send an empty events frame\");\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: [first, ...rest],\n durableThroughSeq,\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 frame,\n };\n};\n\nconst sentResult = (\n state: EDAWebSocketDeliveryState,\n frames: ReadonlyArray<EDAWebSocketServerFrame>,\n catchUpAfterSeq?: SequenceNumber,\n stateChanged = frames.length > 0,\n): EDAWebSocketDeliveryResult => ({\n state,\n actions: [\n ...(stateChanged ? ([{ _tag: \"Persist\" }] as const) : []),\n ...(frames.length > 0 ? ([{ _tag: \"Send\", frames }] as const) : []),\n ...(catchUpAfterSeq === undefined\n ? []\n : ([{ _tag: \"ReadEventPage\", afterSeq: catchUpAfterSeq }] as const)),\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 state.inFlight.some((frame) => frame.sentAtMs + state.policy.ackTimeoutMs <= nowMs)\n ? laggedResult(state, \"ack-timeout\")\n : undefined;\n\nconst laggedResult = (\n state: EDAWebSocketDeliveryState,\n reason: SubscriberLagReason,\n): EDAWebSocketDeliveryResult => ({\n state,\n actions: [\n {\n _tag: \"Send\",\n frames: [\n EDAWebSocketLaggedFrame.make({\n _tag: \"lagged\",\n resumeSeq: state.lastAckedSeq,\n reason,\n }),\n ],\n },\n { _tag: \"Close\", code: EDA_WS_CLOSE_LAGGED, reason: laggedCloseReason(state.lastAckedSeq) },\n ],\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 actions: [\n {\n _tag: \"Send\",\n frames: [EDAWebSocketErrorFrame.make({ _tag: \"error\", message: message.slice(0, 120) })],\n },\n { _tag: \"Close\", code: EDA_WS_CLOSE_PROTOCOL_ERROR, reason: \"protocol\" },\n ],\n },\n});\n"],"mappings":";;;;;;AAKA,MAAM,cAAc,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAC5D,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;;AAGxE,MAAa,uCAAuC;;AAGpD,MAAa,8BAA8B,OAAO,OAAO;CACvD,cAAc;;CAEd,qBAAqB;CACrB,eAAe;CACf,gBAAgB;CAChB,mBAAmB;;CAEnB,gBAAgB,OAAO,YAAY,WAAW;CAC9C,gCAAgC;AAClC,CAAC;;;;;;;AASD,MAAa,8BAA8B;;AAG3C,MAAa,8BAA8B;;AAG3C,MAAa,4BAA4B,OAAO,OAAO,EACrD,MAAM,OAAO,QAAQ,MAAM,EAC7B,CAAC;;AAID,MAAa,4B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M;GAAiB,UAAU;EAAgB,CAAC;CAC5D;AACF;;AAGA,MAAM,kBACJ,OACA,UAEA,MAAM,SAAS,MAAM,UAAU,MAAM,WAAW,MAAM,OAAO,gBAAgB,KAAK,IAC9E,aAAa,OAAO,aAAa,IACjC,KAAA;AAEN,MAAM,gBACJ,OACA,YACgC;CAChC;CACA,SAAS,CACP;EACE,MAAM;EACN,QAAQ,CACN,wBAAwB,KAAK;GAC3B,MAAM;GACN,WAAW,MAAM;GACjB;EACF,CAAC,CACH;CACF,GACA;EAAE,MAAM;EAAS,MAAM;EAAqB,QAAQ,kBAAkB,MAAM,YAAY;CAAE,CAC5F;AACF;AAEA,MAAM,iBACJ,OACA,aAC6E;CAC7E,MAAM;CACN,QAAQ;EACN;EACA,SAAS,CACP;GACE,MAAM;GACN,QAAQ,CAAC,uBAAuB,KAAK;IAAE,MAAM;IAAS,SAAS,QAAQ,MAAM,GAAG,GAAG;GAAE,CAAC,CAAC;EACzF,GACA;GAAE,MAAM;GAAS,MAAM;GAA6B,QAAQ;EAAW,CACzE;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"websocket.js","names":[],"sources":["../src/websocket/protocol.ts","../src/websocket/messages.ts","../src/websocket/delivery.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { Position } from \"../types/core\";\nimport { EDADurableEvent, EDAEphemeralEvent, EventEnvelope } from \"../types/events\";\n\nconst PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));\nconst NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\n/** Current EDA live-event WebSocket wire protocol version. */\nexport const EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION = 1 as const;\n\n/** Flow-control policy announced by the server in the hello frame. */\nexport const EDAWebSocketWireFlowControl = Schema.Struct({\n ackTimeoutMs: PositiveInt,\n /** Deprecated: servers no longer send heartbeat frames. Kept so deployed clients can decode hello. */\n heartbeatIntervalMs: PositiveInt,\n maxFrameBytes: PositiveInt,\n maxFrameEvents: PositiveInt,\n maxInFlightFrames: PositiveInt,\n /** Suggested client-originated ping cadence; absent on servers that still send heartbeats. */\n pingIntervalMs: Schema.optionalKey(PositiveInt),\n subscriberBufferCapacityEvents: PositiveInt,\n});\nexport type EDAWebSocketWireFlowControl = typeof EDAWebSocketWireFlowControl.Type;\n\n/**\n * Canonical client liveness ping message.\n *\n * The exact string matters: hibernation-capable hosts register it with\n * WebSocket auto-response so the runtime answers without waking the object.\n */\nexport const EDA_WEB_SOCKET_PING_MESSAGE = '{\"_tag\":\"ping\"}';\n\n/** Canonical server pong message paired with {@link EDA_WEB_SOCKET_PING_MESSAGE}. */\nexport const EDA_WEB_SOCKET_PONG_MESSAGE = '{\"_tag\":\"pong\"}';\n\n/** Client liveness ping; hosts answer with a pong and never ACK-track it. */\nexport const EDAWebSocketWirePingFrame = Schema.Struct({\n _tag: Schema.Literal(\"ping\"),\n});\nexport type EDAWebSocketWirePingFrame = typeof EDAWebSocketWirePingFrame.Type;\n\n/** Server liveness pong; clients may ignore it and must not ACK it. */\nexport const EDAWebSocketWirePongFrame = Schema.Struct({\n _tag: Schema.Literal(\"pong\"),\n});\nexport type EDAWebSocketWirePongFrame = typeof EDAWebSocketWirePongFrame.Type;\n\nexport const EDAWebSocketWireHelloFrame = Schema.Struct({\n _tag: Schema.Literal(\"hello\"),\n protocolVersion: Schema.Literal(EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION),\n subscriberId: Schema.NonEmptyString,\n resumeSeq: NonNegativeInt,\n flowControl: EDAWebSocketWireFlowControl,\n});\nexport type EDAWebSocketWireHelloFrame = typeof EDAWebSocketWireHelloFrame.Type;\n\nexport const EDAWebSocketWireHeartbeatFrame = Schema.Struct({\n _tag: Schema.Literal(\"heartbeat\"),\n serverTimeMs: NonNegativeInt,\n durableThroughSeq: NonNegativeInt,\n});\nexport type EDAWebSocketWireHeartbeatFrame = typeof EDAWebSocketWireHeartbeatFrame.Type;\n\nexport const EDAWebSocketWireLaggedFrame = Schema.Struct({\n _tag: Schema.Literal(\"lagged\"),\n resumeSeq: NonNegativeInt,\n reason: Schema.Literals([\"buffer-overflow\", \"ack-timeout\"]),\n});\nexport type EDAWebSocketWireLaggedFrame = typeof EDAWebSocketWireLaggedFrame.Type;\n\nexport const EDAWebSocketWireErrorFrame = Schema.Struct({\n _tag: Schema.Literal(\"error\"),\n message: Schema.String,\n});\nexport type EDAWebSocketWireErrorFrame = typeof EDAWebSocketWireErrorFrame.Type;\n\nexport const EDAWebSocketWireAckFrame = Schema.Struct({\n _tag: Schema.Literal(\"ack\"),\n frameId: PositiveInt,\n durableThroughSeq: NonNegativeInt,\n});\nexport type EDAWebSocketWireAckFrame = typeof EDAWebSocketWireAckFrame.Type;\n\nexport const EDAWebSocketWireClientFrame = Schema.Union([\n EDAWebSocketWireAckFrame,\n EDAWebSocketWirePingFrame,\n]);\nexport type EDAWebSocketWireClientFrame = typeof EDAWebSocketWireClientFrame.Type;\n\n/** Exhaustive decision table for a concrete WebSocket event union. */\nexport type EDAWebSocketEventConsumerPolicy<\n Event extends { readonly type: string },\n Disposition,\n> = Readonly<Record<Event[\"type\"], Disposition>>;\n\n/** Complete framework-owned event union present on every EDA WebSocket. */\nexport const EDAFrameworkWebSocketEvent = Schema.Union([EDADurableEvent, EDAEphemeralEvent]);\nexport type EDAFrameworkWebSocketEvent = typeof EDAFrameworkWebSocketEvent.Type;\n\nconst makeEDAWebSocketDomainSchemas = <\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n>(\n event: EventSchema,\n) => {\n const positionedEvent = Schema.Struct({\n position: Position,\n event,\n });\n const eventsFrame = Schema.Struct({\n _tag: Schema.Literal(\"events\"),\n frameId: PositiveInt,\n events: Schema.NonEmptyArray(positionedEvent),\n durableThroughSeq: NonNegativeInt,\n });\n const serverFrame = Schema.Union([\n EDAWebSocketWireHelloFrame,\n eventsFrame,\n EDAWebSocketWireHeartbeatFrame,\n EDAWebSocketWirePongFrame,\n EDAWebSocketWireLaggedFrame,\n EDAWebSocketWireErrorFrame,\n ]);\n return { event, positionedEvent, eventsFrame, serverFrame };\n};\n\ntype EDAWebSocketDomainSchemas<\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n> = ReturnType<typeof makeEDAWebSocketDomainSchemas<EventSchema>>;\n\nconst EDAWebSocketHostDomain = makeEDAWebSocketDomainSchemas(EventEnvelope);\n\n/** Domain frame shape accepted by an app-bound encoder at the EDA host boundary. */\nexport type EDAWebSocketServerFrameInput = typeof EDAWebSocketHostDomain.serverFrame.Type;\n\n/** Minimal typed encoder surface consumed by an EDA host. */\nexport interface EDAWebSocketServerFrameEncoder {\n readonly encodeServerFrame: (frame: EDAWebSocketServerFrameInput) => string;\n}\n\n/** App-bound domain schemas, wire schemas, and encoders for protocol version 1. */\nexport interface EDAWebSocketWireProtocol<\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n> {\n /** Exact app-bound schemas whose `Type` values are used inside the server. */\n readonly domain: EDAWebSocketDomainSchemas<EventSchema>;\n /** Exact app-bound schemas whose `Type` values are the serialized JSON representation. */\n readonly wire: {\n readonly event: Schema.toEncoded<EventSchema>;\n readonly positionedEvent: Schema.toEncoded<\n EDAWebSocketDomainSchemas<EventSchema>[\"positionedEvent\"]\n >;\n readonly eventsFrame: Schema.toEncoded<EDAWebSocketDomainSchemas<EventSchema>[\"eventsFrame\"]>;\n readonly serverFrame: Schema.toEncoded<EDAWebSocketDomainSchemas<EventSchema>[\"serverFrame\"]>;\n readonly clientFrame: typeof EDAWebSocketWireClientFrame;\n };\n /** Serialize one exact app-bound domain frame to a JSON text message. */\n readonly encodeServerFrame: (\n frame: Schema.Schema.Type<EDAWebSocketDomainSchemas<EventSchema>[\"serverFrame\"]>,\n ) => string;\n /** Validate broad host frames against the app event union before serialization. */\n readonly host: EDAWebSocketServerFrameEncoder;\n}\n\nconst makeEDAWebSocketWireProtocolFromEventSchema = <\n EventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n>(\n event: EventSchema,\n): EDAWebSocketWireProtocol<EventSchema> => {\n const domain = makeEDAWebSocketDomainSchemas(event);\n const encodeDomainServerFrame = Schema.encodeSync(domain.serverFrame);\n const encodeUnknownDomainServerFrame = Schema.encodeUnknownSync(domain.serverFrame);\n const encodeServerFrame = (frame: typeof domain.serverFrame.Type): string =>\n JSON.stringify(encodeDomainServerFrame(frame));\n const host: EDAWebSocketServerFrameEncoder = {\n encodeServerFrame: (frame) => JSON.stringify(encodeUnknownDomainServerFrame(frame)),\n };\n\n return {\n domain,\n wire: {\n event: Schema.toEncoded(domain.event),\n positionedEvent: Schema.toEncoded(domain.positionedEvent),\n eventsFrame: Schema.toEncoded(domain.eventsFrame),\n serverFrame: Schema.toEncoded(domain.serverFrame),\n clientFrame: EDAWebSocketWireClientFrame,\n },\n encodeServerFrame,\n host,\n };\n};\n\n/** Strict framework-only protocol used when an app registers no custom events. */\nexport const edaFrameworkWebSocketWireProtocol: EDAWebSocketWireProtocol<\n typeof EDAFrameworkWebSocketEvent\n> = makeEDAWebSocketWireProtocolFromEventSchema(EDAFrameworkWebSocketEvent);\n\n/**\n * Bind the generic EDA WebSocket transport to one app's custom event schema.\n *\n * Framework durable and ephemeral events are included automatically. Future EDA\n * apps register only their custom events. Servers use the returned domain schemas\n * and typed encoder; external consumers decode with the wire schemas. Pass the\n * returned `host` adapter to the selected host package.\n */\nexport const makeEDAWebSocketWireProtocol = <\n AppEventSchema extends Schema.Codec<EventEnvelope, unknown, never, never>,\n>(options: {\n readonly appEvents: AppEventSchema;\n}): EDAWebSocketWireProtocol<\n Schema.Union<readonly [typeof EDAFrameworkWebSocketEvent, AppEventSchema]>\n> =>\n makeEDAWebSocketWireProtocolFromEventSchema(\n Schema.Union([EDAFrameworkWebSocketEvent, options.appEvents]),\n );\n","import * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport {\n EDA_WEB_SOCKET_PING_MESSAGE,\n EDA_WEB_SOCKET_PONG_MESSAGE,\n EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION,\n EDAWebSocketWireAckFrame,\n EDAWebSocketWireClientFrame,\n EDAWebSocketWireErrorFrame,\n EDAWebSocketWireFlowControl,\n EDAWebSocketWireHeartbeatFrame,\n EDAWebSocketWireHelloFrame,\n EDAWebSocketWireLaggedFrame,\n EDAWebSocketWirePingFrame,\n EDAWebSocketWirePongFrame,\n edaFrameworkWebSocketWireProtocol,\n type EDAWebSocketServerFrameEncoder,\n} from \"./protocol\";\n\nexport { EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE };\n\nimport { SequenceNumber } from \"../types/core\";\nimport { PositionedEvent, UnixEpochMillis } from \"../types/events\";\n\n/** Current EDA live-event WebSocket protocol version. */\nexport const EDA_WEB_SOCKET_PROTOCOL_VERSION = EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION;\n\n/** WebSocket close code used when a subscriber cannot keep up with live delivery. */\nexport const EDA_WS_CLOSE_LAGGED = 4008;\n\n/** WebSocket close code used for normal host-driven shutdown. */\nexport const EDA_WS_CLOSE_GOING_AWAY = 1001;\n\n/** WebSocket close code used for malformed client protocol messages. */\nexport const EDA_WS_CLOSE_PROTOCOL_ERROR = 1002;\n\n/** WebSocket close code used when the host cannot send a frame. */\nexport const EDA_WS_CLOSE_SEND_FAILED = 1011;\n\n/** WebSocket close code used for unsupported binary messages. */\nexport const EDA_WS_CLOSE_UNSUPPORTED_DATA = 1003;\n\n/** Live subscriber identity persisted in WebSocket attachments. */\nexport const SubscriberId = Schema.NonEmptyString.pipe(Schema.brand(\"SubscriberId\"));\nexport type SubscriberId = typeof SubscriberId.Type;\n\n/** Per-connection monotonically increasing server frame id. */\nexport const FrameId = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(\n Schema.brand(\"FrameId\"),\n);\nexport type FrameId = typeof FrameId.Type;\n\n/** Flow-control policy announced by the server in the hello frame. */\nexport const EDAWebSocketFlowControl = EDAWebSocketWireFlowControl;\nexport type EDAWebSocketFlowControl = typeof EDAWebSocketFlowControl.Type;\n\n/** Default bounded policy sized for fast model deltas and large durable tool/message events. */\nexport const defaultEDAWebSocketFlowControl: EDAWebSocketFlowControl = {\n ackTimeoutMs: 30_000,\n // Deprecated wire-compat field: servers no longer schedule or send heartbeats.\n heartbeatIntervalMs: 10_000,\n maxFrameBytes: 256 * 1024,\n maxFrameEvents: 1,\n maxInFlightFrames: 16,\n pingIntervalMs: 30_000,\n subscriberBufferCapacityEvents: 2_048,\n};\n\n/** First server frame; announces protocol and flow-control policy. */\nexport const EDAWebSocketHelloFrame = Schema.Struct({\n ...EDAWebSocketWireHelloFrame.fields,\n subscriberId: SubscriberId,\n resumeSeq: SequenceNumber,\n});\nexport type EDAWebSocketHelloFrame = typeof EDAWebSocketHelloFrame.Type;\n\n/** Ordered positioned events delivered to the client. */\nexport const EDAWebSocketEventsFrame = Schema.Struct({\n _tag: Schema.Literal(\"events\"),\n frameId: FrameId,\n events: Schema.NonEmptyArray(PositionedEvent),\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketEventsFrame = typeof EDAWebSocketEventsFrame.Type;\n\n/**\n * Deprecated idle server keepalive frame.\n *\n * Servers no longer send heartbeats; the schema remains so deployed clients\n * keep decoding the server frame union. Liveness is client-originated via\n * {@link EDAWebSocketPingFrame} and the host-level auto-response pong.\n */\nexport const EDAWebSocketHeartbeatFrame = Schema.Struct({\n ...EDAWebSocketWireHeartbeatFrame.fields,\n serverTimeMs: UnixEpochMillis,\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketHeartbeatFrame = typeof EDAWebSocketHeartbeatFrame.Type;\n\n/** Client liveness ping; hosts answer with a pong and never ACK-track it. */\nexport const EDAWebSocketPingFrame = EDAWebSocketWirePingFrame;\nexport type EDAWebSocketPingFrame = typeof EDAWebSocketPingFrame.Type;\n\n/** Server liveness pong; clients may ignore it and must not ACK it. */\nexport const EDAWebSocketPongFrame = EDAWebSocketWirePongFrame;\nexport type EDAWebSocketPongFrame = typeof EDAWebSocketPongFrame.Type;\n\n/** Optional final frame sent before a lag-close. */\nexport const EDAWebSocketLaggedFrame = Schema.Struct({\n ...EDAWebSocketWireLaggedFrame.fields,\n resumeSeq: SequenceNumber,\n});\nexport type EDAWebSocketLaggedFrame = typeof EDAWebSocketLaggedFrame.Type;\n\n/** Optional final frame sent before a protocol/internal close. */\nexport const EDAWebSocketErrorFrame = EDAWebSocketWireErrorFrame;\nexport type EDAWebSocketErrorFrame = typeof EDAWebSocketErrorFrame.Type;\n\n/** Server-to-client application frame union. */\nexport const EDAWebSocketServerFrame = Schema.Union([\n EDAWebSocketHelloFrame,\n EDAWebSocketEventsFrame,\n EDAWebSocketHeartbeatFrame,\n EDAWebSocketPongFrame,\n EDAWebSocketLaggedFrame,\n EDAWebSocketErrorFrame,\n]);\nexport type EDAWebSocketServerFrame = typeof EDAWebSocketServerFrame.Type;\n\n/** Client acknowledgement after applying a server frame. */\nexport const EDAWebSocketAckFrame = Schema.Struct({\n ...EDAWebSocketWireAckFrame.fields,\n frameId: FrameId,\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketAckFrame = typeof EDAWebSocketAckFrame.Type;\n\n/** Client-to-server application frame union. */\nexport const EDAWebSocketClientFrame = Schema.Union([EDAWebSocketAckFrame, EDAWebSocketPingFrame]);\nexport type EDAWebSocketClientFrame = typeof EDAWebSocketClientFrame.Type;\n\n/** Serialize a server frame for a text WebSocket message. */\nexport const encodeEDAWebSocketServerFrame = (\n frame: EDAWebSocketServerFrame,\n protocol?: EDAWebSocketServerFrameEncoder,\n): string => (protocol ?? edaFrameworkWebSocketWireProtocol.host).encodeServerFrame(frame);\n\n/** Decode an inbound text WebSocket message at the host boundary. */\nexport const decodeEDAWebSocketClientMessage = (\n input: string,\n): Effect.Effect<EDAWebSocketClientFrame, unknown> =>\n Effect.try({\n try: () => JSON.parse(input) as unknown,\n catch: (error) => error,\n }).pipe(\n Effect.flatMap((json) => Schema.decodeUnknownEffect(EDAWebSocketWireClientFrame)(json)),\n Effect.flatMap((frame) => Schema.decodeUnknownEffect(EDAWebSocketClientFrame)(frame)),\n );\n\n/** Short close reason that fits the WebSocket protocol reason limit. */\nexport const laggedCloseReason = (seq: SequenceNumber): string => `lag;seq=${seq}`;\n","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 \"./messages\";\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 const EDAWebSocketInFlightFrame = Schema.Struct({\n frameId: FrameId,\n durableThroughSeq: SequenceNumber,\n sentAtMs: Schema.Number,\n});\nexport type EDAWebSocketInFlightFrame = typeof EDAWebSocketInFlightFrame.Type;\n\n/** Compact consecutive host-suppressed receipts blocked by a visible ACK. */\nexport const EDAWebSocketSuppressedRange = Schema.Struct({\n fromFrameId: FrameId,\n throughFrameId: FrameId,\n durableThroughSeq: SequenceNumber,\n});\nexport type EDAWebSocketSuppressedRange = typeof EDAWebSocketSuppressedRange.Type;\n\n/** Complete delivery bookkeeping persisted in the WebSocket attachment. */\nexport const EDAWebSocketDeliveryCheckpoint = Schema.Struct({\n lastAckedSeq: SequenceNumber,\n lastAckedFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n lastSentFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n nextFrameId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),\n sentDurableThroughSeq: SequenceNumber,\n inFlight: Schema.Array(EDAWebSocketInFlightFrame),\n /** Host-projected receipts waiting behind an earlier client-visible ACK. */\n suppressed: Schema.optionalKey(Schema.Array(EDAWebSocketSuppressedRange)),\n});\nexport type EDAWebSocketDeliveryCheckpoint = typeof EDAWebSocketDeliveryCheckpoint.Type;\n\n/** In-memory delivery state for one accepted event WebSocket. */\nexport interface EDAWebSocketDeliveryState extends EDAWebSocketDeliveryCheckpoint {\n readonly subscriberId: SubscriberId;\n readonly policy: EDAWebSocketFlowControl;\n /** Ephemeral events are live-only and intentionally absent from the attachment. */\n readonly pendingEphemeral: ReadonlyArray<PositionedEvent>;\n readonly suppressed: ReadonlyArray<EDAWebSocketSuppressedRange>;\n}\n\n/** Explicit instructions emitted by the pure delivery state machine. */\nexport type EDAWebSocketDeliveryAction =\n | { readonly _tag: \"Persist\" }\n | { readonly _tag: \"Send\"; readonly frames: ReadonlyArray<EDAWebSocketServerFrame> }\n | { readonly _tag: \"ReadEventPage\"; readonly afterSeq: SequenceNumber }\n | { readonly _tag: \"Close\"; readonly code: number; readonly reason: string };\n\n/** Result of one pure delivery transition. */\nexport interface EDAWebSocketDeliveryResult {\n readonly state: EDAWebSocketDeliveryState;\n readonly actions: ReadonlyArray<EDAWebSocketDeliveryAction>;\n}\n\nexport interface MakeDeliveryStateInput {\n readonly subscriberId: SubscriberId;\n readonly resumeSeq: SequenceNumber;\n readonly policy: EDAWebSocketFlowControl;\n}\n\n/** Build delivery state for a newly accepted connection. */\nexport const makeWebSocketDeliveryState = (\n input: MakeDeliveryStateInput,\n): EDAWebSocketDeliveryState => ({\n subscriberId: input.subscriberId,\n policy: input.policy,\n lastAckedSeq: input.resumeSeq,\n lastAckedFrameId: 0,\n lastSentFrameId: 0,\n nextFrameId: 1,\n sentDurableThroughSeq: input.resumeSeq,\n inFlight: [],\n suppressed: [],\n pendingEphemeral: [],\n});\n\n/** Rebuild exact ACK bookkeeping from a hibernating WebSocket attachment. */\nexport const restoreWebSocketDeliveryState = (input: {\n readonly subscriberId: SubscriberId;\n readonly policy: EDAWebSocketFlowControl;\n readonly checkpoint: EDAWebSocketDeliveryCheckpoint;\n}): EDAWebSocketDeliveryState => ({\n subscriberId: input.subscriberId,\n policy: input.policy,\n ...input.checkpoint,\n pendingEphemeral: [],\n suppressed: input.checkpoint.suppressed ?? [],\n});\n\n/** Project in-memory delivery state into the attachment-safe checkpoint. */\nexport const checkpointWebSocketDeliveryState = (\n state: EDAWebSocketDeliveryState,\n): EDAWebSocketDeliveryCheckpoint => ({\n lastAckedSeq: state.lastAckedSeq,\n lastAckedFrameId: state.lastAckedFrameId,\n lastSentFrameId: state.lastSentFrameId,\n nextFrameId: state.nextFrameId,\n sentDurableThroughSeq: state.sentDurableThroughSeq,\n inFlight: state.inFlight,\n ...(state.suppressed.length === 0 ? {} : { suppressed: state.suppressed }),\n});\n\n/** First frame for a freshly accepted connection. 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/** Deliver committed durable events read from the store. */\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) return stale;\n\n let next = state;\n const frames: EDAWebSocketServerFrame[] = [];\n let batch: PositionedEvent[] = [];\n\n const flushBatch = (): void => {\n if (batch.length === 0) return;\n const sent = sendEventsFrame(next, batch, nowMs);\n next = sent.state;\n frames.push(sent.frame);\n batch = [];\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) break;\n batch.push(event);\n if (batch.length >= next.policy.maxFrameEvents) flushBatch();\n }\n flushBatch();\n\n return sentResult(\n next,\n frames,\n windowCapacity(next) > 0 && next.sentDurableThroughSeq < head\n ? next.sentDurableThroughSeq\n : undefined,\n );\n};\n\n/** Deliver one live ephemeral event, buffering only while this isolate is active. */\nexport const onEphemeralEvent = (\n state: EDAWebSocketDeliveryState,\n event: PositionedEvent,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const stale = staleAckResult(state, nowMs);\n if (stale !== undefined) return stale;\n\n if (windowCapacity(state) > 0 && state.pendingEphemeral.length === 0) {\n const sent = sendEventsFrame(state, [event], nowMs);\n return sentResult(sent.state, [sent.frame]);\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 }, actions: [] };\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 = applyAck(state, ack);\n if (validated._tag === \"close\") return validated.result;\n if (validated._tag === \"ignore\") return { state, actions: [] };\n\n return reopenDeliveryWindow(validated.state, nowMs);\n};\n\n/**\n * Apply one exact host-suppressed receipt without cumulatively ACKing any\n * earlier client-visible frame.\n */\nexport const onHostSuppressedFrame = (\n state: EDAWebSocketDeliveryState,\n frame: Pick<EDAWebSocketEventsFrame, \"durableThroughSeq\" | \"frameId\">,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n const receipt = state.inFlight.find((candidate) => candidate.frameId === frame.frameId);\n if (receipt === undefined || receipt.durableThroughSeq !== frame.durableThroughSeq) {\n return protocolClose(state, \"Host suppressed an unknown frame receipt\").result;\n }\n const next = advanceSuppressedReceipts({\n ...state,\n inFlight: state.inFlight.filter((candidate) => candidate.frameId !== frame.frameId),\n suppressed: insertSuppressedReceipt(state.suppressed, receipt),\n });\n return reopenDeliveryWindow(next, nowMs);\n};\n\nconst reopenDeliveryWindow = (\n state: EDAWebSocketDeliveryState,\n nowMs: number,\n): EDAWebSocketDeliveryResult => {\n let next = state;\n const frames: EDAWebSocketServerFrame[] = [];\n while (next.pendingEphemeral.length > 0 && windowCapacity(next) > 0) {\n const [head, ...rest] = next.pendingEphemeral;\n if (head === undefined) break;\n const sent = sendEventsFrame({ ...next, pendingEphemeral: rest }, [head], nowMs);\n next = sent.state;\n frames.push(sent.frame);\n }\n\n const stale = staleAckResult(next, nowMs);\n if (stale !== undefined) return stale;\n\n return sentResult(\n next,\n frames,\n windowCapacity(next) > 0 && next.pendingEphemeral.length === 0\n ? next.sentDurableThroughSeq\n : undefined,\n true,\n );\n};\n\ntype AckValidation =\n | { readonly _tag: \"ignore\" }\n | { readonly _tag: \"close\"; readonly result: EDAWebSocketDeliveryResult }\n | { readonly _tag: \"apply\"; readonly state: EDAWebSocketDeliveryState };\n\nconst applyAck = (state: EDAWebSocketDeliveryState, ack: EDAWebSocketAckFrame): 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 acknowledgedVisible = state.inFlight.filter((frame) => frame.frameId <= ack.frameId);\n if (acknowledgedVisible.length === 0) {\n return protocolClose(state, \"ACK referenced no in-flight frames\");\n }\n if (\n state.suppressed.some(\n (range) => range.fromFrameId <= ack.frameId && ack.frameId <= range.throughFrameId,\n )\n ) {\n return protocolClose(state, \"ACK referenced a host-suppressed frame\");\n }\n const acknowledgedSuppressed = state.suppressed.filter(\n (range) => range.throughFrameId <= ack.frameId,\n );\n const acknowledged = [...acknowledgedVisible, ...acknowledgedSuppressed];\n const allowedDurableSeq = SequenceNumber.make(\n acknowledged.reduce<number>(\n (max, receipt) => Math.max(max, receipt.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 state: advanceSuppressedReceipts({\n ...state,\n inFlight: state.inFlight.filter((frame) => frame.frameId > ack.frameId),\n lastAckedFrameId: ack.frameId,\n lastAckedSeq: ack.durableThroughSeq,\n suppressed: state.suppressed.filter((range) => range.throughFrameId > ack.frameId),\n }),\n };\n};\n\nconst advanceSuppressedReceipts = (state: EDAWebSocketDeliveryState): EDAWebSocketDeliveryState => {\n let lastAckedFrameId = state.lastAckedFrameId;\n let lastAckedSeq = state.lastAckedSeq;\n let consumed = 0;\n for (const range of state.suppressed) {\n if (range.fromFrameId !== lastAckedFrameId + 1) break;\n lastAckedFrameId = range.throughFrameId;\n lastAckedSeq = SequenceNumber.make(Math.max(lastAckedSeq, range.durableThroughSeq));\n consumed += 1;\n }\n return consumed === 0\n ? state\n : {\n ...state,\n lastAckedFrameId,\n lastAckedSeq,\n suppressed: state.suppressed.slice(consumed),\n };\n};\n\nconst insertSuppressedReceipt = (\n ranges: ReadonlyArray<EDAWebSocketSuppressedRange>,\n receipt: EDAWebSocketInFlightFrame,\n): ReadonlyArray<EDAWebSocketSuppressedRange> => {\n const inserted = [\n ...ranges,\n EDAWebSocketSuppressedRange.make({\n fromFrameId: receipt.frameId,\n throughFrameId: receipt.frameId,\n durableThroughSeq: receipt.durableThroughSeq,\n }),\n ].sort((left, right) => left.fromFrameId - right.fromFrameId);\n const compacted: EDAWebSocketSuppressedRange[] = [];\n for (const range of inserted) {\n const previous = compacted.at(-1);\n if (previous === undefined || range.fromFrameId > previous.throughFrameId + 1) {\n compacted.push(range);\n continue;\n }\n compacted[compacted.length - 1] = EDAWebSocketSuppressedRange.make({\n fromFrameId: previous.fromFrameId,\n throughFrameId: FrameId.make(Math.max(previous.throughFrameId, range.throughFrameId)),\n durableThroughSeq: SequenceNumber.make(\n Math.max(previous.durableThroughSeq, range.durableThroughSeq),\n ),\n });\n }\n return compacted;\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): { readonly state: EDAWebSocketDeliveryState; readonly frame: EDAWebSocketEventsFrame } => {\n const [first, ...rest] = events;\n if (first === undefined) throw new Error(\"Cannot send an empty events frame\");\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: [first, ...rest],\n durableThroughSeq,\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 frame,\n };\n};\n\nconst sentResult = (\n state: EDAWebSocketDeliveryState,\n frames: ReadonlyArray<EDAWebSocketServerFrame>,\n catchUpAfterSeq?: SequenceNumber,\n stateChanged = frames.length > 0,\n): EDAWebSocketDeliveryResult => ({\n state,\n actions: [\n ...(stateChanged ? ([{ _tag: \"Persist\" }] as const) : []),\n ...(frames.length > 0 ? ([{ _tag: \"Send\", frames }] as const) : []),\n ...(catchUpAfterSeq === undefined\n ? []\n : ([{ _tag: \"ReadEventPage\", afterSeq: catchUpAfterSeq }] as const)),\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 state.inFlight.some((frame) => frame.sentAtMs + state.policy.ackTimeoutMs <= nowMs)\n ? laggedResult(state, \"ack-timeout\")\n : undefined;\n\nconst laggedResult = (\n state: EDAWebSocketDeliveryState,\n reason: SubscriberLagReason,\n): EDAWebSocketDeliveryResult => ({\n state,\n actions: [\n {\n _tag: \"Send\",\n frames: [\n EDAWebSocketLaggedFrame.make({\n _tag: \"lagged\",\n resumeSeq: state.lastAckedSeq,\n reason,\n }),\n ],\n },\n { _tag: \"Close\", code: EDA_WS_CLOSE_LAGGED, reason: laggedCloseReason(state.lastAckedSeq) },\n ],\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 actions: [\n {\n _tag: \"Send\",\n frames: [EDAWebSocketErrorFrame.make({ _tag: \"error\", message: message.slice(0, 120) })],\n },\n { _tag: \"Close\", code: EDA_WS_CLOSE_PROTOCOL_ERROR, reason: \"protocol\" },\n ],\n },\n});\n"],"mappings":";;;;;;;AAKA,MAAM,cAAc,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAC5D,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;;AAGxE,MAAa,uCAAuC;;AAGpD,MAAa,8BAA8B,OAAO,OAAO;CACvD,cAAc;;CAEd,qBAAqB;CACrB,eAAe;CACf,gBAAgB;CAChB,mBAAmB;;CAEnB,gBAAgB,OAAO,YAAY,WAAW;CAC9C,gCAAgC;AAClC,CAAC;;;;;;;AASD,MAAa,8BAA8B;;AAG3C,MAAa,8BAA8B;;AAG3C,MAAa,4BAA4B,OAAO,OAAO,EACrD,MAAM,OAAO,QAAQ,MAAM,EAC7B,CAAC;;AAID,MAAa,4BAA4B,OAAO,OAAO,EAC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B,CAAC;CAC5D;AACF;;AAGA,MAAM,kBACJ,OACA,UAEA,MAAM,SAAS,MAAM,UAAU,MAAM,WAAW,MAAM,OAAO,gBAAgB,KAAK,IAC9E,aAAa,OAAO,aAAa,IACjC,KAAA;AAEN,MAAM,gBACJ,OACA,YACgC;CAChC;CACA,SAAS,CACP;EACE,MAAM;EACN,QAAQ,CACN,wBAAwB,KAAK;GAC3B,MAAM;GACN,WAAW,MAAM;GACjB;EACF,CAAC,CACH;CACF,GACA;EAAE,MAAM;EAAS,MAAM;EAAqB,QAAQ,kBAAkB,MAAM,YAAY;CAAE,CAC5F;AACF;AAEA,MAAM,iBACJ,OACA,aAC6E;CAC7E,MAAM;CACN,QAAQ;EACN;EACA,SAAS,CACP;GACE,MAAM;GACN,QAAQ,CAAC,uBAAuB,KAAK;IAAE,MAAM;IAAS,SAAS,QAAQ,MAAM,GAAG,GAAG;GAAE,CAAC,CAAC;EACzF,GACA;GAAE,MAAM;GAAS,MAAM;GAA6B,QAAQ;EAAW,CACzE;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-durable-agent",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
4
|
"description": "A host-independent, event-sourced durable state-management and execution layer for agentic applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
"tooling/oxlint/rules/*.mjs"
|
|
31
31
|
],
|
|
32
32
|
"exports": {
|
|
33
|
+
"./services/model-resolver": {
|
|
34
|
+
"types": "./dist/services/model-resolver.d.ts",
|
|
35
|
+
"import": "./dist/services/model-resolver.js"
|
|
36
|
+
},
|
|
37
|
+
"./domain/model-usage": {
|
|
38
|
+
"types": "./dist/domain/model-usage.d.ts",
|
|
39
|
+
"import": "./dist/domain/model-usage.js"
|
|
40
|
+
},
|
|
33
41
|
".": {
|
|
34
42
|
"types": "./dist/index.d.ts",
|
|
35
43
|
"import": "./dist/index.js"
|
|
@@ -161,6 +169,7 @@
|
|
|
161
169
|
"@cloudflare/workers-types": "5.20260813.1",
|
|
162
170
|
"@effect/ai-openai": "4.0.0-beta.102",
|
|
163
171
|
"@effect/tsgo": "0.31.0",
|
|
172
|
+
"@effect/vitest": "4.0.0-beta.102",
|
|
164
173
|
"@types/node": "^25.7.0",
|
|
165
174
|
"effect": "4.0.0-beta.102",
|
|
166
175
|
"esbuild": "^0.28.1",
|