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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/{commands-p8venTWs.d.ts → commands-3OD-p8dD.d.ts} +7 -8
  2. package/dist/{compaction-Db6eoLce.js → compaction-Bell28K8.js} +2 -4
  3. package/dist/{compaction-Db6eoLce.js.map → compaction-Bell28K8.js.map} +1 -1
  4. package/dist/{context-projection-n6Rdup0N.d.ts → context-projection-D_uRtK3r.d.ts} +13 -14
  5. package/dist/{core-C-6xHzRx.d.ts → core-BcimKMIv.d.ts} +1 -2
  6. package/dist/domain/command-queues.d.ts +81 -2
  7. package/dist/domain/command-queues.js.map +1 -1
  8. package/dist/domain/context-projection.d.ts +1 -1
  9. package/dist/domain/message-transcript.d.ts +1 -1
  10. package/dist/domain/message-transcript.js.map +1 -1
  11. package/dist/domain/model-usage.d.ts +1 -1
  12. package/dist/domain/reduced-state-schema.d.ts +3 -992
  13. package/dist/domain/reduced-state-schema.js +114 -2
  14. package/dist/domain/reduced-state-schema.js.map +1 -1
  15. package/dist/domain/reduced-state.d.ts +2 -2
  16. package/dist/domain/run-scheduling.d.ts +1 -1
  17. package/dist/domain/run-scheduling.js.map +1 -1
  18. package/dist/durable-DRY7AcsF.js.map +1 -1
  19. package/dist/{durable-Ceu9SC2D.d.ts → durable-DoG_e4iL.d.ts} +1486 -1487
  20. package/dist/envelope-BCzKUq_z.js.map +1 -1
  21. package/dist/{envelope-VXFEC8zr.d.ts → envelope-Che6KatU.d.ts} +29 -30
  22. package/dist/event-factory-CKuWhjS4.js.map +1 -1
  23. package/dist/{events-D3OAPXgS.d.ts → events-sxIzJY26.d.ts} +124 -122
  24. package/dist/{id-generator--x6itQZ2.d.ts → id-generator-BKGoKjt-.d.ts} +2 -3
  25. package/dist/index.d.ts +7 -7
  26. package/dist/index.js +2 -2
  27. package/dist/{keep-alive-Chl5SJxy.d.ts → keep-alive-_zFCUvt3.d.ts} +1 -2
  28. package/dist/{model-resolver-ci5D5WQv.d.ts → model-resolver-BHYVHsam.d.ts} +3 -3
  29. package/dist/{model-usage-CNcnhj72.d.ts → model-usage-0GeHwaaU.d.ts} +2 -3
  30. package/dist/reduced-state-DFIYylAq.js.map +1 -1
  31. package/dist/{index-DWC70Fsi.d.ts → reduced-state-DrSHn_47.d.ts} +12581 -9701
  32. package/dist/reduced-state-schema-CPEmuHLY.d.ts +2167 -0
  33. package/dist/{reducer-registry-nO4biZlg.d.ts → reducer-registry-C3ZidOI1.d.ts} +8 -7
  34. package/dist/{run-scheduling-wakeup-CXT5_CkI.d.ts → run-scheduling-wakeup-COUj3r_B.d.ts} +2 -3
  35. package/dist/services/compaction.d.ts +1 -1
  36. package/dist/services/compaction.js +1 -1
  37. package/dist/services/id-generator.d.ts +1 -1
  38. package/dist/services/id-generator.js +2 -1
  39. package/dist/services/id-generator.js.map +1 -1
  40. package/dist/services/keep-alive.d.ts +1 -1
  41. package/dist/services/keep-alive.js.map +1 -1
  42. package/dist/services/model-resolver.d.ts +1 -1
  43. package/dist/services/model-resolver.js.map +1 -1
  44. package/dist/services/prompt-projector.d.ts +1 -1
  45. package/dist/services/prompt-projector.js.map +1 -1
  46. package/dist/services/reducer-registry.d.ts +1 -1
  47. package/dist/services/reducer-registry.js.map +1 -1
  48. package/dist/services/run-scheduler.d.ts +1 -2
  49. package/dist/services/run-scheduler.js.map +1 -1
  50. package/dist/services/run-scheduling-wakeup.d.ts +1 -1
  51. package/dist/services/run-scheduling-wakeup.js.map +1 -1
  52. package/dist/services/runtime-layer.d.ts +11 -35
  53. package/dist/services/runtime-layer.js +3 -3
  54. package/dist/services/runtime-layer.js.map +1 -1
  55. package/dist/services/runtime.d.ts +1 -1
  56. package/dist/services/runtime.js +12 -3
  57. package/dist/services/runtime.js.map +1 -1
  58. package/dist/services/session-event-observer.d.ts +1 -1
  59. package/dist/services/session-event-observer.js.map +1 -1
  60. package/dist/services/session-query.d.ts +2 -2
  61. package/dist/services/session-query.js +24 -8
  62. package/dist/services/session-query.js.map +1 -1
  63. package/dist/services/session-state.d.ts +1 -1
  64. package/dist/services/session-state.js +1 -1
  65. package/dist/services/session-store.d.ts +1 -1
  66. package/dist/services/session-store.js +5 -3
  67. package/dist/services/session-store.js.map +1 -1
  68. package/dist/services/sink-checkpoint-store.d.ts +1 -1
  69. package/dist/services/sink-checkpoint-store.js +2 -1
  70. package/dist/services/sink-checkpoint-store.js.map +1 -1
  71. package/dist/services/sink-registry.d.ts +1 -1
  72. package/dist/services/sink-registry.js +1 -1
  73. package/dist/services/tool-registry.d.ts +1 -1
  74. package/dist/services/tool-registry.js.map +1 -1
  75. package/dist/services/tracing.d.ts +3 -3
  76. package/dist/services/tracing.js.map +1 -1
  77. package/dist/{session-event-observer-BWppl2Fr.d.ts → session-event-observer-BDwja1jX.d.ts} +3 -3
  78. package/dist/{session-state-8PJZvuR3.js → session-state-BBzzJrDC.js} +78 -50
  79. package/dist/{session-state-8PJZvuR3.js.map → session-state-BBzzJrDC.js.map} +1 -1
  80. package/dist/{session-store-DBa-TOVH.d.ts → session-store-B_vh581h.d.ts} +9 -9
  81. package/dist/{sink-checkpoint-store-BZGfJLve.d.ts → sink-checkpoint-store-2SxoNMbI.d.ts} +3 -4
  82. package/dist/{sink-registry-B4yxTmlI.js → sink-registry-ogHu2Sw7.js} +2 -2
  83. package/dist/{sink-registry-B4yxTmlI.js.map → sink-registry-ogHu2Sw7.js.map} +1 -1
  84. package/dist/testkit/layers.d.ts +13 -18
  85. package/dist/testkit/layers.js +3 -3
  86. package/dist/testkit/layers.js.map +1 -1
  87. package/dist/{tool-registry-NOP9aTHT.d.ts → tool-registry-DDxbmMpY.d.ts} +5 -5
  88. package/dist/{tracing-BXHAkxkx.d.ts → tracing-BwjbF285.d.ts} +1 -2
  89. package/dist/types/commands.d.ts +1 -1
  90. package/dist/types/commands.js.map +1 -1
  91. package/dist/types/core.d.ts +1 -1
  92. package/dist/types/core.js.map +1 -1
  93. package/dist/types/events/durable.d.ts +1 -1
  94. package/dist/types/events.d.ts +4 -4
  95. package/dist/types/tracing.d.ts +1 -1
  96. package/dist/types/tracing.js.map +1 -1
  97. package/dist/websocket.d.ts +197 -187
  98. package/dist/websocket.js +4 -3
  99. package/dist/websocket.js.map +1 -1
  100. package/package.json +7 -7
  101. package/dist/command-queues-w9WUKTpM.d.ts +0 -556
  102. package/dist/compaction-DhIJ-sAH.d.ts +0 -165
  103. package/dist/event-factory-CHP1-DAF.d.ts +0 -91
  104. package/dist/message-transcript-BfuGCZhP.d.ts +0 -32
  105. package/dist/prompt-projector-DvNHsoEN.d.ts +0 -39
  106. package/dist/run-scheduler-DFBqIRzF.d.ts +0 -43
  107. package/dist/sink-registry-tpmJ-Dhf.d.ts +0 -148
@@ -1,4 +1,5 @@
1
- import { CommandId, InferenceId, MessageId, RunId, SequenceNumber, ToolCallId, TurnId } from "../types/core.js";
1
+ import { CommandId, CompactionId, ContextVersion, InferenceId, MessageId, RunId, SequenceNumber, SummaryId, ToolCallId, TurnId } from "../types/core.js";
2
+ import { RunSchedulingRequestRecord } from "./run-scheduling.js";
2
3
  import { EDAEventTrace, EDARunTrace } from "../types/tracing.js";
3
4
  import { _ as UsagePayload, f as ProviderPartId, h as ToolName, l as ModelSelectionPayload, m as SystemPromptText, s as FailurePayload } from "../envelope-BCzKUq_z.js";
4
5
  import { TokenConsumptionState, TokenUsageTotals } from "./model-usage.js";
@@ -271,12 +272,123 @@ const MessageRecordSchema = messageRecordSchema(UserMessageContent, Schema.Union
271
272
  PromptToolResultPart,
272
273
  PromptToolApprovalRequestPart
273
274
  ]));
275
+ /** Lossless structured-clone query content; admission string transforms do not apply. */
276
+ const QueryUserMessageContent = Schema.toType(UserMessageContent);
277
+ /** Message query records preserve Prompt-part arrays and their structured-clone fields. */
278
+ const QueryMessageRecordSchema = messageRecordSchema(QueryUserMessageContent, Schema.Union([
279
+ Schema.toType(PromptTextPart),
280
+ Schema.toType(PromptFilePart),
281
+ Schema.toType(PromptReasoningPart),
282
+ Schema.toType(PromptToolCallPart),
283
+ Schema.toType(PromptToolResultPart),
284
+ Schema.toType(PromptToolApprovalRequestPart)
285
+ ]));
274
286
  const JsonMessageRecordSchema = messageRecordSchema(JsonUserMessageContent, JsonAssistantMessagePart);
275
287
  const RecoveryContinuationRecordSchema = Schema.Struct({
276
288
  ...RecoveryContinuation.fields,
277
289
  seq: SequenceNumber
278
290
  });
291
+ /** Structured-clone schema for the existing StopRequestRecord query representation. */
292
+ const StopRequestRecordSchema = Schema.Struct({
293
+ commandId: CommandId,
294
+ requestedSeq: SequenceNumber,
295
+ requestedRunId: Schema.optionalKey(RunId),
296
+ requestedTurnId: Schema.optionalKey(TurnId),
297
+ appliedSeq: Schema.optionalKey(SequenceNumber),
298
+ appliedRunId: Schema.optionalKey(RunId),
299
+ appliedTurnId: Schema.optionalKey(TurnId),
300
+ appliedInferenceId: Schema.optionalKey(InferenceId)
301
+ });
302
+ /** Structured-clone schema for the existing CompactionTerminal query representation. */
303
+ const CompactionTerminalSchema = Schema.Union([Schema.Struct({
304
+ _tag: Schema.Literal("Completed"),
305
+ seq: SequenceNumber
306
+ }), Schema.Struct({
307
+ _tag: Schema.Literal("Failed"),
308
+ seq: SequenceNumber,
309
+ error: FailurePayload
310
+ })]);
311
+ /** Structured-clone schema for the existing CompactionRecord query representation. */
312
+ const CompactionRecordSchema = Schema.Struct({
313
+ compactionId: CompactionId,
314
+ requestedSeq: Schema.optionalKey(SequenceNumber),
315
+ startedSeq: Schema.optionalKey(SequenceNumber),
316
+ summaryCreatedSeq: Schema.optionalKey(SequenceNumber),
317
+ summaryId: Schema.optionalKey(SummaryId),
318
+ sourceFromSeq: Schema.optionalKey(SequenceNumber),
319
+ sourceToSeq: Schema.optionalKey(SequenceNumber),
320
+ rebasedSeq: Schema.optionalKey(SequenceNumber),
321
+ contextVersion: Schema.optionalKey(ContextVersion),
322
+ terminal: Schema.optionalKey(CompactionTerminalSchema)
323
+ });
324
+ /** Structured-clone schema for the existing ContextRecord query representation. */
325
+ const ContextRecordSchema = Schema.Struct({
326
+ version: ContextVersion,
327
+ currentSummaryId: Schema.optionalKey(SummaryId)
328
+ });
329
+ /** Structured-clone schema for the existing ActiveCommandEvidence query representation. */
330
+ const ActiveCommandEvidenceSchema = Schema.Struct({
331
+ commandId: CommandId,
332
+ runId: Schema.optionalKey(RunId)
333
+ });
334
+ /** Structured-clone schema for the existing PendingCommand query representation. */
335
+ const PendingCommandSchema = Schema.Struct({
336
+ commandId: CommandId,
337
+ command: EDACommand,
338
+ admittedSeq: SequenceNumber,
339
+ admissionTrace: Schema.optionalKey(EDAEventTrace)
340
+ });
341
+ /** Structured-clone schema for the existing PendingSteeringMessage query representation. */
342
+ const PendingSteeringMessageSchema = Schema.Struct({
343
+ messageId: MessageId,
344
+ commandId: CommandId,
345
+ runId: RunId,
346
+ content: QueryUserMessageContent,
347
+ queuedSeq: SequenceNumber,
348
+ consumedSeq: Schema.optionalKey(SequenceNumber),
349
+ consumedTurnId: Schema.optionalKey(TurnId)
350
+ });
351
+ /** Structured-clone schema for the existing PendingUserMessage query representation. */
352
+ const PendingUserMessageSchema = Schema.Struct({
353
+ messageId: MessageId,
354
+ commandId: CommandId,
355
+ content: QueryUserMessageContent,
356
+ submittedSeq: SequenceNumber,
357
+ effectiveSeq: SequenceNumber,
358
+ disposition: Schema.Union([Schema.Literal("queue"), Schema.Literal("steer")]),
359
+ targetRunId: Schema.optionalKey(RunId),
360
+ pausedByCommandId: Schema.optionalKey(CommandId)
361
+ });
362
+ /** Structured-clone schema for the existing CommandQueues query representation. */
363
+ const CommandQueuesSchema = Schema.Struct({
364
+ active: Schema.optional(ActiveCommandEvidenceSchema),
365
+ pendingCommands: Schema.Array(PendingCommandSchema),
366
+ queuedCommands: Schema.Array(PendingCommandSchema),
367
+ activeControlCommands: Schema.Array(PendingCommandSchema),
368
+ steeringByRun: Schema.ReadonlyMap(RunId, Schema.Array(PendingSteeringMessageSchema)),
369
+ pendingQueue: Schema.Array(PendingUserMessageSchema),
370
+ pendingSteers: Schema.Array(PendingUserMessageSchema),
371
+ pausedQueue: Schema.Array(PendingUserMessageSchema)
372
+ });
373
+ /** Structured-clone schema for the existing ReducedState query representation. */
374
+ const ReducedStateSchema = Schema.Struct({
375
+ runSchedulingRequest: Schema.optionalKey(RunSchedulingRequestRecord),
376
+ modelSelection: Schema.optionalKey(ModelSelectionPayload),
377
+ lastSeq: SequenceNumber,
378
+ commands: Schema.ReadonlyMap(CommandId, CommandRecordSchema),
379
+ runs: Schema.ReadonlyMap(RunId, RunRecordSchema),
380
+ recoveryContinuations: Schema.ReadonlyMap(RunId, RecoveryContinuationRecordSchema),
381
+ turns: Schema.ReadonlyMap(TurnId, TurnRecordSchema),
382
+ inferences: Schema.ReadonlyMap(InferenceId, InferenceRecordSchema),
383
+ toolCalls: Schema.ReadonlyMap(ToolCallId, Schema.toType(ToolCallRecordSchema)),
384
+ messages: Schema.ReadonlyMap(MessageId, QueryMessageRecordSchema),
385
+ stopRequests: Schema.ReadonlyMap(CommandId, StopRequestRecordSchema),
386
+ compactions: Schema.ReadonlyMap(CompactionId, CompactionRecordSchema),
387
+ context: ContextRecordSchema,
388
+ tokenConsumption: TokenConsumptionState,
389
+ commandQueues: CommandQueuesSchema
390
+ });
279
391
  //#endregion
280
- export { CommandRecordSchema, CommandTerminalSchema, InferenceRecordSchema, InferenceTerminalSchema, JsonAssistantMessagePart, JsonCommandRecordSchema, JsonEDACommand, JsonMessageRecordSchema, JsonPromptFilePart, JsonUserMessageContent, JsonUserMessagePart, MessageRecordSchema, RecoveryContinuationRecordSchema, RunRecordSchema, RunTerminalSchema, TokenConsumptionState as TokenConsumptionStateSchema, TokenUsageTotals as TokenUsageTotalsSchema, ToolCallRecordSchema, ToolDecisionSchema, ToolTerminalSchema, TurnRecordSchema, TurnTerminalSchema };
392
+ export { ActiveCommandEvidenceSchema, CommandQueuesSchema, CommandRecordSchema, CommandTerminalSchema, CompactionRecordSchema, CompactionTerminalSchema, ContextRecordSchema, InferenceRecordSchema, InferenceTerminalSchema, JsonAssistantMessagePart, JsonCommandRecordSchema, JsonEDACommand, JsonMessageRecordSchema, JsonPromptFilePart, JsonUserMessageContent, JsonUserMessagePart, MessageRecordSchema, PendingCommandSchema, PendingSteeringMessageSchema, PendingUserMessageSchema, QueryMessageRecordSchema, QueryUserMessageContent, RecoveryContinuationRecordSchema, ReducedStateSchema, RunRecordSchema, RunTerminalSchema, StopRequestRecordSchema, TokenConsumptionState as TokenConsumptionStateSchema, TokenUsageTotals as TokenUsageTotalsSchema, ToolCallRecordSchema, ToolDecisionSchema, ToolTerminalSchema, TurnRecordSchema, TurnTerminalSchema };
281
393
 
282
394
  //# sourceMappingURL=reduced-state-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reduced-state-schema.js","names":[],"sources":["../../src/domain/reduced-state-schema.ts"],"sourcesContent":["import * as Prompt from \"effect/unstable/ai/Prompt\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaTransformation from \"effect/SchemaTransformation\";\nexport {\n TokenConsumptionState as TokenConsumptionStateSchema,\n TokenUsageTotals as TokenUsageTotalsSchema,\n} from \"./model-usage\";\n\nimport {\n CancelPendingMessageCommand,\n EDACommand,\n PromotePendingMessageCommand,\n ResumePendingMessagesCommand,\n StopTurnCommand,\n SubmitMessageCommand,\n UserMessageContent,\n} from \"../types/commands\";\nimport {\n CommandId,\n InferenceId,\n MessageId,\n RunId,\n SequenceNumber,\n ToolCallId,\n TurnId,\n} from \"../types/core\";\nimport {\n AssistantMessageContent,\n EDAEventTrace,\n EDARunTrace,\n FailurePayload,\n ProviderPartId,\n RecoveryContinuation,\n SystemPromptText,\n ToolName,\n UsagePayload,\n ModelSelectionPayload,\n} from \"../types/events\";\n\nconst PromptFilePart = Schema.Struct(Prompt.FilePart.fields);\nconst PromptReasoningPart = Schema.Struct(Prompt.ReasoningPart.fields);\nconst PromptTextPart = Schema.Struct(Prompt.TextPart.fields);\nconst PromptToolApprovalRequestPart = Schema.Struct(Prompt.ToolApprovalRequestPart.fields);\nconst PromptToolCallPart = Schema.Struct(Prompt.ToolCallPart.fields);\nconst PromptToolResultPart = Schema.Struct(Prompt.ToolResultPart.fields);\n\nconst JsonPromptFilePartEncoded = Schema.Struct({\n ...PromptFilePart.fields,\n data: Schema.String,\n});\n\nconst byteArrayDataUrl = (data: Uint8Array, mediaType: string): string => {\n let binary = \"\";\n for (const byte of data) {\n binary += String.fromCharCode(byte);\n }\n return `data:${mediaType};base64,${btoa(binary)}`;\n};\n\n/**\n * Canonical Effect Prompt file part with an explicit JSON string encoding.\n *\n * Strings pass through unchanged, URLs use their href, and bytes become a data\n * URL. Decoding produces the normal Prompt.FilePart type.\n */\nexport const JsonPromptFilePart = JsonPromptFilePartEncoded.pipe(\n Schema.decodeTo(\n Prompt.FilePart,\n SchemaTransformation.transform<Prompt.FilePartEncoded, typeof JsonPromptFilePartEncoded.Type>({\n decode: (part) => part,\n encode: (part) => ({\n ...part,\n \"~effect/ai/Prompt/Part\": \"~effect/ai/Prompt/Part\",\n data:\n typeof part.data === \"string\"\n ? part.data\n : part.data instanceof URL\n ? part.data.href\n : byteArrayDataUrl(part.data, part.mediaType),\n options: part.options ?? {},\n }),\n }),\n ),\n);\n\nexport const JsonUserMessagePart = Schema.Union([PromptTextPart, JsonPromptFilePart]);\nexport const JsonUserMessageContent = Schema.Union([\n Prompt.ContentFromString,\n Schema.NonEmptyArray(JsonUserMessagePart),\n]);\n\nexport const JsonAssistantMessagePart = Schema.Union([\n PromptTextPart,\n JsonPromptFilePart,\n PromptReasoningPart,\n PromptToolCallPart,\n PromptToolResultPart,\n PromptToolApprovalRequestPart,\n]);\n\n/**\n * Command schema for JSON snapshots.\n *\n * Every command except SubmitMessage is reused directly. SubmitMessage only\n * replaces canonical Prompt file data with its explicit JSON string projection.\n */\nexport const JsonEDACommand = Schema.Union([\n Schema.Struct({\n ...SubmitMessageCommand.fields,\n content: JsonUserMessageContent,\n }),\n StopTurnCommand,\n CancelPendingMessageCommand,\n PromotePendingMessageCommand,\n ResumePendingMessagesCommand,\n]);\n\nexport const CommandTerminalSchema = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Completed\"), seq: SequenceNumber }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Cancelled\"),\n reason: Schema.String,\n seq: SequenceNumber,\n }),\n]);\n\nexport const RunTerminalSchema = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Completed\"), seq: SequenceNumber }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Interrupted\"),\n reason: Schema.String,\n seq: SequenceNumber,\n }),\n]);\n\nexport const TurnTerminalSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Completed\"),\n seq: SequenceNumber,\n usage: Schema.optionalKey(UsagePayload),\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Stopped\"),\n reason: Schema.String,\n seq: SequenceNumber,\n }),\n]);\n\nexport const InferenceTerminalSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Completed\"),\n seq: SequenceNumber,\n usage: Schema.optionalKey(UsagePayload),\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n]);\n\nconst LifecycleTimingFields = {\n durationMs: Schema.optionalKey(Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0))),\n startedAtMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n terminalAtMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n};\n\nexport const CommandRecordSchema = Schema.Struct({\n admittedSeq: Schema.optionalKey(SequenceNumber),\n admissionTrace: Schema.optionalKey(EDAEventTrace),\n command: Schema.optionalKey(EDACommand),\n commandId: CommandId,\n startedSeq: Schema.optionalKey(SequenceNumber),\n terminal: Schema.optionalKey(CommandTerminalSchema),\n});\n\nexport const JsonCommandRecordSchema = Schema.Struct({\n ...CommandRecordSchema.fields,\n command: Schema.optionalKey(JsonEDACommand),\n});\n\nexport const RunRecordSchema = Schema.Struct({\n modelSelection: Schema.optionalKey(ModelSelectionPayload),\n ...LifecycleTimingFields,\n commandIds: Schema.Array(CommandId),\n runId: RunId,\n startedSeq: SequenceNumber,\n terminal: Schema.optionalKey(RunTerminalSchema),\n trace: EDARunTrace,\n});\n\nexport const TurnRecordSchema = Schema.Struct({\n ...LifecycleTimingFields,\n runId: RunId,\n startedSeq: SequenceNumber,\n terminal: Schema.optionalKey(TurnTerminalSchema),\n turnId: TurnId,\n});\n\nexport const InferenceRecordSchema = Schema.Struct({\n ...LifecycleTimingFields,\n inferenceId: InferenceId,\n runId: RunId,\n startedSeq: SequenceNumber,\n terminal: Schema.optionalKey(InferenceTerminalSchema),\n turnId: TurnId,\n});\n\nexport const ToolDecisionSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Created\"),\n inferenceId: InferenceId,\n params: Schema.Unknown,\n promptPart: Schema.optionalKey(PromptToolCallPart),\n providerExecuted: Schema.Boolean,\n providerPartId: ProviderPartId,\n runId: RunId,\n seq: SequenceNumber,\n toolName: ToolName,\n turnId: TurnId,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Rejected\"),\n inferenceId: InferenceId,\n modelFeedback: Schema.String,\n promptPart: Schema.optionalKey(PromptToolResultPart),\n providerPartId: ProviderPartId,\n reason: Schema.Literals([\"unknown-tool\", \"invalid-params\"]),\n runId: RunId,\n seq: SequenceNumber,\n toolName: ToolName,\n turnId: TurnId,\n }),\n]);\n\nexport const ToolTerminalSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Completed\"),\n promptPart: Schema.optionalKey(PromptToolResultPart),\n result: Schema.Unknown,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n promptPart: Schema.optionalKey(PromptToolResultPart),\n seq: SequenceNumber,\n }),\n]);\n\nexport const ToolCallRecordSchema = Schema.Struct({\n ...LifecycleTimingFields,\n decision: Schema.optionalKey(ToolDecisionSchema),\n startedSeq: Schema.optionalKey(SequenceNumber),\n terminal: Schema.optionalKey(ToolTerminalSchema),\n toolCallId: ToolCallId,\n});\n\nconst MessageIdentityFields = {\n createdAtMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n messageId: MessageId,\n seq: SequenceNumber,\n};\n\nconst PendingMessageStateFields = {\n cancellationReason: Schema.optionalKey(Schema.String),\n cancelledByCommandId: Schema.optionalKey(CommandId),\n cancelledSeq: Schema.optionalKey(SequenceNumber),\n consumedSeq: Schema.optionalKey(SequenceNumber),\n consumedTurnId: Schema.optionalKey(TurnId),\n pausedByCommandId: Schema.optionalKey(CommandId),\n pausedSeq: Schema.optionalKey(SequenceNumber),\n promotedSeq: Schema.optionalKey(SequenceNumber),\n};\n\nconst messageRecordSchema = <UserContent extends Schema.Top, AssistantPart extends Schema.Top>(\n userContent: UserContent,\n assistantPart: AssistantPart,\n) =>\n Schema.Union([\n Schema.Struct({\n ...MessageIdentityFields,\n _tag: Schema.Literal(\"System\"),\n content: SystemPromptText,\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n ...PendingMessageStateFields,\n _tag: Schema.Literal(\"User\"),\n commandId: CommandId,\n content: userContent,\n disposition: Schema.optionalKey(Schema.Literals([\"queue\", \"steer\"])),\n requestedDisposition: Schema.optionalKey(Schema.Literals([\"queue\", \"steer\"])),\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n ...PendingMessageStateFields,\n _tag: Schema.Literal(\"Steering\"),\n commandId: CommandId,\n content: userContent,\n runId: RunId,\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n _tag: Schema.Literal(\"Assistant\"),\n content: AssistantMessageContent,\n imported: Schema.optionalKey(Schema.Literal(true)),\n inferenceId: InferenceId,\n promptParts: Schema.optionalKey(Schema.Array(assistantPart)),\n runId: RunId,\n turnId: TurnId,\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n _tag: Schema.Literal(\"AssistantPartial\"),\n content: AssistantMessageContent,\n inferenceId: InferenceId,\n promptParts: Schema.optionalKey(Schema.Array(assistantPart)),\n reason: Schema.String,\n runId: RunId,\n turnId: TurnId,\n }),\n ]);\n\nexport const MessageRecordSchema = messageRecordSchema(\n UserMessageContent,\n Schema.Union([\n PromptTextPart,\n PromptFilePart,\n PromptReasoningPart,\n PromptToolCallPart,\n PromptToolResultPart,\n PromptToolApprovalRequestPart,\n ]),\n);\n\nexport const JsonMessageRecordSchema = messageRecordSchema(\n JsonUserMessageContent,\n JsonAssistantMessagePart,\n);\n\nexport const RecoveryContinuationRecordSchema = Schema.Struct({\n ...RecoveryContinuation.fields,\n seq: SequenceNumber,\n});\n"],"mappings":";;;;;;;;;;AAuCA,MAAM,iBAAiB,OAAO,OAAO,OAAO,SAAS,MAAM;AAC3D,MAAM,sBAAsB,OAAO,OAAO,OAAO,cAAc,MAAM;AACrE,MAAM,iBAAiB,OAAO,OAAO,OAAO,SAAS,MAAM;AAC3D,MAAM,gCAAgC,OAAO,OAAO,OAAO,wBAAwB,MAAM;AACzF,MAAM,qBAAqB,OAAO,OAAO,OAAO,aAAa,MAAM;AACnE,MAAM,uBAAuB,OAAO,OAAO,OAAO,eAAe,MAAM;AAEvE,MAAM,4BAA4B,OAAO,OAAO;CAC9C,GAAG,eAAe;CAClB,MAAM,OAAO;AACf,CAAC;AAED,MAAM,oBAAoB,MAAkB,cAA8B;CACxE,IAAI,SAAS;CACb,KAAK,MAAM,QAAQ,MACjB,UAAU,OAAO,aAAa,IAAI;CAEpC,OAAO,QAAQ,UAAU,UAAU,KAAK,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aAAa;EACb,aAAa,OAAO,YAAY,OAAO,MAAM,aAAa,CAAC;EAC3D,QAAQ,OAAO;EACf,OAAO;EACP,QAAQ;CACV,CAAC;AACH,CAAC;AAEH,MAAa,sBAAsB,oBACjC,oBACA,OAAO,MAAM;CACX;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CACH;AAEA,MAAa,0BAA0B,oBACrC,wBACA,wBACF;AAEA,MAAa,mCAAmC,OAAO,OAAO;CAC5D,GAAG,qBAAqB;CACxB,KAAK;AACP,CAAC"}
1
+ {"version":3,"file":"reduced-state-schema.js","names":[],"sources":["../../src/domain/reduced-state-schema.ts"],"sourcesContent":["import { TokenConsumptionState } from \"./model-usage\";\nimport { RunSchedulingRequestRecord } from \"./run-scheduling\";\nimport * as Prompt from \"effect/unstable/ai/Prompt\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaTransformation from \"effect/SchemaTransformation\";\nexport {\n TokenConsumptionState as TokenConsumptionStateSchema,\n TokenUsageTotals as TokenUsageTotalsSchema,\n} from \"./model-usage\";\n\nimport {\n CancelPendingMessageCommand,\n EDACommand,\n PromotePendingMessageCommand,\n ResumePendingMessagesCommand,\n StopTurnCommand,\n SubmitMessageCommand,\n UserMessageContent,\n} from \"../types/commands\";\nimport {\n CommandId,\n CompactionId,\n ContextVersion,\n SummaryId,\n InferenceId,\n MessageId,\n RunId,\n SequenceNumber,\n ToolCallId,\n TurnId,\n} from \"../types/core\";\nimport {\n AssistantMessageContent,\n EDAEventTrace,\n EDARunTrace,\n FailurePayload,\n ProviderPartId,\n RecoveryContinuation,\n SystemPromptText,\n ToolName,\n UsagePayload,\n ModelSelectionPayload,\n} from \"../types/events\";\n\nconst PromptFilePart = Schema.Struct(Prompt.FilePart.fields);\nconst PromptReasoningPart = Schema.Struct(Prompt.ReasoningPart.fields);\nconst PromptTextPart = Schema.Struct(Prompt.TextPart.fields);\nconst PromptToolApprovalRequestPart = Schema.Struct(Prompt.ToolApprovalRequestPart.fields);\nconst PromptToolCallPart = Schema.Struct(Prompt.ToolCallPart.fields);\nconst PromptToolResultPart = Schema.Struct(Prompt.ToolResultPart.fields);\n\nconst JsonPromptFilePartEncoded = Schema.Struct({\n ...PromptFilePart.fields,\n data: Schema.String,\n});\n\nconst byteArrayDataUrl = (data: Uint8Array, mediaType: string): string => {\n let binary = \"\";\n for (const byte of data) {\n binary += String.fromCharCode(byte);\n }\n return `data:${mediaType};base64,${btoa(binary)}`;\n};\n\n/**\n * Canonical Effect Prompt file part with an explicit JSON string encoding.\n *\n * Strings pass through unchanged, URLs use their href, and bytes become a data\n * URL. Decoding produces the normal Prompt.FilePart type.\n */\nexport const JsonPromptFilePart = JsonPromptFilePartEncoded.pipe(\n Schema.decodeTo(\n Prompt.FilePart,\n SchemaTransformation.transform<Prompt.FilePartEncoded, typeof JsonPromptFilePartEncoded.Type>({\n decode: (part) => part,\n encode: (part) => ({\n ...part,\n \"~effect/ai/Prompt/Part\": \"~effect/ai/Prompt/Part\",\n data:\n typeof part.data === \"string\"\n ? part.data\n : part.data instanceof URL\n ? part.data.href\n : byteArrayDataUrl(part.data, part.mediaType),\n options: part.options ?? {},\n }),\n }),\n ),\n);\n\nexport const JsonUserMessagePart = Schema.Union([PromptTextPart, JsonPromptFilePart]);\nexport const JsonUserMessageContent = Schema.Union([\n Prompt.ContentFromString,\n Schema.NonEmptyArray(JsonUserMessagePart),\n]);\n\nexport const JsonAssistantMessagePart = Schema.Union([\n PromptTextPart,\n JsonPromptFilePart,\n PromptReasoningPart,\n PromptToolCallPart,\n PromptToolResultPart,\n PromptToolApprovalRequestPart,\n]);\n\n/**\n * Command schema for JSON snapshots.\n *\n * Every command except SubmitMessage is reused directly. SubmitMessage only\n * replaces canonical Prompt file data with its explicit JSON string projection.\n */\nexport const JsonEDACommand = Schema.Union([\n Schema.Struct({\n ...SubmitMessageCommand.fields,\n content: JsonUserMessageContent,\n }),\n StopTurnCommand,\n CancelPendingMessageCommand,\n PromotePendingMessageCommand,\n ResumePendingMessagesCommand,\n]);\n\nexport const CommandTerminalSchema = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Completed\"), seq: SequenceNumber }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Cancelled\"),\n reason: Schema.String,\n seq: SequenceNumber,\n }),\n]);\n\nexport const RunTerminalSchema = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Completed\"), seq: SequenceNumber }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Interrupted\"),\n reason: Schema.String,\n seq: SequenceNumber,\n }),\n]);\n\nexport const TurnTerminalSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Completed\"),\n seq: SequenceNumber,\n usage: Schema.optionalKey(UsagePayload),\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Stopped\"),\n reason: Schema.String,\n seq: SequenceNumber,\n }),\n]);\n\nexport const InferenceTerminalSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Completed\"),\n seq: SequenceNumber,\n usage: Schema.optionalKey(UsagePayload),\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n seq: SequenceNumber,\n }),\n]);\n\nconst LifecycleTimingFields = {\n durationMs: Schema.optionalKey(Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0))),\n startedAtMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n terminalAtMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n};\n\nexport const CommandRecordSchema = Schema.Struct({\n admittedSeq: Schema.optionalKey(SequenceNumber),\n admissionTrace: Schema.optionalKey(EDAEventTrace),\n command: Schema.optionalKey(EDACommand),\n commandId: CommandId,\n startedSeq: Schema.optionalKey(SequenceNumber),\n terminal: Schema.optionalKey(CommandTerminalSchema),\n});\n\nexport const JsonCommandRecordSchema = Schema.Struct({\n ...CommandRecordSchema.fields,\n command: Schema.optionalKey(JsonEDACommand),\n});\n\nexport const RunRecordSchema = Schema.Struct({\n modelSelection: Schema.optionalKey(ModelSelectionPayload),\n ...LifecycleTimingFields,\n commandIds: Schema.Array(CommandId),\n runId: RunId,\n startedSeq: SequenceNumber,\n terminal: Schema.optionalKey(RunTerminalSchema),\n trace: EDARunTrace,\n});\n\nexport const TurnRecordSchema = Schema.Struct({\n ...LifecycleTimingFields,\n runId: RunId,\n startedSeq: SequenceNumber,\n terminal: Schema.optionalKey(TurnTerminalSchema),\n turnId: TurnId,\n});\n\nexport const InferenceRecordSchema = Schema.Struct({\n ...LifecycleTimingFields,\n inferenceId: InferenceId,\n runId: RunId,\n startedSeq: SequenceNumber,\n terminal: Schema.optionalKey(InferenceTerminalSchema),\n turnId: TurnId,\n});\n\nexport const ToolDecisionSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Created\"),\n inferenceId: InferenceId,\n params: Schema.Unknown,\n promptPart: Schema.optionalKey(PromptToolCallPart),\n providerExecuted: Schema.Boolean,\n providerPartId: ProviderPartId,\n runId: RunId,\n seq: SequenceNumber,\n toolName: ToolName,\n turnId: TurnId,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Rejected\"),\n inferenceId: InferenceId,\n modelFeedback: Schema.String,\n promptPart: Schema.optionalKey(PromptToolResultPart),\n providerPartId: ProviderPartId,\n reason: Schema.Literals([\"unknown-tool\", \"invalid-params\"]),\n runId: RunId,\n seq: SequenceNumber,\n toolName: ToolName,\n turnId: TurnId,\n }),\n]);\n\nexport const ToolTerminalSchema = Schema.Union([\n Schema.Struct({\n _tag: Schema.Literal(\"Completed\"),\n promptPart: Schema.optionalKey(PromptToolResultPart),\n result: Schema.Unknown,\n seq: SequenceNumber,\n }),\n Schema.Struct({\n _tag: Schema.Literal(\"Failed\"),\n error: FailurePayload,\n promptPart: Schema.optionalKey(PromptToolResultPart),\n seq: SequenceNumber,\n }),\n]);\n\nexport const ToolCallRecordSchema = Schema.Struct({\n ...LifecycleTimingFields,\n decision: Schema.optionalKey(ToolDecisionSchema),\n startedSeq: Schema.optionalKey(SequenceNumber),\n terminal: Schema.optionalKey(ToolTerminalSchema),\n toolCallId: ToolCallId,\n});\n\nconst MessageIdentityFields = {\n createdAtMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),\n messageId: MessageId,\n seq: SequenceNumber,\n};\n\nconst PendingMessageStateFields = {\n cancellationReason: Schema.optionalKey(Schema.String),\n cancelledByCommandId: Schema.optionalKey(CommandId),\n cancelledSeq: Schema.optionalKey(SequenceNumber),\n consumedSeq: Schema.optionalKey(SequenceNumber),\n consumedTurnId: Schema.optionalKey(TurnId),\n pausedByCommandId: Schema.optionalKey(CommandId),\n pausedSeq: Schema.optionalKey(SequenceNumber),\n promotedSeq: Schema.optionalKey(SequenceNumber),\n};\n\nconst messageRecordSchema = <UserContent extends Schema.Top, AssistantPart extends Schema.Top>(\n userContent: UserContent,\n assistantPart: AssistantPart,\n) =>\n Schema.Union([\n Schema.Struct({\n ...MessageIdentityFields,\n _tag: Schema.Literal(\"System\"),\n content: SystemPromptText,\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n ...PendingMessageStateFields,\n _tag: Schema.Literal(\"User\"),\n commandId: CommandId,\n content: userContent,\n disposition: Schema.optionalKey(Schema.Literals([\"queue\", \"steer\"])),\n requestedDisposition: Schema.optionalKey(Schema.Literals([\"queue\", \"steer\"])),\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n ...PendingMessageStateFields,\n _tag: Schema.Literal(\"Steering\"),\n commandId: CommandId,\n content: userContent,\n runId: RunId,\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n _tag: Schema.Literal(\"Assistant\"),\n content: AssistantMessageContent,\n imported: Schema.optionalKey(Schema.Literal(true)),\n inferenceId: InferenceId,\n promptParts: Schema.optionalKey(Schema.Array(assistantPart)),\n runId: RunId,\n turnId: TurnId,\n }),\n Schema.Struct({\n ...MessageIdentityFields,\n _tag: Schema.Literal(\"AssistantPartial\"),\n content: AssistantMessageContent,\n inferenceId: InferenceId,\n promptParts: Schema.optionalKey(Schema.Array(assistantPart)),\n reason: Schema.String,\n runId: RunId,\n turnId: TurnId,\n }),\n ]);\n\nexport const MessageRecordSchema = messageRecordSchema(\n UserMessageContent,\n Schema.Union([\n PromptTextPart,\n PromptFilePart,\n PromptReasoningPart,\n PromptToolCallPart,\n PromptToolResultPart,\n PromptToolApprovalRequestPart,\n ]),\n);\n\n/** Lossless structured-clone query content; admission string transforms do not apply. */\nexport const QueryUserMessageContent = Schema.toType(UserMessageContent);\n\n/** Message query records preserve Prompt-part arrays and their structured-clone fields. */\nexport const QueryMessageRecordSchema = messageRecordSchema(\n QueryUserMessageContent,\n Schema.Union([\n Schema.toType(PromptTextPart),\n Schema.toType(PromptFilePart),\n Schema.toType(PromptReasoningPart),\n Schema.toType(PromptToolCallPart),\n Schema.toType(PromptToolResultPart),\n Schema.toType(PromptToolApprovalRequestPart),\n ]),\n);\n\nexport const JsonMessageRecordSchema = messageRecordSchema(\n JsonUserMessageContent,\n JsonAssistantMessagePart,\n);\n\nexport const RecoveryContinuationRecordSchema = Schema.Struct({\n ...RecoveryContinuation.fields,\n seq: SequenceNumber,\n});\n\n/** Structured-clone schema for the existing StopRequestRecord query representation. */\nexport const StopRequestRecordSchema = Schema.Struct({\n commandId: CommandId,\n requestedSeq: SequenceNumber,\n requestedRunId: Schema.optionalKey(RunId),\n requestedTurnId: Schema.optionalKey(TurnId),\n appliedSeq: Schema.optionalKey(SequenceNumber),\n appliedRunId: Schema.optionalKey(RunId),\n appliedTurnId: Schema.optionalKey(TurnId),\n appliedInferenceId: Schema.optionalKey(InferenceId),\n});\n\n/** Structured-clone schema for the existing CompactionTerminal query representation. */\nexport const CompactionTerminalSchema = Schema.Union([\n Schema.Struct({ _tag: Schema.Literal(\"Completed\"), seq: SequenceNumber }),\n Schema.Struct({ _tag: Schema.Literal(\"Failed\"), seq: SequenceNumber, error: FailurePayload }),\n]);\n\n/** Structured-clone schema for the existing CompactionRecord query representation. */\nexport const CompactionRecordSchema = Schema.Struct({\n compactionId: CompactionId,\n requestedSeq: Schema.optionalKey(SequenceNumber),\n startedSeq: Schema.optionalKey(SequenceNumber),\n summaryCreatedSeq: Schema.optionalKey(SequenceNumber),\n summaryId: Schema.optionalKey(SummaryId),\n sourceFromSeq: Schema.optionalKey(SequenceNumber),\n sourceToSeq: Schema.optionalKey(SequenceNumber),\n rebasedSeq: Schema.optionalKey(SequenceNumber),\n contextVersion: Schema.optionalKey(ContextVersion),\n terminal: Schema.optionalKey(CompactionTerminalSchema),\n});\n\n/** Structured-clone schema for the existing ContextRecord query representation. */\nexport const ContextRecordSchema = Schema.Struct({\n version: ContextVersion,\n currentSummaryId: Schema.optionalKey(SummaryId),\n});\n\n/** Structured-clone schema for the existing ActiveCommandEvidence query representation. */\nexport const ActiveCommandEvidenceSchema = Schema.Struct({\n commandId: CommandId,\n runId: Schema.optionalKey(RunId),\n});\n\n/** Structured-clone schema for the existing PendingCommand query representation. */\nexport const PendingCommandSchema = Schema.Struct({\n commandId: CommandId,\n command: EDACommand,\n admittedSeq: SequenceNumber,\n admissionTrace: Schema.optionalKey(EDAEventTrace),\n});\n\n/** Structured-clone schema for the existing PendingSteeringMessage query representation. */\nexport const PendingSteeringMessageSchema = Schema.Struct({\n messageId: MessageId,\n commandId: CommandId,\n runId: RunId,\n content: QueryUserMessageContent,\n queuedSeq: SequenceNumber,\n consumedSeq: Schema.optionalKey(SequenceNumber),\n consumedTurnId: Schema.optionalKey(TurnId),\n});\n\n/** Structured-clone schema for the existing PendingUserMessage query representation. */\nexport const PendingUserMessageSchema = Schema.Struct({\n messageId: MessageId,\n commandId: CommandId,\n content: QueryUserMessageContent,\n submittedSeq: SequenceNumber,\n effectiveSeq: SequenceNumber,\n disposition: Schema.Union([Schema.Literal(\"queue\"), Schema.Literal(\"steer\")]),\n targetRunId: Schema.optionalKey(RunId),\n pausedByCommandId: Schema.optionalKey(CommandId),\n});\n\n/** Structured-clone schema for the existing CommandQueues query representation. */\nexport const CommandQueuesSchema = Schema.Struct({\n active: Schema.optional(ActiveCommandEvidenceSchema),\n pendingCommands: Schema.Array(PendingCommandSchema),\n queuedCommands: Schema.Array(PendingCommandSchema),\n activeControlCommands: Schema.Array(PendingCommandSchema),\n steeringByRun: Schema.ReadonlyMap(RunId, Schema.Array(PendingSteeringMessageSchema)),\n pendingQueue: Schema.Array(PendingUserMessageSchema),\n pendingSteers: Schema.Array(PendingUserMessageSchema),\n pausedQueue: Schema.Array(PendingUserMessageSchema),\n});\n\n/** Structured-clone schema for the existing ReducedState query representation. */\nexport const ReducedStateSchema = Schema.Struct({\n runSchedulingRequest: Schema.optionalKey(RunSchedulingRequestRecord),\n modelSelection: Schema.optionalKey(ModelSelectionPayload),\n lastSeq: SequenceNumber,\n commands: Schema.ReadonlyMap(CommandId, CommandRecordSchema),\n runs: Schema.ReadonlyMap(RunId, RunRecordSchema),\n recoveryContinuations: Schema.ReadonlyMap(RunId, RecoveryContinuationRecordSchema),\n turns: Schema.ReadonlyMap(TurnId, TurnRecordSchema),\n inferences: Schema.ReadonlyMap(InferenceId, InferenceRecordSchema),\n toolCalls: Schema.ReadonlyMap(ToolCallId, Schema.toType(ToolCallRecordSchema)),\n messages: Schema.ReadonlyMap(MessageId, QueryMessageRecordSchema),\n stopRequests: Schema.ReadonlyMap(CommandId, StopRequestRecordSchema),\n compactions: Schema.ReadonlyMap(CompactionId, CompactionRecordSchema),\n context: ContextRecordSchema,\n tokenConsumption: TokenConsumptionState,\n commandQueues: CommandQueuesSchema,\n});\n"],"mappings":";;;;;;;;;;;AA4CA,MAAM,iBAAiB,OAAO,OAAO,OAAO,SAAS,MAAM;AAC3D,M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OAAO,QAAQ,OAAO,CAAC,CAAC;CAC5E,aAAa,OAAO,YAAY,KAAK;CACrC,mBAAmB,OAAO,YAAY,SAAS;AACjD,CAAC;;AAGD,MAAa,sBAAsB,OAAO,OAAO;CAC/C,QAAQ,OAAO,SAAS,2BAA2B;CACnD,iBAAiB,OAAO,MAAM,oBAAoB;CAClD,gBAAgB,OAAO,MAAM,oBAAoB;CACjD,uBAAuB,OAAO,MAAM,oBAAoB;CACxD,eAAe,OAAO,YAAY,OAAO,OAAO,MAAM,4BAA4B,CAAC;CACnF,cAAc,OAAO,MAAM,wBAAwB;CACnD,eAAe,OAAO,MAAM,wBAAwB;CACpD,aAAa,OAAO,MAAM,wBAAwB;AACpD,CAAC;;AAGD,MAAa,qBAAqB,OAAO,OAAO;CAC9C,sBAAsB,OAAO,YAAY,0BAA0B;CACnE,gBAAgB,OAAO,YAAY,qBAAqB;CACxD,SAAS;CACT,UAAU,OAAO,YAAY,WAAW,mBAAmB;CAC3D,MAAM,OAAO,YAAY,OAAO,eAAe;CAC/C,uBAAuB,OAAO,YAAY,OAAO,gCAAgC;CACjF,OAAO,OAAO,YAAY,QAAQ,gBAAgB;CAClD,YAAY,OAAO,YAAY,aAAa,qBAAqB;CACjE,WAAW,OAAO,YAAY,YAAY,OAAO,OAAO,oBAAoB,CAAC;CAC7E,UAAU,OAAO,YAAY,WAAW,wBAAwB;CAChE,cAAc,OAAO,YAAY,WAAW,uBAAuB;CACnE,aAAa,OAAO,YAAY,cAAc,sBAAsB;CACpE,SAAS;CACT,kBAAkB;CAClB,eAAe;AACjB,CAAC"}
@@ -1,3 +1,3 @@
1
- import { A as RunTerminal, B as decodeReducedStateCheckpoint, C as ReducedStateCheckpointCommandRecord, D as ReducedStateCheckpointToolDecision, E as ReducedStateCheckpointToolCallRecord, F as TurnRecord, G as initialReducedState, H as foldReducedState, I as TurnTerminal, J as reduceCommittedEvents, K as pendingCommands, L as activeCommand, M as ToolCallRecord, N as ToolDecision, O as ReducedStateCheckpointToolTerminal, P as ToolTerminal, R as activeTurnIdentityForCommand, S as ReducedState, T as ReducedStateCheckpointPayload, U as frameworkReducedStateReducerName, V as encodeReducedStateCheckpoint, W as frameworkReducedStateReducerSchemaVersion, Y as reducedStateCheckpointEventSeqs, _ as LifecycleTiming, b as RecoverableWork, c as ActiveTurnIdentity, d as CompactionRecord, f as CompactionTerminal, g as LifecycleFailure, h as InferenceTerminal, j as StopRequestRecord, k as RunRecord, l as CommandRecord, m as InferenceRecord, p as ContextRecord, q as pendingStopCommand, s as ActiveCommandEvidence, u as CommandTerminal, v as MessageRecord, w as ReducedStateCheckpointMessageRecord, x as RecoveryContinuationRecord, y as PendingCommand, z as classifyRecoverableWork } from "../command-queues-w9WUKTpM.js";
2
- import { n as TokenConsumptionState, r as TokenUsageTotals } from "../model-usage-CNcnhj72.js";
1
+ import { A as TurnTerminal, B as pendingCommands, C as RunRecord, D as ToolDecision, E as ToolCallRecord, F as encodeReducedStateCheckpoint, H as reduceCommittedEvents, I as foldReducedState, L as frameworkReducedStateReducerName, M as activeTurnIdentityForCommand, N as classifyRecoverableWork, O as ToolTerminal, P as decodeReducedStateCheckpoint, R as frameworkReducedStateReducerSchemaVersion, S as ReducedStateCheckpointToolTerminal, T as StopRequestRecord, U as reducedStateCheckpointEventSeqs, V as pendingStopCommand, _ as ReducedStateCheckpointCommandRecord, a as CompactionRecord, b as ReducedStateCheckpointToolCallRecord, c as InferenceRecord, d as LifecycleTiming, f as MessageRecord, g as ReducedState, h as RecoveryContinuationRecord, i as CommandTerminal, j as activeCommand, k as TurnRecord, l as InferenceTerminal, m as RecoverableWork, n as ActiveTurnIdentity, o as CompactionTerminal, p as PendingCommand, r as CommandRecord, s as ContextRecord, t as ActiveCommandEvidence, u as LifecycleFailure, v as ReducedStateCheckpointMessageRecord, w as RunTerminal, x as ReducedStateCheckpointToolDecision, y as ReducedStateCheckpointPayload, z as initialReducedState } from "../reduced-state-DrSHn_47.js";
2
+ import { n as TokenConsumptionState, r as TokenUsageTotals } from "../model-usage-0GeHwaaU.js";
3
3
  export { ActiveCommandEvidence, ActiveTurnIdentity, CommandRecord, CommandTerminal, CompactionRecord, CompactionTerminal, ContextRecord, InferenceRecord, InferenceTerminal, LifecycleFailure, LifecycleTiming, MessageRecord, PendingCommand, RecoverableWork, RecoveryContinuationRecord, ReducedState, ReducedStateCheckpointCommandRecord, ReducedStateCheckpointMessageRecord, ReducedStateCheckpointPayload, ReducedStateCheckpointToolCallRecord, ReducedStateCheckpointToolDecision, ReducedStateCheckpointToolTerminal, RunRecord, RunTerminal, StopRequestRecord, TokenConsumptionState, type TokenUsageTotals, ToolCallRecord, ToolDecision, ToolTerminal, TurnRecord, TurnTerminal, activeCommand, activeTurnIdentityForCommand, classifyRecoverableWork, decodeReducedStateCheckpoint, encodeReducedStateCheckpoint, foldReducedState, frameworkReducedStateReducerName, frameworkReducedStateReducerSchemaVersion, initialReducedState, pendingCommands, pendingStopCommand, reduceCommittedEvents, reducedStateCheckpointEventSeqs };
@@ -1,2 +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-w9WUKTpM.js";
1
+ import { Bt as RunSchedulingCancellationPlan, Ft as DeferredRunResolution, Gt as canGrantRun, Ht as RunSchedulingRequest, It as LocalRunResolution, Jt as runSchedulingInputMessageIds, Kt as planRunSchedulingCancellation, Lt as RunGrantResult, Rt as RunRequestOutcome, Ut as RunSchedulingRequestRecord, Vt as RunSchedulingInput, Wt as RunSchedulingWork, Yt as waitingRunControl, qt as planWaitingRunInterruption, zt as RunResolution } from "../reduced-state-DrSHn_47.js";
2
2
  export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunRequestOutcome, RunResolution, RunSchedulingCancellationPlan, RunSchedulingInput, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runSchedulingInputMessageIds, waitingRunControl };
@@ -1 +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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AAQ,SAAS,mBAAmB,QAAQ,QAAQ,gBAAgB,YACjF;CACA,MAAM,YAAY,YAAoC;EACpD,QAAQ,QAAQ,QAAQ,MAAxB;GACE,KAAK,YACH,OAAO;GACT,KAAK,wBACH,OAAO;GACT,KAAK,yBACH,OAAO;GACT,SACE,OAAO;EACX;CACF;CACA,OAAO,SAAS,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE;AAC7F;;AAUA,MAAa,iCACX,OACA,cAC8C;CAC9C,MAAM,UAAU,MAAM;CACtB,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAClC,MAAM,SAAS,6BAA6B,OAAO,QAAQ,IAAI;CAC/D,IAAI,CAAC,OAAO,SAAS,SAAS,GAAG,OAAO,KAAA;CACxC,IAAI,QAAQ,KAAK,SAAS,WAAW,OAAO,EAAE,WAAW,QAAQ,UAAU;CAC3E,MAAM,kBAAkB,OAAO,QAAQ,OAAO,OAAO,SAAS;CAC9D,OAAO,gBAAgB,WAAW,IAC9B;EAAE,WAAW,QAAQ;EAAW,iBAAiB,QAAQ,KAAK;CAAU,IACxE;EACE,WAAW,QAAQ;EACnB,iBAAiB;GAAE,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
+ {"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,MA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AAI,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;AAC7F;;AAUA,MAAa,iCACX,OACA,cAC8C;CAC9C,MAAM,UAAU,MAAM;CACtB,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAClC,MAAM,SAAS,6BAA6B,OAAO,QAAQ,IAAI;CAC/D,IAAI,CAAC,OAAO,SAAS,SAAS,GAAG,OAAO,KAAA;CACxC,IAAI,QAAQ,KAAK,SAAS,WAAW,OAAO,EAAE,WAAW,QAAQ,UAAU;CAC3E,MAAM,kBAAkB,OAAO,QAAQ,OAAO,OAAO,SAAS;CAC9D,OAAO,gBAAgB,WAAW,IAC9B;EAAE,WAAW,QAAQ;EAAW,iBAAiB,QAAQ,KAAK;CAAU,IACxE;EACE,WAAW,QAAQ;EACnB,iBAAiB;GAAE,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,CAAC,CACpF,QAAQ,YAAY,QAAQ,cAAc,gBAAgB,CAAC,CAC3D,KAAK,YAAY,QAAQ,SAAS;EACrC,iBAAiB,QAAQ,KAAK;CAChC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"durable-DRY7AcsF.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 ForeignDurableEvent,\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/** Retained pre-inference lifecycle facts. Attempt identities remain unchanged in storage and on wire. */\nexport const LegacyTurnAttemptStartedEvent = durableEventSchema(\n makeEventType(\"TurnAttemptStarted\"),\n Schema.Struct({ runId: RunId, turnId: TurnId, attemptId: InferenceId }),\n);\n\n/** A successful historical provider request; multiple attempts can belong to one historical turn. */\nexport const LegacyTurnAttemptCompletedEvent = durableEventSchema(\n makeEventType(\"TurnAttemptCompleted\"),\n Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n attemptId: 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 }),\n);\n\n/** Historical assistant content links to the original attempt rather than a renamed event. */\nexport const LegacyAssistantMessageCommittedEvent = durableEventSchema(\n assistantMessageCommittedEventType,\n Schema.Struct({\n messageId: MessageId,\n runId: RunId,\n turnId: TurnId,\n attemptId: InferenceId,\n promptParts: AssistantPromptParts,\n }),\n);\n\n/** Historical tool decisions retain their attempt and turn references during replay. */\nexport const LegacyToolCallCreatedEvent = durableEventSchema(\n toolCallCreatedEventType,\n Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n attemptId: InferenceId,\n toolCallId: ToolCallId,\n promptPart: ToolCallPromptPart,\n }),\n);\n\n/** Explicitly supported historical shapes; unknown event types and versions remain errors. */\nexport const LegacyAttemptEvent = Schema.Union([\n LegacyTurnAttemptStartedEvent,\n LegacyTurnAttemptCompletedEvent,\n LegacyAssistantMessageCommittedEvent,\n LegacyToolCallCreatedEvent,\n]);\n\n/**\n * Interprets retained attempt references solely for domain folding. It never changes the stored\n * envelope, stream position, or wire event. Historical turns retain all of their attempts;\n * this deliberately does not split turns or manufacture lifecycle events.\n */\nexport const interpretLegacyAttemptForReduction = (\n event: EDADurableEvent,\n): CurrentEDADurableEvent => {\n if (event.type === \"TurnAttemptStarted\") {\n return {\n ...event,\n type: inferenceStartedEventType,\n payload: { ...event.payload, inferenceId: event.payload.attemptId },\n };\n }\n if (event.type === \"TurnAttemptCompleted\") {\n return {\n ...event,\n type: inferenceCompletedEventType,\n payload: { ...event.payload, inferenceId: event.payload.attemptId },\n };\n }\n if (Schema.is(AssistantMessageCommittedEvent)(event) || Schema.is(ToolCallCreatedEvent)(event)) {\n return event;\n }\n if (isLegacyAssistant(event)) {\n return { ...event, payload: { ...event.payload, inferenceId: event.payload.attemptId } };\n }\n if (isLegacyToolCall(event)) {\n return { ...event, payload: { ...event.payload, inferenceId: event.payload.attemptId } };\n }\n return event;\n};\n\nconst isLegacyAssistant = (\n event: EDADurableEvent,\n): event is typeof LegacyAssistantMessageCommittedEvent.Type =>\n event.type === assistantMessageCommittedEventType && \"attemptId\" in event.payload;\nconst isLegacyToolCall = (\n event: EDADurableEvent,\n): event is typeof LegacyToolCallCreatedEvent.Type =>\n event.type === toolCallCreatedEventType && \"attemptId\" in event.payload;\n\n/** Built-in durable event union for framework-owned session facts, including retained historical schemas. */\nexport const CurrentEDADurableEvent = 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 CurrentEDADurableEvent = typeof CurrentEDADurableEvent.Type;\n/** Retained historical facts remain readable without rewriting the event journal. */\nexport const EDADurableEvent = Schema.Union([LegacyAttemptEvent, CurrentEDADurableEvent]);\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 return decodeFrameworkEnvelope(Schema.decodeUnknownSync(DurableEventEnvelope)(input));\n};\n\nconst decodeFrameworkEnvelope = (envelope: DurableEventEnvelope): EDADurableEvent => {\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 onExcessProperty: \"preserve\",\n });\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\n/** Decoded internal facts distinguish framework events from explicitly opaque foreign envelopes. */\nexport const DecodedDurableEvent = Schema.Union([EDADurableEvent, ForeignDurableEvent]);\nexport type DecodedDurableEvent = typeof DecodedDurableEvent.Type;\n\n/** Restore the original envelope at persistence and protocol boundaries. */\nexport const durableEventEnvelope = (\n event: DecodedDurableEvent | DurableEventEnvelope,\n): DurableEventEnvelope =>\n \"envelope\" in event && Schema.is(ForeignDurableEvent)(event) ? event.envelope : event;\n\n/** Decode a durable envelope once at the store boundary, preserving foreign namespaces opaquely. */\nexport const decodeDurableEventSync = (input: unknown): DecodedDurableEvent => {\n const envelope = Schema.decodeUnknownSync(DurableEventEnvelope)(input);\n if (envelope.namespace === effectDurableAgentNamespace) return decodeFrameworkEnvelope(envelope);\n return { ...envelope, namesp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AS,4BAA4B,eAAe,MAAM;;AAGlE,MAAa,yBAAyB,OAAO,MAAM;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,kBAAkB,OAAO,MAAM,CAAC,oBAAoB,sBAAsB,CAAC;;AAIxF,MAAa,oBAAoB;;AAIjC,MAAa,oCAAoC,UAAoC;CACnF,OAAO,wBAAwB,OAAO,kBAAkB,oBAAoB,EAAE,KAAK,CAAC;AACtF;AAEA,MAAM,2BAA2B,aAAoD;CACnF,IAAI,SAAS,cAAA,wBACX,MAAM,IAAI,MACR,kDAAkD,4BAA4B,aAAa,SAAS,WACtG;CAGF,QAAQ,SAAS,eAAjB;EACE,KAAK,UACH,OAAO,OAAO,kBAAkB,iBAAiB,EAAE,UAAU,EAC3D,kBAAkB,WACpB,CAAC;EACH,SACE,MAAM,IAAI,MACR,+CAA+C,SAAS,cAAc,OAAO,SAAS,MACxF;CACJ;AACF;;AAGA,MAAa,gCACX,UAEA,OAAO,IAAI;CACT,WAAW,iCAAiC,KAAK;CACjD,QAAQ,UAAU;AACpB,CAAC;;AAGH,MAAa,sBAAsB,OAAO,MAAM,CAAC,iBAAiB,mBAAmB,CAAC;;AAItF,MAAa,wBACX,UAEA,cAAc,SAAS,OAAO,GAAG,mBAAmB,EAAE,KAAK,IAAI,MAAM,WAAW;;AAGlF,MAAa,0BAA0B,UAAwC;CAC7E,MAAM,WAAW,OAAO,kBAAkB,oBAAoB,EAAE,KAAK;CACrE,IAAI,SAAS,cAAA,wBAA2C,OAAO,wBAAwB,QAAQ;CAC/F,OAAO;EAAE,GAAG;EAAU,WAAW;EAAa,MAAM;EAAW,MAAM;EAAW;CAAS;AAC3F"}
1
+ {"version":3,"file":"durable-DRY7AcsF.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 ForeignDurableEvent,\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/** Retained pre-inference lifecycle facts. Attempt identities remain unchanged in storage and on wire. */\nexport const LegacyTurnAttemptStartedEvent = durableEventSchema(\n makeEventType(\"TurnAttemptStarted\"),\n Schema.Struct({ runId: RunId, turnId: TurnId, attemptId: InferenceId }),\n);\n\n/** A successful historical provider request; multiple attempts can belong to one historical turn. */\nexport const LegacyTurnAttemptCompletedEvent = durableEventSchema(\n makeEventType(\"TurnAttemptCompleted\"),\n Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n attemptId: 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 }),\n);\n\n/** Historical assistant content links to the original attempt rather than a renamed event. */\nexport const LegacyAssistantMessageCommittedEvent = durableEventSchema(\n assistantMessageCommittedEventType,\n Schema.Struct({\n messageId: MessageId,\n runId: RunId,\n turnId: TurnId,\n attemptId: InferenceId,\n promptParts: AssistantPromptParts,\n }),\n);\n\n/** Historical tool decisions retain their attempt and turn references during replay. */\nexport const LegacyToolCallCreatedEvent = durableEventSchema(\n toolCallCreatedEventType,\n Schema.Struct({\n runId: RunId,\n turnId: TurnId,\n attemptId: InferenceId,\n toolCallId: ToolCallId,\n promptPart: ToolCallPromptPart,\n }),\n);\n\n/** Explicitly supported historical shapes; unknown event types and versions remain errors. */\nexport const LegacyAttemptEvent = Schema.Union([\n LegacyTurnAttemptStartedEvent,\n LegacyTurnAttemptCompletedEvent,\n LegacyAssistantMessageCommittedEvent,\n LegacyToolCallCreatedEvent,\n]);\n\n/**\n * Interprets retained attempt references solely for domain folding. It never changes the stored\n * envelope, stream position, or wire event. Historical turns retain all of their attempts;\n * this deliberately does not split turns or manufacture lifecycle events.\n */\nexport const interpretLegacyAttemptForReduction = (\n event: EDADurableEvent,\n): CurrentEDADurableEvent => {\n if (event.type === \"TurnAttemptStarted\") {\n return {\n ...event,\n type: inferenceStartedEventType,\n payload: { ...event.payload, inferenceId: event.payload.attemptId },\n };\n }\n if (event.type === \"TurnAttemptCompleted\") {\n return {\n ...event,\n type: inferenceCompletedEventType,\n payload: { ...event.payload, inferenceId: event.payload.attemptId },\n };\n }\n if (Schema.is(AssistantMessageCommittedEvent)(event) || Schema.is(ToolCallCreatedEvent)(event)) {\n return event;\n }\n if (isLegacyAssistant(event)) {\n return { ...event, payload: { ...event.payload, inferenceId: event.payload.attemptId } };\n }\n if (isLegacyToolCall(event)) {\n return { ...event, payload: { ...event.payload, inferenceId: event.payload.attemptId } };\n }\n return event;\n};\n\nconst isLegacyAssistant = (\n event: EDADurableEvent,\n): event is typeof LegacyAssistantMessageCommittedEvent.Type =>\n event.type === assistantMessageCommittedEventType && \"attemptId\" in event.payload;\nconst isLegacyToolCall = (\n event: EDADurableEvent,\n): event is typeof LegacyToolCallCreatedEvent.Type =>\n event.type === toolCallCreatedEventType && \"attemptId\" in event.payload;\n\n/** Built-in durable event union for framework-owned session facts, including retained historical schemas. */\nexport const CurrentEDADurableEvent = 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 CurrentEDADurableEvent = typeof CurrentEDADurableEvent.Type;\n/** Retained historical facts remain readable without rewriting the event journal. */\nexport const EDADurableEvent = Schema.Union([LegacyAttemptEvent, CurrentEDADurableEvent]);\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 return decodeFrameworkEnvelope(Schema.decodeUnknownSync(DurableEventEnvelope)(input));\n};\n\nconst decodeFrameworkEnvelope = (envelope: DurableEventEnvelope): EDADurableEvent => {\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 onExcessProperty: \"preserve\",\n });\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\n/** Decoded internal facts distinguish framework events from explicitly opaque foreign envelopes. */\nexport const DecodedDurableEvent = Schema.Union([EDADurableEvent, ForeignDurableEvent]);\nexport type DecodedDurableEvent = typeof DecodedDurableEvent.Type;\n\n/** Restore the original envelope at persistence and protocol boundaries. */\nexport const durableEventEnvelope = (\n event: DecodedDurableEvent | DurableEventEnvelope,\n): DurableEventEnvelope =>\n \"envelope\" in event && Schema.is(ForeignDurableEvent)(event) ? event.envelope : event;\n\n/** Decode a durable envelope once at the store boundary, preserving foreign namespaces opaquely. */\nexport const decodeDurableEventSync = (input: unknown): DecodedDurableEvent => {\n const envelope = Schema.decodeUnknownSync(DurableEventEnvelope)(input);\n if (envelope.namespace === effectDurableAgentNamespace) return decodeFrameworkEnvelope(envelope);\n return { ...envelope, namespace: \"__foreign\", type: \"Foreign\", _tag: \"Foreign\", envelope };\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;;;;ACGH,MAAa,6BAA6B,cAAc,mBAAmB;AAC3E,MAAa,yBAAyB,mBACpC,4BACA,OAAO,OAAO,EAAE,gBAAgB,sBAAsB,CAAC,CACzD;;AAIA,MAAa,2BAA2B,cAAc,iBAAiB;AACvE,MAAa,0BAA0B,cAAc,gBAAgB;AACrE,MAAa,4BAA4B,cAAc,kBAAkB;AACzE,MAAa,yBAAyB,cAAc,eAAe;AACnE,MAAa,4BAA4B,cAAc,kBAAkB;;AAGzE,MAAa,yBAAyB,OAAO,OAAO,EAAE,SAAS,WAAW,CAAC;AAE3E,MAAa,uBAAuB,mBAClC,0BACA,sBACF;;AAIA,MAAa,wBAAwB,OAAO,OAAO,EAAE,WAAW,UAAU,CAAC;AAE3E,MAAa,sBAAsB,mBACjC,yBACA,qBACF;;AAIA,MAAa,0BAA0B,OAAO,OAAO,EAAE,WAAW,UAAU,CAAC;AAE7E,MAAa,wBAAwB,mBACnC,2BACA,uBACF;;AAIA,MAAa,uBAAuB,OAAO,OAAO;CAAE,WAAW;CAA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