effect-durable-agent 0.1.0-alpha.1 → 0.1.0-alpha.10
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/README.md +140 -136
- package/dist/{command-queues-CQ9cwRP7.d.ts → command-queues-CQi4Xc7u.d.ts} +109 -21
- package/dist/{commands-Ce1ec6kH.d.ts → commands-p8venTWs.d.ts} +10 -2
- package/dist/compaction-0k8zCJgB.js +473 -0
- package/dist/compaction-0k8zCJgB.js.map +1 -0
- package/dist/{compaction-YayFKo_1.d.ts → compaction-BhLSSXJ-.d.ts} +28 -7
- package/dist/context-projection-mCuvcO2W.d.ts +140 -0
- package/dist/{core-Hv3cFydL.d.ts → core-C-6xHzRx.d.ts} +6 -3
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/command-queues.js +1 -1
- package/dist/domain/command-queues.js.map +1 -1
- package/dist/domain/context-projection.d.ts +2 -0
- package/dist/domain/context-projection.js +32 -0
- package/dist/domain/context-projection.js.map +1 -0
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/model-usage.d.ts +2 -0
- package/dist/domain/model-usage.js +59 -0
- package/dist/domain/model-usage.js.map +1 -0
- package/dist/domain/reduced-state-schema.d.ts +14 -18
- package/dist/domain/reduced-state-schema.js +7 -11
- package/dist/domain/reduced-state-schema.js.map +1 -1
- package/dist/domain/reduced-state.d.ts +3 -2
- package/dist/domain/reduced-state.js +3 -2
- package/dist/domain/run-scheduling.d.ts +2 -0
- package/dist/domain/run-scheduling.js +127 -0
- package/dist/domain/run-scheduling.js.map +1 -0
- package/dist/{durable-C3Rz7kg3.js → durable-BPHVFVvV.js} +74 -83
- package/dist/durable-BPHVFVvV.js.map +1 -0
- package/dist/{durable-DlScwmCy.d.ts → durable-DeLCAvbw.d.ts} +1256 -104
- package/dist/envelope-DkZyMIgp.d.ts +191 -0
- package/dist/envelope-DxQzo5rN.js +82 -0
- package/dist/envelope-DxQzo5rN.js.map +1 -0
- package/dist/{keep-alive-DYDsH6qN.d.ts → event-factory-KaeDSfeP.d.ts} +11 -31
- package/dist/{keep-alive-p8dIcSVy.js → event-factory-QuC_UvyP.js} +8 -10
- package/dist/event-factory-QuC_UvyP.js.map +1 -0
- package/dist/{events-Bb9-Cu-7.d.ts → events-LZFNoESe.d.ts} +2 -188
- package/dist/{id-generator-C2Q15uZM.d.ts → id-generator--x6itQZ2.d.ts} +3 -2
- package/dist/index.d.ts +7 -6
- package/dist/index.js +5 -4
- package/dist/keep-alive-Chl5SJxy.d.ts +29 -0
- package/dist/{message-transcript-BCHdHAe2.d.ts → message-transcript-6PEzaEGn.d.ts} +4 -4
- package/dist/model-resolver-BPPJAsuh.d.ts +18 -0
- package/dist/model-usage-CdBEkTwU.d.ts +55 -0
- package/dist/{prompt-projector-9_02lk5-.d.ts → prompt-projector-CNhqUsEr.d.ts} +15 -16
- package/dist/{reduced-state-C4nVVzz9.js → reduced-state-Bz68V2H8.js} +65 -32
- package/dist/reduced-state-Bz68V2H8.js.map +1 -0
- package/dist/{reducer-registry-C0svUa63.d.ts → reducer-registry-CCSzc4h8.d.ts} +16 -6
- package/dist/run-scheduler-DcS_okUH.d.ts +43 -0
- package/dist/run-scheduling-wakeup-CeHrvXie.d.ts +25 -0
- package/dist/{runtime-C56FQxiL.d.ts → runtime-WL_gKqxn.d.ts} +16 -7
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/compaction.js +1 -425
- package/dist/services/id-generator.d.ts +1 -1
- package/dist/services/id-generator.js +2 -1
- package/dist/services/id-generator.js.map +1 -1
- package/dist/services/keep-alive.d.ts +2 -0
- package/dist/services/keep-alive.js +13 -0
- package/dist/services/keep-alive.js.map +1 -0
- package/dist/services/model-resolver.d.ts +2 -0
- package/dist/services/model-resolver.js +17 -0
- package/dist/services/model-resolver.js.map +1 -0
- package/dist/services/prompt-projector.d.ts +2 -2
- package/dist/services/prompt-projector.js +20 -10
- package/dist/services/prompt-projector.js.map +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/run-scheduler.d.ts +3 -0
- package/dist/services/run-scheduler.js +25 -0
- package/dist/services/run-scheduler.js.map +1 -0
- package/dist/services/run-scheduling-wakeup.d.ts +2 -0
- package/dist/services/run-scheduling-wakeup.js +13 -0
- package/dist/services/run-scheduling-wakeup.js.map +1 -0
- package/dist/services/runtime-layer.d.ts +67 -0
- package/dist/services/runtime-layer.js +47 -0
- package/dist/services/runtime-layer.js.map +1 -0
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +21 -14
- 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 +140 -1
- package/dist/services/session-query.js.map +1 -0
- package/dist/services/session-state.d.ts +2 -0
- package/dist/services/session-state.js +2 -0
- package/dist/services/session-store.d.ts +2 -2
- package/dist/services/session-store.js +182 -2
- package/dist/services/session-store.js.map +1 -0
- package/dist/services/sink-checkpoint-store.d.ts +2 -0
- package/dist/services/sink-checkpoint-store.js +49 -0
- package/dist/services/sink-checkpoint-store.js.map +1 -0
- 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 +3 -0
- package/dist/services/span-names.js.map +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/services/tracing.d.ts +1 -1
- package/dist/services/tracing.js +23 -2
- package/dist/services/tracing.js.map +1 -1
- package/dist/session-event-observer-DaFMKKNc.d.ts +24 -0
- package/dist/session-query-DfW_4KC0.d.ts +47 -0
- package/dist/{session-query-DOc1KanA.js → session-state-BIZ2SYaP.js} +350 -183
- package/dist/session-state-BIZ2SYaP.js.map +1 -0
- package/dist/{session-query-DlRo5Ufc.d.ts → session-state-BeR2rZRR.d.ts} +144 -46
- package/dist/{session-store-D2Ore1QC.d.ts → session-store-J_Un45kW.d.ts} +7 -96
- package/dist/sink-checkpoint-store-C9hUxfH0.d.ts +40 -0
- package/dist/{sink-registry-CFC6xjsN.js → sink-registry-Bbqhtdnx.js} +27 -67
- package/dist/sink-registry-Bbqhtdnx.js.map +1 -0
- package/dist/{sink-registry-CIU0LD3m.d.ts → sink-registry-DuDkNXjZ.d.ts} +24 -49
- package/dist/testkit/layers.d.ts +24 -14
- package/dist/testkit/layers.js +18 -11
- package/dist/testkit/layers.js.map +1 -1
- package/dist/{tool-registry-CcnkAAQK.d.ts → tool-registry-BDmJe_Wr.d.ts} +4 -4
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/commands.js +7 -2
- package/dist/types/commands.js.map +1 -1
- package/dist/types/core.d.ts +2 -2
- package/dist/types/core.js +4 -2
- package/dist/types/core.js.map +1 -1
- package/dist/types/events/durable.d.ts +2 -2
- package/dist/types/events/durable.js +2 -2
- package/dist/types/events.d.ts +4 -3
- package/dist/types/events.js +3 -2
- package/dist/types/events.js.map +1 -1
- package/dist/websocket.d.ts +2776 -0
- package/dist/websocket.js +498 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +68 -43
- package/testing/offline-trace/README.md +2 -1
- package/CHANGELOG.md +0 -10
- package/CONTRIBUTING.md +0 -26
- package/SECURITY.md +0 -8
- package/dist/durable-C3Rz7kg3.js.map +0 -1
- package/dist/durable-object-runtime-B7jwBY2R.js +0 -1494
- package/dist/durable-object-runtime-B7jwBY2R.js.map +0 -1
- package/dist/durable-object-runtime-pWv0ohlz.d.ts +0 -257
- package/dist/durable-object-storage-Czy7IPrh.d.ts +0 -41
- package/dist/host/durable-object-runtime.d.ts +0 -2
- package/dist/host/durable-object-runtime.js +0 -2
- package/dist/host/durable-object-storage.d.ts +0 -2
- package/dist/host/durable-object-storage.js +0 -0
- package/dist/host/durable-object.d.ts +0 -83
- package/dist/host/durable-object.js +0 -191
- package/dist/host/durable-object.js.map +0 -1
- package/dist/host/websocket-wire.d.ts +0 -2
- package/dist/host/websocket-wire.js +0 -88
- package/dist/host/websocket-wire.js.map +0 -1
- package/dist/keep-alive-p8dIcSVy.js.map +0 -1
- package/dist/reduced-state-C4nVVzz9.js.map +0 -1
- package/dist/services/compaction.js.map +0 -1
- package/dist/session-query-DOc1KanA.js.map +0 -1
- package/dist/session-store-pYxQW9qh.js +0 -214
- package/dist/session-store-pYxQW9qh.js.map +0 -1
- package/dist/sink-registry-CFC6xjsN.js.map +0 -1
- package/dist/websocket-wire-DvOu_6BJ.d.ts +0 -16773
- package/docs/assets/architecture.svg +0 -106
- package/docs/assets/event-sequence.svg +0 -143
- package/docs/assets/gcp-trace.png +0 -0
- package/docs/message-steering.md +0 -831
- package/docs/releasing.md +0 -57
- package/docs/spec.md +0 -774
- package/docs/subagents.md +0 -725
- package/docs/testing.md +0 -64
- package/docs/ui-projection.md +0 -742
- package/docs/websocket-protocol.md +0 -613
- package/examples/001-no-tools/README.md +0 -65
- package/examples/001-no-tools/worker.ts +0 -79
- package/examples/002-slack-bridge/README.md +0 -134
- package/examples/002-slack-bridge/events.ts +0 -115
- package/examples/002-slack-bridge/reducer.ts +0 -216
- package/examples/002-slack-bridge/scenario.test.ts +0 -223
- package/examples/002-slack-bridge/sinks.ts +0 -109
- package/examples/002-slack-bridge/worker.ts +0 -140
- package/examples/003-sandbox-lifecycle/README.md +0 -78
- package/examples/003-sandbox-lifecycle/events.ts +0 -203
- package/examples/003-sandbox-lifecycle/reducer.ts +0 -305
- package/examples/003-sandbox-lifecycle/scenario.test.ts +0 -202
- package/examples/_shared/event-id.ts +0 -12
- package/examples/_shared/http.ts +0 -27
- package/examples/_shared/openai.ts +0 -33
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as EDASessionStore, o as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
1
|
+
import { Q as RunGrantResult, S as ReducedState } from "./command-queues-CQi4Xc7u.js";
|
|
2
|
+
import { d as PositionedEvent, l as ModelSelectionPayload, n as EphemeralEventEnvelope, t as DurableEventEnvelope, u as NonNegativeInt } from "./envelope-DkZyMIgp.js";
|
|
3
|
+
import { i as GrantRunCommand, r as EDACommand } from "./commands-p8venTWs.js";
|
|
4
|
+
import { zt as ToolCallCreatedEvent } from "./durable-DeLCAvbw.js";
|
|
5
|
+
import { a as EDASessionStore, o as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-J_Un45kW.js";
|
|
6
|
+
import { t as ModelResolver } from "./model-resolver-BPPJAsuh.js";
|
|
7
|
+
import { t as IdGenerator } from "./id-generator--x6itQZ2.js";
|
|
8
|
+
import { r as SessionContext, t as EventFactory } from "./event-factory-KaeDSfeP.js";
|
|
9
|
+
import { t as EDAKeepAlive } from "./keep-alive-Chl5SJxy.js";
|
|
10
|
+
import { d as CompactionRunner } from "./compaction-BhLSSXJ-.js";
|
|
11
|
+
import { s as EDASinkRegistry, u as LiveEventBus } from "./sink-registry-DuDkNXjZ.js";
|
|
12
|
+
import { a as EDAReducerStateSnapshot, r as EDAReducerRegistry } from "./reducer-registry-CCSzc4h8.js";
|
|
13
|
+
import { r as EDAPromptProjector } from "./prompt-projector-CNhqUsEr.js";
|
|
14
|
+
import { t as RunScheduler } from "./run-scheduler-DcS_okUH.js";
|
|
15
|
+
import { t as RunSchedulingWakeup } from "./run-scheduling-wakeup-CeHrvXie.js";
|
|
16
|
+
import { r as EDAToolRegistry } from "./tool-registry-BDmJe_Wr.js";
|
|
15
17
|
import * as Context from "effect/Context";
|
|
16
18
|
import * as Effect from "effect/Effect";
|
|
17
19
|
import * as Layer from "effect/Layer";
|
|
18
20
|
import * as Schema from "effect/Schema";
|
|
19
|
-
import * as Stream from "effect/Stream";
|
|
20
21
|
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
21
22
|
import * as Cause from "effect/Cause";
|
|
22
|
-
import * as Scope from "effect/Scope";
|
|
23
|
-
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
24
23
|
import * as Response from "effect/unstable/ai/Response";
|
|
25
24
|
|
|
26
25
|
//#region src/services/session-event-sink.d.ts
|
|
@@ -146,7 +145,7 @@ interface ToolExecutorShape {
|
|
|
146
145
|
declare const ToolExecutor_base: Context.ServiceClass<ToolExecutor, "@effect-durable-agent/ToolExecutor", ToolExecutorShape>;
|
|
147
146
|
/** Executes sealed framework-owned tool calls and commits tool lifecycle boundaries. */
|
|
148
147
|
declare class ToolExecutor extends ToolExecutor_base {
|
|
149
|
-
static readonly Live: Layer.Layer<ToolExecutor, never,
|
|
148
|
+
static readonly Live: Layer.Layer<ToolExecutor, never, EDAToolRegistry | SessionContext | EventFactory | IdGenerator>;
|
|
150
149
|
}
|
|
151
150
|
//#endregion
|
|
152
151
|
//#region src/services/inference-runner.d.ts
|
|
@@ -294,7 +293,7 @@ interface InferenceRunnerShape {
|
|
|
294
293
|
declare const InferenceRunner_base: Context.ServiceClass<InferenceRunner, "@effect-durable-agent/InferenceRunner", InferenceRunnerShape>;
|
|
295
294
|
/** Owns provider inference streams and routes them into durable/live inference emissions. */
|
|
296
295
|
declare class InferenceRunner extends InferenceRunner_base {
|
|
297
|
-
static readonly Live: Layer.Layer<InferenceRunner, never,
|
|
296
|
+
static readonly Live: Layer.Layer<InferenceRunner, never, ModelResolver | EDAToolRegistry | EventFactory | IdGenerator>;
|
|
298
297
|
}
|
|
299
298
|
//#endregion
|
|
300
299
|
//#region src/services/turn-runner.d.ts
|
|
@@ -547,7 +546,7 @@ interface TurnRunnerShape {
|
|
|
547
546
|
declare const TurnRunner_base: Context.ServiceClass<TurnRunner, "@effect-durable-agent/TurnRunner", TurnRunnerShape>;
|
|
548
547
|
/** Owns one turn: turn boundaries, inferences, tool handoff, and terminal turn events. */
|
|
549
548
|
declare class TurnRunner extends TurnRunner_base {
|
|
550
|
-
static readonly Live: Layer.Layer<TurnRunner, never,
|
|
549
|
+
static readonly Live: Layer.Layer<TurnRunner, never, EventFactory | IdGenerator | InferenceRunner | ToolExecutor>;
|
|
551
550
|
}
|
|
552
551
|
//#endregion
|
|
553
552
|
//#region src/services/session-state.d.ts
|
|
@@ -567,6 +566,120 @@ declare const SessionRunInput: Schema.Struct<{
|
|
|
567
566
|
readonly systemPrompt: Schema.optionalKey<Schema.NonEmptyString>;
|
|
568
567
|
}>;
|
|
569
568
|
type SessionRunInput = typeof SessionRunInput.Type;
|
|
569
|
+
/** Command outcome when the command's run completed and the command was completed. */
|
|
570
|
+
declare const SessionCommandCompleted: Schema.TaggedStruct<"SessionCommandCompleted", {
|
|
571
|
+
readonly committed: Schema.Struct<{
|
|
572
|
+
readonly position: Schema.Struct<{
|
|
573
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
574
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
575
|
+
}>;
|
|
576
|
+
readonly event: Schema.Struct<{
|
|
577
|
+
readonly durability: Schema.Literal<"durable">;
|
|
578
|
+
readonly namespace: Schema.NonEmptyString;
|
|
579
|
+
readonly type: Schema.NonEmptyString;
|
|
580
|
+
readonly schemaVersion: Schema.Int;
|
|
581
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
582
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
583
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
584
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
585
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
586
|
+
readonly span: Schema.Struct<{
|
|
587
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
588
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
589
|
+
readonly sampled: Schema.Boolean;
|
|
590
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
591
|
+
}>;
|
|
592
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
593
|
+
readonly context: Schema.Struct<{
|
|
594
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
595
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
596
|
+
readonly sampled: Schema.Boolean;
|
|
597
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
598
|
+
}>;
|
|
599
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
600
|
+
}>>;
|
|
601
|
+
}>>;
|
|
602
|
+
readonly payload: Schema.Unknown;
|
|
603
|
+
}>;
|
|
604
|
+
}>;
|
|
605
|
+
}>;
|
|
606
|
+
type SessionCommandCompleted = typeof SessionCommandCompleted.Type;
|
|
607
|
+
/** Command outcome when the command's run failed and the command was failed. */
|
|
608
|
+
declare const SessionCommandFailed: Schema.TaggedStruct<"SessionCommandFailed", {
|
|
609
|
+
readonly committed: Schema.Struct<{
|
|
610
|
+
readonly position: Schema.Struct<{
|
|
611
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
612
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
613
|
+
}>;
|
|
614
|
+
readonly event: Schema.Struct<{
|
|
615
|
+
readonly durability: Schema.Literal<"durable">;
|
|
616
|
+
readonly namespace: Schema.NonEmptyString;
|
|
617
|
+
readonly type: Schema.NonEmptyString;
|
|
618
|
+
readonly schemaVersion: Schema.Int;
|
|
619
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
620
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
621
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
622
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
623
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
624
|
+
readonly span: Schema.Struct<{
|
|
625
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
626
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
627
|
+
readonly sampled: Schema.Boolean;
|
|
628
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
629
|
+
}>;
|
|
630
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
631
|
+
readonly context: Schema.Struct<{
|
|
632
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
633
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
634
|
+
readonly sampled: Schema.Boolean;
|
|
635
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
636
|
+
}>;
|
|
637
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
638
|
+
}>>;
|
|
639
|
+
}>>;
|
|
640
|
+
readonly payload: Schema.Unknown;
|
|
641
|
+
}>;
|
|
642
|
+
}>;
|
|
643
|
+
}>;
|
|
644
|
+
type SessionCommandFailed = typeof SessionCommandFailed.Type;
|
|
645
|
+
/** Command outcome when command work was cancelled by stop, interrupt, or recovery. */
|
|
646
|
+
declare const SessionCommandCancelled: Schema.TaggedStruct<"SessionCommandCancelled", {
|
|
647
|
+
readonly committed: Schema.Struct<{
|
|
648
|
+
readonly position: Schema.Struct<{
|
|
649
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
650
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
651
|
+
}>;
|
|
652
|
+
readonly event: Schema.Struct<{
|
|
653
|
+
readonly durability: Schema.Literal<"durable">;
|
|
654
|
+
readonly namespace: Schema.NonEmptyString;
|
|
655
|
+
readonly type: Schema.NonEmptyString;
|
|
656
|
+
readonly schemaVersion: Schema.Int;
|
|
657
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
658
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
659
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
660
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
661
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
662
|
+
readonly span: Schema.Struct<{
|
|
663
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
664
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
665
|
+
readonly sampled: Schema.Boolean;
|
|
666
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
667
|
+
}>;
|
|
668
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
669
|
+
readonly context: Schema.Struct<{
|
|
670
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
671
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
672
|
+
readonly sampled: Schema.Boolean;
|
|
673
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
674
|
+
}>;
|
|
675
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
676
|
+
}>>;
|
|
677
|
+
}>>;
|
|
678
|
+
readonly payload: Schema.Unknown;
|
|
679
|
+
}>;
|
|
680
|
+
}>;
|
|
681
|
+
}>;
|
|
682
|
+
type SessionCommandCancelled = typeof SessionCommandCancelled.Type;
|
|
570
683
|
/** Terminal command-processing variants returned from one control action. */
|
|
571
684
|
declare const SessionCommandOutcome: Schema.Union<readonly [Schema.TaggedStruct<"SessionCommandCompleted", {
|
|
572
685
|
readonly committed: Schema.Struct<{
|
|
@@ -680,9 +793,12 @@ interface SessionCommandResult {
|
|
|
680
793
|
readonly started: CommittedDurableEvent;
|
|
681
794
|
readonly outcome: SessionCommandOutcome;
|
|
682
795
|
}
|
|
796
|
+
/** Why a control drain stopped without starting more command work. */
|
|
797
|
+
declare const SessionNoRunnableReason: Schema.Literals<readonly ["active-command", "no-pending-command", "awaiting-run-authorization"]>;
|
|
798
|
+
type SessionNoRunnableReason = typeof SessionNoRunnableReason.Type;
|
|
683
799
|
/** Session control result when no admitted command is runnable. */
|
|
684
800
|
declare const SessionNoRunnableCommand: Schema.TaggedStruct<"SessionNoRunnableCommand", {
|
|
685
|
-
readonly reason: Schema.Literals<readonly ["active-command", "no-pending-command"]>;
|
|
801
|
+
readonly reason: Schema.Literals<readonly ["active-command", "no-pending-command", "awaiting-run-authorization"]>;
|
|
686
802
|
readonly active: Schema.optionalKey<Schema.TaggedStruct<"DispatchActiveCommand", {
|
|
687
803
|
readonly commandId: Schema.brand<Schema.String, "CommandId">;
|
|
688
804
|
readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "RunId">>;
|
|
@@ -716,6 +832,10 @@ type SessionCommandAdmissionError = EDASessionStoreError | SessionCommandAdmissi
|
|
|
716
832
|
type EDASubmittable = EDACommand | DurableEventEnvelope;
|
|
717
833
|
/** Internal live-process authority for commands, durable writes, and scheduling. */
|
|
718
834
|
interface SessionStateShape extends SessionEventSink {
|
|
835
|
+
/** Trusted permission entrypoint, serialized with control actions and revalidated before commit. */
|
|
836
|
+
readonly grantRun: (command: GrantRunCommand, input: SessionRunInput) => Effect.Effect<RunGrantResult, SessionStateError>;
|
|
837
|
+
/** Host alarm callback for strict, at-least-once delivery of the current persisted request. */
|
|
838
|
+
readonly retryRunSchedulingDelivery: () => Effect.Effect<void, EDASessionStoreError>;
|
|
719
839
|
/** Commit session-initial context, such as app-owned system prompt, before command work starts. */
|
|
720
840
|
readonly initialize: (input: SessionRunInput) => Effect.Effect<void, SessionCommandAdmissionError>;
|
|
721
841
|
/** Submit commands and/or app durable events as one ordered durable batch. */
|
|
@@ -740,30 +860,8 @@ interface SessionStateShape extends SessionEventSink {
|
|
|
740
860
|
declare const SessionState_base: Context.ServiceClass<SessionState, "@effect-durable-agent/SessionState", SessionStateShape>;
|
|
741
861
|
/** Internal authoritative live state and root control loop for one session. */
|
|
742
862
|
declare class SessionState extends SessionState_base {
|
|
743
|
-
static readonly Live: Layer.Layer<SessionState, EDASessionStoreError,
|
|
744
|
-
}
|
|
745
|
-
//#endregion
|
|
746
|
-
//#region src/services/session-query.d.ts
|
|
747
|
-
/** Authoritative live snapshot for one EDA session plus its derived durable transcript. */
|
|
748
|
-
interface EDASessionSnapshot {
|
|
749
|
-
readonly state: ReducedState;
|
|
750
|
-
readonly reducerStates: EDAReducerStateSnapshot;
|
|
751
|
-
readonly messages: ReadonlyArray<DurableTranscriptMessage>;
|
|
752
|
-
}
|
|
753
|
-
/** Read-only query facade over authoritative live state and reconnect-safe event streams. */
|
|
754
|
-
interface EDASessionQueryShape {
|
|
755
|
-
/** Read the authoritative live state and derive its durable transcript. */
|
|
756
|
-
readonly snapshot: () => Effect.Effect<EDASessionSnapshot, EDASessionStoreError>;
|
|
757
|
-
/** Read durable user/assistant messages in committed sequence order from the live snapshot. */
|
|
758
|
-
readonly messages: () => Effect.Effect<ReadonlyArray<DurableTranscriptMessage>, EDASessionStoreError>;
|
|
759
|
-
/** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */
|
|
760
|
-
readonly eventsAfter: (afterSeq: SequenceNumber) => Effect.Effect<Stream.Stream<PositionedEvent, EDASessionStoreError>, EDASessionStoreError, Scope.Scope>;
|
|
761
|
-
}
|
|
762
|
-
declare const EDASessionQuery_base: Context.ServiceClass<EDASessionQuery, "@effect-durable-agent/EDASessionQuery", EDASessionQueryShape>;
|
|
763
|
-
/** Read-only session query facade backed by authoritative SessionState plus durable backfill. */
|
|
764
|
-
declare class EDASessionQuery extends EDASessionQuery_base {
|
|
765
|
-
static readonly Live: Layer.Layer<EDASessionQuery, never, SessionState | LiveEventBus | EDASessionStore>;
|
|
863
|
+
static readonly Live: Layer.Layer<SessionState, EDASessionStoreError, RunSchedulingWakeup | RunScheduler | EDASessionStore | EDASinkRegistry | EDAReducerRegistry | LiveEventBus | EDAKeepAlive | SessionContext | EventFactory | IdGenerator | TurnRunner | CompactionRunner | EDAPromptProjector>;
|
|
766
864
|
}
|
|
767
865
|
//#endregion
|
|
768
|
-
export {
|
|
769
|
-
//# sourceMappingURL=session-
|
|
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-BeR2rZRR.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { g as SessionId, h as SequenceNumber, n as CommandId, v as SummaryId } from "./core-C-6xHzRx.js";
|
|
2
|
+
import { t as DurableEventEnvelope } from "./envelope-DkZyMIgp.js";
|
|
3
|
+
import { n as CommandIdempotencyKey } from "./commands-p8venTWs.js";
|
|
4
|
+
import { r as CompactionSummaryArtifact } from "./context-projection-mCuvcO2W.js";
|
|
4
5
|
import * as Context from "effect/Context";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
6
7
|
import * as Layer from "effect/Layer";
|
|
@@ -8,89 +9,6 @@ import * as Schema from "effect/Schema";
|
|
|
8
9
|
import * as Stream from "effect/Stream";
|
|
9
10
|
import * as Cause from "effect/Cause";
|
|
10
11
|
|
|
11
|
-
//#region src/domain/context-projection.d.ts
|
|
12
|
-
/** Stable identifier for the compaction policy that selected a summary plan. */
|
|
13
|
-
declare const CompactionPolicyId: Schema.brand<Schema.NonEmptyString, "CompactionPolicyId">;
|
|
14
|
-
type CompactionPolicyId = typeof CompactionPolicyId.Type;
|
|
15
|
-
/** Stable identifier for the executor that produced a summary artifact. */
|
|
16
|
-
declare const CompactionExecutorId: Schema.brand<Schema.NonEmptyString, "CompactionExecutorId">;
|
|
17
|
-
type CompactionExecutorId = typeof CompactionExecutorId.Type;
|
|
18
|
-
/** Authoritative cumulative model-context summary written with `SummaryCreated`. */
|
|
19
|
-
declare const CompactionSummaryArtifact: Schema.Struct<{
|
|
20
|
-
readonly compactionId: Schema.brand<Schema.String, "CompactionId">;
|
|
21
|
-
readonly summaryId: Schema.brand<Schema.String, "SummaryId">;
|
|
22
|
-
readonly previousSummaryId: Schema.optionalKey<Schema.brand<Schema.String, "SummaryId">>;
|
|
23
|
-
readonly sourceFromSeq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
24
|
-
readonly sourceToSeq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
25
|
-
readonly retainedFromContextSeq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
26
|
-
readonly text: Schema.NonEmptyString;
|
|
27
|
-
readonly promptMessage: Schema.Struct<{
|
|
28
|
-
readonly role: Schema.Literal<"user">;
|
|
29
|
-
readonly content: Schema.Union<readonly [Schema.decodeTo<Schema.NonEmptyArray<Schema.toType<Schema.Struct<{
|
|
30
|
-
readonly type: Schema.Literal<"text">;
|
|
31
|
-
readonly text: Schema.String;
|
|
32
|
-
readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>;
|
|
33
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
34
|
-
}>>>, Schema.String, never, never>, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
35
|
-
readonly type: Schema.Literal<"text">;
|
|
36
|
-
readonly text: Schema.String;
|
|
37
|
-
readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>;
|
|
38
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
39
|
-
}>, Schema.Struct<{
|
|
40
|
-
readonly type: Schema.Literal<"file">;
|
|
41
|
-
readonly mediaType: Schema.String;
|
|
42
|
-
readonly fileName: Schema.optional<Schema.String>;
|
|
43
|
-
readonly data: Schema.Union<readonly [Schema.String, Schema.Uint8Array, Schema.URL]>;
|
|
44
|
-
readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>;
|
|
45
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
46
|
-
}>]>>]>;
|
|
47
|
-
readonly "~effect/ai/Prompt/Message": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Message">>;
|
|
48
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
49
|
-
}>;
|
|
50
|
-
readonly policyId: Schema.brand<Schema.NonEmptyString, "CompactionPolicyId">;
|
|
51
|
-
readonly executorId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "CompactionExecutorId">>;
|
|
52
|
-
}>;
|
|
53
|
-
type CompactionSummaryArtifact = typeof CompactionSummaryArtifact.Type;
|
|
54
|
-
/** Current durable context cursor projected from framework reducer state and summary rows. */
|
|
55
|
-
declare const ContextProjection: Schema.Struct<{
|
|
56
|
-
readonly contextVersion: Schema.brand<Schema.Int, "ContextVersion">;
|
|
57
|
-
readonly currentSummary: Schema.optionalKey<Schema.Struct<{
|
|
58
|
-
readonly compactionId: Schema.brand<Schema.String, "CompactionId">;
|
|
59
|
-
readonly summaryId: Schema.brand<Schema.String, "SummaryId">;
|
|
60
|
-
readonly previousSummaryId: Schema.optionalKey<Schema.brand<Schema.String, "SummaryId">>;
|
|
61
|
-
readonly sourceFromSeq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
62
|
-
readonly sourceToSeq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
63
|
-
readonly retainedFromContextSeq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
64
|
-
readonly text: Schema.NonEmptyString;
|
|
65
|
-
readonly promptMessage: Schema.Struct<{
|
|
66
|
-
readonly role: Schema.Literal<"user">;
|
|
67
|
-
readonly content: Schema.Union<readonly [Schema.decodeTo<Schema.NonEmptyArray<Schema.toType<Schema.Struct<{
|
|
68
|
-
readonly type: Schema.Literal<"text">;
|
|
69
|
-
readonly text: Schema.String;
|
|
70
|
-
readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>;
|
|
71
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
72
|
-
}>>>, Schema.String, never, never>, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
73
|
-
readonly type: Schema.Literal<"text">;
|
|
74
|
-
readonly text: Schema.String;
|
|
75
|
-
readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>;
|
|
76
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
77
|
-
}>, Schema.Struct<{
|
|
78
|
-
readonly type: Schema.Literal<"file">;
|
|
79
|
-
readonly mediaType: Schema.String;
|
|
80
|
-
readonly fileName: Schema.optional<Schema.String>;
|
|
81
|
-
readonly data: Schema.Union<readonly [Schema.String, Schema.Uint8Array, Schema.URL]>;
|
|
82
|
-
readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>;
|
|
83
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
84
|
-
}>]>>]>;
|
|
85
|
-
readonly "~effect/ai/Prompt/Message": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Message">>;
|
|
86
|
-
readonly options: Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.NullOr<Schema.Codec<Schema.Json>>>>;
|
|
87
|
-
}>;
|
|
88
|
-
readonly policyId: Schema.brand<Schema.NonEmptyString, "CompactionPolicyId">;
|
|
89
|
-
readonly executorId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "CompactionExecutorId">>;
|
|
90
|
-
}>>;
|
|
91
|
-
}>;
|
|
92
|
-
type ContextProjection = typeof ContextProjection.Type;
|
|
93
|
-
//#endregion
|
|
94
12
|
//#region src/services/session-store.d.ts
|
|
95
13
|
/** A durable event after the store has assigned its replay position. */
|
|
96
14
|
declare const CommittedDurableEvent: Schema.Struct<{
|
|
@@ -135,19 +53,12 @@ declare const EDASessionStoreError_base: Schema.Class<EDASessionStoreError, Sche
|
|
|
135
53
|
* Store-level failure surfaced by durable append, replay, and hydration APIs.
|
|
136
54
|
*
|
|
137
55
|
* The error intentionally stays storage-semantic rather than SQL-specific so
|
|
138
|
-
* framework services can treat
|
|
56
|
+
* framework services can treat SQL-backed hosts, in-memory tests, and future adapters
|
|
139
57
|
* as the same durability boundary.
|
|
140
58
|
*/
|
|
141
59
|
declare class EDASessionStoreError extends EDASessionStoreError_base {}
|
|
142
60
|
/** True when a Cause contains an escaped durable-store failure. */
|
|
143
61
|
declare const hasEDASessionStoreError: (cause: Cause.Cause<unknown>) => boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Initial hard cap for one serialized JSON value stored in DO SQLite.
|
|
146
|
-
*
|
|
147
|
-
* Cloudflare's SQL row/string limit is 2MB; failing around 1.5MB leaves margin
|
|
148
|
-
* for encoding overhead and makes the future blob/chunk decision explicit.
|
|
149
|
-
*/
|
|
150
|
-
declare const durableObjectSerializedJsonHardCapBytes = 1500000;
|
|
151
62
|
/**
|
|
152
63
|
* One logical event to persist in the durable session log.
|
|
153
64
|
*
|
|
@@ -291,5 +202,5 @@ declare class EDASessionStore extends EDASessionStore_base {
|
|
|
291
202
|
static readonly InMemorySeeded: (sessionId: SessionId, events: ReadonlyArray<DurableEventEnvelope>) => Layer.Layer<EDASessionStore, never, never>;
|
|
292
203
|
}
|
|
293
204
|
//#endregion
|
|
294
|
-
export { EDASessionStore as a, FindCommandAdmissionInput as c,
|
|
295
|
-
//# sourceMappingURL=session-store-
|
|
205
|
+
export { EDASessionStore as a, FindCommandAdmissionInput as c, EDAReducerCheckpoint as i, SaveReducerCheckpointInput as l, DurableAppendBatch as n, EDASessionStoreError as o, DurableAppendEntry as r, EDASessionStoreShape as s, CommittedDurableEvent as t, hasEDASessionStoreError as u };
|
|
206
|
+
//# sourceMappingURL=session-store-J_Un45kW.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { h as SequenceNumber } from "./core-C-6xHzRx.js";
|
|
2
|
+
import { o as EDASessionStoreError } from "./session-store-J_Un45kW.js";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
|
|
8
|
+
//#region src/services/sink-checkpoint-store.d.ts
|
|
9
|
+
/** Stable sink name used as the durable checkpoint key. */
|
|
10
|
+
declare const EDASinkName: Schema.brand<Schema.NonEmptyString, "EDASinkName">;
|
|
11
|
+
type EDASinkName = typeof EDASinkName.Type;
|
|
12
|
+
/** Persisted cursor and sink-owned payload for one registered sink. */
|
|
13
|
+
interface StoredSinkCheckpoint {
|
|
14
|
+
readonly afterSeq: SequenceNumber;
|
|
15
|
+
readonly payload: unknown | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** Durable checkpoint persistence port for at-least-once sink runners. */
|
|
18
|
+
interface SinkCheckpointStoreShape {
|
|
19
|
+
/** Read the latest committed cursor and sink-owned payload. */
|
|
20
|
+
readonly load: (sinkName: EDASinkName) => Effect.Effect<StoredSinkCheckpoint, EDASessionStoreError>;
|
|
21
|
+
/** Save sink-owned state without advancing the durable cursor. */
|
|
22
|
+
readonly saveState: (sinkName: EDASinkName, payload: unknown) => Effect.Effect<void, EDASessionStoreError>;
|
|
23
|
+
/** Atomically commit the processed cursor together with current sink-owned state. */
|
|
24
|
+
readonly commit: (sinkName: EDASinkName, afterSeq: SequenceNumber, payload: unknown | undefined) => Effect.Effect<void, EDASessionStoreError>;
|
|
25
|
+
}
|
|
26
|
+
declare const SinkCheckpointStore_base: Context.ServiceClass<SinkCheckpointStore, "@effect-durable-agent/SinkCheckpointStore", SinkCheckpointStoreShape>;
|
|
27
|
+
/**
|
|
28
|
+
* Semantic checkpoint store for registered EDA sinks.
|
|
29
|
+
*
|
|
30
|
+
* Checkpoints are intentionally exposed as load/save/commit operations rather
|
|
31
|
+
* than SQL. Sink side effects happen outside event append transactions, and the
|
|
32
|
+
* cursor advances only after the sink finishes its own external work.
|
|
33
|
+
*/
|
|
34
|
+
declare class SinkCheckpointStore extends SinkCheckpointStore_base {
|
|
35
|
+
/** In-memory checkpoint implementation for store/runtime tests. */
|
|
36
|
+
static readonly InMemory: Layer.Layer<SinkCheckpointStore, never, never>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { StoredSinkCheckpoint as i, SinkCheckpointStore as n, SinkCheckpointStoreShape as r, EDASinkName as t };
|
|
40
|
+
//# sourceMappingURL=sink-checkpoint-store-C9hUxfH0.d.ts.map
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { SequenceNumber, durablePosition } from "./types/core.js";
|
|
2
|
-
import {
|
|
3
|
-
import { f as reduceCommittedEvents, o as foldReducedState } from "./reduced-state-
|
|
4
|
-
import {
|
|
2
|
+
import { dr as turnCompletedEventType, fr as turnFailedEventType, mr as turnStoppedEventType, pr as turnStartedEventType } from "./durable-BPHVFVvV.js";
|
|
3
|
+
import { f as reduceCommittedEvents, o as foldReducedState } from "./reduced-state-Bz68V2H8.js";
|
|
4
|
+
import { CommittedDurableEvent, EDASessionStore, EDASessionStoreError } from "./services/session-store.js";
|
|
5
5
|
import { IdGenerator } from "./services/id-generator.js";
|
|
6
|
-
import { n as
|
|
6
|
+
import { n as SessionContext, t as EventFactory } from "./event-factory-QuC_UvyP.js";
|
|
7
7
|
import { annotateEdaSpan } from "./services/tracing.js";
|
|
8
|
+
import { EDAKeepAlive } from "./services/keep-alive.js";
|
|
9
|
+
import { SessionEventObserver } from "./services/session-event-observer.js";
|
|
8
10
|
import { EDAReducerRegistry } from "./services/reducer-registry.js";
|
|
11
|
+
import { EDASinkName, SinkCheckpointStore } from "./services/sink-checkpoint-store.js";
|
|
9
12
|
import * as Context from "effect/Context";
|
|
10
13
|
import * as Effect from "effect/Effect";
|
|
11
14
|
import * as Layer from "effect/Layer";
|
|
@@ -15,8 +18,6 @@ import * as Cause from "effect/Cause";
|
|
|
15
18
|
import * as Ref from "effect/Ref";
|
|
16
19
|
import * as Scope from "effect/Scope";
|
|
17
20
|
import * as PubSub from "effect/PubSub";
|
|
18
|
-
import * as Duration from "effect/Duration";
|
|
19
|
-
import * as Schedule from "effect/Schedule";
|
|
20
21
|
import * as SynchronizedRef from "effect/SynchronizedRef";
|
|
21
22
|
//#region src/services/live-event-bus.ts
|
|
22
23
|
/** Conservative raw-delta cap for one open turn's live-only reconnect replay. */
|
|
@@ -27,11 +28,17 @@ var LiveEventBus = class LiveEventBus extends Context.Service()("@effect-durable
|
|
|
27
28
|
return makeLiveBus(yield* Effect.acquireRelease(PubSub.unbounded(), PubSub.shutdown), yield* Ref.make({
|
|
28
29
|
events: [],
|
|
29
30
|
overflowed: false
|
|
30
|
-
}));
|
|
31
|
+
}), yield* SessionEventObserver);
|
|
31
32
|
}));
|
|
33
|
+
/** Live bus for hosts that do not install an append-driven observer. */
|
|
34
|
+
static Noop = LiveEventBus.Live.pipe(Layer.provide(SessionEventObserver.Noop));
|
|
32
35
|
};
|
|
33
|
-
const makeLiveBus = (pubsub, activeTurnReplay) => ({
|
|
34
|
-
publish: (event) =>
|
|
36
|
+
const makeLiveBus = (pubsub, activeTurnReplay, observer) => ({
|
|
37
|
+
publish: (event) => Effect.gen(function* () {
|
|
38
|
+
yield* updateActiveTurnReplay(activeTurnReplay, event);
|
|
39
|
+
yield* observer.onEvent(event);
|
|
40
|
+
return yield* PubSub.publish(pubsub, event);
|
|
41
|
+
}),
|
|
35
42
|
subscribeQueue: () => PubSub.subscribe(pubsub),
|
|
36
43
|
subscribe: () => Effect.map(PubSub.subscribe(pubsub), (subscription) => Stream.fromEffectRepeat(PubSub.take(subscription))),
|
|
37
44
|
activeTurnReplay: () => Ref.get(activeTurnReplay)
|
|
@@ -63,46 +70,6 @@ const nextActiveTurnReplay = (state, event) => {
|
|
|
63
70
|
};
|
|
64
71
|
};
|
|
65
72
|
//#endregion
|
|
66
|
-
//#region src/services/sink-checkpoint-store.ts
|
|
67
|
-
/** Stable sink name used as the durable checkpoint key. */
|
|
68
|
-
const EDASinkName = Schema.NonEmptyString.pipe(Schema.brand("EDASinkName"));
|
|
69
|
-
/**
|
|
70
|
-
* Semantic checkpoint store for registered EDA sinks.
|
|
71
|
-
*
|
|
72
|
-
* Checkpoints are intentionally exposed as load/save/commit operations rather
|
|
73
|
-
* than SQL. Sink side effects happen outside event append transactions, and the
|
|
74
|
-
* cursor advances only after the sink finishes its own external work.
|
|
75
|
-
*/
|
|
76
|
-
var SinkCheckpointStore = class SinkCheckpointStore extends Context.Service()("@effect-durable-agent/SinkCheckpointStore") {
|
|
77
|
-
/** In-memory checkpoint implementation for store/runtime tests. */
|
|
78
|
-
static InMemory = Layer.effect(SinkCheckpointStore, Effect.gen(function* () {
|
|
79
|
-
return makeInMemorySinkCheckpointStore(yield* Ref.make(/* @__PURE__ */ new Map()));
|
|
80
|
-
}));
|
|
81
|
-
};
|
|
82
|
-
/** Build a ref-backed checkpoint map with the same public semantics as host adapters. */
|
|
83
|
-
const makeInMemorySinkCheckpointStore = (checkpoints) => ({
|
|
84
|
-
load: (sinkName) => Ref.get(checkpoints).pipe(Effect.map((map) => map.get(sinkName) ?? {
|
|
85
|
-
afterSeq: SequenceNumber.make(0),
|
|
86
|
-
payload: void 0
|
|
87
|
-
})),
|
|
88
|
-
saveState: (sinkName, payload) => Ref.update(checkpoints, (map) => {
|
|
89
|
-
const next = new Map(map);
|
|
90
|
-
next.set(sinkName, {
|
|
91
|
-
afterSeq: map.get(sinkName)?.afterSeq ?? SequenceNumber.make(0),
|
|
92
|
-
payload
|
|
93
|
-
});
|
|
94
|
-
return next;
|
|
95
|
-
}),
|
|
96
|
-
commit: (sinkName, afterSeq, payload) => Ref.update(checkpoints, (map) => {
|
|
97
|
-
const next = new Map(map);
|
|
98
|
-
next.set(sinkName, {
|
|
99
|
-
afterSeq,
|
|
100
|
-
payload
|
|
101
|
-
});
|
|
102
|
-
return next;
|
|
103
|
-
})
|
|
104
|
-
});
|
|
105
|
-
//#endregion
|
|
106
73
|
//#region src/services/sink-registry.ts
|
|
107
74
|
/** Convenience constructor preserving a sink's literal name/type information. */
|
|
108
75
|
const EDASink = { make: (sink) => sink };
|
|
@@ -117,9 +84,7 @@ var EDASinkRegistry = class EDASinkRegistry extends Context.Service()("@effect-d
|
|
|
117
84
|
static Live = (sinks) => Layer.effect(EDASinkRegistry, makeSinkRegistry(sinks));
|
|
118
85
|
};
|
|
119
86
|
const defaultBatchSize = 100;
|
|
120
|
-
const maxDurableSinkRetryDelay = Duration.seconds(5);
|
|
121
87
|
const sinkCheckpointFormatVersion = 1;
|
|
122
|
-
const durableSinkRetrySchedule = Schedule.exponential("100 millis").pipe(Schedule.jittered, Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.min(duration, maxDurableSinkRetryDelay))));
|
|
123
88
|
const makeSinkRegistry = (sinks) => Effect.gen(function* () {
|
|
124
89
|
const session = yield* SessionContext;
|
|
125
90
|
const store = yield* EDASessionStore;
|
|
@@ -164,14 +129,16 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
|
|
|
164
129
|
const eventsForSink = durable === void 0 ? [] : filterInterested(fresh, durable.interests);
|
|
165
130
|
if (durable !== void 0 && eventsForSink.length > 0) yield* Effect.gen(function* () {
|
|
166
131
|
const staged = [];
|
|
167
|
-
yield* durable.process({
|
|
132
|
+
if ((yield* durable.process({
|
|
168
133
|
allEvents: fresh,
|
|
169
134
|
events: eventsForSink,
|
|
170
135
|
stateAfter: nextReduced,
|
|
171
136
|
reducerStates: nextReducerStates,
|
|
172
137
|
throughSeq
|
|
173
|
-
}, baseContext(staged, input.publishEphemeral, input.scope, checkpoint))
|
|
174
|
-
|
|
138
|
+
}, baseContext(staged, input.publishEphemeral, input.scope, checkpoint)).pipe(Effect.as(true), Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.failCause(cause) : Effect.logError("EDA durable sink violated its infallible contract", {
|
|
139
|
+
cause: Cause.pretty(cause),
|
|
140
|
+
sink: sink.name
|
|
141
|
+
}).pipe(Effect.as(false))))) && staged.length > 0) {
|
|
175
142
|
yield* annotateEdaSpan({ "eda.sink.staged_events": staged.length });
|
|
176
143
|
yield* input.appendDurableBatch(staged);
|
|
177
144
|
}
|
|
@@ -189,17 +156,14 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
|
|
|
189
156
|
reducerStates: nextReducerStates
|
|
190
157
|
});
|
|
191
158
|
});
|
|
192
|
-
const
|
|
193
|
-
error: formatSinkError(error),
|
|
194
|
-
sink: sink.name
|
|
195
|
-
})), Effect.retry(durableSinkRetrySchedule)));
|
|
159
|
+
const processDurableBatchWithKeepAlive = (events) => keepAlive.withActiveWork(`sink:${sink.name}`, processDurableBatch(events));
|
|
196
160
|
const drainDurablesThrough = (targetHead) => Effect.gen(function* () {
|
|
197
161
|
while (true) {
|
|
198
162
|
const current = yield* Ref.get(state);
|
|
199
163
|
if (current.cursor >= targetHead) return;
|
|
200
164
|
const allEvents = yield* readCursorBatchThrough(store, current.cursor, targetHead, sink.durable?.batchSize);
|
|
201
165
|
if (allEvents.length === 0) return;
|
|
202
|
-
yield*
|
|
166
|
+
yield* processDurableBatchWithKeepAlive(allEvents);
|
|
203
167
|
}
|
|
204
168
|
});
|
|
205
169
|
const processLiveDurable = (event) => Effect.gen(function* () {
|
|
@@ -215,7 +179,7 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
|
|
|
215
179
|
});
|
|
216
180
|
return;
|
|
217
181
|
}
|
|
218
|
-
yield*
|
|
182
|
+
yield* processDurableBatchWithKeepAlive([committedDurableFromPositioned(event)]);
|
|
219
183
|
});
|
|
220
184
|
const processLiveEphemeral = (event) => Effect.gen(function* () {
|
|
221
185
|
const before = yield* Ref.get(state);
|
|
@@ -232,7 +196,7 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
|
|
|
232
196
|
const processLiveEvent = (event) => event.event.durability === "durable" ? processLiveDurable(event) : processLiveEphemeral(event);
|
|
233
197
|
yield* Effect.gen(function* () {
|
|
234
198
|
yield* drainDurablesThrough(input.initialHead);
|
|
235
|
-
yield* Effect.forever(Effect.gen(function* () {
|
|
199
|
+
return yield* Effect.forever(Effect.gen(function* () {
|
|
236
200
|
yield* processLiveEvent(yield* PubSub.take(live));
|
|
237
201
|
}));
|
|
238
202
|
}).pipe(Effect.catchCause((cause) => Effect.logError("EDA sink runner failed", {
|
|
@@ -302,11 +266,7 @@ const committedDurableFromPositioned = (event) => CommittedDurableEvent.make({
|
|
|
302
266
|
});
|
|
303
267
|
const filterInterested = (events, interests) => events.filter((event) => matchesInterest(event.event.type, interests));
|
|
304
268
|
const matchesInterest = (type, interests) => interests === void 0 || interests.some((interest) => interest === type);
|
|
305
|
-
const formatSinkError = (error) => {
|
|
306
|
-
if (Cause.isUnknownError(error)) return `${error.message ?? error._tag}: ${formatSinkError(error.cause)}`;
|
|
307
|
-
return error instanceof Error ? error.message : String(error);
|
|
308
|
-
};
|
|
309
269
|
//#endregion
|
|
310
|
-
export {
|
|
270
|
+
export { EDASinkRegistry as n, LiveEventBus as r, EDASink as t };
|
|
311
271
|
|
|
312
|
-
//# sourceMappingURL=sink-registry-
|
|
272
|
+
//# sourceMappingURL=sink-registry-Bbqhtdnx.js.map
|