effect-durable-agent 0.1.0-alpha.3 → 0.1.0-alpha.30
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 +43 -41
- package/dist/assert-never-CoyUpoRB.js +18 -0
- package/dist/assert-never-CoyUpoRB.js.map +1 -0
- package/dist/{commands-Ce1ec6kH.d.ts → commands-3OD-p8dD.d.ts} +16 -9
- package/dist/compaction-63iEDHHl.js +523 -0
- package/dist/compaction-63iEDHHl.js.map +1 -0
- package/dist/context-projection-D_uRtK3r.d.ts +139 -0
- package/dist/{core-Hv3cFydL.d.ts → core-BcimKMIv.d.ts} +6 -4
- package/dist/delivery-2ZILvoRD.js +507 -0
- package/dist/delivery-2ZILvoRD.js.map +1 -0
- package/dist/{websocket-wire-D3tLrhe2.d.ts → delivery-RjM1_NAE.d.ts} +1019 -200
- package/dist/domain/command-queues.d.ts +81 -2
- 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 +36 -2
- package/dist/domain/message-transcript.js +10 -2
- package/dist/domain/message-transcript.js.map +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 +3 -996
- package/dist/domain/reduced-state-schema.js +121 -12
- 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 +937 -2
- package/dist/domain/reduced-state.js.map +1 -0
- 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-DlScwmCy.d.ts → durable-Cqv5ZRFA.d.ts} +8505 -2497
- package/dist/{durable-C3Rz7kg3.js → durable-D13w1Qr3.js} +253 -91
- package/dist/durable-D13w1Qr3.js.map +1 -0
- package/dist/envelope-BCzKUq_z.js +91 -0
- package/dist/envelope-BCzKUq_z.js.map +1 -0
- package/dist/envelope-Che6KatU.d.ts +254 -0
- package/dist/{keep-alive-p8dIcSVy.js → event-factory-_vF1bIJ7.js} +8 -10
- package/dist/event-factory-_vF1bIJ7.js.map +1 -0
- package/dist/{events-Bb9-Cu-7.d.ts → events-Dg0o5wWs.d.ts} +140 -324
- package/dist/{id-generator-C2Q15uZM.d.ts → id-generator-BKGoKjt-.d.ts} +3 -3
- package/dist/in-memory-CeODnZhE.js +150 -0
- package/dist/in-memory-CeODnZhE.js.map +1 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +6 -5
- package/dist/interpreter-DKGJ1sSx.js +1452 -0
- package/dist/interpreter-DKGJ1sSx.js.map +1 -0
- package/dist/keep-alive-_zFCUvt3.d.ts +28 -0
- package/dist/model-resolver-D0vcDZsU.d.ts +24 -0
- package/dist/model-usage-0GeHwaaU.d.ts +54 -0
- package/dist/records--54mZEBx.js +675 -0
- package/dist/records--54mZEBx.js.map +1 -0
- package/dist/reduced-state-DU2ECOUp.d.ts +47821 -0
- package/dist/reduced-state-schema-B2t3cobf.d.ts +2187 -0
- package/dist/{reducer-registry-C0svUa63.d.ts → reducer-registry-JLU1yptN.d.ts} +24 -8
- package/dist/run-scheduling-wakeup-D_bGdicf.d.ts +24 -0
- package/dist/services/compaction.d.ts +2 -2
- package/dist/services/compaction.js +2 -426
- package/dist/services/id-generator.d.ts +1 -1
- package/dist/services/id-generator.js +4 -2
- 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-call.d.ts +15 -0
- package/dist/services/model-call.js +15 -0
- package/dist/services/model-call.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 +49 -5
- package/dist/services/prompt-projector.js.map +1 -1
- package/dist/services/reducer-registry.d.ts +2 -2
- package/dist/services/reducer-registry.js +21 -4
- package/dist/services/reducer-registry.js.map +1 -1
- package/dist/services/run-scheduler.d.ts +2 -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 +48 -0
- package/dist/services/runtime-layer.js +51 -0
- package/dist/services/runtime-layer.js.map +1 -0
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +34 -20
- 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 +141 -2
- 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 +272 -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 +50 -0
- package/dist/services/sink-checkpoint-store.js.map +1 -0
- package/dist/services/sink-registry.d.ts +2 -2
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/span-names.d.ts +1 -1
- package/dist/services/span-names.js +7 -1
- package/dist/services/span-names.js.map +1 -1
- package/dist/services/tool-registry.d.ts +2 -2
- package/dist/services/tool-registry.js +12 -3
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/tracing.d.ts +3 -3
- package/dist/services/tracing.js +25 -4
- package/dist/services/tracing.js.map +1 -1
- package/dist/session-event-observer-HvrRckbC.d.ts +24 -0
- package/dist/{session-query-Cbf-e0rG.js → session-state-BQYsuBqi.js} +693 -251
- package/dist/session-state-BQYsuBqi.js.map +1 -0
- package/dist/session-store-CQxg9U82.d.ts +3302 -0
- package/dist/sink-checkpoint-store-DWGifxp0.d.ts +39 -0
- package/dist/sink-registry-DskRcyOS.js +345 -0
- package/dist/sink-registry-DskRcyOS.js.map +1 -0
- package/dist/subscription-DmO3BcdT.js +505 -0
- package/dist/subscription-DmO3BcdT.js.map +1 -0
- package/dist/subscription-rC35dAWn.d.ts +958 -0
- package/dist/testkit/layers.d.ts +34 -19
- package/dist/testkit/layers.js +30 -16
- package/dist/testkit/layers.js.map +1 -1
- package/dist/testkit/transcript.d.ts +226 -0
- package/dist/testkit/transcript.js +1475 -0
- package/dist/testkit/transcript.js.map +1 -0
- package/dist/{tool-registry-CcnkAAQK.d.ts → tool-registry-BzlMhwzj.d.ts} +44 -8
- package/dist/{tracing-BXHAkxkx.d.ts → tracing-BwjbF285.d.ts} +1 -2
- package/dist/transcript.d.ts +101 -0
- package/dist/transcript.js +107 -0
- package/dist/transcript.js.map +1 -0
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/commands.js +8 -3
- 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 +5 -4
- package/dist/types/events.js +3 -2
- package/dist/types/events.js.map +1 -1
- package/dist/types/tracing.d.ts +1 -1
- package/dist/types/tracing.js.map +1 -1
- package/dist/websocket/events.d.ts +2 -0
- package/dist/websocket/events.js +2 -0
- package/dist/websocket.d.ts +2201 -0
- package/dist/websocket.js +684 -0
- package/dist/websocket.js.map +1 -0
- package/dist/window-read-CBZEJ84M.d.ts +113 -0
- package/dist/window-read-DPFAA1hM.js +264 -0
- package/dist/window-read-DPFAA1hM.js.map +1 -0
- package/package.json +87 -46
- package/testing/offline-trace/README.md +2 -1
- package/CHANGELOG.md +0 -25
- package/CONTRIBUTING.md +0 -26
- package/SECURITY.md +0 -7
- package/dist/command-queues-CQ9cwRP7.d.ts +0 -468
- package/dist/compaction-1LSZR944.d.ts +0 -144
- package/dist/durable-C3Rz7kg3.js.map +0 -1
- package/dist/durable-object-runtime-CiMKxGs6.d.ts +0 -257
- package/dist/durable-object-runtime-wKiqaAt2.js +0 -1494
- package/dist/durable-object-runtime-wKiqaAt2.js.map +0 -1
- 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 -105
- package/dist/host/websocket-wire.js.map +0 -1
- package/dist/index-BVVgDSdq.d.ts +0 -1
- package/dist/keep-alive-DYDsH6qN.d.ts +0 -111
- package/dist/keep-alive-p8dIcSVy.js.map +0 -1
- package/dist/message-transcript-BCHdHAe2.d.ts +0 -32
- package/dist/prompt-projector-DimXJPOJ.d.ts +0 -39
- package/dist/reduced-state-C4nVVzz9.js +0 -910
- package/dist/reduced-state-C4nVVzz9.js.map +0 -1
- package/dist/runtime-DcdPOEuE.d.ts +0 -60
- package/dist/services/compaction.js.map +0 -1
- package/dist/session-query-Cbf-e0rG.js.map +0 -1
- package/dist/session-query-hxfujxUH.d.ts +0 -769
- package/dist/session-store-D2Ore1QC.d.ts +0 -295
- package/dist/session-store-pYxQW9qh.js +0 -214
- package/dist/session-store-pYxQW9qh.js.map +0 -1
- package/dist/sink-registry-BziFpxoE.d.ts +0 -158
- package/dist/sink-registry-CFC6xjsN.js +0 -312
- package/dist/sink-registry-CFC6xjsN.js.map +0 -1
- package/docs/assets/architecture.svg +0 -216
- package/docs/assets/event-sequence.svg +0 -133
- package/docs/assets/gcp-trace.png +0 -0
- package/docs/assets/hero.svg +0 -33
- package/docs/message-steering.md +0 -831
- package/docs/releasing.md +0 -96
- package/docs/spec.md +0 -777
- 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 -639
- 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,295 +0,0 @@
|
|
|
1
|
-
import { _ as SummaryId, h as SessionId, m as SequenceNumber, n as CommandId } from "./core-Hv3cFydL.js";
|
|
2
|
-
import { n as CommandIdempotencyKey } from "./commands-Ce1ec6kH.js";
|
|
3
|
-
import { D as DurableEventEnvelope } from "./events-Bb9-Cu-7.js";
|
|
4
|
-
import * as Context from "effect/Context";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as Layer from "effect/Layer";
|
|
7
|
-
import * as Schema from "effect/Schema";
|
|
8
|
-
import * as Stream from "effect/Stream";
|
|
9
|
-
import * as Cause from "effect/Cause";
|
|
10
|
-
|
|
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
|
-
//#region src/services/session-store.d.ts
|
|
95
|
-
/** A durable event after the store has assigned its replay position. */
|
|
96
|
-
declare const CommittedDurableEvent: Schema.Struct<{
|
|
97
|
-
readonly position: Schema.Struct<{
|
|
98
|
-
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
99
|
-
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
100
|
-
}>;
|
|
101
|
-
readonly event: Schema.Struct<{
|
|
102
|
-
readonly durability: Schema.Literal<"durable">;
|
|
103
|
-
readonly namespace: Schema.NonEmptyString;
|
|
104
|
-
readonly type: Schema.NonEmptyString;
|
|
105
|
-
readonly schemaVersion: Schema.Int;
|
|
106
|
-
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
107
|
-
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
108
|
-
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
109
|
-
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
110
|
-
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
111
|
-
readonly span: Schema.Struct<{
|
|
112
|
-
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
113
|
-
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
114
|
-
readonly sampled: Schema.Boolean;
|
|
115
|
-
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
116
|
-
}>;
|
|
117
|
-
readonly links: Schema.$Array<Schema.Struct<{
|
|
118
|
-
readonly context: Schema.Struct<{
|
|
119
|
-
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
120
|
-
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
121
|
-
readonly sampled: Schema.Boolean;
|
|
122
|
-
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
123
|
-
}>;
|
|
124
|
-
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
125
|
-
}>>;
|
|
126
|
-
}>>;
|
|
127
|
-
readonly payload: Schema.Unknown;
|
|
128
|
-
}>;
|
|
129
|
-
}>;
|
|
130
|
-
type CommittedDurableEvent = typeof CommittedDurableEvent.Type;
|
|
131
|
-
declare const EDASessionStoreError_base: Schema.Class<EDASessionStoreError, Schema.TaggedStruct<"EDASessionStoreError", {
|
|
132
|
-
readonly message: Schema.String;
|
|
133
|
-
}>, Cause.YieldableError>;
|
|
134
|
-
/**
|
|
135
|
-
* Store-level failure surfaced by durable append, replay, and hydration APIs.
|
|
136
|
-
*
|
|
137
|
-
* The error intentionally stays storage-semantic rather than SQL-specific so
|
|
138
|
-
* framework services can treat DO SQLite, in-memory tests, and future adapters
|
|
139
|
-
* as the same durability boundary.
|
|
140
|
-
*/
|
|
141
|
-
declare class EDASessionStoreError extends EDASessionStoreError_base {}
|
|
142
|
-
/** True when a Cause contains an escaped durable-store failure. */
|
|
143
|
-
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
|
-
/**
|
|
152
|
-
* One logical event to persist in the durable session log.
|
|
153
|
-
*
|
|
154
|
-
* Store adapters may split large logical payload fields into sidecar rows after
|
|
155
|
-
* the event insert assigns `seq`, but callers still provide one fat event.
|
|
156
|
-
*/
|
|
157
|
-
declare const DurableAppendEntry: Schema.Struct<{
|
|
158
|
-
readonly event: Schema.Struct<{
|
|
159
|
-
readonly durability: Schema.Literal<"durable">;
|
|
160
|
-
readonly namespace: Schema.NonEmptyString;
|
|
161
|
-
readonly type: Schema.NonEmptyString;
|
|
162
|
-
readonly schemaVersion: Schema.Int;
|
|
163
|
-
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
164
|
-
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
165
|
-
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
166
|
-
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
167
|
-
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
168
|
-
readonly span: Schema.Struct<{
|
|
169
|
-
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
170
|
-
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
171
|
-
readonly sampled: Schema.Boolean;
|
|
172
|
-
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
173
|
-
}>;
|
|
174
|
-
readonly links: Schema.$Array<Schema.Struct<{
|
|
175
|
-
readonly context: Schema.Struct<{
|
|
176
|
-
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
177
|
-
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
178
|
-
readonly sampled: Schema.Boolean;
|
|
179
|
-
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
180
|
-
}>;
|
|
181
|
-
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
182
|
-
}>>;
|
|
183
|
-
}>>;
|
|
184
|
-
readonly payload: Schema.Unknown;
|
|
185
|
-
}>;
|
|
186
|
-
}>;
|
|
187
|
-
type DurableAppendEntry = typeof DurableAppendEntry.Type;
|
|
188
|
-
/**
|
|
189
|
-
* Ordered durable append intent. Adapters assign positions in entry order.
|
|
190
|
-
*
|
|
191
|
-
* This is the single write shape exposed to framework services. It avoids raw
|
|
192
|
-
* SQL and public transaction callbacks while still expressing the full atomic
|
|
193
|
-
* transition EDA needs for events, normalized bodies, and metadata.
|
|
194
|
-
*/
|
|
195
|
-
declare const DurableAppendBatch: Schema.Struct<{
|
|
196
|
-
readonly entries: Schema.$Array<Schema.Struct<{
|
|
197
|
-
readonly event: Schema.Struct<{
|
|
198
|
-
readonly durability: Schema.Literal<"durable">;
|
|
199
|
-
readonly namespace: Schema.NonEmptyString;
|
|
200
|
-
readonly type: Schema.NonEmptyString;
|
|
201
|
-
readonly schemaVersion: Schema.Int;
|
|
202
|
-
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
203
|
-
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
204
|
-
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
205
|
-
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
206
|
-
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
207
|
-
readonly span: Schema.Struct<{
|
|
208
|
-
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
209
|
-
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
210
|
-
readonly sampled: Schema.Boolean;
|
|
211
|
-
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
212
|
-
}>;
|
|
213
|
-
readonly links: Schema.$Array<Schema.Struct<{
|
|
214
|
-
readonly context: Schema.Struct<{
|
|
215
|
-
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
216
|
-
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
217
|
-
readonly sampled: Schema.Boolean;
|
|
218
|
-
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
219
|
-
}>;
|
|
220
|
-
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
221
|
-
}>>;
|
|
222
|
-
}>>;
|
|
223
|
-
readonly payload: Schema.Unknown;
|
|
224
|
-
}>;
|
|
225
|
-
}>>;
|
|
226
|
-
}>;
|
|
227
|
-
type DurableAppendBatch = typeof DurableAppendBatch.Type;
|
|
228
|
-
/** Durable reducer checkpoint row used to hydrate framework and app projections cheaply. */
|
|
229
|
-
interface EDAReducerCheckpoint {
|
|
230
|
-
readonly name: string;
|
|
231
|
-
readonly schemaVersion: number;
|
|
232
|
-
readonly throughSeq: SequenceNumber;
|
|
233
|
-
readonly payload: unknown;
|
|
234
|
-
readonly updatedAtMs: number;
|
|
235
|
-
}
|
|
236
|
-
/** Input for writing one durable reducer checkpoint. */
|
|
237
|
-
interface SaveReducerCheckpointInput {
|
|
238
|
-
readonly name: string;
|
|
239
|
-
readonly schemaVersion: number;
|
|
240
|
-
readonly throughSeq: SequenceNumber;
|
|
241
|
-
readonly payload: unknown;
|
|
242
|
-
readonly updatedAtMs: number;
|
|
243
|
-
}
|
|
244
|
-
/** Indexed command-admission lookup used for idempotent ingress. */
|
|
245
|
-
declare const FindCommandAdmissionInput: Schema.Struct<{
|
|
246
|
-
readonly commandId: Schema.optionalKey<Schema.brand<Schema.String, "CommandId">>;
|
|
247
|
-
readonly idempotencyKey: Schema.optionalKey<Schema.String>;
|
|
248
|
-
}>;
|
|
249
|
-
/** Typed command-admission lookup accepted by the semantic store port. */
|
|
250
|
-
interface FindCommandAdmissionInput {
|
|
251
|
-
readonly commandId?: CommandId;
|
|
252
|
-
readonly idempotencyKey?: CommandIdempotencyKey;
|
|
253
|
-
}
|
|
254
|
-
/** Semantic durable store contract for one EDA session. */
|
|
255
|
-
interface EDASessionStoreShape {
|
|
256
|
-
/**
|
|
257
|
-
* Append durable logical events atomically, preserving input order.
|
|
258
|
-
*
|
|
259
|
-
* Implementations must be idempotent by `eventId`: duplicates return the
|
|
260
|
-
* original committed position and do not advance the durable head. Live publish
|
|
261
|
-
* remains outside the store and is owned by `SessionState` after this succeeds.
|
|
262
|
-
*/
|
|
263
|
-
readonly append: (batch: DurableAppendBatch) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;
|
|
264
|
-
/** Replay committed durable events with `seq > afterSeq`. */
|
|
265
|
-
readonly eventsAfter: (afterSeq: SequenceNumber) => Stream.Stream<CommittedDurableEvent, EDASessionStoreError>;
|
|
266
|
-
/** Load committed durable events by exact sequence number for checkpoint pointer hydration. */
|
|
267
|
-
readonly loadCommittedEventsBySeq: (seqs: ReadonlyArray<SequenceNumber>) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;
|
|
268
|
-
/** Lookup an admitted command without replaying the full journal. */
|
|
269
|
-
readonly findCommandAdmission: (input: FindCommandAdmissionInput) => Effect.Effect<CommittedDurableEvent | undefined, EDASessionStoreError>;
|
|
270
|
-
/** Load one compacted summary artifact body by id, if it has been saved. */
|
|
271
|
-
readonly loadSummaryArtifact: (summaryId: SummaryId) => Effect.Effect<CompactionSummaryArtifact | undefined, EDASessionStoreError>;
|
|
272
|
-
/** Load one framework or app reducer checkpoint, if it has been saved. */
|
|
273
|
-
readonly loadReducerCheckpoint: (name: string) => Effect.Effect<EDAReducerCheckpoint | undefined, EDASessionStoreError>;
|
|
274
|
-
/** Persist one framework or app reducer checkpoint as a derived cache. */
|
|
275
|
-
readonly saveReducerCheckpoint: (checkpoint: SaveReducerCheckpointInput) => Effect.Effect<void, EDASessionStoreError>;
|
|
276
|
-
/** Persist a reducer checkpoint snapshot atomically across framework and app reducers. */
|
|
277
|
-
readonly saveReducerCheckpoints: (checkpoints: ReadonlyArray<SaveReducerCheckpointInput>) => Effect.Effect<void, EDASessionStoreError>;
|
|
278
|
-
}
|
|
279
|
-
declare const EDASessionStore_base: Context.ServiceClass<EDASessionStore, "@effect-durable-agent/EDASessionStore", EDASessionStoreShape>;
|
|
280
|
-
/**
|
|
281
|
-
* SQL-agnostic durable storage port for one EDA session.
|
|
282
|
-
*
|
|
283
|
-
* Framework services depend on this semantic port rather than raw SQL. Host
|
|
284
|
-
* adapters own physical tables and synchronous transaction mechanics; callers
|
|
285
|
-
* only express durable append/replay/lookup intent.
|
|
286
|
-
*/
|
|
287
|
-
declare class EDASessionStore extends EDASessionStore_base {
|
|
288
|
-
/** Deterministic in-memory implementation used by runtime and recovery tests. */
|
|
289
|
-
static readonly InMemory: (sessionId: SessionId) => Layer.Layer<EDASessionStore, never, never>;
|
|
290
|
-
/** In-memory store seeded with a durable prefix; intended for recovery tests. */
|
|
291
|
-
static readonly InMemorySeeded: (sessionId: SessionId, events: ReadonlyArray<DurableEventEnvelope>) => Layer.Layer<EDASessionStore, never, never>;
|
|
292
|
-
}
|
|
293
|
-
//#endregion
|
|
294
|
-
export { EDASessionStore as a, FindCommandAdmissionInput as c, hasEDASessionStoreError as d, CompactionExecutorId as f, EDAReducerCheckpoint as i, SaveReducerCheckpointInput as l, ContextProjection as m, DurableAppendBatch as n, EDASessionStoreError as o, CompactionPolicyId as p, DurableAppendEntry as r, EDASessionStoreShape as s, CommittedDurableEvent as t, durableObjectSerializedJsonHardCapBytes as u };
|
|
295
|
-
//# sourceMappingURL=session-store-D2Ore1QC.d.ts.map
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { CommandId, CompactionId, ContextVersion, DurablePosition, SequenceNumber, SummaryId, durablePosition } from "./types/core.js";
|
|
2
|
-
import { Bn as summaryCreatedEventType, Cn as contextRebasedEventType, nr as DurableEventEnvelope, pn as commandAdmittedEventType } from "./durable-C3Rz7kg3.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
|
-
import * as Stream from "effect/Stream";
|
|
8
|
-
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
9
|
-
import * as Cause from "effect/Cause";
|
|
10
|
-
import * as Ref from "effect/Ref";
|
|
11
|
-
//#region src/domain/context-projection.ts
|
|
12
|
-
/** Stable identifier for the compaction policy that selected a summary plan. */
|
|
13
|
-
const CompactionPolicyId = Schema.NonEmptyString.pipe(Schema.brand("CompactionPolicyId"));
|
|
14
|
-
/** Stable identifier for the executor that produced a summary artifact. */
|
|
15
|
-
const CompactionExecutorId = Schema.NonEmptyString.pipe(Schema.brand("CompactionExecutorId"));
|
|
16
|
-
/** Authoritative cumulative model-context summary written with `SummaryCreated`. */
|
|
17
|
-
const CompactionSummaryArtifact = Schema.Struct({
|
|
18
|
-
compactionId: CompactionId,
|
|
19
|
-
summaryId: SummaryId,
|
|
20
|
-
previousSummaryId: Schema.optionalKey(SummaryId),
|
|
21
|
-
sourceFromSeq: SequenceNumber,
|
|
22
|
-
sourceToSeq: SequenceNumber,
|
|
23
|
-
retainedFromContextSeq: SequenceNumber,
|
|
24
|
-
text: Schema.NonEmptyString,
|
|
25
|
-
promptMessage: Prompt.UserMessage,
|
|
26
|
-
policyId: CompactionPolicyId,
|
|
27
|
-
executorId: Schema.optionalKey(CompactionExecutorId)
|
|
28
|
-
});
|
|
29
|
-
/** Current durable context cursor projected from framework reducer state and summary rows. */
|
|
30
|
-
const ContextProjection = Schema.Struct({
|
|
31
|
-
contextVersion: ContextVersion,
|
|
32
|
-
currentSummary: Schema.optionalKey(CompactionSummaryArtifact)
|
|
33
|
-
});
|
|
34
|
-
/** Genesis context before any compaction has rebased prompt history. */
|
|
35
|
-
const emptyContextProjection = ContextProjection.make({ contextVersion: ContextVersion.make(0) });
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/services/session-store.ts
|
|
38
|
-
/** A durable event after the store has assigned its replay position. */
|
|
39
|
-
const CommittedDurableEvent = Schema.Struct({
|
|
40
|
-
position: DurablePosition,
|
|
41
|
-
event: DurableEventEnvelope
|
|
42
|
-
});
|
|
43
|
-
/**
|
|
44
|
-
* Store-level failure surfaced by durable append, replay, and hydration APIs.
|
|
45
|
-
*
|
|
46
|
-
* The error intentionally stays storage-semantic rather than SQL-specific so
|
|
47
|
-
* framework services can treat DO SQLite, in-memory tests, and future adapters
|
|
48
|
-
* as the same durability boundary.
|
|
49
|
-
*/
|
|
50
|
-
var EDASessionStoreError = class extends Schema.TaggedErrorClass()("EDASessionStoreError", { message: Schema.String }) {};
|
|
51
|
-
/** True when a Cause contains an escaped durable-store failure. */
|
|
52
|
-
const hasEDASessionStoreError = (cause) => cause.reasons.some((reason) => Cause.isFailReason(reason) && reason.error instanceof EDASessionStoreError);
|
|
53
|
-
/**
|
|
54
|
-
* Initial hard cap for one serialized JSON value stored in DO SQLite.
|
|
55
|
-
*
|
|
56
|
-
* Cloudflare's SQL row/string limit is 2MB; failing around 1.5MB leaves margin
|
|
57
|
-
* for encoding overhead and makes the future blob/chunk decision explicit.
|
|
58
|
-
*/
|
|
59
|
-
const durableObjectSerializedJsonHardCapBytes = 15e5;
|
|
60
|
-
/**
|
|
61
|
-
* One logical event to persist in the durable session log.
|
|
62
|
-
*
|
|
63
|
-
* Store adapters may split large logical payload fields into sidecar rows after
|
|
64
|
-
* the event insert assigns `seq`, but callers still provide one fat event.
|
|
65
|
-
*/
|
|
66
|
-
const DurableAppendEntry = Schema.Struct({ event: DurableEventEnvelope });
|
|
67
|
-
/**
|
|
68
|
-
* Ordered durable append intent. Adapters assign positions in entry order.
|
|
69
|
-
*
|
|
70
|
-
* This is the single write shape exposed to framework services. It avoids raw
|
|
71
|
-
* SQL and public transaction callbacks while still expressing the full atomic
|
|
72
|
-
* transition EDA needs for events, normalized bodies, and metadata.
|
|
73
|
-
*/
|
|
74
|
-
const DurableAppendBatch = Schema.Struct({ entries: Schema.Array(DurableAppendEntry) });
|
|
75
|
-
/** Indexed command-admission lookup used for idempotent ingress. */
|
|
76
|
-
const FindCommandAdmissionInput = Schema.Struct({
|
|
77
|
-
commandId: Schema.optionalKey(CommandId),
|
|
78
|
-
idempotencyKey: Schema.optionalKey(Schema.String)
|
|
79
|
-
});
|
|
80
|
-
/**
|
|
81
|
-
* SQL-agnostic durable storage port for one EDA session.
|
|
82
|
-
*
|
|
83
|
-
* Framework services depend on this semantic port rather than raw SQL. Host
|
|
84
|
-
* adapters own physical tables and synchronous transaction mechanics; callers
|
|
85
|
-
* only express durable append/replay/lookup intent.
|
|
86
|
-
*/
|
|
87
|
-
var EDASessionStore = class EDASessionStore extends Context.Service()("@effect-durable-agent/EDASessionStore") {
|
|
88
|
-
/** Deterministic in-memory implementation used by runtime and recovery tests. */
|
|
89
|
-
static InMemory = (sessionId) => Layer.effect(EDASessionStore, Effect.gen(function* () {
|
|
90
|
-
return makeInMemoryStore(sessionId, yield* Ref.make(emptyInMemoryStoreData()));
|
|
91
|
-
}));
|
|
92
|
-
/** In-memory store seeded with a durable prefix; intended for recovery tests. */
|
|
93
|
-
static InMemorySeeded = (sessionId, events) => Layer.effect(EDASessionStore, Effect.gen(function* () {
|
|
94
|
-
const committed = seedCommittedEvents(sessionId, events);
|
|
95
|
-
return makeInMemoryStore(sessionId, yield* Ref.make({
|
|
96
|
-
...emptyInMemoryStoreData(),
|
|
97
|
-
committed,
|
|
98
|
-
summaries: summariesFromCommittedEvents(committed)
|
|
99
|
-
}));
|
|
100
|
-
}));
|
|
101
|
-
};
|
|
102
|
-
const emptyInMemoryStoreData = () => ({
|
|
103
|
-
committed: [],
|
|
104
|
-
summaries: /* @__PURE__ */ new Map(),
|
|
105
|
-
reducerCheckpoints: /* @__PURE__ */ new Map()
|
|
106
|
-
});
|
|
107
|
-
const seedCommittedEvents = (sessionId, events) => {
|
|
108
|
-
const seen = /* @__PURE__ */ new Set();
|
|
109
|
-
return events.map((event, index) => {
|
|
110
|
-
if (event.sessionId !== sessionId) throw new Error(`EDASessionStore.InMemorySeeded is scoped to session ${sessionId}; received ${event.sessionId}`);
|
|
111
|
-
if (seen.has(event.eventId)) throw new Error(`Duplicate seed eventId ${event.eventId}`);
|
|
112
|
-
seen.add(event.eventId);
|
|
113
|
-
return CommittedDurableEvent.make({
|
|
114
|
-
position: durablePosition(SequenceNumber.make(index + 1)),
|
|
115
|
-
event
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
const summariesFromCommittedEvents = (events) => {
|
|
120
|
-
const summaries = /* @__PURE__ */ new Map();
|
|
121
|
-
for (const { event } of events) {
|
|
122
|
-
if (event.type !== summaryCreatedEventType) continue;
|
|
123
|
-
const payload = event.payload;
|
|
124
|
-
if (payload.summary !== void 0) {
|
|
125
|
-
const summary = CompactionSummaryArtifact.make(payload.summary);
|
|
126
|
-
summaries.set(summary.summaryId, summary);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return summaries;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Build an in-memory store with one `Ref.modify` append critical section.
|
|
133
|
-
*
|
|
134
|
-
* The fake models the semantic atomicity of the production adapter without
|
|
135
|
-
* exposing SQL, so runtime tests exercise the same store contract.
|
|
136
|
-
*/
|
|
137
|
-
const makeInMemoryStore = (sessionId, data) => {
|
|
138
|
-
const ensureSession = (event) => Effect.gen(function* () {
|
|
139
|
-
if (event.sessionId === sessionId) return;
|
|
140
|
-
return yield* new EDASessionStoreError({ message: `EDASessionStore.InMemory is scoped to session ${sessionId}; received ${event.sessionId}` });
|
|
141
|
-
});
|
|
142
|
-
const append = (batch) => Effect.gen(function* () {
|
|
143
|
-
for (const entry of batch.entries) yield* ensureSession(entry.event);
|
|
144
|
-
return yield* Ref.modify(data, (current) => {
|
|
145
|
-
const nextEntries = [...current.committed];
|
|
146
|
-
const nextSummaries = new Map(current.summaries);
|
|
147
|
-
const committedEvents = [];
|
|
148
|
-
for (const entry of batch.entries) {
|
|
149
|
-
const { event } = entry;
|
|
150
|
-
const existing = nextEntries.find((entry) => entry.event.eventId === event.eventId);
|
|
151
|
-
if (existing !== void 0) {
|
|
152
|
-
committedEvents.push(existing);
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
const committed = CommittedDurableEvent.make({
|
|
156
|
-
position: durablePosition(SequenceNumber.make(nextEntries.length + 1)),
|
|
157
|
-
event
|
|
158
|
-
});
|
|
159
|
-
nextEntries.push(committed);
|
|
160
|
-
committedEvents.push(committed);
|
|
161
|
-
if (event.type === summaryCreatedEventType) {
|
|
162
|
-
const payload = event.payload;
|
|
163
|
-
if (payload.summary === void 0) throw new Error("SummaryCreated requires summary payload");
|
|
164
|
-
const summary = CompactionSummaryArtifact.make(payload.summary);
|
|
165
|
-
if (payload.summaryId !== void 0 && summary.summaryId !== payload.summaryId) throw new Error("SummaryCreated summaryId does not match summary payload");
|
|
166
|
-
nextSummaries.set(summary.summaryId, summary);
|
|
167
|
-
}
|
|
168
|
-
if (event.type === contextRebasedEventType) {
|
|
169
|
-
const payload = event.payload;
|
|
170
|
-
if (payload.summaryId === void 0 || !nextSummaries.has(payload.summaryId)) throw new Error(`ContextRebased references unknown summaryId ${String(payload.summaryId)}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return [committedEvents, {
|
|
174
|
-
committed: nextEntries,
|
|
175
|
-
summaries: nextSummaries,
|
|
176
|
-
reducerCheckpoints: current.reducerCheckpoints
|
|
177
|
-
}];
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
return {
|
|
181
|
-
append,
|
|
182
|
-
eventsAfter: (afterSeq) => Stream.fromIterableEffect(Ref.get(data).pipe(Effect.map(({ committed }) => committed.filter((entry) => entry.position.seq > afterSeq)))),
|
|
183
|
-
loadCommittedEventsBySeq: (seqs) => Ref.get(data).pipe(Effect.map(({ committed }) => {
|
|
184
|
-
const requested = new Set(seqs.map((seq) => Number(seq)));
|
|
185
|
-
return committed.filter((entry) => requested.has(Number(entry.position.seq)));
|
|
186
|
-
})),
|
|
187
|
-
findCommandAdmission: (input) => Ref.get(data).pipe(Effect.map(({ committed }) => committed.find((entry) => commandAdmissionMatches(entry, input)))),
|
|
188
|
-
loadSummaryArtifact: (summaryId) => Ref.get(data).pipe(Effect.map(({ summaries }) => summaries.get(summaryId))),
|
|
189
|
-
loadReducerCheckpoint: (name) => Ref.get(data).pipe(Effect.map(({ reducerCheckpoints }) => reducerCheckpoints.get(name))),
|
|
190
|
-
saveReducerCheckpoint: (checkpoint) => Ref.update(data, (current) => ({
|
|
191
|
-
...current,
|
|
192
|
-
reducerCheckpoints: new Map(current.reducerCheckpoints).set(checkpoint.name, checkpoint)
|
|
193
|
-
})),
|
|
194
|
-
saveReducerCheckpoints: (checkpoints) => Ref.update(data, (current) => {
|
|
195
|
-
const reducerCheckpoints = new Map(current.reducerCheckpoints);
|
|
196
|
-
for (const checkpoint of checkpoints) reducerCheckpoints.set(checkpoint.name, checkpoint);
|
|
197
|
-
return {
|
|
198
|
-
...current,
|
|
199
|
-
reducerCheckpoints
|
|
200
|
-
};
|
|
201
|
-
})
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
const commandAdmissionMatches = (entry, input) => {
|
|
205
|
-
if (entry.event.type !== commandAdmittedEventType) return false;
|
|
206
|
-
const admitted = entry.event.payload.command;
|
|
207
|
-
if (admitted === void 0) return false;
|
|
208
|
-
if (input.idempotencyKey !== void 0 && admitted.idempotencyKey === input.idempotencyKey) return true;
|
|
209
|
-
return input.commandId !== void 0 && admitted.commandId === input.commandId;
|
|
210
|
-
};
|
|
211
|
-
//#endregion
|
|
212
|
-
export { EDASessionStoreError as a, hasEDASessionStoreError as c, CompactionSummaryArtifact as d, ContextProjection as f, EDASessionStore as i, CompactionExecutorId as l, DurableAppendBatch as n, FindCommandAdmissionInput as o, emptyContextProjection as p, DurableAppendEntry as r, durableObjectSerializedJsonHardCapBytes as s, CommittedDurableEvent as t, CompactionPolicyId as u };
|
|
213
|
-
|
|
214
|
-
//# sourceMappingURL=session-store-pYxQW9qh.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-store-pYxQW9qh.js","names":[],"sources":["../src/domain/context-projection.ts","../src/services/session-store.ts"],"sourcesContent":["import * as Prompt from \"effect/unstable/ai/Prompt\";\nimport * as Schema from \"effect/Schema\";\n\nimport { CompactionId, ContextVersion, SequenceNumber, SummaryId } from \"../types/core\";\n\n/** Stable identifier for the compaction policy that selected a summary plan. */\nexport const CompactionPolicyId = Schema.NonEmptyString.pipe(Schema.brand(\"CompactionPolicyId\"));\nexport type CompactionPolicyId = typeof CompactionPolicyId.Type;\n\n/** Stable identifier for the executor that produced a summary artifact. */\nexport const CompactionExecutorId = Schema.NonEmptyString.pipe(\n Schema.brand(\"CompactionExecutorId\"),\n);\nexport type CompactionExecutorId = typeof CompactionExecutorId.Type;\n\n/** Authoritative cumulative model-context summary written with `SummaryCreated`. */\nexport const CompactionSummaryArtifact = Schema.Struct({\n compactionId: CompactionId,\n summaryId: SummaryId,\n previousSummaryId: Schema.optionalKey(SummaryId),\n sourceFromSeq: SequenceNumber,\n sourceToSeq: SequenceNumber,\n retainedFromContextSeq: SequenceNumber,\n text: Schema.NonEmptyString,\n promptMessage: Prompt.UserMessage,\n policyId: CompactionPolicyId,\n executorId: Schema.optionalKey(CompactionExecutorId),\n});\nexport type CompactionSummaryArtifact = typeof CompactionSummaryArtifact.Type;\n\n/** Current durable context cursor projected from framework reducer state and summary rows. */\nexport const ContextProjection = Schema.Struct({\n contextVersion: ContextVersion,\n currentSummary: Schema.optionalKey(CompactionSummaryArtifact),\n});\nexport type ContextProjection = typeof ContextProjection.Type;\n\n/** Genesis context before any compaction has rebased prompt history. */\nexport const emptyContextProjection = ContextProjection.make({\n contextVersion: ContextVersion.make(0),\n});\n","import * as Cause from \"effect/Cause\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { type CommandIdempotencyKey, type EDACommand } from \"../types/commands\";\nimport { CompactionSummaryArtifact } from \"../domain/context-projection\";\nimport {\n CommandId,\n DurablePosition,\n SequenceNumber,\n SessionId,\n SummaryId,\n durablePosition,\n} from \"../types/core\";\nimport {\n DurableEventEnvelope,\n commandAdmittedEventType,\n contextRebasedEventType,\n summaryCreatedEventType,\n} from \"../types/events\";\n\n/** A durable event after the store has assigned its replay position. */\nexport const CommittedDurableEvent = Schema.Struct({\n position: DurablePosition,\n event: DurableEventEnvelope,\n});\nexport type CommittedDurableEvent = typeof CommittedDurableEvent.Type;\n\n/**\n * Store-level failure surfaced by durable append, replay, and hydration APIs.\n *\n * The error intentionally stays storage-semantic rather than SQL-specific so\n * framework services can treat DO SQLite, in-memory tests, and future adapters\n * as the same durability boundary.\n */\nexport class EDASessionStoreError extends Schema.TaggedErrorClass<EDASessionStoreError>()(\n \"EDASessionStoreError\",\n {\n message: Schema.String,\n },\n) {}\n\n/** True when a Cause contains an escaped durable-store failure. */\nexport const hasEDASessionStoreError = (cause: Cause.Cause<unknown>): boolean =>\n cause.reasons.some(\n (reason) => Cause.isFailReason(reason) && reason.error instanceof EDASessionStoreError,\n );\n\n/**\n * Initial hard cap for one serialized JSON value stored in DO SQLite.\n *\n * Cloudflare's SQL row/string limit is 2MB; failing around 1.5MB leaves margin\n * for encoding overhead and makes the future blob/chunk decision explicit.\n */\nexport const durableObjectSerializedJsonHardCapBytes = 1_500_000;\n\n/**\n * One logical event to persist in the durable session log.\n *\n * Store adapters may split large logical payload fields into sidecar rows after\n * the event insert assigns `seq`, but callers still provide one fat event.\n */\nexport const DurableAppendEntry = Schema.Struct({\n event: DurableEventEnvelope,\n});\nexport type DurableAppendEntry = typeof DurableAppendEntry.Type;\n\n/**\n * Ordered durable append intent. Adapters assign positions in entry order.\n *\n * This is the single write shape exposed to framework services. It avoids raw\n * SQL and public transaction callbacks while still expressing the full atomic\n * transition EDA needs for events, normalized bodies, and metadata.\n */\nexport const DurableAppendBatch = Schema.Struct({\n entries: Schema.Array(DurableAppendEntry),\n});\nexport type DurableAppendBatch = typeof DurableAppendBatch.Type;\n\n/** Durable reducer checkpoint row used to hydrate framework and app projections cheaply. */\nexport interface EDAReducerCheckpoint {\n readonly name: string;\n readonly schemaVersion: number;\n readonly throughSeq: SequenceNumber;\n readonly payload: unknown;\n readonly updatedAtMs: number;\n}\n\n/** Input for writing one durable reducer checkpoint. */\nexport interface SaveReducerCheckpointInput {\n readonly name: string;\n readonly schemaVersion: number;\n readonly throughSeq: SequenceNumber;\n readonly payload: unknown;\n readonly updatedAtMs: number;\n}\n\n/** Indexed command-admission lookup used for idempotent ingress. */\nexport const FindCommandAdmissionInput = Schema.Struct({\n commandId: Schema.optionalKey(CommandId),\n idempotencyKey: Schema.optionalKey(Schema.String),\n});\n/** Typed command-admission lookup accepted by the semantic store port. */\nexport interface FindCommandAdmissionInput {\n readonly commandId?: CommandId;\n readonly idempotencyKey?: CommandIdempotencyKey;\n}\n\n/** Semantic durable store contract for one EDA session. */\nexport interface EDASessionStoreShape {\n /**\n * Append durable logical events atomically, preserving input order.\n *\n * Implementations must be idempotent by `eventId`: duplicates return the\n * original committed position and do not advance the durable head. Live publish\n * remains outside the store and is owned by `SessionState` after this succeeds.\n */\n readonly append: (\n batch: DurableAppendBatch,\n ) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;\n /** Replay committed durable events with `seq > afterSeq`. */\n readonly eventsAfter: (\n afterSeq: SequenceNumber,\n ) => Stream.Stream<CommittedDurableEvent, EDASessionStoreError>;\n /** Load committed durable events by exact sequence number for checkpoint pointer hydration. */\n readonly loadCommittedEventsBySeq: (\n seqs: ReadonlyArray<SequenceNumber>,\n ) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;\n /** Lookup an admitted command without replaying the full journal. */\n readonly findCommandAdmission: (\n input: FindCommandAdmissionInput,\n ) => Effect.Effect<CommittedDurableEvent | undefined, EDASessionStoreError>;\n /** Load one compacted summary artifact body by id, if it has been saved. */\n readonly loadSummaryArtifact: (\n summaryId: SummaryId,\n ) => Effect.Effect<CompactionSummaryArtifact | undefined, EDASessionStoreError>;\n /** Load one framework or app reducer checkpoint, if it has been saved. */\n readonly loadReducerCheckpoint: (\n name: string,\n ) => Effect.Effect<EDAReducerCheckpoint | undefined, EDASessionStoreError>;\n /** Persist one framework or app reducer checkpoint as a derived cache. */\n readonly saveReducerCheckpoint: (\n checkpoint: SaveReducerCheckpointInput,\n ) => Effect.Effect<void, EDASessionStoreError>;\n /** Persist a reducer checkpoint snapshot atomically across framework and app reducers. */\n readonly saveReducerCheckpoints: (\n checkpoints: ReadonlyArray<SaveReducerCheckpointInput>,\n ) => Effect.Effect<void, EDASessionStoreError>;\n}\n\n/**\n * SQL-agnostic durable storage port for one EDA session.\n *\n * Framework services depend on this semantic port rather than raw SQL. Host\n * adapters own physical tables and synchronous transaction mechanics; callers\n * only express durable append/replay/lookup intent.\n */\nexport class EDASessionStore extends Context.Service<EDASessionStore, EDASessionStoreShape>()(\n \"@effect-durable-agent/EDASessionStore\",\n) {\n /** Deterministic in-memory implementation used by runtime and recovery tests. */\n static readonly InMemory = (sessionId: SessionId) =>\n Layer.effect(\n EDASessionStore,\n Effect.gen(function* () {\n const data = yield* Ref.make<InMemoryStoreData>(emptyInMemoryStoreData());\n return makeInMemoryStore(sessionId, data);\n }),\n );\n\n /** In-memory store seeded with a durable prefix; intended for recovery tests. */\n static readonly InMemorySeeded = (\n sessionId: SessionId,\n events: ReadonlyArray<DurableEventEnvelope>,\n ) =>\n Layer.effect(\n EDASessionStore,\n Effect.gen(function* () {\n const committed = seedCommittedEvents(sessionId, events);\n const data = yield* Ref.make<InMemoryStoreData>({\n ...emptyInMemoryStoreData(),\n committed,\n summaries: summariesFromCommittedEvents(committed),\n });\n return makeInMemoryStore(sessionId, data);\n }),\n );\n}\n\ninterface InMemoryStoreData {\n readonly committed: ReadonlyArray<CommittedDurableEvent>;\n readonly summaries: ReadonlyMap<SummaryId, CompactionSummaryArtifact>;\n readonly reducerCheckpoints: ReadonlyMap<string, EDAReducerCheckpoint>;\n}\n\nconst emptyInMemoryStoreData = (): InMemoryStoreData => ({\n committed: [],\n summaries: new Map(),\n reducerCheckpoints: new Map(),\n});\n\nconst seedCommittedEvents = (\n sessionId: SessionId,\n events: ReadonlyArray<DurableEventEnvelope>,\n): ReadonlyArray<CommittedDurableEvent> => {\n const seen = new Set<string>();\n return events.map((event, index) => {\n if (event.sessionId !== sessionId) {\n throw new Error(\n `EDASessionStore.InMemorySeeded is scoped to session ${sessionId}; received ${event.sessionId}`,\n );\n }\n if (seen.has(event.eventId)) {\n throw new Error(`Duplicate seed eventId ${event.eventId}`);\n }\n seen.add(event.eventId);\n return CommittedDurableEvent.make({\n position: durablePosition(SequenceNumber.make(index + 1)),\n event,\n });\n });\n};\n\nconst summariesFromCommittedEvents = (\n events: ReadonlyArray<CommittedDurableEvent>,\n): ReadonlyMap<SummaryId, CompactionSummaryArtifact> => {\n const summaries = new Map<SummaryId, CompactionSummaryArtifact>();\n for (const { event } of events) {\n if (event.type !== summaryCreatedEventType) {\n continue;\n }\n const payload = event.payload as { readonly summary?: unknown };\n if (payload.summary !== undefined) {\n const summary = CompactionSummaryArtifact.make(payload.summary as never);\n summaries.set(summary.summaryId, summary);\n }\n }\n return summaries;\n};\n\n/**\n * Build an in-memory store with one `Ref.modify` append critical section.\n *\n * The fake models the semantic atomicity of the production adapter without\n * exposing SQL, so runtime tests exercise the same store contract.\n */\nconst makeInMemoryStore = (\n sessionId: SessionId,\n data: Ref.Ref<InMemoryStoreData>,\n): EDASessionStoreShape => {\n const ensureSession = (event: DurableEventEnvelope): Effect.Effect<void, EDASessionStoreError> =>\n Effect.gen(function* () {\n if (event.sessionId === sessionId) {\n return;\n }\n return yield* new EDASessionStoreError({\n message: `EDASessionStore.InMemory is scoped to session ${sessionId}; received ${event.sessionId}`,\n });\n });\n\n const append = (batch: DurableAppendBatch) =>\n Effect.gen(function* () {\n for (const entry of batch.entries) {\n yield* ensureSession(entry.event);\n }\n\n return yield* Ref.modify(data, (current) => {\n const nextEntries: Array<CommittedDurableEvent> = [...current.committed];\n const nextSummaries = new Map(current.summaries);\n const committedEvents: Array<CommittedDurableEvent> = [];\n\n for (const entry of batch.entries) {\n const { event } = entry;\n const existing = nextEntries.find((entry) => entry.event.eventId === event.eventId);\n if (existing !== undefined) {\n committedEvents.push(existing);\n continue;\n }\n\n const committed = CommittedDurableEvent.make({\n position: durablePosition(SequenceNumber.make(nextEntries.length + 1)),\n event,\n });\n nextEntries.push(committed);\n committedEvents.push(committed);\n\n if (event.type === summaryCreatedEventType) {\n const payload = event.payload as {\n readonly summary?: unknown;\n readonly summaryId?: CompactionSummaryArtifact[\"summaryId\"];\n };\n if (payload.summary === undefined) {\n throw new Error(\"SummaryCreated requires summary payload\");\n }\n const summary = CompactionSummaryArtifact.make(payload.summary as never);\n if (payload.summaryId !== undefined && summary.summaryId !== payload.summaryId) {\n throw new Error(\"SummaryCreated summaryId does not match summary payload\");\n }\n nextSummaries.set(summary.summaryId, summary);\n }\n\n if (event.type === contextRebasedEventType) {\n const payload = event.payload as { readonly summaryId?: SummaryId };\n if (payload.summaryId === undefined || !nextSummaries.has(payload.summaryId)) {\n throw new Error(\n `ContextRebased references unknown summaryId ${String(payload.summaryId)}`,\n );\n }\n }\n }\n\n return [\n committedEvents,\n {\n committed: nextEntries,\n summaries: nextSummaries,\n reducerCheckpoints: current.reducerCheckpoints,\n },\n ];\n });\n });\n\n return {\n append,\n eventsAfter: (afterSeq) =>\n Stream.fromIterableEffect(\n Ref.get(data).pipe(\n Effect.map(({ committed }) => committed.filter((entry) => entry.position.seq > afterSeq)),\n ),\n ),\n loadCommittedEventsBySeq: (seqs) =>\n Ref.get(data).pipe(\n Effect.map(({ committed }) => {\n const requested = new Set(seqs.map((seq) => Number(seq)));\n return committed.filter((entry) => requested.has(Number(entry.position.seq)));\n }),\n ),\n findCommandAdmission: (input) =>\n Ref.get(data).pipe(\n Effect.map(({ committed }) =>\n committed.find((entry) => commandAdmissionMatches(entry, input)),\n ),\n ),\n loadSummaryArtifact: (summaryId) =>\n Ref.get(data).pipe(Effect.map(({ summaries }) => summaries.get(summaryId))),\n loadReducerCheckpoint: (name) =>\n Ref.get(data).pipe(Effect.map(({ reducerCheckpoints }) => reducerCheckpoints.get(name))),\n saveReducerCheckpoint: (checkpoint) =>\n Ref.update(data, (current) => ({\n ...current,\n reducerCheckpoints: new Map(current.reducerCheckpoints).set(checkpoint.name, checkpoint),\n })),\n saveReducerCheckpoints: (checkpoints) =>\n Ref.update(data, (current) => {\n const reducerCheckpoints = new Map(current.reducerCheckpoints);\n for (const checkpoint of checkpoints) {\n reducerCheckpoints.set(checkpoint.name, checkpoint);\n }\n return { ...current, reducerCheckpoints };\n }),\n };\n};\n\nconst commandAdmissionMatches = (\n entry: CommittedDurableEvent,\n input: FindCommandAdmissionInput,\n): boolean => {\n if (entry.event.type !== commandAdmittedEventType) {\n return false;\n }\n const admitted = (entry.event.payload as { readonly command?: EDACommand }).command;\n if (admitted === undefined) {\n return false;\n }\n if (input.idempotencyKey !== undefined && admitted.idempotencyKey === input.idempotencyKey) {\n return true;\n }\n return input.commandId !== undefined && admitted.commandId === input.commandId;\n};\n"],"mappings":";;;;;;;;;;;;AAMA,MAAa,qBAAqB,OAAO,eAAe,KAAK,OAAO,MAAM,oBAAoB,CAAC;;AAI/F,MAAa,uBAAuB,OAAO,eAAe,KACxD,OAAO,MAAM,sBAAsB,CACrC;;AAIA,MAAa,4BAA4B,OAAO,OAAO;CACrD,cAAc;CACd,WAAW;CACX,mBAAmB,OAAO,YAAY,SAAS;CAC/C,eAAe;CACf,aAAa;CACb,wBAAwB;CACxB,MAAM,OAAO;CACb,eAAe,OAAO;CACtB,UAAU;CACV,YAAY,OAAO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