effect-durable-agent 0.1.0-alpha.1 → 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +140 -136
  2. package/dist/{command-queues-CQ9cwRP7.d.ts → command-queues-CQi4Xc7u.d.ts} +109 -21
  3. package/dist/{commands-Ce1ec6kH.d.ts → commands-p8venTWs.d.ts} +10 -2
  4. package/dist/compaction-0k8zCJgB.js +473 -0
  5. package/dist/compaction-0k8zCJgB.js.map +1 -0
  6. package/dist/{compaction-YayFKo_1.d.ts → compaction-BhLSSXJ-.d.ts} +28 -7
  7. package/dist/context-projection-mCuvcO2W.d.ts +140 -0
  8. package/dist/{core-Hv3cFydL.d.ts → core-C-6xHzRx.d.ts} +6 -3
  9. package/dist/domain/command-queues.d.ts +1 -1
  10. package/dist/domain/command-queues.js +1 -1
  11. package/dist/domain/command-queues.js.map +1 -1
  12. package/dist/domain/context-projection.d.ts +2 -0
  13. package/dist/domain/context-projection.js +32 -0
  14. package/dist/domain/context-projection.js.map +1 -0
  15. package/dist/domain/message-transcript.d.ts +1 -1
  16. package/dist/domain/model-usage.d.ts +2 -0
  17. package/dist/domain/model-usage.js +59 -0
  18. package/dist/domain/model-usage.js.map +1 -0
  19. package/dist/domain/reduced-state-schema.d.ts +14 -18
  20. package/dist/domain/reduced-state-schema.js +7 -11
  21. package/dist/domain/reduced-state-schema.js.map +1 -1
  22. package/dist/domain/reduced-state.d.ts +3 -2
  23. package/dist/domain/reduced-state.js +3 -2
  24. package/dist/domain/run-scheduling.d.ts +2 -0
  25. package/dist/domain/run-scheduling.js +127 -0
  26. package/dist/domain/run-scheduling.js.map +1 -0
  27. package/dist/{durable-C3Rz7kg3.js → durable-BPHVFVvV.js} +74 -83
  28. package/dist/durable-BPHVFVvV.js.map +1 -0
  29. package/dist/{durable-DlScwmCy.d.ts → durable-DeLCAvbw.d.ts} +1256 -104
  30. package/dist/envelope-DkZyMIgp.d.ts +191 -0
  31. package/dist/envelope-DxQzo5rN.js +82 -0
  32. package/dist/envelope-DxQzo5rN.js.map +1 -0
  33. package/dist/{keep-alive-DYDsH6qN.d.ts → event-factory-KaeDSfeP.d.ts} +11 -31
  34. package/dist/{keep-alive-p8dIcSVy.js → event-factory-QuC_UvyP.js} +8 -10
  35. package/dist/event-factory-QuC_UvyP.js.map +1 -0
  36. package/dist/{events-Bb9-Cu-7.d.ts → events-LZFNoESe.d.ts} +2 -188
  37. package/dist/{id-generator-C2Q15uZM.d.ts → id-generator--x6itQZ2.d.ts} +3 -2
  38. package/dist/index.d.ts +7 -6
  39. package/dist/index.js +5 -4
  40. package/dist/keep-alive-Chl5SJxy.d.ts +29 -0
  41. package/dist/{message-transcript-BCHdHAe2.d.ts → message-transcript-6PEzaEGn.d.ts} +4 -4
  42. package/dist/model-resolver-BPPJAsuh.d.ts +18 -0
  43. package/dist/model-usage-CdBEkTwU.d.ts +55 -0
  44. package/dist/{prompt-projector-9_02lk5-.d.ts → prompt-projector-CNhqUsEr.d.ts} +15 -16
  45. package/dist/{reduced-state-C4nVVzz9.js → reduced-state-Bz68V2H8.js} +65 -32
  46. package/dist/reduced-state-Bz68V2H8.js.map +1 -0
  47. package/dist/{reducer-registry-C0svUa63.d.ts → reducer-registry-CCSzc4h8.d.ts} +16 -6
  48. package/dist/run-scheduler-DcS_okUH.d.ts +43 -0
  49. package/dist/run-scheduling-wakeup-CeHrvXie.d.ts +25 -0
  50. package/dist/{runtime-C56FQxiL.d.ts → runtime-WL_gKqxn.d.ts} +16 -7
  51. package/dist/services/compaction.d.ts +1 -1
  52. package/dist/services/compaction.js +1 -425
  53. package/dist/services/id-generator.d.ts +1 -1
  54. package/dist/services/id-generator.js +2 -1
  55. package/dist/services/id-generator.js.map +1 -1
  56. package/dist/services/keep-alive.d.ts +2 -0
  57. package/dist/services/keep-alive.js +13 -0
  58. package/dist/services/keep-alive.js.map +1 -0
  59. package/dist/services/model-resolver.d.ts +2 -0
  60. package/dist/services/model-resolver.js +17 -0
  61. package/dist/services/model-resolver.js.map +1 -0
  62. package/dist/services/prompt-projector.d.ts +2 -2
  63. package/dist/services/prompt-projector.js +20 -10
  64. package/dist/services/prompt-projector.js.map +1 -1
  65. package/dist/services/reducer-registry.d.ts +2 -2
  66. package/dist/services/reducer-registry.js +7 -3
  67. package/dist/services/reducer-registry.js.map +1 -1
  68. package/dist/services/run-scheduler.d.ts +3 -0
  69. package/dist/services/run-scheduler.js +25 -0
  70. package/dist/services/run-scheduler.js.map +1 -0
  71. package/dist/services/run-scheduling-wakeup.d.ts +2 -0
  72. package/dist/services/run-scheduling-wakeup.js +13 -0
  73. package/dist/services/run-scheduling-wakeup.js.map +1 -0
  74. package/dist/services/runtime-layer.d.ts +67 -0
  75. package/dist/services/runtime-layer.js +47 -0
  76. package/dist/services/runtime-layer.js.map +1 -0
  77. package/dist/services/runtime.d.ts +1 -1
  78. package/dist/services/runtime.js +21 -14
  79. package/dist/services/runtime.js.map +1 -1
  80. package/dist/services/session-event-observer.d.ts +2 -0
  81. package/dist/services/session-event-observer.js +13 -0
  82. package/dist/services/session-event-observer.js.map +1 -0
  83. package/dist/services/session-query.d.ts +2 -2
  84. package/dist/services/session-query.js +140 -1
  85. package/dist/services/session-query.js.map +1 -0
  86. package/dist/services/session-state.d.ts +2 -0
  87. package/dist/services/session-state.js +2 -0
  88. package/dist/services/session-store.d.ts +2 -2
  89. package/dist/services/session-store.js +182 -2
  90. package/dist/services/session-store.js.map +1 -0
  91. package/dist/services/sink-checkpoint-store.d.ts +2 -0
  92. package/dist/services/sink-checkpoint-store.js +49 -0
  93. package/dist/services/sink-checkpoint-store.js.map +1 -0
  94. package/dist/services/sink-registry.d.ts +1 -1
  95. package/dist/services/sink-registry.js +1 -1
  96. package/dist/services/span-names.d.ts +1 -1
  97. package/dist/services/span-names.js +3 -0
  98. package/dist/services/span-names.js.map +1 -1
  99. package/dist/services/tool-registry.d.ts +1 -1
  100. package/dist/services/tracing.d.ts +1 -1
  101. package/dist/services/tracing.js +23 -2
  102. package/dist/services/tracing.js.map +1 -1
  103. package/dist/session-event-observer-DaFMKKNc.d.ts +24 -0
  104. package/dist/session-query-DfW_4KC0.d.ts +47 -0
  105. package/dist/{session-query-DOc1KanA.js → session-state-BIZ2SYaP.js} +350 -183
  106. package/dist/session-state-BIZ2SYaP.js.map +1 -0
  107. package/dist/{session-query-DlRo5Ufc.d.ts → session-state-BeR2rZRR.d.ts} +144 -46
  108. package/dist/{session-store-D2Ore1QC.d.ts → session-store-J_Un45kW.d.ts} +7 -96
  109. package/dist/sink-checkpoint-store-C9hUxfH0.d.ts +40 -0
  110. package/dist/{sink-registry-CFC6xjsN.js → sink-registry-Bbqhtdnx.js} +27 -67
  111. package/dist/sink-registry-Bbqhtdnx.js.map +1 -0
  112. package/dist/{sink-registry-CIU0LD3m.d.ts → sink-registry-DuDkNXjZ.d.ts} +24 -49
  113. package/dist/testkit/layers.d.ts +24 -14
  114. package/dist/testkit/layers.js +18 -11
  115. package/dist/testkit/layers.js.map +1 -1
  116. package/dist/{tool-registry-CcnkAAQK.d.ts → tool-registry-BDmJe_Wr.d.ts} +4 -4
  117. package/dist/types/commands.d.ts +2 -2
  118. package/dist/types/commands.js +7 -2
  119. package/dist/types/commands.js.map +1 -1
  120. package/dist/types/core.d.ts +2 -2
  121. package/dist/types/core.js +4 -2
  122. package/dist/types/core.js.map +1 -1
  123. package/dist/types/events/durable.d.ts +2 -2
  124. package/dist/types/events/durable.js +2 -2
  125. package/dist/types/events.d.ts +4 -3
  126. package/dist/types/events.js +3 -2
  127. package/dist/types/events.js.map +1 -1
  128. package/dist/websocket.d.ts +2776 -0
  129. package/dist/websocket.js +498 -0
  130. package/dist/websocket.js.map +1 -0
  131. package/package.json +68 -43
  132. package/testing/offline-trace/README.md +2 -1
  133. package/CHANGELOG.md +0 -10
  134. package/CONTRIBUTING.md +0 -26
  135. package/SECURITY.md +0 -8
  136. package/dist/durable-C3Rz7kg3.js.map +0 -1
  137. package/dist/durable-object-runtime-B7jwBY2R.js +0 -1494
  138. package/dist/durable-object-runtime-B7jwBY2R.js.map +0 -1
  139. package/dist/durable-object-runtime-pWv0ohlz.d.ts +0 -257
  140. package/dist/durable-object-storage-Czy7IPrh.d.ts +0 -41
  141. package/dist/host/durable-object-runtime.d.ts +0 -2
  142. package/dist/host/durable-object-runtime.js +0 -2
  143. package/dist/host/durable-object-storage.d.ts +0 -2
  144. package/dist/host/durable-object-storage.js +0 -0
  145. package/dist/host/durable-object.d.ts +0 -83
  146. package/dist/host/durable-object.js +0 -191
  147. package/dist/host/durable-object.js.map +0 -1
  148. package/dist/host/websocket-wire.d.ts +0 -2
  149. package/dist/host/websocket-wire.js +0 -88
  150. package/dist/host/websocket-wire.js.map +0 -1
  151. package/dist/keep-alive-p8dIcSVy.js.map +0 -1
  152. package/dist/reduced-state-C4nVVzz9.js.map +0 -1
  153. package/dist/services/compaction.js.map +0 -1
  154. package/dist/session-query-DOc1KanA.js.map +0 -1
  155. package/dist/session-store-pYxQW9qh.js +0 -214
  156. package/dist/session-store-pYxQW9qh.js.map +0 -1
  157. package/dist/sink-registry-CFC6xjsN.js.map +0 -1
  158. package/dist/websocket-wire-DvOu_6BJ.d.ts +0 -16773
  159. package/docs/assets/architecture.svg +0 -106
  160. package/docs/assets/event-sequence.svg +0 -143
  161. package/docs/assets/gcp-trace.png +0 -0
  162. package/docs/message-steering.md +0 -831
  163. package/docs/releasing.md +0 -57
  164. package/docs/spec.md +0 -774
  165. package/docs/subagents.md +0 -725
  166. package/docs/testing.md +0 -64
  167. package/docs/ui-projection.md +0 -742
  168. package/docs/websocket-protocol.md +0 -613
  169. package/examples/001-no-tools/README.md +0 -65
  170. package/examples/001-no-tools/worker.ts +0 -79
  171. package/examples/002-slack-bridge/README.md +0 -134
  172. package/examples/002-slack-bridge/events.ts +0 -115
  173. package/examples/002-slack-bridge/reducer.ts +0 -216
  174. package/examples/002-slack-bridge/scenario.test.ts +0 -223
  175. package/examples/002-slack-bridge/sinks.ts +0 -109
  176. package/examples/002-slack-bridge/worker.ts +0 -140
  177. package/examples/003-sandbox-lifecycle/README.md +0 -78
  178. package/examples/003-sandbox-lifecycle/events.ts +0 -203
  179. package/examples/003-sandbox-lifecycle/reducer.ts +0 -305
  180. package/examples/003-sandbox-lifecycle/scenario.test.ts +0 -202
  181. package/examples/_shared/event-id.ts +0 -12
  182. package/examples/_shared/http.ts +0 -27
  183. package/examples/_shared/openai.ts +0 -33
@@ -1,2 +1,3 @@
1
- import { a as encodeReducedStateCheckpoint, c as frameworkReducedStateReducerSchemaVersion, d as pendingStopCommand, f as reduceCommittedEvents, i as decodeReducedStateCheckpoint, l as initialReducedState, n as activeTurnIdentityForCommand, o as foldReducedState, p as reducedStateCheckpointEventSeqs, r as classifyRecoverableWork, s as frameworkReducedStateReducerName, t as activeCommand, u as pendingCommands } from "../reduced-state-C4nVVzz9.js";
2
- export { activeCommand, activeTurnIdentityForCommand, classifyRecoverableWork, decodeReducedStateCheckpoint, encodeReducedStateCheckpoint, foldReducedState, frameworkReducedStateReducerName, frameworkReducedStateReducerSchemaVersion, initialReducedState, pendingCommands, pendingStopCommand, reduceCommittedEvents, reducedStateCheckpointEventSeqs };
1
+ import { TokenConsumptionState } from "./model-usage.js";
2
+ import { a as encodeReducedStateCheckpoint, c as frameworkReducedStateReducerSchemaVersion, d as pendingStopCommand, f as reduceCommittedEvents, i as decodeReducedStateCheckpoint, l as initialReducedState, n as activeTurnIdentityForCommand, o as foldReducedState, p as reducedStateCheckpointEventSeqs, r as classifyRecoverableWork, s as frameworkReducedStateReducerName, t as activeCommand, u as pendingCommands } from "../reduced-state-Bz68V2H8.js";
3
+ export { TokenConsumptionState, activeCommand, activeTurnIdentityForCommand, classifyRecoverableWork, decodeReducedStateCheckpoint, encodeReducedStateCheckpoint, foldReducedState, frameworkReducedStateReducerName, frameworkReducedStateReducerSchemaVersion, initialReducedState, pendingCommands, pendingStopCommand, reduceCommittedEvents, reducedStateCheckpointEventSeqs };
@@ -0,0 +1,2 @@
1
+ import { $ as RunRequestOutcome, Q as RunGrantResult, X as DeferredRunResolution, Z as LocalRunResolution, at as RunSchedulingWork, ct as planWaitingRunInterruption, et as RunResolution, it as RunSchedulingRequestRecord, lt as runSchedulingInputMessageIds, nt as RunSchedulingInput, ot as canGrantRun, rt as RunSchedulingRequest, st as planRunSchedulingCancellation, tt as RunSchedulingCancellationPlan, ut as waitingRunControl } from "../command-queues-CQi4Xc7u.js";
2
+ export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunRequestOutcome, RunResolution, RunSchedulingCancellationPlan, RunSchedulingInput, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runSchedulingInputMessageIds, waitingRunControl };
@@ -0,0 +1,127 @@
1
+ import { CommandId, MessageId, RunId, RunRequestId, SequenceNumber } from "../types/core.js";
2
+ import * as Schema from "effect/Schema";
3
+ //#region src/domain/run-scheduling.ts
4
+ /**
5
+ * Permission to start the selected run in this session's current runtime.
6
+ * This value is never persisted and allocates no scheduling identity.
7
+ */
8
+ const LocalRunResolution = Schema.TaggedStruct("Local", {});
9
+ /** Intent to request external permission; resolution itself must perform no delivery. */
10
+ const DeferredRunResolution = Schema.TaggedStruct("Deferred", {});
11
+ /** Prompt selection result interpreted by SessionState before any run is started. */
12
+ const RunResolution = Schema.Union([LocalRunResolution, DeferredRunResolution]);
13
+ /** Selected work and the durable predecessor needed to authorize a recovery replacement. */
14
+ const RunSchedulingWork = Schema.Union([Schema.TaggedStruct("Command", { commandId: CommandId }), Schema.TaggedStruct("Recovery", {
15
+ commandId: CommandId,
16
+ interruptedRunId: RunId,
17
+ inputMessageIds: Schema.Array(MessageId)
18
+ })]);
19
+ /** One run-slot reservation. External schedulers must deduplicate delivery by requestId. */
20
+ const RunSchedulingRequest = Schema.Struct({
21
+ requestId: RunRequestId,
22
+ work: RunSchedulingWork
23
+ });
24
+ /** Current reservation, folded solely from request and successful delivery facts. */
25
+ const RunSchedulingRequestRecord = Schema.Struct({
26
+ ...RunSchedulingRequest.fields,
27
+ requestedSeq: SequenceNumber,
28
+ deliveredSeq: Schema.optionalKey(SequenceNumber)
29
+ });
30
+ /** A stale/duplicate permission is harmless and cannot allocate another run. */
31
+ const RunGrantResult = Schema.Union([Schema.TaggedStruct("Granted", { runId: RunId }), Schema.TaggedStruct("Stale", {})]);
32
+ /** Durable answer for reconciling an ambiguous grant delivery. Unknown never authorizes replacement work. */
33
+ const RunRequestOutcome = Schema.Union([
34
+ Schema.TaggedStruct("Unknown", {}),
35
+ Schema.TaggedStruct("Waiting", {}),
36
+ Schema.TaggedStruct("Invalidated", {}),
37
+ Schema.TaggedStruct("Granted", {
38
+ runId: RunId,
39
+ status: Schema.Literals([
40
+ "Running",
41
+ "Completed",
42
+ "Failed",
43
+ "Interrupted"
44
+ ])
45
+ })
46
+ ]);
47
+ /** Still-unconsumed inputs owned by a reservation, derived from the existing message records. */
48
+ const runSchedulingInputMessageIds = (state, work) => {
49
+ const command = state.commands.get(work.commandId)?.command;
50
+ return (work._tag === "Recovery" ? work.inputMessageIds : command?._tag === "ResumePendingMessages" ? command.messageIds : Array.from(state.messages.values()).flatMap((message) => (message._tag === "User" || message._tag === "Steering") && message.commandId === work.commandId ? [message.messageId] : [])).filter((messageId) => {
51
+ const message = state.messages.get(messageId);
52
+ return (message?._tag === "User" || message?._tag === "Steering") && message.consumedSeq === void 0 && message.cancelledSeq === void 0 && message.pausedByCommandId === void 0;
53
+ });
54
+ };
55
+ /** Revalidate durable ownership and pending controls immediately before granting permission. */
56
+ const canGrantRun = (state, requestId) => {
57
+ const request = state.runSchedulingRequest;
58
+ if (request?.requestId !== requestId) return false;
59
+ const command = state.commands.get(request.work.commandId);
60
+ if (command?.command === void 0 || command.terminal !== void 0) return false;
61
+ if (Array.from(state.runs.values()).some((run) => run.terminal === void 0)) return false;
62
+ const inputs = runSchedulingInputMessageIds(state, request.work);
63
+ if (request.work._tag === "Command") {
64
+ if (command.startedSeq !== void 0) return false;
65
+ const legacySubmit = command.command._tag === "SubmitMessage" && !Array.from(state.messages.values()).some((message) => (message._tag === "User" || message._tag === "Steering") && message.commandId === command.commandId);
66
+ if (inputs.length === 0 && !legacySubmit) return false;
67
+ } else {
68
+ const predecessor = state.runs.get(request.work.interruptedRunId);
69
+ if (command.startedSeq === void 0 || predecessor?.terminal === void 0 || !predecessor.commandIds.includes(command.commandId) || request.work.inputMessageIds.length > 0 && inputs.length === 0) return false;
70
+ }
71
+ return !state.commandQueues.activeControlCommands.some((pending) => {
72
+ if (pending.commandId === command.commandId) return false;
73
+ switch (pending.command._tag) {
74
+ case "StopTurn": return true;
75
+ case "SubmitMessage": return pending.command.disposition === "interrupt";
76
+ case "CancelPendingMessage": return inputs.includes(pending.command.messageId);
77
+ default: return false;
78
+ }
79
+ });
80
+ };
81
+ /** Controls may change waiting work; later messages cannot take its reserved slot. */
82
+ const waitingRunControl = (state) => {
83
+ const owner = state.runSchedulingRequest?.work.commandId;
84
+ const controls = state.commandQueues.activeControlCommands.filter((pending) => pending.commandId !== owner && (pending.command._tag !== "SubmitMessage" || pending.command.disposition === "interrupt"));
85
+ const priority = (pending) => {
86
+ switch (pending.command._tag) {
87
+ case "StopTurn": return 0;
88
+ case "CancelPendingMessage": return 1;
89
+ case "PromotePendingMessage": return 2;
90
+ default: return 3;
91
+ }
92
+ };
93
+ return controls.sort((a, b) => priority(a) - priority(b) || a.admittedSeq - b.admittedSeq)[0];
94
+ };
95
+ /** Preserve a recovery predecessor when cancellation leaves other selected inputs eligible. */
96
+ const planRunSchedulingCancellation = (state, messageId) => {
97
+ const request = state.runSchedulingRequest;
98
+ if (request === void 0) return void 0;
99
+ const inputs = runSchedulingInputMessageIds(state, request.work);
100
+ if (!inputs.includes(messageId)) return void 0;
101
+ if (request.work._tag === "Command") return { requestId: request.requestId };
102
+ const remainingInputs = inputs.filter((id) => id !== messageId);
103
+ return remainingInputs.length === 0 ? {
104
+ requestId: request.requestId,
105
+ cancelCommandId: request.work.commandId
106
+ } : {
107
+ requestId: request.requestId,
108
+ replacementWork: {
109
+ ...request.work,
110
+ inputMessageIds: remainingInputs
111
+ }
112
+ };
113
+ };
114
+ /** Stop/interrupt facts that invalidate authorization and pause pending work before any run. */
115
+ const planWaitingRunInterruption = (state, controlCommandId) => {
116
+ const request = state.runSchedulingRequest;
117
+ if (request === void 0) return void 0;
118
+ return {
119
+ requestId: request.requestId,
120
+ messageIds: [...state.commandQueues.pendingQueue, ...state.commandQueues.pendingSteers].filter((message) => message.commandId !== controlCommandId).map((message) => message.messageId),
121
+ cancelCommandId: request.work.commandId
122
+ };
123
+ };
124
+ //#endregion
125
+ export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunRequestOutcome, RunResolution, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runSchedulingInputMessageIds, waitingRunControl };
126
+
127
+ //# sourceMappingURL=run-scheduling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-scheduling.js","names":[],"sources":["../../src/domain/run-scheduling.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport {\n CommandId,\n MessageId,\n RunId,\n RunRequestId,\n SequenceNumber,\n type SessionId,\n} from \"../types/core\";\nimport type { PendingCommand, ReducedState } from \"./reduced-state\";\n\n/**\n * Identity of the admitted work selected by dispatch or recovery for a new run.\n * This is not a durable request identity: recovery can resolve the same command again.\n */\nexport interface RunSchedulingInput {\n readonly sessionId: SessionId;\n readonly commandId: CommandId;\n}\n\n/**\n * Permission to start the selected run in this session's current runtime.\n * This value is never persisted and allocates no scheduling identity.\n */\nexport const LocalRunResolution = Schema.TaggedStruct(\"Local\", {});\nexport type LocalRunResolution = typeof LocalRunResolution.Type;\n\n/** Intent to request external permission; resolution itself must perform no delivery. */\nexport const DeferredRunResolution = Schema.TaggedStruct(\"Deferred\", {});\nexport type DeferredRunResolution = typeof DeferredRunResolution.Type;\n\n/** Prompt selection result interpreted by SessionState before any run is started. */\nexport const RunResolution = Schema.Union([LocalRunResolution, DeferredRunResolution]);\nexport type RunResolution = typeof RunResolution.Type;\n\n/** Selected work and the durable predecessor needed to authorize a recovery replacement. */\nexport const RunSchedulingWork = Schema.Union([\n Schema.TaggedStruct(\"Command\", { commandId: CommandId }),\n Schema.TaggedStruct(\"Recovery\", {\n commandId: CommandId,\n interruptedRunId: RunId,\n inputMessageIds: Schema.Array(MessageId),\n }),\n]);\nexport type RunSchedulingWork = typeof RunSchedulingWork.Type;\n\n/** One run-slot reservation. External schedulers must deduplicate delivery by requestId. */\nexport const RunSchedulingRequest = Schema.Struct({\n requestId: RunRequestId,\n work: RunSchedulingWork,\n});\nexport type RunSchedulingRequest = typeof RunSchedulingRequest.Type;\n\n/** Current reservation, folded solely from request and successful delivery facts. */\nexport const RunSchedulingRequestRecord = Schema.Struct({\n ...RunSchedulingRequest.fields,\n requestedSeq: SequenceNumber,\n deliveredSeq: Schema.optionalKey(SequenceNumber),\n});\nexport type RunSchedulingRequestRecord = typeof RunSchedulingRequestRecord.Type;\n\n/** A stale/duplicate permission is harmless and cannot allocate another run. */\nexport const RunGrantResult = Schema.Union([\n Schema.TaggedStruct(\"Granted\", { runId: RunId }),\n Schema.TaggedStruct(\"Stale\", {}),\n]);\nexport type RunGrantResult = typeof RunGrantResult.Type;\n\n/** Durable answer for reconciling an ambiguous grant delivery. Unknown never authorizes replacement work. */\nexport const RunRequestOutcome = Schema.Union([\n Schema.TaggedStruct(\"Unknown\", {}),\n Schema.TaggedStruct(\"Waiting\", {}),\n Schema.TaggedStruct(\"Invalidated\", {}),\n Schema.TaggedStruct(\"Granted\", {\n runId: RunId,\n status: Schema.Literals([\"Running\", \"Completed\", \"Failed\", \"Interrupted\"]),\n }),\n]);\nexport type RunRequestOutcome = typeof RunRequestOutcome.Type;\n\n/** Canonical records consulted by authorization policy, without an Effect-layer snapshot. */\ntype SchedulingState = Pick<\n ReducedState,\n \"commands\" | \"runs\" | \"messages\" | \"commandQueues\" | \"runSchedulingRequest\"\n>;\n\n/** Still-unconsumed inputs owned by a reservation, derived from the existing message records. */\nexport const runSchedulingInputMessageIds = (\n state: SchedulingState,\n work: RunSchedulingWork,\n): ReadonlyArray<MessageId> => {\n const command = state.commands.get(work.commandId)?.command;\n const candidates =\n work._tag === \"Recovery\"\n ? work.inputMessageIds\n : command?._tag === \"ResumePendingMessages\"\n ? command.messageIds\n : Array.from(state.messages.values()).flatMap((message) =>\n (message._tag === \"User\" || message._tag === \"Steering\") &&\n message.commandId === work.commandId\n ? [message.messageId]\n : [],\n );\n return candidates.filter((messageId) => {\n const message = state.messages.get(messageId);\n return (\n (message?._tag === \"User\" || message?._tag === \"Steering\") &&\n message.consumedSeq === undefined &&\n message.cancelledSeq === undefined &&\n message.pausedByCommandId === undefined\n );\n });\n};\n\n/** Revalidate durable ownership and pending controls immediately before granting permission. */\nexport const canGrantRun = (state: SchedulingState, requestId: RunRequestId): boolean => {\n const request = state.runSchedulingRequest;\n if (request?.requestId !== requestId) return false;\n const command = state.commands.get(request.work.commandId);\n if (command?.command === undefined || command.terminal !== undefined) return false;\n if (Array.from(state.runs.values()).some((run) => run.terminal === undefined)) return false;\n const inputs = runSchedulingInputMessageIds(state, request.work);\n if (request.work._tag === \"Command\") {\n if (command.startedSeq !== undefined) return false;\n // Older admitted commands did not commit their User message until run start.\n const legacySubmit =\n command.command._tag === \"SubmitMessage\" &&\n !Array.from(state.messages.values()).some(\n (message) =>\n (message._tag === \"User\" || message._tag === \"Steering\") &&\n message.commandId === command.commandId,\n );\n if (inputs.length === 0 && !legacySubmit) return false;\n } else {\n const predecessor = state.runs.get(request.work.interruptedRunId);\n if (\n command.startedSeq === undefined ||\n predecessor?.terminal === undefined ||\n !predecessor.commandIds.includes(command.commandId) ||\n (request.work.inputMessageIds.length > 0 && inputs.length === 0)\n )\n return false;\n }\n return !state.commandQueues.activeControlCommands.some((pending) => {\n if (pending.commandId === command.commandId) return false;\n switch (pending.command._tag) {\n case \"StopTurn\":\n return true;\n case \"SubmitMessage\":\n return pending.command.disposition === \"interrupt\";\n case \"CancelPendingMessage\":\n return inputs.includes(pending.command.messageId);\n default:\n return false;\n }\n });\n};\n\n/** Controls may change waiting work; later messages cannot take its reserved slot. */\nexport const waitingRunControl = (state: SchedulingState): PendingCommand | undefined => {\n const owner = state.runSchedulingRequest?.work.commandId;\n const controls = state.commandQueues.activeControlCommands.filter(\n (pending) =>\n pending.commandId !== owner &&\n (pending.command._tag !== \"SubmitMessage\" || pending.command.disposition === \"interrupt\"),\n );\n const priority = (pending: PendingCommand): number => {\n switch (pending.command._tag) {\n case \"StopTurn\":\n return 0;\n case \"CancelPendingMessage\":\n return 1;\n case \"PromotePendingMessage\":\n return 2;\n default:\n return 3;\n }\n };\n return controls.sort((a, b) => priority(a) - priority(b) || a.admittedSeq - b.admittedSeq)[0];\n};\n\n/** Atomic request changes required when one of its selected messages is cancelled. */\nexport interface RunSchedulingCancellationPlan {\n readonly requestId: RunRequestId;\n readonly cancelCommandId?: CommandId;\n readonly replacementWork?: RunSchedulingWork;\n}\n\n/** Preserve a recovery predecessor when cancellation leaves other selected inputs eligible. */\nexport const planRunSchedulingCancellation = (\n state: SchedulingState,\n messageId: MessageId,\n): RunSchedulingCancellationPlan | undefined => {\n const request = state.runSchedulingRequest;\n if (request === undefined) return undefined;\n const inputs = runSchedulingInputMessageIds(state, request.work);\n if (!inputs.includes(messageId)) return undefined;\n if (request.work._tag === \"Command\") return { requestId: request.requestId };\n const remainingInputs = inputs.filter((id) => id !== messageId);\n return remainingInputs.length === 0\n ? { requestId: request.requestId, cancelCommandId: request.work.commandId }\n : {\n requestId: request.requestId,\n replacementWork: { ...request.work, inputMessageIds: remainingInputs },\n };\n};\n\n/** Stop/interrupt facts that invalidate authorization and pause pending work before any run. */\nexport const planWaitingRunInterruption = (state: SchedulingState, controlCommandId: CommandId) => {\n const request = state.runSchedulingRequest;\n if (request === undefined) return undefined;\n return {\n requestId: request.requestId,\n messageIds: [...state.commandQueues.pendingQueue, ...state.commandQueues.pendingSteers]\n .filter((message) => message.commandId !== controlCommandId)\n .map((message) => message.messageId),\n cancelCommandId: request.work.commandId,\n };\n};\n"],"mappings":";;;;;;;AAyBA,MAAa,qBAAqB,OAAO,aAAa,SAAS,CAAC,CAAC;;AAIjE,MAAa,wBAAwB,OAAO,aAAa,YAAY,CAAC,CAAC;;AAIvE,MAAa,gBAAgB,OAAO,MAAM,CAAC,oBAAoB,qBAAqB,CAAC;;AAIrF,MAAa,oBAAoB,OAAO,MAAM,CAC5C,OAAO,aAAa,WAAW,EAAE,WAAW,UAAU,CAAC,GACvD,OAAO,aAAa,YAAY;CAC9B,WAAW;CACX,kBAAkB;CAClB,iBAAiB,OAAO,MAAM,SAAS;AACzC,CAAC,CACH,CAAC;;AAID,MAAa,uBAAuB,OAAO,OAAO;CAChD,WAAW;CACX,MAAM;AACR,CAAC;;AAID,MAAa,6BAA6B,OAAO,OAAO;CACtD,GAAG,qBAAqB;CACxB,cAAc;CACd,cAAc,OAAO,YAAY,cAAc;AACjD,CAAC;;AAID,MAAa,iBAAiB,OAAO,MAAM,CACzC,OAAO,aAAa,WAAW,EAAE,OAAO,MAAM,CAAC,GAC/C,OAAO,aAAa,SAAS,CAAC,CAAC,CACjC,CAAC;;AAID,MAAa,oBAAoB,OAAO,MAAM;CAC5C,OAAO,aAAa,WAAW,CAAC,CAAC;CACjC,OAAO,aAAa,WAAW,CAAC,CAAC;CACjC,OAAO,aAAa,eAAe,CAAC,CAAC;CACrC,OAAO,aAAa,WAAW;EAC7B,OAAO;EACP,QAAQ,OAAO,SAAS;GAAC;GAAW;GAAa;GAAU;EAAa,CAAC;CAC3E,CAAC;AACH,CAAC;;AAUD,MAAa,gCACX,OACA,SAC6B;CAC7B,MAAM,UAAU,MAAM,SAAS,IAAI,KAAK,SAAS,GAAG;CAYpD,QAVE,KAAK,SAAS,aACV,KAAK,kBACL,SAAS,SAAS,0BAChB,QAAQ,aACR,M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GAAG,QAAQ;GAAM,iBAAiB;EAAgB;CACvE;AACN;;AAGA,MAAa,8BAA8B,OAAwB,qBAAgC;CACjG,MAAM,UAAU,MAAM;CACtB,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAClC,OAAO;EACL,WAAW,QAAQ;EACnB,YAAY,CAAC,GAAG,MAAM,cAAc,cAAc,GAAG,MAAM,cAAc,aAAa,EACnF,QAAQ,YAAY,QAAQ,cAAc,gBAAgB,EAC1D,KAAK,YAAY,QAAQ,SAAS;EACrC,iBAAiB,QAAQ,KAAK;CAChC;AACF"}
@@ -1,83 +1,11 @@
1
- import { BaseStateId, CommandId, CompactionId, ContextVersion, CorrelationId, EventId, InferenceId, MessageId, Position, RunId, SequenceNumber, SessionId, SummaryId, ToolCallId, TurnId } from "./types/core.js";
1
+ import { BaseStateId, CommandId, CompactionId, ContextVersion, InferenceId, MessageId, RunId, RunRequestId, SequenceNumber, SummaryId, ToolCallId, TurnId } from "./types/core.js";
2
+ import { RunSchedulingRequest } from "./domain/run-scheduling.js";
3
+ import { EDARunTrace, makeEDARunTrace } from "./types/tracing.js";
4
+ import { _ as effectDurableAgentNamespace, c as ModelSelectionPayload, d as ProviderPartId, g as UsagePayload, m as ToolName, n as EphemeralEventEnvelope, p as SystemPromptText, s as FailurePayload, t as DurableEventEnvelope, v as makeEventType, y as schemaV1 } from "./envelope-DxQzo5rN.js";
2
5
  import { EDACommand, UserMessageContent } from "./types/commands.js";
3
- import { EDAEventTrace, EDARunTrace, makeEDARunTrace, makeRootEDAEventTrace } from "./types/tracing.js";
4
6
  import * as Effect from "effect/Effect";
5
7
  import * as Schema from "effect/Schema";
6
8
  import * as Prompt from "effect/unstable/ai/Prompt";
7
- //#region src/types/events/envelope.ts
8
- /** Event namespace, such as `effect-durable-agent`, `sandbox`, or `gia`. */
9
- const EventNamespace = Schema.NonEmptyString;
10
- /** Event type within a namespace, such as `CommandAdmitted` or `TextDelta`. */
11
- const EventType = Schema.NonEmptyString;
12
- /** Build a non-empty event type while preserving its string literal for exhaustive unions. */
13
- const makeEventType = (value) => value;
14
- /** Provider-supplied stream part identity, preserved for correlation/debugging. */
15
- const ProviderPartId = Schema.NonEmptyString.pipe(Schema.brand("ProviderPartId"));
16
- /** Positive schema version for one namespace/type payload contract. */
17
- const SchemaVersion = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
18
- /** Milliseconds since unix epoch, represented as a non-negative integer. */
19
- const UnixEpochMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("UnixEpochMillis"));
20
- /** Whether an event is persisted or live-only. */
21
- const EventDurability = Schema.Literals(["durable", "ephemeral"]);
22
- /** Common event envelope decoded before payload-specific schemas. */
23
- const EventEnvelope = Schema.Struct({
24
- namespace: EventNamespace,
25
- type: EventType,
26
- schemaVersion: SchemaVersion,
27
- durability: EventDurability,
28
- eventId: EventId,
29
- sessionId: SessionId,
30
- correlationId: Schema.optionalKey(CorrelationId),
31
- createdAtMs: UnixEpochMillis,
32
- trace: EDAEventTrace.pipe(Schema.withConstructorDefault(Effect.sync(makeRootEDAEventTrace))),
33
- payload: Schema.Unknown
34
- });
35
- /** Common envelope narrowed to committed durable events. */
36
- const DurableEventEnvelope = Schema.Struct({
37
- ...EventEnvelope.fields,
38
- durability: Schema.Literal("durable")
39
- });
40
- /** Common envelope narrowed to live-only ephemeral events. */
41
- const EphemeralEventEnvelope = Schema.Struct({
42
- ...EventEnvelope.fields,
43
- durability: Schema.Literal("ephemeral")
44
- });
45
- /** Event delivered to live subscribers with its durable/ephemeral position. */
46
- const PositionedEvent = Schema.Struct({
47
- position: Position,
48
- event: EventEnvelope
49
- });
50
- /** Built-in framework event namespace. */
51
- const effectDurableAgentNamespace = EventNamespace.make("effect-durable-agent");
52
- /** Initial schema version for built-in event payloads. */
53
- const schemaV1 = SchemaVersion.make(1);
54
- /** Non-negative integer used by token counts and similar counters. */
55
- const NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
56
- /** Registered tool name; plain non-empty text, not a lifecycle identity. */
57
- const ToolName = Schema.NonEmptyString;
58
- /** Error details stored on failed lifecycle events. */
59
- const FailurePayload = Schema.Struct({
60
- message: Schema.String,
61
- code: Schema.optionalKey(Schema.String),
62
- details: Schema.optionalKey(Schema.Unknown)
63
- });
64
- /** Token usage reported by a model provider when available. */
65
- const UsagePayload = Schema.Struct({
66
- inputTokens: Schema.optionalKey(NonNegativeInt),
67
- cachedInputTokens: Schema.optionalKey(NonNegativeInt),
68
- outputTokens: Schema.optionalKey(NonNegativeInt),
69
- textTokens: Schema.optionalKey(NonNegativeInt),
70
- reasoningTokens: Schema.optionalKey(NonNegativeInt)
71
- });
72
- /** Intended provider/model selection known before a model request starts. */
73
- const ModelSelectionPayload = Schema.Struct({
74
- provider: Schema.NonEmptyString,
75
- modelId: Schema.NonEmptyString,
76
- settings: Schema.optionalKey(Schema.Unknown)
77
- });
78
- /** App-owned instructions inserted into model context as a system message. */
79
- const SystemPromptText = Schema.NonEmptyString;
80
- //#endregion
81
9
  //#region src/types/events/internal.ts
82
10
  /** Build a built-in durable event schema from its fixed event type and payload schema. */
83
11
  const durableEventSchema = (type, payload) => Schema.Struct({
@@ -97,6 +25,9 @@ const ephemeralEventSchema = (type, payload) => Schema.Struct({
97
25
  });
98
26
  //#endregion
99
27
  //#region src/types/events/durable.ts
28
+ /** Establishes a session's execution policy before its first run; not a model-switch operation. */
29
+ const sessionConfiguredEventType = makeEventType("SessionConfigured");
30
+ const SessionConfiguredEvent = durableEventSchema(sessionConfiguredEventType, Schema.Struct({ modelSelection: ModelSelectionPayload }));
100
31
  /** Event type values for durable command lifecycle events. */
101
32
  const commandAdmittedEventType = makeEventType("CommandAdmitted");
102
33
  const commandStartedEventType = makeEventType("CommandStarted");
@@ -132,6 +63,40 @@ const CommandEvent = Schema.Union([
132
63
  CommandFailedEvent,
133
64
  CommandCancelledEvent
134
65
  ]);
66
+ /** Durable reservation for the next run slot, committed before outbound delivery. */
67
+ const runSchedulingRequestedEventType = makeEventType("RunSchedulingRequested");
68
+ const RunSchedulingRequestedPayload = RunSchedulingRequest;
69
+ const RunSchedulingRequestedEvent = durableEventSchema(runSchedulingRequestedEventType, RunSchedulingRequestedPayload);
70
+ /** Acknowledgment that the external authorizer durably accepted this request. */
71
+ const runSchedulingDeliveredEventType = makeEventType("RunSchedulingDelivered");
72
+ const RunSchedulingDeliveredPayload = Schema.Struct({ requestId: RunRequestId });
73
+ const RunSchedulingDeliveredEvent = durableEventSchema(runSchedulingDeliveredEventType, RunSchedulingDeliveredPayload);
74
+ /** Revocation of a reservation whose work was cancelled, stopped, or superseded. */
75
+ const runSchedulingInvalidatedEventType = makeEventType("RunSchedulingInvalidated");
76
+ const RunSchedulingInvalidatedPayload = Schema.Struct({
77
+ requestId: RunRequestId,
78
+ reason: Schema.Literals([
79
+ "stopped",
80
+ "interrupted",
81
+ "message-cancelled",
82
+ "ineligible"
83
+ ])
84
+ });
85
+ const RunSchedulingInvalidatedEvent = durableEventSchema(runSchedulingInvalidatedEventType, RunSchedulingInvalidatedPayload);
86
+ /** Permission consumed atomically with RunStarted; never a standalone authorization. */
87
+ const runSchedulingGrantedEventType = makeEventType("RunSchedulingGranted");
88
+ const RunSchedulingGrantedPayload = Schema.Struct({
89
+ requestId: RunRequestId,
90
+ runId: RunId
91
+ });
92
+ const RunSchedulingGrantedEvent = durableEventSchema(runSchedulingGrantedEventType, RunSchedulingGrantedPayload);
93
+ /** Framework facts for durable run authorization and its strict delivery acknowledgment. */
94
+ const RunSchedulingEvent = Schema.Union([
95
+ RunSchedulingRequestedEvent,
96
+ RunSchedulingDeliveredEvent,
97
+ RunSchedulingInvalidatedEvent,
98
+ RunSchedulingGrantedEvent
99
+ ]);
135
100
  /** Event type values for durable message lifecycle events. */
136
101
  const systemMessageCommittedEventType = makeEventType("SystemMessageCommitted");
137
102
  const userMessageCommittedEventType = makeEventType("UserMessageCommitted");
@@ -143,6 +108,7 @@ const userMessageCancelledEventType = makeEventType("UserMessageCancelled");
143
108
  const messageQueuePausedEventType = makeEventType("MessageQueuePaused");
144
109
  const pendingMessagesPausedEventType = makeEventType("PendingMessagesPaused");
145
110
  const assistantMessageCommittedEventType = makeEventType("AssistantMessageCommitted");
111
+ const assistantMessageImportedEventType = makeEventType("AssistantMessageImported");
146
112
  const assistantPartialCommittedEventType = makeEventType("AssistantPartialCommitted");
147
113
  /** Semantic assistant content derived from canonical prompt parts for query convenience. */
148
114
  const AssistantMessageContent = Schema.Struct({
@@ -234,12 +200,19 @@ const MessageQueuePausedPayload = Schema.Struct({
234
200
  reason: Schema.Literal("user-interrupted")
235
201
  });
236
202
  const MessageQueuePausedEvent = durableEventSchema(messageQueuePausedEventType, MessageQueuePausedPayload);
237
- const PendingMessagesPausedPayload = Schema.Struct({
203
+ const PendingMessagesPausedFields = {
238
204
  interruptionCommandId: CommandId,
239
- runId: RunId,
240
205
  messageIds: Schema.NonEmptyArray(MessageId),
241
206
  reason: Schema.Literal("user-interrupted")
242
- });
207
+ };
208
+ /** A pause refers to the running lifecycle or to permission still waiting before a run. */
209
+ const PendingMessagesPausedPayload = Schema.Union([Schema.Struct({
210
+ ...PendingMessagesPausedFields,
211
+ runId: RunId
212
+ }), Schema.Struct({
213
+ ...PendingMessagesPausedFields,
214
+ runRequestId: RunRequestId
215
+ })]);
243
216
  const PendingMessagesPausedEvent = durableEventSchema(pendingMessagesPausedEventType, PendingMessagesPausedPayload);
244
217
  /** Payload recorded when an assistant message is durably finalized. */
245
218
  const AssistantMessageCommittedPayload = Schema.Struct({
@@ -250,6 +223,15 @@ const AssistantMessageCommittedPayload = Schema.Struct({
250
223
  promptParts: AssistantPromptParts
251
224
  });
252
225
  const AssistantMessageCommittedEvent = durableEventSchema(assistantMessageCommittedEventType, AssistantMessageCommittedPayload);
226
+ /** Payload recorded when pre-existing assistant context is imported from an external transport. */
227
+ const AssistantMessageImportedPayload = Schema.Struct({
228
+ messageId: MessageId,
229
+ runId: RunId,
230
+ turnId: TurnId,
231
+ inferenceId: InferenceId,
232
+ promptParts: AssistantPromptParts
233
+ });
234
+ const AssistantMessageImportedEvent = durableEventSchema(assistantMessageImportedEventType, AssistantMessageImportedPayload);
253
235
  /** Payload recorded when a partial assistant message is preserved durably. */
254
236
  const AssistantPartialCommittedPayload = Schema.Struct({
255
237
  messageId: MessageId,
@@ -272,6 +254,7 @@ const MessageEvent = Schema.Union([
272
254
  MessageQueuePausedEvent,
273
255
  PendingMessagesPausedEvent,
274
256
  AssistantMessageCommittedEvent,
257
+ AssistantMessageImportedEvent,
275
258
  AssistantPartialCommittedEvent
276
259
  ]);
277
260
  /** Event type values for durable run lifecycle events. */
@@ -536,7 +519,11 @@ const SummaryCreatedPayload = Schema.Struct({
536
519
  });
537
520
  const SummaryCreatedEvent = durableEventSchema(summaryCreatedEventType, SummaryCreatedPayload);
538
521
  /** Payload recorded when compaction completes. */
539
- const CompactionCompletedPayload = Schema.Struct({ compactionId: CompactionId });
522
+ const CompactionCompletedPayload = Schema.Struct({
523
+ compactionId: CompactionId,
524
+ modelSelection: Schema.optionalKey(ModelSelectionPayload),
525
+ usage: Schema.optionalKey(UsagePayload)
526
+ });
540
527
  const CompactionCompletedEvent = durableEventSchema(compactionCompletedEventType, CompactionCompletedPayload);
541
528
  /** Payload recorded when durable context is rebased onto a summary. */
542
529
  const ContextRebasedPayload = Schema.Struct({
@@ -549,7 +536,9 @@ const ContextRebasedEvent = durableEventSchema(contextRebasedEventType, ContextR
549
536
  /** Payload recorded when compaction fails. */
550
537
  const CompactionFailedPayload = Schema.Struct({
551
538
  compactionId: CompactionId,
552
- error: FailurePayload
539
+ error: FailurePayload,
540
+ modelSelection: Schema.optionalKey(ModelSelectionPayload),
541
+ usage: Schema.optionalKey(UsagePayload)
553
542
  });
554
543
  const CompactionFailedEvent = durableEventSchema(compactionFailedEventType, CompactionFailedPayload);
555
544
  /** Durable event union for context projection and compaction boundaries. */
@@ -592,6 +581,8 @@ const BaseStateEvent = Schema.Union([
592
581
  ]);
593
582
  /** Built-in durable event union for framework-owned session facts. */
594
583
  const EDADurableEvent = Schema.Union([
584
+ SessionConfiguredEvent,
585
+ RunSchedulingEvent,
595
586
  CommandEvent,
596
587
  MessageEvent,
597
588
  RunEvent,
@@ -620,6 +611,6 @@ const decodeUnknownEDADurableEvent = (input) => Effect.try({
620
611
  catch: (error) => error
621
612
  });
622
613
  //#endregion
623
- export { RecoveryCompletedEvent as $, userMessagePromotedEventType as $n, UserMessageCancelledEvent as $t, CompactionRequestedEvent as A, pendingMessagesPausedEventType as An, ToolCallFailedEvent as At, EDADurableEventV1 as B, summaryCreatedEventType as Bn, ToolPromptPart as Bt, CommandFailedPayload as C, contextRebasedEventType as Cn, SystemMessageCommittedEvent as Ct, CompactionCompletedPayload as D, inferenceFailedEventType as Dn, ToolCallCreatedEvent as Dt, CompactionCompletedEvent as E, inferenceCompletedEventType as En, ToolCallCompletedPayload as Et, ContextProjectedEvent as F, runStartedEventType as Fn, ToolCallRejectionFeedback as Ft, InferenceFailedPayload as G, toolCallRejectedEventType as Gn, TurnEvent as Gt, InferenceCompletedPayload as H, toolCallCompletedEventType as Hn, ToolSuccessPromptPart as Ht, ContextProjectedPayload as I, steeringMessageCancelledEventType as In, ToolCallRejectionReason as It, MessageEvent as J, turnFailedEventType as Jn, TurnStartedEvent as Jt, InferenceStartedEvent as K, toolCallStartedEventType as Kn, TurnFailedEvent as Kt, ContextRebasedEvent as L, steeringMessageQueuedEventType as Ln, ToolCallStartedEvent as Lt, CompactionStartedEvent as M, runCompletedEventType as Mn, ToolCallPromptPart as Mt, CompactionStartedPayload as N, runFailedEventType as Nn, ToolCallRejectedEvent as Nt, CompactionFailedEvent as O, inferenceStartedEventType as On, ToolCallCreatedPayload as Ot, ContextAndCompactionEvent as P, runInterruptedEventType as Pn, ToolCallRejectedPayload as Pt, PendingMessagesPausedPayload as Q, userMessageCommittedEventType as Qn, UserMessageCancellationReason as Qt, ContextRebasedPayload as R, stopTurnAppliedEventType as Rn, ToolCallStartedPayload as Rt, CommandFailedEvent as S, contextProjectedEventType as Sn, SummaryCreatedPayload as St, CommandStartedPayload as T, decodeUnknownEDADurableEventSync as Tn, ToolCallCompletedEvent as Tt, InferenceEvent as U, toolCallCreatedEventType as Un, TurnCompletedEvent as Ut, InferenceCompletedEvent as V, systemMessageCommittedEventType as Vn, ToolRejectionPromptPart as Vt, InferenceFailedEvent as W, toolCallFailedEventType as Wn, TurnCompletedPayload as Wt, MessageQueuePausedPayload as X, turnStoppedEventType as Xn, TurnStoppedEvent as Xt, MessageQueuePausedEvent as Y, turnStartedEventType as Yn, TurnStartedPayload as Yt, PendingMessagesPausedEvent as Z, userMessageCancelledEventType as Zn, TurnStoppedPayload as Zt, CommandCancelledEvent as _, commandStartedEventType as _n, UsagePayload as _r, StopTurnAppliedEvent as _t, AssistantPartialCommittedPayload as a, UserMessagePromotedPayload as an, EventEnvelope as ar, RunEvent as at, CommandCompletedPayload as b, compactionRequestedEventType as bn, schemaV1 as br, StopTurnRequestedPayload as bt, BaseStateCreatedEvent as c, assistantMessageCommittedEventType as cn, FailurePayload as cr, RunInterruptedEvent as ct, BaseStateFailedEvent as d, baseStateFailedEventType as dn, PositionedEvent as dr, RunStartedPayload as dt, UserMessageCancelledPayload as en, userMessageSubmittedEventType as er, RecoveryCompletedPayload as et, BaseStateFailedPayload as f, baseStateRequestedEventType as fn, ProviderPartId as fr, SteeringMessageCancelledEvent as ft, CommandAdmittedPayload as g, commandFailedEventType as gn, UnixEpochMillis as gr, StopControlEvent as gt, CommandAdmittedEvent as h, commandCompletedEventType as hn, ToolName as hr, SteeringMessageQueuedPayload as ht, AssistantPartialCommittedEvent as i, UserMessagePromotedEvent as in, EventDurability as ir, RunCompletedPayload as it, CompactionRequestedPayload as j, recoveryCompletedEventType as jn, ToolCallFailedPayload as jt, CompactionFailedPayload as k, messageQueuePausedEventType as kn, ToolCallEvent as kt, BaseStateCreatedPayload as l, assistantPartialCommittedEventType as ln, ModelSelectionPayload as lr, RunInterruptedPayload as lt, BaseStateRequestedPayload as m, commandCancelledEventType as mn, SystemPromptText as mr, SteeringMessageQueuedEvent as mt, AssistantMessageCommittedPayload as n, UserMessageCommittedPayload as nn, DurableEventEnvelope as nr, RecoveryEvent as nt, AssistantPromptPart as o, UserMessageSubmittedEvent as on, EventNamespace as or, RunFailedEvent as ot, BaseStateRequestedEvent as p, commandAdmittedEventType as pn, SchemaVersion as pr, SteeringMessageCancelledPayload as pt, InferenceStartedPayload as q, turnCompletedEventType as qn, TurnFailedPayload as qt, AssistantMessageContent as r, UserMessageDisposition as rn, EphemeralEventEnvelope as rr, RunCompletedEvent as rt, AssistantPromptParts as s, UserMessageSubmittedPayload as sn, EventType as sr, RunFailedPayload as st, AssistantMessageCommittedEvent as t, UserMessageCommittedEvent as tn, ephemeralEventSchema as tr, RecoveryContinuation as tt, BaseStateEvent as u, baseStateCreatedEventType as un, NonNegativeInt as ur, RunStartedEvent as ut, CommandCancelledPayload as v, compactionCompletedEventType as vn, effectDurableAgentNamespace as vr, StopTurnAppliedPayload as vt, CommandStartedEvent as w, decodeUnknownEDADurableEvent as wn, SystemMessageCommittedPayload as wt, CommandEvent as x, compactionStartedEventType as xn, SummaryCreatedEvent as xt, CommandCompletedEvent as y, compactionFailedEventType as yn, makeEventType as yr, StopTurnRequestedEvent as yt, EDADurableEvent as z, stopTurnRequestedEventType as zn, ToolFailurePromptPart as zt };
614
+ export { PendingMessagesPausedEvent as $, sessionConfiguredEventType as $n, ToolRejectionPromptPart as $t, CompactionFailedEvent as A, commandStartedEventType as An, StopTurnAppliedPayload as At, ContextRebasedPayload as B, inferenceFailedEventType as Bn, ToolCallCreatedPayload as Bt, CommandEvent as C, baseStateCreatedEventType as Cn, SessionConfiguredEvent as Ct, CommandStartedPayload as D, commandCancelledEventType as Dn, SteeringMessageQueuedPayload as Dt, CommandStartedEvent as E, commandAdmittedEventType as En, SteeringMessageQueuedEvent as Et, CompactionStartedPayload as F, contextProjectedEventType as Fn, SystemMessageCommittedEvent as Ft, InferenceEvent as G, runCompletedEventType as Gn, ToolCallRejectedEvent as Gt, EDADurableEventV1 as H, messageQueuePausedEventType as Hn, ToolCallFailedEvent as Ht, ContextAndCompactionEvent as I, contextRebasedEventType as In, SystemMessageCommittedPayload as It, InferenceStartedEvent as J, runSchedulingDeliveredEventType as Jn, ToolCallRejectionReason as Jt, InferenceFailedEvent as K, runFailedEventType as Kn, ToolCallRejectedPayload as Kt, ContextProjectedEvent as L, decodeUnknownEDADurableEvent as Ln, ToolCallCompletedEvent as Lt, CompactionRequestedEvent as M, compactionFailedEventType as Mn, StopTurnRequestedPayload as Mt, CompactionRequestedPayload as N, compactionRequestedEventType as Nn, SummaryCreatedEvent as Nt, CompactionCompletedEvent as O, commandCompletedEventType as On, StopControlEvent as Ot, CompactionStartedEvent as P, compactionStartedEventType as Pn, SummaryCreatedPayload as Pt, MessageQueuePausedPayload as Q, runStartedEventType as Qn, ToolPromptPart as Qt, ContextProjectedPayload as R, decodeUnknownEDADurableEventSync as Rn, ToolCallCompletedPayload as Rt, CommandCompletedPayload as S, assistantPartialCommittedEventType as Sn, RunStartedPayload as St, CommandFailedPayload as T, baseStateRequestedEventType as Tn, SteeringMessageCancelledPayload as Tt, InferenceCompletedEvent as U, pendingMessagesPausedEventType as Un, ToolCallFailedPayload as Ut, EDADurableEvent as V, inferenceStartedEventType as Vn, ToolCallEvent as Vt, InferenceCompletedPayload as W, recoveryCompletedEventType as Wn, ToolCallPromptPart as Wt, MessageEvent as X, runSchedulingInvalidatedEventType as Xn, ToolCallStartedPayload as Xt, InferenceStartedPayload as Y, runSchedulingGrantedEventType as Yn, ToolCallStartedEvent as Yt, MessageQueuePausedEvent as Z, runSchedulingRequestedEventType as Zn, ToolFailurePromptPart as Zt, CommandAdmittedEvent as _, UserMessagePromotedPayload as _n, userMessagePromotedEventType as _r, RunSchedulingInvalidatedEvent as _t, AssistantMessageImportedPayload as a, TurnFailedPayload as an, systemMessageCommittedEventType as ar, RunCompletedEvent as at, CommandCancelledPayload as b, assistantMessageCommittedEventType as bn, RunSchedulingRequestedPayload as bt, AssistantPromptPart as c, TurnStoppedEvent as cn, toolCallFailedEventType as cr, RunFailedEvent as ct, BaseStateCreatedPayload as d, UserMessageCancelledEvent as dn, turnCompletedEventType as dr, RunInterruptedPayload as dt, ToolSuccessPromptPart as en, steeringMessageCancelledEventType as er, PendingMessagesPausedPayload as et, BaseStateEvent as f, UserMessageCancelledPayload as fn, turnFailedEventType as fr, RunSchedulingDeliveredEvent as ft, BaseStateRequestedPayload as g, UserMessagePromotedEvent as gn, userMessageCommittedEventType as gr, RunSchedulingGrantedPayload as gt, BaseStateRequestedEvent as h, UserMessageDisposition as hn, userMessageCancelledEventType as hr, RunSchedulingGrantedEvent as ht, AssistantMessageImportedEvent as i, TurnFailedEvent as in, summaryCreatedEventType as ir, RecoveryEvent as it, CompactionFailedPayload as j, compactionCompletedEventType as jn, StopTurnRequestedEvent as jt, CompactionCompletedPayload as k, commandFailedEventType as kn, StopTurnAppliedEvent as kt, AssistantPromptParts as l, TurnStoppedPayload as ln, toolCallRejectedEventType as lr, RunFailedPayload as lt, BaseStateFailedPayload as m, UserMessageCommittedPayload as mn, turnStoppedEventType as mr, RunSchedulingEvent as mt, AssistantMessageCommittedPayload as n, TurnCompletedPayload as nn, stopTurnAppliedEventType as nr, RecoveryCompletedPayload as nt, AssistantPartialCommittedEvent as o, TurnStartedEvent as on, toolCallCompletedEventType as or, RunCompletedPayload as ot, BaseStateFailedEvent as p, UserMessageCommittedEvent as pn, turnStartedEventType as pr, RunSchedulingDeliveredPayload as pt, InferenceFailedPayload as q, runInterruptedEventType as qn, ToolCallRejectionFeedback as qt, AssistantMessageContent as r, TurnEvent as rn, stopTurnRequestedEventType as rr, RecoveryContinuation as rt, AssistantPartialCommittedPayload as s, TurnStartedPayload as sn, toolCallCreatedEventType as sr, RunEvent as st, AssistantMessageCommittedEvent as t, TurnCompletedEvent as tn, steeringMessageQueuedEventType as tr, RecoveryCompletedEvent as tt, BaseStateCreatedEvent as u, UserMessageCancellationReason as un, toolCallStartedEventType as ur, RunInterruptedEvent as ut, CommandAdmittedPayload as v, UserMessageSubmittedEvent as vn, userMessageSubmittedEventType as vr, RunSchedulingInvalidatedPayload as vt, CommandFailedEvent as w, baseStateFailedEventType as wn, SteeringMessageCancelledEvent as wt, CommandCompletedEvent as x, assistantMessageImportedEventType as xn, RunStartedEvent as xt, CommandCancelledEvent as y, UserMessageSubmittedPayload as yn, ephemeralEventSchema as yr, RunSchedulingRequestedEvent as yt, ContextRebasedEvent as z, inferenceCompletedEventType as zn, ToolCallCreatedEvent as zt };
624
615
 
625
- //# sourceMappingURL=durable-C3Rz7kg3.js.map
616
+ //# sourceMappingURL=durable-BPHVFVvV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-BPHVFVvV.js","names":[],"sources":["../src/types/events/internal.ts","../src/types/events/durable.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport {\n DurableEventEnvelope,\n EphemeralEventEnvelope,\n EventType,\n effectDurableAgentNamespace,\n schemaV1,\n} from \"./envelope\";\n\n/** Build a built-in durable event schema from its fixed event type and payload schema. */\nexport const durableEventSchema = <const Type extends EventType, Payload extends Schema.Top>(\n type: Type,\n payload: Payload,\n) =>\n Schema.Struct({\n ...DurableEventEnvelope.fields,\n namespace: Schema.Literal(effectDurableAgentNamespace),\n type: Schema.Literal(type),\n schemaVersion: Schema.Literal(schemaV1),\n payload,\n });\n\n/** Build a built-in ephemeral event schema from its fixed event type and payload schema. */\nexport const ephemeralEventSchema = <const Type extends EventType, Payload extends Schema.Top>(\n type: Type,\n payload: Payload,\n) =>\n Schema.Struct({\n ...EphemeralEventEnvelope.fields,\n namespace: Schema.Literal(effectDurableAgentNamespace),\n type: Schema.Literal(type),\n schemaVersion: Schema.Literal(schemaV1),\n payload,\n });\n","import * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport * as Prompt from \"effect/unstable/ai/Prompt\";\n\nimport { EDACommand, UserMessageContent } from \"../commands\";\nimport {\n BaseStateId,\n CommandId,\n CompactionId,\n ContextVersion,\n InferenceId,\n MessageId,\n RunId,\n RunRequestId,\n SequenceNumber,\n SummaryId,\n ToolCallId,\n TurnId,\n} from \"../core\";\nimport {\n DurableEventEnvelope,\n FailurePayload,\n ModelSelectionPayload,\n ProviderPartId,\n SystemPromptText,\n ToolName,\n UsagePayload,\n effectDurableAgentNamespace,\n makeEventType,\n schemaV1,\n} from \"./envelope\";\nimport { RunSchedulingRequest } from \"../../domain/run-scheduling\";\nimport { durableEventSchema } from \"./internal\";\nimport { EDARunTrace, makeEDARunTrace } from \"../tracing\";\n\n/** Establishes a session's execution policy before its first run; not a model-switch operation. */\nexport const sessionConfiguredEventType = makeEventType(\"SessionConfigured\");\nexport const SessionConfiguredEvent = durableEventSchema(\n sessionConfiguredEventType,\n Schema.Struct({ modelSelection: ModelSelectionPayload }),\n);\nexport type SessionConfiguredEvent = typeof SessionConfiguredEvent.Type;\n\n/** Event type values for durable command lifecycle events. */\nexport const commandAdmittedEventType = makeEventType(\"CommandAdmitted\");\nexport const commandStartedEventType = makeEventType(\"CommandStarted\");\nexport const commandCompletedEventType = makeEventType(\"CommandCompleted\");\nexport const commandFailedEventType = makeEventType(\"CommandFailed\");\nexport const commandCancelledEventType = makeEventType(\"CommandCancelled\");\n\n/** Payload recorded when a command enters the durable session log. */\nexport const CommandAdmittedPayload = Schema.Struct({ command: EDACommand });\nexport type CommandAdmittedPayload = typeof CommandAdmittedPayload.Type;\nexport const CommandAdmittedEvent = durableEventSchema(\n commandAdmittedEventType,\n CommandAdmittedPayload,\n);\nexport type CommandAdmittedEvent = typeof CommandAdmittedEvent.Type;\n\n/** Payload recorded when command execution starts. */\nexport const CommandStartedPayload = Schema.Struct({ commandId: CommandId });\nexport type CommandStartedPayload = typeof CommandStartedPayload.Type;\nexport const CommandStartedEvent = durableEventSchema(\n commandStartedEventType,\n CommandStartedPayload,\n);\nexport type CommandStartedEvent = typeof CommandStartedEvent.Type;\n\n/** Payload recorded when command execution completes normally. */\nexport const CommandCompletedPayload = Schema.Struct({ commandId: CommandId });\nexport type CommandCompletedPayload = typeof CommandCompletedPayload.Type;\nexport const CommandCompletedEvent = durableEventSchema(\n commandCompletedEventType,\n CommandCompletedPayload,\n);\nexport type CommandCompletedEvent = typeof CommandCompletedEvent.Type;\n\n/** Payload recorded when command execution fails. */\nexport const CommandFailedPayload = Schema.Struct({ commandId: CommandId, error: FailurePayload });\nexport type CommandFailedPayload = typeof CommandFailedPayload.Type;\nexport const CommandFailedEvent = durableEventSchema(commandFailedEventType, CommandFailedPayload);\nexport type CommandFailedEvent = typeof CommandFailedEvent.Type;\n\n/** Payload recorded when a command is cancelled before completion. */\nexport const CommandCancelledPayload = Schema.Struct({\n commandId: CommandId,\n reason: Schema.String,\n});\nexport type CommandCancelledPayload = typeof CommandCancelledPayload.Type;\nexport const CommandCancelledEvent = durableEventSchema(\n commandCancelledEventType,\n CommandCancelledPayload,\n);\nexport type CommandCancelledEvent = typeof CommandCancelledEvent.Type;\n\n/** Durable event union for the command lifecycle. */\nexport const CommandEvent = Schema.Union([\n CommandAdmittedEvent,\n CommandStartedEvent,\n CommandCompletedEvent,\n CommandFailedEvent,\n CommandCancelledEvent,\n]);\nexport type CommandEvent = typeof CommandEvent.Type;\n\n/** Durable reservation for the next run slot, committed before outbound delivery. */\nexport const runSchedulingRequestedEventType = makeEventType(\"RunSchedulingRequested\");\nexport const RunSchedulingRequestedPayload = RunSchedulingRequest;\nexport type RunSchedulingRequestedPayload = typeof RunSchedulingRequestedPayload.Type;\nexport const RunSchedulingRequestedEvent = durableEventSchema(\n runSchedulingRequestedEventType,\n RunSchedulingRequestedPayload,\n);\nexport type RunSchedulingRequestedEvent = typeof RunSchedulingRequestedEvent.Type;\n\n/** Acknowledgment that the external authorizer durably accepted this request. */\nexport const runSchedulingDeliveredEventType = makeEventType(\"RunSchedulingDelivered\");\nexport const RunSchedulingDeliveredPayload = Schema.Struct({ requestId: RunRequestId });\nexport type RunSchedulingDeliveredPayload = typeof RunSchedulingDeliveredPayload.Type;\nexport const RunSchedulingDeliveredEvent = durableEventSchema(\n runSchedulingDeliveredEventType,\n RunSchedulingDeliveredPayload,\n);\nexport type RunSchedulingDeliveredEvent = typeof RunSchedulingDeliveredEvent.Type;\n\n/** Revocation of a reservation whose work was cancelled, stopped, or superseded. */\nexport const runSchedulingInvalidatedEventType = makeEventType(\"RunSchedulingInvalidated\");\nexport const RunSchedulingInvalidatedPayload = Schema.Struct({\n requestId: RunRequestId,\n reason: Schema.Literals([\"stopped\", \"interrupted\", \"message-cancelled\", \"ineligible\"]),\n});\nexport type RunSchedulingInvalidatedPayload = typeof RunSchedulingInvalidatedPayload.Type;\nexport const RunSchedulingInvalidatedEvent = durableEventSchema(\n runSchedulingInvalidatedEventType,\n RunSchedulingInvalidatedPayload,\n);\nexport type RunSchedulingInvalidatedEvent = typeof RunSchedulingInvalidatedEvent.Type;\n\n/** Permission consumed atomically with RunStarted; never a standalone authorization. */\nexport const runSchedulingGrantedEventType = makeEventType(\"RunSchedulingGranted\");\nexport const RunSchedulingGrantedPayload = Schema.Struct({ requestId: RunRequestId, runId: RunId });\nexport type RunSchedulingGrantedPayload = typeof RunSchedulingGrantedPayload.Type;\nexport const RunSchedulingGrantedEvent = durableEventSchema(\n runSchedulingGrantedEventType,\n RunSchedulingGrantedPayload,\n);\nexport type RunSchedulingGrantedEvent = typeof RunSchedulingGrantedEvent.Type;\n\n/** Framework facts for durable run authorization and its strict delivery acknowledgment. */\nexport const RunSchedulingEvent = Schema.Union([\n RunSchedulingRequestedEvent,\n RunSchedulingDeliveredEvent,\n RunSchedulingInvalidatedEvent,\n RunSchedulingGrantedEvent,\n]);\nexport type RunSchedulingEvent = typeof RunSchedulingEvent.Type;\n\n/** Event type values for durable message lifecycle events. */\nexport const systemMessageCommittedEventType = makeEventType(\"SystemMessageCommitted\");\nexport const userMessageCommittedEventType = makeEventType(\"UserMessageCommitted\");\nexport const steeringMessageQueuedEventType = makeEventType(\"SteeringMessageQueued\");\nexport const steeringMessageCancelledEventType = makeEventType(\"SteeringMessageCancelled\");\nexport const userMessageSubmittedEventType = makeEventType(\"UserMessageSubmitted\");\nexport const userMessagePromotedEventType = makeEventType(\"UserMessagePromoted\");\nexport const userMessageCancelledEventType = makeEventType(\"UserMessageCancelled\");\nexport const messageQueuePausedEventType = makeEventType(\"MessageQueuePaused\");\nexport const pendingMessagesPausedEventType = makeEventType(\"PendingMessagesPaused\");\nexport const assistantMessageCommittedEventType = makeEventType(\"AssistantMessageCommitted\");\nexport const assistantMessageImportedEventType = makeEventType(\"AssistantMessageImported\");\nexport const assistantPartialCommittedEventType = makeEventType(\"AssistantPartialCommitted\");\n\n/** Semantic assistant content derived from canonical prompt parts for query convenience. */\nexport const AssistantMessageContent = Schema.Struct({\n text: Schema.String,\n reasoning: Schema.optionalKey(Schema.String),\n});\nexport type AssistantMessageContent = typeof AssistantMessageContent.Type;\n\n/** Exact assistant-role prompt parts sent to the model for cache-faithful replay. */\nexport const AssistantPromptPart = Schema.Union([\n Prompt.TextPart,\n Prompt.FilePart,\n Prompt.ReasoningPart,\n Prompt.ToolCallPart,\n Prompt.ToolResultPart,\n Prompt.ToolApprovalRequestPart,\n]);\nexport type AssistantPromptPart = typeof AssistantPromptPart.Type;\n\n/** Exact non-empty assistant-role prompt content sent to the model. */\nexport const AssistantPromptParts = Schema.NonEmptyArray(AssistantPromptPart);\nexport type AssistantPromptParts = typeof AssistantPromptParts.Type;\n\n/** Exact assistant tool-call prompt part with EDA-branded provider identity. */\nexport const ToolCallPromptPart = Schema.Struct({\n ...Prompt.ToolCallPart.fields,\n id: ProviderPartId,\n name: ToolName,\n});\nexport type ToolCallPromptPart = typeof ToolCallPromptPart.Type;\n\n/** Exact tool-role prompt part sent to the model with EDA-branded provider identity. */\nexport const ToolPromptPart = Schema.Struct({\n ...Prompt.ToolResultPart.fields,\n id: ProviderPartId,\n name: ToolName,\n});\nexport type ToolPromptPart = typeof ToolPromptPart.Type;\n\n/** Payload recorded when app instructions become durable system-message context. */\nexport const SystemMessageCommittedPayload = Schema.Struct({\n messageId: MessageId,\n content: SystemPromptText,\n});\nexport type SystemMessageCommittedPayload = typeof SystemMessageCommittedPayload.Type;\nexport const SystemMessageCommittedEvent = durableEventSchema(\n systemMessageCommittedEventType,\n SystemMessageCommittedPayload,\n);\nexport type SystemMessageCommittedEvent = typeof SystemMessageCommittedEvent.Type;\n\n/** Payload recorded when a user message becomes durable session context. */\nexport const UserMessageCommittedPayload = Schema.Struct({\n commandId: CommandId,\n messageId: MessageId,\n content: UserMessageContent,\n});\nexport type UserMessageCommittedPayload = typeof UserMessageCommittedPayload.Type;\nexport const UserMessageCommittedEvent = durableEventSchema(\n userMessageCommittedEventType,\n UserMessageCommittedPayload,\n);\nexport type UserMessageCommittedEvent = typeof UserMessageCommittedEvent.Type;\n\n/** Payload recorded when steering context is queued for a future turn. */\nexport const SteeringMessageQueuedPayload = Schema.Struct({\n commandId: CommandId,\n messageId: MessageId,\n runId: RunId,\n content: UserMessageContent,\n});\nexport type SteeringMessageQueuedPayload = typeof SteeringMessageQueuedPayload.Type;\nexport const SteeringMessageQueuedEvent = durableEventSchema(\n steeringMessageQueuedEventType,\n SteeringMessageQueuedPayload,\n);\nexport type SteeringMessageQueuedEvent = typeof SteeringMessageQueuedEvent.Type;\n\n/** Payload recorded when queued steering will never be consumed by its target run. */\nexport const SteeringMessageCancelledPayload = Schema.Struct({\n messageId: MessageId,\n runId: RunId,\n reason: Schema.String,\n});\nexport type SteeringMessageCancelledPayload = typeof SteeringMessageCancelledPayload.Type;\nexport const SteeringMessageCancelledEvent = durableEventSchema(\n steeringMessageCancelledEventType,\n SteeringMessageCancelledPayload,\n);\nexport type SteeringMessageCancelledEvent = typeof SteeringMessageCancelledEvent.Type;\n\nexport const UserMessageDisposition = Schema.Literals([\"queue\", \"steer\"]);\nexport type UserMessageDisposition = typeof UserMessageDisposition.Type;\n\nexport const UserMessageSubmittedPayload = Schema.Struct({\n commandId: CommandId,\n messageId: MessageId,\n disposition: UserMessageDisposition,\n content: UserMessageContent,\n});\nexport type UserMessageSubmittedPayload = typeof UserMessageSubmittedPayload.Type;\nexport const UserMessageSubmittedEvent = durableEventSchema(\n userMessageSubmittedEventType,\n UserMessageSubmittedPayload,\n);\nexport type UserMessageSubmittedEvent = typeof UserMessageSubmittedEvent.Type;\n\nexport const UserMessagePromotedPayload = Schema.Struct({\n commandId: CommandId,\n messageId: MessageId,\n from: Schema.Literal(\"queue\"),\n to: Schema.Literal(\"steer\"),\n});\nexport type UserMessagePromotedPayload = typeof UserMessagePromotedPayload.Type;\nexport const UserMessagePromotedEvent = durableEventSchema(\n userMessagePromotedEventType,\n UserMessagePromotedPayload,\n);\nexport type UserMessagePromotedEvent = typeof UserMessagePromotedEvent.Type;\n\nexport const UserMessageCancellationReason = Schema.Literals([\n \"edit\",\n \"user-cancel\",\n \"clear-paused-queue\",\n]);\nexport type UserMessageCancellationReason = typeof UserMessageCancellationReason.Type;\nexport const UserMessageCancelledPayload = Schema.Struct({\n commandId: CommandId,\n messageId: MessageId,\n reason: UserMessageCancellationReason,\n});\nexport type UserMessageCancelledPayload = typeof UserMessageCancelledPayload.Type;\nexport const UserMessageCancelledEvent = durableEventSchema(\n userMessageCancelledEventType,\n UserMessageCancelledPayload,\n);\nexport type UserMessageCancelledEvent = typeof UserMessageCancelledEvent.Type;\n\n/** Legacy V1 pause fact retained for replay compatibility. */\nexport const MessageQueuePausedPayload = Schema.Struct({\n stopCommandId: CommandId,\n runId: RunId,\n messageIds: Schema.Array(MessageId),\n reason: Schema.Literal(\"user-interrupted\"),\n});\nexport type MessageQueuePausedPayload = typeof MessageQueuePausedPayload.Type;\nexport const MessageQueuePausedEvent = durableEventSchema(\n messageQueuePausedEventType,\n MessageQueuePausedPayload,\n);\nexport type MessageQueuePausedEvent = typeof MessageQueuePausedEvent.Type;\n\nconst PendingMessagesPausedFields = {\n interruptionCommandId: CommandId,\n messageIds: Schema.NonEmptyArray(MessageId),\n reason: Schema.Literal(\"user-interrupted\"),\n};\n/** A pause refers to the running lifecycle or to permission still waiting before a run. */\nexport const PendingMessagesPausedPayload = Schema.Union([\n Schema.Struct({ ...PendingMessagesPausedFields, runId: RunId }),\n Schema.Struct({ ...PendingMessagesPausedFields, runRequestId: RunRequestId }),\n]);\nexport type PendingMessagesPausedPayload = typeof PendingMessagesPausedPayload.Type;\nexport const PendingMessagesPausedEvent = durableEventSchema(\n pendingMessagesPausedEventType,\n PendingMessagesPausedPayload,\n);\nexport type PendingMessagesPausedEvent = typeof PendingMessagesPausedEvent.Type;\n\n/** Payload recorded when an assistant message is durably finalized. */\nexport const AssistantMessageCommittedPayload = Schema.Struct({\n messageId: MessageId,\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n promptParts: AssistantPromptParts,\n});\nexport type AssistantMessageCommittedPayload = typeof AssistantMessageCommittedPayload.Type;\nexport const AssistantMessageCommittedEvent = durableEventSchema(\n assistantMessageCommittedEventType,\n AssistantMessageCommittedPayload,\n);\nexport type AssistantMessageCommittedEvent = typeof AssistantMessageCommittedEvent.Type;\n\n/** Payload recorded when pre-existing assistant context is imported from an external transport. */\nexport const AssistantMessageImportedPayload = Schema.Struct({\n messageId: MessageId,\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n promptParts: AssistantPromptParts,\n});\nexport type AssistantMessageImportedPayload = typeof AssistantMessageImportedPayload.Type;\nexport const AssistantMessageImportedEvent = durableEventSchema(\n assistantMessageImportedEventType,\n AssistantMessageImportedPayload,\n);\nexport type AssistantMessageImportedEvent = typeof AssistantMessageImportedEvent.Type;\n\n/** Payload recorded when a partial assistant message is preserved durably. */\nexport const AssistantPartialCommittedPayload = Schema.Struct({\n messageId: MessageId,\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n promptParts: AssistantPromptParts,\n reason: Schema.String,\n});\nexport type AssistantPartialCommittedPayload = typeof AssistantPartialCommittedPayload.Type;\nexport const AssistantPartialCommittedEvent = durableEventSchema(\n assistantPartialCommittedEventType,\n AssistantPartialCommittedPayload,\n);\nexport type AssistantPartialCommittedEvent = typeof AssistantPartialCommittedEvent.Type;\n\n/** Durable event union for message commit/queue boundaries. */\nexport const MessageEvent = Schema.Union([\n SystemMessageCommittedEvent,\n UserMessageCommittedEvent,\n SteeringMessageQueuedEvent,\n SteeringMessageCancelledEvent,\n UserMessageSubmittedEvent,\n UserMessagePromotedEvent,\n UserMessageCancelledEvent,\n MessageQueuePausedEvent,\n PendingMessagesPausedEvent,\n AssistantMessageCommittedEvent,\n AssistantMessageImportedEvent,\n AssistantPartialCommittedEvent,\n]);\nexport type MessageEvent = typeof MessageEvent.Type;\n\n/** Event type values for durable run lifecycle events. */\nexport const runStartedEventType = makeEventType(\"RunStarted\");\nexport const runCompletedEventType = makeEventType(\"RunCompleted\");\nexport const runFailedEventType = makeEventType(\"RunFailed\");\n/** @deprecated Legacy terminal retained for durable replay. Emit `RunFailed` with an interruption-coded `FailurePayload` instead. */\nexport const runInterruptedEventType = makeEventType(\"RunInterrupted\");\n\n/** Payload recorded when a run starts with its intended model selection. */\nexport const RunStartedPayload = Schema.Struct({\n runId: RunId,\n commandIds: Schema.Array(CommandId),\n modelSelection: ModelSelectionPayload,\n trace: EDARunTrace.pipe(Schema.withConstructorDefault(Effect.sync(() => makeEDARunTrace()))),\n});\nexport type RunStartedPayload = typeof RunStartedPayload.Type;\nexport const RunStartedEvent = durableEventSchema(runStartedEventType, RunStartedPayload);\nexport type RunStartedEvent = typeof RunStartedEvent.Type;\n\n/** Payload recorded when a run completes. */\nexport const RunCompletedPayload = Schema.Struct({ runId: RunId });\nexport type RunCompletedPayload = typeof RunCompletedPayload.Type;\nexport const RunCompletedEvent = durableEventSchema(runCompletedEventType, RunCompletedPayload);\nexport type RunCompletedEvent = typeof RunCompletedEvent.Type;\n\n/** Payload recorded when a run fails. */\nexport const RunFailedPayload = Schema.Struct({ runId: RunId, error: FailurePayload });\nexport type RunFailedPayload = typeof RunFailedPayload.Type;\nexport const RunFailedEvent = durableEventSchema(runFailedEventType, RunFailedPayload);\nexport type RunFailedEvent = typeof RunFailedEvent.Type;\n\n/** @deprecated Legacy payload retained for durable replay. New interruptions use `RunFailedPayload` with `error.code = \"run.interrupted\"`. */\nexport const RunInterruptedPayload = Schema.Struct({ runId: RunId, reason: Schema.String });\n/** @deprecated Use `RunFailedPayload` with interruption metadata. */\nexport type RunInterruptedPayload = typeof RunInterruptedPayload.Type;\n/** @deprecated Legacy event schema retained for durable replay; new producers emit `RunFailedEvent`. */\nexport const RunInterruptedEvent = durableEventSchema(\n runInterruptedEventType,\n RunInterruptedPayload,\n);\n/** @deprecated Use `RunFailedEvent` with interruption metadata. */\nexport type RunInterruptedEvent = typeof RunInterruptedEvent.Type;\n\n/** Durable event union for run lifecycle boundaries. */\nexport const RunEvent = Schema.Union([\n RunStartedEvent,\n RunCompletedEvent,\n RunFailedEvent,\n RunInterruptedEvent,\n]);\nexport type RunEvent = typeof RunEvent.Type;\n\n/** Event type value for the durable barrier written after real startup recovery work. */\nexport const recoveryCompletedEventType = makeEventType(\"RecoveryCompleted\");\n\n/** Explicit relationship between an interrupted run and its startup-recovery replacement. */\nexport const RecoveryContinuation = Schema.Struct({\n commandId: CommandId,\n interruptedRunId: RunId,\n replacementRunId: RunId,\n});\nexport type RecoveryContinuation = typeof RecoveryContinuation.Type;\n\n/**\n * Durable completion barrier for a startup recovery transaction that repaired\n * unfinished state. Idle runtime construction does not emit this event.\n */\nexport const RecoveryCompletedPayload = Schema.Struct({\n trigger: Schema.Literal(\"runtime-restart\"),\n continuation: Schema.optionalKey(RecoveryContinuation),\n});\nexport type RecoveryCompletedPayload = typeof RecoveryCompletedPayload.Type;\nexport const RecoveryCompletedEvent = durableEventSchema(\n recoveryCompletedEventType,\n RecoveryCompletedPayload,\n);\nexport type RecoveryCompletedEvent = typeof RecoveryCompletedEvent.Type;\n\n/** Durable facts written only by the framework startup-recovery transaction. */\nexport const RecoveryEvent = RecoveryCompletedEvent;\nexport type RecoveryEvent = typeof RecoveryEvent.Type;\n\n/** Event type values for durable turn lifecycle events. */\nexport const turnStartedEventType = makeEventType(\"TurnStarted\");\nexport const turnCompletedEventType = makeEventType(\"TurnCompleted\");\nexport const turnFailedEventType = makeEventType(\"TurnFailed\");\n/** @deprecated Legacy terminal retained for durable replay. Emit `TurnFailed` with an interruption-coded `FailurePayload` instead. */\nexport const turnStoppedEventType = makeEventType(\"TurnStopped\");\n\n/** Payload recorded when one turn starts inside a run. */\nexport const TurnStartedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n inputMessageIds: Schema.optionalKey(Schema.Array(MessageId)),\n});\nexport type TurnStartedPayload = typeof TurnStartedPayload.Type;\nexport const TurnStartedEvent = durableEventSchema(turnStartedEventType, TurnStartedPayload);\nexport type TurnStartedEvent = typeof TurnStartedEvent.Type;\n\n/** Payload recorded when one turn completes. */\nexport const TurnCompletedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n usage: Schema.optionalKey(UsagePayload),\n});\nexport type TurnCompletedPayload = typeof TurnCompletedPayload.Type;\nexport const TurnCompletedEvent = durableEventSchema(turnCompletedEventType, TurnCompletedPayload);\nexport type TurnCompletedEvent = typeof TurnCompletedEvent.Type;\n\n/** Payload recorded when one turn fails. */\nexport const TurnFailedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n error: FailurePayload,\n});\nexport type TurnFailedPayload = typeof TurnFailedPayload.Type;\nexport const TurnFailedEvent = durableEventSchema(turnFailedEventType, TurnFailedPayload);\nexport type TurnFailedEvent = typeof TurnFailedEvent.Type;\n\n/** @deprecated Legacy payload retained for durable replay. New stops use `TurnFailedPayload` with `error.code = \"turn.interrupted\"`. */\nexport const TurnStoppedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n reason: Schema.String,\n});\n/** @deprecated Use `TurnFailedPayload` with interruption metadata. */\nexport type TurnStoppedPayload = typeof TurnStoppedPayload.Type;\n/** @deprecated Legacy event schema retained for durable replay; new producers emit `TurnFailedEvent`. */\nexport const TurnStoppedEvent = durableEventSchema(turnStoppedEventType, TurnStoppedPayload);\n/** @deprecated Use `TurnFailedEvent` with interruption metadata. */\nexport type TurnStoppedEvent = typeof TurnStoppedEvent.Type;\n\n/** Durable event union for turn lifecycle boundaries. */\nexport const TurnEvent = Schema.Union([\n TurnStartedEvent,\n TurnCompletedEvent,\n TurnFailedEvent,\n TurnStoppedEvent,\n]);\nexport type TurnEvent = typeof TurnEvent.Type;\n\n/** Event type values for durable model-inference lifecycle events. */\nexport const inferenceStartedEventType = makeEventType(\"InferenceStarted\");\nexport const inferenceCompletedEventType = makeEventType(\"InferenceCompleted\");\nexport const inferenceFailedEventType = makeEventType(\"InferenceFailed\");\n\n/** Payload recorded when one model inference starts for a turn. */\nexport const InferenceStartedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n});\nexport type InferenceStartedPayload = typeof InferenceStartedPayload.Type;\nexport const InferenceStartedEvent = durableEventSchema(\n inferenceStartedEventType,\n InferenceStartedPayload,\n);\nexport type InferenceStartedEvent = typeof InferenceStartedEvent.Type;\n\n/** Payload recorded when one model inference completes. */\nexport const InferenceCompletedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n finishReason: Schema.optionalKey(Schema.String),\n usage: Schema.optionalKey(UsagePayload),\n responseMetadata: Schema.optionalKey(Schema.Unknown),\n finishMetadata: Schema.optionalKey(Schema.Unknown),\n});\nexport type InferenceCompletedPayload = typeof InferenceCompletedPayload.Type;\nexport const InferenceCompletedEvent = durableEventSchema(\n inferenceCompletedEventType,\n InferenceCompletedPayload,\n);\nexport type InferenceCompletedEvent = typeof InferenceCompletedEvent.Type;\n\n/** Payload recorded when one model inference fails or is interrupted. */\nexport const InferenceFailedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n error: FailurePayload,\n});\nexport type InferenceFailedPayload = typeof InferenceFailedPayload.Type;\nexport const InferenceFailedEvent = durableEventSchema(\n inferenceFailedEventType,\n InferenceFailedPayload,\n);\nexport type InferenceFailedEvent = typeof InferenceFailedEvent.Type;\n\n/** Durable event union for canonical model-inference lifecycle boundaries. */\nexport const InferenceEvent = Schema.Union([\n InferenceStartedEvent,\n InferenceCompletedEvent,\n InferenceFailedEvent,\n]);\nexport type InferenceEvent = typeof InferenceEvent.Type;\n\n/** Event type values for durable tool lifecycle events. */\nexport const toolCallCreatedEventType = makeEventType(\"ToolCallCreated\");\nexport const toolCallRejectedEventType = makeEventType(\"ToolCallRejected\");\nexport const toolCallStartedEventType = makeEventType(\"ToolCallStarted\");\nexport const toolCallCompletedEventType = makeEventType(\"ToolCallCompleted\");\nexport const toolCallFailedEventType = makeEventType(\"ToolCallFailed\");\n\n/** Reason a model-requested tool call was rejected before execution. */\nexport const ToolCallRejectionReason = Schema.Literals([\"unknown-tool\", \"invalid-params\"]);\nexport type ToolCallRejectionReason = typeof ToolCallRejectionReason.Type;\n\n/** Exact synthetic tool-result feedback for a rejected model-requested tool call. */\nexport const ToolCallRejectionFeedback = Schema.Struct({\n message: Schema.String,\n reason: ToolCallRejectionReason,\n modelFeedback: Schema.NonEmptyString,\n});\nexport type ToolCallRejectionFeedback = typeof ToolCallRejectionFeedback.Type;\n\n/** Exact prompt part for a rejected model-requested tool call. */\nexport const ToolRejectionPromptPart = Schema.Struct({\n ...ToolPromptPart.fields,\n isFailure: Schema.Literal(true),\n result: ToolCallRejectionFeedback,\n});\nexport type ToolRejectionPromptPart = typeof ToolRejectionPromptPart.Type;\n\n/** Exact prompt part for a successful framework-owned tool result. */\nexport const ToolSuccessPromptPart = Schema.Struct({\n ...ToolPromptPart.fields,\n isFailure: Schema.Literal(false),\n result: Schema.Unknown,\n});\nexport type ToolSuccessPromptPart = typeof ToolSuccessPromptPart.Type;\n\n/** Exact prompt part for a failed framework-owned tool result. */\nexport const ToolFailurePromptPart = Schema.Struct({\n ...ToolPromptPart.fields,\n isFailure: Schema.Literal(true),\n result: FailurePayload,\n});\nexport type ToolFailurePromptPart = typeof ToolFailurePromptPart.Type;\n\n/** Payload recorded once streamed tool parameters validate and become executable. */\nexport const ToolCallCreatedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n toolCallId: ToolCallId,\n promptPart: ToolCallPromptPart,\n});\nexport type ToolCallCreatedPayload = typeof ToolCallCreatedPayload.Type;\nexport const ToolCallCreatedEvent = durableEventSchema(\n toolCallCreatedEventType,\n ToolCallCreatedPayload,\n);\nexport type ToolCallCreatedEvent = typeof ToolCallCreatedEvent.Type;\n\n/** Payload recorded when a model-requested tool call is not executable. */\nexport const ToolCallRejectedPayload = Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n inferenceId: InferenceId,\n toolCallId: ToolCallId,\n promptPart: ToolRejectionPromptPart,\n});\nexport type ToolCallRejectedPayload = typeof ToolCallRejectedPayload.Type;\nexport const ToolCallRejectedEvent = durableEventSchema(\n toolCallRejectedEventType,\n ToolCallRejectedPayload,\n);\nexport type ToolCallRejectedEvent = typeof ToolCallRejectedEvent.Type;\n\n/** Payload recorded when framework-owned tool execution starts. */\nexport const ToolCallStartedPayload = Schema.Struct({ toolCallId: ToolCallId });\nexport type ToolCallStartedPayload = typeof ToolCallStartedPayload.Type;\nexport const ToolCallStartedEvent = durableEventSchema(\n toolCallStartedEventType,\n ToolCallStartedPayload,\n);\nexport type ToolCallStartedEvent = typeof ToolCallStartedEvent.Type;\n\n/** Payload recorded when a tool call completes with a result. */\nexport const ToolCallCompletedPayload = Schema.Struct({\n toolCallId: ToolCallId,\n promptPart: ToolSuccessPromptPart,\n});\nexport type ToolCallCompletedPayload = typeof ToolCallCompletedPayload.Type;\nexport const ToolCallCompletedEvent = durableEventSchema(\n toolCallCompletedEventType,\n ToolCallCompletedPayload,\n);\nexport type ToolCallCompletedEvent = typeof ToolCallCompletedEvent.Type;\n\n/** Payload recorded when a tool call fails. */\nexport const ToolCallFailedPayload = Schema.Struct({\n toolCallId: ToolCallId,\n error: Schema.optionalKey(FailurePayload),\n promptPart: ToolFailurePromptPart,\n});\nexport type ToolCallFailedPayload = typeof ToolCallFailedPayload.Type;\nexport const ToolCallFailedEvent = durableEventSchema(\n toolCallFailedEventType,\n ToolCallFailedPayload,\n);\nexport type ToolCallFailedEvent = typeof ToolCallFailedEvent.Type;\n\n/** Durable event union for tool lifecycle boundaries. */\nexport const ToolCallEvent = Schema.Union([\n ToolCallCreatedEvent,\n ToolCallRejectedEvent,\n ToolCallStartedEvent,\n ToolCallCompletedEvent,\n ToolCallFailedEvent,\n]);\nexport type ToolCallEvent = typeof ToolCallEvent.Type;\n\n/** Event type values for durable stop-control events. */\nexport const stopTurnRequestedEventType = makeEventType(\"StopTurnRequested\");\nexport const stopTurnAppliedEventType = makeEventType(\"StopTurnApplied\");\n\n/** Payload recorded when a stop command targets active or future turn work. */\nexport const StopTurnRequestedPayload = Schema.Struct({\n commandId: CommandId,\n runId: Schema.optionalKey(RunId),\n turnId: Schema.optionalKey(TurnId),\n});\nexport type StopTurnRequestedPayload = typeof StopTurnRequestedPayload.Type;\nexport const StopTurnRequestedEvent = durableEventSchema(\n stopTurnRequestedEventType,\n StopTurnRequestedPayload,\n);\nexport type StopTurnRequestedEvent = typeof StopTurnRequestedEvent.Type;\n\n/** Payload recorded when a stop request has affected runtime work. */\nexport const StopTurnAppliedPayload = Schema.Struct({\n commandId: CommandId,\n runId: RunId,\n turnId: TurnId,\n inferenceId: Schema.optionalKey(InferenceId),\n});\nexport type StopTurnAppliedPayload = typeof StopTurnAppliedPayload.Type;\nexport const StopTurnAppliedEvent = durableEventSchema(\n stopTurnAppliedEventType,\n StopTurnAppliedPayload,\n);\nexport type StopTurnAppliedEvent = typeof StopTurnAppliedEvent.Type;\n\n/** Durable event union for stop-request lifecycle boundaries. */\nexport const StopControlEvent = Schema.Union([StopTurnRequestedEvent, StopTurnAppliedEvent]);\nexport type StopControlEvent = typeof StopControlEvent.Type;\n\n/** Event type values for durable context and compaction events. */\nexport const contextProjectedEventType = makeEventType(\"ContextProjected\");\nexport const compactionRequestedEventType = makeEventType(\"CompactionRequested\");\nexport const compactionStartedEventType = makeEventType(\"CompactionStarted\");\nexport const summaryCreatedEventType = makeEventType(\"SummaryCreated\");\nexport const compactionCompletedEventType = makeEventType(\"CompactionCompleted\");\nexport const contextRebasedEventType = makeEventType(\"ContextRebased\");\nexport const compactionFailedEventType = makeEventType(\"CompactionFailed\");\n\n/** Payload recorded when the prompt context projection advances. */\nexport const ContextProjectedPayload = Schema.Struct({\n contextVersion: ContextVersion,\n throughSeq: SequenceNumber,\n});\nexport type ContextProjectedPayload = typeof ContextProjectedPayload.Type;\nexport const ContextProjectedEvent = durableEventSchema(\n contextProjectedEventType,\n ContextProjectedPayload,\n);\nexport type ContextProjectedEvent = typeof ContextProjectedEvent.Type;\n\n/** Payload recorded when compaction is requested for a durable range. */\nexport const CompactionRequestedPayload = Schema.Struct({\n compactionId: CompactionId,\n sourceFromSeq: SequenceNumber,\n sourceToSeq: SequenceNumber,\n});\nexport type CompactionRequestedPayload = typeof CompactionRequestedPayload.Type;\nexport const CompactionRequestedEvent = durableEventSchema(\n compactionRequestedEventType,\n CompactionRequestedPayload,\n);\nexport type CompactionRequestedEvent = typeof CompactionRequestedEvent.Type;\n\n/** Payload recorded when compaction starts. */\nexport const CompactionStartedPayload = Schema.Struct({ compactionId: CompactionId });\nexport type CompactionStartedPayload = typeof CompactionStartedPayload.Type;\nexport const CompactionStartedEvent = durableEventSchema(\n compactionStartedEventType,\n CompactionStartedPayload,\n);\nexport type CompactionStartedEvent = typeof CompactionStartedEvent.Type;\n\n/** Payload recorded when a summary artifact is created. */\nexport const SummaryCreatedPayload = Schema.Struct({\n compactionId: CompactionId,\n summaryId: SummaryId,\n sourceFromSeq: SequenceNumber,\n sourceToSeq: SequenceNumber,\n summary: Schema.Unknown,\n});\nexport type SummaryCreatedPayload = typeof SummaryCreatedPayload.Type;\nexport const SummaryCreatedEvent = durableEventSchema(\n summaryCreatedEventType,\n SummaryCreatedPayload,\n);\nexport type SummaryCreatedEvent = typeof SummaryCreatedEvent.Type;\n\n/** Payload recorded when compaction completes. */\nexport const CompactionCompletedPayload = Schema.Struct({\n compactionId: CompactionId,\n modelSelection: Schema.optionalKey(ModelSelectionPayload),\n usage: Schema.optionalKey(UsagePayload),\n});\nexport type CompactionCompletedPayload = typeof CompactionCompletedPayload.Type;\nexport const CompactionCompletedEvent = durableEventSchema(\n compactionCompletedEventType,\n CompactionCompletedPayload,\n);\nexport type CompactionCompletedEvent = typeof CompactionCompletedEvent.Type;\n\n/** Payload recorded when durable context is rebased onto a summary. */\nexport const ContextRebasedPayload = Schema.Struct({\n compactionId: CompactionId,\n summaryId: SummaryId,\n contextVersion: ContextVersion,\n retainedFromContextSeq: SequenceNumber,\n});\nexport type ContextRebasedPayload = typeof ContextRebasedPayload.Type;\nexport const ContextRebasedEvent = durableEventSchema(\n contextRebasedEventType,\n ContextRebasedPayload,\n);\nexport type ContextRebasedEvent = typeof ContextRebasedEvent.Type;\n\n/** Payload recorded when compaction fails. */\nexport const CompactionFailedPayload = Schema.Struct({\n compactionId: CompactionId,\n error: FailurePayload,\n modelSelection: Schema.optionalKey(ModelSelectionPayload),\n usage: Schema.optionalKey(UsagePayload),\n});\nexport type CompactionFailedPayload = typeof CompactionFailedPayload.Type;\nexport const CompactionFailedEvent = durableEventSchema(\n compactionFailedEventType,\n CompactionFailedPayload,\n);\nexport type CompactionFailedEvent = typeof CompactionFailedEvent.Type;\n\n/** Durable event union for context projection and compaction boundaries. */\nexport const ContextAndCompactionEvent = Schema.Union([\n ContextProjectedEvent,\n CompactionRequestedEvent,\n CompactionStartedEvent,\n SummaryCreatedEvent,\n CompactionCompletedEvent,\n ContextRebasedEvent,\n CompactionFailedEvent,\n]);\nexport type ContextAndCompactionEvent = typeof ContextAndCompactionEvent.Type;\n\n/** Event type values for durable BaseState lifecycle events. */\nexport const baseStateRequestedEventType = makeEventType(\"BaseStateRequested\");\nexport const baseStateCreatedEventType = makeEventType(\"BaseStateCreated\");\nexport const baseStateFailedEventType = makeEventType(\"BaseStateFailed\");\n\n/** Payload recorded when durable BaseState generation is requested. */\nexport const BaseStateRequestedPayload = Schema.Struct({\n baseStateId: BaseStateId,\n requestedThroughSeq: SequenceNumber,\n});\nexport type BaseStateRequestedPayload = typeof BaseStateRequestedPayload.Type;\nexport const BaseStateRequestedEvent = durableEventSchema(\n baseStateRequestedEventType,\n BaseStateRequestedPayload,\n);\nexport type BaseStateRequestedEvent = typeof BaseStateRequestedEvent.Type;\n\n/** Payload recorded when a BaseState snapshot is created. */\nexport const BaseStateCreatedPayload = Schema.Struct({\n baseStateId: BaseStateId,\n coversThroughSeq: SequenceNumber,\n});\nexport type BaseStateCreatedPayload = typeof BaseStateCreatedPayload.Type;\nexport const BaseStateCreatedEvent = durableEventSchema(\n baseStateCreatedEventType,\n BaseStateCreatedPayload,\n);\nexport type BaseStateCreatedEvent = typeof BaseStateCreatedEvent.Type;\n\n/** Payload recorded when BaseState generation fails. */\nexport const BaseStateFailedPayload = Schema.Struct({\n baseStateId: BaseStateId,\n error: FailurePayload,\n});\nexport type BaseStateFailedPayload = typeof BaseStateFailedPayload.Type;\nexport const BaseStateFailedEvent = durableEventSchema(\n baseStateFailedEventType,\n BaseStateFailedPayload,\n);\nexport type BaseStateFailedEvent = typeof BaseStateFailedEvent.Type;\n\n/** Durable event union for BaseState lifecycle boundaries. */\nexport const BaseStateEvent = Schema.Union([\n BaseStateRequestedEvent,\n BaseStateCreatedEvent,\n BaseStateFailedEvent,\n]);\nexport type BaseStateEvent = typeof BaseStateEvent.Type;\n\n/** Built-in durable event union for framework-owned session facts. */\nexport const EDADurableEvent = Schema.Union([\n SessionConfiguredEvent,\n RunSchedulingEvent,\n CommandEvent,\n MessageEvent,\n RunEvent,\n RecoveryEvent,\n TurnEvent,\n InferenceEvent,\n ToolCallEvent,\n StopControlEvent,\n ContextAndCompactionEvent,\n BaseStateEvent,\n]);\nexport type EDADurableEvent = typeof EDADurableEvent.Type;\n\n/** Current V1 framework durable event schema. Future versions route beside this alias. */\nexport const EDADurableEventV1 = EDADurableEvent;\nexport type EDADurableEventV1 = typeof EDADurableEventV1.Type;\n\n/** Decode one framework-owned durable event through the namespace/type/version router. */\nexport const decodeUnknownEDADurableEventSync = (input: unknown): EDADurableEvent => {\n const envelope = Schema.decodeUnknownSync(DurableEventEnvelope)(input);\n if (envelope.namespace !== effectDurableAgentNamespace) {\n throw new Error(\n `EDADurableEvent decoder only accepts namespace ${effectDurableAgentNamespace}; received ${envelope.namespace}`,\n );\n }\n\n switch (envelope.schemaVersion) {\n case schemaV1:\n return Schema.decodeUnknownSync(EDADurableEventV1)(envelope);\n default:\n throw new Error(\n `Unsupported EDA durable event schemaVersion ${envelope.schemaVersion} for ${envelope.type}`,\n );\n }\n};\n\n/** Effectful V1+ router for untrusted framework-owned durable event boundaries. */\nexport const decodeUnknownEDADurableEvent = (\n input: unknown,\n): Effect.Effect<EDADurableEvent, unknown> =>\n Effect.try({\n try: () => decodeUnknownEDADurableEventSync(input),\n catch: (error) => error,\n });\n"],"mappings":";;;;;;;;;;AAWA,MAAa,sBACX,MACA,YAEA,OAAO,OAAO;CACZ,GAAG,qBAAqB;CACxB,WAAW,OAAO,QAAQ,2BAA2B;CACrD,MAAM,OAAO,QAAQ,IAAI;CACzB,eAAe,OAAO,QAAQ,QAAQ;CACtC;AACF,CAAC;;AAGH,MAAa,wBACX,MACA,YAEA,OAAO,OAAO;CACZ,GAAG,uBAAuB;CAC1B,WAAW,OAAO,QAAQ,2BAA2B;CACrD,MAAM,OAAO,QAAQ,IAAI;CACzB,eAAe,OAAO,QAAQ,QAAQ;CACtC;AACF,CAAC;;;;ACEH,MAAa,6BAA6B,cAAc,mBAAmB;AAC3E,MAAa,yBAAyB,mBACpC,4BACA,OAAO,OAAO,EAAE,gBAAgB,sBAAsB,CAAC,CACzD;;AAIA,MAAa,2BAA2B,cAAc,iBAAiB;AACvE,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