effect-durable-agent 0.1.0-alpha.13 → 0.1.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/{compaction-CYItD6di.d.ts → compaction-DYAlYxx5.d.ts} +2 -2
  2. package/dist/index.d.ts +1 -1
  3. package/dist/{runtime-BRURBOyt.d.ts → runtime-Ca8Qw1fl.d.ts} +3 -3
  4. package/dist/services/compaction.d.ts +1 -1
  5. package/dist/services/runtime-layer.d.ts +4 -4
  6. package/dist/services/runtime-layer.js +2 -2
  7. package/dist/services/runtime.d.ts +1 -1
  8. package/dist/services/runtime.js +1 -1
  9. package/dist/services/session-query.d.ts +1 -1
  10. package/dist/services/session-query.js +1 -2
  11. package/dist/services/session-query.js.map +1 -1
  12. package/dist/services/session-state.d.ts +1 -1
  13. package/dist/services/session-state.js +1 -1
  14. package/dist/services/sink-registry.d.ts +2 -2
  15. package/dist/services/sink-registry.js +1 -1
  16. package/dist/services/span-names.d.ts +1 -1
  17. package/dist/services/span-names.js +1 -0
  18. package/dist/services/span-names.js.map +1 -1
  19. package/dist/{session-query-Dzdcr2xL.d.ts → session-query-dlbwukcq.d.ts} +2 -3
  20. package/dist/{session-state-Cm5sXbZW.d.ts → session-state-Cb_8YOre.d.ts} +35 -7
  21. package/dist/{session-state-DfYX21mA.js → session-state-Dk7Iie-r.js} +59 -9
  22. package/dist/session-state-Dk7Iie-r.js.map +1 -0
  23. package/dist/{sink-registry-CT3C3N5R.js → sink-registry-C2XFRBEV.js} +163 -135
  24. package/dist/sink-registry-C2XFRBEV.js.map +1 -0
  25. package/dist/{sink-registry-CU-WMK96.d.ts → sink-registry-DiZyYd5f.d.ts} +44 -41
  26. package/dist/testkit/layers.d.ts +5 -5
  27. package/dist/testkit/layers.js +2 -2
  28. package/package.json +1 -1
  29. package/dist/session-state-DfYX21mA.js.map +0 -1
  30. package/dist/sink-registry-CT3C3N5R.js.map +0 -1
@@ -158,8 +158,8 @@ interface CompactionRunnerShape {
158
158
  declare const CompactionRunner_base: Context.ServiceClass<CompactionRunner, "@effect-durable-agent/CompactionRunner", CompactionRunnerShape>;
159
159
  /** Framework-owned compaction lifecycle runner. */
160
160
  declare class CompactionRunner extends CompactionRunner_base {
161
- static readonly Live: Layer.Layer<CompactionRunner, never, EDAKeepAlive | ModelResolver | CompactionExecutor | CompactionPolicy | IdGenerator | EventFactory>;
161
+ static readonly Live: Layer.Layer<CompactionRunner, never, ModelResolver | IdGenerator | EDAKeepAlive | CompactionExecutor | CompactionPolicy | EventFactory>;
162
162
  }
163
163
  //#endregion
164
164
  export { defaultCompactionRetainTailTokens as _, CompactionExecutorShape as a, CompactionPolicy as c, CompactionRunner as d, CompactionRunnerInput as f, defaultCompactionMinSummarizableTokens as g, defaultCompactionCharsPerToken as h, CompactionExecutorInput as i, CompactionPolicyInput as l, LanguageModelSummaryCompactionExecutorOptions as m, CompactionError as n, CompactionOutput as o, CompactionRunnerShape as p, CompactionExecutor as r, CompactionPlan as s, ApproximateTokenThresholdCompactionPolicyOptions as t, CompactionPolicyShape as u, defaultCompactionThresholdTokens as v };
165
- //# sourceMappingURL=compaction-CYItD6di.d.ts.map
165
+ //# sourceMappingURL=compaction-DYAlYxx5.d.ts.map
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ import { a as PendingMessageCancellationReason, c as StopTurnCommand, d as UserM
4
4
  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";
5
5
  import { $ as PendingMessagesPausedEvent, $n as sessionConfiguredEventType, $t as ToolRejectionPromptPart, A as CompactionFailedEvent, An as commandStartedEventType, At as StopTurnAppliedPayload, B as ContextRebasedPayload, Bn as inferenceFailedEventType, Bt as ToolCallCreatedPayload, C as CommandEvent, Cn as baseStateCreatedEventType, Ct as SessionConfiguredEvent, D as CommandStartedPayload, Dn as commandCancelledEventType, Dt as SteeringMessageQueuedPayload, E as CommandStartedEvent, En as commandAdmittedEventType, Et as SteeringMessageQueuedEvent, F as CompactionStartedPayload, Fn as contextProjectedEventType, Ft as SystemMessageCommittedEvent, G as InferenceEvent, Gn as runCompletedEventType, Gt as ToolCallRejectedEvent, H as EDADurableEventV1, Hn as messageQueuePausedEventType, Ht as ToolCallFailedEvent, I as ContextAndCompactionEvent, In as contextRebasedEventType, It as SystemMessageCommittedPayload, J as InferenceStartedEvent, Jn as runSchedulingDeliveredEventType, Jt as ToolCallRejectionReason, K as InferenceFailedEvent, Kn as runFailedEventType, Kt as ToolCallRejectedPayload, L as ContextProjectedEvent, Ln as decodeUnknownEDADurableEvent, Lt as ToolCallCompletedEvent, M as CompactionRequestedEvent, Mn as compactionFailedEventType, Mt as StopTurnRequestedPayload, N as CompactionRequestedPayload, Nn as compactionRequestedEventType, Nt as SummaryCreatedEvent, O as CompactionCompletedEvent, On as commandCompletedEventType, Ot as StopControlEvent, P as CompactionStartedEvent, Pn as compactionStartedEventType, Pt as SummaryCreatedPayload, Q as MessageQueuePausedPayload, Qn as runStartedEventType, Qt as ToolPromptPart, R as ContextProjectedPayload, Rn as decodeUnknownEDADurableEventSync, Rt as ToolCallCompletedPayload, S as CommandCompletedPayload, Sn as assistantPartialCommittedEventType, St as RunStartedPayload, T as CommandFailedPayload, Tn as baseStateRequestedEventType, Tt as SteeringMessageCancelledPayload, U as InferenceCompletedEvent, Un as pendingMessagesPausedEventType, Ut as ToolCallFailedPayload, V as EDADurableEvent, Vn as inferenceStartedEventType, Vt as ToolCallEvent, W as InferenceCompletedPayload, Wn as recoveryCompletedEventType, Wt as ToolCallPromptPart, X as MessageEvent, Xn as runSchedulingInvalidatedEventType, Xt as ToolCallStartedPayload, Y as InferenceStartedPayload, Yn as runSchedulingGrantedEventType, Yt as ToolCallStartedEvent, Z as MessageQueuePausedEvent, Zn as runSchedulingRequestedEventType, Zt as ToolFailurePromptPart, _ as CommandAdmittedEvent, _n as UserMessagePromotedPayload, _r as userMessagePromotedEventType, _t as RunSchedulingInvalidatedEvent, a as AssistantMessageImportedPayload, an as TurnFailedPayload, ar as systemMessageCommittedEventType, at as RunCompletedEvent, b as CommandCancelledPayload, bn as assistantMessageCommittedEventType, bt as RunSchedulingRequestedPayload, c as AssistantPromptPart, cn as TurnStoppedEvent, cr as toolCallFailedEventType, ct as RunFailedEvent, d as BaseStateCreatedPayload, dn as UserMessageCancelledEvent, dr as turnCompletedEventType, dt as RunInterruptedPayload, en as ToolSuccessPromptPart, er as steeringMessageCancelledEventType, et as PendingMessagesPausedPayload, f as BaseStateEvent, fn as UserMessageCancelledPayload, fr as turnFailedEventType, ft as RunSchedulingDeliveredEvent, g as BaseStateRequestedPayload, gn as UserMessagePromotedEvent, gr as userMessageCommittedEventType, gt as RunSchedulingGrantedPayload, h as BaseStateRequestedEvent, hn as UserMessageDisposition, hr as userMessageCancelledEventType, ht as RunSchedulingGrantedEvent, i as AssistantMessageImportedEvent, in as TurnFailedEvent, ir as summaryCreatedEventType, it as RecoveryEvent, j as CompactionFailedPayload, jn as compactionCompletedEventType, jt as StopTurnRequestedEvent, k as CompactionCompletedPayload, kn as commandFailedEventType, kt as StopTurnAppliedEvent, l as AssistantPromptParts, ln as TurnStoppedPayload, lr as toolCallRejectedEventType, lt as RunFailedPayload, m as BaseStateFailedPayload, mn as UserMessageCommittedPayload, mr as turnStoppedEventType, mt as RunSchedulingEvent, n as AssistantMessageCommittedPayload, nn as TurnCompletedPayload, nr as stopTurnAppliedEventType, nt as RecoveryCompletedPayload, o as AssistantPartialCommittedEvent, on as TurnStartedEvent, or as toolCallCompletedEventType, ot as RunCompletedPayload, p as BaseStateFailedEvent, pn as UserMessageCommittedEvent, pr as turnStartedEventType, pt as RunSchedulingDeliveredPayload, q as InferenceFailedPayload, qn as runInterruptedEventType, qt as ToolCallRejectionFeedback, r as AssistantMessageContent, rn as TurnEvent, rr as stopTurnRequestedEventType, rt as RecoveryContinuation, s as AssistantPartialCommittedPayload, sn as TurnStartedPayload, sr as toolCallCreatedEventType, st as RunEvent, t as AssistantMessageCommittedEvent, tn as TurnCompletedEvent, tr as steeringMessageQueuedEventType, tt as RecoveryCompletedEvent, u as BaseStateCreatedEvent, un as UserMessageCancellationReason, ur as toolCallStartedEventType, ut as RunInterruptedEvent, v as CommandAdmittedPayload, vn as UserMessageSubmittedEvent, vr as userMessageSubmittedEventType, vt as RunSchedulingInvalidatedPayload, w as CommandFailedEvent, wn as baseStateFailedEventType, wt as SteeringMessageCancelledEvent, x as CommandCompletedEvent, xn as assistantMessageImportedEventType, xt as RunStartedEvent, y as CommandCancelledEvent, yn as UserMessageSubmittedPayload, yt as RunSchedulingRequestedEvent, z as ContextRebasedEvent, zn as inferenceCompletedEventType, zt as ToolCallCreatedEvent } from "./durable-DeLCAvbw.js";
6
6
  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";
7
- import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "./runtime-BRURBOyt.js";
7
+ import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "./runtime-Ca8Qw1fl.js";
8
8
  export { AssistantMessageCommittedEvent, AssistantMessageCommittedPayload, AssistantMessageContent, AssistantMessageImportedEvent, AssistantMessageImportedPayload, AssistantPartialCommittedEvent, AssistantPartialCommittedPayload, AssistantPromptPart, AssistantPromptParts, BaseStateCreatedEvent, BaseStateCreatedPayload, BaseStateEvent, BaseStateFailedEvent, BaseStateFailedPayload, BaseStateId, BaseStateRequestedEvent, BaseStateRequestedPayload, CancelPendingMessageCommand, CommandAdmittedEvent, CommandAdmittedPayload, CommandCancelledEvent, CommandCancelledPayload, CommandCompletedEvent, CommandCompletedPayload, CommandEvent, CommandFailedEvent, CommandFailedPayload, CommandId, CommandIdempotencyKey, CommandStartedEvent, CommandStartedPayload, CommittedCommandTerminalEvent, CompactionCompletedEvent, CompactionCompletedPayload, CompactionFailedEvent, CompactionFailedPayload, CompactionId, CompactionRequestedEvent, CompactionRequestedPayload, CompactionStartedEvent, CompactionStartedPayload, ContextAndCompactionEvent, ContextProjectedEvent, ContextProjectedPayload, ContextRebasedEvent, ContextRebasedPayload, ContextVersion, CorrelationId, DurableEventEnvelope, DurablePosition, DurableSubSequenceNumber, EDACommand, EDACommandTerminalEvent, EDADurableEvent, EDADurableEventV1, EDAEphemeralEvent, EDAEventTrace, EDARunTrace, EDARuntime, EDARuntimeConfig, EDARuntimeError, EDARuntimeShape, EDARuntimeSubmit, EDASpanId, EDATraceAttributeValue, EDATraceAttributes, EDATraceContext, EDATraceId, EDATraceLink, EDATraceMetadata, EphemeralEventEnvelope, EventDurability, EventEnvelope, EventId, EventNamespace, EventType, EventTypeName, FailurePayload, GrantRunCommand, InferenceCompletedEvent, InferenceCompletedPayload, InferenceEvent, InferenceFailedEvent, InferenceFailedPayload, InferenceId, InferenceStartedEvent, InferenceStartedPayload, MessageEvent, MessageId, MessageQueuePausedEvent, MessageQueuePausedPayload, ModelSelectionPayload, ModelStreamEvent, NonNegativeInt, PendingMessageCancellationReason, PendingMessagesPausedEvent, PendingMessagesPausedPayload, Position, PositionOrder, PositionedEvent, PromotePendingMessageCommand, ProviderPartId, ReasoningDeltaEvent, ReasoningDeltaPayload, RecoveryCompletedEvent, RecoveryCompletedPayload, RecoveryContinuation, RecoveryEvent, ResumePendingMessagesCommand, RunCompletedEvent, RunCompletedPayload, RunEvent, RunFailedEvent, RunFailedPayload, RunId, RunInterruptedEvent, RunInterruptedPayload, RunRequestId, RunSchedulingDeliveredEvent, RunSchedulingDeliveredPayload, RunSchedulingEvent, RunSchedulingGrantedEvent, RunSchedulingGrantedPayload, RunSchedulingInvalidatedEvent, RunSchedulingInvalidatedPayload, RunSchedulingRequestedEvent, RunSchedulingRequestedPayload, RunStartedEvent, RunStartedPayload, RuntimeStatusEvent, SchemaVersion, SequenceNumber, SessionConfiguredEvent, SessionId, SteeringMessageCancelledEvent, SteeringMessageCancelledPayload, SteeringMessageQueuedEvent, SteeringMessageQueuedPayload, StopControlEvent, StopTurnAppliedEvent, StopTurnAppliedPayload, StopTurnCommand, StopTurnRequestedEvent, StopTurnRequestedPayload, SubSequenceNumber, SubmitMessageCommand, SubmitMessageDisposition, SubscriberStatusEvent, SubscriberStatusKind, SubscriberStatusPayload, SummaryCreatedEvent, SummaryCreatedPayload, SummaryId, SystemMessageCommittedEvent, SystemMessageCommittedPayload, SystemPromptText, TextDeltaEvent, TextDeltaPayload, ToolCallCompletedEvent, ToolCallCompletedPayload, ToolCallCreatedEvent, ToolCallCreatedPayload, ToolCallEvent, ToolCallFailedEvent, ToolCallFailedPayload, ToolCallId, 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, TurnId, TurnStartedEvent, TurnStartedPayload, TurnStoppedEvent, TurnStoppedPayload, UnixEpochMillis, UsagePayload, UserMessageCancellationReason, UserMessageCancelledEvent, UserMessageCancelledPayload, UserMessageCommittedEvent, UserMessageCommittedPayload, UserMessageContent, UserMessageDisposition, UserMessagePart, UserMessagePromotedEvent, UserMessagePromotedPayload, UserMessageSubmittedEvent, UserMessageSubmittedPayload, assistantMessageCommittedEventType, assistantMessageImportedEventType, assistantPartialCommittedEventType, baseStateCreatedEventType, baseStateFailedEventType, baseStateRequestedEventType, buildEDATraceparent, commandAdmittedEventType, commandCancelledEventType, commandCompletedEventType, commandFailedEventType, commandStartedEventType, compactionCompletedEventType, compactionFailedEventType, compactionRequestedEventType, compactionStartedEventType, comparePosition, contextProjectedEventType, contextRebasedEventType, decodeUnknownEDADurableEvent, decodeUnknownEDADurableEventSync, durablePosition, effectDurableAgentNamespace, inferenceCompletedEventType, inferenceFailedEventType, inferenceStartedEventType, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEventType, makeRootEDAEventTrace, makeRootEDATraceMetadata, messageQueuePausedEventType, parseEDATraceparent, pendingMessagesPausedEventType, reasoningDeltaEventType, recoveryCompletedEventType, runCompletedEventType, runFailedEventType, runInterruptedEventType, runSchedulingDeliveredEventType, runSchedulingGrantedEventType, runSchedulingInvalidatedEventType, runSchedulingRequestedEventType, 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 };
@@ -2,8 +2,8 @@ import { h as SequenceNumber, n as CommandId } from "./core-C-6xHzRx.js";
2
2
  import { i as GrantRunCommand, r as EDACommand } from "./commands-p8venTWs.js";
3
3
  import { w as CommandFailedEvent, x as CommandCompletedEvent, y as CommandCancelledEvent } from "./durable-DeLCAvbw.js";
4
4
  import { t as CommittedDurableEvent } from "./session-store-DCs--1kc.js";
5
- import { _ as SessionStateShape, h as SessionState, r as SessionCommandAdmissionError, t as EDASubmittable } from "./session-state-Cm5sXbZW.js";
6
- import { n as EDASessionQuery, r as EDASessionQueryShape } from "./session-query-Dzdcr2xL.js";
5
+ import { _ as SessionStateShape, h as SessionState, r as SessionCommandAdmissionError, t as EDASubmittable } from "./session-state-Cb_8YOre.js";
6
+ import { n as EDASessionQuery, r as EDASessionQueryShape } from "./session-query-dlbwukcq.js";
7
7
  import * as Context from "effect/Context";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Layer from "effect/Layer";
@@ -66,4 +66,4 @@ declare class EDARuntime extends EDARuntime_base {
66
66
  }
67
67
  //#endregion
68
68
  export { EDARuntimeError as a, EDARuntimeConfig as i, EDACommandTerminalEvent as n, EDARuntimeShape as o, EDARuntime as r, EDARuntimeSubmit as s, CommittedCommandTerminalEvent as t };
69
- //# sourceMappingURL=runtime-BRURBOyt.d.ts.map
69
+ //# sourceMappingURL=runtime-Ca8Qw1fl.d.ts.map
@@ -1,2 +1,2 @@
1
- import { _ as defaultCompactionRetainTailTokens, a as CompactionExecutorShape, c as CompactionPolicy, d as CompactionRunner, f as CompactionRunnerInput, g as defaultCompactionMinSummarizableTokens, h as defaultCompactionCharsPerToken, i as CompactionExecutorInput, l as CompactionPolicyInput, m as LanguageModelSummaryCompactionExecutorOptions, n as CompactionError, o as CompactionOutput, p as CompactionRunnerShape, r as CompactionExecutor, s as CompactionPlan, t as ApproximateTokenThresholdCompactionPolicyOptions, u as CompactionPolicyShape, v as defaultCompactionThresholdTokens } from "../compaction-CYItD6di.js";
1
+ import { _ as defaultCompactionRetainTailTokens, a as CompactionExecutorShape, c as CompactionPolicy, d as CompactionRunner, f as CompactionRunnerInput, g as defaultCompactionMinSummarizableTokens, h as defaultCompactionCharsPerToken, i as CompactionExecutorInput, l as CompactionPolicyInput, m as LanguageModelSummaryCompactionExecutorOptions, n as CompactionError, o as CompactionOutput, p as CompactionRunnerShape, r as CompactionExecutor, s as CompactionPlan, t as ApproximateTokenThresholdCompactionPolicyOptions, u as CompactionPolicyShape, v as defaultCompactionThresholdTokens } from "../compaction-DYAlYxx5.js";
2
2
  export { ApproximateTokenThresholdCompactionPolicyOptions, CompactionError, CompactionExecutor, CompactionExecutorInput, CompactionExecutorShape, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionPolicyInput, CompactionPolicyShape, CompactionRunner, CompactionRunnerInput, CompactionRunnerShape, LanguageModelSummaryCompactionExecutorOptions, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionThresholdTokens };
@@ -2,17 +2,17 @@ import { g as SessionId } from "../core-C-6xHzRx.js";
2
2
  import { a as EDASessionStore, o as EDASessionStoreError } from "../session-store-DCs--1kc.js";
3
3
  import { t as ModelResolver } from "../model-resolver-BPPJAsuh.js";
4
4
  import { t as EDAKeepAlive } from "../keep-alive-Chl5SJxy.js";
5
- import { c as CompactionPolicy, r as CompactionExecutor } from "../compaction-CYItD6di.js";
5
+ import { c as CompactionPolicy, r as CompactionExecutor } from "../compaction-DYAlYxx5.js";
6
6
  import { t as SessionEventObserver } from "../session-event-observer-DaFMKKNc.js";
7
- import { r as EDASink } from "../sink-registry-CU-WMK96.js";
7
+ import { r as SessionCommandAdmissionError } from "../session-state-Cb_8YOre.js";
8
8
  import { r as EDAReducerRegistry } from "../reducer-registry-BgtK0NuX.js";
9
9
  import { r as EDAPromptProjector } from "../prompt-projector-_Zxe7dlE.js";
10
10
  import { n as SinkCheckpointStore } from "../sink-checkpoint-store-CasqHvDz.js";
11
+ import { s as EDASink } from "../sink-registry-DiZyYd5f.js";
11
12
  import { t as RunScheduler } from "../run-scheduler-BBqZ0Ate.js";
12
13
  import { t as RunSchedulingWakeup } from "../run-scheduling-wakeup-DRYZztL6.js";
13
- import { r as SessionCommandAdmissionError } from "../session-state-Cm5sXbZW.js";
14
14
  import { i as EDAToolRegistryShape, t as EDAModelToolkit } from "../tool-registry-CHMtDCJ5.js";
15
- import { i as EDARuntimeConfig, r as EDARuntime } from "../runtime-BRURBOyt.js";
15
+ import { i as EDARuntimeConfig, r as EDARuntime } from "../runtime-Ca8Qw1fl.js";
16
16
  import * as Layer from "effect/Layer";
17
17
  import * as Tracer from "effect/Tracer";
18
18
 
@@ -1,14 +1,14 @@
1
1
  import { RunSchedulingWakeup } from "./run-scheduling-wakeup.js";
2
2
  import { RunScheduler } from "./run-scheduler.js";
3
- import { d as TurnRunner, f as InferenceRunner, p as ToolExecutor, u as SessionState } from "../session-state-DfYX21mA.js";
3
+ import { d as TurnRunner, f as InferenceRunner, m as LiveEventBus, p as ToolExecutor, u as SessionState } from "../session-state-Dk7Iie-r.js";
4
4
  import { a as CompactionPolicy, n as CompactionExecutor, o as CompactionRunner } from "../compaction-0k8zCJgB.js";
5
5
  import { IdGenerator } from "./id-generator.js";
6
6
  import { n as SessionContext, t as EventFactory } from "../event-factory-QuC_UvyP.js";
7
7
  import { EDAKeepAlive } from "./keep-alive.js";
8
8
  import { SessionEventObserver } from "./session-event-observer.js";
9
- import { n as EDASinkRegistry, r as LiveEventBus } from "../sink-registry-CT3C3N5R.js";
10
9
  import { EDAPromptProjector } from "./prompt-projector.js";
11
10
  import { EDAReducerRegistry } from "./reducer-registry.js";
11
+ import { n as EDASinkRegistry } from "../sink-registry-C2XFRBEV.js";
12
12
  import { EDAToolRegistry } from "./tool-registry.js";
13
13
  import { EDASessionQuery } from "./session-query.js";
14
14
  import { EDARuntime } from "./runtime.js";
@@ -1,2 +1,2 @@
1
- import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "../runtime-BRURBOyt.js";
1
+ import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "../runtime-Ca8Qw1fl.js";
2
2
  export { CommittedCommandTerminalEvent, EDACommandTerminalEvent, EDARuntime, EDARuntimeConfig, EDARuntimeError, EDARuntimeShape, EDARuntimeSubmit };
@@ -1,7 +1,7 @@
1
1
  import { SequenceNumber, durablePosition } from "../types/core.js";
2
2
  import { c as ModelSelectionPayload, l as NonNegativeInt, p as SystemPromptText } from "../envelope-DxQzo5rN.js";
3
3
  import { Dn as commandCancelledEventType, On as commandCompletedEventType, kn as commandFailedEventType } from "../durable-BPHVFVvV.js";
4
- import { u as SessionState } from "../session-state-DfYX21mA.js";
4
+ import { u as SessionState } from "../session-state-Dk7Iie-r.js";
5
5
  import { CommittedDurableEvent } from "./session-store.js";
6
6
  import { annotateEdaSpan, committedBatchAttributes } from "./tracing.js";
7
7
  import { EDASessionQuery } from "./session-query.js";
@@ -1,2 +1,2 @@
1
- import { i as EDASessionSnapshot, n as EDASessionQuery, r as EDASessionQueryShape, t as EDASessionEventPage } from "../session-query-Dzdcr2xL.js";
1
+ import { i as EDASessionSnapshot, n as EDASessionQuery, r as EDASessionQueryShape, t as EDASessionEventPage } from "../session-query-dlbwukcq.js";
2
2
  export { EDASessionEventPage, EDASessionQuery, EDASessionQueryShape, EDASessionSnapshot };
@@ -1,11 +1,10 @@
1
1
  import { SequenceNumber } from "../types/core.js";
2
2
  import { _ as effectDurableAgentNamespace, u as PositionedEvent } from "../envelope-DxQzo5rN.js";
3
3
  import { bt as RunSchedulingRequestedPayload, dt as RunInterruptedPayload, gt as RunSchedulingGrantedPayload, lt as RunFailedPayload, ot as RunCompletedPayload, vt as RunSchedulingInvalidatedPayload } from "../durable-BPHVFVvV.js";
4
- import { u as SessionState } from "../session-state-DfYX21mA.js";
4
+ import { m as LiveEventBus, u as SessionState } from "../session-state-Dk7Iie-r.js";
5
5
  import { EDASessionStore } from "./session-store.js";
6
6
  import { durableMessageTranscript } from "../domain/message-transcript.js";
7
7
  import { annotateEdaSpan } from "./tracing.js";
8
- import { r as LiveEventBus } from "../sink-registry-CT3C3N5R.js";
9
8
  import * as Context from "effect/Context";
10
9
  import * as Effect from "effect/Effect";
11
10
  import * as Layer from "effect/Layer";
@@ -1 +1 @@
1
- {"version":3,"file":"session-query.js","names":[],"sources":["../../src/services/session-query.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as PubSub from \"effect/PubSub\";\nimport type * as Scope from \"effect/Scope\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { durableMessageTranscript } from \"../domain/message-transcript\";\nimport type { DurableTranscriptMessage } from \"../domain/message-transcript\";\nimport type { ReducedState } from \"../domain/reduced-state\";\nimport type { EDAReducerStateSnapshot } from \"./reducer-registry\";\nimport { RunRequestOutcome } from \"../domain/run-scheduling\";\nimport {\n RunSchedulingRequestedPayload,\n RunSchedulingGrantedPayload,\n RunSchedulingInvalidatedPayload,\n RunCompletedPayload,\n RunFailedPayload,\n RunInterruptedPayload,\n effectDurableAgentNamespace,\n} from \"../types/events\";\nimport { type RunRequestId, SequenceNumber } from \"../types/core\";\nimport { PositionedEvent } from \"../types/events\";\nimport { EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { SessionState } from \"./session-state\";\nimport { annotateEdaSpan } from \"./tracing\";\n\n/** Authoritative live snapshot for one EDA session plus its derived durable transcript. */\nexport interface EDASessionSnapshot {\n readonly state: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n readonly messages: ReadonlyArray<DurableTranscriptMessage>;\n}\n\n/** Read-only query facade over authoritative live state and reconnect-safe event streams. */\nexport interface EDASessionQueryShape {\n /** Reconcile one request against committed facts, including after reducer history pruning. */\n readonly runRequestOutcome: (\n requestId: RunRequestId,\n ) => Effect.Effect<RunRequestOutcome, EDASessionStoreError>;\n /** Read the authoritative live state and derive its durable transcript. */\n readonly snapshot: () => Effect.Effect<EDASessionSnapshot, EDASessionStoreError>;\n /** Read durable user/assistant messages in committed sequence order from the live snapshot. */\n readonly messages: () => Effect.Effect<\n ReadonlyArray<DurableTranscriptMessage>,\n EDASessionStoreError\n >;\n /** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */\n readonly eventsAfter: (\n afterSeq: SequenceNumber,\n ) => Effect.Effect<\n Stream.Stream<PositionedEvent, EDASessionStoreError>,\n EDASessionStoreError,\n Scope.Scope\n >;\n /** Read one bounded committed durable slice after `afterSeq` plus the committed head. */\n readonly readEventPage: (\n afterSeq: SequenceNumber,\n limit: number,\n ) => Effect.Effect<EDASessionEventPage, EDASessionStoreError>;\n}\n\n/** Bounded committed durable event page for pull-based host delivery. */\nexport interface EDASessionEventPage {\n readonly events: ReadonlyArray<PositionedEvent>;\n readonly head: SequenceNumber;\n}\n\n/** Read-only session query facade backed by authoritative SessionState plus durable backfill. */\nexport class EDASessionQuery extends Context.Service<EDASessionQuery, EDASessionQueryShape>()(\n \"@effect-durable-agent/EDASessionQuery\",\n) {\n static readonly Live = Layer.effect(\n EDASessionQuery,\n Effect.gen(function* () {\n const store = yield* EDASessionStore;\n const liveBus = yield* LiveEventBus;\n const sessionState = yield* SessionState;\n\n const snapshot = Effect.gen(function* () {\n const data = yield* sessionState.snapshotData();\n return {\n state: data.reduced,\n reducerStates: data.reducerStates,\n messages: durableMessageTranscript(data.reduced),\n } satisfies EDASessionSnapshot;\n });\n\n return {\n runRequestOutcome: Effect.fn(\"agent.run.request.outcome\")(function* (\n requestId: RunRequestId,\n ) {\n const head = (yield* sessionState.snapshot()).lastSeq;\n let outcome: RunRequestOutcome = { _tag: \"Unknown\" };\n yield* store.eventsAfter(SequenceNumber.make(0)).pipe(\n Stream.takeWhile((entry) => entry.position.seq <= head),\n Stream.runForEach((entry) =>\n Effect.sync(() => {\n const event = entry.event;\n if (event.namespace !== effectDurableAgentNamespace) return;\n switch (event.type) {\n case \"RunSchedulingRequested\":\n if (\n Schema.decodeUnknownSync(RunSchedulingRequestedPayload)(event.payload)\n .requestId === requestId\n )\n outcome = { _tag: \"Waiting\" };\n break;\n case \"RunSchedulingInvalidated\":\n if (\n Schema.decodeUnknownSync(RunSchedulingInvalidatedPayload)(event.payload)\n .requestId === requestId\n )\n outcome = { _tag: \"Invalidated\" };\n break;\n case \"RunSchedulingGranted\": {\n const grant = Schema.decodeUnknownSync(RunSchedulingGrantedPayload)(\n event.payload,\n );\n if (grant.requestId === requestId)\n outcome = { _tag: \"Granted\", runId: grant.runId, status: \"Running\" };\n break;\n }\n case \"RunCompleted\":\n if (\n outcome._tag === \"Granted\" &&\n Schema.decodeUnknownSync(RunCompletedPayload)(event.payload).runId ===\n outcome.runId\n )\n outcome = { ...outcome, status: \"Completed\" };\n break;\n case \"RunFailed\":\n if (\n outcome._tag === \"Granted\" &&\n Schema.decodeUnknownSync(RunFailedPayload)(event.payload).runId ===\n outcome.runId\n )\n outcome = { ...outcome, status: \"Failed\" };\n break;\n case \"RunInterrupted\":\n if (\n outcome._tag === \"Granted\" &&\n Schema.decodeUnknownSync(RunInterruptedPayload)(event.payload).runId ===\n outcome.runId\n )\n outcome = { ...outcome, status: \"Interrupted\" };\n break;\n }\n }),\n ),\n );\n return outcome;\n }),\n snapshot: () => snapshot,\n messages: () => snapshot.pipe(Effect.map((snapshot) => snapshot.messages)),\n eventsAfter: (afterSeq: SequenceNumber) =>\n Effect.gen(function* () {\n const live = yield* liveBus.subscribeQueue();\n const replayHead = (yield* sessionState.snapshot()).lastSeq;\n // TODO(backpressure): this runCollect drains the store stream eagerly and buffers the\n // whole durable reconnect prefix, defeating host-level paged replay/backpressure for\n // slow clients. Stream this prefix into the live follow stream instead.\n const replay = yield* store.eventsAfter(afterSeq).pipe(\n Stream.filter((entry) => entry.position.seq <= replayHead),\n Stream.map((entry) =>\n PositionedEvent.make({ position: entry.position, event: entry.event }),\n ),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n const activeTurnReplay = yield* liveBus.activeTurnReplay();\n const pendingLive = (yield* PubSub.takeUpTo(live, Number.POSITIVE_INFINITY)).filter(\n (event) => shouldEmitLiveEvent(event, replayHead),\n );\n const reconnectPrefix: ReadonlyArray<PositionedEvent> = Array.from(\n uniquePositionedEvents([...replay, ...activeTurnReplay.events, ...pendingLive]),\n ).sort(comparePositionedEvents);\n yield* annotateEdaSpan({\n \"eda.seq.after\": afterSeq,\n \"eda.seq.head\": replayHead,\n \"eda.replay.events\": replay.length,\n \"eda.live.active_turn_events\": activeTurnReplay.events.length,\n \"eda.live.active_turn_overflowed\": activeTurnReplay.overflowed,\n \"eda.live.buffered_events\": pendingLive.length,\n });\n const follow: Stream.Stream<PositionedEvent> = Stream.fromEffectRepeat(\n PubSub.take(live),\n ).pipe(Stream.filter((event) => shouldEmitLiveEvent(event, replayHead)));\n return Stream.fromIterable(reconnectPrefix).pipe(Stream.concat(follow));\n }).pipe(\n Effect.withSpan(\"agent.events.follow\", {\n attributes: { \"eda.seq.after\": afterSeq },\n }),\n ),\n readEventPage: (afterSeq: SequenceNumber, limit: number) =>\n Effect.gen(function* () {\n const head = (yield* sessionState.snapshot()).lastSeq;\n if (limit <= 0 || afterSeq >= head) {\n return { events: [], head } satisfies EDASessionEventPage;\n }\n const events = yield* store.eventsAfter(afterSeq).pipe(\n Stream.filter((entry) => entry.position.seq <= head),\n Stream.take(limit),\n Stream.map((entry) =>\n PositionedEvent.make({ position: entry.position, event: entry.event }),\n ),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n return { events, head } satisfies EDASessionEventPage;\n }).pipe(\n Effect.withSpan(\"agent.events.page\", {\n attributes: { \"eda.seq.after\": afterSeq, \"eda.page.limit\": limit },\n }),\n ),\n };\n }),\n );\n}\n\nconst shouldEmitLiveEvent = (event: PositionedEvent, replayHead: SequenceNumber): boolean =>\n event.event.durability === \"ephemeral\" || event.position.seq > replayHead;\n\nconst comparePositionedEvents = (left: PositionedEvent, right: PositionedEvent): number => {\n const seq = left.position.seq - right.position.seq;\n return seq === 0 ? left.position.subSeq - right.position.subSeq : seq;\n};\n\nconst uniquePositionedEvents = (\n events: ReadonlyArray<PositionedEvent>,\n): ReadonlyArray<PositionedEvent> => {\n const seen = new Set<string>();\n const output: PositionedEvent[] = [];\n for (const event of events) {\n const key = `${event.position.seq}:${event.position.subSeq}:${event.event.eventId}`;\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n output.push(event);\n }\n return output;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAuEA,IAAa,kBAAb,MAAa,wBAAwB,QAAQ,QAA+C,EAC1F,uCACF,EAAE;CACA,OAAgB,OAAO,MAAM,OAC3B,iBACA,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,OAAO;EACrB,MAAM,UAAU,OAAO;EACvB,MAAM,eAAe,OAAO;EAE5B,MAAM,WAAW,OAAO,IAAI,aAAa;GACvC,MAAM,OAAO,OAAO,aAAa,aAAa;GAC9C,OAAO;IACL,OAAO,KAAK;IACZ,eAAe,KAAK;IACpB,UAAU,yBAAyB,KAAK,OAAO;GACjD;EACF,CAAC;EAED,OAAO;GACL,mBAAmB,OAAO,GAAG,2BAA2B,EAAE,WACxD,WACA;IACA,MAAM,QAAQ,OAAO,aAAa,SAAS,GAAG;IAC9C,IAAI,UAA6B,EAAE,MAAM,UAAU;IACnD,OAAO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,YAAY,QAAQ,EAAE,KAChD,OAAO,QAAQ,UAAU,MAAM,SAAS,OAAO,IAAI,GACnD,OAAO,KAAK,KAAK,GACjB,OAAO,KAAK,UACV,gBAAgB,KAAK;MAAE,UAAU,MAAM;MAAU,OAAO,MAAM;KAAM,CAAC,CACvE,GACA,OAAO,YACP,OAAO,KAAK,WAAW,MAAM,KAAK,MAAM,CAAC,CAC3C;KACiB;IAAK;GACxB,CAAC,EAAE,KACD,OAAO,SAAS,qBAAqB,EACnC,YAAY;IAAE,iBAAiB;IAAU,kBAAkB;GAAM,EACnE,CAAC,CACH;EACJ;CACF,CAAC,CACH;AACF;AAEA,MAAM,uBAAuB,OAAwB,eACnD,MAAM,MAAM,eAAe,eAAe,MAAM,SAAS,MAAM;AAEjE,MAAM,2BAA2B,MAAuB,UAAmC;CACzF,MAAM,MAAM,KAAK,SAAS,MAAM,MAAM,SAAS;CAC/C,OAAO,QAAQ,IAAI,KAAK,SAAS,SAAS,MAAM,SAAS,SAAS;AACpE;AAEA,MAAM,0BACJ,WACmC;CACnC,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAA4B,CAAC;CACnC,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,MAAM,GAAG,MAAM,SAAS,IAAI,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM,MAAM;EAC1E,IAAI,KAAK,IAAI,GAAG,GACd;EAEF,KAAK,IAAI,GAAG;EACZ,OAAO,KAAK,KAAK;CACnB;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"session-query.js","names":[],"sources":["../../src/services/session-query.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as PubSub from \"effect/PubSub\";\nimport type * as Scope from \"effect/Scope\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { durableMessageTranscript } from \"../domain/message-transcript\";\nimport type { DurableTranscriptMessage } from \"../domain/message-transcript\";\nimport type { ReducedState } from \"../domain/reduced-state\";\nimport type { EDAReducerStateSnapshot } from \"./reducer-registry\";\nimport { RunRequestOutcome } from \"../domain/run-scheduling\";\nimport {\n RunSchedulingRequestedPayload,\n RunSchedulingGrantedPayload,\n RunSchedulingInvalidatedPayload,\n RunCompletedPayload,\n RunFailedPayload,\n RunInterruptedPayload,\n effectDurableAgentNamespace,\n} from \"../types/events\";\nimport { type RunRequestId, SequenceNumber } from \"../types/core\";\nimport { PositionedEvent } from \"../types/events\";\nimport { EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { SessionState } from \"./session-state\";\nimport { annotateEdaSpan } from \"./tracing\";\n\n/** Authoritative live snapshot for one EDA session plus its derived durable transcript. */\nexport interface EDASessionSnapshot {\n readonly state: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n readonly messages: ReadonlyArray<DurableTranscriptMessage>;\n}\n\n/** Read-only query facade over authoritative live state and reconnect-safe event streams. */\nexport interface EDASessionQueryShape {\n /** Reconcile one request against committed facts, including after reducer history pruning. */\n readonly runRequestOutcome: (\n requestId: RunRequestId,\n ) => Effect.Effect<RunRequestOutcome, EDASessionStoreError>;\n /** Read the authoritative live state and derive its durable transcript. */\n readonly snapshot: () => Effect.Effect<EDASessionSnapshot, EDASessionStoreError>;\n /** Read durable user/assistant messages in committed sequence order from the live snapshot. */\n readonly messages: () => Effect.Effect<\n ReadonlyArray<DurableTranscriptMessage>,\n EDASessionStoreError\n >;\n /** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */\n readonly eventsAfter: (\n afterSeq: SequenceNumber,\n ) => Effect.Effect<\n Stream.Stream<PositionedEvent, EDASessionStoreError>,\n EDASessionStoreError,\n Scope.Scope\n >;\n /** Read one bounded committed durable slice after `afterSeq` plus the committed head. */\n readonly readEventPage: (\n afterSeq: SequenceNumber,\n limit: number,\n ) => Effect.Effect<EDASessionEventPage, EDASessionStoreError>;\n}\n\n/** Bounded committed durable event page for pull-based host delivery. */\nexport interface EDASessionEventPage {\n readonly events: ReadonlyArray<PositionedEvent>;\n readonly head: SequenceNumber;\n}\n\n/** Read-only session query facade backed by authoritative SessionState plus durable backfill. */\nexport class EDASessionQuery extends Context.Service<EDASessionQuery, EDASessionQueryShape>()(\n \"@effect-durable-agent/EDASessionQuery\",\n) {\n static readonly Live = Layer.effect(\n EDASessionQuery,\n Effect.gen(function* () {\n const store = yield* EDASessionStore;\n const liveBus = yield* LiveEventBus;\n const sessionState = yield* SessionState;\n\n const snapshot = Effect.gen(function* () {\n const data = yield* sessionState.snapshotData();\n return {\n state: data.reduced,\n reducerStates: data.reducerStates,\n messages: durableMessageTranscript(data.reduced),\n } satisfies EDASessionSnapshot;\n });\n\n return {\n runRequestOutcome: Effect.fn(\"agent.run.request.outcome\")(function* (\n requestId: RunRequestId,\n ) {\n const head = (yield* sessionState.snapshot()).lastSeq;\n let outcome: RunRequestOutcome = { _tag: \"Unknown\" };\n yield* store.eventsAfter(SequenceNumber.make(0)).pipe(\n Stream.takeWhile((entry) => entry.position.seq <= head),\n Stream.runForEach((entry) =>\n Effect.sync(() => {\n const event = entry.event;\n if (event.namespace !== effectDurableAgentNamespace) return;\n switch (event.type) {\n case \"RunSchedulingRequested\":\n if (\n Schema.decodeUnknownSync(RunSchedulingRequestedPayload)(event.payload)\n .requestId === requestId\n )\n outcome = { _tag: \"Waiting\" };\n break;\n case \"RunSchedulingInvalidated\":\n if (\n Schema.decodeUnknownSync(RunSchedulingInvalidatedPayload)(event.payload)\n .requestId === requestId\n )\n outcome = { _tag: \"Invalidated\" };\n break;\n case \"RunSchedulingGranted\": {\n const grant = Schema.decodeUnknownSync(RunSchedulingGrantedPayload)(\n event.payload,\n );\n if (grant.requestId === requestId)\n outcome = { _tag: \"Granted\", runId: grant.runId, status: \"Running\" };\n break;\n }\n case \"RunCompleted\":\n if (\n outcome._tag === \"Granted\" &&\n Schema.decodeUnknownSync(RunCompletedPayload)(event.payload).runId ===\n outcome.runId\n )\n outcome = { ...outcome, status: \"Completed\" };\n break;\n case \"RunFailed\":\n if (\n outcome._tag === \"Granted\" &&\n Schema.decodeUnknownSync(RunFailedPayload)(event.payload).runId ===\n outcome.runId\n )\n outcome = { ...outcome, status: \"Failed\" };\n break;\n case \"RunInterrupted\":\n if (\n outcome._tag === \"Granted\" &&\n Schema.decodeUnknownSync(RunInterruptedPayload)(event.payload).runId ===\n outcome.runId\n )\n outcome = { ...outcome, status: \"Interrupted\" };\n break;\n }\n }),\n ),\n );\n return outcome;\n }),\n snapshot: () => snapshot,\n messages: () => snapshot.pipe(Effect.map((snapshot) => snapshot.messages)),\n eventsAfter: (afterSeq: SequenceNumber) =>\n Effect.gen(function* () {\n const live = yield* liveBus.subscribeQueue();\n const replayHead = (yield* sessionState.snapshot()).lastSeq;\n // TODO(backpressure): this runCollect drains the store stream eagerly and buffers the\n // whole durable reconnect prefix, defeating host-level paged replay/backpressure for\n // slow clients. Stream this prefix into the live follow stream instead.\n const replay = yield* store.eventsAfter(afterSeq).pipe(\n Stream.filter((entry) => entry.position.seq <= replayHead),\n Stream.map((entry) =>\n PositionedEvent.make({ position: entry.position, event: entry.event }),\n ),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n const activeTurnReplay = yield* liveBus.activeTurnReplay();\n const pendingLive = (yield* PubSub.takeUpTo(live, Number.POSITIVE_INFINITY)).filter(\n (event) => shouldEmitLiveEvent(event, replayHead),\n );\n const reconnectPrefix: ReadonlyArray<PositionedEvent> = Array.from(\n uniquePositionedEvents([...replay, ...activeTurnReplay.events, ...pendingLive]),\n ).sort(comparePositionedEvents);\n yield* annotateEdaSpan({\n \"eda.seq.after\": afterSeq,\n \"eda.seq.head\": replayHead,\n \"eda.replay.events\": replay.length,\n \"eda.live.active_turn_events\": activeTurnReplay.events.length,\n \"eda.live.active_turn_overflowed\": activeTurnReplay.overflowed,\n \"eda.live.buffered_events\": pendingLive.length,\n });\n const follow: Stream.Stream<PositionedEvent> = Stream.fromEffectRepeat(\n PubSub.take(live),\n ).pipe(Stream.filter((event) => shouldEmitLiveEvent(event, replayHead)));\n return Stream.fromIterable(reconnectPrefix).pipe(Stream.concat(follow));\n }).pipe(\n Effect.withSpan(\"agent.events.follow\", {\n attributes: { \"eda.seq.after\": afterSeq },\n }),\n ),\n readEventPage: (afterSeq: SequenceNumber, limit: number) =>\n Effect.gen(function* () {\n const head = (yield* sessionState.snapshot()).lastSeq;\n if (limit <= 0 || afterSeq >= head) {\n return { events: [], head } satisfies EDASessionEventPage;\n }\n const events = yield* store.eventsAfter(afterSeq).pipe(\n Stream.filter((entry) => entry.position.seq <= head),\n Stream.take(limit),\n Stream.map((entry) =>\n PositionedEvent.make({ position: entry.position, event: entry.event }),\n ),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n return { events, head } satisfies EDASessionEventPage;\n }).pipe(\n Effect.withSpan(\"agent.events.page\", {\n attributes: { \"eda.seq.after\": afterSeq, \"eda.page.limit\": limit },\n }),\n ),\n };\n }),\n );\n}\n\nconst shouldEmitLiveEvent = (event: PositionedEvent, replayHead: SequenceNumber): boolean =>\n event.event.durability === \"ephemeral\" || event.position.seq > replayHead;\n\nconst comparePositionedEvents = (left: PositionedEvent, right: PositionedEvent): number => {\n const seq = left.position.seq - right.position.seq;\n return seq === 0 ? left.position.subSeq - right.position.subSeq : seq;\n};\n\nconst uniquePositionedEvents = (\n events: ReadonlyArray<PositionedEvent>,\n): ReadonlyArray<PositionedEvent> => {\n const seen = new Set<string>();\n const output: PositionedEvent[] = [];\n for (const event of events) {\n const key = `${event.position.seq}:${event.position.subSeq}:${event.event.eventId}`;\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n output.push(event);\n }\n return output;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAuEA,IAAa,kBAAb,MAAa,wBAAwB,QAAQ,QAA+C,EAC1F,uCACF,EAAE;CACA,OAAgB,OAAO,MAAM,OAC3B,iBACA,OAAO,IAAI,aAAa;EACtB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AK,IAAI,GAAG,GACd;EAEF,KAAK,IAAI,GAAG;EACZ,OAAO,KAAK,KAAK;CACnB;CACA,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- import { _ as SessionStateShape, a as SessionCommandCompleted, c as SessionCommandResult, d as SessionForkedCommand, f as SessionNoRunnableCommand, g as SessionStateError, h as SessionState, i as SessionCommandCancelled, l as SessionDrainProcessed, m as SessionRunInput, n as SessionCommandAdmissionConflict, o as SessionCommandFailed, p as SessionNoRunnableReason, r as SessionCommandAdmissionError, s as SessionCommandOutcome, t as EDASubmittable, u as SessionDrainResult, v as SessionStateSnapshotData } from "../session-state-Cm5sXbZW.js";
1
+ import { _ as SessionStateShape, a as SessionCommandCompleted, c as SessionCommandResult, d as SessionForkedCommand, f as SessionNoRunnableCommand, g as SessionStateError, h as SessionState, i as SessionCommandCancelled, l as SessionDrainProcessed, m as SessionRunInput, n as SessionCommandAdmissionConflict, o as SessionCommandFailed, p as SessionNoRunnableReason, r as SessionCommandAdmissionError, s as SessionCommandOutcome, t as EDASubmittable, u as SessionDrainResult, v as SessionStateSnapshotData } from "../session-state-Cb_8YOre.js";
2
2
  export { EDASubmittable, SessionCommandAdmissionConflict, SessionCommandAdmissionError, SessionCommandCancelled, SessionCommandCompleted, SessionCommandFailed, SessionCommandOutcome, SessionCommandResult, SessionDrainProcessed, SessionDrainResult, SessionForkedCommand, SessionNoRunnableCommand, SessionNoRunnableReason, SessionRunInput, SessionState, SessionStateError, SessionStateShape, SessionStateSnapshotData };
@@ -1,2 +1,2 @@
1
- import { a as SessionCommandOutcome, c as SessionNoRunnableReason, i as SessionCommandFailed, l as SessionRunInput, n as SessionCommandCancelled, o as SessionForkedCommand, r as SessionCommandCompleted, s as SessionNoRunnableCommand, t as SessionCommandAdmissionConflict, u as SessionState } from "../session-state-DfYX21mA.js";
1
+ import { a as SessionCommandOutcome, c as SessionNoRunnableReason, i as SessionCommandFailed, l as SessionRunInput, n as SessionCommandCancelled, o as SessionForkedCommand, r as SessionCommandCompleted, s as SessionNoRunnableCommand, t as SessionCommandAdmissionConflict, u as SessionState } from "../session-state-Dk7Iie-r.js";
2
2
  export { SessionCommandAdmissionConflict, SessionCommandCancelled, SessionCommandCompleted, SessionCommandFailed, SessionCommandOutcome, SessionForkedCommand, SessionNoRunnableCommand, SessionNoRunnableReason, SessionRunInput, SessionState };
@@ -1,2 +1,2 @@
1
- import { a as EDASinkContext, c as EDASinkRegistryShape, i as EDASinkCheckpoint, l as EDASinkRunnerStartInput, n as EDAEphemeralSinkDefinition, o as EDASinkDurableBatch, r as EDASink, s as EDASinkRegistry, t as EDADurableSinkDefinition } from "../sink-registry-CU-WMK96.js";
2
- export { EDADurableSinkDefinition, EDAEphemeralSinkDefinition, EDASink, EDASinkCheckpoint, EDASinkContext, EDASinkDurableBatch, EDASinkRegistry, EDASinkRegistryShape, EDASinkRunnerStartInput };
1
+ import { a as EDARawDurableSinkDefinition, c as EDASinkCheckpoint, d as EDASinkInterests, f as EDASinkRawDurableBatch, h as EDASinkRunnerStartInput, i as EDAProjectedSink, l as EDASinkContext, m as EDASinkRegistryShape, n as EDAEphemeralSinkDefinition, o as EDARawSink, p as EDASinkRegistry, r as EDAProjectedDurableSinkDefinition, s as EDASink, t as EDADurableSinkDefinition, u as EDASinkDurableBatch } from "../sink-registry-DiZyYd5f.js";
2
+ export { EDADurableSinkDefinition, EDAEphemeralSinkDefinition, EDAProjectedDurableSinkDefinition, EDAProjectedSink, EDARawDurableSinkDefinition, EDARawSink, EDASink, EDASinkCheckpoint, EDASinkContext, EDASinkDurableBatch, EDASinkInterests, EDASinkRawDurableBatch, EDASinkRegistry, EDASinkRegistryShape, EDASinkRunnerStartInput };
@@ -1,2 +1,2 @@
1
- import { n as EDASinkRegistry, t as EDASink } from "../sink-registry-CT3C3N5R.js";
1
+ import { n as EDASinkRegistry, t as EDASink } from "../sink-registry-C2XFRBEV.js";
2
2
  export { EDASink, EDASinkRegistry };
@@ -20,7 +20,7 @@
20
20
  *
21
21
  * Application-specific operations belong in the application catalog, not this reusable catalog.
22
22
  */
23
- declare const SpanNames: readonly ["agent.command.submit", "agent.command.submit.wait", "agent.command.wait", "agent.compaction", "agent.events.follow", "agent.events.page", "agent.events.stream", "agent.inference", "agent.messages.list", "agent.run", "agent.run.grant", "agent.run.request.outcome", "agent.session.hydrate", "agent.session.snapshot", "agent.sink.drain", "agent.sinks.initialize", "agent.tool", "agent.turn"];
23
+ declare const SpanNames: readonly ["agent.command.submit", "agent.command.submit.wait", "agent.command.wait", "agent.compaction", "agent.events.follow", "agent.events.page", "agent.events.stream", "agent.inference", "agent.messages.list", "agent.run", "agent.run.grant", "agent.run.request.outcome", "agent.session.hydrate", "agent.session.snapshot", "agent.sink.drain", "agent.sink.hydrate", "agent.sinks.initialize", "agent.tool", "agent.turn"];
24
24
  /** Union of values admitted by the centralized EDA span-name catalog. */
25
25
  type SpanName = (typeof SpanNames)[number];
26
26
  //#endregion
@@ -37,6 +37,7 @@ const SpanNames = defineSpanNames([
37
37
  "agent.session.hydrate",
38
38
  "agent.session.snapshot",
39
39
  "agent.sink.drain",
40
+ "agent.sink.hydrate",
40
41
  "agent.sinks.initialize",
41
42
  "agent.tool",
42
43
  "agent.turn"
@@ -1 +1 @@
1
- {"version":3,"file":"span-names.js","names":[],"sources":["../../src/services/span-names.ts"],"sourcesContent":["type CanonicalSpanName = `${string}.${string}`;\n\nconst defineSpanNames = <const Names extends ReadonlyArray<CanonicalSpanName>>(\n names: Names,\n): Names => names;\n\n/**\n * Allowlist of meaningful spans owned by the reusable durable-agent runtime.\n *\n * Add a name only when the span:\n * - represents a recognizable agent operation in the end-to-end execution flow;\n * - owns non-trivial work whose duration, failure, or interruption is useful to diagnose; and\n * - has a lifetime that matches that work rather than acting as an instantaneous marker.\n *\n * Names are stable, lowercase, dot-separated semantic paths. Start with the owning subsystem and\n * move from general to specific, ending with the operation, for example `agent.command.submit`.\n * Describe domain work, not TypeScript symbols, class names, EDA prefixes, or helper mechanics.\n * Keep names low-cardinality: IDs, tool or sink names, providers, models, attempts, and outcomes are\n * span attributes, never name segments.\n *\n * Prefer `Effect.fn(\"...\")` when a function owns the operation and `Effect.withSpan(\"...\")` around\n * an existing effect boundary. Do not add spans for pure transforms, bookkeeping, condition checks,\n * retry-delay calculations, or other near-zero-width implementation steps. Use unnamed `Effect.fn`\n * when a function benefits from Effect structure but would not add a useful node to the trace.\n *\n * Application-specific operations belong in the application catalog, not this reusable catalog.\n */\nexport const SpanNames = defineSpanNames([\n \"agent.command.submit\",\n \"agent.command.submit.wait\",\n \"agent.command.wait\",\n \"agent.compaction\",\n \"agent.events.follow\",\n \"agent.events.page\",\n \"agent.events.stream\",\n \"agent.inference\",\n \"agent.messages.list\",\n \"agent.run\",\n \"agent.run.grant\",\n \"agent.run.request.outcome\",\n \"agent.session.hydrate\",\n \"agent.session.snapshot\",\n \"agent.sink.drain\",\n \"agent.sinks.initialize\",\n \"agent.tool\",\n \"agent.turn\",\n]);\n\n/** Union of values admitted by the centralized EDA span-name catalog. */\nexport type SpanName = (typeof SpanNames)[number];\n"],"mappings":";AAEA,MAAM,mBACJ,UACU;;;;;;;;;;;;;;;;;;;;;;AAuBZ,MAAa,YAAY,gBAAgB;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"span-names.js","names":[],"sources":["../../src/services/span-names.ts"],"sourcesContent":["type CanonicalSpanName = `${string}.${string}`;\n\nconst defineSpanNames = <const Names extends ReadonlyArray<CanonicalSpanName>>(\n names: Names,\n): Names => names;\n\n/**\n * Allowlist of meaningful spans owned by the reusable durable-agent runtime.\n *\n * Add a name only when the span:\n * - represents a recognizable agent operation in the end-to-end execution flow;\n * - owns non-trivial work whose duration, failure, or interruption is useful to diagnose; and\n * - has a lifetime that matches that work rather than acting as an instantaneous marker.\n *\n * Names are stable, lowercase, dot-separated semantic paths. Start with the owning subsystem and\n * move from general to specific, ending with the operation, for example `agent.command.submit`.\n * Describe domain work, not TypeScript symbols, class names, EDA prefixes, or helper mechanics.\n * Keep names low-cardinality: IDs, tool or sink names, providers, models, attempts, and outcomes are\n * span attributes, never name segments.\n *\n * Prefer `Effect.fn(\"...\")` when a function owns the operation and `Effect.withSpan(\"...\")` around\n * an existing effect boundary. Do not add spans for pure transforms, bookkeeping, condition checks,\n * retry-delay calculations, or other near-zero-width implementation steps. Use unnamed `Effect.fn`\n * when a function benefits from Effect structure but would not add a useful node to the trace.\n *\n * Application-specific operations belong in the application catalog, not this reusable catalog.\n */\nexport const SpanNames = defineSpanNames([\n \"agent.command.submit\",\n \"agent.command.submit.wait\",\n \"agent.command.wait\",\n \"agent.compaction\",\n \"agent.events.follow\",\n \"agent.events.page\",\n \"agent.events.stream\",\n \"agent.inference\",\n \"agent.messages.list\",\n \"agent.run\",\n \"agent.run.grant\",\n \"agent.run.request.outcome\",\n \"agent.session.hydrate\",\n \"agent.session.snapshot\",\n \"agent.sink.drain\",\n \"agent.sink.hydrate\",\n \"agent.sinks.initialize\",\n \"agent.tool\",\n \"agent.turn\",\n]);\n\n/** Union of values admitted by the centralized EDA span-name catalog. */\nexport type SpanName = (typeof SpanNames)[number];\n"],"mappings":";AAEA,MAAM,mBACJ,UACU;;;;;;;;;;;;;;;;;;;;;;AAuBZ,MAAa,YAAY,gBAAgB;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
@@ -3,9 +3,8 @@ import { $ as RunRequestOutcome, S as ReducedState } from "./command-queues-CSEl
3
3
  import { d as PositionedEvent } from "./envelope-DkZyMIgp.js";
4
4
  import { a as EDASessionStore, o as EDASessionStoreError } from "./session-store-DCs--1kc.js";
5
5
  import { t as DurableTranscriptMessage } from "./message-transcript-CmCHC1Pg.js";
6
- import { u as LiveEventBus } from "./sink-registry-CU-WMK96.js";
6
+ import { C as LiveEventBus, h as SessionState } from "./session-state-Cb_8YOre.js";
7
7
  import { a as EDAReducerStateSnapshot } from "./reducer-registry-BgtK0NuX.js";
8
- import { h as SessionState } from "./session-state-Cm5sXbZW.js";
9
8
  import * as Context from "effect/Context";
10
9
  import * as Effect from "effect/Effect";
11
10
  import * as Layer from "effect/Layer";
@@ -44,4 +43,4 @@ declare class EDASessionQuery extends EDASessionQuery_base {
44
43
  }
45
44
  //#endregion
46
45
  export { EDASessionSnapshot as i, EDASessionQuery as n, EDASessionQueryShape as r, EDASessionEventPage as t };
47
- //# sourceMappingURL=session-query-Dzdcr2xL.d.ts.map
46
+ //# sourceMappingURL=session-query-dlbwukcq.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { b as TurnId } from "./core-C-6xHzRx.js";
1
2
  import { Q as RunGrantResult, S as ReducedState } from "./command-queues-CSEl1yrH.js";
2
3
  import { d as PositionedEvent, l as ModelSelectionPayload, n as EphemeralEventEnvelope, t as DurableEventEnvelope, u as NonNegativeInt } from "./envelope-DkZyMIgp.js";
3
4
  import { i as GrantRunCommand, r as EDACommand } from "./commands-p8venTWs.js";
@@ -7,10 +8,11 @@ import { t as ModelResolver } from "./model-resolver-BPPJAsuh.js";
7
8
  import { t as IdGenerator } from "./id-generator--x6itQZ2.js";
8
9
  import { r as SessionContext, t as EventFactory } from "./event-factory-EL4szNWm.js";
9
10
  import { t as EDAKeepAlive } from "./keep-alive-Chl5SJxy.js";
10
- import { d as CompactionRunner } from "./compaction-CYItD6di.js";
11
- import { s as EDASinkRegistry, u as LiveEventBus } from "./sink-registry-CU-WMK96.js";
11
+ import { d as CompactionRunner } from "./compaction-DYAlYxx5.js";
12
+ import { t as SessionEventObserver } from "./session-event-observer-DaFMKKNc.js";
12
13
  import { a as EDAReducerStateSnapshot, r as EDAReducerRegistry } from "./reducer-registry-BgtK0NuX.js";
13
14
  import { r as EDAPromptProjector } from "./prompt-projector-_Zxe7dlE.js";
15
+ import { p as EDASinkRegistry } from "./sink-registry-DiZyYd5f.js";
14
16
  import { t as RunScheduler } from "./run-scheduler-BBqZ0Ate.js";
15
17
  import { t as RunSchedulingWakeup } from "./run-scheduling-wakeup-DRYZztL6.js";
16
18
  import { r as EDAToolRegistry } from "./tool-registry-CHMtDCJ5.js";
@@ -18,10 +20,36 @@ import * as Context from "effect/Context";
18
20
  import * as Effect from "effect/Effect";
19
21
  import * as Layer from "effect/Layer";
20
22
  import * as Schema from "effect/Schema";
23
+ import * as Stream from "effect/Stream";
21
24
  import * as Prompt from "effect/unstable/ai/Prompt";
22
25
  import * as Cause from "effect/Cause";
26
+ import * as Scope from "effect/Scope";
27
+ import * as PubSub from "effect/PubSub";
23
28
  import * as Response from "effect/unstable/ai/Response";
24
29
 
30
+ //#region src/services/live-event-bus.d.ts
31
+ /** Live-only replay buffer for the currently open turn. */
32
+ interface ActiveTurnEphemeralReplay {
33
+ readonly turnId?: TurnId;
34
+ readonly events: ReadonlyArray<PositionedEvent>;
35
+ readonly overflowed: boolean;
36
+ }
37
+ /** In-memory live fanout plus active-turn replay source for reconnect streams. */
38
+ interface LiveEventBusShape {
39
+ readonly publish: (event: PositionedEvent) => Effect.Effect<boolean>;
40
+ readonly subscribe: () => Effect.Effect<Stream.Stream<PositionedEvent>, never, Scope.Scope>;
41
+ readonly subscribeQueue: () => Effect.Effect<PubSub.Subscription<PositionedEvent>, never, Scope.Scope>;
42
+ /** Snapshot raw live-only events retained for the currently open turn. */
43
+ readonly activeTurnReplay: () => Effect.Effect<ActiveTurnEphemeralReplay>;
44
+ }
45
+ declare const LiveEventBus_base: Context.ServiceClass<LiveEventBus, "@effect-durable-agent/LiveEventBus", LiveEventBusShape>;
46
+ /** Unbounded in-memory fanout plus bounded active-turn ephemeral replay. */
47
+ declare class LiveEventBus extends LiveEventBus_base {
48
+ static readonly Live: Layer.Layer<LiveEventBus, never, SessionEventObserver>;
49
+ /** Live bus for hosts that do not install an append-driven observer. */
50
+ static readonly Noop: Layer.Layer<LiveEventBus, never, never>;
51
+ }
52
+ //#endregion
25
53
  //#region src/services/session-event-sink.d.ts
26
54
  /**
27
55
  * Narrow write/publish capability passed from `SessionState` into execution subcomponents.
@@ -145,7 +173,7 @@ interface ToolExecutorShape {
145
173
  declare const ToolExecutor_base: Context.ServiceClass<ToolExecutor, "@effect-durable-agent/ToolExecutor", ToolExecutorShape>;
146
174
  /** Executes sealed framework-owned tool calls and commits tool lifecycle boundaries. */
147
175
  declare class ToolExecutor extends ToolExecutor_base {
148
- static readonly Live: Layer.Layer<ToolExecutor, never, EDAToolRegistry | IdGenerator | EventFactory | SessionContext>;
176
+ static readonly Live: Layer.Layer<ToolExecutor, never, IdGenerator | EventFactory | SessionContext | EDAToolRegistry>;
149
177
  }
150
178
  //#endregion
151
179
  //#region src/services/inference-runner.d.ts
@@ -293,7 +321,7 @@ interface InferenceRunnerShape {
293
321
  declare const InferenceRunner_base: Context.ServiceClass<InferenceRunner, "@effect-durable-agent/InferenceRunner", InferenceRunnerShape>;
294
322
  /** Owns provider inference streams and routes them into durable/live inference emissions. */
295
323
  declare class InferenceRunner extends InferenceRunner_base {
296
- static readonly Live: Layer.Layer<InferenceRunner, never, ModelResolver | EDAToolRegistry | IdGenerator | EventFactory>;
324
+ static readonly Live: Layer.Layer<InferenceRunner, never, ModelResolver | IdGenerator | EventFactory | EDAToolRegistry>;
297
325
  }
298
326
  //#endregion
299
327
  //#region src/services/turn-runner.d.ts
@@ -860,8 +888,8 @@ interface SessionStateShape extends SessionEventSink {
860
888
  declare const SessionState_base: Context.ServiceClass<SessionState, "@effect-durable-agent/SessionState", SessionStateShape>;
861
889
  /** Internal authoritative live state and root control loop for one session. */
862
890
  declare class SessionState extends SessionState_base {
863
- static readonly Live: Layer.Layer<SessionState, EDASessionStoreError, RunScheduler | EDAKeepAlive | RunSchedulingWakeup | EDAPromptProjector | EDAReducerRegistry | EDASessionStore | LiveEventBus | IdGenerator | EventFactory | TurnRunner | CompactionRunner | SessionContext | EDASinkRegistry>;
891
+ static readonly Live: Layer.Layer<SessionState, EDASessionStoreError, EDAReducerRegistry | RunSchedulingWakeup | RunScheduler | IdGenerator | EDAKeepAlive | EDAPromptProjector | EDASessionStore | CompactionRunner | EventFactory | EDASinkRegistry | SessionContext | LiveEventBus | TurnRunner>;
864
892
  }
865
893
  //#endregion
866
- export { ToolExecutor as S, SessionStateShape as _, SessionCommandCompleted as a, InferenceRunner as b, SessionCommandResult as c, SessionForkedCommand as d, SessionNoRunnableCommand as f, SessionStateError as g, SessionState as h, SessionCommandCancelled as i, SessionDrainProcessed as l, SessionRunInput as m, SessionCommandAdmissionConflict as n, SessionCommandFailed as o, SessionNoRunnableReason as p, SessionCommandAdmissionError as r, SessionCommandOutcome as s, EDASubmittable as t, SessionDrainResult as u, SessionStateSnapshotData as v, InferenceRunnerStreamPart as x, TurnRunner as y };
867
- //# sourceMappingURL=session-state-Cm5sXbZW.d.ts.map
894
+ export { LiveEventBus as C, ToolExecutor as S, SessionStateShape as _, SessionCommandCompleted as a, InferenceRunner as b, SessionCommandResult as c, SessionForkedCommand as d, SessionNoRunnableCommand as f, SessionStateError as g, SessionState as h, SessionCommandCancelled as i, SessionDrainProcessed as l, SessionRunInput as m, SessionCommandAdmissionConflict as n, SessionCommandFailed as o, SessionNoRunnableReason as p, SessionCommandAdmissionError as r, SessionCommandOutcome as s, EDASubmittable as t, SessionDrainResult as u, SessionStateSnapshotData as v, InferenceRunnerStreamPart as x, TurnRunner as y };
895
+ //# sourceMappingURL=session-state-Cb_8YOre.d.ts.map
@@ -6,7 +6,7 @@ import { ModelResolver } from "./services/model-resolver.js";
6
6
  import { makeEDARunTrace } from "./types/tracing.js";
7
7
  import { c as ModelSelectionPayload, d as ProviderPartId, l as NonNegativeInt, m as ToolName, p as SystemPromptText, s as FailurePayload, u as PositionedEvent } from "./envelope-DxQzo5rN.js";
8
8
  import { CancelPendingMessageCommand, PromotePendingMessageCommand, ResumePendingMessagesCommand, StopTurnCommand, SubmitMessageCommand } from "./types/commands.js";
9
- import { Bn as inferenceFailedEventType, En as commandAdmittedEventType, fr as turnFailedEventType, lr as toolCallRejectedEventType, sr as toolCallCreatedEventType, zn as inferenceCompletedEventType } from "./durable-BPHVFVvV.js";
9
+ import { Bn as inferenceFailedEventType, En as commandAdmittedEventType, dr as turnCompletedEventType, fr as turnFailedEventType, lr as toolCallRejectedEventType, mr as turnStoppedEventType, pr as turnStartedEventType, sr as toolCallCreatedEventType, zn as inferenceCompletedEventType } from "./durable-BPHVFVvV.js";
10
10
  import { a as encodeReducedStateCheckpoint, h as assertNeverError, i as decodeReducedStateCheckpoint, l as initialReducedState, m as assertNever, n as activeTurnIdentityForCommand, o as foldReducedState, p as reducedStateCheckpointEventSeqs, r as classifyRecoverableWork, s as frameworkReducedStateReducerName } from "./reduced-state-Bz68V2H8.js";
11
11
  import { ContextProjection, emptyContextProjection } from "./domain/context-projection.js";
12
12
  import { CommittedDurableEvent, EDASessionStore, EDASessionStoreError, hasEDASessionStoreError } from "./services/session-store.js";
@@ -15,9 +15,10 @@ import { IdGenerator } from "./services/id-generator.js";
15
15
  import { n as SessionContext, t as EventFactory } from "./event-factory-QuC_UvyP.js";
16
16
  import { annotateEdaSpan, committedBatchAttributes, edaTraceContextFromSpan, eventBatchAttributes, toEdaExternalSpan, usageAttributes } from "./services/tracing.js";
17
17
  import { EDAKeepAlive } from "./services/keep-alive.js";
18
- import { n as EDASinkRegistry, r as LiveEventBus } from "./sink-registry-CT3C3N5R.js";
18
+ import { SessionEventObserver } from "./services/session-event-observer.js";
19
19
  import { EDAPromptProjector, buildEDAPrompt } from "./services/prompt-projector.js";
20
20
  import { EDAReducerRegistry, decodeReducerState, encodeReducerState, reducerSchemaVersion } from "./services/reducer-registry.js";
21
+ import { n as EDASinkRegistry } from "./sink-registry-C2XFRBEV.js";
21
22
  import { EDAToolRegistry } from "./services/tool-registry.js";
22
23
  import * as Context from "effect/Context";
23
24
  import * as Effect from "effect/Effect";
@@ -34,6 +35,7 @@ import * as Ref from "effect/Ref";
34
35
  import * as Scope from "effect/Scope";
35
36
  import * as Semaphore from "effect/Semaphore";
36
37
  import * as Option from "effect/Option";
38
+ import * as PubSub from "effect/PubSub";
37
39
  import * as Response from "effect/unstable/ai/Response";
38
40
  //#region src/domain/dispatch-policy.ts
39
41
  /** Durable/runtime evidence for active work blocking new queued commands. */
@@ -259,6 +261,57 @@ const planRunFailure = (state) => ({ messageIdsToResume: state.commandQueues.pen
259
261
  /** Normal explicit Stop/Interrupt policy. This is not startup recovery. */
260
262
  const planUserInterruption = (state) => ({ messageIdsToPause: [...state.commandQueues.pendingQueue, ...state.commandQueues.pendingSteers].map((message) => message.messageId) });
261
263
  //#endregion
264
+ //#region src/services/live-event-bus.ts
265
+ /** Conservative raw-delta cap for one open turn's live-only reconnect replay. */
266
+ const activeTurnEphemeralReplayCapacity = 4096;
267
+ /** Unbounded in-memory fanout plus bounded active-turn ephemeral replay. */
268
+ var LiveEventBus = class LiveEventBus extends Context.Service()("@effect-durable-agent/LiveEventBus") {
269
+ static Live = Layer.effect(LiveEventBus, Effect.gen(function* () {
270
+ return makeLiveBus(yield* Effect.acquireRelease(PubSub.unbounded(), PubSub.shutdown), yield* Ref.make({
271
+ events: [],
272
+ overflowed: false
273
+ }), yield* SessionEventObserver);
274
+ }));
275
+ /** Live bus for hosts that do not install an append-driven observer. */
276
+ static Noop = LiveEventBus.Live.pipe(Layer.provide(SessionEventObserver.Noop));
277
+ };
278
+ const makeLiveBus = (pubsub, activeTurnReplay, observer) => ({
279
+ publish: (event) => Effect.gen(function* () {
280
+ yield* updateActiveTurnReplay(activeTurnReplay, event);
281
+ yield* observer.onEvent(event);
282
+ return yield* PubSub.publish(pubsub, event);
283
+ }),
284
+ subscribeQueue: () => PubSub.subscribe(pubsub),
285
+ subscribe: () => Effect.map(PubSub.subscribe(pubsub), (subscription) => Stream.fromEffectRepeat(PubSub.take(subscription))),
286
+ activeTurnReplay: () => Ref.get(activeTurnReplay)
287
+ });
288
+ const updateActiveTurnReplay = (ref, event) => Ref.update(ref, (state) => nextActiveTurnReplay(state, event));
289
+ const nextActiveTurnReplay = (state, event) => {
290
+ if (event.event.type === turnStartedEventType) return {
291
+ turnId: event.event.payload.turnId,
292
+ events: [],
293
+ overflowed: false
294
+ };
295
+ if (event.event.type === turnCompletedEventType || event.event.type === turnFailedEventType || event.event.type === turnStoppedEventType) {
296
+ const turnId = event.event.payload.turnId;
297
+ return turnId === void 0 || state.turnId === void 0 || turnId === state.turnId ? {
298
+ events: [],
299
+ overflowed: false
300
+ } : state;
301
+ }
302
+ if (event.event.durability !== "ephemeral" || state.turnId === void 0) return state;
303
+ const events = [...state.events, event];
304
+ if (events.length <= 4096) return {
305
+ ...state,
306
+ events
307
+ };
308
+ return {
309
+ ...state,
310
+ events: events.slice(events.length - activeTurnEphemeralReplayCapacity),
311
+ overflowed: true
312
+ };
313
+ };
314
+ //#endregion
262
315
  //#region src/services/started-boundary-guard.ts
263
316
  /** Build a guard bound to the session's durable append boundary. */
264
317
  const makeStartedBoundaryGuard = (state) => (spec) => {
@@ -1668,13 +1721,10 @@ const makeLiveSessionState = Effect.gen(function* () {
1668
1721
  }
1669
1722
  });
1670
1723
  yield* liveBus.publish(positioned);
1724
+ yield* sinkRegistry.publishEphemeralToSinks(positioned);
1671
1725
  return positioned;
1672
1726
  }));
1673
- const publishEphemeral = (event) => Effect.gen(function* () {
1674
- const positioned = yield* publishEphemeralCore(event);
1675
- yield* sinkRegistry.publishEphemeralToSinks(positioned, publishEphemeralCore);
1676
- return positioned;
1677
- });
1727
+ const publishEphemeral = publishEphemeralCore;
1678
1728
  const wakeAfterCommandAdmission = () => Queue.offer(ingressSignals, void 0);
1679
1729
  /** Use indexed store lookup for command idempotency instead of genesis replay. */
1680
1730
  const findExistingCommandAdmission = (command) => Effect.gen(function* () {
@@ -3107,6 +3157,6 @@ const requireTurnFailed = (committed) => isTurnFailed(committed) ? Effect.succee
3107
3157
  const isTurnFailed = (committed) => committed.event.type === turnFailedEventType;
3108
3158
  const isSessionNoRunnableCommand = (result) => "_tag" in result && result._tag === "SessionNoRunnableCommand";
3109
3159
  //#endregion
3110
- export { SessionCommandOutcome as a, SessionNoRunnableReason as c, TurnRunner as d, InferenceRunner as f, SessionCommandFailed as i, SessionRunInput as l, SessionCommandCancelled as n, SessionForkedCommand as o, ToolExecutor as p, SessionCommandCompleted as r, SessionNoRunnableCommand as s, SessionCommandAdmissionConflict as t, SessionState as u };
3160
+ export { SessionCommandOutcome as a, SessionNoRunnableReason as c, TurnRunner as d, InferenceRunner as f, SessionCommandFailed as i, SessionRunInput as l, LiveEventBus as m, SessionCommandCancelled as n, SessionForkedCommand as o, ToolExecutor as p, SessionCommandCompleted as r, SessionNoRunnableCommand as s, SessionCommandAdmissionConflict as t, SessionState as u };
3111
3161
 
3112
- //# sourceMappingURL=session-state-DfYX21mA.js.map
3162
+ //# sourceMappingURL=session-state-Dk7Iie-r.js.map