effect-durable-agent 0.1.0-alpha.5 → 0.1.0-alpha.7
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-Dwdf41mq.d.ts → command-queues-C8muEqeQ.d.ts} +2 -2
- package/dist/{compaction-DpHOf-g7.d.ts → compaction-D7W0-Ur1.d.ts} +4 -4
- package/dist/{context-projection-B4DWOZgi.d.ts → context-projection-C43pyxn2.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/reduced-state.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{message-transcript-CFn_D3MH.d.ts → message-transcript-DsKTT47f.d.ts} +3 -3
- package/dist/{prompt-projector-C2meuNrV.d.ts → prompt-projector-hqPh5-NI.d.ts} +4 -4
- package/dist/{reducer-registry-K9FqZq5-.d.ts → reducer-registry--vQFATXb.d.ts} +16 -6
- package/dist/{runtime-5NEJngu3.d.ts → runtime-DXvMCq-J.d.ts} +7 -10
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/prompt-projector.d.ts +1 -1
- package/dist/services/reducer-registry.d.ts +2 -2
- package/dist/services/reducer-registry.js +7 -3
- package/dist/services/reducer-registry.js.map +1 -1
- package/dist/services/runtime-layer.d.ts +12 -9
- package/dist/services/runtime-layer.js +6 -4
- package/dist/services/runtime-layer.js.map +1 -1
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +2 -5
- package/dist/services/runtime.js.map +1 -1
- package/dist/services/session-event-observer.d.ts +2 -0
- package/dist/services/session-event-observer.js +13 -0
- package/dist/services/session-event-observer.js.map +1 -0
- package/dist/services/session-query.d.ts +2 -2
- package/dist/services/session-query.js +5 -5
- package/dist/services/session-query.js.map +1 -1
- 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 +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/span-names.d.ts +1 -1
- package/dist/services/span-names.js +1 -1
- package/dist/services/span-names.js.map +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/services/tracing.js +23 -2
- package/dist/services/tracing.js.map +1 -1
- package/dist/session-event-observer-D_aoFnQs.d.ts +24 -0
- package/dist/{session-query-5oyZRaQL.d.ts → session-query-lUZQpMvM.d.ts} +11 -11
- package/dist/{session-state-CI1xeT6f.d.ts → session-state-Bi3oEbJU.d.ts} +10 -10
- package/dist/{session-state-D7dqko7r.js → session-state-C4m0j6CJ.js} +3 -3
- package/dist/{session-state-D7dqko7r.js.map → session-state-C4m0j6CJ.js.map} +1 -1
- package/dist/{session-store-BLg6UvZa.d.ts → session-store-ofm8FFxs.d.ts} +2 -2
- package/dist/{sink-checkpoint-store-B9WNvDtY.d.ts → sink-checkpoint-store-BQVbI9DQ.d.ts} +2 -2
- package/dist/{sink-registry-CO3YPS1p.d.ts → sink-registry-CE-hL7cB.d.ts} +11 -19
- package/dist/{sink-registry-BbmoI9uv.js → sink-registry-DH6uiEgP.js} +14 -9
- package/dist/sink-registry-DH6uiEgP.js.map +1 -0
- package/dist/testkit/layers.d.ts +10 -10
- package/dist/testkit/layers.js +4 -4
- package/dist/testkit/layers.js.map +1 -1
- package/dist/{tool-registry-B8H1P6Pu.d.ts → tool-registry-ClHdr_G5.d.ts} +2 -2
- package/dist/{websocket-wire-DPxwY4G5.d.ts → websocket.d.ts} +316 -4
- package/dist/websocket.js +497 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +8 -12
- package/dist/host/websocket-protocol.d.ts +0 -252
- package/dist/host/websocket-protocol.js +0 -111
- package/dist/host/websocket-protocol.js.map +0 -1
- package/dist/host/websocket-wire.d.ts +0 -2
- package/dist/host/websocket-wire.js +0 -122
- package/dist/host/websocket-wire.js.map +0 -1
- package/dist/services/websocket-delivery.d.ts +0 -90
- package/dist/services/websocket-delivery.js +0 -221
- package/dist/services/websocket-delivery.js.map +0 -1
- package/dist/sink-registry-BbmoI9uv.js.map +0 -1
|
@@ -3,7 +3,7 @@ import { r as EDACommand, u as UserMessageContent } from "./commands-Ce1ec6kH.js
|
|
|
3
3
|
import { n as EDARunTrace, t as EDAEventTrace } from "./tracing-BXHAkxkx.js";
|
|
4
4
|
import { B as SystemPromptText, P as FailurePayload, R as ProviderPartId, U as UsagePayload, V as ToolName } from "./events-Bb9-Cu-7.js";
|
|
5
5
|
import { r as AssistantMessageContent, rt as RecoveryContinuation } from "./durable-B7M6TD_0.js";
|
|
6
|
-
import { t as CommittedDurableEvent } from "./session-store-
|
|
6
|
+
import { t as CommittedDurableEvent } from "./session-store-ofm8FFxs.js";
|
|
7
7
|
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
8
8
|
|
|
9
9
|
//#region src/domain/reduced-state.d.ts
|
|
@@ -466,4 +466,4 @@ declare const emptyCommandQueues: CommandQueues;
|
|
|
466
466
|
declare const deriveCommandQueues: (state: CommandQueueSource) => CommandQueues;
|
|
467
467
|
//#endregion
|
|
468
468
|
export { RunTerminal as A, activeTurnIdentityForCommand as B, ReducedStateCheckpointCommandRecord as C, ReducedStateCheckpointToolDecision as D, ReducedStateCheckpointToolCallRecord as E, ToolDecision as F, frameworkReducedStateReducerName as G, decodeReducedStateCheckpoint as H, ToolTerminal as I, pendingCommands as J, frameworkReducedStateReducerSchemaVersion as K, TurnRecord as L, TokenConsumptionState as M, TokenUsageTotals as N, ReducedStateCheckpointToolTerminal as O, ToolCallRecord as P, TurnTerminal as R, ReducedState as S, ReducedStateCheckpointPayload as T, encodeReducedStateCheckpoint as U, classifyRecoverableWork as V, foldReducedState as W, reduceCommittedEvents as X, pendingStopCommand as Y, reducedStateCheckpointEventSeqs as Z, LifecycleTiming as _, deriveCommandQueues as a, RecoverableWork as b, ActiveTurnIdentity as c, CompactionRecord as d, CompactionTerminal as f, LifecycleFailure as g, InferenceTerminal as h, PendingUserMessage as i, StopRequestRecord as j, RunRecord as k, CommandRecord as l, InferenceRecord as m, CommandQueues as n, emptyCommandQueues as o, ContextRecord as p, initialReducedState as q, PendingSteeringMessage as r, ActiveCommandEvidence as s, CommandQueueSource as t, CommandTerminal as u, MessageRecord as v, ReducedStateCheckpointMessageRecord as w, RecoveryContinuationRecord as x, PendingCommand as y, activeCommand as z };
|
|
469
|
-
//# sourceMappingURL=command-queues-
|
|
469
|
+
//# sourceMappingURL=command-queues-C8muEqeQ.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as ContextProjection, n as CompactionPolicyId, t as CompactionExecutorId } from "./context-projection-
|
|
2
|
-
import { o as EDASessionStoreError, r as DurableAppendEntry, t as CommittedDurableEvent } from "./session-store-
|
|
3
|
-
import { S as ReducedState } from "./command-queues-
|
|
1
|
+
import { i as ContextProjection, n as CompactionPolicyId, t as CompactionExecutorId } from "./context-projection-C43pyxn2.js";
|
|
2
|
+
import { o as EDASessionStoreError, r as DurableAppendEntry, t as CommittedDurableEvent } from "./session-store-ofm8FFxs.js";
|
|
3
|
+
import { S as ReducedState } from "./command-queues-C8muEqeQ.js";
|
|
4
4
|
import { t as IdGenerator } from "./id-generator-Ckl8_XWW.js";
|
|
5
5
|
import { t as EventFactory } from "./event-factory-CLJcyymV.js";
|
|
6
6
|
import { t as EDAKeepAlive } from "./keep-alive-Chl5SJxy.js";
|
|
@@ -143,4 +143,4 @@ declare class CompactionRunner extends CompactionRunner_base {
|
|
|
143
143
|
}
|
|
144
144
|
//#endregion
|
|
145
145
|
export { defaultCompactionRetainTailTokens as _, CompactionExecutorShape as a, CompactionPolicy as c, CompactionRunner as d, CompactionRunnerInput as f, defaultCompactionMinSummarizableTokens as g, defaultCompactionCharsPerToken as h, CompactionExecutorInput as i, CompactionPolicyInput as l, LanguageModelSummaryCompactionExecutorOptions as m, CompactionError as n, CompactionOutput as o, CompactionRunnerShape as p, CompactionExecutor as r, CompactionPlan as s, ApproximateTokenThresholdCompactionPolicyOptions as t, CompactionPolicyShape as u, defaultCompactionThresholdTokens as v };
|
|
146
|
-
//# sourceMappingURL=compaction-
|
|
146
|
+
//# sourceMappingURL=compaction-D7W0-Ur1.d.ts.map
|
|
@@ -87,9 +87,9 @@ declare const emptyContextProjection: {
|
|
|
87
87
|
readonly contextVersion: number & import("effect/Brand").Brand<"ContextVersion">;
|
|
88
88
|
readonly currentSummary?: {
|
|
89
89
|
readonly compactionId: string & import("effect/Brand").Brand<"CompactionId">;
|
|
90
|
+
readonly summaryId: string & import("effect/Brand").Brand<"SummaryId">;
|
|
90
91
|
readonly sourceFromSeq: number & import("effect/Brand").Brand<"SequenceNumber">;
|
|
91
92
|
readonly sourceToSeq: number & import("effect/Brand").Brand<"SequenceNumber">;
|
|
92
|
-
readonly summaryId: string & import("effect/Brand").Brand<"SummaryId">;
|
|
93
93
|
readonly retainedFromContextSeq: number & import("effect/Brand").Brand<"SequenceNumber">;
|
|
94
94
|
readonly text: string;
|
|
95
95
|
readonly promptMessage: {
|
|
@@ -137,4 +137,4 @@ declare const emptyContextProjection: {
|
|
|
137
137
|
};
|
|
138
138
|
//#endregion
|
|
139
139
|
export { emptyContextProjection as a, ContextProjection as i, CompactionPolicyId as n, CompactionSummaryArtifact as r, CompactionExecutorId as t };
|
|
140
|
-
//# sourceMappingURL=context-projection-
|
|
140
|
+
//# sourceMappingURL=context-projection-C43pyxn2.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as deriveCommandQueues, i as PendingUserMessage, n as CommandQueues, o as emptyCommandQueues, r as PendingSteeringMessage, t as CommandQueueSource } from "../command-queues-
|
|
1
|
+
import { a as deriveCommandQueues, i as PendingUserMessage, n as CommandQueues, o as emptyCommandQueues, r as PendingSteeringMessage, t as CommandQueueSource } from "../command-queues-C8muEqeQ.js";
|
|
2
2
|
export { CommandQueueSource, CommandQueues, PendingSteeringMessage, PendingUserMessage, deriveCommandQueues, emptyCommandQueues };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as emptyContextProjection, i as ContextProjection, n as CompactionPolicyId, r as CompactionSummaryArtifact, t as CompactionExecutorId } from "../context-projection-
|
|
1
|
+
import { a as emptyContextProjection, i as ContextProjection, n as CompactionPolicyId, r as CompactionSummaryArtifact, t as CompactionExecutorId } from "../context-projection-C43pyxn2.js";
|
|
2
2
|
export { CompactionExecutorId, CompactionPolicyId, CompactionSummaryArtifact, ContextProjection, emptyContextProjection };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as durableMessageTranscript, i as contextProjectionPromptWithUserContents, n as contextProjectionPrompt, o as durableTranscriptPrompt, r as contextProjectionPromptWithUserContent, s as durableTranscriptPromptWithUserContent, t as DurableTranscriptMessage } from "../message-transcript-
|
|
1
|
+
import { a as durableMessageTranscript, i as contextProjectionPromptWithUserContents, n as contextProjectionPrompt, o as durableTranscriptPrompt, r as contextProjectionPromptWithUserContent, s as durableTranscriptPromptWithUserContent, t as DurableTranscriptMessage } from "../message-transcript-DsKTT47f.js";
|
|
2
2
|
export { DurableTranscriptMessage, contextProjectionPrompt, contextProjectionPromptWithUserContent, contextProjectionPromptWithUserContents, durableMessageTranscript, durableTranscriptPrompt, durableTranscriptPromptWithUserContent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as RunTerminal, B as activeTurnIdentityForCommand, C as ReducedStateCheckpointCommandRecord, D as ReducedStateCheckpointToolDecision, E as ReducedStateCheckpointToolCallRecord, F as ToolDecision, G as frameworkReducedStateReducerName, H as decodeReducedStateCheckpoint, I as ToolTerminal, J as pendingCommands, K as frameworkReducedStateReducerSchemaVersion, L as TurnRecord, M as TokenConsumptionState, N as TokenUsageTotals, O as ReducedStateCheckpointToolTerminal, P as ToolCallRecord, R as TurnTerminal, S as ReducedState, T as ReducedStateCheckpointPayload, U as encodeReducedStateCheckpoint, V as classifyRecoverableWork, W as foldReducedState, X as reduceCommittedEvents, Y as pendingStopCommand, Z as reducedStateCheckpointEventSeqs, _ as LifecycleTiming, b as RecoverableWork, c as ActiveTurnIdentity, d as CompactionRecord, f as CompactionTerminal, g as LifecycleFailure, h as InferenceTerminal, j as StopRequestRecord, k as RunRecord, l as CommandRecord, m as InferenceRecord, p as ContextRecord, q as initialReducedState, s as ActiveCommandEvidence, u as CommandTerminal, v as MessageRecord, w as ReducedStateCheckpointMessageRecord, x as RecoveryContinuationRecord, y as PendingCommand, z as activeCommand } from "../command-queues-
|
|
1
|
+
import { A as RunTerminal, B as activeTurnIdentityForCommand, C as ReducedStateCheckpointCommandRecord, D as ReducedStateCheckpointToolDecision, E as ReducedStateCheckpointToolCallRecord, F as ToolDecision, G as frameworkReducedStateReducerName, H as decodeReducedStateCheckpoint, I as ToolTerminal, J as pendingCommands, K as frameworkReducedStateReducerSchemaVersion, L as TurnRecord, M as TokenConsumptionState, N as TokenUsageTotals, O as ReducedStateCheckpointToolTerminal, P as ToolCallRecord, R as TurnTerminal, S as ReducedState, T as ReducedStateCheckpointPayload, U as encodeReducedStateCheckpoint, V as classifyRecoverableWork, W as foldReducedState, X as reduceCommittedEvents, Y as pendingStopCommand, Z as reducedStateCheckpointEventSeqs, _ as LifecycleTiming, b as RecoverableWork, c as ActiveTurnIdentity, d as CompactionRecord, f as CompactionTerminal, g as LifecycleFailure, h as InferenceTerminal, j as StopRequestRecord, k as RunRecord, l as CommandRecord, m as InferenceRecord, p as ContextRecord, q as initialReducedState, s as ActiveCommandEvidence, u as CommandTerminal, v as MessageRecord, w as ReducedStateCheckpointMessageRecord, x as RecoveryContinuationRecord, y as PendingCommand, z as activeCommand } from "../command-queues-C8muEqeQ.js";
|
|
2
2
|
export { ActiveCommandEvidence, ActiveTurnIdentity, CommandRecord, CommandTerminal, CompactionRecord, CompactionTerminal, ContextRecord, InferenceRecord, InferenceTerminal, LifecycleFailure, LifecycleTiming, MessageRecord, PendingCommand, RecoverableWork, RecoveryContinuationRecord, ReducedState, ReducedStateCheckpointCommandRecord, ReducedStateCheckpointMessageRecord, ReducedStateCheckpointPayload, ReducedStateCheckpointToolCallRecord, ReducedStateCheckpointToolDecision, ReducedStateCheckpointToolTerminal, RunRecord, RunTerminal, StopRequestRecord, TokenConsumptionState, TokenUsageTotals, ToolCallRecord, ToolDecision, ToolTerminal, TurnRecord, TurnTerminal, activeCommand, activeTurnIdentityForCommand, classifyRecoverableWork, decodeReducedStateCheckpoint, encodeReducedStateCheckpoint, foldReducedState, frameworkReducedStateReducerName, frameworkReducedStateReducerSchemaVersion, initialReducedState, pendingCommands, pendingStopCommand, reduceCommittedEvents, reducedStateCheckpointEventSeqs };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { a as PromotePendingMessageCommand, c as SubmitMessageCommand, d as User
|
|
|
3
3
|
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";
|
|
4
4
|
import { A as EventEnvelope, B as SystemPromptText, C as toolParamsDeltaEventType, D as DurableEventEnvelope, E as traceStatusEventType, F as ModelSelectionPayload, G as makeEventType, H as UnixEpochMillis, I as NonNegativeInt, K as schemaV1, L as PositionedEvent, M as EventType, N as EventTypeName, O as EphemeralEventEnvelope, P as FailurePayload, R as ProviderPartId, S as textDeltaEventType, T as toolParamsStartEventType, U as UsagePayload, V as ToolName, W as effectDurableAgentNamespace, _ 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, j as EventNamespace, k as EventDurability, 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, z as SchemaVersion } from "./events-Bb9-Cu-7.js";
|
|
5
5
|
import { $ as PendingMessagesPausedEvent, $n as turnStoppedEventType, $t as TurnStoppedPayload, A as CompactionFailedEvent, An as inferenceFailedEventType, At as ToolCallCreatedPayload, B as ContextRebasedPayload, Bn as steeringMessageQueuedEventType, Bt as ToolCallStartedPayload, C as CommandEvent, Cn as compactionRequestedEventType, Ct as SummaryCreatedEvent, D as CommandStartedPayload, Dn as decodeUnknownEDADurableEvent, Dt as ToolCallCompletedEvent, E as CommandStartedEvent, En as contextRebasedEventType, Et as SystemMessageCommittedPayload, F as CompactionStartedPayload, Fn as runCompletedEventType, Ft as ToolCallRejectedEvent, G as InferenceEvent, Gn as toolCallCompletedEventType, Gt as TurnCompletedEvent, H as EDADurableEventV1, Hn as stopTurnRequestedEventType, Ht as ToolPromptPart, I as ContextAndCompactionEvent, In as runFailedEventType, It as ToolCallRejectedPayload, J as InferenceStartedEvent, Jn as toolCallRejectedEventType, Jt as TurnFailedEvent, K as InferenceFailedEvent, Kn as toolCallCreatedEventType, Kt as TurnCompletedPayload, L as ContextProjectedEvent, Ln as runInterruptedEventType, Lt as ToolCallRejectionFeedback, M as CompactionRequestedEvent, Mn as messageQueuePausedEventType, Mt as ToolCallFailedEvent, N as CompactionRequestedPayload, Nn as pendingMessagesPausedEventType, Nt as ToolCallFailedPayload, O as CompactionCompletedEvent, On as decodeUnknownEDADurableEventSync, Ot as ToolCallCompletedPayload, P as CompactionStartedEvent, Pn as recoveryCompletedEventType, Pt as ToolCallPromptPart, Q as MessageQueuePausedPayload, Qn as turnStartedEventType, Qt as TurnStoppedEvent, R as ContextProjectedPayload, Rn as runStartedEventType, Rt as ToolCallRejectionReason, S as CommandCompletedPayload, Sn as compactionFailedEventType, St as StopTurnRequestedPayload, T as CommandFailedPayload, Tn as contextProjectedEventType, Tt as SystemMessageCommittedEvent, U as InferenceCompletedEvent, Un as summaryCreatedEventType, Ut as ToolRejectionPromptPart, V as EDADurableEvent, Vn as stopTurnAppliedEventType, Vt as ToolFailurePromptPart, W as InferenceCompletedPayload, Wn as systemMessageCommittedEventType, Wt as ToolSuccessPromptPart, X as MessageEvent, Xn as turnCompletedEventType, Xt as TurnStartedEvent, Y as InferenceStartedPayload, Yn as toolCallStartedEventType, Yt as TurnFailedPayload, Z as MessageQueuePausedEvent, Zn as turnFailedEventType, Zt as TurnStartedPayload, _ as CommandAdmittedEvent, _n as commandCancelledEventType, _t as SteeringMessageQueuedPayload, a as AssistantMessageImportedPayload, an as UserMessageDisposition, at as RunCompletedEvent, b as CommandCancelledPayload, bn as commandStartedEventType, bt as StopTurnAppliedPayload, c as AssistantPromptPart, cn as UserMessageSubmittedEvent, ct as RunFailedEvent, d as BaseStateCreatedPayload, dn as assistantMessageImportedEventType, dt as RunInterruptedPayload, en as UserMessageCancellationReason, er as userMessageCancelledEventType, et as PendingMessagesPausedPayload, f as BaseStateEvent, fn as assistantPartialCommittedEventType, ft as RunStartedEvent, g as BaseStateRequestedPayload, gn as commandAdmittedEventType, gt as SteeringMessageQueuedEvent, h as BaseStateRequestedEvent, hn as baseStateRequestedEventType, ht as SteeringMessageCancelledPayload, i as AssistantMessageImportedEvent, in as UserMessageCommittedPayload, it as RecoveryEvent, j as CompactionFailedPayload, jn as inferenceStartedEventType, jt as ToolCallEvent, k as CompactionCompletedPayload, kn as inferenceCompletedEventType, kt as ToolCallCreatedEvent, l as AssistantPromptParts, ln as UserMessageSubmittedPayload, lt as RunFailedPayload, m as BaseStateFailedPayload, mn as baseStateFailedEventType, mt as SteeringMessageCancelledEvent, n as AssistantMessageCommittedPayload, nn as UserMessageCancelledPayload, nr as userMessagePromotedEventType, nt as RecoveryCompletedPayload, o as AssistantPartialCommittedEvent, on as UserMessagePromotedEvent, ot as RunCompletedPayload, p as BaseStateFailedEvent, pn as baseStateCreatedEventType, pt as RunStartedPayload, q as InferenceFailedPayload, qn as toolCallFailedEventType, qt as TurnEvent, r as AssistantMessageContent, rn as UserMessageCommittedEvent, rr as userMessageSubmittedEventType, rt as RecoveryContinuation, s as AssistantPartialCommittedPayload, sn as UserMessagePromotedPayload, st as RunEvent, t as AssistantMessageCommittedEvent, tn as UserMessageCancelledEvent, tr as userMessageCommittedEventType, tt as RecoveryCompletedEvent, u as BaseStateCreatedEvent, un as assistantMessageCommittedEventType, ut as RunInterruptedEvent, v as CommandAdmittedPayload, vn as commandCompletedEventType, vt as StopControlEvent, w as CommandFailedEvent, wn as compactionStartedEventType, wt as SummaryCreatedPayload, x as CommandCompletedEvent, xn as compactionCompletedEventType, xt as StopTurnRequestedEvent, y as CommandCancelledEvent, yn as commandFailedEventType, yt as StopTurnAppliedEvent, z as ContextRebasedEvent, zn as steeringMessageCancelledEventType, zt as ToolCallStartedEvent } from "./durable-B7M6TD_0.js";
|
|
6
|
-
import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "./runtime-
|
|
6
|
+
import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "./runtime-DXvMCq-J.js";
|
|
7
7
|
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, 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, RunStartedEvent, RunStartedPayload, RuntimeStatusEvent, SchemaVersion, SequenceNumber, 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, 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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { u as UserMessageContent } from "./commands-Ce1ec6kH.js";
|
|
2
|
-
import { i as ContextProjection } from "./context-projection-
|
|
3
|
-
import { S as ReducedState, v as MessageRecord } from "./command-queues-
|
|
2
|
+
import { i as ContextProjection } from "./context-projection-C43pyxn2.js";
|
|
3
|
+
import { S as ReducedState, v as MessageRecord } from "./command-queues-C8muEqeQ.js";
|
|
4
4
|
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
5
5
|
|
|
6
6
|
//#region src/domain/message-transcript.d.ts
|
|
@@ -29,4 +29,4 @@ declare const contextProjectionPromptWithUserContent: (state: PromptProjectionSt
|
|
|
29
29
|
declare const contextProjectionPromptWithUserContents: (state: PromptProjectionState, context: ContextProjection | undefined, contents: ReadonlyArray<UserMessageContent>) => Prompt.Prompt;
|
|
30
30
|
//#endregion
|
|
31
31
|
export { durableMessageTranscript as a, contextProjectionPromptWithUserContents as i, contextProjectionPrompt as n, durableTranscriptPrompt as o, contextProjectionPromptWithUserContent as r, durableTranscriptPromptWithUserContent as s, DurableTranscriptMessage as t };
|
|
32
|
-
//# sourceMappingURL=message-transcript-
|
|
32
|
+
//# sourceMappingURL=message-transcript-DsKTT47f.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h as SessionId } from "./core-CYT6DBaS.js";
|
|
2
|
-
import { i as ContextProjection } from "./context-projection-
|
|
3
|
-
import { S as ReducedState } from "./command-queues-
|
|
4
|
-
import {
|
|
2
|
+
import { i as ContextProjection } from "./context-projection-C43pyxn2.js";
|
|
3
|
+
import { S as ReducedState } from "./command-queues-C8muEqeQ.js";
|
|
4
|
+
import { a as EDAReducerStateSnapshot } from "./reducer-registry--vQFATXb.js";
|
|
5
5
|
import * as Context from "effect/Context";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
@@ -36,4 +36,4 @@ declare class EDAPromptProjector extends EDAPromptProjector_base {
|
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
export { buildEDAPrompt as a, EDAPromptProjectorShape as i, EDAPromptProjectionInput as n, EDAPromptProjector as r, EDAProjectedPromptContext as t };
|
|
39
|
-
//# sourceMappingURL=prompt-projector-
|
|
39
|
+
//# sourceMappingURL=prompt-projector-hqPh5-NI.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as CommittedDurableEvent } from "./session-store-
|
|
1
|
+
import { t as CommittedDurableEvent } from "./session-store-ofm8FFxs.js";
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
|
|
6
6
|
//#region src/services/reducer-registry.d.ts
|
|
7
|
-
/**
|
|
8
|
-
interface
|
|
7
|
+
/** Input accepted by the reducer constructor before schema codecs are materialized. */
|
|
8
|
+
interface EDAReducerDefinition<State, Name extends string = string> {
|
|
9
9
|
readonly name: Name;
|
|
10
10
|
readonly initial: State;
|
|
11
11
|
readonly stateSchema: Schema.Codec<State, unknown, never, never>;
|
|
@@ -14,9 +14,19 @@ interface EDAReducer<State = unknown, Name extends string = string> {
|
|
|
14
14
|
readonly decode?: (payload: unknown) => State;
|
|
15
15
|
reduce(state: State, event: CommittedDurableEvent): State;
|
|
16
16
|
}
|
|
17
|
+
/** App-specific pure reducer over the durable session event log. */
|
|
18
|
+
interface EDAReducer<State = unknown, Name extends string = string> {
|
|
19
|
+
readonly name: Name;
|
|
20
|
+
readonly initial: State;
|
|
21
|
+
readonly stateSchema: Schema.Codec<State, unknown, never, never>;
|
|
22
|
+
readonly schemaVersion?: number;
|
|
23
|
+
encode(state: State): unknown;
|
|
24
|
+
decode(payload: unknown): State;
|
|
25
|
+
reduce(state: State, event: CommittedDurableEvent): State;
|
|
26
|
+
}
|
|
17
27
|
/** Convenience constructor preserving a reducer's literal name and schema-derived state type. */
|
|
18
28
|
declare const EDAReducer: {
|
|
19
|
-
make: <State, const Name extends string = string>(reducer:
|
|
29
|
+
make: <State, const Name extends string = string>(reducer: EDAReducerDefinition<State, Name>) => EDAReducer<State, Name>;
|
|
20
30
|
};
|
|
21
31
|
/** Snapshot of all app reducer states, keyed by reducer name. */
|
|
22
32
|
type EDAReducerStateSnapshot = ReadonlyMap<string, unknown>;
|
|
@@ -65,5 +75,5 @@ declare class EDAReducerRegistry extends EDAReducerRegistry_base {
|
|
|
65
75
|
/** Read one typed reducer state from a snapshot. */
|
|
66
76
|
declare const getEDAReducerState: <State, Name extends string>(snapshot: EDAReducerStateSnapshot, reducer: EDAReducer<State, Name>) => State;
|
|
67
77
|
//#endregion
|
|
68
|
-
export {
|
|
69
|
-
//# sourceMappingURL=reducer-registry
|
|
78
|
+
export { EDAReducerStateSnapshot as a, decodeReducerState as c, encodeReducerState as d, getEDAReducerState as f, EDAReducerRegistryShape as i, defineEDAReducerRegistry as l, EDAReducerDefinition as n, EDAReducersFor as o, reducerSchemaVersion as p, EDAReducerRegistry as r, EDATypedReducerRegistry as s, EDAReducer as t, edaReservedReducerNamePrefix as u };
|
|
79
|
+
//# sourceMappingURL=reducer-registry--vQFATXb.d.ts.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { m as SequenceNumber, n as CommandId } from "./core-CYT6DBaS.js";
|
|
2
2
|
import { r as EDACommand } from "./commands-Ce1ec6kH.js";
|
|
3
3
|
import { w as CommandFailedEvent, x as CommandCompletedEvent, y as CommandCancelledEvent } from "./durable-B7M6TD_0.js";
|
|
4
|
-
import { t as CommittedDurableEvent } from "./session-store-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { n as EDASessionQuery, r as EDASessionQueryShape } from "./session-query-5oyZRaQL.js";
|
|
4
|
+
import { t as CommittedDurableEvent } from "./session-store-ofm8FFxs.js";
|
|
5
|
+
import { h as SessionState, r as SessionCommandAdmissionError, t as EDASubmittable } from "./session-state-Bi3oEbJU.js";
|
|
6
|
+
import { n as EDASessionQuery, r as EDASessionQueryShape } from "./session-query-lUZQpMvM.js";
|
|
8
7
|
import * as Context from "effect/Context";
|
|
9
8
|
import * as Effect from "effect/Effect";
|
|
10
9
|
import * as Layer from "effect/Layer";
|
|
@@ -51,16 +50,14 @@ interface EDARuntimeShape {
|
|
|
51
50
|
readonly messages: EDASessionQueryShape["messages"];
|
|
52
51
|
/** Backfill durable events after a committed sequence, then follow live events. */
|
|
53
52
|
readonly eventsAfter: EDASessionQueryShape["eventsAfter"];
|
|
54
|
-
/** Read one bounded committed durable
|
|
55
|
-
readonly
|
|
56
|
-
/** Register one push-delivery listener invoked inline on every published event. */
|
|
57
|
-
readonly registerDeliveryListener: LiveEventBusShape["registerDeliveryListener"];
|
|
53
|
+
/** Read one bounded page of committed durable events plus the committed head. */
|
|
54
|
+
readonly readEventPage: EDASessionQueryShape["readEventPage"];
|
|
58
55
|
}
|
|
59
56
|
declare const EDARuntime_base: Context.ServiceClass<EDARuntime, "@effect-durable-agent/EDARuntime", EDARuntimeShape>;
|
|
60
57
|
/** Top-level public facade for one effect-durable-agent session runtime. */
|
|
61
58
|
declare class EDARuntime extends EDARuntime_base {
|
|
62
|
-
static readonly Live: (config: EDARuntimeConfig) => Layer.Layer<EDARuntime, SessionCommandAdmissionError, SessionState |
|
|
59
|
+
static readonly Live: (config: EDARuntimeConfig) => Layer.Layer<EDARuntime, SessionCommandAdmissionError, SessionState | EDASessionQuery>;
|
|
63
60
|
}
|
|
64
61
|
//#endregion
|
|
65
62
|
export { EDARuntimeError as a, EDARuntimeConfig as i, EDACommandTerminalEvent as n, EDARuntimeShape as o, EDARuntime as r, EDARuntimeSubmit as s, CommittedCommandTerminalEvent as t };
|
|
66
|
-
//# sourceMappingURL=runtime-
|
|
63
|
+
//# sourceMappingURL=runtime-DXvMCq-J.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-
|
|
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-D7W0-Ur1.js";
|
|
2
2
|
export { ApproximateTokenThresholdCompactionPolicyOptions, CompactionError, CompactionExecutor, CompactionExecutorInput, CompactionExecutorShape, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionPolicyInput, CompactionPolicyShape, CompactionRunner, CompactionRunnerInput, CompactionRunnerShape, LanguageModelSummaryCompactionExecutorOptions, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionThresholdTokens };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as buildEDAPrompt, i as EDAPromptProjectorShape, n as EDAPromptProjectionInput, r as EDAPromptProjector, t as EDAProjectedPromptContext } from "../prompt-projector-
|
|
1
|
+
import { a as buildEDAPrompt, i as EDAPromptProjectorShape, n as EDAPromptProjectionInput, r as EDAPromptProjector, t as EDAProjectedPromptContext } from "../prompt-projector-hqPh5-NI.js";
|
|
2
2
|
export { EDAProjectedPromptContext, EDAPromptProjectionInput, EDAPromptProjector, EDAPromptProjectorShape, buildEDAPrompt };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { EDAReducer, EDAReducerRegistry, EDAReducerRegistryShape, EDAReducerStateSnapshot, EDAReducersFor, EDATypedReducerRegistry, decodeReducerState, defineEDAReducerRegistry, edaReservedReducerNamePrefix, encodeReducerState, getEDAReducerState, reducerSchemaVersion };
|
|
1
|
+
import { a as EDAReducerStateSnapshot, c as decodeReducerState, d as encodeReducerState, f as getEDAReducerState, i as EDAReducerRegistryShape, l as defineEDAReducerRegistry, n as EDAReducerDefinition, o as EDAReducersFor, p as reducerSchemaVersion, r as EDAReducerRegistry, s as EDATypedReducerRegistry, t as EDAReducer, u as edaReservedReducerNamePrefix } from "../reducer-registry--vQFATXb.js";
|
|
2
|
+
export { EDAReducer, EDAReducerDefinition, EDAReducerRegistry, EDAReducerRegistryShape, EDAReducerStateSnapshot, EDAReducersFor, EDATypedReducerRegistry, decodeReducerState, defineEDAReducerRegistry, edaReservedReducerNamePrefix, encodeReducerState, getEDAReducerState, reducerSchemaVersion };
|
|
@@ -3,7 +3,11 @@ import * as Layer from "effect/Layer";
|
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
4
|
//#region src/services/reducer-registry.ts
|
|
5
5
|
/** Convenience constructor preserving a reducer's literal name and schema-derived state type. */
|
|
6
|
-
const EDAReducer = { make: (reducer) =>
|
|
6
|
+
const EDAReducer = { make: (reducer) => ({
|
|
7
|
+
...reducer,
|
|
8
|
+
encode: reducer.encode ?? ((state) => Schema.encodeUnknownSync(reducer.stateSchema)(state)),
|
|
9
|
+
decode: reducer.decode ?? ((payload) => Schema.decodeUnknownSync(reducer.stateSchema)(payload))
|
|
10
|
+
}) };
|
|
7
11
|
const reducerValues = (reducers) => Object.values(reducers);
|
|
8
12
|
/**
|
|
9
13
|
* Register an app's complete reducer set against its public serialized-state union.
|
|
@@ -28,9 +32,9 @@ const edaReservedReducerNamePrefix = "_eda.";
|
|
|
28
32
|
/** Return the persisted schema version for one reducer. */
|
|
29
33
|
const reducerSchemaVersion = (reducer) => reducer.schemaVersion ?? 1;
|
|
30
34
|
/** Encode one reducer state for durable checkpoint storage. */
|
|
31
|
-
const encodeReducerState = (reducer, state) => reducer.encode
|
|
35
|
+
const encodeReducerState = (reducer, state) => reducer.encode(state);
|
|
32
36
|
/** Decode one reducer state from durable checkpoint storage. */
|
|
33
|
-
const decodeReducerState = (reducer, payload) => reducer.decode
|
|
37
|
+
const decodeReducerState = (reducer, payload) => reducer.decode(payload);
|
|
34
38
|
/** Registry for app-specific durable metadata reducers. */
|
|
35
39
|
var EDAReducerRegistry = class EDAReducerRegistry extends Context.Service()("@effect-durable-agent/EDAReducerRegistry") {
|
|
36
40
|
static Empty = Layer.succeed(EDAReducerRegistry, makeReducerRegistry([]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer-registry.js","names":[],"sources":["../../src/services/reducer-registry.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport type { CommittedDurableEvent } from \"./session-store\";\n\n/** App-specific pure reducer over the durable session event log. */\nexport interface EDAReducer<State = unknown, Name extends string = string> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n
|
|
1
|
+
{"version":3,"file":"reducer-registry.js","names":[],"sources":["../../src/services/reducer-registry.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport type { CommittedDurableEvent } from \"./session-store\";\n\n/** Input accepted by the reducer constructor before schema codecs are materialized. */\nexport interface EDAReducerDefinition<State, Name extends string = string> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n readonly encode?: (state: State) => unknown;\n readonly decode?: (payload: unknown) => State;\n reduce(state: State, event: CommittedDurableEvent): State;\n}\n\n/** App-specific pure reducer over the durable session event log. */\nexport interface EDAReducer<State = unknown, Name extends string = string> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n encode(state: State): unknown;\n decode(payload: unknown): State;\n reduce(state: State, event: CommittedDurableEvent): State;\n}\n\n/** Convenience constructor preserving a reducer's literal name and schema-derived state type. */\nexport const EDAReducer = {\n make: <State, const Name extends string = string>(\n reducer: EDAReducerDefinition<State, Name>,\n ): EDAReducer<State, Name> => ({\n ...reducer,\n encode: reducer.encode ?? ((state) => Schema.encodeUnknownSync(reducer.stateSchema)(state)),\n decode: reducer.decode ?? ((payload) => Schema.decodeUnknownSync(reducer.stateSchema)(payload)),\n }),\n};\n\n/** Snapshot of all app reducer states, keyed by reducer name. */\nexport type EDAReducerStateSnapshot = ReadonlyMap<string, unknown>;\n\ninterface EDASerializedReducerState {\n readonly name: string;\n readonly state: unknown;\n}\n\ntype EDAReducerStateForName<\n Entry extends EDASerializedReducerState,\n Name extends Entry[\"name\"],\n> = Extract<Entry, { readonly name: Name }>[\"state\"];\n\n/** Exact reducer object required for every member of a serialized state union. */\nexport type EDAReducersFor<Entry extends EDASerializedReducerState> = {\n readonly [Name in Entry[\"name\"]]: EDAReducer<EDAReducerStateForName<Entry, Name>, Name>;\n};\n\n/** Schema-backed app reducer registry used by both runtime folding and snapshot serialization. */\nexport interface EDATypedReducerRegistry<\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n> {\n readonly entrySchema: EntrySchema;\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly serialize: (snapshot: EDAReducerStateSnapshot) => ReadonlyArray<EntrySchema[\"Type\"]>;\n}\n\nconst reducerValues = (reducers: Readonly<Record<string, EDAReducer>>): ReadonlyArray<EDAReducer> =>\n Object.values(reducers);\n\n/**\n * Register an app's complete reducer set against its public serialized-state union.\n *\n * Missing reducers, extra reducers, reducer-name drift, and state-schema drift are\n * rejected by TypeScript at the registration site.\n */\nexport const defineEDAReducerRegistry = <\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n>(\n entrySchema: EntrySchema,\n reducers: EDAReducersFor<EntrySchema[\"Type\"]>,\n): EDATypedReducerRegistry<EntrySchema> => {\n const values = reducerValues(reducers);\n const serializedStatesSchema = Schema.Array(entrySchema);\n return {\n entrySchema,\n reducers: values,\n serialize: (snapshot) =>\n Schema.decodeUnknownSync(serializedStatesSchema)(\n values.map((reducer) => ({\n name: reducer.name,\n state: snapshot.get(reducer.name) ?? reducer.initial,\n })),\n ),\n };\n};\n\n/** Registry that folds app-specific read-model state beside EDA reduced state. */\nexport interface EDAReducerRegistryShape {\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly initial: EDAReducerStateSnapshot;\n readonly reduce: (\n state: EDAReducerStateSnapshot,\n events: ReadonlyArray<CommittedDurableEvent>,\n ) => EDAReducerStateSnapshot;\n}\n\n/** Prefix reserved for framework-owned reducer checkpoints. */\nexport const edaReservedReducerNamePrefix = \"_eda.\";\n\n/** Return the persisted schema version for one reducer. */\nexport const reducerSchemaVersion = (reducer: EDAReducer): number => reducer.schemaVersion ?? 1;\n\n/** Encode one reducer state for durable checkpoint storage. */\nexport const encodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n state: State,\n): unknown => reducer.encode(state);\n\n/** Decode one reducer state from durable checkpoint storage. */\nexport const decodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n payload: unknown,\n): State => reducer.decode(payload);\n\n/** Registry for app-specific durable metadata reducers. */\nexport class EDAReducerRegistry extends Context.Service<\n EDAReducerRegistry,\n EDAReducerRegistryShape\n>()(\"@effect-durable-agent/EDAReducerRegistry\") {\n static readonly Empty = Layer.succeed(EDAReducerRegistry, makeReducerRegistry([]));\n\n static readonly Live = (reducers: ReadonlyArray<EDAReducer>) =>\n Layer.succeed(EDAReducerRegistry, makeReducerRegistry(reducers));\n}\n\n/** Read one typed reducer state from a snapshot. */\nexport const getEDAReducerState = <State, Name extends string>(\n snapshot: EDAReducerStateSnapshot,\n reducer: EDAReducer<State, Name>,\n): State => {\n const state = snapshot.get(reducer.name);\n return state === undefined\n ? reducer.initial\n : Schema.decodeUnknownSync(reducer.stateSchema)(state);\n};\n\nfunction makeReducerRegistry(reducers: ReadonlyArray<EDAReducer>): EDAReducerRegistryShape {\n validateReducerNames(reducers);\n const initial = new Map(reducers.map((reducer) => [reducer.name, reducer.initial]));\n return {\n reducers,\n initial,\n reduce: (state, events) => {\n if (events.length === 0 || reducers.length === 0) {\n return state;\n }\n const next = new Map(state);\n for (const event of events) {\n for (const reducer of reducers) {\n const current = next.get(reducer.name) ?? reducer.initial;\n next.set(reducer.name, reducer.reduce(current, event));\n }\n }\n return next;\n },\n };\n}\n\nfunction validateReducerNames(reducers: ReadonlyArray<EDAReducer>): void {\n const seen = new Set<string>();\n for (const reducer of reducers) {\n if (reducer.name.startsWith(edaReservedReducerNamePrefix)) {\n throw new Error(\n `Reducer name ${reducer.name} uses reserved EDA prefix ${edaReservedReducerNamePrefix}`,\n );\n }\n if (seen.has(reducer.name)) {\n throw new Error(`Duplicate EDA reducer name ${reducer.name}`);\n }\n seen.add(reducer.name);\n }\n}\n"],"mappings":";;;;;AA6BA,MAAa,aAAa,EACxB,OACE,aAC6B;CAC7B,GAAG;CACH,QAAQ,QAAQ,YAAY,UAAU,OAAO,kBAAkB,QAAQ,WAAW,EAAE,KAAK;CACzF,QAAQ,QAAQ,YAAY,YAAY,OAAO,kBAAkB,QAAQ,WAAW,EAAE,OAAO;AAC/F,GACF;AA6BA,MAAM,iBAAiB,aACrB,OAAO,OAAO,QAAQ;;;;;;;AAQxB,MAAa,4BAGX,aACA,aACyC;CACzC,MAAM,SAAS,cAAc,QAAQ;CACrC,MAAM,yBAAyB,OAAO,MAAM,WAAW;CACvD,OAAO;EACL;EACA,UAAU;EACV,YAAY,aACV,OAAO,kBAAkB,sBAAsB,EAC7C,OAAO,KAAK,aAAa;GACvB,MAAM,QAAQ;GACd,OAAO,SAAS,IAAI,QAAQ,IAAI,KAAK,QAAQ;EAC/C,EAAE,CACJ;CACJ;AACF;;AAaA,MAAa,+BAA+B;;AAG5C,MAAa,wBAAwB,YAAgC,QAAQ,iBAAiB;;AAG9F,MAAa,sBACX,SACA,UACY,QAAQ,OAAO,KAAK;;AAGlC,MAAa,sBACX,SACA,YACU,QAAQ,OAAO,OAAO;;AAGlC,IAAa,qBAAb,MAAa,2BAA2B,QAAQ,QAG9C,EAAE,0CAA0C,EAAE;CAC9C,OAAgB,QAAQ,MAAM,QAAQ,oBAAoB,oBAAoB,CAAC,CAAC,CAAC;CAEjF,OAAgB,QAAQ,aACtB,MAAM,QAAQ,oBAAoB,oBAAoB,QAAQ,CAAC;AACnE;;AAGA,MAAa,sBACX,UACA,YACU;CACV,MAAM,QAAQ,SAAS,IAAI,QAAQ,IAAI;CACvC,OAAO,UAAU,KAAA,IACb,QAAQ,UACR,OAAO,kBAAkB,QAAQ,WAAW,EAAE,KAAK;AACzD;AAEA,SAAS,oBAAoB,UAA8D;CACzF,qBAAqB,QAAQ;CAE7B,OAAO;EACL;EACA,SAAA,IAHkB,IAAI,SAAS,KAAK,YAAY,CAAC,QAAQ,MAAM,QAAQ,OAAO,CAAC,CAGzE;EACN,SAAS,OAAO,WAAW;GACzB,IAAI,OAAO,WAAW,KAAK,SAAS,WAAW,GAC7C,OAAO;GAET,MAAM,OAAO,IAAI,IAAI,KAAK;GAC1B,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,UAAU,KAAK,IAAI,QAAQ,IAAI,KAAK,QAAQ;IAClD,KAAK,IAAI,QAAQ,MAAM,QAAQ,OAAO,SAAS,KAAK,CAAC;GACvD;GAEF,OAAO;EACT;CACF;AACF;AAEA,SAAS,qBAAqB,UAA2C;CACvE,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,KAAK,WAAA,OAAuC,GACtD,MAAM,IAAI,MACR,gBAAgB,QAAQ,KAAK,4BAA4B,8BAC3D;EAEF,IAAI,KAAK,IAAI,QAAQ,IAAI,GACvB,MAAM,IAAI,MAAM,8BAA8B,QAAQ,MAAM;EAE9D,KAAK,IAAI,QAAQ,IAAI;CACvB;AACF"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { h as SessionId } from "../core-CYT6DBaS.js";
|
|
2
|
-
import { a as EDASessionStore, o as EDASessionStoreError } from "../session-store-
|
|
3
|
-
import { r as EDASink } from "../sink-registry-CO3YPS1p.js";
|
|
2
|
+
import { a as EDASessionStore, o as EDASessionStoreError } from "../session-store-ofm8FFxs.js";
|
|
4
3
|
import { t as EDAKeepAlive } from "../keep-alive-Chl5SJxy.js";
|
|
5
|
-
import { c as CompactionPolicy, r as CompactionExecutor } from "../compaction-
|
|
6
|
-
import {
|
|
7
|
-
import { r as
|
|
8
|
-
import {
|
|
9
|
-
import { r as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { c as CompactionPolicy, r as CompactionExecutor } from "../compaction-D7W0-Ur1.js";
|
|
5
|
+
import { t as SessionEventObserver } from "../session-event-observer-D_aoFnQs.js";
|
|
6
|
+
import { r as EDASink } from "../sink-registry-CE-hL7cB.js";
|
|
7
|
+
import { r as EDAReducerRegistry } from "../reducer-registry--vQFATXb.js";
|
|
8
|
+
import { r as EDAPromptProjector } from "../prompt-projector-hqPh5-NI.js";
|
|
9
|
+
import { n as SinkCheckpointStore } from "../sink-checkpoint-store-BQVbI9DQ.js";
|
|
10
|
+
import { r as SessionCommandAdmissionError } from "../session-state-Bi3oEbJU.js";
|
|
11
|
+
import { i as EDAToolRegistryShape, t as EDAModelToolkit } from "../tool-registry-ClHdr_G5.js";
|
|
12
|
+
import { i as EDARuntimeConfig, r as EDARuntime } from "../runtime-DXvMCq-J.js";
|
|
12
13
|
import * as Layer from "effect/Layer";
|
|
13
14
|
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
14
15
|
import * as Tracer from "effect/Tracer";
|
|
@@ -29,6 +30,7 @@ interface EDARuntimeLayerOptions {
|
|
|
29
30
|
readonly promptProjectorLayer?: Layer.Layer<EDAPromptProjector>;
|
|
30
31
|
readonly reducerRegistryLayer?: Layer.Layer<EDAReducerRegistry>;
|
|
31
32
|
readonly sessionId: SessionId;
|
|
33
|
+
readonly sessionEventObserverLayer?: Layer.Layer<SessionEventObserver>;
|
|
32
34
|
readonly sessionStoreLayer: Layer.Layer<EDASessionStore, EDASessionStoreError>;
|
|
33
35
|
readonly sinkCheckpointStoreLayer: Layer.Layer<SinkCheckpointStore, EDASessionStoreError>;
|
|
34
36
|
readonly sinks?: ReadonlyArray<EDASink>;
|
|
@@ -46,6 +48,7 @@ declare const makeEDARuntimeLayer: ({
|
|
|
46
48
|
promptProjectorLayer,
|
|
47
49
|
reducerRegistryLayer,
|
|
48
50
|
sessionId,
|
|
51
|
+
sessionEventObserverLayer,
|
|
49
52
|
sessionStoreLayer,
|
|
50
53
|
sinkCheckpointStoreLayer,
|
|
51
54
|
sinks,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as TurnRunner, f as InferenceRunner, p as ToolExecutor, u as SessionState } from "../session-state-D7dqko7r.js";
|
|
1
|
+
import { d as TurnRunner, f as InferenceRunner, p as ToolExecutor, u as SessionState } from "../session-state-C4m0j6CJ.js";
|
|
3
2
|
import { IdGenerator } from "./id-generator.js";
|
|
4
3
|
import { n as SessionContext, t as EventFactory } from "../event-factory-tcpLgdMN.js";
|
|
5
4
|
import { EDAKeepAlive } from "./keep-alive.js";
|
|
6
5
|
import { CompactionExecutor, CompactionPolicy, CompactionRunner } from "./compaction.js";
|
|
6
|
+
import { SessionEventObserver } from "./session-event-observer.js";
|
|
7
|
+
import { n as EDASinkRegistry, r as LiveEventBus } from "../sink-registry-DH6uiEgP.js";
|
|
7
8
|
import { EDAPromptProjector } from "./prompt-projector.js";
|
|
8
9
|
import { EDAReducerRegistry } from "./reducer-registry.js";
|
|
9
10
|
import { EDAToolRegistry } from "./tool-registry.js";
|
|
@@ -13,9 +14,10 @@ import * as Layer from "effect/Layer";
|
|
|
13
14
|
import * as Tracer from "effect/Tracer";
|
|
14
15
|
//#region src/services/runtime-layer.ts
|
|
15
16
|
/** Compose the complete platform-neutral EDA service graph for one session. */
|
|
16
|
-
const makeEDARuntimeLayer = ({ config, compactionExecutorLayer, compactionPolicyLayer, keepAliveLayer, modelLayer, promptProjectorLayer, reducerRegistryLayer, sessionId, sessionStoreLayer, sinkCheckpointStoreLayer, sinks, toolkit, toolRegistry, tracer }) => {
|
|
17
|
+
const makeEDARuntimeLayer = ({ config, compactionExecutorLayer, compactionPolicyLayer, keepAliveLayer, modelLayer, promptProjectorLayer, reducerRegistryLayer, sessionId, sessionEventObserverLayer, sessionStoreLayer, sinkCheckpointStoreLayer, sinks, toolkit, toolRegistry, tracer }) => {
|
|
17
18
|
const Store = sessionStoreLayer;
|
|
18
|
-
const
|
|
19
|
+
const EventObserver = sessionEventObserverLayer ?? SessionEventObserver.Noop;
|
|
20
|
+
const Bus = LiveEventBus.Live.pipe(Layer.provide(EventObserver));
|
|
19
21
|
const KeepAlive = keepAliveLayer ?? EDAKeepAlive.Noop;
|
|
20
22
|
const Ids = IdGenerator.Live;
|
|
21
23
|
const Session = SessionContext.Live(sessionId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-layer.js","names":[],"sources":["../../src/services/runtime-layer.ts"],"sourcesContent":["import type * as LanguageModel from \"effect/unstable/ai/LanguageModel\";\nimport * as Layer from \"effect/Layer\";\nimport * as Tracer from \"effect/Tracer\";\n\nimport type { SessionId } from \"../types/core\";\nimport { CompactionExecutor, CompactionPolicy, CompactionRunner } from \"./compaction\";\nimport { EventFactory } from \"./event-factory\";\nimport { IdGenerator } from \"./id-generator\";\nimport { InferenceRunner } from \"./inference-runner\";\nimport { EDAKeepAlive } from \"./keep-alive\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { EDAPromptProjector } from \"./prompt-projector\";\nimport { EDAReducerRegistry } from \"./reducer-registry\";\nimport { EDARuntime, type EDARuntimeConfig } from \"./runtime\";\nimport { SessionContext } from \"./session-context\";\nimport { EDASessionQuery } from \"./session-query\";\nimport { EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { SessionState, type SessionCommandAdmissionError } from \"./session-state\";\nimport { SinkCheckpointStore } from \"./sink-checkpoint-store\";\nimport { EDASinkRegistry, type EDASink } from \"./sink-registry\";\nimport { ToolExecutor } from \"./tool-executor\";\nimport { EDAToolRegistry, type EDAModelToolkit, type EDAToolRegistryShape } from \"./tool-registry\";\nimport { TurnRunner } from \"./turn-runner\";\n\n/**\n * Host-owned adapters and application policy needed to construct one EDA runtime.\n *\n * Core owns the service graph, while hosts supply only semantic persistence,\n * checkpoint, and lifecycle layers. Platform SDK types never cross this boundary.\n */\nexport interface EDARuntimeLayerOptions {\n readonly config: EDARuntimeConfig;\n readonly compactionExecutorLayer?: Layer.Layer<\n CompactionExecutor,\n never,\n LanguageModel.LanguageModel\n >;\n readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;\n readonly keepAliveLayer?: Layer.Layer<EDAKeepAlive>;\n readonly modelLayer: Layer.Layer<LanguageModel.LanguageModel>;\n readonly promptProjectorLayer?: Layer.Layer<EDAPromptProjector>;\n readonly reducerRegistryLayer?: Layer.Layer<EDAReducerRegistry>;\n readonly sessionId: SessionId;\n readonly sessionStoreLayer: Layer.Layer<EDASessionStore, EDASessionStoreError>;\n readonly sinkCheckpointStoreLayer: Layer.Layer<SinkCheckpointStore, EDASessionStoreError>;\n readonly sinks?: ReadonlyArray<EDASink>;\n readonly toolkit?: EDAModelToolkit;\n readonly toolRegistry?: EDAToolRegistryShape;\n readonly tracer?: Tracer.Tracer;\n}\n\n/** Compose the complete platform-neutral EDA service graph for one session. */\nexport const makeEDARuntimeLayer = ({\n config,\n compactionExecutorLayer,\n compactionPolicyLayer,\n keepAliveLayer,\n modelLayer,\n promptProjectorLayer,\n reducerRegistryLayer,\n sessionId,\n sessionStoreLayer,\n sinkCheckpointStoreLayer,\n sinks,\n toolkit,\n toolRegistry,\n tracer,\n}: EDARuntimeLayerOptions): Layer.Layer<EDARuntime, SessionCommandAdmissionError> => {\n const Store = sessionStoreLayer;\n const Bus = LiveEventBus.Live;\n const KeepAlive = keepAliveLayer ?? EDAKeepAlive.Noop;\n const Ids = IdGenerator.Live;\n const Session = SessionContext.Live(sessionId);\n const Factory = EventFactory.Live.pipe(Layer.provideMerge(Layer.mergeAll(Session, Ids)));\n const PromptProjector = promptProjectorLayer ?? EDAPromptProjector.Default;\n const ReducerRegistry = reducerRegistryLayer ?? EDAReducerRegistry.Empty;\n const CompactionPolicyLayer = compactionPolicyLayer ?? CompactionPolicy.Disabled;\n const CompactionExecutorLayer = compactionExecutorLayer ?? CompactionExecutor.Disabled;\n const Compaction = CompactionRunner.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Factory,\n Ids,\n KeepAlive,\n modelLayer,\n CompactionPolicyLayer,\n CompactionExecutorLayer,\n ),\n ),\n );\n const SinkRegistry = EDASinkRegistry.Live(sinks ?? []).pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Session,\n Store,\n Bus,\n sinkCheckpointStoreLayer,\n Factory,\n Ids,\n ReducerRegistry,\n KeepAlive,\n ),\n ),\n );\n const State = SessionState.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Bus,\n Session,\n ReducerRegistry,\n SinkRegistry,\n KeepAlive,\n Compaction,\n PromptProjector,\n ),\n ),\n );\n const Registry =\n toolRegistry !== undefined\n ? EDAToolRegistry.FromShape(toolRegistry)\n : toolkit === undefined\n ? EDAToolRegistry.Empty\n : EDAToolRegistry.FromToolkit(toolkit);\n const InferenceRunnerLayer = InferenceRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, modelLayer, Registry, Ids)),\n );\n const ToolExec = ToolExecutor.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Registry, Ids, Session)),\n );\n const Turn = TurnRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(InferenceRunnerLayer, ToolExec, Factory, Ids)),\n );\n const StateWithRun = State.pipe(Layer.provideMerge(Layer.mergeAll(Turn, Factory, Ids)));\n const Query = EDASessionQuery.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Store, Bus)),\n );\n const Runtime = EDARuntime.Live(config).pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Query)),\n );\n\n return tracer === undefined\n ? Runtime\n : Runtime.pipe(Layer.provideMerge(Layer.succeed(Tracer.Tracer, tracer)));\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-layer.js","names":[],"sources":["../../src/services/runtime-layer.ts"],"sourcesContent":["import type * as LanguageModel from \"effect/unstable/ai/LanguageModel\";\nimport * as Layer from \"effect/Layer\";\nimport * as Tracer from \"effect/Tracer\";\n\nimport type { SessionId } from \"../types/core\";\nimport { CompactionExecutor, CompactionPolicy, CompactionRunner } from \"./compaction\";\nimport { EventFactory } from \"./event-factory\";\nimport { IdGenerator } from \"./id-generator\";\nimport { InferenceRunner } from \"./inference-runner\";\nimport { EDAKeepAlive } from \"./keep-alive\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { EDAPromptProjector } from \"./prompt-projector\";\nimport { EDAReducerRegistry } from \"./reducer-registry\";\nimport { EDARuntime, type EDARuntimeConfig } from \"./runtime\";\nimport { SessionContext } from \"./session-context\";\nimport { SessionEventObserver } from \"./session-event-observer\";\nimport { EDASessionQuery } from \"./session-query\";\nimport { EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { SessionState, type SessionCommandAdmissionError } from \"./session-state\";\nimport { SinkCheckpointStore } from \"./sink-checkpoint-store\";\nimport { EDASinkRegistry, type EDASink } from \"./sink-registry\";\nimport { ToolExecutor } from \"./tool-executor\";\nimport { EDAToolRegistry, type EDAModelToolkit, type EDAToolRegistryShape } from \"./tool-registry\";\nimport { TurnRunner } from \"./turn-runner\";\n\n/**\n * Host-owned adapters and application policy needed to construct one EDA runtime.\n *\n * Core owns the service graph, while hosts supply only semantic persistence,\n * checkpoint, and lifecycle layers. Platform SDK types never cross this boundary.\n */\nexport interface EDARuntimeLayerOptions {\n readonly config: EDARuntimeConfig;\n readonly compactionExecutorLayer?: Layer.Layer<\n CompactionExecutor,\n never,\n LanguageModel.LanguageModel\n >;\n readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;\n readonly keepAliveLayer?: Layer.Layer<EDAKeepAlive>;\n readonly modelLayer: Layer.Layer<LanguageModel.LanguageModel>;\n readonly promptProjectorLayer?: Layer.Layer<EDAPromptProjector>;\n readonly reducerRegistryLayer?: Layer.Layer<EDAReducerRegistry>;\n readonly sessionId: SessionId;\n readonly sessionEventObserverLayer?: Layer.Layer<SessionEventObserver>;\n readonly sessionStoreLayer: Layer.Layer<EDASessionStore, EDASessionStoreError>;\n readonly sinkCheckpointStoreLayer: Layer.Layer<SinkCheckpointStore, EDASessionStoreError>;\n readonly sinks?: ReadonlyArray<EDASink>;\n readonly toolkit?: EDAModelToolkit;\n readonly toolRegistry?: EDAToolRegistryShape;\n readonly tracer?: Tracer.Tracer;\n}\n\n/** Compose the complete platform-neutral EDA service graph for one session. */\nexport const makeEDARuntimeLayer = ({\n config,\n compactionExecutorLayer,\n compactionPolicyLayer,\n keepAliveLayer,\n modelLayer,\n promptProjectorLayer,\n reducerRegistryLayer,\n sessionId,\n sessionEventObserverLayer,\n sessionStoreLayer,\n sinkCheckpointStoreLayer,\n sinks,\n toolkit,\n toolRegistry,\n tracer,\n}: EDARuntimeLayerOptions): Layer.Layer<EDARuntime, SessionCommandAdmissionError> => {\n const Store = sessionStoreLayer;\n const EventObserver = sessionEventObserverLayer ?? SessionEventObserver.Noop;\n const Bus = LiveEventBus.Live.pipe(Layer.provide(EventObserver));\n const KeepAlive = keepAliveLayer ?? EDAKeepAlive.Noop;\n const Ids = IdGenerator.Live;\n const Session = SessionContext.Live(sessionId);\n const Factory = EventFactory.Live.pipe(Layer.provideMerge(Layer.mergeAll(Session, Ids)));\n const PromptProjector = promptProjectorLayer ?? EDAPromptProjector.Default;\n const ReducerRegistry = reducerRegistryLayer ?? EDAReducerRegistry.Empty;\n const CompactionPolicyLayer = compactionPolicyLayer ?? CompactionPolicy.Disabled;\n const CompactionExecutorLayer = compactionExecutorLayer ?? CompactionExecutor.Disabled;\n const Compaction = CompactionRunner.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Factory,\n Ids,\n KeepAlive,\n modelLayer,\n CompactionPolicyLayer,\n CompactionExecutorLayer,\n ),\n ),\n );\n const SinkRegistry = EDASinkRegistry.Live(sinks ?? []).pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Session,\n Store,\n Bus,\n sinkCheckpointStoreLayer,\n Factory,\n Ids,\n ReducerRegistry,\n KeepAlive,\n ),\n ),\n );\n const State = SessionState.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Bus,\n Session,\n ReducerRegistry,\n SinkRegistry,\n KeepAlive,\n Compaction,\n PromptProjector,\n ),\n ),\n );\n const Registry =\n toolRegistry !== undefined\n ? EDAToolRegistry.FromShape(toolRegistry)\n : toolkit === undefined\n ? EDAToolRegistry.Empty\n : EDAToolRegistry.FromToolkit(toolkit);\n const InferenceRunnerLayer = InferenceRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, modelLayer, Registry, Ids)),\n );\n const ToolExec = ToolExecutor.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Registry, Ids, Session)),\n );\n const Turn = TurnRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(InferenceRunnerLayer, ToolExec, Factory, Ids)),\n );\n const StateWithRun = State.pipe(Layer.provideMerge(Layer.mergeAll(Turn, Factory, Ids)));\n const Query = EDASessionQuery.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Store, Bus)),\n );\n const Runtime = EDARuntime.Live(config).pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Query)),\n );\n\n return tracer === undefined\n ? Runtime\n : Runtime.pipe(Layer.provideMerge(Layer.succeed(Tracer.Tracer, tracer)));\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAsDA,MAAa,uBAAuB,EAClC,QACA,yBACA,uBACA,gBACA,YACA,sBACA,sBACA,WACA,2BACA,mBACA,0BACA,OACA,SACA,cACA,aACmF;CACnF,MAAM,QAAQ;CACd,MAAM,gBAAgB,6BAA6B,qBAAqB;CACxE,MAAM,MAAM,aAAa,KAAK,KAAK,MAAM,QAAQ,aAAa,CAAC;CAC/D,MAAM,YAAY,kBAAkB,aAAa;CACjD,MAAM,MAAM,YAAY;CACxB,MAAM,UAAU,eAAe,KAAK,SAAS;CAC7C,MAAM,UAAU,aAAa,KAAK,KAAK,MAAM,aAAa,MAAM,SAAS,SAAS,GAAG,CAAC,CAAC;CACvF,MAAM,kBAAkB,wBAAwB,mBAAmB;CACnE,MAAM,kBAAkB,wBAAwB,mBAAmB;CACnE,MAAM,wBAAwB,yBAAyB,iBAAiB;CACxE,MAAM,0BAA0B,2BAA2B,mBAAmB;CAC9E,MAAM,aAAa,iBAAiB,KAAK,KACvC,MAAM,aACJ,MAAM,SACJ,OACA,SACA,KACA,WACA,YACA,uBACA,uBACF,CACF,CACF;CACA,MAAM,eAAe,gBAAgB,KAAK,SAAS,CAAC,CAAC,EAAE,KACrD,MAAM,aACJ,MAAM,SACJ,SACA,OACA,KACA,0BACA,SACA,KACA,iBACA,SACF,CACF,CACF;CACA,MAAM,QAAQ,aAAa,KAAK,KAC9B,MAAM,aACJ,MAAM,SACJ,OACA,KACA,SACA,iBACA,cACA,WACA,YACA,eACF,CACF,CACF;CACA,MAAM,WACJ,iBAAiB,KAAA,IACb,gBAAgB,UAAU,YAAY,IACtC,YAAY,KAAA,IACV,gBAAgB,QAChB,gBAAgB,YAAY,OAAO;CAC3C,MAAM,uBAAuB,gBAAgB,KAAK,KAChD,MAAM,aAAa,MAAM,SAAS,SAAS,YAAY,UAAU,GAAG,CAAC,CACvE;CACA,MAAM,WAAW,aAAa,KAAK,KACjC,MAAM,aAAa,MAAM,SAAS,SAAS,UAAU,KAAK,OAAO,CAAC,CACpE;CACA,MAAM,OAAO,WAAW,KAAK,KAC3B,MAAM,aAAa,MAAM,SAAS,sBAAsB,UAAU,SAAS,GAAG,CAAC,CACjF;CACA,MAAM,eAAe,MAAM,KAAK,MAAM,aAAa,MAAM,SAAS,MAAM,SAAS,GAAG,CAAC,CAAC;CACtF,MAAM,QAAQ,gBAAgB,KAAK,KACjC,MAAM,aAAa,MAAM,SAAS,cAAc,OAAO,GAAG,CAAC,CAC7D;CACA,MAAM,UAAU,WAAW,KAAK,MAAM,EAAE,KACtC,MAAM,aAAa,MAAM,SAAS,cAAc,KAAK,CAAC,CACxD;CAEA,OAAO,WAAW,KAAA,IACd,UACA,QAAQ,KAAK,MAAM,aAAa,MAAM,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC;AAC3E"}
|
|
@@ -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-
|
|
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-DXvMCq-J.js";
|
|
2
2
|
export { CommittedCommandTerminalEvent, EDACommandTerminalEvent, EDARuntime, EDARuntimeConfig, EDARuntimeError, EDARuntimeShape, EDARuntimeSubmit };
|
package/dist/services/runtime.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SequenceNumber, durablePosition } from "../types/core.js";
|
|
2
2
|
import { _n as commandCancelledEventType, _r as SystemPromptText, fr as ModelSelectionPayload, pr as NonNegativeInt, vn as commandCompletedEventType, yn as commandFailedEventType } from "../durable-DsV9PxZC.js";
|
|
3
|
-
import {
|
|
4
|
-
import { u as SessionState } from "../session-state-D7dqko7r.js";
|
|
3
|
+
import { u as SessionState } from "../session-state-C4m0j6CJ.js";
|
|
5
4
|
import { CommittedDurableEvent } from "./session-store.js";
|
|
6
5
|
import { annotateEdaSpan, committedBatchAttributes } from "./tracing.js";
|
|
7
6
|
import { EDASessionQuery } from "./session-query.js";
|
|
@@ -25,7 +24,6 @@ var EDARuntime = class EDARuntime extends Context.Service()("@effect-durable-age
|
|
|
25
24
|
const makeLiveRuntime = (config) => Effect.gen(function* () {
|
|
26
25
|
const sessionState = yield* SessionState;
|
|
27
26
|
const query = yield* EDASessionQuery;
|
|
28
|
-
const liveBus = yield* LiveEventBus;
|
|
29
27
|
const runInput = {
|
|
30
28
|
modelSelection: config.modelSelection,
|
|
31
29
|
...config.maxToolCallsPerRun === void 0 ? {} : { maxToolCallsPerRun: config.maxToolCallsPerRun },
|
|
@@ -66,8 +64,7 @@ const makeLiveRuntime = (config) => Effect.gen(function* () {
|
|
|
66
64
|
snapshot: () => query.snapshot(),
|
|
67
65
|
messages: () => query.messages(),
|
|
68
66
|
eventsAfter: (afterSeq) => query.eventsAfter(afterSeq),
|
|
69
|
-
|
|
70
|
-
registerDeliveryListener: (listener) => liveBus.registerDeliveryListener(listener)
|
|
67
|
+
readEventPage: (afterSeq, limit) => query.readEventPage(afterSeq, limit)
|
|
71
68
|
};
|
|
72
69
|
});
|
|
73
70
|
const isCommandTerminalFor = (commandId) => (event) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../../src/services/runtime.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { EDACommand } from \"../types/commands\";\nimport { CommandId, SequenceNumber, durablePosition } from \"../types/core\";\nimport {\n ModelSelectionPayload,\n NonNegativeInt,\n SystemPromptText,\n commandCancelledEventType,\n commandCompletedEventType,\n commandFailedEventType,\n} from \"../types/events\";\nimport type {\n CommandCancelledEvent,\n CommandCompletedEvent,\n CommandFailedEvent,\n PositionedEvent,\n} from \"../types/events\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport type { LiveDeliveryListener, LiveEventBusShape } from \"./live-event-bus\";\nimport { SessionState } from \"./session-state\";\nimport type { EDASubmittable, SessionCommandAdmissionError } from \"./session-state\";\nimport { CommittedDurableEvent } from \"./session-store\";\nimport { EDASessionQuery } from \"./session-query\";\nimport { annotateEdaSpan, committedBatchAttributes } from \"./tracing\";\nimport type { EDASessionQueryShape } from \"./session-query\";\n\n/** Configuration for one scoped session runtime instance. */\nexport const EDARuntimeConfig = Schema.Struct({\n modelSelection: ModelSelectionPayload,\n /** Maximum framework-owned tool calls one model run may execute before failing safely. */\n maxToolCallsPerRun: Schema.optionalKey(NonNegativeInt),\n systemPrompt: Schema.optionalKey(SystemPromptText),\n});\nexport type EDARuntimeConfig = typeof EDARuntimeConfig.Type;\n\n/** Public runtime error surface for command admission helpers. */\nexport type EDARuntimeError = SessionCommandAdmissionError;\n\n/** Command terminal events observed by blocking runtime helpers. */\nexport type EDACommandTerminalEvent =\n | CommandCompletedEvent\n | CommandFailedEvent\n | CommandCancelledEvent;\n\n/** Committed durable event narrowed to a command terminal boundary. */\nexport type CommittedCommandTerminalEvent = CommittedDurableEvent & {\n readonly event: EDACommandTerminalEvent;\n};\n\n/** Overloaded public submit API for single commands or ordered durable batches. */\nexport interface EDARuntimeSubmit {\n /** Submit one command and return its committed CommandAdmitted event. */\n (command: EDACommand): Effect.Effect<CommittedDurableEvent, EDARuntimeError>;\n /** Submit one ordered durable batch of commands and/or app events. */\n (\n input: ReadonlyArray<EDASubmittable>,\n ): Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDARuntimeError>;\n}\n\n/** Public facade exposed to hosts and route handlers for one live session runtime. */\nexport interface EDARuntimeShape {\n /** Submit commands and/or app durable events durably and wake the dispatch process if needed. */\n readonly submit: EDARuntimeSubmit;\n /** Block until the command reaches CommandCompleted, CommandFailed, or CommandCancelled. */\n readonly blockOnCommand: (\n commandId: CommandId,\n afterSeq?: SequenceNumber,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Admit one command and block until that command reaches a terminal command boundary. */\n readonly submitAndBlock: (\n command: EDACommand,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Read the authoritative live session snapshot. */\n readonly snapshot: EDASessionQueryShape[\"snapshot\"];\n /** Read durable user/assistant messages in committed order. */\n readonly messages: EDASessionQueryShape[\"messages\"];\n /** Backfill durable events after a committed sequence, then follow live events. */\n readonly eventsAfter: EDASessionQueryShape[\"eventsAfter\"];\n /** Read one bounded committed durable slice plus the committed head. */\n readonly eventsSlice: EDASessionQueryShape[\"eventsSlice\"];\n /** Register one push-delivery listener invoked inline on every published event. */\n readonly registerDeliveryListener: LiveEventBusShape[\"registerDeliveryListener\"];\n}\n\n/** Top-level public facade for one effect-durable-agent session runtime. */\nexport class EDARuntime extends Context.Service<EDARuntime, EDARuntimeShape>()(\n \"@effect-durable-agent/EDARuntime\",\n) {\n static readonly Live = (config: EDARuntimeConfig) =>\n Layer.effect(EDARuntime, makeLiveRuntime(config));\n}\n\nconst makeLiveRuntime = (config: EDARuntimeConfig) =>\n Effect.gen(function* () {\n const sessionState = yield* SessionState;\n const query = yield* EDASessionQuery;\n const liveBus = yield* LiveEventBus;\n\n const runInput = {\n modelSelection: config.modelSelection,\n ...(config.maxToolCallsPerRun === undefined\n ? {}\n : { maxToolCallsPerRun: config.maxToolCallsPerRun }),\n ...(config.systemPrompt === undefined ? {} : { systemPrompt: config.systemPrompt }),\n };\n yield* sessionState.start(runInput);\n\n const blockOnCommand = Effect.fn(function* (\n commandId: CommandId,\n afterSeq: SequenceNumber = SequenceNumber.make(0),\n ) {\n yield* annotateEdaSpan({ \"eda.command.id\": commandId, \"eda.seq.after\": afterSeq });\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const events = yield* query.eventsAfter(afterSeq);\n const terminal = yield* events.pipe(\n Stream.filter(isCommandTerminalFor(commandId)),\n Stream.take(1),\n Stream.map(toCommittedCommandTerminal),\n Stream.runCollect,\n Effect.map((events) => events[0]),\n );\n return terminal === undefined\n ? yield* Effect.die(new Error(\"Expected command terminal event\"))\n : terminal;\n }),\n );\n });\n\n const submit = Effect.fn(function* (input: EDACommand | ReadonlyArray<EDASubmittable>) {\n const items = Array.isArray(input) ? input : [input as EDACommand];\n yield* annotateEdaSpan({\n \"eda.command.submittable_count\": items.length,\n \"eda.command.count\": items.filter((item) => \"_tag\" in item).length,\n });\n const committed = Array.isArray(input)\n ? yield* sessionState.submitBatch(input)\n : [yield* sessionState.admitCommand(input as EDACommand)];\n yield* annotateEdaSpan(committedBatchAttributes(committed));\n return Array.isArray(input) ? committed : committed[0]!;\n }) as EDARuntimeSubmit;\n\n return {\n submit,\n blockOnCommand,\n submitAndBlock: Effect.fn(function* (command: EDACommand) {\n yield* annotateEdaSpan({\n \"eda.command.kind\": command._tag,\n \"eda.command.id\": command.commandId,\n \"eda.command.disposition\": \"disposition\" in command ? command.disposition : undefined,\n });\n const admitted = yield* sessionState.admitCommand(command);\n return yield* blockOnCommand(commandIdFromCommandAdmitted(admitted), admitted.position.seq);\n }),\n snapshot: () => query.snapshot(),\n messages: () => query.messages(),\n eventsAfter: (afterSeq: SequenceNumber) => query.eventsAfter(afterSeq),\n eventsSlice: (afterSeq: SequenceNumber, limit: number) => query.eventsSlice(afterSeq, limit),\n registerDeliveryListener: (listener: LiveDeliveryListener) =>\n liveBus.registerDeliveryListener(listener),\n };\n });\n\nconst isCommandTerminalFor =\n (commandId: CommandId) =>\n (event: PositionedEvent): boolean => {\n if (\n event.event.type !== commandCompletedEventType &&\n event.event.type !== commandFailedEventType &&\n event.event.type !== commandCancelledEventType\n ) {\n return false;\n }\n return (event.event.payload as { readonly commandId: CommandId }).commandId === commandId;\n };\n\nconst toCommittedCommandTerminal = (event: PositionedEvent): CommittedCommandTerminalEvent =>\n CommittedDurableEvent.make({\n position: durablePosition(event.position.seq),\n event: event.event as EDACommandTerminalEvent,\n }) as CommittedCommandTerminalEvent;\n\nconst commandIdFromCommandAdmitted = (committed: CommittedDurableEvent): CommandId => {\n const commandId = (committed.event.payload as { readonly command?: EDACommand }).command\n ?.commandId;\n if (commandId === undefined) {\n throw new Error(\"CommandAdmitted event is missing a framework commandId\");\n }\n return commandId;\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"runtime.js","names":[],"sources":["../../src/services/runtime.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { EDACommand } from \"../types/commands\";\nimport { CommandId, SequenceNumber, durablePosition } from \"../types/core\";\nimport {\n ModelSelectionPayload,\n NonNegativeInt,\n SystemPromptText,\n commandCancelledEventType,\n commandCompletedEventType,\n commandFailedEventType,\n} from \"../types/events\";\nimport type {\n CommandCancelledEvent,\n CommandCompletedEvent,\n CommandFailedEvent,\n PositionedEvent,\n} from \"../types/events\";\nimport { SessionState } from \"./session-state\";\nimport type { EDASubmittable, SessionCommandAdmissionError } from \"./session-state\";\nimport { CommittedDurableEvent } from \"./session-store\";\nimport { EDASessionQuery } from \"./session-query\";\nimport { annotateEdaSpan, committedBatchAttributes } from \"./tracing\";\nimport type { EDASessionQueryShape } from \"./session-query\";\n\n/** Configuration for one scoped session runtime instance. */\nexport const EDARuntimeConfig = Schema.Struct({\n modelSelection: ModelSelectionPayload,\n /** Maximum framework-owned tool calls one model run may execute before failing safely. */\n maxToolCallsPerRun: Schema.optionalKey(NonNegativeInt),\n systemPrompt: Schema.optionalKey(SystemPromptText),\n});\nexport type EDARuntimeConfig = typeof EDARuntimeConfig.Type;\n\n/** Public runtime error surface for command admission helpers. */\nexport type EDARuntimeError = SessionCommandAdmissionError;\n\n/** Command terminal events observed by blocking runtime helpers. */\nexport type EDACommandTerminalEvent =\n | CommandCompletedEvent\n | CommandFailedEvent\n | CommandCancelledEvent;\n\n/** Committed durable event narrowed to a command terminal boundary. */\nexport type CommittedCommandTerminalEvent = CommittedDurableEvent & {\n readonly event: EDACommandTerminalEvent;\n};\n\n/** Overloaded public submit API for single commands or ordered durable batches. */\nexport interface EDARuntimeSubmit {\n /** Submit one command and return its committed CommandAdmitted event. */\n (command: EDACommand): Effect.Effect<CommittedDurableEvent, EDARuntimeError>;\n /** Submit one ordered durable batch of commands and/or app events. */\n (\n input: ReadonlyArray<EDASubmittable>,\n ): Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDARuntimeError>;\n}\n\n/** Public facade exposed to hosts and route handlers for one live session runtime. */\nexport interface EDARuntimeShape {\n /** Submit commands and/or app durable events durably and wake the dispatch process if needed. */\n readonly submit: EDARuntimeSubmit;\n /** Block until the command reaches CommandCompleted, CommandFailed, or CommandCancelled. */\n readonly blockOnCommand: (\n commandId: CommandId,\n afterSeq?: SequenceNumber,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Admit one command and block until that command reaches a terminal command boundary. */\n readonly submitAndBlock: (\n command: EDACommand,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Read the authoritative live session snapshot. */\n readonly snapshot: EDASessionQueryShape[\"snapshot\"];\n /** Read durable user/assistant messages in committed order. */\n readonly messages: EDASessionQueryShape[\"messages\"];\n /** Backfill durable events after a committed sequence, then follow live events. */\n readonly eventsAfter: EDASessionQueryShape[\"eventsAfter\"];\n /** Read one bounded page of committed durable events plus the committed head. */\n readonly readEventPage: EDASessionQueryShape[\"readEventPage\"];\n}\n\n/** Top-level public facade for one effect-durable-agent session runtime. */\nexport class EDARuntime extends Context.Service<EDARuntime, EDARuntimeShape>()(\n \"@effect-durable-agent/EDARuntime\",\n) {\n static readonly Live = (config: EDARuntimeConfig) =>\n Layer.effect(EDARuntime, makeLiveRuntime(config));\n}\n\nconst makeLiveRuntime = (config: EDARuntimeConfig) =>\n Effect.gen(function* () {\n const sessionState = yield* SessionState;\n const query = yield* EDASessionQuery;\n\n const runInput = {\n modelSelection: config.modelSelection,\n ...(config.maxToolCallsPerRun === undefined\n ? {}\n : { maxToolCallsPerRun: config.maxToolCallsPerRun }),\n ...(config.systemPrompt === undefined ? {} : { systemPrompt: config.systemPrompt }),\n };\n yield* sessionState.start(runInput);\n\n const blockOnCommand = Effect.fn(function* (\n commandId: CommandId,\n afterSeq: SequenceNumber = SequenceNumber.make(0),\n ) {\n yield* annotateEdaSpan({ \"eda.command.id\": commandId, \"eda.seq.after\": afterSeq });\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const events = yield* query.eventsAfter(afterSeq);\n const terminal = yield* events.pipe(\n Stream.filter(isCommandTerminalFor(commandId)),\n Stream.take(1),\n Stream.map(toCommittedCommandTerminal),\n Stream.runCollect,\n Effect.map((events) => events[0]),\n );\n return terminal === undefined\n ? yield* Effect.die(new Error(\"Expected command terminal event\"))\n : terminal;\n }),\n );\n });\n\n const submit = Effect.fn(function* (input: EDACommand | ReadonlyArray<EDASubmittable>) {\n const items = Array.isArray(input) ? input : [input as EDACommand];\n yield* annotateEdaSpan({\n \"eda.command.submittable_count\": items.length,\n \"eda.command.count\": items.filter((item) => \"_tag\" in item).length,\n });\n const committed = Array.isArray(input)\n ? yield* sessionState.submitBatch(input)\n : [yield* sessionState.admitCommand(input as EDACommand)];\n yield* annotateEdaSpan(committedBatchAttributes(committed));\n return Array.isArray(input) ? committed : committed[0]!;\n }) as EDARuntimeSubmit;\n\n return {\n submit,\n blockOnCommand,\n submitAndBlock: Effect.fn(function* (command: EDACommand) {\n yield* annotateEdaSpan({\n \"eda.command.kind\": command._tag,\n \"eda.command.id\": command.commandId,\n \"eda.command.disposition\": \"disposition\" in command ? command.disposition : undefined,\n });\n const admitted = yield* sessionState.admitCommand(command);\n return yield* blockOnCommand(commandIdFromCommandAdmitted(admitted), admitted.position.seq);\n }),\n snapshot: () => query.snapshot(),\n messages: () => query.messages(),\n eventsAfter: (afterSeq: SequenceNumber) => query.eventsAfter(afterSeq),\n readEventPage: (afterSeq: SequenceNumber, limit: number) =>\n query.readEventPage(afterSeq, limit),\n };\n });\n\nconst isCommandTerminalFor =\n (commandId: CommandId) =>\n (event: PositionedEvent): boolean => {\n if (\n event.event.type !== commandCompletedEventType &&\n event.event.type !== commandFailedEventType &&\n event.event.type !== commandCancelledEventType\n ) {\n return false;\n }\n return (event.event.payload as { readonly commandId: CommandId }).commandId === commandId;\n };\n\nconst toCommittedCommandTerminal = (event: PositionedEvent): CommittedCommandTerminalEvent =>\n CommittedDurableEvent.make({\n position: durablePosition(event.position.seq),\n event: event.event as EDACommandTerminalEvent,\n }) as CommittedCommandTerminalEvent;\n\nconst commandIdFromCommandAdmitted = (committed: CommittedDurableEvent): CommandId => {\n const commandId = (committed.event.payload as { readonly command?: EDACommand }).command\n ?.commandId;\n if (commandId === undefined) {\n throw new Error(\"CommandAdmitted event is missing a framework commandId\");\n }\n return commandId;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
//#region src/services/session-event-observer.ts
|
|
5
|
+
/** Host-provided observer for append-driven integrations such as hibernatable WebSockets. */
|
|
6
|
+
var SessionEventObserver = class SessionEventObserver extends Context.Service()("@effect-durable-agent/SessionEventObserver") {
|
|
7
|
+
static Noop = Layer.succeed(SessionEventObserver, { onEvent: () => Effect.void });
|
|
8
|
+
static FromHandler = (onEvent) => Layer.succeed(SessionEventObserver, { onEvent });
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { SessionEventObserver };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=session-event-observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-event-observer.js","names":[],"sources":["../../src/services/session-event-observer.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport type { PositionedEvent } from \"../types/events\";\n\n/**\n * Outbound integration point notified synchronously after EDA publishes an event.\n *\n * Hosts provide this service while composing the runtime. Implementations own\n * their failures and never expose host errors to the session runtime.\n */\nexport interface SessionEventObserverShape {\n readonly onEvent: (event: PositionedEvent) => Effect.Effect<void>;\n}\n\n/** Host-provided observer for append-driven integrations such as hibernatable WebSockets. */\nexport class SessionEventObserver extends Context.Service<\n SessionEventObserver,\n SessionEventObserverShape\n>()(\"@effect-durable-agent/SessionEventObserver\") {\n static readonly Noop = Layer.succeed(SessionEventObserver, {\n onEvent: () => Effect.void,\n });\n\n static readonly FromHandler = (\n onEvent: SessionEventObserverShape[\"onEvent\"],\n ): Layer.Layer<SessionEventObserver> => Layer.succeed(SessionEventObserver, { onEvent });\n}\n"],"mappings":";;;;;AAiBA,IAAa,uBAAb,MAAa,6BAA6B,QAAQ,QAGhD,EAAE,4CAA4C,EAAE;CAChD,OAAgB,OAAO,MAAM,QAAQ,sBAAsB,EACzD,eAAe,OAAO,KACxB,CAAC;CAED,OAAgB,eACd,YACsC,MAAM,QAAQ,sBAAsB,EAAE,QAAQ,CAAC;AACzF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as EDASessionSnapshot, n as EDASessionQuery, r as EDASessionQueryShape, t as
|
|
2
|
-
export {
|
|
1
|
+
import { i as EDASessionSnapshot, n as EDASessionQuery, r as EDASessionQueryShape, t as EDASessionEventPage } from "../session-query-lUZQpMvM.js";
|
|
2
|
+
export { EDASessionEventPage, EDASessionQuery, EDASessionQueryShape, EDASessionSnapshot };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mr as PositionedEvent } from "../durable-DsV9PxZC.js";
|
|
2
|
-
import {
|
|
3
|
-
import { u as SessionState } from "../session-state-D7dqko7r.js";
|
|
2
|
+
import { u as SessionState } from "../session-state-C4m0j6CJ.js";
|
|
4
3
|
import { EDASessionStore } from "./session-store.js";
|
|
5
4
|
import { durableMessageTranscript } from "../domain/message-transcript.js";
|
|
6
5
|
import { annotateEdaSpan } from "./tracing.js";
|
|
6
|
+
import { r as LiveEventBus } from "../sink-registry-DH6uiEgP.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";
|
|
@@ -52,7 +52,7 @@ var EDASessionQuery = class EDASessionQuery extends Context.Service()("@effect-d
|
|
|
52
52
|
const follow = Stream.fromEffectRepeat(PubSub.take(live)).pipe(Stream.filter((event) => shouldEmitLiveEvent(event, replayHead)));
|
|
53
53
|
return Stream.fromIterable(reconnectPrefix).pipe(Stream.concat(follow));
|
|
54
54
|
}).pipe(Effect.withSpan("agent.events.follow", { attributes: { "eda.seq.after": afterSeq } })),
|
|
55
|
-
|
|
55
|
+
readEventPage: (afterSeq, limit) => Effect.gen(function* () {
|
|
56
56
|
const head = (yield* sessionState.snapshot()).lastSeq;
|
|
57
57
|
if (limit <= 0 || afterSeq >= head) return {
|
|
58
58
|
events: [],
|
|
@@ -65,9 +65,9 @@ var EDASessionQuery = class EDASessionQuery extends Context.Service()("@effect-d
|
|
|
65
65
|
})), Stream.runCollect, Effect.map((events) => Array.from(events))),
|
|
66
66
|
head
|
|
67
67
|
};
|
|
68
|
-
}).pipe(Effect.withSpan("agent.events.
|
|
68
|
+
}).pipe(Effect.withSpan("agent.events.page", { attributes: {
|
|
69
69
|
"eda.seq.after": afterSeq,
|
|
70
|
-
"eda.
|
|
70
|
+
"eda.page.limit": limit
|
|
71
71
|
} }))
|
|
72
72
|
};
|
|
73
73
|
}));
|