effect-durable-agent 0.1.0-alpha.17 → 0.1.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/{commands-p8venTWs.d.ts → commands-3OD-p8dD.d.ts} +7 -8
  2. package/dist/{compaction-Db6eoLce.js → compaction-Bell28K8.js} +2 -4
  3. package/dist/{compaction-Db6eoLce.js.map → compaction-Bell28K8.js.map} +1 -1
  4. package/dist/{context-projection-n6Rdup0N.d.ts → context-projection-D_uRtK3r.d.ts} +13 -14
  5. package/dist/{core-C-6xHzRx.d.ts → core-BcimKMIv.d.ts} +1 -2
  6. package/dist/domain/command-queues.d.ts +81 -2
  7. package/dist/domain/command-queues.js.map +1 -1
  8. package/dist/domain/context-projection.d.ts +1 -1
  9. package/dist/domain/message-transcript.d.ts +1 -1
  10. package/dist/domain/message-transcript.js.map +1 -1
  11. package/dist/domain/model-usage.d.ts +1 -1
  12. package/dist/domain/reduced-state-schema.d.ts +3 -992
  13. package/dist/domain/reduced-state-schema.js +114 -2
  14. package/dist/domain/reduced-state-schema.js.map +1 -1
  15. package/dist/domain/reduced-state.d.ts +2 -2
  16. package/dist/domain/run-scheduling.d.ts +1 -1
  17. package/dist/domain/run-scheduling.js.map +1 -1
  18. package/dist/durable-DRY7AcsF.js.map +1 -1
  19. package/dist/{durable-Ceu9SC2D.d.ts → durable-DoG_e4iL.d.ts} +1486 -1487
  20. package/dist/envelope-BCzKUq_z.js.map +1 -1
  21. package/dist/{envelope-VXFEC8zr.d.ts → envelope-Che6KatU.d.ts} +29 -30
  22. package/dist/event-factory-CKuWhjS4.js.map +1 -1
  23. package/dist/{events-D3OAPXgS.d.ts → events-sxIzJY26.d.ts} +124 -122
  24. package/dist/{id-generator--x6itQZ2.d.ts → id-generator-BKGoKjt-.d.ts} +2 -3
  25. package/dist/index.d.ts +7 -7
  26. package/dist/index.js +2 -2
  27. package/dist/{keep-alive-Chl5SJxy.d.ts → keep-alive-_zFCUvt3.d.ts} +1 -2
  28. package/dist/{model-resolver-ci5D5WQv.d.ts → model-resolver-BHYVHsam.d.ts} +3 -3
  29. package/dist/{model-usage-CNcnhj72.d.ts → model-usage-0GeHwaaU.d.ts} +2 -3
  30. package/dist/reduced-state-DFIYylAq.js.map +1 -1
  31. package/dist/{index-DWC70Fsi.d.ts → reduced-state-DrSHn_47.d.ts} +12581 -9701
  32. package/dist/reduced-state-schema-CPEmuHLY.d.ts +2167 -0
  33. package/dist/{reducer-registry-nO4biZlg.d.ts → reducer-registry-C3ZidOI1.d.ts} +8 -7
  34. package/dist/{run-scheduling-wakeup-CXT5_CkI.d.ts → run-scheduling-wakeup-COUj3r_B.d.ts} +2 -3
  35. package/dist/services/compaction.d.ts +1 -1
  36. package/dist/services/compaction.js +1 -1
  37. package/dist/services/id-generator.d.ts +1 -1
  38. package/dist/services/id-generator.js +2 -1
  39. package/dist/services/id-generator.js.map +1 -1
  40. package/dist/services/keep-alive.d.ts +1 -1
  41. package/dist/services/keep-alive.js.map +1 -1
  42. package/dist/services/model-resolver.d.ts +1 -1
  43. package/dist/services/model-resolver.js.map +1 -1
  44. package/dist/services/prompt-projector.d.ts +1 -1
  45. package/dist/services/prompt-projector.js.map +1 -1
  46. package/dist/services/reducer-registry.d.ts +1 -1
  47. package/dist/services/reducer-registry.js.map +1 -1
  48. package/dist/services/run-scheduler.d.ts +1 -2
  49. package/dist/services/run-scheduler.js.map +1 -1
  50. package/dist/services/run-scheduling-wakeup.d.ts +1 -1
  51. package/dist/services/run-scheduling-wakeup.js.map +1 -1
  52. package/dist/services/runtime-layer.d.ts +11 -35
  53. package/dist/services/runtime-layer.js +3 -3
  54. package/dist/services/runtime-layer.js.map +1 -1
  55. package/dist/services/runtime.d.ts +1 -1
  56. package/dist/services/runtime.js +12 -3
  57. package/dist/services/runtime.js.map +1 -1
  58. package/dist/services/session-event-observer.d.ts +1 -1
  59. package/dist/services/session-event-observer.js.map +1 -1
  60. package/dist/services/session-query.d.ts +2 -2
  61. package/dist/services/session-query.js +24 -8
  62. package/dist/services/session-query.js.map +1 -1
  63. package/dist/services/session-state.d.ts +1 -1
  64. package/dist/services/session-state.js +1 -1
  65. package/dist/services/session-store.d.ts +1 -1
  66. package/dist/services/session-store.js +5 -3
  67. package/dist/services/session-store.js.map +1 -1
  68. package/dist/services/sink-checkpoint-store.d.ts +1 -1
  69. package/dist/services/sink-checkpoint-store.js +2 -1
  70. package/dist/services/sink-checkpoint-store.js.map +1 -1
  71. package/dist/services/sink-registry.d.ts +1 -1
  72. package/dist/services/sink-registry.js +1 -1
  73. package/dist/services/tool-registry.d.ts +1 -1
  74. package/dist/services/tool-registry.js.map +1 -1
  75. package/dist/services/tracing.d.ts +3 -3
  76. package/dist/services/tracing.js.map +1 -1
  77. package/dist/{session-event-observer-BWppl2Fr.d.ts → session-event-observer-BDwja1jX.d.ts} +3 -3
  78. package/dist/{session-state-8PJZvuR3.js → session-state-BBzzJrDC.js} +78 -50
  79. package/dist/{session-state-8PJZvuR3.js.map → session-state-BBzzJrDC.js.map} +1 -1
  80. package/dist/{session-store-DBa-TOVH.d.ts → session-store-B_vh581h.d.ts} +9 -9
  81. package/dist/{sink-checkpoint-store-BZGfJLve.d.ts → sink-checkpoint-store-2SxoNMbI.d.ts} +3 -4
  82. package/dist/{sink-registry-B4yxTmlI.js → sink-registry-ogHu2Sw7.js} +2 -2
  83. package/dist/{sink-registry-B4yxTmlI.js.map → sink-registry-ogHu2Sw7.js.map} +1 -1
  84. package/dist/testkit/layers.d.ts +13 -18
  85. package/dist/testkit/layers.js +3 -3
  86. package/dist/testkit/layers.js.map +1 -1
  87. package/dist/{tool-registry-NOP9aTHT.d.ts → tool-registry-DDxbmMpY.d.ts} +5 -5
  88. package/dist/{tracing-BXHAkxkx.d.ts → tracing-BwjbF285.d.ts} +1 -2
  89. package/dist/types/commands.d.ts +1 -1
  90. package/dist/types/commands.js.map +1 -1
  91. package/dist/types/core.d.ts +1 -1
  92. package/dist/types/core.js.map +1 -1
  93. package/dist/types/events/durable.d.ts +1 -1
  94. package/dist/types/events.d.ts +4 -4
  95. package/dist/types/tracing.d.ts +1 -1
  96. package/dist/types/tracing.js.map +1 -1
  97. package/dist/websocket.d.ts +197 -187
  98. package/dist/websocket.js +4 -3
  99. package/dist/websocket.js.map +1 -1
  100. package/package.json +7 -7
  101. package/dist/command-queues-w9WUKTpM.d.ts +0 -556
  102. package/dist/compaction-DhIJ-sAH.d.ts +0 -165
  103. package/dist/event-factory-CHP1-DAF.d.ts +0 -91
  104. package/dist/message-transcript-BfuGCZhP.d.ts +0 -32
  105. package/dist/prompt-projector-DvNHsoEN.d.ts +0 -39
  106. package/dist/run-scheduler-DFBqIRzF.d.ts +0 -43
  107. package/dist/sink-registry-tpmJ-Dhf.d.ts +0 -148
@@ -1,10 +1,10 @@
1
- import { t as DurableEventEnvelope } from "./envelope-VXFEC8zr.js";
2
- import { H as DecodedDurableEvent } from "./durable-Ceu9SC2D.js";
3
- import { t as CommittedDurableEvent } from "./session-store-DBa-TOVH.js";
1
+ import { t as DurableEventEnvelope } from "./envelope-Che6KatU.js";
2
+ import { H as DecodedDurableEvent } from "./durable-DoG_e4iL.js";
3
+ import "./events-sxIzJY26.js";
4
+ import { t as CommittedDurableEvent } from "./session-store-B_vh581h.js";
4
5
  import * as Context from "effect/Context";
5
6
  import * as Layer from "effect/Layer";
6
7
  import * as Schema from "effect/Schema";
7
-
8
8
  //#region src/services/reducer-registry.d.ts
9
9
  /** Input accepted by the reducer constructor before schema codecs are materialized. */
10
10
  interface EDAReducerDefinition<State, Name extends string = string, E = DecodedDurableEvent> {
@@ -30,7 +30,8 @@ interface EDAReducer<State = unknown, Name extends string = string> {
30
30
  }
31
31
  /** Convenience constructor preserving a reducer's literal name and schema-derived state type. */
32
32
  declare const EDAReducer: {
33
- /** Select and narrow reducer input from one event schema; malformed registered events fail in the store. */forEvents: <E extends DurableEventEnvelope, State, const Name extends string>(events: Schema.Codec<E, unknown, never, never>, reducer: EDAReducerDefinition<State, Name, E>) => EDAReducer<State, Name>;
33
+ /** Select and narrow reducer input from one event schema; malformed registered events fail in the store. */
34
+ forEvents: <E extends DurableEventEnvelope, State, const Name extends string>(events: Schema.Codec<E, unknown, never, never>, reducer: EDAReducerDefinition<State, Name, E>) => EDAReducer<State, Name>;
34
35
  make: <State, const Name extends string = string>(reducer: EDAReducerDefinition<State, Name>) => EDAReducer<State, Name>;
35
36
  };
36
37
  /** Snapshot of all app reducer states, keyed by reducer name. */
@@ -43,7 +44,7 @@ type EDAReducerStateForName<Entry extends EDASerializedReducerState, Name extend
43
44
  readonly name: Name;
44
45
  }>["state"];
45
46
  /** Exact reducer object required for every member of a serialized state union. */
46
- type EDAReducersFor<Entry extends EDASerializedReducerState> = { readonly [Name in Entry["name"]]: EDAReducer<EDAReducerStateForName<Entry, Name>, Name> };
47
+ type EDAReducersFor<Entry extends EDASerializedReducerState> = { readonly [Name in Entry["name"]]: EDAReducer<EDAReducerStateForName<Entry, Name>, Name>; };
47
48
  /** Schema-backed app reducer registry used by both runtime folding and snapshot serialization. */
48
49
  interface EDATypedReducerRegistry<EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>> {
49
50
  readonly entrySchema: EntrySchema;
@@ -81,4 +82,4 @@ declare class EDAReducerRegistry extends EDAReducerRegistry_base {
81
82
  declare const getEDAReducerState: <State, Name extends string>(snapshot: EDAReducerStateSnapshot, reducer: EDAReducer<State, Name>) => State;
82
83
  //#endregion
83
84
  export { EDAReducerStateSnapshot as a, decodeReducerState as c, encodeReducerState as d, getEDAReducerState as f, EDAReducerRegistryShape as i, defineEDAReducerRegistry as l, EDAReducerDefinition as n, EDAReducersFor as o, reducerSchemaVersion as p, EDAReducerRegistry as r, EDATypedReducerRegistry as s, EDAReducer as t, edaReservedReducerNamePrefix as u };
84
- //# sourceMappingURL=reducer-registry-nO4biZlg.d.ts.map
85
+ //# sourceMappingURL=reducer-registry-C3ZidOI1.d.ts.map
@@ -1,8 +1,7 @@
1
- import { s as EDASessionStoreError } from "./session-store-DBa-TOVH.js";
1
+ import { s as EDASessionStoreError } from "./session-store-B_vh581h.js";
2
2
  import * as Context from "effect/Context";
3
3
  import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
-
6
5
  //#region src/services/run-scheduling-wakeup.d.ts
7
6
  /**
8
7
  * Host-owned durable retry obligation for undelivered run authorization requests.
@@ -22,4 +21,4 @@ declare class RunSchedulingWakeup extends RunSchedulingWakeup_base {
22
21
  }
23
22
  //#endregion
24
23
  export { RunSchedulingWakeupShape as n, RunSchedulingWakeup as t };
25
- //# sourceMappingURL=run-scheduling-wakeup-CXT5_CkI.d.ts.map
24
+ //# sourceMappingURL=run-scheduling-wakeup-COUj3r_B.d.ts.map
@@ -1,2 +1,2 @@
1
- import { _ as defaultCompactionRetainTailTokens, a as CompactionExecutorShape, c as CompactionPolicy, d as CompactionRunner, f as CompactionRunnerInput, g as defaultCompactionMinSummarizableTokens, h as defaultCompactionCharsPerToken, i as CompactionExecutorInput, l as CompactionPolicyInput, m as LanguageModelSummaryCompactionExecutorOptions, n as CompactionError, o as CompactionOutput, p as CompactionRunnerShape, r as CompactionExecutor, s as CompactionPlan, t as ApproximateTokenThresholdCompactionPolicyOptions, u as CompactionPolicyShape, v as defaultCompactionThresholdTokens } from "../compaction-DhIJ-sAH.js";
1
+ import { An as LanguageModelSummaryCompactionExecutorOptions, Cn as CompactionPlan, Dn as CompactionRunner, En as CompactionPolicyShape, Mn as defaultCompactionMinSummarizableTokens, Nn as defaultCompactionRetainTailTokens, On as CompactionRunnerInput, Pn as defaultCompactionThresholdTokens, Sn as CompactionOutput, Tn as CompactionPolicyInput, _n as ApproximateTokenThresholdCompactionPolicyOptions, bn as CompactionExecutorInput, jn as defaultCompactionCharsPerToken, kn as CompactionRunnerShape, vn as CompactionError, wn as CompactionPolicy, xn as CompactionExecutorShape, yn as CompactionExecutor } from "../reduced-state-DrSHn_47.js";
2
2
  export { ApproximateTokenThresholdCompactionPolicyOptions, CompactionError, CompactionExecutor, CompactionExecutorInput, CompactionExecutorShape, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionPolicyInput, CompactionPolicyShape, CompactionRunner, CompactionRunnerInput, CompactionRunnerShape, LanguageModelSummaryCompactionExecutorOptions, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionThresholdTokens };
@@ -1,2 +1,2 @@
1
- import { a as CompactionPolicy, c as defaultCompactionMinSummarizableTokens, i as CompactionPlan, l as defaultCompactionRetainTailTokens, n as CompactionExecutor, o as CompactionRunner, r as CompactionOutput, s as defaultCompactionCharsPerToken, t as CompactionError, u as defaultCompactionThresholdTokens } from "../compaction-Db6eoLce.js";
1
+ import { a as CompactionPolicy, c as defaultCompactionMinSummarizableTokens, i as CompactionPlan, l as defaultCompactionRetainTailTokens, n as CompactionExecutor, o as CompactionRunner, r as CompactionOutput, s as defaultCompactionCharsPerToken, t as CompactionError, u as defaultCompactionThresholdTokens } from "../compaction-Bell28K8.js";
2
2
  export { CompactionError, CompactionExecutor, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionRunner, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionThresholdTokens };
@@ -1,2 +1,2 @@
1
- import { n as IdGeneratorShape, r as sequentialUuidV7, t as IdGenerator } from "../id-generator--x6itQZ2.js";
1
+ import { n as IdGeneratorShape, r as sequentialUuidV7, t as IdGenerator } from "../id-generator-BKGoKjt-.js";
2
2
  export { IdGenerator, IdGeneratorShape, sequentialUuidV7 };
@@ -15,7 +15,8 @@ const WebCryptoLive = Layer.succeed(Crypto.Crypto, Crypto.make({
15
15
  /** Mints framework-owned UUIDv7 lifecycle IDs for effect-durable-agent. */
16
16
  var IdGenerator = class IdGenerator extends Context.Service()("@effect-durable-agent/IdGenerator") {
17
17
  static Live = Layer.effect(IdGenerator, Effect.gen(function* () {
18
- return makeIdGenerator((yield* Crypto.Crypto).randomUUIDv7.pipe(Effect.orDie));
18
+ const crypto = yield* Crypto.Crypto;
19
+ return makeIdGenerator(crypto.randomUUIDv7.pipe(Effect.orDie));
19
20
  })).pipe(Layer.provide(WebCryptoLive));
20
21
  static Deterministic = (ids) => Layer.sync(IdGenerator, () => {
21
22
  let index = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"id-generator.js","names":[],"sources":["../../src/services/id-generator.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Crypto from \"effect/Crypto\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport {\n InferenceId,\n CommandId,\n CompactionId,\n CorrelationId,\n EventId,\n MessageId,\n RunId,\n RunRequestId,\n SessionId,\n SummaryId,\n ToolCallId,\n TurnId,\n} from \"../types/core\";\n\n/** UUIDv7 minting capability for all framework-owned lifecycle identities. */\nexport interface IdGeneratorShape {\n readonly makeSessionId: () => Effect.Effect<SessionId>;\n readonly makeEventId: () => Effect.Effect<EventId>;\n readonly makeCommandId: () => Effect.Effect<CommandId>;\n readonly makeRunId: () => Effect.Effect<RunId>;\n readonly makeRunRequestId: () => Effect.Effect<RunRequestId>;\n readonly makeTurnId: () => Effect.Effect<TurnId>;\n readonly makeInferenceId: () => Effect.Effect<InferenceId>;\n readonly makeToolCallId: () => Effect.Effect<ToolCallId>;\n readonly makeMessageId: () => Effect.Effect<MessageId>;\n readonly makeCompactionId: () => Effect.Effect<CompactionId>;\n readonly makeSummaryId: () => Effect.Effect<SummaryId>;\n readonly makeCorrelationId: () => Effect.Effect<CorrelationId>;\n}\n\nconst WebCryptoLive = Layer.succeed(\n Crypto.Crypto,\n Crypto.make({\n randomBytes: (size) => {\n const bytes = new Uint8Array(size);\n globalThis.crypto.getRandomValues(bytes);\n return bytes;\n },\n digest: () => Effect.die(new Error(\"IdGenerator does not use Crypto.digest\")),\n }),\n);\n\n/** Mints framework-owned UUIDv7 lifecycle IDs for effect-durable-agent. */\nexport class IdGenerator extends Context.Service<IdGenerator, IdGeneratorShape>()(\n \"@effect-durable-agent/IdGenerator\",\n) {\n static readonly Live = Layer.effect(\n IdGenerator,\n Effect.gen(function* () {\n const crypto = yield* Crypto.Crypto;\n return makeIdGenerator(crypto.randomUUIDv7.pipe(Effect.orDie));\n }),\n ).pipe(Layer.provide(WebCryptoLive));\n\n static readonly Deterministic = (ids: ReadonlyArray<string>) =>\n Layer.sync(IdGenerator, () => {\n let index = 0;\n return makeIdGenerator(\n Effect.sync(() => {\n const next = ids[index];\n if (next === undefined) {\n throw new Error(\"deterministic IdGenerator exhausted\");\n }\n index += 1;\n return next;\n }),\n );\n });\n\n /** Counter-based deterministic IDs; the nth minted ID is `sequentialUuidV7(n)`. */\n static readonly Sequential = Layer.sync(IdGenerator, () => {\n let counter = 0;\n return makeIdGenerator(\n Effect.sync(() => {\n counter += 1;\n return sequentialUuidV7(counter);\n }),\n );\n });\n}\n\n/** The UUIDv7-shaped value minted by `IdGenerator.Sequential` for counter `n` (1-based). */\nexport const sequentialUuidV7 = (n: number): string =>\n `00000000-0000-7000-8000-${n.toString(16).padStart(12, \"0\")}`;\n\nconst makeIdGenerator = (nextUuidV7: Effect.Effect<string>): IdGeneratorShape => ({\n makeSessionId: () => nextUuidV7.pipe(Effect.map((id) => SessionId.make(id))),\n makeEventId: () => nextUuidV7.pipe(Effect.map((id) => EventId.make(id))),\n makeCommandId: () => nextUuidV7.pipe(Effect.map((id) => CommandId.make(id))),\n makeRunId: () => nextUuidV7.pipe(Effect.map((id) => RunId.make(id))),\n makeRunRequestId: () => nextUuidV7.pipe(Effect.map((id) => RunRequestId.make(id))),\n makeTurnId: () => nextUuidV7.pipe(Effect.map((id) => TurnId.make(id))),\n makeInferenceId: () => nextUuidV7.pipe(Effect.map((id) => InferenceId.make(id))),\n makeToolCallId: () => nextUuidV7.pipe(Effect.map((id) => ToolCallId.make(id))),\n makeMessageId: () => nextUuidV7.pipe(Effect.map((id) => MessageId.make(id))),\n makeCompactionId: () => nextUuidV7.pipe(Effect.map((id) => CompactionId.make(id))),\n makeSummaryId: () => nextUuidV7.pipe(Effect.map((id) => SummaryId.make(id))),\n makeCorrelationId: () => nextUuidV7.pipe(Effect.map((id) => CorrelationId.make(id))),\n});\n"],"mappings":";;;;;;AAoCA,MAAM,gBAAgB,MAAM,QAC1B,OAAO,QACP,OAAO,KAAK;CACV,cAAc,SAAS;EACrB,MAAM,QAAQ,IAAI,WAAW,IAAI;EACjC,WAAW,OAAO,gBAAgB,KAAK;EACvC,OAAO;CACT;CACA,cAAc,OAAO,oBAAI,IAAI,MAAM,wCAAwC,CAAC;AAC9E,CAAC,CACH;;AAGA,IAAa,cAAb,MAAa,oBAAoB,QAAQ,QAAuC,EAC9E,mCACF,EAAE;CACA,OAAgB,OAAO,MAAM,OAC3B,aACA,OAAO,IAAI,aAAa;EAEtB,OAAO,iBAAgB,OADD,OAAO,QACC,aAAa,KAAK,OAAO,KAAK,CAAC;CAC/D,CAAC,CACH,EAAE,KAAK,MAAM,QAAQ,aAAa,CAAC;CAEnC,OAAgB,iBAAiB,QAC/B,MAAM,KAAK,mBAAmB;EAC5B,IAAI,QAAQ;EACZ,OAAO,gBACL,OAAO,WAAW;GAChB,MAAM,OAAO,IAAI;GACjB,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MAAM,qCAAqC;GAEvD,SAAS;GACT,OAAO;EACT,CAAC,CACH;CACF,CAAC;;CAGH,OAAgB,aAAa,MAAM,KAAK,mBAAmB;EACzD,IAAI,UAAU;EACd,OAAO,gBACL,OAAO,WAAW;GAChB,WAAW;GACX,OAAO,iBAAiB,OAAO;EACjC,CAAC,CACH;CACF,CAAC;AACH;;AAGA,MAAa,oBAAoB,MAC/B,2BAA2B,EAAE,SAAS,EAAE,EAAE,SAAS,IAAI,GAAG;AAE5D,MAAM,mBAAmB,gBAAyD;CAChF,qBAAqB,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC;CAC3E,mBAAmB,WAAW,KAAK,OAAO,KAAK,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC;CACvE,qBAAqB,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC;CAC3E,iBAAiB,WAAW,KAAK,OAAO,KAAK,OAAO,MAAM,KAAK,EAAE,CAAC,CAAC;CACnE,wBAAwB,WAAW,KAAK,OAAO,KAAK,OAAO,aAAa,KAAK,EAAE,CAAC,CAAC;CACjF,kBAAkB,WAAW,KAAK,OAAO,KAAK,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC;CACrE,uBAAuB,WAAW,KAAK,OAAO,KAAK,OAAO,YAAY,KAAK,EAAE,CAAC,CAAC;CAC/E,sBAAsB,WAAW,KAAK,OAAO,KAAK,OAAO,WAAW,KAAK,EAAE,CAAC,CAAC;CAC7E,qBAAqB,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC;CAC3E,wBAAwB,WAAW,KAAK,OAAO,KAAK,OAAO,aAAa,KAAK,EAAE,CAAC,CAAC;CACjF,qBAAqB,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC;CAC3E,yBAAyB,WAAW,KAAK,OAAO,KAAK,OAAO,cAAc,KAAK,EAAE,CAAC,CAAC;AACrF"}
1
+ {"version":3,"file":"id-generator.js","names":[],"sources":["../../src/services/id-generator.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Crypto from \"effect/Crypto\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport {\n InferenceId,\n CommandId,\n CompactionId,\n CorrelationId,\n EventId,\n MessageId,\n RunId,\n RunRequestId,\n SessionId,\n SummaryId,\n ToolCallId,\n TurnId,\n} from \"../types/core\";\n\n/** UUIDv7 minting capability for all framework-owned lifecycle identities. */\nexport interface IdGeneratorShape {\n readonly makeSessionId: () => Effect.Effect<SessionId>;\n readonly makeEventId: () => Effect.Effect<EventId>;\n readonly makeCommandId: () => Effect.Effect<CommandId>;\n readonly makeRunId: () => Effect.Effect<RunId>;\n readonly makeRunRequestId: () => Effect.Effect<RunRequestId>;\n readonly makeTurnId: () => Effect.Effect<TurnId>;\n readonly makeInferenceId: () => Effect.Effect<InferenceId>;\n readonly makeToolCallId: () => Effect.Effect<ToolCallId>;\n readonly makeMessageId: () => Effect.Effect<MessageId>;\n readonly makeCompactionId: () => Effect.Effect<CompactionId>;\n readonly makeSummaryId: () => Effect.Effect<SummaryId>;\n readonly makeCorrelationId: () => Effect.Effect<CorrelationId>;\n}\n\nconst WebCryptoLive = Layer.succeed(\n Crypto.Crypto,\n Crypto.make({\n randomBytes: (size) => {\n const bytes = new Uint8Array(size);\n globalThis.crypto.getRandomValues(bytes);\n return bytes;\n },\n digest: () => Effect.die(new Error(\"IdGenerator does not use Crypto.digest\")),\n }),\n);\n\n/** Mints framework-owned UUIDv7 lifecycle IDs for effect-durable-agent. */\nexport class IdGenerator extends Context.Service<IdGenerator, IdGeneratorShape>()(\n \"@effect-durable-agent/IdGenerator\",\n) {\n static readonly Live = Layer.effect(\n IdGenerator,\n Effect.gen(function* () {\n const crypto = yield* Crypto.Crypto;\n return makeIdGenerator(crypto.randomUUIDv7.pipe(Effect.orDie));\n }),\n ).pipe(Layer.provide(WebCryptoLive));\n\n static readonly Deterministic = (ids: ReadonlyArray<string>) =>\n Layer.sync(IdGenerator, () => {\n let index = 0;\n return makeIdGenerator(\n Effect.sync(() => {\n const next = ids[index];\n if (next === undefined) {\n throw new Error(\"deterministic IdGenerator exhausted\");\n }\n index += 1;\n return next;\n }),\n );\n });\n\n /** Counter-based deterministic IDs; the nth minted ID is `sequentialUuidV7(n)`. */\n static readonly Sequential = Layer.sync(IdGenerator, () => {\n let counter = 0;\n return makeIdGenerator(\n Effect.sync(() => {\n counter += 1;\n return sequentialUuidV7(counter);\n }),\n );\n });\n}\n\n/** The UUIDv7-shaped value minted by `IdGenerator.Sequential` for counter `n` (1-based). */\nexport const sequentialUuidV7 = (n: number): string =>\n `00000000-0000-7000-8000-${n.toString(16).padStart(12, \"0\")}`;\n\nconst makeIdGenerator = (nextUuidV7: Effect.Effect<string>): IdGeneratorShape => ({\n makeSessionId: () => nextUuidV7.pipe(Effect.map((id) => SessionId.make(id))),\n makeEventId: () => nextUuidV7.pipe(Effect.map((id) => EventId.make(id))),\n makeCommandId: () => nextUuidV7.pipe(Effect.map((id) => CommandId.make(id))),\n makeRunId: () => nextUuidV7.pipe(Effect.map((id) => RunId.make(id))),\n makeRunRequestId: () => nextUuidV7.pipe(Effect.map((id) => RunRequestId.make(id))),\n makeTurnId: () => nextUuidV7.pipe(Effect.map((id) => TurnId.make(id))),\n makeInferenceId: () => nextUuidV7.pipe(Effect.map((id) => InferenceId.make(id))),\n makeToolCallId: () => nextUuidV7.pipe(Effect.map((id) => ToolCallId.make(id))),\n makeMessageId: () => nextUuidV7.pipe(Effect.map((id) => MessageId.make(id))),\n makeCompactionId: () => nextUuidV7.pipe(Effect.map((id) => CompactionId.make(id))),\n makeSummaryId: () => nextUuidV7.pipe(Effect.map((id) => SummaryId.make(id))),\n makeCorrelationId: () => nextUuidV7.pipe(Effect.map((id) => CorrelationId.make(id))),\n});\n"],"mappings":";;;;;;AAoCA,MAAM,gBAAgB,MAAM,QAC1B,OAAO,QACP,OAAO,KAAK;CACV,cAAc,SAAS;EACrB,MAAM,QAAQ,IAAI,WAAW,IAAI;EACjC,WAAW,OAAO,gBAAgB,KAAK;EACvC,OAAO;CACT;CACA,cAAc,OAAO,oBAAI,IAAI,MAAM,wCAAwC,CAAC;AAC9E,CAAC,CACH;;AAGA,IAAa,cAAb,MAAa,oBAAoB,QAAQ,QAAuC,CAAC,CAC/E,mCACF,CAAC,CAAC;CACA,OAAgB,OAAO,MAAM,OAC3B,aACA,OAAO,IAAI,aAAa;EACtB,MAAM,SAAS,OAAO,OAAO;EAC7B,OAAO,gBAAgB,OAAO,aAAa,KAAK,OAAO,KAAK,CAAC;CAC/D,CAAC,CAC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E,wBAAwB,WAAW,KAAK,OAAO,KAAK,OAAO,aAAa,KAAK,EAAE,CAAC,CAAC;CACjF,qBAAqB,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC;CAC3E,yBAAyB,WAAW,KAAK,OAAO,KAAK,OAAO,cAAc,KAAK,EAAE,CAAC,CAAC;AACrF"}
@@ -1,2 +1,2 @@
1
- import { n as EDAKeepAliveLease, r as EDAKeepAliveShape, t as EDAKeepAlive } from "../keep-alive-Chl5SJxy.js";
1
+ import { n as EDAKeepAliveLease, r as EDAKeepAliveShape, t as EDAKeepAlive } from "../keep-alive-_zFCUvt3.js";
2
2
  export { EDAKeepAlive, EDAKeepAliveLease, EDAKeepAliveShape };
@@ -1 +1 @@
1
- {"version":3,"file":"keep-alive.js","names":[],"sources":["../../src/services/keep-alive.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\n/** Host lifecycle lease held while finite EDA work is actively running. */\nexport interface EDAKeepAliveLease {\n readonly release: () => Promise<void>;\n}\n\n/** Host-provided wrapper for keeping finite active work alive. */\nexport interface EDAKeepAliveShape {\n /**\n * A host may suspend an idle session after ingress returns while model turns,\n * recovery drains, and durable sink catch-up still run in Effect fibers. Wrap\n * those finite active-work regions so the host can retain or schedule the\n * session until work completes, parks durably, fails, or is interrupted.\n * Long-lived fibers blocked on queues should not hold a lease.\n */\n readonly withActiveWork: <A, E, R>(\n label: string,\n effect: Effect.Effect<A, E, R>,\n ) => Effect.Effect<A, E, R>;\n}\n\n/** Host keep-alive service for finite active EDA work roots. */\nexport class EDAKeepAlive extends Context.Service<EDAKeepAlive, EDAKeepAliveShape>()(\n \"@effect-durable-agent/EDAKeepAlive\",\n) {\n static readonly Noop = Layer.succeed(EDAKeepAlive, {\n withActiveWork: (_label, effect) => effect,\n } satisfies EDAKeepAliveShape);\n\n static readonly FromAcquire = (\n acquire: (label: string) => Promise<EDAKeepAliveLease>,\n ): Layer.Layer<EDAKeepAlive> =>\n Layer.succeed(EDAKeepAlive, {\n withActiveWork: (label, effect) =>\n Effect.acquireUseRelease(\n Effect.promise(() => acquire(label)),\n () => effect,\n (lease) => Effect.promise(() => lease.release()),\n ),\n } satisfies EDAKeepAliveShape);\n}\n"],"mappings":";;;;;AAyBA,IAAa,eAAb,MAAa,qBAAqB,QAAQ,QAAyC,EACjF,oCACF,EAAE;CACA,OAAgB,OAAO,MAAM,QAAQ,cAAc,EACjD,iBAAiB,QAAQ,WAAW,OACtC,CAA6B;CAE7B,OAAgB,eACd,YAEA,MAAM,QAAQ,cAAc,EAC1B,iBAAiB,OAAO,WACtB,OAAO,kBACL,OAAO,cAAc,QAAQ,KAAK,CAAC,SAC7B,SACL,UAAU,OAAO,cAAc,MAAM,QAAQ,CAAC,CACjD,EACJ,CAA6B;AACjC"}
1
+ {"version":3,"file":"keep-alive.js","names":[],"sources":["../../src/services/keep-alive.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\n/** Host lifecycle lease held while finite EDA work is actively running. */\nexport interface EDAKeepAliveLease {\n readonly release: () => Promise<void>;\n}\n\n/** Host-provided wrapper for keeping finite active work alive. */\nexport interface EDAKeepAliveShape {\n /**\n * A host may suspend an idle session after ingress returns while model turns,\n * recovery drains, and durable sink catch-up still run in Effect fibers. Wrap\n * those finite active-work regions so the host can retain or schedule the\n * session until work completes, parks durably, fails, or is interrupted.\n * Long-lived fibers blocked on queues should not hold a lease.\n */\n readonly withActiveWork: <A, E, R>(\n label: string,\n effect: Effect.Effect<A, E, R>,\n ) => Effect.Effect<A, E, R>;\n}\n\n/** Host keep-alive service for finite active EDA work roots. */\nexport class EDAKeepAlive extends Context.Service<EDAKeepAlive, EDAKeepAliveShape>()(\n \"@effect-durable-agent/EDAKeepAlive\",\n) {\n static readonly Noop = Layer.succeed(EDAKeepAlive, {\n withActiveWork: (_label, effect) => effect,\n } satisfies EDAKeepAliveShape);\n\n static readonly FromAcquire = (\n acquire: (label: string) => Promise<EDAKeepAliveLease>,\n ): Layer.Layer<EDAKeepAlive> =>\n Layer.succeed(EDAKeepAlive, {\n withActiveWork: (label, effect) =>\n Effect.acquireUseRelease(\n Effect.promise(() => acquire(label)),\n () => effect,\n (lease) => Effect.promise(() => lease.release()),\n ),\n } satisfies EDAKeepAliveShape);\n}\n"],"mappings":";;;;;AAyBA,IAAa,eAAb,MAAa,qBAAqB,QAAQ,QAAyC,CAAC,CAClF,oCACF,CAAC,CAAC;CACA,OAAgB,OAAO,MAAM,QAAQ,cAAc,EACjD,iBAAiB,QAAQ,WAAW,OACtC,CAA6B;CAE7B,OAAgB,eACd,YAEA,MAAM,QAAQ,cAAc,EAC1B,iBAAiB,OAAO,WACtB,OAAO,kBACL,OAAO,cAAc,QAAQ,KAAK,CAAC,SAC7B,SACL,UAAU,OAAO,cAAc,MAAM,QAAQ,CAAC,CACjD,EACJ,CAA6B;AACjC"}
@@ -1,2 +1,2 @@
1
- import { t as ModelResolver } from "../model-resolver-ci5D5WQv.js";
1
+ import { t as ModelResolver } from "../model-resolver-BHYVHsam.js";
2
2
  export { ModelResolver };
@@ -1 +1 @@
1
- {"version":3,"file":"model-resolver.js","names":[],"sources":["../../src/services/model-resolver.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as LanguageModel from \"effect/unstable/ai/LanguageModel\";\nimport type { ModelSelectionPayload } from \"../types/events\";\n\n/** Resolves a recorded selection into an executable provider service at a model-call boundary. */\nexport class ModelResolver extends Context.Service<\n ModelResolver,\n {\n readonly resolve: (\n selection: ModelSelectionPayload | undefined,\n ) => Effect.Effect<LanguageModel.Service>;\n }\n>()(\"@effect-durable-agent/ModelResolver\") {\n /** Fixed provider implementation for deterministic tests and single-model hosts. */\n static readonly Fixed = Layer.effect(\n ModelResolver,\n Effect.gen(function* () {\n const model = yield* LanguageModel.LanguageModel;\n return { resolve: () => Effect.succeed(model) };\n }),\n );\n}\n"],"mappings":";;;;;;AAOA,IAAa,gBAAb,MAAa,sBAAsB,QAAQ,QAOzC,EAAE,qCAAqC,EAAE;;CAEzC,OAAgB,QAAQ,MAAM,OAC5B,eACA,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,OAAO,cAAc;EACnC,OAAO,EAAE,eAAe,OAAO,QAAQ,KAAK,EAAE;CAChD,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"model-resolver.js","names":[],"sources":["../../src/services/model-resolver.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as LanguageModel from \"effect/unstable/ai/LanguageModel\";\nimport type { ModelSelectionPayload } from \"../types/events\";\n\n/** Resolves a recorded selection into an executable provider service at a model-call boundary. */\nexport class ModelResolver extends Context.Service<\n ModelResolver,\n {\n readonly resolve: (\n selection: ModelSelectionPayload | undefined,\n ) => Effect.Effect<LanguageModel.Service>;\n }\n>()(\"@effect-durable-agent/ModelResolver\") {\n /** Fixed provider implementation for deterministic tests and single-model hosts. */\n static readonly Fixed = Layer.effect(\n ModelResolver,\n Effect.gen(function* () {\n const model = yield* LanguageModel.LanguageModel;\n return { resolve: () => Effect.succeed(model) };\n }),\n );\n}\n"],"mappings":";;;;;;AAOA,IAAa,gBAAb,MAAa,sBAAsB,QAAQ,QAOzC,CAAC,CAAC,qCAAqC,CAAC,CAAC;;CAEzC,OAAgB,QAAQ,MAAM,OAC5B,eACA,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,OAAO,cAAc;EACnC,OAAO,EAAE,eAAe,OAAO,QAAQ,KAAK,EAAE;CAChD,CAAC,CACH;AACF"}
@@ -1,2 +1,2 @@
1
- import { a as buildEDAPrompt, i as EDAPromptProjectorShape, n as EDAPromptProjectionInput, r as EDAPromptProjector, t as EDAProjectedPromptContext } from "../prompt-projector-DvNHsoEN.js";
1
+ import { dn as EDAProjectedPromptContext, fn as EDAPromptProjectionInput, hn as buildEDAPrompt, mn as EDAPromptProjectorShape, pn as EDAPromptProjector } from "../reduced-state-DrSHn_47.js";
2
2
  export { EDAProjectedPromptContext, EDAPromptProjectionInput, EDAPromptProjector, EDAPromptProjectorShape, buildEDAPrompt };
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-projector.js","names":[],"sources":["../../src/services/prompt-projector.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Prompt from \"effect/unstable/ai/Prompt\";\n\nimport { contextProjectionPrompt } from \"../domain/message-transcript\";\nimport type { ContextProjection } from \"../domain/context-projection\";\nimport type { ReducedState } from \"../domain/reduced-state\";\nimport type { SessionId } from \"../types/core\";\nimport type { EDAReducerStateSnapshot } from \"./reducer-registry\";\n\n/** Input for app-extensible state-to-LLM prompt projection. */\nexport interface EDAPromptProjectionInput {\n readonly sessionId: SessionId;\n readonly state: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n readonly context?: ContextProjection;\n}\n\n/** App-derived instructions and data inserted around the durable transcript. */\nexport interface EDAProjectedPromptContext {\n /** Instruction messages placed after durable system context and before transcript history. */\n readonly instructions: ReadonlyArray<Prompt.SystemMessage>;\n /** Data messages placed after transcript history and before scheduler-selected user messages. */\n readonly messages: ReadonlyArray<Prompt.UserMessage>;\n}\n\n/** Host-extensible projection from durable state into provider prompt context. */\nexport interface EDAPromptProjectorShape {\n readonly projectContext: (\n input: EDAPromptProjectionInput,\n ) => Effect.Effect<EDAProjectedPromptContext>;\n readonly projectState: (input: EDAPromptProjectionInput) => Effect.Effect<ReducedState>;\n}\n\n/** Build a provider prompt entirely from the current durable state projection. */\nexport const buildEDAPrompt = (\n projector: EDAPromptProjectorShape,\n input: EDAPromptProjectionInput,\n): Effect.Effect<Prompt.Prompt> =>\n Effect.gen(function* () {\n const state = yield* projector.projectState(input);\n const context = yield* projector.projectContext(input);\n const transcript = contextProjectionPrompt(state, input.context);\n const instructionBoundary = firstNonSystemMessageIndex(transcript.content);\n return Prompt.fromMessages([\n ...transcript.content.slice(0, instructionBoundary),\n ...context.instructions,\n ...transcript.content.slice(instructionBoundary),\n ...context.messages,\n ]);\n });\n\nconst firstNonSystemMessageIndex = (messages: ReadonlyArray<Prompt.Message>): number => {\n const index = messages.findIndex((message) => message.role !== \"system\");\n return index === -1 ? messages.length : index;\n};\n\n/** Service that lets apps derive LLM context independently from UI projections. */\nexport class EDAPromptProjector extends Context.Service<\n EDAPromptProjector,\n EDAPromptProjectorShape\n>()(\"@effect-durable-agent/EDAPromptProjector\") {\n static readonly Default = Layer.succeed(EDAPromptProjector, {\n projectContext: () => Effect.succeed({ instructions: [], messages: [] }),\n projectState: (input) => Effect.succeed(input.state),\n } satisfies EDAPromptProjectorShape);\n}\n"],"mappings":";;;;;;;AAoCA,MAAa,kBACX,WACA,UAEA,OAAO,IAAI,aAAa;CACtB,MAAM,QAAQ,OAAO,UAAU,aAAa,KAAK;CACjD,MAAM,UAAU,OAAO,UAAU,eAAe,KAAK;CACrD,MAAM,aAAa,wBAAwB,OAAO,MAAM,OAAO;CAC/D,MAAM,sBAAsB,2BAA2B,WAAW,OAAO;CACzE,OAAO,OAAO,aAAa;EACzB,GAAG,WAAW,QAAQ,MAAM,GAAG,mBAAmB;EAClD,GAAG,QAAQ;EACX,GAAG,WAAW,QAAQ,MAAM,mBAAmB;EAC/C,GAAG,QAAQ;CACb,CAAC;AACH,CAAC;AAEH,MAAM,8BAA8B,aAAoD;CACtF,MAAM,QAAQ,SAAS,WAAW,YAAY,QAAQ,SAAS,QAAQ;CACvE,OAAO,UAAU,KAAK,SAAS,SAAS;AAC1C;;AAGA,IAAa,qBAAb,MAAa,2BAA2B,QAAQ,QAG9C,EAAE,0CAA0C,EAAE;CAC9C,OAAgB,UAAU,MAAM,QAAQ,oBAAoB;EAC1D,sBAAsB,OAAO,QAAQ;GAAE,cAAc,CAAC;GAAG,UAAU,CAAC;EAAE,CAAC;EACvE,eAAe,UAAU,OAAO,QAAQ,MAAM,KAAK;CACrD,CAAmC;AACrC"}
1
+ {"version":3,"file":"prompt-projector.js","names":[],"sources":["../../src/services/prompt-projector.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Prompt from \"effect/unstable/ai/Prompt\";\n\nimport { contextProjectionPrompt } from \"../domain/message-transcript\";\nimport type { ContextProjection } from \"../domain/context-projection\";\nimport type { ReducedState } from \"../domain/reduced-state\";\nimport type { SessionId } from \"../types/core\";\nimport type { EDAReducerStateSnapshot } from \"./reducer-registry\";\n\n/** Input for app-extensible state-to-LLM prompt projection. */\nexport interface EDAPromptProjectionInput {\n readonly sessionId: SessionId;\n readonly state: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n readonly context?: ContextProjection;\n}\n\n/** App-derived instructions and data inserted around the durable transcript. */\nexport interface EDAProjectedPromptContext {\n /** Instruction messages placed after durable system context and before transcript history. */\n readonly instructions: ReadonlyArray<Prompt.SystemMessage>;\n /** Data messages placed after transcript history and before scheduler-selected user messages. */\n readonly messages: ReadonlyArray<Prompt.UserMessage>;\n}\n\n/** Host-extensible projection from durable state into provider prompt context. */\nexport interface EDAPromptProjectorShape {\n readonly projectContext: (\n input: EDAPromptProjectionInput,\n ) => Effect.Effect<EDAProjectedPromptContext>;\n readonly projectState: (input: EDAPromptProjectionInput) => Effect.Effect<ReducedState>;\n}\n\n/** Build a provider prompt entirely from the current durable state projection. */\nexport const buildEDAPrompt = (\n projector: EDAPromptProjectorShape,\n input: EDAPromptProjectionInput,\n): Effect.Effect<Prompt.Prompt> =>\n Effect.gen(function* () {\n const state = yield* projector.projectState(input);\n const context = yield* projector.projectContext(input);\n const transcript = contextProjectionPrompt(state, input.context);\n const instructionBoundary = firstNonSystemMessageIndex(transcript.content);\n return Prompt.fromMessages([\n ...transcript.content.slice(0, instructionBoundary),\n ...context.instructions,\n ...transcript.content.slice(instructionBoundary),\n ...context.messages,\n ]);\n });\n\nconst firstNonSystemMessageIndex = (messages: ReadonlyArray<Prompt.Message>): number => {\n const index = messages.findIndex((message) => message.role !== \"system\");\n return index === -1 ? messages.length : index;\n};\n\n/** Service that lets apps derive LLM context independently from UI projections. */\nexport class EDAPromptProjector extends Context.Service<\n EDAPromptProjector,\n EDAPromptProjectorShape\n>()(\"@effect-durable-agent/EDAPromptProjector\") {\n static readonly Default = Layer.succeed(EDAPromptProjector, {\n projectContext: () => Effect.succeed({ instructions: [], messages: [] }),\n projectState: (input) => Effect.succeed(input.state),\n } satisfies EDAPromptProjectorShape);\n}\n"],"mappings":";;;;;;;AAoCA,MAAa,kBACX,WACA,UAEA,OAAO,IAAI,aAAa;CACtB,MAAM,QAAQ,OAAO,UAAU,aAAa,KAAK;CACjD,MAAM,UAAU,OAAO,UAAU,eAAe,KAAK;CACrD,MAAM,aAAa,wBAAwB,OAAO,MAAM,OAAO;CAC/D,MAAM,sBAAsB,2BAA2B,WAAW,OAAO;CACzE,OAAO,OAAO,aAAa;EACzB,GAAG,WAAW,QAAQ,MAAM,GAAG,mBAAmB;EAClD,GAAG,QAAQ;EACX,GAAG,WAAW,QAAQ,MAAM,mBAAmB;EAC/C,GAAG,QAAQ;CACb,CAAC;AACH,CAAC;AAEH,MAAM,8BAA8B,aAAoD;CACtF,MAAM,QAAQ,SAAS,WAAW,YAAY,QAAQ,SAAS,QAAQ;CACvE,OAAO,UAAU,KAAK,SAAS,SAAS;AAC1C;;AAGA,IAAa,qBAAb,MAAa,2BAA2B,QAAQ,QAG9C,CAAC,CAAC,0CAA0C,CAAC,CAAC;CAC9C,OAAgB,UAAU,MAAM,QAAQ,oBAAoB;EAC1D,sBAAsB,OAAO,QAAQ;GAAE,cAAc,CAAC;GAAG,UAAU,CAAC;EAAE,CAAC;EACvE,eAAe,UAAU,OAAO,QAAQ,MAAM,KAAK;CACrD,CAAmC;AACrC"}
@@ -1,2 +1,2 @@
1
- import { a as EDAReducerStateSnapshot, c as decodeReducerState, d as encodeReducerState, f as getEDAReducerState, i as EDAReducerRegistryShape, l as defineEDAReducerRegistry, n as EDAReducerDefinition, o as EDAReducersFor, p as reducerSchemaVersion, r as EDAReducerRegistry, s as EDATypedReducerRegistry, t as EDAReducer, u as edaReservedReducerNamePrefix } from "../reducer-registry-nO4biZlg.js";
1
+ import { a as EDAReducerStateSnapshot, c as decodeReducerState, d as encodeReducerState, f as getEDAReducerState, i as EDAReducerRegistryShape, l as defineEDAReducerRegistry, n as EDAReducerDefinition, o as EDAReducersFor, p as reducerSchemaVersion, r as EDAReducerRegistry, s as EDATypedReducerRegistry, t as EDAReducer, u as edaReservedReducerNamePrefix } from "../reducer-registry-C3ZidOI1.js";
2
2
  export { EDAReducer, EDAReducerDefinition, EDAReducerRegistry, EDAReducerRegistryShape, EDAReducerStateSnapshot, EDAReducersFor, EDATypedReducerRegistry, decodeReducerState, defineEDAReducerRegistry, edaReservedReducerNamePrefix, encodeReducerState, getEDAReducerState, reducerSchemaVersion };
@@ -1 +1 @@
1
- {"version":3,"file":"reducer-registry.js","names":[],"sources":["../../src/services/reducer-registry.ts"],"sourcesContent":["import type { DurableEventEnvelope } from \"../types/events\";\nimport * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport { selectCommittedEvent, type CommittedDurableEvent } from \"./session-store\";\n\n/** Input accepted by the reducer constructor before schema codecs are materialized. */\nexport interface EDAReducerDefinition<\n State,\n Name extends string = string,\n E = import(\"../types/events/durable\").DecodedDurableEvent,\n> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n readonly encode?: (state: State) => unknown;\n readonly decode?: (payload: unknown) => State;\n /** Return the next state without mutating the input; projections may be shared across sinks. */\n reduce(state: State, event: CommittedDurableEvent<E>): State;\n}\n\n/** App-specific pure reducer over the durable session event log. */\nexport interface EDAReducer<State = unknown, Name extends string = string> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n encode(state: State): unknown;\n decode(payload: unknown): State;\n /** Return the next state without mutating the input; projections may be shared across sinks. */\n reduce(state: State, event: CommittedDurableEvent): State;\n}\n\n/** Convenience constructor preserving a reducer's literal name and schema-derived state type. */\nexport const EDAReducer = {\n /** Select and narrow reducer input from one event schema; malformed registered events fail in the store. */\n forEvents: <E extends DurableEventEnvelope, State, const Name extends string>(\n events: Schema.Codec<E, unknown, never, never>,\n reducer: EDAReducerDefinition<State, Name, E>,\n ): EDAReducer<State, Name> =>\n EDAReducer.make({\n ...reducer,\n reduce: (state, entry) => {\n const selected = selectCommittedEvent(events, entry);\n return selected === undefined ? state : reducer.reduce(state, selected);\n },\n }),\n make: <State, const Name extends string = string>(\n reducer: EDAReducerDefinition<State, Name>,\n ): EDAReducer<State, Name> => ({\n ...reducer,\n encode: reducer.encode ?? ((state) => Schema.encodeUnknownSync(reducer.stateSchema)(state)),\n decode: reducer.decode ?? ((payload) => Schema.decodeUnknownSync(reducer.stateSchema)(payload)),\n }),\n};\n\n/** Snapshot of all app reducer states, keyed by reducer name. */\nexport type EDAReducerStateSnapshot = ReadonlyMap<string, unknown>;\n\ninterface EDASerializedReducerState {\n readonly name: string;\n readonly state: unknown;\n}\n\ntype EDAReducerStateForName<\n Entry extends EDASerializedReducerState,\n Name extends Entry[\"name\"],\n> = Extract<Entry, { readonly name: Name }>[\"state\"];\n\n/** Exact reducer object required for every member of a serialized state union. */\nexport type EDAReducersFor<Entry extends EDASerializedReducerState> = {\n readonly [Name in Entry[\"name\"]]: EDAReducer<EDAReducerStateForName<Entry, Name>, Name>;\n};\n\n/** Schema-backed app reducer registry used by both runtime folding and snapshot serialization. */\nexport interface EDATypedReducerRegistry<\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n> {\n readonly entrySchema: EntrySchema;\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly serialize: (snapshot: EDAReducerStateSnapshot) => ReadonlyArray<EntrySchema[\"Type\"]>;\n}\n\nconst reducerValues = (reducers: Readonly<Record<string, EDAReducer>>): ReadonlyArray<EDAReducer> =>\n Object.values(reducers);\n\n/**\n * Register an app's complete reducer set against its public serialized-state union.\n *\n * Missing reducers, extra reducers, reducer-name drift, and state-schema drift are\n * rejected by TypeScript at the registration site.\n */\nexport const defineEDAReducerRegistry = <\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n>(\n entrySchema: EntrySchema,\n reducers: EDAReducersFor<EntrySchema[\"Type\"]>,\n): EDATypedReducerRegistry<EntrySchema> => {\n const values = reducerValues(reducers);\n const serializedStatesSchema = Schema.Array(entrySchema);\n return {\n entrySchema,\n reducers: values,\n serialize: (snapshot) =>\n Schema.decodeUnknownSync(serializedStatesSchema)(\n values.map((reducer) => ({\n name: reducer.name,\n state: snapshot.get(reducer.name) ?? reducer.initial,\n })),\n ),\n };\n};\n\n/** Registry that folds app-specific read-model state beside EDA reduced state. */\nexport interface EDAReducerRegistryShape {\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly initial: EDAReducerStateSnapshot;\n readonly reduce: (\n state: EDAReducerStateSnapshot,\n events: ReadonlyArray<CommittedDurableEvent>,\n ) => EDAReducerStateSnapshot;\n}\n\n/** Prefix reserved for framework-owned reducer checkpoints. */\nexport const edaReservedReducerNamePrefix = \"_eda.\";\n\n/** Return the persisted schema version for one reducer. */\nexport const reducerSchemaVersion = (reducer: EDAReducer): number => reducer.schemaVersion ?? 1;\n\n/** Encode one reducer state for durable checkpoint storage. */\nexport const encodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n state: State,\n): unknown => reducer.encode(state);\n\n/** Decode one reducer state from durable checkpoint storage. */\nexport const decodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n payload: unknown,\n): State => reducer.decode(payload);\n\n/** Registry for app-specific durable metadata reducers. */\nexport class EDAReducerRegistry extends Context.Service<\n EDAReducerRegistry,\n EDAReducerRegistryShape\n>()(\"@effect-durable-agent/EDAReducerRegistry\") {\n static readonly Empty = Layer.succeed(EDAReducerRegistry, makeReducerRegistry([]));\n\n static readonly Live = (reducers: ReadonlyArray<EDAReducer>) =>\n Layer.succeed(EDAReducerRegistry, makeReducerRegistry(reducers));\n}\n\n/** Read one typed reducer state from a snapshot. */\nexport const getEDAReducerState = <State, Name extends string>(\n snapshot: EDAReducerStateSnapshot,\n reducer: EDAReducer<State, Name>,\n): State => {\n const state = snapshot.get(reducer.name);\n if (state === undefined) return reducer.initial;\n if (Schema.is(reducer.stateSchema)(state)) return state;\n throw new Error(`Invalid in-memory reducer state for ${reducer.name}`);\n};\n\nfunction makeReducerRegistry(reducers: ReadonlyArray<EDAReducer>): EDAReducerRegistryShape {\n validateReducerNames(reducers);\n const initial = new Map(reducers.map((reducer) => [reducer.name, reducer.initial]));\n return {\n reducers,\n initial,\n reduce: (state, events) => {\n if (events.length === 0 || reducers.length === 0) {\n return state;\n }\n const next = new Map(state);\n for (const event of events) {\n for (const reducer of reducers) {\n const current = next.get(reducer.name) ?? reducer.initial;\n next.set(reducer.name, reducer.reduce(current, event));\n }\n }\n return next;\n },\n };\n}\n\nfunction validateReducerNames(reducers: ReadonlyArray<EDAReducer>): void {\n const seen = new Set<string>();\n for (const reducer of reducers) {\n if (reducer.name.startsWith(edaReservedReducerNamePrefix)) {\n throw new Error(\n `Reducer name ${reducer.name} uses reserved EDA prefix ${edaReservedReducerNamePrefix}`,\n );\n }\n if (seen.has(reducer.name)) {\n throw new Error(`Duplicate EDA reducer name ${reducer.name}`);\n }\n seen.add(reducer.name);\n }\n}\n"],"mappings":";;;;;;AAoCA,MAAa,aAAa;;CAExB,YACE,QACA,YAEA,WAAW,KAAK;EACd,GAAG;EACH,SAAS,OAAO,UAAU;GACxB,MAAM,WAAW,qBAAqB,QAAQ,KAAK;GACnD,OAAO,aAAa,KAAA,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,qBAAqB,QAAQ;CAE7B,OAAO;EACL;EACA,SAAA,IAHkB,IAAI,SAAS,KAAK,YAAY,CAAC,QAAQ,MAAM,QAAQ,OAAO,CAAC,CAGzE;EACN,SAAS,OAAO,WAAW;GACzB,IAAI,OAAO,WAAW,KAAK,SAAS,WAAW,GAC7C,OAAO;GAET,MAAM,OAAO,IAAI,IAAI,KAAK;GAC1B,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,UAAU,KAAK,IAAI,QAAQ,IAAI,KAAK,QAAQ;IAClD,KAAK,IAAI,QAAQ,MAAM,QAAQ,OAAO,SAAS,KAAK,CAAC;GACvD;GAEF,OAAO;EACT;CACF;AACF;AAEA,SAAS,qBAAqB,UAA2C;CACvE,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,KAAK,WAAA,OAAuC,GACtD,MAAM,IAAI,MACR,gBAAgB,QAAQ,KAAK,4BAA4B,8BAC3D;EAEF,IAAI,KAAK,IAAI,QAAQ,IAAI,GACvB,MAAM,IAAI,MAAM,8BAA8B,QAAQ,MAAM;EAE9D,KAAK,IAAI,QAAQ,IAAI;CACvB;AACF"}
1
+ {"version":3,"file":"reducer-registry.js","names":[],"sources":["../../src/services/reducer-registry.ts"],"sourcesContent":["import type { DurableEventEnvelope } from \"../types/events\";\nimport * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport { selectCommittedEvent, type CommittedDurableEvent } from \"./session-store\";\n\n/** Input accepted by the reducer constructor before schema codecs are materialized. */\nexport interface EDAReducerDefinition<\n State,\n Name extends string = string,\n E = import(\"../types/events/durable\").DecodedDurableEvent,\n> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n readonly encode?: (state: State) => unknown;\n readonly decode?: (payload: unknown) => State;\n /** Return the next state without mutating the input; projections may be shared across sinks. */\n reduce(state: State, event: CommittedDurableEvent<E>): State;\n}\n\n/** App-specific pure reducer over the durable session event log. */\nexport interface EDAReducer<State = unknown, Name extends string = string> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n encode(state: State): unknown;\n decode(payload: unknown): State;\n /** Return the next state without mutating the input; projections may be shared across sinks. */\n reduce(state: State, event: CommittedDurableEvent): State;\n}\n\n/** Convenience constructor preserving a reducer's literal name and schema-derived state type. */\nexport const EDAReducer = {\n /** Select and narrow reducer input from one event schema; malformed registered events fail in the store. */\n forEvents: <E extends DurableEventEnvelope, State, const Name extends string>(\n events: Schema.Codec<E, unknown, never, never>,\n reducer: EDAReducerDefinition<State, Name, E>,\n ): EDAReducer<State, Name> =>\n EDAReducer.make({\n ...reducer,\n reduce: (state, entry) => {\n const selected = selectCommittedEvent(events, entry);\n return selected === undefined ? state : reducer.reduce(state, selected);\n },\n }),\n make: <State, const Name extends string = string>(\n reducer: EDAReducerDefinition<State, Name>,\n ): EDAReducer<State, Name> => ({\n ...reducer,\n encode: reducer.encode ?? ((state) => Schema.encodeUnknownSync(reducer.stateSchema)(state)),\n decode: reducer.decode ?? ((payload) => Schema.decodeUnknownSync(reducer.stateSchema)(payload)),\n }),\n};\n\n/** Snapshot of all app reducer states, keyed by reducer name. */\nexport type EDAReducerStateSnapshot = ReadonlyMap<string, unknown>;\n\ninterface EDASerializedReducerState {\n readonly name: string;\n readonly state: unknown;\n}\n\ntype EDAReducerStateForName<\n Entry extends EDASerializedReducerState,\n Name extends Entry[\"name\"],\n> = Extract<Entry, { readonly name: Name }>[\"state\"];\n\n/** Exact reducer object required for every member of a serialized state union. */\nexport type EDAReducersFor<Entry extends EDASerializedReducerState> = {\n readonly [Name in Entry[\"name\"]]: EDAReducer<EDAReducerStateForName<Entry, Name>, Name>;\n};\n\n/** Schema-backed app reducer registry used by both runtime folding and snapshot serialization. */\nexport interface EDATypedReducerRegistry<\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n> {\n readonly entrySchema: EntrySchema;\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly serialize: (snapshot: EDAReducerStateSnapshot) => ReadonlyArray<EntrySchema[\"Type\"]>;\n}\n\nconst reducerValues = (reducers: Readonly<Record<string, EDAReducer>>): ReadonlyArray<EDAReducer> =>\n Object.values(reducers);\n\n/**\n * Register an app's complete reducer set against its public serialized-state union.\n *\n * Missing reducers, extra reducers, reducer-name drift, and state-schema drift are\n * rejected by TypeScript at the registration site.\n */\nexport const defineEDAReducerRegistry = <\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n>(\n entrySchema: EntrySchema,\n reducers: EDAReducersFor<EntrySchema[\"Type\"]>,\n): EDATypedReducerRegistry<EntrySchema> => {\n const values = reducerValues(reducers);\n const serializedStatesSchema = Schema.Array(entrySchema);\n return {\n entrySchema,\n reducers: values,\n serialize: (snapshot) =>\n Schema.decodeUnknownSync(serializedStatesSchema)(\n values.map((reducer) => ({\n name: reducer.name,\n state: snapshot.get(reducer.name) ?? reducer.initial,\n })),\n ),\n };\n};\n\n/** Registry that folds app-specific read-model state beside EDA reduced state. */\nexport interface EDAReducerRegistryShape {\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly initial: EDAReducerStateSnapshot;\n readonly reduce: (\n state: EDAReducerStateSnapshot,\n events: ReadonlyArray<CommittedDurableEvent>,\n ) => EDAReducerStateSnapshot;\n}\n\n/** Prefix reserved for framework-owned reducer checkpoints. */\nexport const edaReservedReducerNamePrefix = \"_eda.\";\n\n/** Return the persisted schema version for one reducer. */\nexport const reducerSchemaVersion = (reducer: EDAReducer): number => reducer.schemaVersion ?? 1;\n\n/** Encode one reducer state for durable checkpoint storage. */\nexport const encodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n state: State,\n): unknown => reducer.encode(state);\n\n/** Decode one reducer state from durable checkpoint storage. */\nexport const decodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n payload: unknown,\n): State => reducer.decode(payload);\n\n/** Registry for app-specific durable metadata reducers. */\nexport class EDAReducerRegistry extends Context.Service<\n EDAReducerRegistry,\n EDAReducerRegistryShape\n>()(\"@effect-durable-agent/EDAReducerRegistry\") {\n static readonly Empty = Layer.succeed(EDAReducerRegistry, makeReducerRegistry([]));\n\n static readonly Live = (reducers: ReadonlyArray<EDAReducer>) =>\n Layer.succeed(EDAReducerRegistry, makeReducerRegistry(reducers));\n}\n\n/** Read one typed reducer state from a snapshot. */\nexport const getEDAReducerState = <State, Name extends string>(\n snapshot: EDAReducerStateSnapshot,\n reducer: EDAReducer<State, Name>,\n): State => {\n const state = snapshot.get(reducer.name);\n if (state === undefined) return reducer.initial;\n if (Schema.is(reducer.stateSchema)(state)) return state;\n throw new Error(`Invalid in-memory reducer state for ${reducer.name}`);\n};\n\nfunction makeReducerRegistry(reducers: ReadonlyArray<EDAReducer>): EDAReducerRegistryShape {\n validateReducerNames(reducers);\n const initial = new Map(reducers.map((reducer) => [reducer.name, reducer.initial]));\n return {\n reducers,\n initial,\n reduce: (state, events) => {\n if (events.length === 0 || reducers.length === 0) {\n return state;\n }\n const next = new Map(state);\n for (const event of events) {\n for (const reducer of reducers) {\n const current = next.get(reducer.name) ?? reducer.initial;\n next.set(reducer.name, reducer.reduce(current, event));\n }\n }\n return next;\n },\n };\n}\n\nfunction validateReducerNames(reducers: ReadonlyArray<EDAReducer>): void {\n const seen = new Set<string>();\n for (const reducer of reducers) {\n if (reducer.name.startsWith(edaReservedReducerNamePrefix)) {\n throw new Error(\n `Reducer name ${reducer.name} uses reserved EDA prefix ${edaReservedReducerNamePrefix}`,\n );\n }\n if (seen.has(reducer.name)) {\n throw new Error(`Duplicate EDA reducer name ${reducer.name}`);\n }\n seen.add(reducer.name);\n }\n}\n"],"mappings":";;;;;;AAoCA,MAAa,aAAa;;CAExB,YACE,QACA,YAEA,WAAW,KAAK;EACd,GAAG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Q,WAAW,CAAC,CAAC,KAAK,GAAG,OAAO;CAClD,MAAM,IAAI,MAAM,uCAAuC,QAAQ,MAAM;AACvE;AAEA,SAAS,oBAAoB,UAA8D;CACzF,qBAAqB,QAAQ;CAE7B,OAAO;EACL;EACA,SAAA,IAHkB,IAAI,SAAS,KAAK,YAAY,CAAC,QAAQ,MAAM,QAAQ,OAAO,CAAC,CAGzE;EACN,SAAS,OAAO,WAAW;GACzB,IAAI,OAAO,WAAW,KAAK,SAAS,WAAW,GAC7C,OAAO;GAET,MAAM,OAAO,IAAI,IAAI,KAAK;GAC1B,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,UAAU,KAAK,IAAI,QAAQ,IAAI,KAAK,QAAQ;IAClD,KAAK,IAAI,QAAQ,MAAM,QAAQ,OAAO,SAAS,KAAK,CAAC;GACvD;GAEF,OAAO;EACT;CACF;AACF;AAEA,SAAS,qBAAqB,UAA2C;CACvE,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,KAAK,WAAA,OAAuC,GACtD,MAAM,IAAI,MACR,gBAAgB,QAAQ,KAAK,4BAA4B,8BAC3D;EAEF,IAAI,KAAK,IAAI,QAAQ,IAAI,GACvB,MAAM,IAAI,MAAM,8BAA8B,QAAQ,MAAM;EAE9D,KAAK,IAAI,QAAQ,IAAI;CACvB;AACF"}
@@ -1,3 +1,2 @@
1
- import { X as DeferredRunResolution, Z as LocalRunResolution, et as RunResolution, nt as RunSchedulingInput } from "../command-queues-w9WUKTpM.js";
2
- import { i as RunSchedulingDeliveryError, n as RunSchedulerShape, r as RunSchedulingDelivery, t as RunScheduler } from "../run-scheduler-DFBqIRzF.js";
1
+ import { Ft as DeferredRunResolution, It as LocalRunResolution, Mt as RunSchedulerShape, Nt as RunSchedulingDelivery, Pt as RunSchedulingDeliveryError, Vt as RunSchedulingInput, jt as RunScheduler, zt as RunResolution } from "../reduced-state-DrSHn_47.js";
3
2
  export { DeferredRunResolution, LocalRunResolution, type RunResolution, RunScheduler, RunSchedulerShape, RunSchedulingDelivery, RunSchedulingDeliveryError, type RunSchedulingInput };
@@ -1 +1 @@
1
- {"version":3,"file":"run-scheduler.js","names":[],"sources":["../../src/services/run-scheduler.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport {\n DeferredRunResolution,\n LocalRunResolution,\n type RunResolution,\n type RunSchedulingInput,\n type RunSchedulingRequest,\n} from \"../domain/run-scheduling\";\nimport type { SessionId } from \"../types/core\";\n\nexport {\n DeferredRunResolution,\n LocalRunResolution,\n type RunResolution,\n type RunSchedulingInput,\n} from \"../domain/run-scheduling\";\n\n/** Recoverable failure delivering a persisted request; it never acknowledges that request. */\nexport class RunSchedulingDeliveryError extends Schema.TaggedErrorClass<RunSchedulingDeliveryError>()(\n \"RunSchedulingDeliveryError\",\n {\n message: Schema.String,\n },\n) {}\n\n/** At-least-once outbound delivery, separate from the serialized run-start decision. */\nexport type RunSchedulingDelivery = (input: {\n readonly sessionId: SessionId;\n readonly request: RunSchedulingRequest;\n}) => Effect.Effect<void, RunSchedulingDeliveryError>;\n\n/**\n * Run-start boundary called by SessionState after pure dispatch or recovery policy\n * selects work, before allocating its run ID or committing RunStarted.\n *\n * Resolution must finish promptly with Local or Deferred intent and must not contact\n * an external scheduler. SessionState persists Deferred intent before calling deliver\n * outside the control loop. A successful delivery must mean the scheduler durably\n * accepted responsibility for the request and will retry its trusted grant callback.\n * Calls may repeat after a restart; command identity is not an exactly-once key.\n */\nexport interface RunSchedulerShape {\n readonly resolve: (input: RunSchedulingInput) => Effect.Effect<RunResolution>;\n readonly deliver: RunSchedulingDelivery;\n}\n\n/** Replaceable run-start integration, independent of persistence and host SDKs. */\nexport class RunScheduler extends Context.Service<RunScheduler, RunSchedulerShape>()(\n \"@effect-durable-agent/RunScheduler\",\n) {\n /** Preserve local execution without allocating IDs, issuing commands, or writing events. */\n static readonly Immediate = Layer.succeed(RunScheduler, {\n resolve: () => Effect.succeed(LocalRunResolution.make({})),\n deliver: () => Effect.die(new Error(\"Immediate RunScheduler cannot deliver deferred requests\")),\n });\n\n /** Defer every new run to a durable, idempotent external authorizer. */\n static readonly Deferred = (deliver: RunSchedulingDelivery) =>\n Layer.succeed(RunScheduler, {\n resolve: () => Effect.succeed(DeferredRunResolution.make({})),\n deliver,\n });\n}\n"],"mappings":";;;;;;;AAsBA,IAAa,6BAAb,cAAgD,OAAO,iBAA6C,EAClG,8BACA,EACE,SAAS,OAAO,OAClB,CACF,EAAE,CAAC;;AAwBH,IAAa,eAAb,MAAa,qBAAqB,QAAQ,QAAyC,EACjF,oCACF,EAAE;;CAEA,OAAgB,YAAY,MAAM,QAAQ,cAAc;EACtD,eAAe,OAAO,QAAQ,mBAAmB,KAAK,CAAC,CAAC,CAAC;EACzD,eAAe,OAAO,oBAAI,IAAI,MAAM,yDAAyD,CAAC;CAChG,CAAC;;CAGD,OAAgB,YAAY,YAC1B,MAAM,QAAQ,cAAc;EAC1B,eAAe,OAAO,QAAQ,sBAAsB,KAAK,CAAC,CAAC,CAAC;EAC5D;CACF,CAAC;AACL"}
1
+ {"version":3,"file":"run-scheduler.js","names":[],"sources":["../../src/services/run-scheduler.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport {\n DeferredRunResolution,\n LocalRunResolution,\n type RunResolution,\n type RunSchedulingInput,\n type RunSchedulingRequest,\n} from \"../domain/run-scheduling\";\nimport type { SessionId } from \"../types/core\";\n\nexport {\n DeferredRunResolution,\n LocalRunResolution,\n type RunResolution,\n type RunSchedulingInput,\n} from \"../domain/run-scheduling\";\n\n/** Recoverable failure delivering a persisted request; it never acknowledges that request. */\nexport class RunSchedulingDeliveryError extends Schema.TaggedErrorClass<RunSchedulingDeliveryError>()(\n \"RunSchedulingDeliveryError\",\n {\n message: Schema.String,\n },\n) {}\n\n/** At-least-once outbound delivery, separate from the serialized run-start decision. */\nexport type RunSchedulingDelivery = (input: {\n readonly sessionId: SessionId;\n readonly request: RunSchedulingRequest;\n}) => Effect.Effect<void, RunSchedulingDeliveryError>;\n\n/**\n * Run-start boundary called by SessionState after pure dispatch or recovery policy\n * selects work, before allocating its run ID or committing RunStarted.\n *\n * Resolution must finish promptly with Local or Deferred intent and must not contact\n * an external scheduler. SessionState persists Deferred intent before calling deliver\n * outside the control loop. A successful delivery must mean the scheduler durably\n * accepted responsibility for the request and will retry its trusted grant callback.\n * Calls may repeat after a restart; command identity is not an exactly-once key.\n */\nexport interface RunSchedulerShape {\n readonly resolve: (input: RunSchedulingInput) => Effect.Effect<RunResolution>;\n readonly deliver: RunSchedulingDelivery;\n}\n\n/** Replaceable run-start integration, independent of persistence and host SDKs. */\nexport class RunScheduler extends Context.Service<RunScheduler, RunSchedulerShape>()(\n \"@effect-durable-agent/RunScheduler\",\n) {\n /** Preserve local execution without allocating IDs, issuing commands, or writing events. */\n static readonly Immediate = Layer.succeed(RunScheduler, {\n resolve: () => Effect.succeed(LocalRunResolution.make({})),\n deliver: () => Effect.die(new Error(\"Immediate RunScheduler cannot deliver deferred requests\")),\n });\n\n /** Defer every new run to a durable, idempotent external authorizer. */\n static readonly Deferred = (deliver: RunSchedulingDelivery) =>\n Layer.succeed(RunScheduler, {\n resolve: () => Effect.succeed(DeferredRunResolution.make({})),\n deliver,\n });\n}\n"],"mappings":";;;;;;;AAsBA,IAAa,6BAAb,cAAgD,OAAO,iBAA6C,CAAC,CACnG,8BACA,EACE,SAAS,OAAO,OAClB,CACF,CAAC,CAAC,CAAC;;AAwBH,IAAa,eAAb,MAAa,qBAAqB,QAAQ,QAAyC,CAAC,CAClF,oCACF,CAAC,CAAC;;CAEA,OAAgB,YAAY,MAAM,QAAQ,cAAc;EACtD,eAAe,OAAO,QAAQ,mBAAmB,KAAK,CAAC,CAAC,CAAC;EACzD,eAAe,OAAO,oBAAI,IAAI,MAAM,yDAAyD,CAAC;CAChG,CAAC;;CAGD,OAAgB,YAAY,YAC1B,MAAM,QAAQ,cAAc;EAC1B,eAAe,OAAO,QAAQ,sBAAsB,KAAK,CAAC,CAAC,CAAC;EAC5D;CACF,CAAC;AACL"}
@@ -1,2 +1,2 @@
1
- import { n as RunSchedulingWakeupShape, t as RunSchedulingWakeup } from "../run-scheduling-wakeup-CXT5_CkI.js";
1
+ import { n as RunSchedulingWakeupShape, t as RunSchedulingWakeup } from "../run-scheduling-wakeup-COUj3r_B.js";
2
2
  export { RunSchedulingWakeup, RunSchedulingWakeupShape };
@@ -1 +1 @@
1
- {"version":3,"file":"run-scheduling-wakeup.js","names":[],"sources":["../../src/services/run-scheduling-wakeup.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport type { EDASessionStoreError } from \"./session-store\";\n\n/**\n * Host-owned durable retry obligation for undelivered run authorization requests.\n * setPending(true) must arm a wakeup before returning, survive eviction, and keep\n * retrying until setPending(false). The callback invokes retryRunSchedulingDelivery.\n * Hosts must reconcile this obligation with their active-work alarms, never delete\n * it when an unrelated lease ends, and reconstruct it before recovery releases work.\n */\nexport interface RunSchedulingWakeupShape {\n readonly setPending: (pending: boolean) => Effect.Effect<void, EDASessionStoreError>;\n}\n\n/** Required durable host capability when a scheduler can resolve Deferred. */\nexport class RunSchedulingWakeup extends Context.Service<\n RunSchedulingWakeup,\n RunSchedulingWakeupShape\n>()(\"@effect-durable-agent/RunSchedulingWakeup\") {\n /** Immediate runtimes need no wakeup; fail before persisting unsupported deferral. */\n static readonly Unsupported = Layer.succeed(RunSchedulingWakeup, {\n setPending: (pending) =>\n pending\n ? Effect.die(\n new Error(\n \"Deferred run scheduling requires a durable RunSchedulingWakeup host adapter\",\n ),\n )\n : Effect.void,\n });\n}\n"],"mappings":";;;;;AAkBA,IAAa,sBAAb,MAAa,4BAA4B,QAAQ,QAG/C,EAAE,2CAA2C,EAAE;;CAE/C,OAAgB,cAAc,MAAM,QAAQ,qBAAqB,EAC/D,aAAa,YACX,UACI,OAAO,oBACL,IAAI,MACF,6EACF,CACF,IACA,OAAO,KACf,CAAC;AACH"}
1
+ {"version":3,"file":"run-scheduling-wakeup.js","names":[],"sources":["../../src/services/run-scheduling-wakeup.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport type { EDASessionStoreError } from \"./session-store\";\n\n/**\n * Host-owned durable retry obligation for undelivered run authorization requests.\n * setPending(true) must arm a wakeup before returning, survive eviction, and keep\n * retrying until setPending(false). The callback invokes retryRunSchedulingDelivery.\n * Hosts must reconcile this obligation with their active-work alarms, never delete\n * it when an unrelated lease ends, and reconstruct it before recovery releases work.\n */\nexport interface RunSchedulingWakeupShape {\n readonly setPending: (pending: boolean) => Effect.Effect<void, EDASessionStoreError>;\n}\n\n/** Required durable host capability when a scheduler can resolve Deferred. */\nexport class RunSchedulingWakeup extends Context.Service<\n RunSchedulingWakeup,\n RunSchedulingWakeupShape\n>()(\"@effect-durable-agent/RunSchedulingWakeup\") {\n /** Immediate runtimes need no wakeup; fail before persisting unsupported deferral. */\n static readonly Unsupported = Layer.succeed(RunSchedulingWakeup, {\n setPending: (pending) =>\n pending\n ? Effect.die(\n new Error(\n \"Deferred run scheduling requires a durable RunSchedulingWakeup host adapter\",\n ),\n )\n : Effect.void,\n });\n}\n"],"mappings":";;;;;AAkBA,IAAa,sBAAb,MAAa,4BAA4B,QAAQ,QAG/C,CAAC,CAAC,2CAA2C,CAAC,CAAC;;CAE/C,OAAgB,cAAc,MAAM,QAAQ,qBAAqB,EAC/D,aAAa,YACX,UACI,OAAO,oBACL,IAAI,MACF,6EACF,CACF,IACA,OAAO,KACf,CAAC;AACH"}
@@ -1,20 +1,15 @@
1
- import { g as SessionId } from "../core-C-6xHzRx.js";
2
- import { i as EDAAppEvents, o as EDASessionStore, s as EDASessionStoreError } from "../session-store-DBa-TOVH.js";
3
- import { t as ModelResolver } from "../model-resolver-ci5D5WQv.js";
4
- import { t as EDAKeepAlive } from "../keep-alive-Chl5SJxy.js";
5
- import { c as CompactionPolicy, r as CompactionExecutor } from "../compaction-DhIJ-sAH.js";
6
- import { t as SessionEventObserver } from "../session-event-observer-BWppl2Fr.js";
7
- import { i as EDARuntimeConfig, m as SessionCommandAdmissionError, r as EDARuntime } from "../index-DWC70Fsi.js";
8
- import { r as EDAReducerRegistry } from "../reducer-registry-nO4biZlg.js";
9
- import { r as EDAPromptProjector } from "../prompt-projector-DvNHsoEN.js";
10
- import { n as SinkCheckpointStore } from "../sink-checkpoint-store-BZGfJLve.js";
11
- import { s as EDASink } from "../sink-registry-tpmJ-Dhf.js";
12
- import { t as RunScheduler } from "../run-scheduler-DFBqIRzF.js";
13
- import { t as RunSchedulingWakeup } from "../run-scheduling-wakeup-CXT5_CkI.js";
14
- import { i as EDAToolRegistryShape, t as EDAModelToolkit } from "../tool-registry-NOP9aTHT.js";
1
+ import { g as SessionId } from "../core-BcimKMIv.js";
2
+ import { i as EDAAppEvents, o as EDASessionStore, s as EDASessionStoreError } from "../session-store-B_vh581h.js";
3
+ import { t as ModelResolver } from "../model-resolver-BHYVHsam.js";
4
+ import { K as EDARuntime, dt as SessionCommandAdmissionError, jt as RunScheduler, nn as EDASink, pn as EDAPromptProjector, q as EDARuntimeConfig, wn as CompactionPolicy, yn as CompactionExecutor } from "../reduced-state-DrSHn_47.js";
5
+ import { t as EDAKeepAlive } from "../keep-alive-_zFCUvt3.js";
6
+ import { t as SessionEventObserver } from "../session-event-observer-BDwja1jX.js";
7
+ import { r as EDAReducerRegistry } from "../reducer-registry-C3ZidOI1.js";
8
+ import { n as SinkCheckpointStore } from "../sink-checkpoint-store-2SxoNMbI.js";
9
+ import { t as RunSchedulingWakeup } from "../run-scheduling-wakeup-COUj3r_B.js";
10
+ import { i as EDAToolRegistryShape, t as EDAModelToolkit } from "../tool-registry-DDxbmMpY.js";
15
11
  import * as Layer from "effect/Layer";
16
12
  import * as Tracer from "effect/Tracer";
17
-
18
13
  //#region src/services/runtime-layer.d.ts
19
14
  /**
20
15
  * Host-owned adapters and application policy needed to construct one EDA runtime.
@@ -44,26 +39,7 @@ interface EDARuntimeLayerOptions {
44
39
  readonly tracer?: Tracer.Tracer;
45
40
  }
46
41
  /** Compose the complete platform-neutral EDA service graph for one session. */
47
- declare const makeEDARuntimeLayer: ({
48
- appEvents,
49
- config,
50
- compactionExecutorLayer,
51
- compactionPolicyLayer,
52
- keepAliveLayer,
53
- modelResolverLayer,
54
- promptProjectorLayer,
55
- reducerRegistryLayer,
56
- runSchedulerLayer,
57
- runSchedulingWakeupLayer,
58
- sessionId,
59
- sessionEventObserverLayer,
60
- sessionStoreLayer,
61
- sinkCheckpointStoreLayer,
62
- sinks,
63
- toolkit,
64
- toolRegistry,
65
- tracer
66
- }: EDARuntimeLayerOptions) => Layer.Layer<EDARuntime, SessionCommandAdmissionError>;
42
+ declare const makeEDARuntimeLayer: ({ appEvents, config, compactionExecutorLayer, compactionPolicyLayer, keepAliveLayer, modelResolverLayer, promptProjectorLayer, reducerRegistryLayer, runSchedulerLayer, runSchedulingWakeupLayer, sessionId, sessionEventObserverLayer, sessionStoreLayer, sinkCheckpointStoreLayer, sinks, toolkit, toolRegistry, tracer }: EDARuntimeLayerOptions) => Layer.Layer<EDARuntime, SessionCommandAdmissionError>;
67
43
  //#endregion
68
44
  export { EDARuntimeLayerOptions, makeEDARuntimeLayer };
69
45
  //# sourceMappingURL=runtime-layer.d.ts.map
@@ -1,15 +1,15 @@
1
1
  import { RunSchedulingWakeup } from "./run-scheduling-wakeup.js";
2
2
  import { RunScheduler } from "./run-scheduler.js";
3
- import { d as TurnRunner, f as InferenceRunner, m as LiveEventBus, p as ToolExecutor, u as SessionState } from "../session-state-8PJZvuR3.js";
3
+ import { d as TurnRunner, f as InferenceRunner, m as LiveEventBus, p as ToolExecutor, u as SessionState } from "../session-state-BBzzJrDC.js";
4
4
  import { EDASessionStore, registerAppEvents } from "./session-store.js";
5
- import { a as CompactionPolicy, n as CompactionExecutor, o as CompactionRunner } from "../compaction-Db6eoLce.js";
5
+ import { a as CompactionPolicy, n as CompactionExecutor, o as CompactionRunner } from "../compaction-Bell28K8.js";
6
6
  import { IdGenerator } from "./id-generator.js";
7
7
  import { n as SessionContext, t as EventFactory } from "../event-factory-CKuWhjS4.js";
8
8
  import { EDAKeepAlive } from "./keep-alive.js";
9
9
  import { SessionEventObserver } from "./session-event-observer.js";
10
10
  import { EDAPromptProjector } from "./prompt-projector.js";
11
11
  import { EDAReducerRegistry } from "./reducer-registry.js";
12
- import { n as EDASinkRegistry } from "../sink-registry-B4yxTmlI.js";
12
+ import { n as EDASinkRegistry } from "../sink-registry-ogHu2Sw7.js";
13
13
  import { EDAToolRegistry } from "./tool-registry.js";
14
14
  import { EDASessionQuery } from "./session-query.js";
15
15
  import { EDARuntime } from "./runtime.js";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-layer.js","names":[],"sources":["../../src/services/runtime-layer.ts"],"sourcesContent":["import { ModelResolver } from \"./model-resolver\";\nimport * as Layer from \"effect/Layer\";\nimport * as Tracer from \"effect/Tracer\";\n\nimport type { SessionId } from \"../types/core\";\nimport { CompactionExecutor, CompactionPolicy, CompactionRunner } from \"./compaction\";\nimport { EventFactory } from \"./event-factory\";\nimport { IdGenerator } from \"./id-generator\";\nimport { InferenceRunner } from \"./inference-runner\";\nimport { EDAKeepAlive } from \"./keep-alive\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { EDAPromptProjector } from \"./prompt-projector\";\nimport { EDAReducerRegistry } from \"./reducer-registry\";\nimport { EDARuntime, type EDARuntimeConfig } from \"./runtime\";\nimport { RunScheduler } from \"./run-scheduler\";\nimport { RunSchedulingWakeup } from \"./run-scheduling-wakeup\";\nimport { SessionContext } from \"./session-context\";\nimport { SessionEventObserver } from \"./session-event-observer\";\nimport { EDASessionQuery } from \"./session-query\";\nimport * as Effect from \"effect/Effect\";\nimport {\n registerAppEvents,\n type EDAAppEvents,\n EDASessionStore,\n EDASessionStoreError,\n} from \"./session-store\";\nimport { SessionState, type SessionCommandAdmissionError } from \"./session-state\";\nimport { SinkCheckpointStore } from \"./sink-checkpoint-store\";\nimport { EDASinkRegistry, type EDASink } from \"./sink-registry\";\nimport { ToolExecutor } from \"./tool-executor\";\nimport { EDAToolRegistry, type EDAModelToolkit, type EDAToolRegistryShape } from \"./tool-registry\";\nimport { TurnRunner } from \"./turn-runner\";\n\n/**\n * Host-owned adapters and application policy needed to construct one EDA runtime.\n *\n * Core owns the service graph, while hosts supply only semantic persistence,\n * checkpoint, and lifecycle layers. Platform SDK types never cross this boundary.\n */\nexport interface EDARuntimeLayerOptions {\n /** Complete application event union with literal namespaces, decoded once at the store boundary. */\n readonly appEvents?: EDAAppEvents;\n readonly config: EDARuntimeConfig;\n readonly compactionExecutorLayer?: Layer.Layer<CompactionExecutor>;\n readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;\n readonly keepAliveLayer?: Layer.Layer<EDAKeepAlive>;\n readonly modelResolverLayer: Layer.Layer<ModelResolver>;\n readonly promptProjectorLayer?: Layer.Layer<EDAPromptProjector>;\n readonly reducerRegistryLayer?: Layer.Layer<EDAReducerRegistry>;\n readonly runSchedulerLayer?: Layer.Layer<RunScheduler>;\n readonly runSchedulingWakeupLayer?: Layer.Layer<RunSchedulingWakeup>;\n readonly sessionId: SessionId;\n readonly sessionEventObserverLayer?: Layer.Layer<SessionEventObserver>;\n readonly sessionStoreLayer: Layer.Layer<EDASessionStore, EDASessionStoreError>;\n readonly sinkCheckpointStoreLayer: Layer.Layer<SinkCheckpointStore, EDASessionStoreError>;\n readonly sinks?: ReadonlyArray<EDASink>;\n readonly toolkit?: EDAModelToolkit;\n readonly toolRegistry?: EDAToolRegistryShape;\n readonly tracer?: Tracer.Tracer;\n}\n\n/** Compose the complete platform-neutral EDA service graph for one session. */\nexport const makeEDARuntimeLayer = ({\n appEvents,\n config,\n compactionExecutorLayer,\n compactionPolicyLayer,\n keepAliveLayer,\n modelResolverLayer,\n promptProjectorLayer,\n reducerRegistryLayer,\n runSchedulerLayer,\n runSchedulingWakeupLayer,\n sessionId,\n sessionEventObserverLayer,\n sessionStoreLayer,\n sinkCheckpointStoreLayer,\n sinks,\n toolkit,\n toolRegistry,\n tracer,\n}: EDARuntimeLayerOptions): Layer.Layer<EDARuntime, SessionCommandAdmissionError> => {\n const Store =\n appEvents === undefined\n ? sessionStoreLayer\n : Layer.effect(\n EDASessionStore,\n Effect.gen(function* () {\n return registerAppEvents(yield* EDASessionStore, appEvents);\n }),\n ).pipe(Layer.provide(sessionStoreLayer));\n const Models = modelResolverLayer;\n const EventObserver = sessionEventObserverLayer ?? SessionEventObserver.Noop;\n const Bus = LiveEventBus.Live.pipe(Layer.provide(EventObserver));\n const KeepAlive = keepAliveLayer ?? EDAKeepAlive.Noop;\n const Ids = IdGenerator.Live;\n const Session = SessionContext.Live(sessionId);\n const Factory = EventFactory.Live.pipe(Layer.provideMerge(Layer.mergeAll(Session, Ids)));\n const PromptProjector = promptProjectorLayer ?? EDAPromptProjector.Default;\n const ReducerRegistry = reducerRegistryLayer ?? EDAReducerRegistry.Empty;\n const CompactionPolicyLayer = compactionPolicyLayer ?? CompactionPolicy.Disabled;\n const CompactionExecutorLayer = compactionExecutorLayer ?? CompactionExecutor.Disabled;\n const Compaction = CompactionRunner.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Factory,\n Ids,\n KeepAlive,\n Models,\n CompactionPolicyLayer,\n CompactionExecutorLayer,\n ),\n ),\n );\n const SinkRegistry = EDASinkRegistry.Live(sinks ?? []).pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Session,\n Store,\n Bus,\n sinkCheckpointStoreLayer,\n Factory,\n Ids,\n ReducerRegistry,\n KeepAlive,\n ),\n ),\n );\n const State = SessionState.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Bus,\n Session,\n ReducerRegistry,\n SinkRegistry,\n KeepAlive,\n Compaction,\n PromptProjector,\n runSchedulerLayer ?? RunScheduler.Immediate,\n runSchedulingWakeupLayer ?? RunSchedulingWakeup.Unsupported,\n ),\n ),\n );\n const Registry =\n toolRegistry !== undefined\n ? EDAToolRegistry.FromShape(toolRegistry)\n : toolkit === undefined\n ? EDAToolRegistry.Empty\n : EDAToolRegistry.FromToolkit(toolkit);\n const InferenceRunnerLayer = InferenceRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Models, Registry, Ids)),\n );\n const ToolExec = ToolExecutor.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Registry, Ids, Session, Store)),\n );\n const Turn = TurnRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(InferenceRunnerLayer, ToolExec, Factory, Ids)),\n );\n const StateWithRun = State.pipe(Layer.provideMerge(Layer.mergeAll(Turn, Factory, Ids)));\n const Query = EDASessionQuery.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Store, Bus)),\n );\n const Runtime = EDARuntime.Live(config).pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Query)),\n );\n\n return tracer === undefined\n ? Runtime\n : Runtime.pipe(Layer.provideMerge(Layer.succeed(Tracer.Tracer, tracer)));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8DA,MAAa,uBAAuB,EAClC,WACA,QACA,yBACA,uBACA,gBACA,oBACA,sBACA,sBACA,mBACA,0BACA,WACA,2BACA,mBACA,0BACA,OACA,SACA,cACA,aACmF;CACnF,MAAM,QACJ,cAAc,KAAA,IACV,oBACA,MAAM,OACJ,iBACA,OAAO,IAAI,aAAa;EACtB,OAAO,kBAAkB,OAAO,iBAAiB,SAAS;CAC5D,CAAC,CACH,EAAE,KAAK,MAAM,QAAQ,iBAAiB,CAAC;CAC7C,MAAM,SAAS;CACf,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C,CACjF;CACA,MAAM,eAAe,MAAM,KAAK,MAAM,aAAa,MAAM,SAAS,MAAM,SAAS,GAAG,CAAC,CAAC;CACtF,MAAM,QAAQ,gBAAgB,KAAK,KACjC,MAAM,aAAa,MAAM,SAAS,cAAc,OAAO,GAAG,CAAC,CAC7D;CACA,MAAM,UAAU,WAAW,KAAK,MAAM,EAAE,KACtC,MAAM,aAAa,MAAM,SAAS,cAAc,KAAK,CAAC,CACxD;CAEA,OAAO,WAAW,KAAA,IACd,UACA,QAAQ,KAAK,MAAM,aAAa,MAAM,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC;AAC3E"}
1
+ {"version":3,"file":"runtime-layer.js","names":[],"sources":["../../src/services/runtime-layer.ts"],"sourcesContent":["import { ModelResolver } from \"./model-resolver\";\nimport * as Layer from \"effect/Layer\";\nimport * as Tracer from \"effect/Tracer\";\n\nimport type { SessionId } from \"../types/core\";\nimport { CompactionExecutor, CompactionPolicy, CompactionRunner } from \"./compaction\";\nimport { EventFactory } from \"./event-factory\";\nimport { IdGenerator } from \"./id-generator\";\nimport { InferenceRunner } from \"./inference-runner\";\nimport { EDAKeepAlive } from \"./keep-alive\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { EDAPromptProjector } from \"./prompt-projector\";\nimport { EDAReducerRegistry } from \"./reducer-registry\";\nimport { EDARuntime, type EDARuntimeConfig } from \"./runtime\";\nimport { RunScheduler } from \"./run-scheduler\";\nimport { RunSchedulingWakeup } from \"./run-scheduling-wakeup\";\nimport { SessionContext } from \"./session-context\";\nimport { SessionEventObserver } from \"./session-event-observer\";\nimport { EDASessionQuery } from \"./session-query\";\nimport * as Effect from \"effect/Effect\";\nimport {\n registerAppEvents,\n type EDAAppEvents,\n EDASessionStore,\n EDASessionStoreError,\n} from \"./session-store\";\nimport { SessionState, type SessionCommandAdmissionError } from \"./session-state\";\nimport { SinkCheckpointStore } from \"./sink-checkpoint-store\";\nimport { EDASinkRegistry, type EDASink } from \"./sink-registry\";\nimport { ToolExecutor } from \"./tool-executor\";\nimport { EDAToolRegistry, type EDAModelToolkit, type EDAToolRegistryShape } from \"./tool-registry\";\nimport { TurnRunner } from \"./turn-runner\";\n\n/**\n * Host-owned adapters and application policy needed to construct one EDA runtime.\n *\n * Core owns the service graph, while hosts supply only semantic persistence,\n * checkpoint, and lifecycle layers. Platform SDK types never cross this boundary.\n */\nexport interface EDARuntimeLayerOptions {\n /** Complete application event union with literal namespaces, decoded once at the store boundary. */\n readonly appEvents?: EDAAppEvents;\n readonly config: EDARuntimeConfig;\n readonly compactionExecutorLayer?: Layer.Layer<CompactionExecutor>;\n readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;\n readonly keepAliveLayer?: Layer.Layer<EDAKeepAlive>;\n readonly modelResolverLayer: Layer.Layer<ModelResolver>;\n readonly promptProjectorLayer?: Layer.Layer<EDAPromptProjector>;\n readonly reducerRegistryLayer?: Layer.Layer<EDAReducerRegistry>;\n readonly runSchedulerLayer?: Layer.Layer<RunScheduler>;\n readonly runSchedulingWakeupLayer?: Layer.Layer<RunSchedulingWakeup>;\n readonly sessionId: SessionId;\n readonly sessionEventObserverLayer?: Layer.Layer<SessionEventObserver>;\n readonly sessionStoreLayer: Layer.Layer<EDASessionStore, EDASessionStoreError>;\n readonly sinkCheckpointStoreLayer: Layer.Layer<SinkCheckpointStore, EDASessionStoreError>;\n readonly sinks?: ReadonlyArray<EDASink>;\n readonly toolkit?: EDAModelToolkit;\n readonly toolRegistry?: EDAToolRegistryShape;\n readonly tracer?: Tracer.Tracer;\n}\n\n/** Compose the complete platform-neutral EDA service graph for one session. */\nexport const makeEDARuntimeLayer = ({\n appEvents,\n config,\n compactionExecutorLayer,\n compactionPolicyLayer,\n keepAliveLayer,\n modelResolverLayer,\n promptProjectorLayer,\n reducerRegistryLayer,\n runSchedulerLayer,\n runSchedulingWakeupLayer,\n sessionId,\n sessionEventObserverLayer,\n sessionStoreLayer,\n sinkCheckpointStoreLayer,\n sinks,\n toolkit,\n toolRegistry,\n tracer,\n}: EDARuntimeLayerOptions): Layer.Layer<EDARuntime, SessionCommandAdmissionError> => {\n const Store =\n appEvents === undefined\n ? sessionStoreLayer\n : Layer.effect(\n EDASessionStore,\n Effect.gen(function* () {\n return registerAppEvents(yield* EDASessionStore, appEvents);\n }),\n ).pipe(Layer.provide(sessionStoreLayer));\n const Models = modelResolverLayer;\n const EventObserver = sessionEventObserverLayer ?? SessionEventObserver.Noop;\n const Bus = LiveEventBus.Live.pipe(Layer.provide(EventObserver));\n const KeepAlive = keepAliveLayer ?? EDAKeepAlive.Noop;\n const Ids = IdGenerator.Live;\n const Session = SessionContext.Live(sessionId);\n const Factory = EventFactory.Live.pipe(Layer.provideMerge(Layer.mergeAll(Session, Ids)));\n const PromptProjector = promptProjectorLayer ?? EDAPromptProjector.Default;\n const ReducerRegistry = reducerRegistryLayer ?? EDAReducerRegistry.Empty;\n const CompactionPolicyLayer = compactionPolicyLayer ?? CompactionPolicy.Disabled;\n const CompactionExecutorLayer = compactionExecutorLayer ?? CompactionExecutor.Disabled;\n const Compaction = CompactionRunner.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Factory,\n Ids,\n KeepAlive,\n Models,\n CompactionPolicyLayer,\n CompactionExecutorLayer,\n ),\n ),\n );\n const SinkRegistry = EDASinkRegistry.Live(sinks ?? []).pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Session,\n Store,\n Bus,\n sinkCheckpointStoreLayer,\n Factory,\n Ids,\n ReducerRegistry,\n KeepAlive,\n ),\n ),\n );\n const State = SessionState.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Bus,\n Session,\n ReducerRegistry,\n SinkRegistry,\n KeepAlive,\n Compaction,\n PromptProjector,\n runSchedulerLayer ?? RunScheduler.Immediate,\n runSchedulingWakeupLayer ?? RunSchedulingWakeup.Unsupported,\n ),\n ),\n );\n const Registry =\n toolRegistry !== undefined\n ? EDAToolRegistry.FromShape(toolRegistry)\n : toolkit === undefined\n ? EDAToolRegistry.Empty\n : EDAToolRegistry.FromToolkit(toolkit);\n const InferenceRunnerLayer = InferenceRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Models, Registry, Ids)),\n );\n const ToolExec = ToolExecutor.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Registry, Ids, Session, Store)),\n );\n const Turn = TurnRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(InferenceRunnerLayer, ToolExec, Factory, Ids)),\n );\n const StateWithRun = State.pipe(Layer.provideMerge(Layer.mergeAll(Turn, Factory, Ids)));\n const Query = EDASessionQuery.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Store, Bus)),\n );\n const Runtime = EDARuntime.Live(config).pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Query)),\n );\n\n return tracer === undefined\n ? Runtime\n : Runtime.pipe(Layer.provideMerge(Layer.succeed(Tracer.Tracer, tracer)));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8DA,MAAa,uBAAuB,EAClC,WACA,QACA,yBACA,uBACA,gBACA,oBACA,sBACA,sBACA,mBACA,0BACA,WACA,2BACA,mBACA,0BACA,OACA,SACA,cACA,aACmF;CACnF,MAAM,QACJ,cAAc,KAAA,IACV,oBACA,MAAM,OACJ,iBACA,OAAO,IAAI,aAAa;EACtB,OAAO,kBAAkB,OAAO,iBAAiB,SAAS;CAC5D,CAAC,CACH,CAAC,CAAC,KAAK,MAAM,QAAQ,iBAAiB,CAAC;CAC7C,MAAM,SAAS;CACf,MAAM,gBAAgB,6BAA6B,qBAAqB;CACxE,MAAM,MAAM,aAAa,KAAK,KAAK,MAAM,QAAQ,aAAa,CAAC;CAC/D,MAAM,YAAY,kBAAkB,aAAa;CACjD,MAAM,MAAM,YAAY;CACxB,MAAM,UAAU,eAAe,KAAK,SAAS;CAC7C,MAAM,UAAU,aAAa,KAAK,KAAK,MAAM,aAAa,MAAM,SAAS,SAAS,GAAG,CAA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SAAS,cAAc,KAAK,CAAC,CACxD;CAEA,OAAO,WAAW,KAAA,IACd,UACA,QAAQ,KAAK,MAAM,aAAa,MAAM,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC;AAC3E"}
@@ -1,2 +1,2 @@
1
- import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "../index-DWC70Fsi.js";
1
+ import { G as EDACommandTerminalEvent, J as EDARuntimeError, K as EDARuntime, W as CommittedCommandTerminalEvent, X as EDARuntimeSubmit, Y as EDARuntimeShape, q as EDARuntimeConfig } from "../reduced-state-DrSHn_47.js";
2
2
  export { CommittedCommandTerminalEvent, EDACommandTerminalEvent, EDARuntime, EDARuntimeConfig, EDARuntimeError, EDARuntimeShape, EDARuntimeSubmit };
@@ -1,7 +1,7 @@
1
- import { SequenceNumber, durablePosition } from "../types/core.js";
1
+ import { DurablePosition, SequenceNumber, durablePosition } from "../types/core.js";
2
2
  import { l as ModelSelectionPayload, m as SystemPromptText, u as NonNegativeInt } from "../envelope-BCzKUq_z.js";
3
3
  import { w as CommandFailedEvent, x as CommandCompletedEvent, y as CommandCancelledEvent } from "../durable-DRY7AcsF.js";
4
- import { u as SessionState } from "../session-state-8PJZvuR3.js";
4
+ import { u as SessionState } from "../session-state-BBzzJrDC.js";
5
5
  import { annotateEdaSpan, committedBatchAttributes } from "./tracing.js";
6
6
  import { EDASessionQuery } from "./session-query.js";
7
7
  import * as Context from "effect/Context";
@@ -17,6 +17,15 @@ const EDARuntimeConfig = Schema.Struct({
17
17
  maxToolCallsPerRun: Schema.optionalKey(NonNegativeInt),
18
18
  systemPrompt: Schema.optionalKey(SystemPromptText)
19
19
  });
20
+ /** Committed durable event narrowed to a command terminal boundary. */
21
+ const CommittedCommandTerminalEvent = Schema.Struct({
22
+ position: DurablePosition,
23
+ event: Schema.Union([
24
+ CommandCompletedEvent,
25
+ CommandFailedEvent,
26
+ CommandCancelledEvent
27
+ ])
28
+ });
20
29
  /** Top-level public facade for one effect-durable-agent session runtime. */
21
30
  var EDARuntime = class EDARuntime extends Context.Service()("@effect-durable-agent/EDARuntime") {
22
31
  static Live = (config) => Layer.effect(EDARuntime, makeLiveRuntime(config));
@@ -85,6 +94,6 @@ const commandIdFromCommandAdmitted = (committed) => {
85
94
  return commandId;
86
95
  };
87
96
  //#endregion
88
- export { EDARuntime, EDARuntimeConfig };
97
+ export { CommittedCommandTerminalEvent, EDARuntime, EDARuntimeConfig };
89
98
 
90
99
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","names":[],"sources":["../../src/services/runtime.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { EDACommand, GrantRunCommand } from \"../types/commands\";\nimport { CommandId, SequenceNumber, durablePosition } from \"../types/core\";\nimport {\n CommandCompletedEvent,\n CommandFailedEvent,\n CommandCancelledEvent,\n ModelSelectionPayload,\n NonNegativeInt,\n SystemPromptText,\n} from \"../types/events\";\nimport type { PositionedEvent } from \"../types/events\";\nimport { SessionState } from \"./session-state\";\nimport type {\n EDASubmittable,\n SessionCommandAdmissionError,\n SessionStateShape,\n} from \"./session-state\";\nimport { CommittedDurableEvent } from \"./session-store\";\nimport { EDASessionQuery } from \"./session-query\";\nimport { annotateEdaSpan, committedBatchAttributes } from \"./tracing\";\nimport type { EDASessionQueryShape } from \"./session-query\";\n\n/** Configuration for one scoped session runtime instance. */\nexport const EDARuntimeConfig = Schema.Struct({\n modelSelection: ModelSelectionPayload,\n /** Maximum framework-owned tool calls one model run may execute before failing safely. */\n maxToolCallsPerRun: Schema.optionalKey(NonNegativeInt),\n systemPrompt: Schema.optionalKey(SystemPromptText),\n});\nexport type EDARuntimeConfig = typeof EDARuntimeConfig.Type;\n\n/** Public runtime error surface for command admission helpers. */\nexport type EDARuntimeError = SessionCommandAdmissionError;\n\n/** Command terminal events observed by blocking runtime helpers. */\nexport type EDACommandTerminalEvent =\n | CommandCompletedEvent\n | CommandFailedEvent\n | CommandCancelledEvent;\n\n/** Committed durable event narrowed to a command terminal boundary. */\nexport type CommittedCommandTerminalEvent = CommittedDurableEvent & {\n readonly event: EDACommandTerminalEvent;\n};\n\n/** Overloaded public submit API for single commands or ordered durable batches. */\nexport interface EDARuntimeSubmit {\n /** Submit one command and return its committed CommandAdmitted event. */\n (command: EDACommand): Effect.Effect<CommittedDurableEvent, EDARuntimeError>;\n /** Submit one ordered durable batch of commands and/or app events. */\n (\n input: ReadonlyArray<EDASubmittable>,\n ): Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDARuntimeError>;\n}\n\n/** Public facade exposed to hosts and route handlers for one live session runtime. */\nexport interface EDARuntimeShape {\n /** Trusted scheduler callback, deliberately separate from ordinary command admission. */\n /** Durable request reconciliation for trusted external schedulers. */\n readonly runRequestOutcome: EDASessionQueryShape[\"runRequestOutcome\"];\n readonly grantRun: (command: GrantRunCommand) => ReturnType<SessionStateShape[\"grantRun\"]>;\n /** Durable host wakeup callback; retry delivery without waiting for authorization. */\n readonly retryRunSchedulingDelivery: SessionStateShape[\"retryRunSchedulingDelivery\"];\n /** Submit commands and/or app durable events durably and wake the dispatch process if needed. */\n readonly submit: EDARuntimeSubmit;\n /** Block until the command reaches CommandCompleted, CommandFailed, or CommandCancelled. */\n readonly blockOnCommand: (\n commandId: CommandId,\n afterSeq?: SequenceNumber,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Admit one command and block until that command reaches a terminal command boundary. */\n readonly submitAndBlock: (\n command: EDACommand,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Read the authoritative live session snapshot. */\n readonly snapshot: EDASessionQueryShape[\"snapshot\"];\n /** Read durable user/assistant messages in committed order. */\n readonly messages: EDASessionQueryShape[\"messages\"];\n /** Backfill durable events after a committed sequence, then follow live events. */\n readonly eventsAfter: EDASessionQueryShape[\"eventsAfter\"];\n /** Read one bounded page of committed durable events plus the committed head. */\n readonly readEventPage: EDASessionQueryShape[\"readEventPage\"];\n}\n\n/** Top-level public facade for one effect-durable-agent session runtime. */\nexport class EDARuntime extends Context.Service<EDARuntime, EDARuntimeShape>()(\n \"@effect-durable-agent/EDARuntime\",\n) {\n static readonly Live = (config: EDARuntimeConfig) =>\n Layer.effect(EDARuntime, makeLiveRuntime(config));\n}\n\nconst makeLiveRuntime = (config: EDARuntimeConfig) =>\n Effect.gen(function* () {\n const sessionState = yield* SessionState;\n const query = yield* EDASessionQuery;\n\n const runInput = {\n modelSelection: config.modelSelection,\n ...(config.maxToolCallsPerRun === undefined\n ? {}\n : { maxToolCallsPerRun: config.maxToolCallsPerRun }),\n ...(config.systemPrompt === undefined ? {} : { systemPrompt: config.systemPrompt }),\n };\n yield* sessionState.start(runInput);\n\n const blockOnCommand = Effect.fn(function* (\n commandId: CommandId,\n afterSeq: SequenceNumber = SequenceNumber.make(0),\n ) {\n yield* annotateEdaSpan({ \"eda.command.id\": commandId, \"eda.seq.after\": afterSeq });\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const events = yield* query.eventsAfter(afterSeq);\n const terminal = yield* events.pipe(\n Stream.filter(isCommandTerminalFor(commandId)),\n Stream.take(1),\n Stream.map(toCommittedCommandTerminal),\n Stream.runCollect,\n Effect.map((events) => events[0]),\n );\n return terminal === undefined\n ? yield* Effect.die(new Error(\"Expected command terminal event\"))\n : terminal;\n }),\n );\n });\n\n const submit = Effect.fn(function* (input: EDACommand | ReadonlyArray<EDASubmittable>) {\n const items = Array.isArray(input) ? input : [input as EDACommand];\n yield* annotateEdaSpan({\n \"eda.command.submittable_count\": items.length,\n \"eda.command.count\": items.filter((item) => \"_tag\" in item).length,\n });\n const committed = Array.isArray(input)\n ? yield* sessionState.submitBatch(input)\n : [yield* sessionState.admitCommand(input as EDACommand)];\n yield* annotateEdaSpan(committedBatchAttributes(committed));\n return Array.isArray(input) ? committed : committed[0]!;\n }) as EDARuntimeSubmit;\n\n return {\n runRequestOutcome: query.runRequestOutcome,\n grantRun: (command: GrantRunCommand) => sessionState.grantRun(command, runInput),\n retryRunSchedulingDelivery: () => sessionState.retryRunSchedulingDelivery(),\n submit,\n blockOnCommand,\n submitAndBlock: Effect.fn(function* (command: EDACommand) {\n yield* annotateEdaSpan({\n \"eda.command.kind\": command._tag,\n \"eda.command.id\": command.commandId,\n \"eda.command.disposition\": \"disposition\" in command ? command.disposition : undefined,\n });\n const admitted = yield* sessionState.admitCommand(command);\n return yield* blockOnCommand(commandIdFromCommandAdmitted(admitted), admitted.position.seq);\n }),\n snapshot: () => query.snapshot(),\n messages: () => query.messages(),\n eventsAfter: (afterSeq: SequenceNumber) => query.eventsAfter(afterSeq),\n readEventPage: (afterSeq: SequenceNumber, limit: number) =>\n query.readEventPage(afterSeq, limit),\n };\n });\n\nconst isCommandTerminalFor =\n (commandId: CommandId) =>\n (\n event: PositionedEvent,\n ): event is PositionedEvent & { readonly event: EDACommandTerminalEvent } => {\n if (\n !Schema.is(CommandCompletedEvent)(event.event) &&\n !Schema.is(CommandFailedEvent)(event.event) &&\n !Schema.is(CommandCancelledEvent)(event.event)\n ) {\n return false;\n }\n return event.event.payload.commandId === commandId;\n };\n\nconst toCommittedCommandTerminal = (\n event: PositionedEvent & { readonly event: EDACommandTerminalEvent },\n): CommittedCommandTerminalEvent => ({\n position: durablePosition(event.position.seq),\n event: event.event,\n});\n\nconst commandIdFromCommandAdmitted = (committed: CommittedDurableEvent): CommandId => {\n const commandId =\n committed.event.type === \"CommandAdmitted\"\n ? committed.event.payload.command.commandId\n : undefined;\n if (commandId === undefined) {\n throw new Error(\"CommandAdmitted event is missing a framework commandId\");\n }\n return commandId;\n};\n"],"mappings":";;;;;;;;;;;;;AA6BA,MAAa,mBAAmB,OAAO,OAAO;CAC5C,gBAAgB;;CAEhB,oBA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cAAc,KAAA,GAChB,MAAM,IAAI,MAAM,wDAAwD;CAE1E,OAAO;AACT"}
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../../src/services/runtime.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { EDACommand, GrantRunCommand } from \"../types/commands\";\nimport { CommandId, DurablePosition, SequenceNumber, durablePosition } from \"../types/core\";\nimport {\n CommandCompletedEvent,\n CommandFailedEvent,\n CommandCancelledEvent,\n ModelSelectionPayload,\n NonNegativeInt,\n SystemPromptText,\n} from \"../types/events\";\nimport type { PositionedEvent } from \"../types/events\";\nimport { SessionState } from \"./session-state\";\nimport type {\n EDASubmittable,\n SessionCommandAdmissionError,\n SessionStateShape,\n} from \"./session-state\";\nimport { CommittedDurableEvent } from \"./session-store\";\nimport { EDASessionQuery } from \"./session-query\";\nimport { annotateEdaSpan, committedBatchAttributes } from \"./tracing\";\nimport type { EDASessionQueryShape } from \"./session-query\";\n\n/** Configuration for one scoped session runtime instance. */\nexport const EDARuntimeConfig = Schema.Struct({\n modelSelection: ModelSelectionPayload,\n /** Maximum framework-owned tool calls one model run may execute before failing safely. */\n maxToolCallsPerRun: Schema.optionalKey(NonNegativeInt),\n systemPrompt: Schema.optionalKey(SystemPromptText),\n});\nexport type EDARuntimeConfig = typeof EDARuntimeConfig.Type;\n\n/** Public runtime error surface for command admission helpers. */\nexport type EDARuntimeError = SessionCommandAdmissionError;\n\n/** Command terminal events observed by blocking runtime helpers. */\nexport type EDACommandTerminalEvent =\n | CommandCompletedEvent\n | CommandFailedEvent\n | CommandCancelledEvent;\n\n/** Committed durable event narrowed to a command terminal boundary. */\nexport const CommittedCommandTerminalEvent = Schema.Struct({\n position: DurablePosition,\n event: Schema.Union([CommandCompletedEvent, CommandFailedEvent, CommandCancelledEvent]),\n});\nexport type CommittedCommandTerminalEvent = typeof CommittedCommandTerminalEvent.Type;\n\n/** Overloaded public submit API for single commands or ordered durable batches. */\nexport interface EDARuntimeSubmit {\n /** Submit one command and return its committed CommandAdmitted event. */\n (command: EDACommand): Effect.Effect<CommittedDurableEvent, EDARuntimeError>;\n /** Submit one ordered durable batch of commands and/or app events. */\n (\n input: ReadonlyArray<EDASubmittable>,\n ): Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDARuntimeError>;\n}\n\n/** Public facade exposed to hosts and route handlers for one live session runtime. */\nexport interface EDARuntimeShape {\n /** Trusted scheduler callback, deliberately separate from ordinary command admission. */\n /** Durable request reconciliation for trusted external schedulers. */\n readonly runRequestOutcome: EDASessionQueryShape[\"runRequestOutcome\"];\n readonly grantRun: (command: GrantRunCommand) => ReturnType<SessionStateShape[\"grantRun\"]>;\n /** Durable host wakeup callback; retry delivery without waiting for authorization. */\n readonly retryRunSchedulingDelivery: SessionStateShape[\"retryRunSchedulingDelivery\"];\n /** Submit commands and/or app durable events durably and wake the dispatch process if needed. */\n readonly submit: EDARuntimeSubmit;\n /** Block until the command reaches CommandCompleted, CommandFailed, or CommandCancelled. */\n readonly blockOnCommand: (\n commandId: CommandId,\n afterSeq?: SequenceNumber,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Admit one command and block until that command reaches a terminal command boundary. */\n readonly submitAndBlock: (\n command: EDACommand,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Read the authoritative live session snapshot. */\n readonly snapshot: EDASessionQueryShape[\"snapshot\"];\n /** Read durable user/assistant messages in committed order. */\n readonly messages: EDASessionQueryShape[\"messages\"];\n /** Backfill durable events after a committed sequence, then follow live events. */\n readonly eventsAfter: EDASessionQueryShape[\"eventsAfter\"];\n /** Read one bounded page of committed durable events plus the committed head. */\n readonly readEventPage: EDASessionQueryShape[\"readEventPage\"];\n}\n\n/** Top-level public facade for one effect-durable-agent session runtime. */\nexport class EDARuntime extends Context.Service<EDARuntime, EDARuntimeShape>()(\n \"@effect-durable-agent/EDARuntime\",\n) {\n static readonly Live = (config: EDARuntimeConfig) =>\n Layer.effect(EDARuntime, makeLiveRuntime(config));\n}\n\nconst makeLiveRuntime = (config: EDARuntimeConfig) =>\n Effect.gen(function* () {\n const sessionState = yield* SessionState;\n const query = yield* EDASessionQuery;\n\n const runInput = {\n modelSelection: config.modelSelection,\n ...(config.maxToolCallsPerRun === undefined\n ? {}\n : { maxToolCallsPerRun: config.maxToolCallsPerRun }),\n ...(config.systemPrompt === undefined ? {} : { systemPrompt: config.systemPrompt }),\n };\n yield* sessionState.start(runInput);\n\n const blockOnCommand = Effect.fn(function* (\n commandId: CommandId,\n afterSeq: SequenceNumber = SequenceNumber.make(0),\n ) {\n yield* annotateEdaSpan({ \"eda.command.id\": commandId, \"eda.seq.after\": afterSeq });\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const events = yield* query.eventsAfter(afterSeq);\n const terminal = yield* events.pipe(\n Stream.filter(isCommandTerminalFor(commandId)),\n Stream.take(1),\n Stream.map(toCommittedCommandTerminal),\n Stream.runCollect,\n Effect.map((events) => events[0]),\n );\n return terminal === undefined\n ? yield* Effect.die(new Error(\"Expected command terminal event\"))\n : terminal;\n }),\n );\n });\n\n const submit = Effect.fn(function* (input: EDACommand | ReadonlyArray<EDASubmittable>) {\n const items = Array.isArray(input) ? input : [input as EDACommand];\n yield* annotateEdaSpan({\n \"eda.command.submittable_count\": items.length,\n \"eda.command.count\": items.filter((item) => \"_tag\" in item).length,\n });\n const committed = Array.isArray(input)\n ? yield* sessionState.submitBatch(input)\n : [yield* sessionState.admitCommand(input as EDACommand)];\n yield* annotateEdaSpan(committedBatchAttributes(committed));\n return Array.isArray(input) ? committed : committed[0]!;\n }) as EDARuntimeSubmit;\n\n return {\n runRequestOutcome: query.runRequestOutcome,\n grantRun: (command: GrantRunCommand) => sessionState.grantRun(command, runInput),\n retryRunSchedulingDelivery: () => sessionState.retryRunSchedulingDelivery(),\n submit,\n blockOnCommand,\n submitAndBlock: Effect.fn(function* (command: EDACommand) {\n yield* annotateEdaSpan({\n \"eda.command.kind\": command._tag,\n \"eda.command.id\": command.commandId,\n \"eda.command.disposition\": \"disposition\" in command ? command.disposition : undefined,\n });\n const admitted = yield* sessionState.admitCommand(command);\n return yield* blockOnCommand(commandIdFromCommandAdmitted(admitted), admitted.position.seq);\n }),\n snapshot: () => query.snapshot(),\n messages: () => query.messages(),\n eventsAfter: (afterSeq: SequenceNumber) => query.eventsAfter(afterSeq),\n readEventPage: (afterSeq: SequenceNumber, limit: number) =>\n query.readEventPage(afterSeq, limit),\n };\n });\n\nconst isCommandTerminalFor =\n (commandId: CommandId) =>\n (\n event: PositionedEvent,\n ): event is PositionedEvent & { readonly event: EDACommandTerminalEvent } => {\n if (\n !Schema.is(CommandCompletedEvent)(event.event) &&\n !Schema.is(CommandFailedEvent)(event.event) &&\n !Schema.is(CommandCancelledEvent)(event.event)\n ) {\n return false;\n }\n return event.event.payload.commandId === commandId;\n };\n\nconst toCommittedCommandTerminal = (\n event: PositionedEvent & { readonly event: EDACommandTerminalEvent },\n): CommittedCommandTerminalEvent => ({\n position: durablePosition(event.position.seq),\n event: event.event,\n});\n\nconst commandIdFromCommandAdmitted = (committed: CommittedDurableEvent): CommandId => {\n const commandId =\n committed.event.type === \"CommandAdmitted\"\n ? committed.event.payload.command.commandId\n : undefined;\n if (commandId === undefined) {\n throw new Error(\"CommandAdmitted event is missing a framework commandId\");\n }\n return commandId;\n};\n"],"mappings":";;;;;;;;;;;;;AA6BA,MAAa,mBAAmB,OAAO,OAAO;CAC5C,gBAAgB;;CAEhB,oBAAoB,OAAO,YAAY,cAAc;CACrD,cAAc,OAAO,YAAY,gBAAgB;AACnD,CAAC;;AAaD,MAAa,gCAAgC,OAAO,OAAO;CACzD,UAAU;CACV,OAAO,OAAO,MAAM;EAAC;EAAuB;EAAoB;CAAqB,CAAC;AACxF,CAAC;;AA2CD,IAAa,aAAb,MAAa,mBAAmB,QAAQ,QAAqC,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+1,2 @@
1
- import { n as SessionEventObserverShape, t as SessionEventObserver } from "../session-event-observer-BWppl2Fr.js";
1
+ import { n as SessionEventObserverShape, t as SessionEventObserver } from "../session-event-observer-BDwja1jX.js";
2
2
  export { SessionEventObserver, SessionEventObserverShape };
@@ -1 +1 @@
1
- {"version":3,"file":"session-event-observer.js","names":[],"sources":["../../src/services/session-event-observer.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport type { PositionedEvent } from \"../types/events\";\n\n/**\n * Outbound integration point notified synchronously after EDA publishes an event.\n *\n * Hosts provide this service while composing the runtime. Implementations own\n * their failures and never expose host errors to the session runtime.\n */\nexport interface SessionEventObserverShape {\n readonly onEvent: (event: PositionedEvent) => Effect.Effect<void>;\n}\n\n/** Host-provided observer for append-driven integrations such as hibernatable WebSockets. */\nexport class SessionEventObserver extends Context.Service<\n SessionEventObserver,\n SessionEventObserverShape\n>()(\"@effect-durable-agent/SessionEventObserver\") {\n static readonly Noop = Layer.succeed(SessionEventObserver, {\n onEvent: () => Effect.void,\n });\n\n static readonly FromHandler = (\n onEvent: SessionEventObserverShape[\"onEvent\"],\n ): Layer.Layer<SessionEventObserver> => Layer.succeed(SessionEventObserver, { onEvent });\n}\n"],"mappings":";;;;;AAiBA,IAAa,uBAAb,MAAa,6BAA6B,QAAQ,QAGhD,EAAE,4CAA4C,EAAE;CAChD,OAAgB,OAAO,MAAM,QAAQ,sBAAsB,EACzD,eAAe,OAAO,KACxB,CAAC;CAED,OAAgB,eACd,YACsC,MAAM,QAAQ,sBAAsB,EAAE,QAAQ,CAAC;AACzF"}
1
+ {"version":3,"file":"session-event-observer.js","names":[],"sources":["../../src/services/session-event-observer.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport type { PositionedEvent } from \"../types/events\";\n\n/**\n * Outbound integration point notified synchronously after EDA publishes an event.\n *\n * Hosts provide this service while composing the runtime. Implementations own\n * their failures and never expose host errors to the session runtime.\n */\nexport interface SessionEventObserverShape {\n readonly onEvent: (event: PositionedEvent) => Effect.Effect<void>;\n}\n\n/** Host-provided observer for append-driven integrations such as hibernatable WebSockets. */\nexport class SessionEventObserver extends Context.Service<\n SessionEventObserver,\n SessionEventObserverShape\n>()(\"@effect-durable-agent/SessionEventObserver\") {\n static readonly Noop = Layer.succeed(SessionEventObserver, {\n onEvent: () => Effect.void,\n });\n\n static readonly FromHandler = (\n onEvent: SessionEventObserverShape[\"onEvent\"],\n ): Layer.Layer<SessionEventObserver> => Layer.succeed(SessionEventObserver, { onEvent });\n}\n"],"mappings":";;;;;AAiBA,IAAa,uBAAb,MAAa,6BAA6B,QAAQ,QAGhD,CAAC,CAAC,4CAA4C,CAAC,CAAC;CAChD,OAAgB,OAAO,MAAM,QAAQ,sBAAsB,EACzD,eAAe,OAAO,KACxB,CAAC;CAED,OAAgB,eACd,YACsC,MAAM,QAAQ,sBAAsB,EAAE,QAAQ,CAAC;AACzF"}
@@ -1,2 +1,2 @@
1
- import { c as EDASessionEventPage, d as EDASessionSnapshot, l as EDASessionQuery, u as EDASessionQueryShape } from "../index-DWC70Fsi.js";
2
- export { EDASessionEventPage, EDASessionQuery, EDASessionQueryShape, EDASessionSnapshot };
1
+ import { $ as EDASessionQuery, Q as EDASessionEventPage, Z as DurableTranscriptMessages, et as EDASessionQueryShape, tt as EDASessionSnapshot } from "../reduced-state-DrSHn_47.js";
2
+ export { DurableTranscriptMessages, EDASessionEventPage, EDASessionQuery, EDASessionQueryShape, EDASessionSnapshot };