effect-durable-agent 0.1.0-alpha.1

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 (140) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/CONTRIBUTING.md +26 -0
  3. package/LICENSE +21 -0
  4. package/README.md +305 -0
  5. package/SECURITY.md +8 -0
  6. package/dist/command-queues-CQ9cwRP7.d.ts +468 -0
  7. package/dist/commands-Ce1ec6kH.d.ts +104 -0
  8. package/dist/compaction-YayFKo_1.d.ts +144 -0
  9. package/dist/core-Hv3cFydL.d.ts +81 -0
  10. package/dist/domain/command-queues.d.ts +2 -0
  11. package/dist/domain/command-queues.js +97 -0
  12. package/dist/domain/command-queues.js.map +1 -0
  13. package/dist/domain/message-transcript.d.ts +2 -0
  14. package/dist/domain/message-transcript.js +111 -0
  15. package/dist/domain/message-transcript.js.map +1 -0
  16. package/dist/domain/reduced-state-schema.d.ts +996 -0
  17. package/dist/domain/reduced-state-schema.js +286 -0
  18. package/dist/domain/reduced-state-schema.js.map +1 -0
  19. package/dist/domain/reduced-state.d.ts +2 -0
  20. package/dist/domain/reduced-state.js +2 -0
  21. package/dist/durable-C3Rz7kg3.js +625 -0
  22. package/dist/durable-C3Rz7kg3.js.map +1 -0
  23. package/dist/durable-DlScwmCy.d.ts +7424 -0
  24. package/dist/durable-object-runtime-B7jwBY2R.js +1494 -0
  25. package/dist/durable-object-runtime-B7jwBY2R.js.map +1 -0
  26. package/dist/durable-object-runtime-pWv0ohlz.d.ts +257 -0
  27. package/dist/durable-object-storage-Czy7IPrh.d.ts +41 -0
  28. package/dist/events-Bb9-Cu-7.d.ts +918 -0
  29. package/dist/host/durable-object-runtime.d.ts +2 -0
  30. package/dist/host/durable-object-runtime.js +2 -0
  31. package/dist/host/durable-object-storage.d.ts +2 -0
  32. package/dist/host/durable-object-storage.js +0 -0
  33. package/dist/host/durable-object.d.ts +83 -0
  34. package/dist/host/durable-object.js +191 -0
  35. package/dist/host/durable-object.js.map +1 -0
  36. package/dist/host/websocket-wire.d.ts +2 -0
  37. package/dist/host/websocket-wire.js +88 -0
  38. package/dist/host/websocket-wire.js.map +1 -0
  39. package/dist/id-generator-C2Q15uZM.d.ts +33 -0
  40. package/dist/index-BVVgDSdq.d.ts +1 -0
  41. package/dist/index.d.ts +7 -0
  42. package/dist/index.js +7 -0
  43. package/dist/keep-alive-DYDsH6qN.d.ts +111 -0
  44. package/dist/keep-alive-p8dIcSVy.js +109 -0
  45. package/dist/keep-alive-p8dIcSVy.js.map +1 -0
  46. package/dist/message-transcript-BCHdHAe2.d.ts +32 -0
  47. package/dist/prompt-projector-9_02lk5-.d.ts +40 -0
  48. package/dist/reduced-state-C4nVVzz9.js +910 -0
  49. package/dist/reduced-state-C4nVVzz9.js.map +1 -0
  50. package/dist/reducer-registry-C0svUa63.d.ts +69 -0
  51. package/dist/runtime-C56FQxiL.d.ts +60 -0
  52. package/dist/services/compaction.d.ts +2 -0
  53. package/dist/services/compaction.js +426 -0
  54. package/dist/services/compaction.js.map +1 -0
  55. package/dist/services/id-generator.d.ts +2 -0
  56. package/dist/services/id-generator.js +56 -0
  57. package/dist/services/id-generator.js.map +1 -0
  58. package/dist/services/prompt-projector.d.ts +2 -0
  59. package/dist/services/prompt-projector.js +27 -0
  60. package/dist/services/prompt-projector.js.map +1 -0
  61. package/dist/services/reducer-registry.d.ts +2 -0
  62. package/dist/services/reducer-registry.js +71 -0
  63. package/dist/services/reducer-registry.js.map +1 -0
  64. package/dist/services/runtime.d.ts +2 -0
  65. package/dist/services/runtime.js +84 -0
  66. package/dist/services/runtime.js.map +1 -0
  67. package/dist/services/session-query.d.ts +2 -0
  68. package/dist/services/session-query.js +2 -0
  69. package/dist/services/session-store.d.ts +2 -0
  70. package/dist/services/session-store.js +2 -0
  71. package/dist/services/sink-registry.d.ts +2 -0
  72. package/dist/services/sink-registry.js +2 -0
  73. package/dist/services/span-names.d.ts +28 -0
  74. package/dist/services/span-names.js +42 -0
  75. package/dist/services/span-names.js.map +1 -0
  76. package/dist/services/tool-registry.d.ts +2 -0
  77. package/dist/services/tool-registry.js +46 -0
  78. package/dist/services/tool-registry.js.map +1 -0
  79. package/dist/services/tracing.d.ts +76 -0
  80. package/dist/services/tracing.js +116 -0
  81. package/dist/services/tracing.js.map +1 -0
  82. package/dist/session-query-DOc1KanA.js +2930 -0
  83. package/dist/session-query-DOc1KanA.js.map +1 -0
  84. package/dist/session-query-DlRo5Ufc.d.ts +769 -0
  85. package/dist/session-store-D2Ore1QC.d.ts +295 -0
  86. package/dist/session-store-pYxQW9qh.js +214 -0
  87. package/dist/session-store-pYxQW9qh.js.map +1 -0
  88. package/dist/sink-registry-CFC6xjsN.js +312 -0
  89. package/dist/sink-registry-CFC6xjsN.js.map +1 -0
  90. package/dist/sink-registry-CIU0LD3m.d.ts +158 -0
  91. package/dist/testkit/layers.d.ts +101 -0
  92. package/dist/testkit/layers.js +108 -0
  93. package/dist/testkit/layers.js.map +1 -0
  94. package/dist/tool-registry-CcnkAAQK.d.ts +51 -0
  95. package/dist/tracing-BXHAkxkx.d.ts +111 -0
  96. package/dist/types/commands.d.ts +2 -0
  97. package/dist/types/commands.js +60 -0
  98. package/dist/types/commands.js.map +1 -0
  99. package/dist/types/core.d.ts +2 -0
  100. package/dist/types/core.js +68 -0
  101. package/dist/types/core.js.map +1 -0
  102. package/dist/types/events/durable.d.ts +2 -0
  103. package/dist/types/events/durable.js +2 -0
  104. package/dist/types/events.d.ts +4 -0
  105. package/dist/types/events.js +90 -0
  106. package/dist/types/events.js.map +1 -0
  107. package/dist/types/tracing.d.ts +2 -0
  108. package/dist/types/tracing.js +99 -0
  109. package/dist/types/tracing.js.map +1 -0
  110. package/dist/websocket-wire-DvOu_6BJ.d.ts +16773 -0
  111. package/docs/assets/architecture.svg +106 -0
  112. package/docs/assets/event-sequence.svg +143 -0
  113. package/docs/assets/gcp-trace.png +0 -0
  114. package/docs/message-steering.md +831 -0
  115. package/docs/releasing.md +57 -0
  116. package/docs/spec.md +774 -0
  117. package/docs/subagents.md +725 -0
  118. package/docs/testing.md +64 -0
  119. package/docs/ui-projection.md +742 -0
  120. package/docs/websocket-protocol.md +613 -0
  121. package/examples/001-no-tools/README.md +65 -0
  122. package/examples/001-no-tools/worker.ts +79 -0
  123. package/examples/002-slack-bridge/README.md +134 -0
  124. package/examples/002-slack-bridge/events.ts +115 -0
  125. package/examples/002-slack-bridge/reducer.ts +216 -0
  126. package/examples/002-slack-bridge/scenario.test.ts +223 -0
  127. package/examples/002-slack-bridge/sinks.ts +109 -0
  128. package/examples/002-slack-bridge/worker.ts +140 -0
  129. package/examples/003-sandbox-lifecycle/README.md +78 -0
  130. package/examples/003-sandbox-lifecycle/events.ts +203 -0
  131. package/examples/003-sandbox-lifecycle/reducer.ts +305 -0
  132. package/examples/003-sandbox-lifecycle/scenario.test.ts +202 -0
  133. package/examples/_shared/event-id.ts +12 -0
  134. package/examples/_shared/http.ts +27 -0
  135. package/examples/_shared/openai.ts +33 -0
  136. package/package.json +181 -0
  137. package/testing/offline-trace/README.md +63 -0
  138. package/tooling/oxlint/index.mjs +15 -0
  139. package/tooling/oxlint/rules/effect-span-from-catalog.mjs +152 -0
  140. package/tooling/oxlint/rules/span-catalog-format.mjs +74 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reduced-state-C4nVVzz9.js","names":[],"sources":["../src/domain/assert-never.ts","../src/domain/reduced-state.ts"],"sourcesContent":["const formatNeverValue = (value: never): string => {\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n};\n\n/** Build the defect used when an exhaustive switch receives an impossible value. */\nexport const assertNeverError = (value: never, context: string) =>\n new Error(`Unhandled ${context}: ${formatNeverValue(value)}`);\n\n/** Throw for impossible branches in pure code after TypeScript exhaustiveness checking. */\nexport const assertNever = (value: never, context: string): never => {\n throw assertNeverError(value, context);\n};\n","import type * as Prompt from \"effect/unstable/ai/Prompt\";\n\nimport { assertNever } from \"./assert-never\";\nimport { deriveCommandQueues, emptyCommandQueues, type CommandQueues } from \"./command-queues\";\nimport {\n InferenceId,\n CommandId,\n CompactionId,\n ContextVersion,\n MessageId,\n RunId,\n SequenceNumber,\n SummaryId,\n ToolCallId,\n TurnId,\n} from \"../types/core\";\nimport {\n assistantMessageCommittedEventType,\n assistantPartialCommittedEventType,\n baseStateCreatedEventType,\n baseStateFailedEventType,\n baseStateRequestedEventType,\n commandAdmittedEventType,\n commandCancelledEventType,\n commandCompletedEventType,\n commandFailedEventType,\n commandStartedEventType,\n compactionCompletedEventType,\n compactionFailedEventType,\n compactionRequestedEventType,\n compactionStartedEventType,\n contextProjectedEventType,\n effectDurableAgentNamespace,\n contextRebasedEventType,\n inferenceCompletedEventType,\n inferenceFailedEventType,\n inferenceStartedEventType,\n runCompletedEventType,\n runFailedEventType,\n runInterruptedEventType,\n runStartedEventType,\n stopTurnAppliedEventType,\n stopTurnRequestedEventType,\n steeringMessageCancelledEventType,\n steeringMessageQueuedEventType,\n userMessageSubmittedEventType,\n userMessagePromotedEventType,\n userMessageCancelledEventType,\n messageQueuePausedEventType,\n pendingMessagesPausedEventType,\n recoveryCompletedEventType,\n summaryCreatedEventType,\n systemMessageCommittedEventType,\n toolCallCompletedEventType,\n toolCallCreatedEventType,\n toolCallFailedEventType,\n toolCallRejectedEventType,\n toolCallStartedEventType,\n turnCompletedEventType,\n turnFailedEventType,\n turnStartedEventType,\n turnStoppedEventType,\n userMessageCommittedEventType,\n} from \"../types/events\";\nimport { type EDACommand as EDACommandValue, type UserMessageContent } from \"../types/commands\";\nimport type {\n AssistantMessageContent,\n EDAEventTrace,\n EDARunTrace,\n FailurePayload,\n ProviderPartId,\n RecoveryContinuation,\n SystemPromptText,\n ToolName,\n UsagePayload,\n} from \"../types/events\";\nimport type { CommittedDurableEvent } from \"../services/session-store\";\n\n/** Failure payload paired with the durable sequence that recorded it. */\nexport type LifecycleFailure = {\n readonly seq: SequenceNumber;\n readonly error: FailurePayload;\n};\n\n/** Terminal command state folded from command lifecycle events. */\nexport type CommandTerminal =\n | { readonly _tag: \"Completed\"; readonly seq: SequenceNumber }\n | { readonly _tag: \"Failed\"; readonly seq: SequenceNumber; readonly error: FailurePayload }\n | { readonly _tag: \"Cancelled\"; readonly seq: SequenceNumber; readonly reason: string };\n\n/** Durable command lifecycle projection used for scheduling and recovery. */\nexport interface CommandRecord {\n readonly commandId: CommandId;\n readonly command?: EDACommandValue;\n readonly admittedSeq?: SequenceNumber;\n readonly admissionTrace?: EDAEventTrace;\n readonly startedSeq?: SequenceNumber;\n readonly terminal?: CommandTerminal;\n}\n\n/** Terminal run state folded from run lifecycle events. */\nexport type RunTerminal =\n | { readonly _tag: \"Completed\"; readonly seq: SequenceNumber }\n | { readonly _tag: \"Failed\"; readonly seq: SequenceNumber; readonly error: FailurePayload }\n | { readonly _tag: \"Interrupted\"; readonly seq: SequenceNumber; readonly reason: string };\n\n/** Common wall-clock lifecycle timing folded from durable event envelopes. */\nexport interface LifecycleTiming {\n readonly startedAtMs?: number;\n readonly terminalAtMs?: number;\n readonly durationMs?: number;\n}\n\n/** Durable run lifecycle projection tying one run to its owning command ids. */\nexport interface RunRecord extends LifecycleTiming {\n readonly runId: RunId;\n readonly commandIds: ReadonlyArray<CommandId>;\n readonly startedSeq: SequenceNumber;\n readonly trace: EDARunTrace;\n readonly terminal?: RunTerminal;\n}\n\n/** Terminal turn state folded from turn lifecycle events. */\nexport type TurnTerminal =\n | { readonly _tag: \"Completed\"; readonly seq: SequenceNumber; readonly usage?: UsagePayload }\n | { readonly _tag: \"Failed\"; readonly seq: SequenceNumber; readonly error: FailurePayload }\n | { readonly _tag: \"Stopped\"; readonly seq: SequenceNumber; readonly reason: string };\n\n/** Durable turn lifecycle projection nested under a run. */\nexport interface TurnRecord extends LifecycleTiming {\n readonly runId: RunId;\n readonly turnId: TurnId;\n readonly startedSeq: SequenceNumber;\n readonly terminal?: TurnTerminal;\n}\n\n/** Terminal inference state folded from inference lifecycle events. */\nexport type InferenceTerminal =\n | { readonly _tag: \"Completed\"; readonly seq: SequenceNumber; readonly usage?: UsagePayload }\n | { readonly _tag: \"Failed\"; readonly seq: SequenceNumber; readonly error: FailurePayload };\n\n/** Durable model-inference lifecycle projection nested under a turn. */\nexport interface InferenceRecord extends LifecycleTiming {\n readonly runId: RunId;\n readonly turnId: TurnId;\n readonly inferenceId: InferenceId;\n readonly startedSeq: SequenceNumber;\n readonly terminal?: InferenceTerminal;\n}\n\n/** Durable decision produced after a model inference seals final tool calls. */\nexport type ToolDecision =\n | {\n readonly _tag: \"Created\";\n readonly seq: SequenceNumber;\n readonly runId: RunId;\n readonly turnId: TurnId;\n readonly inferenceId: InferenceId;\n readonly providerPartId: ProviderPartId;\n readonly toolName: ToolName;\n readonly params: unknown;\n readonly providerExecuted: boolean;\n readonly promptPart?: Prompt.ToolCallPart;\n }\n | {\n readonly _tag: \"Rejected\";\n readonly seq: SequenceNumber;\n readonly runId: RunId;\n readonly turnId: TurnId;\n readonly inferenceId: InferenceId;\n readonly providerPartId: ProviderPartId;\n readonly toolName: ToolName;\n readonly reason: \"unknown-tool\" | \"invalid-params\";\n readonly modelFeedback: string;\n readonly promptPart?: Prompt.ToolResultPart;\n };\n\n/** Terminal framework-owned tool-call execution state. */\nexport type ToolTerminal =\n | {\n readonly _tag: \"Completed\";\n readonly seq: SequenceNumber;\n readonly result: unknown;\n readonly promptPart?: Prompt.ToolResultPart;\n }\n | {\n readonly _tag: \"Failed\";\n readonly seq: SequenceNumber;\n readonly error: FailurePayload;\n readonly promptPart?: Prompt.ToolResultPart;\n };\n\n/** Durable tool-call projection from decision through execution terminal. */\nexport interface ToolCallRecord extends LifecycleTiming {\n readonly toolCallId: ToolCallId;\n readonly decision?: ToolDecision;\n readonly startedSeq?: SequenceNumber;\n readonly terminal?: ToolTerminal;\n}\n\n/** Durable message-like facts folded from the event log. */\nexport type MessageRecord =\n | {\n readonly _tag: \"System\";\n readonly messageId: MessageId;\n readonly content: SystemPromptText;\n readonly createdAtMs?: number;\n readonly seq: SequenceNumber;\n }\n | {\n readonly _tag: \"User\";\n readonly messageId: MessageId;\n readonly commandId: CommandId;\n readonly content: UserMessageContent;\n readonly createdAtMs?: number;\n readonly seq: SequenceNumber;\n /** Present for admission-time message entities; absent on legacy committed users. */\n readonly requestedDisposition?: \"queue\" | \"steer\";\n readonly disposition?: \"queue\" | \"steer\";\n readonly promotedSeq?: SequenceNumber;\n readonly pausedSeq?: SequenceNumber;\n readonly pausedByCommandId?: CommandId;\n readonly consumedSeq?: SequenceNumber;\n readonly consumedTurnId?: TurnId;\n readonly cancelledSeq?: SequenceNumber;\n readonly cancelledByCommandId?: CommandId;\n readonly cancellationReason?: string;\n }\n | {\n readonly _tag: \"Steering\";\n readonly messageId: MessageId;\n readonly commandId: CommandId;\n readonly runId: RunId;\n readonly content: UserMessageContent;\n readonly createdAtMs?: number;\n readonly seq: SequenceNumber;\n readonly promotedSeq?: SequenceNumber;\n readonly consumedSeq?: SequenceNumber;\n readonly consumedTurnId?: TurnId;\n readonly cancelledSeq?: SequenceNumber;\n readonly cancelledByCommandId?: CommandId;\n readonly cancellationReason?: string;\n readonly pausedSeq?: SequenceNumber;\n readonly pausedByCommandId?: CommandId;\n }\n | {\n readonly _tag: \"Assistant\";\n readonly messageId: MessageId;\n readonly runId: RunId;\n readonly turnId: TurnId;\n readonly inferenceId: InferenceId;\n readonly content: AssistantMessageContent;\n readonly createdAtMs?: number;\n readonly promptParts?: ReadonlyArray<Prompt.AssistantMessagePart>;\n readonly seq: SequenceNumber;\n }\n | {\n readonly _tag: \"AssistantPartial\";\n readonly messageId: MessageId;\n readonly runId: RunId;\n readonly turnId: TurnId;\n readonly inferenceId: InferenceId;\n readonly content: AssistantMessageContent;\n readonly createdAtMs?: number;\n readonly promptParts?: ReadonlyArray<Prompt.AssistantMessagePart>;\n readonly reason: string;\n readonly seq: SequenceNumber;\n };\n\n/** Terminal compaction state folded from compaction lifecycle events. */\nexport type CompactionTerminal =\n | { readonly _tag: \"Completed\"; readonly seq: SequenceNumber }\n | { readonly _tag: \"Failed\"; readonly seq: SequenceNumber; readonly error: FailurePayload };\n\n/** Durable compaction lifecycle projection and its produced summary cursor. */\nexport interface CompactionRecord {\n readonly compactionId: CompactionId;\n readonly requestedSeq?: SequenceNumber;\n readonly startedSeq?: SequenceNumber;\n readonly summaryCreatedSeq?: SequenceNumber;\n readonly summaryId?: SummaryId;\n readonly sourceFromSeq?: SequenceNumber;\n readonly sourceToSeq?: SequenceNumber;\n readonly rebasedSeq?: SequenceNumber;\n readonly contextVersion?: ContextVersion;\n readonly terminal?: CompactionTerminal;\n}\n\n/** Current model-context version and summary selected by compaction. */\nexport interface ContextRecord {\n readonly version: ContextVersion;\n readonly currentSummaryId?: SummaryId;\n}\n\n/** Durable StopTurn request and the lifecycle boundary it eventually applied to. */\nexport interface StopRequestRecord {\n readonly commandId: CommandId;\n readonly requestedSeq: SequenceNumber;\n readonly requestedRunId?: RunId;\n readonly requestedTurnId?: TurnId;\n readonly appliedSeq?: SequenceNumber;\n readonly appliedRunId?: RunId;\n readonly appliedTurnId?: TurnId;\n readonly appliedInferenceId?: InferenceId;\n}\n\n/** Rolling session totals for provider-reported model token usage. */\nexport interface TokenUsageTotals {\n readonly inputTokens: number;\n readonly cachedInputTokens: number;\n readonly outputTokens: number;\n readonly textTokens: number;\n readonly reasoningTokens: number;\n}\n\n/** First-party token consumption metadata folded by the framework reducer. */\nexport interface TokenConsumptionState {\n readonly total: TokenUsageTotals;\n}\n\n/** Admitted command that has not yet crossed the `CommandStarted` boundary. */\nexport interface PendingCommand {\n /** Lifecycle ID for the admitted command. */\n readonly commandId: CommandId;\n /** Typed command payload admitted durably. */\n readonly command: EDACommandValue;\n /** Admission sequence used for deterministic FIFO/control ordering. */\n readonly admittedSeq: SequenceNumber;\n /** Trace context captured at the durable command admission boundary. */\n readonly admissionTrace?: EDAEventTrace;\n}\n\n/** Started command without a terminal command boundary, optionally tied to an open run. */\nexport interface ActiveCommandEvidence {\n readonly commandId: CommandId;\n readonly runId?: RunId;\n}\n\n/** Active run/turn/inference identity derived from unfinished lifecycle records. */\nexport type ActiveTurnIdentity = {\n readonly runId: RunId;\n readonly turnId: TurnId;\n readonly inferenceId?: InferenceId;\n};\n\n/** Canonical durable replay product used by queries, recovery, and scheduling. */\nexport interface ReducedState {\n readonly lastSeq: SequenceNumber;\n readonly commands: ReadonlyMap<CommandId, CommandRecord>;\n readonly runs: ReadonlyMap<RunId, RunRecord>;\n /** Explicit startup-recovery links keyed by replacement physical run id. */\n readonly recoveryContinuations: ReadonlyMap<RunId, RecoveryContinuationRecord>;\n readonly turns: ReadonlyMap<TurnId, TurnRecord>;\n readonly inferences: ReadonlyMap<InferenceId, InferenceRecord>;\n readonly toolCalls: ReadonlyMap<ToolCallId, ToolCallRecord>;\n readonly messages: ReadonlyMap<MessageId, MessageRecord>;\n readonly stopRequests: ReadonlyMap<CommandId, StopRequestRecord>;\n readonly compactions: ReadonlyMap<CompactionId, CompactionRecord>;\n readonly context: ContextRecord;\n /** Rolling model-token usage totals derived from completed provider inferences. */\n readonly tokenConsumption: TokenConsumptionState;\n /** Materialized scheduler queues derived from the maps above after every fold. */\n readonly commandQueues: CommandQueues;\n}\n\n/** Durable recovery continuation plus the sequence of its completion barrier. */\nexport interface RecoveryContinuationRecord extends RecoveryContinuation {\n readonly seq: SequenceNumber;\n}\n\n/** Unfinished lifecycle records requiring deterministic startup recovery. */\nexport interface RecoverableWork {\n readonly activeCommands: ReadonlyArray<CommandRecord>;\n readonly activeRuns: ReadonlyArray<RunRecord>;\n readonly activeTurns: ReadonlyArray<TurnRecord>;\n readonly activeInferences: ReadonlyArray<InferenceRecord>;\n readonly openToolCalls: ReadonlyArray<ToolCallRecord>;\n readonly runningToolCalls: ReadonlyArray<ToolCallRecord>;\n readonly pendingStopRequests: ReadonlyArray<StopRequestRecord>;\n readonly openCompactions: ReadonlyArray<CompactionRecord>;\n}\n\nconst emptyTokenUsageTotals: TokenUsageTotals = {\n inputTokens: 0,\n cachedInputTokens: 0,\n outputTokens: 0,\n textTokens: 0,\n reasoningTokens: 0,\n};\n\nconst emptyTokenConsumptionState: TokenConsumptionState = {\n total: emptyTokenUsageTotals,\n};\n\n/** Empty durable replay state before any session event has committed. */\nexport const initialReducedState: ReducedState = {\n lastSeq: SequenceNumber.make(0),\n commands: new Map(),\n runs: new Map(),\n recoveryContinuations: new Map(),\n turns: new Map(),\n inferences: new Map(),\n toolCalls: new Map(),\n messages: new Map(),\n stopRequests: new Map(),\n compactions: new Map(),\n context: { version: ContextVersion.make(0) },\n tokenConsumption: emptyTokenConsumptionState,\n commandQueues: emptyCommandQueues,\n};\n\n/** Reserved reducer checkpoint name for the framework-owned `ReducedState`. */\nexport const frameworkReducedStateReducerName = \"_eda.framework.reduced-state\";\n\n/** Schema version for the framework-owned `ReducedState` checkpoint payload. */\nexport const frameworkReducedStateReducerSchemaVersion = 4;\n\n/** JSON payload stored for the framework-owned reduced-state reducer checkpoint. */\nexport type ReducedStateCheckpointCommandRecord = Omit<CommandRecord, \"command\">;\n\ntype SystemMessageRecord = Extract<MessageRecord, { readonly _tag: \"System\" }>;\ntype UserMessageRecord = Extract<MessageRecord, { readonly _tag: \"User\" }>;\ntype SteeringMessageRecord = Extract<MessageRecord, { readonly _tag: \"Steering\" }>;\ntype AssistantMessageRecord = Extract<MessageRecord, { readonly _tag: \"Assistant\" }>;\ntype AssistantPartialMessageRecord = Extract<MessageRecord, { readonly _tag: \"AssistantPartial\" }>;\n\nexport type ReducedStateCheckpointMessageRecord =\n | Omit<SystemMessageRecord, \"content\">\n | Omit<UserMessageRecord, \"content\">\n | Omit<SteeringMessageRecord, \"content\">\n | Omit<AssistantMessageRecord, \"content\" | \"promptParts\">\n | Omit<AssistantPartialMessageRecord, \"content\" | \"promptParts\">;\n\ntype CreatedToolDecision = Extract<ToolDecision, { readonly _tag: \"Created\" }>;\ntype RejectedToolDecision = Extract<ToolDecision, { readonly _tag: \"Rejected\" }>;\ntype CompletedToolTerminal = Extract<ToolTerminal, { readonly _tag: \"Completed\" }>;\ntype FailedToolTerminal = Extract<ToolTerminal, { readonly _tag: \"Failed\" }>;\n\nexport type ReducedStateCheckpointToolDecision =\n | Omit<CreatedToolDecision, \"params\" | \"promptPart\">\n | Omit<RejectedToolDecision, \"promptPart\">;\n\nexport type ReducedStateCheckpointToolTerminal =\n | Omit<CompletedToolTerminal, \"result\" | \"promptPart\">\n | Omit<FailedToolTerminal, \"error\" | \"promptPart\">;\n\nexport interface ReducedStateCheckpointToolCallRecord extends Omit<\n ToolCallRecord,\n \"decision\" | \"terminal\"\n> {\n readonly decision?: ReducedStateCheckpointToolDecision;\n readonly terminal?: ReducedStateCheckpointToolTerminal;\n}\n\nexport interface ReducedStateCheckpointPayload {\n readonly lastSeq: SequenceNumber;\n readonly commands: ReadonlyArray<readonly [CommandId, ReducedStateCheckpointCommandRecord]>;\n readonly runs: ReadonlyArray<readonly [RunId, RunRecord]>;\n readonly recoveryContinuations?: ReadonlyArray<readonly [RunId, RecoveryContinuationRecord]>;\n readonly turns: ReadonlyArray<readonly [TurnId, TurnRecord]>;\n readonly inferences: ReadonlyArray<readonly [InferenceId, InferenceRecord]>;\n readonly toolCalls: ReadonlyArray<readonly [ToolCallId, ReducedStateCheckpointToolCallRecord]>;\n readonly messages: ReadonlyArray<readonly [MessageId, ReducedStateCheckpointMessageRecord]>;\n readonly stopRequests: ReadonlyArray<readonly [CommandId, StopRequestRecord]>;\n readonly compactions: ReadonlyArray<readonly [CompactionId, CompactionRecord]>;\n readonly context: ContextRecord;\n readonly tokenConsumption?: TokenConsumptionState;\n}\n\n/** Encode the framework reducer state into a pointer-based JSON-safe checkpoint payload. */\nexport const encodeReducedStateCheckpoint = (\n state: ReducedState,\n): ReducedStateCheckpointPayload => ({\n lastSeq: state.lastSeq,\n commands: Array.from(state.commands.entries()).map(([commandId, record]) => [\n commandId,\n encodeCheckpointCommandRecord(record),\n ]),\n runs: Array.from(state.runs.entries()),\n recoveryContinuations: Array.from(state.recoveryContinuations.entries()),\n turns: Array.from(state.turns.entries()),\n inferences: Array.from(state.inferences.entries()),\n toolCalls: Array.from(state.toolCalls.entries()).map(([toolCallId, record]) => [\n toolCallId,\n encodeCheckpointToolCallRecord(record),\n ]),\n messages: Array.from(state.messages.entries()).map(([messageId, record]) => [\n messageId,\n encodeCheckpointMessageRecord(record),\n ]),\n stopRequests: Array.from(state.stopRequests.entries()),\n compactions: Array.from(state.compactions.entries()),\n context: state.context,\n tokenConsumption: state.tokenConsumption,\n});\n\n/** Event-log positions required to hydrate a pointer-based framework checkpoint. */\nexport const reducedStateCheckpointEventSeqs = (\n payload: unknown,\n): ReadonlyArray<SequenceNumber> => {\n const checkpoint = payload as ReducedStateCheckpointPayload;\n const seqs: Array<SequenceNumber> = [];\n for (const [, record] of checkpoint.commands ?? []) {\n if (record.admittedSeq !== undefined) {\n seqs.push(record.admittedSeq);\n }\n }\n for (const [, record] of checkpoint.messages ?? []) {\n seqs.push(record.seq);\n }\n for (const [, record] of checkpoint.toolCalls ?? []) {\n if (record.decision !== undefined) {\n seqs.push(record.decision.seq);\n }\n if (\n record.terminal !== undefined &&\n (record.terminal._tag === \"Completed\" || record.terminal._tag === \"Failed\")\n ) {\n seqs.push(record.terminal.seq);\n }\n }\n return uniqueSequenceNumbers(seqs);\n};\n\n/** Decode the framework reducer checkpoint and rebuild derived scheduler queues. */\nexport const decodeReducedStateCheckpoint = (\n payload: unknown,\n referencedEvents: ReadonlyArray<CommittedDurableEvent>,\n): ReducedState => {\n const checkpoint = payload as ReducedStateCheckpointPayload;\n const eventsBySeq = committedEventMapBySeq(referencedEvents);\n const commands = decodeCheckpointCommandRecords(checkpoint.commands ?? [], eventsBySeq);\n const runs = new Map(checkpoint.runs ?? []);\n const messages = decodeCheckpointMessageRecords(checkpoint.messages ?? [], eventsBySeq);\n return {\n lastSeq: SequenceNumber.make(Number(checkpoint.lastSeq ?? 0)),\n commands,\n runs,\n recoveryContinuations: new Map(checkpoint.recoveryContinuations ?? []),\n turns: new Map(checkpoint.turns ?? []),\n inferences: new Map(checkpoint.inferences ?? []),\n toolCalls: decodeCheckpointToolCallRecords(checkpoint.toolCalls ?? [], eventsBySeq),\n messages,\n stopRequests: new Map(checkpoint.stopRequests ?? []),\n compactions: new Map(checkpoint.compactions ?? []),\n context: checkpoint.context ?? { version: ContextVersion.make(0) },\n tokenConsumption: decodeTokenConsumptionState(checkpoint.tokenConsumption),\n commandQueues: deriveCommandQueues({ commands, runs, messages }),\n };\n};\n\nconst encodeCheckpointCommandRecord = (\n record: CommandRecord,\n): ReducedStateCheckpointCommandRecord => {\n const { command: _command, ...checkpoint } = record;\n return checkpoint;\n};\n\nconst encodeCheckpointMessageRecord = (\n record: MessageRecord,\n): ReducedStateCheckpointMessageRecord => {\n switch (record._tag) {\n case \"System\": {\n const { content: _content, ...checkpoint } = record;\n return checkpoint;\n }\n case \"User\": {\n const { content: _content, ...checkpoint } = record;\n return checkpoint;\n }\n case \"Steering\": {\n const { content: _content, ...checkpoint } = record;\n return checkpoint;\n }\n case \"Assistant\": {\n const { content: _content, promptParts: _promptParts, ...checkpoint } = record;\n return checkpoint;\n }\n case \"AssistantPartial\": {\n const { content: _content, promptParts: _promptParts, ...checkpoint } = record;\n return checkpoint;\n }\n default:\n return assertNever(record, \"checkpoint message record\");\n }\n};\n\nconst encodeCheckpointToolCallRecord = (\n record: ToolCallRecord,\n): ReducedStateCheckpointToolCallRecord => ({\n toolCallId: record.toolCallId,\n ...(record.decision === undefined\n ? {}\n : { decision: encodeCheckpointToolDecision(record.decision) }),\n ...(record.durationMs === undefined ? {} : { durationMs: record.durationMs }),\n ...(record.startedAtMs === undefined ? {} : { startedAtMs: record.startedAtMs }),\n ...(record.startedSeq === undefined ? {} : { startedSeq: record.startedSeq }),\n ...(record.terminalAtMs === undefined ? {} : { terminalAtMs: record.terminalAtMs }),\n ...(record.terminal === undefined\n ? {}\n : { terminal: encodeCheckpointToolTerminal(record.terminal) }),\n});\n\nconst encodeCheckpointToolDecision = (\n decision: ToolDecision,\n): ReducedStateCheckpointToolDecision => {\n switch (decision._tag) {\n case \"Created\": {\n const { params: _params, promptPart: _promptPart, ...checkpoint } = decision;\n return checkpoint;\n }\n case \"Rejected\": {\n const { promptPart: _promptPart, ...checkpoint } = decision;\n return checkpoint;\n }\n default:\n return assertNever(decision, \"checkpoint tool decision\");\n }\n};\n\nconst encodeCheckpointToolTerminal = (\n terminal: ToolTerminal,\n): ReducedStateCheckpointToolTerminal => {\n switch (terminal._tag) {\n case \"Completed\": {\n const { result: _result, promptPart: _promptPart, ...checkpoint } = terminal;\n return checkpoint;\n }\n case \"Failed\": {\n const { error: _error, promptPart: _promptPart, ...checkpoint } = terminal;\n return checkpoint;\n }\n default:\n return assertNever(terminal, \"checkpoint tool terminal\");\n }\n};\n\nconst decodeCheckpointCommandRecords = (\n records: ReducedStateCheckpointPayload[\"commands\"],\n eventsBySeq: ReadonlyMap<number, CommittedDurableEvent>,\n): ReadonlyMap<CommandId, CommandRecord> =>\n new Map(\n records.map(([commandId, record]) => {\n if (record.admittedSeq === undefined) {\n return [commandId, record];\n }\n const admitted = reduceSingleCheckpointEvent(\n eventsBySeq,\n record.admittedSeq,\n commandAdmittedEventType,\n ).commands.get(commandId);\n if (admitted?.command === undefined) {\n throw new Error(`Checkpoint command ${commandId} missing admission payload`);\n }\n return [commandId, { ...record, command: admitted.command }];\n }),\n );\n\nconst decodeCheckpointMessageRecords = (\n records: ReducedStateCheckpointPayload[\"messages\"],\n eventsBySeq: ReadonlyMap<number, CommittedDurableEvent>,\n): ReadonlyMap<MessageId, MessageRecord> =>\n new Map(\n records.map(([messageId, record]) => {\n const message = reduceSingleCheckpointEvent(\n eventsBySeq,\n record.seq,\n checkpointMessageEventType(record),\n ).messages.get(messageId);\n if (message === undefined) {\n throw new Error(`Checkpoint message ${messageId} missing message payload`);\n }\n return [messageId, { ...message, ...record } as MessageRecord];\n }),\n );\n\nconst decodeCheckpointToolCallRecords = (\n records: ReducedStateCheckpointPayload[\"toolCalls\"],\n eventsBySeq: ReadonlyMap<number, CommittedDurableEvent>,\n): ReadonlyMap<ToolCallId, ToolCallRecord> =>\n new Map(\n records.map(([toolCallId, record]) => [\n toolCallId,\n {\n toolCallId,\n ...(record.decision === undefined\n ? {}\n : { decision: decodeCheckpointToolDecision(toolCallId, record.decision, eventsBySeq) }),\n ...(record.durationMs === undefined ? {} : { durationMs: record.durationMs }),\n ...(record.startedAtMs === undefined ? {} : { startedAtMs: record.startedAtMs }),\n ...(record.startedSeq === undefined ? {} : { startedSeq: record.startedSeq }),\n ...(record.terminalAtMs === undefined ? {} : { terminalAtMs: record.terminalAtMs }),\n ...(record.terminal === undefined\n ? {}\n : { terminal: decodeCheckpointToolTerminal(toolCallId, record.terminal, eventsBySeq) }),\n },\n ]),\n );\n\nconst decodeCheckpointToolDecision = (\n toolCallId: ToolCallId,\n decision: ReducedStateCheckpointToolDecision,\n eventsBySeq: ReadonlyMap<number, CommittedDurableEvent>,\n): ToolDecision => {\n const hydrated = reduceSingleCheckpointEvent(\n eventsBySeq,\n decision.seq,\n decision._tag === \"Created\" ? toolCallCreatedEventType : toolCallRejectedEventType,\n ).toolCalls.get(toolCallId)?.decision;\n if (hydrated === undefined || hydrated._tag !== decision._tag) {\n throw new Error(`Checkpoint tool decision ${toolCallId} missing ${decision._tag} payload`);\n }\n return hydrated;\n};\n\nconst decodeCheckpointToolTerminal = (\n toolCallId: ToolCallId,\n terminal: ReducedStateCheckpointToolTerminal,\n eventsBySeq: ReadonlyMap<number, CommittedDurableEvent>,\n): ToolTerminal => {\n const hydrated = reduceSingleCheckpointEvent(\n eventsBySeq,\n terminal.seq,\n terminal._tag === \"Completed\" ? toolCallCompletedEventType : toolCallFailedEventType,\n ).toolCalls.get(toolCallId)?.terminal;\n if (hydrated === undefined || hydrated._tag !== terminal._tag) {\n throw new Error(`Checkpoint tool terminal ${toolCallId} missing ${terminal._tag} payload`);\n }\n return hydrated;\n};\n\nconst checkpointMessageEventType = (record: ReducedStateCheckpointMessageRecord) => {\n switch (record._tag) {\n case \"System\":\n return systemMessageCommittedEventType;\n case \"User\":\n return record.requestedDisposition === undefined\n ? userMessageCommittedEventType\n : userMessageSubmittedEventType;\n case \"Steering\":\n return steeringMessageQueuedEventType;\n case \"Assistant\":\n return assistantMessageCommittedEventType;\n case \"AssistantPartial\":\n return assistantPartialCommittedEventType;\n default:\n return assertNever(record, \"checkpoint message type\");\n }\n};\n\nconst reduceSingleCheckpointEvent = (\n eventsBySeq: ReadonlyMap<number, CommittedDurableEvent>,\n seq: SequenceNumber,\n expectedType: string,\n): ReducedState => {\n const event = eventsBySeq.get(Number(seq));\n if (event === undefined) {\n throw new Error(`Checkpoint reference seq ${seq} is missing`);\n }\n if (event.event.type !== expectedType) {\n throw new Error(\n `Checkpoint reference seq ${seq} expected ${expectedType}; got ${event.event.type}`,\n );\n }\n return foldReducedState(initialReducedState, [event]);\n};\n\nconst committedEventMapBySeq = (\n events: ReadonlyArray<CommittedDurableEvent>,\n): ReadonlyMap<number, CommittedDurableEvent> =>\n new Map(events.map((event) => [Number(event.position.seq), event]));\n\nconst uniqueSequenceNumbers = (\n seqs: ReadonlyArray<SequenceNumber>,\n): ReadonlyArray<SequenceNumber> =>\n Array.from(new Set(seqs.map((seq) => Number(seq))))\n .sort((left, right) => left - right)\n .map((seq) => SequenceNumber.make(seq));\n\nconst decodeTokenConsumptionState = (\n value: TokenConsumptionState | undefined,\n): TokenConsumptionState => ({\n total: {\n inputTokens: nonNegativeNumber(value?.total?.inputTokens),\n cachedInputTokens: nonNegativeNumber(value?.total?.cachedInputTokens),\n outputTokens: nonNegativeNumber(value?.total?.outputTokens),\n textTokens: nonNegativeNumber(value?.total?.textTokens),\n reasoningTokens: nonNegativeNumber(value?.total?.reasoningTokens),\n },\n});\n\n/** Fold newly committed durable events into the canonical replay state. */\nexport const foldReducedState = (\n state: ReducedState,\n committed: ReadonlyArray<CommittedDurableEvent>,\n): ReducedState => {\n let lastSeq = state.lastSeq;\n const commands = new Map(state.commands);\n const runs = new Map(state.runs);\n const recoveryContinuations = new Map(state.recoveryContinuations);\n const turns = new Map(state.turns);\n const inferences = new Map(state.inferences);\n const toolCalls = new Map(state.toolCalls);\n const messages = new Map(state.messages);\n const stopRequests = new Map(state.stopRequests);\n const compactions = new Map(state.compactions);\n let context = state.context;\n let tokenConsumption = state.tokenConsumption;\n\n for (const entry of committed) {\n lastSeq = entry.position.seq;\n const { event } = entry;\n if (event.namespace !== effectDurableAgentNamespace) {\n continue;\n }\n\n const payload = event.payload as any;\n const seq = entry.position.seq;\n const eventCreatedAtMs = Number(event.createdAtMs);\n\n switch (event.type) {\n case commandAdmittedEventType: {\n const { command } = payload;\n const commandId = requireAdmittedCommandId(command);\n upsert(commands, commandId, { commandId }, (record) => ({\n ...record,\n admittedSeq: seq,\n admissionTrace: event.trace,\n command,\n }));\n break;\n }\n case commandStartedEventType: {\n const { commandId } = payload;\n upsert(commands, commandId, { commandId }, (record) => ({ ...record, startedSeq: seq }));\n break;\n }\n case commandCompletedEventType: {\n const { commandId } = payload;\n upsert(commands, commandId, { commandId }, (record) => ({\n ...record,\n terminal: { _tag: \"Completed\", seq } as CommandTerminal,\n }));\n break;\n }\n case commandFailedEventType: {\n const { commandId, error } = payload;\n upsert(commands, commandId, { commandId }, (record) => ({\n ...record,\n terminal: { _tag: \"Failed\", seq, error } as CommandTerminal,\n }));\n break;\n }\n case commandCancelledEventType: {\n const { commandId, reason } = payload;\n upsert(commands, commandId, { commandId }, (record) => ({\n ...record,\n terminal: { _tag: \"Cancelled\", seq, reason } as CommandTerminal,\n }));\n break;\n }\n case runStartedEventType: {\n const { runId, commandIds, trace } = payload;\n const terminal = runs.get(runId)?.terminal;\n runs.set(runId, {\n runId,\n commandIds,\n startedAtMs: eventCreatedAtMs,\n startedSeq: seq,\n trace,\n ...(terminal === undefined ? {} : { terminal }),\n });\n break;\n }\n case runCompletedEventType: {\n const { runId } = payload;\n updateExisting(runs, runId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: { _tag: \"Completed\", seq } as RunTerminal,\n }));\n break;\n }\n case runFailedEventType: {\n const { runId, error } = payload;\n updateExisting(runs, runId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: { _tag: \"Failed\", seq, error } as RunTerminal,\n }));\n break;\n }\n case runInterruptedEventType: {\n const { runId, reason } = payload;\n updateExisting(runs, runId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: { _tag: \"Interrupted\", seq, reason } as RunTerminal,\n }));\n break;\n }\n case turnStartedEventType: {\n const { runId, turnId, inputMessageIds } = payload;\n const terminal = turns.get(turnId)?.terminal;\n turns.set(turnId, {\n runId,\n turnId,\n startedAtMs: eventCreatedAtMs,\n startedSeq: seq,\n ...(terminal === undefined ? {} : { terminal }),\n });\n for (const messageId of inputMessageIds ?? []) {\n const message = messages.get(messageId);\n if (message?._tag === \"Steering\" || message?._tag === \"User\") {\n messages.set(messageId, { ...message, consumedSeq: seq, consumedTurnId: turnId });\n }\n }\n break;\n }\n case turnCompletedEventType: {\n const { turnId, usage } = payload;\n updateExisting(turns, turnId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: {\n _tag: \"Completed\",\n seq,\n ...(usage === undefined ? {} : { usage }),\n } as TurnTerminal,\n }));\n break;\n }\n case turnFailedEventType: {\n const { turnId, error } = payload;\n updateExisting(turns, turnId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: { _tag: \"Failed\", seq, error } as TurnTerminal,\n }));\n break;\n }\n case turnStoppedEventType: {\n const { turnId, reason } = payload;\n updateExisting(turns, turnId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: { _tag: \"Stopped\", seq, reason } as TurnTerminal,\n }));\n break;\n }\n case inferenceStartedEventType: {\n const { runId, turnId, inferenceId } = payload;\n const terminal = inferences.get(inferenceId)?.terminal;\n inferences.set(inferenceId, {\n runId,\n turnId,\n inferenceId: inferenceId,\n startedAtMs: eventCreatedAtMs,\n startedSeq: seq,\n ...(terminal === undefined ? {} : { terminal }),\n });\n break;\n }\n case inferenceCompletedEventType: {\n const { inferenceId, usage } = payload;\n const previouslyCompleted = inferences.get(inferenceId)?.terminal?._tag === \"Completed\";\n updateExisting(inferences, inferenceId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: {\n _tag: \"Completed\",\n seq,\n ...(usage === undefined ? {} : { usage }),\n } as InferenceTerminal,\n }));\n if (!previouslyCompleted && inferences.get(inferenceId)?.terminal?._tag === \"Completed\") {\n tokenConsumption = addTokenUsage(tokenConsumption, usage);\n }\n break;\n }\n case inferenceFailedEventType: {\n const { inferenceId, error } = payload;\n updateExisting(inferences, inferenceId, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: { _tag: \"Failed\", seq, error } as InferenceTerminal,\n }));\n break;\n }\n case toolCallCreatedEventType: {\n const { runId, turnId, inferenceId, toolCallId, promptPart } = payload;\n upsert(toolCalls, toolCallId, { toolCallId }, (record) => ({\n ...record,\n decision: {\n _tag: \"Created\",\n seq,\n runId,\n turnId,\n inferenceId: inferenceId,\n providerPartId: promptPart.id,\n toolName: promptPart.name,\n params: promptPart.params,\n providerExecuted: promptPart.providerExecuted,\n promptPart,\n } as ToolDecision,\n }));\n break;\n }\n case toolCallRejectedEventType: {\n const { runId, turnId, inferenceId, toolCallId, promptPart } = payload;\n upsert(toolCalls, toolCallId, { toolCallId }, (record) => ({\n ...record,\n decision: {\n _tag: \"Rejected\",\n seq,\n runId,\n turnId,\n inferenceId: inferenceId,\n providerPartId: promptPart.id,\n toolName: promptPart.name,\n reason: promptPart.result.reason,\n modelFeedback: promptPart.result.modelFeedback,\n promptPart,\n } as ToolDecision,\n }));\n break;\n }\n case toolCallStartedEventType: {\n const { toolCallId } = payload;\n upsert(toolCalls, toolCallId, { toolCallId }, (record) => ({\n ...record,\n startedAtMs: eventCreatedAtMs,\n startedSeq: seq,\n }));\n break;\n }\n case toolCallCompletedEventType: {\n const { toolCallId, promptPart } = payload;\n upsert(toolCalls, toolCallId, { toolCallId }, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: {\n _tag: \"Completed\",\n seq,\n result: promptPart.result,\n promptPart,\n } as ToolTerminal,\n }));\n break;\n }\n case toolCallFailedEventType: {\n const { toolCallId, promptPart, error } = payload;\n upsert(toolCalls, toolCallId, { toolCallId }, (record) => ({\n ...record,\n ...terminalTiming(record, eventCreatedAtMs),\n terminal: {\n _tag: \"Failed\",\n seq,\n error: error ?? promptPart.result,\n promptPart,\n } as ToolTerminal,\n }));\n break;\n }\n case systemMessageCommittedEventType: {\n const { messageId, content } = payload;\n messages.set(messageId, {\n _tag: \"System\",\n messageId,\n content,\n ...(Number.isFinite(eventCreatedAtMs) ? { createdAtMs: eventCreatedAtMs } : {}),\n seq,\n });\n break;\n }\n case userMessageCommittedEventType: {\n const { commandId, messageId, content } = payload;\n messages.set(messageId, {\n _tag: \"User\",\n messageId,\n commandId,\n content,\n ...(Number.isFinite(eventCreatedAtMs) ? { createdAtMs: eventCreatedAtMs } : {}),\n seq,\n });\n break;\n }\n case userMessageSubmittedEventType: {\n const { commandId, messageId, disposition: requestedDisposition, content } = payload;\n messages.set(messageId, {\n _tag: \"User\",\n messageId,\n commandId,\n content,\n requestedDisposition,\n disposition: requestedDisposition,\n ...(Number.isFinite(eventCreatedAtMs) ? { createdAtMs: eventCreatedAtMs } : {}),\n seq,\n });\n break;\n }\n case userMessagePromotedEventType: {\n const { messageId } = payload;\n const message = messages.get(messageId);\n if (\n (message?._tag === \"User\" && message.disposition === \"queue\") ||\n (message?._tag === \"Steering\" && message.pausedByCommandId !== undefined)\n ) {\n const {\n pausedByCommandId: _pausedByCommandId,\n pausedSeq: _pausedSeq,\n ...unpausedMessage\n } = message;\n messages.set(messageId, {\n ...unpausedMessage,\n ...(message._tag === \"User\" ? { disposition: \"steer\" as const } : {}),\n promotedSeq: seq,\n });\n }\n break;\n }\n case userMessageCancelledEventType: {\n const { commandId, messageId, reason } = payload;\n const message = messages.get(messageId);\n if (message?._tag === \"User\" || message?._tag === \"Steering\") {\n messages.set(messageId, {\n ...message,\n cancelledSeq: seq,\n cancelledByCommandId: commandId,\n cancellationReason: reason,\n });\n }\n break;\n }\n case messageQueuePausedEventType:\n case pendingMessagesPausedEventType: {\n const messageIds = payload.messageIds;\n const interruptionCommandId =\n event.type === messageQueuePausedEventType\n ? payload.stopCommandId\n : payload.interruptionCommandId;\n for (const messageId of messageIds) {\n const message = messages.get(messageId);\n if (\n (message?._tag === \"User\" || message?._tag === \"Steering\") &&\n message.consumedSeq === undefined &&\n message.cancelledSeq === undefined\n ) {\n messages.set(messageId, {\n ...message,\n ...(message._tag === \"User\" ? { disposition: \"queue\" as const } : {}),\n pausedSeq: seq,\n pausedByCommandId: interruptionCommandId,\n });\n }\n }\n break;\n }\n case steeringMessageQueuedEventType: {\n const { commandId, messageId, runId, content } = payload;\n messages.set(messageId, {\n _tag: \"Steering\",\n messageId,\n commandId,\n runId,\n content,\n ...(Number.isFinite(eventCreatedAtMs) ? { createdAtMs: eventCreatedAtMs } : {}),\n seq,\n });\n break;\n }\n case steeringMessageCancelledEventType: {\n const { messageId, reason } = payload;\n const message = messages.get(messageId);\n if (message?._tag === \"Steering\") {\n messages.set(messageId, { ...message, cancelledSeq: seq, cancellationReason: reason });\n }\n break;\n }\n case assistantMessageCommittedEventType: {\n const { messageId, runId, turnId, inferenceId, promptParts } = payload;\n messages.set(messageId, {\n _tag: \"Assistant\",\n messageId,\n runId,\n turnId,\n inferenceId: inferenceId,\n content: assistantContentFromPromptParts(promptParts),\n ...(Number.isFinite(eventCreatedAtMs) ? { createdAtMs: eventCreatedAtMs } : {}),\n promptParts,\n seq,\n });\n break;\n }\n case assistantPartialCommittedEventType: {\n const { messageId, runId, turnId, inferenceId, promptParts, reason } = payload;\n messages.set(messageId, {\n _tag: \"AssistantPartial\",\n messageId,\n runId,\n turnId,\n inferenceId: inferenceId,\n content: assistantContentFromPromptParts(promptParts),\n ...(Number.isFinite(eventCreatedAtMs) ? { createdAtMs: eventCreatedAtMs } : {}),\n promptParts,\n reason,\n seq,\n });\n break;\n }\n case stopTurnRequestedEventType: {\n const { commandId, runId, turnId } = payload;\n stopRequests.set(commandId, {\n commandId,\n requestedSeq: seq,\n ...(runId === undefined ? {} : { requestedRunId: runId }),\n ...(turnId === undefined ? {} : { requestedTurnId: turnId }),\n ...appliedFields(stopRequests.get(commandId)),\n });\n break;\n }\n case stopTurnAppliedEventType: {\n const { commandId, runId, turnId, inferenceId } = payload;\n const existing = stopRequests.get(commandId);\n stopRequests.set(commandId, {\n commandId,\n requestedSeq: existing?.requestedSeq ?? seq,\n ...(existing?.requestedRunId === undefined\n ? {}\n : { requestedRunId: existing.requestedRunId }),\n ...(existing?.requestedTurnId === undefined\n ? {}\n : { requestedTurnId: existing.requestedTurnId }),\n appliedSeq: seq,\n appliedRunId: runId,\n appliedTurnId: turnId,\n ...(inferenceId === undefined ? {} : { appliedInferenceId: inferenceId }),\n });\n break;\n }\n case contextProjectedEventType: {\n const { contextVersion } = payload;\n context = { ...context, version: contextVersion };\n break;\n }\n case compactionRequestedEventType: {\n const { compactionId, sourceFromSeq, sourceToSeq } = payload;\n upsert(compactions, compactionId, { compactionId }, (record) => ({\n ...record,\n requestedSeq: seq,\n sourceFromSeq,\n sourceToSeq,\n }));\n break;\n }\n case compactionStartedEventType: {\n const { compactionId } = payload;\n upsert(compactions, compactionId, { compactionId }, (record) => ({\n ...record,\n startedSeq: seq,\n }));\n break;\n }\n case summaryCreatedEventType: {\n const { compactionId, summaryId, sourceFromSeq, sourceToSeq } = payload;\n upsert(compactions, compactionId, { compactionId }, (record) => ({\n ...record,\n summaryCreatedSeq: seq,\n summaryId,\n sourceFromSeq,\n sourceToSeq,\n }));\n break;\n }\n case contextRebasedEventType: {\n const { compactionId, summaryId, contextVersion, retainedFromContextSeq } = payload;\n upsert(compactions, compactionId, { compactionId }, (record) => ({\n ...record,\n summaryId,\n rebasedSeq: seq,\n contextVersion,\n }));\n pruneForContextRebase(\n {\n commands,\n runs,\n recoveryContinuations,\n turns,\n inferences,\n toolCalls,\n messages,\n stopRequests,\n compactions,\n },\n retainedFromContextSeq,\n summaryId,\n );\n context = {\n version: contextVersion,\n currentSummaryId: summaryId,\n };\n break;\n }\n case compactionCompletedEventType: {\n const { compactionId } = payload;\n upsert(compactions, compactionId, { compactionId }, (record) => ({\n ...record,\n terminal: { _tag: \"Completed\", seq } as CompactionTerminal,\n }));\n break;\n }\n case compactionFailedEventType: {\n const { compactionId, error } = payload;\n upsert(compactions, compactionId, { compactionId }, (record) => ({\n ...record,\n terminal: { _tag: \"Failed\", seq, error } as CompactionTerminal,\n }));\n const failed = compactions.get(compactionId);\n if (failed?.summaryId === undefined || failed.summaryId !== context.currentSummaryId) {\n compactions.delete(compactionId);\n }\n break;\n }\n case recoveryCompletedEventType: {\n const { continuation } = payload;\n if (continuation !== undefined) {\n recoveryContinuations.set(continuation.replacementRunId, { ...continuation, seq });\n }\n break;\n }\n case baseStateRequestedEventType:\n case baseStateCreatedEventType:\n case baseStateFailedEventType:\n break;\n default:\n assertNever(event as never, \"reduced-state durable event\");\n }\n }\n\n return {\n lastSeq,\n commands,\n runs,\n recoveryContinuations,\n turns,\n inferences,\n toolCalls,\n messages,\n stopRequests,\n compactions,\n context,\n tokenConsumption,\n commandQueues: deriveCommandQueues({ commands, runs, messages }),\n };\n};\n\n/** Fold committed events from genesis into a fresh `ReducedState`. */\nexport const reduceCommittedEvents = (committed: ReadonlyArray<CommittedDurableEvent>) =>\n foldReducedState(initialReducedState, committed);\n\nconst addTokenUsage = (\n state: TokenConsumptionState,\n usage: UsagePayload | undefined,\n): TokenConsumptionState => {\n if (usage === undefined) {\n return state;\n }\n return {\n total: {\n inputTokens: state.total.inputTokens + tokenCount(usage.inputTokens),\n cachedInputTokens: state.total.cachedInputTokens + tokenCount(usage.cachedInputTokens),\n outputTokens: state.total.outputTokens + tokenCount(usage.outputTokens),\n textTokens: state.total.textTokens + tokenCount(usage.textTokens),\n reasoningTokens: state.total.reasoningTokens + tokenCount(usage.reasoningTokens),\n },\n };\n};\n\nconst tokenCount = (value: number | undefined): number => nonNegativeNumber(value);\n\nconst nonNegativeNumber = (value: number | undefined): number =>\n value === undefined || !Number.isFinite(value) ? 0 : Math.max(0, Math.trunc(value));\n\ninterface MutableReplayMaps {\n readonly commands: Map<CommandId, CommandRecord>;\n readonly runs: Map<RunId, RunRecord>;\n readonly recoveryContinuations: Map<RunId, RecoveryContinuationRecord>;\n readonly turns: Map<TurnId, TurnRecord>;\n readonly inferences: Map<InferenceId, InferenceRecord>;\n readonly toolCalls: Map<ToolCallId, ToolCallRecord>;\n readonly messages: Map<MessageId, MessageRecord>;\n readonly stopRequests: Map<CommandId, StopRequestRecord>;\n readonly compactions: Map<CompactionId, CompactionRecord>;\n}\n\n/** Drop runtime state made model-invisible by a context rebase; storage remains append-only. */\nconst pruneForContextRebase = (\n maps: MutableReplayMaps,\n retainedFromContextSeq: SequenceNumber,\n currentSummaryId: SummaryId,\n): void => {\n for (const [messageId, message] of maps.messages) {\n if (message._tag !== \"System\" && messagePruneSeq(message) < retainedFromContextSeq) {\n maps.messages.delete(messageId);\n }\n }\n\n for (const [toolCallId, tool] of maps.toolCalls) {\n const terminalSeq = tool.terminal?.seq;\n if (terminalSeq !== undefined && terminalSeq < retainedFromContextSeq) {\n maps.toolCalls.delete(toolCallId);\n }\n }\n\n for (const [inferenceId, inference] of maps.inferences) {\n if (inference.terminal !== undefined && inference.terminal.seq < retainedFromContextSeq) {\n maps.inferences.delete(inferenceId);\n }\n }\n\n for (const [turnId, turn] of maps.turns) {\n if (turn.terminal !== undefined && turn.terminal.seq < retainedFromContextSeq) {\n maps.turns.delete(turnId);\n }\n }\n\n for (const [runId, run] of maps.runs) {\n if (run.terminal !== undefined && run.terminal.seq < retainedFromContextSeq) {\n maps.runs.delete(runId);\n }\n }\n\n for (const replacementRunId of maps.recoveryContinuations.keys()) {\n if (!maps.runs.has(replacementRunId)) {\n maps.recoveryContinuations.delete(replacementRunId);\n }\n }\n\n for (const [commandId, command] of maps.commands) {\n if (command.terminal !== undefined && command.terminal.seq < retainedFromContextSeq) {\n maps.commands.delete(commandId);\n }\n }\n\n for (const [commandId, request] of maps.stopRequests) {\n if (request.appliedSeq !== undefined && request.appliedSeq < retainedFromContextSeq) {\n maps.stopRequests.delete(commandId);\n }\n }\n\n for (const [compactionId, compaction] of maps.compactions) {\n if (compaction.terminal !== undefined && compaction.summaryId !== currentSummaryId) {\n maps.compactions.delete(compactionId);\n }\n }\n};\n\nconst messagePruneSeq = (message: Exclude<MessageRecord, { readonly _tag: \"System\" }>): number => {\n if (message._tag === \"Steering\") {\n return message.consumedSeq ?? message.cancelledSeq ?? Number.POSITIVE_INFINITY;\n }\n return message.seq;\n};\n\n/** Pending admitted commands in deterministic scheduler order. */\nexport const pendingCommands = (state: ReducedState): ReadonlyArray<PendingCommand> =>\n state.commandQueues.pendingCommands;\n\n/** First pending StopTurn control command, when one is waiting. */\nexport const pendingStopCommand = (state: ReducedState): PendingCommand | undefined =>\n state.commandQueues.activeControlCommands.find((command) => command.command._tag === \"StopTurn\");\n\n/** Currently active command evidence, if any unfinished command is blocking FIFO work. */\nexport const activeCommand = (state: ReducedState): ActiveCommandEvidence | undefined =>\n state.commandQueues.active;\n\n/** Active run/turn/inference identity owned by a specific active command. */\nexport const activeTurnIdentityForCommand = (\n state: ReducedState,\n commandId: CommandId,\n): ActiveTurnIdentity | undefined => {\n const run = findLast(Array.from(state.runs.values()), (candidate): candidate is RunRecord =>\n candidate.commandIds.includes(commandId),\n );\n if (run === undefined) {\n return undefined;\n }\n\n const turn = findLast(\n Array.from(state.turns.values()),\n (candidate): candidate is TurnRecord => candidate.runId === run.runId,\n );\n if (turn === undefined) {\n return undefined;\n }\n\n const inference = findLast(\n Array.from(state.inferences.values()),\n (candidate): candidate is InferenceRecord =>\n candidate.runId === run.runId && candidate.turnId === turn.turnId,\n );\n\n return {\n runId: run.runId,\n turnId: turn.turnId,\n ...(inference === undefined ? {} : { inferenceId: inference.inferenceId }),\n };\n};\n\n/** Classify unfinished durable lifecycles that recovery may need to repair. */\nexport const classifyRecoverableWork = (state: ReducedState): RecoverableWork => {\n const activeCommands = Array.from(state.commands.values()).filter(\n (command) => command.startedSeq !== undefined && command.terminal === undefined,\n );\n const activeRuns = Array.from(state.runs.values()).filter((run) => run.terminal === undefined);\n const activeTurns = Array.from(state.turns.values()).filter(\n (turn) => turn.terminal === undefined,\n );\n const activeInferences = Array.from(state.inferences.values()).filter(\n (inference) => inference.terminal === undefined,\n );\n const openToolCalls = Array.from(state.toolCalls.values()).filter(\n (tool) =>\n tool.decision?._tag === \"Created\" &&\n !tool.decision.providerExecuted &&\n tool.terminal === undefined,\n );\n const runningToolCalls = openToolCalls.filter((tool) => tool.startedSeq !== undefined);\n const pendingStopRequests = Array.from(state.stopRequests.values()).filter(\n (request) =>\n request.appliedSeq === undefined &&\n state.commands.get(request.commandId)?.terminal === undefined,\n );\n const openCompactions = Array.from(state.compactions.values()).filter(\n (compaction) => compaction.terminal === undefined,\n );\n\n return {\n activeCommands,\n activeRuns,\n activeTurns,\n activeInferences,\n openToolCalls,\n runningToolCalls,\n pendingStopRequests,\n openCompactions,\n };\n};\n\nconst assistantContentFromPromptParts = (\n promptParts: ReadonlyArray<Prompt.AssistantMessagePart>,\n): AssistantMessageContent => {\n const text = promptParts\n .filter((part): part is Prompt.TextPart => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n const reasoning = promptParts\n .filter((part): part is Prompt.ReasoningPart => part.type === \"reasoning\")\n .map((part) => part.text)\n .join(\"\");\n return {\n text,\n ...(reasoning.length === 0 ? {} : { reasoning }),\n };\n};\n\nconst findLast = <A, B extends A>(\n items: ReadonlyArray<A>,\n predicate: (item: A) => item is B,\n): B | undefined => {\n for (let index = items.length - 1; index >= 0; index -= 1) {\n const item = items[index] as A;\n if (predicate(item)) {\n return item;\n }\n }\n return undefined;\n};\n\nconst requireAdmittedCommandId = (command: EDACommandValue): CommandId => {\n if (command.commandId !== undefined) {\n return command.commandId;\n }\n throw new Error(\"CommandAdmitted command is missing a framework commandId\");\n};\n\nconst terminalTiming = (\n record: Pick<LifecycleTiming, \"startedAtMs\">,\n terminalAtMs: number,\n): LifecycleTiming => ({\n terminalAtMs,\n ...(record.startedAtMs === undefined\n ? {}\n : { durationMs: Math.max(0, terminalAtMs - record.startedAtMs) }),\n});\n\nconst upsert = <K, V>(map: Map<K, V>, key: K, fallback: V, update: (record: V) => V) => {\n map.set(key, update(map.get(key) ?? fallback));\n};\n\nconst updateExisting = <K, V>(map: Map<K, V>, key: K, update: (record: V) => V) => {\n const record = map.get(key);\n if (record !== undefined) {\n map.set(key, update(record));\n }\n};\n\nconst appliedFields = (record: StopRequestRecord | undefined) =>\n record?.appliedSeq === undefined\n ? {}\n : {\n appliedSeq: record.appliedSeq,\n appliedRunId: record.appliedRunId,\n appliedTurnId: record.appliedTurnId,\n ...(record.appliedInferenceId === undefined\n ? {}\n : { appliedInferenceId: record.appliedInferenceId }),\n };\n"],"mappings":";;;;AAAA,MAAM,oBAAoB,UAAyB;CACjD,IAAI;EACF,OAAO,KAAK,UAAU,KAAK;CAC7B,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF;;AAGA,MAAa,oBAAoB,OAAc,4BAC7C,IAAI,MAAM,aAAa,QAAQ,IAAI,iBAAiB,KAAK,GAAG;;AAG9D,MAAa,eAAe,OAAc,YAA2B;CACnE,MAAM,iBAAiB,OAAO,OAAO;AACvC;;AC4XA,MAAa,sBAAoC;CAC/C,SAAS,eAAe,KAAK,CAAC;CAC9B,0BAAU,IAAI,IAAI;CAClB,sBAAM,IAAI,IAAI;CACd,uCAAuB,IAAI,IAAI;CAC/B,uBAAO,IAAI,IAAI;CACf,4BAAY,IAAI,IAAI;CACpB,2BAAW,IAAI,IAAI;CACnB,0BAAU,IAAI,IAAI;CAClB,8B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Event } from "./session-store-D2Ore1QC.js";
2
+ import * as Context from "effect/Context";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Schema from "effect/Schema";
5
+
6
+ //#region src/services/reducer-registry.d.ts
7
+ /** App-specific pure reducer over the durable session event log. */
8
+ interface EDAReducer<State = unknown, Name extends string = string> {
9
+ readonly name: Name;
10
+ readonly initial: State;
11
+ readonly stateSchema: Schema.Codec<State, unknown, never, never>;
12
+ readonly schemaVersion?: number;
13
+ readonly encode?: (state: State) => unknown;
14
+ readonly decode?: (payload: unknown) => State;
15
+ reduce(state: State, event: CommittedDurableEvent): State;
16
+ }
17
+ /** Convenience constructor preserving a reducer's literal name and schema-derived state type. */
18
+ declare const EDAReducer: {
19
+ make: <State, const Name extends string = string>(reducer: EDAReducer<State, Name>) => EDAReducer<State, Name>;
20
+ };
21
+ /** Snapshot of all app reducer states, keyed by reducer name. */
22
+ type EDAReducerStateSnapshot = ReadonlyMap<string, unknown>;
23
+ interface EDASerializedReducerState {
24
+ readonly name: string;
25
+ readonly state: unknown;
26
+ }
27
+ type EDAReducerStateForName<Entry extends EDASerializedReducerState, Name extends Entry["name"]> = Extract<Entry, {
28
+ readonly name: Name;
29
+ }>["state"];
30
+ /** Exact reducer object required for every member of a serialized state union. */
31
+ type EDAReducersFor<Entry extends EDASerializedReducerState> = { readonly [Name in Entry["name"]]: EDAReducer<EDAReducerStateForName<Entry, Name>, Name> };
32
+ /** Schema-backed app reducer registry used by both runtime folding and snapshot serialization. */
33
+ interface EDATypedReducerRegistry<EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>> {
34
+ readonly entrySchema: EntrySchema;
35
+ readonly reducers: ReadonlyArray<EDAReducer>;
36
+ readonly serialize: (snapshot: EDAReducerStateSnapshot) => ReadonlyArray<EntrySchema["Type"]>;
37
+ }
38
+ /**
39
+ * Register an app's complete reducer set against its public serialized-state union.
40
+ *
41
+ * Missing reducers, extra reducers, reducer-name drift, and state-schema drift are
42
+ * rejected by TypeScript at the registration site.
43
+ */
44
+ declare const defineEDAReducerRegistry: <EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>>(entrySchema: EntrySchema, reducers: EDAReducersFor<EntrySchema["Type"]>) => EDATypedReducerRegistry<EntrySchema>;
45
+ /** Registry that folds app-specific read-model state beside EDA reduced state. */
46
+ interface EDAReducerRegistryShape {
47
+ readonly reducers: ReadonlyArray<EDAReducer>;
48
+ readonly initial: EDAReducerStateSnapshot;
49
+ readonly reduce: (state: EDAReducerStateSnapshot, events: ReadonlyArray<CommittedDurableEvent>) => EDAReducerStateSnapshot;
50
+ }
51
+ /** Prefix reserved for framework-owned reducer checkpoints. */
52
+ declare const edaReservedReducerNamePrefix = "_eda.";
53
+ /** Return the persisted schema version for one reducer. */
54
+ declare const reducerSchemaVersion: (reducer: EDAReducer) => number;
55
+ /** Encode one reducer state for durable checkpoint storage. */
56
+ declare const encodeReducerState: <State, Name extends string>(reducer: EDAReducer<State, Name>, state: State) => unknown;
57
+ /** Decode one reducer state from durable checkpoint storage. */
58
+ declare const decodeReducerState: <State, Name extends string>(reducer: EDAReducer<State, Name>, payload: unknown) => State;
59
+ declare const EDAReducerRegistry_base: Context.ServiceClass<EDAReducerRegistry, "@effect-durable-agent/EDAReducerRegistry", EDAReducerRegistryShape>;
60
+ /** Registry for app-specific durable metadata reducers. */
61
+ declare class EDAReducerRegistry extends EDAReducerRegistry_base {
62
+ static readonly Empty: Layer.Layer<EDAReducerRegistry, never, never>;
63
+ static readonly Live: (reducers: ReadonlyArray<EDAReducer>) => Layer.Layer<EDAReducerRegistry, never, never>;
64
+ }
65
+ /** Read one typed reducer state from a snapshot. */
66
+ declare const getEDAReducerState: <State, Name extends string>(snapshot: EDAReducerStateSnapshot, reducer: EDAReducer<State, Name>) => State;
67
+ //#endregion
68
+ export { EDAReducersFor as a, defineEDAReducerRegistry as c, getEDAReducerState as d, reducerSchemaVersion as f, EDAReducerStateSnapshot as i, edaReservedReducerNamePrefix as l, EDAReducerRegistry as n, EDATypedReducerRegistry as o, EDAReducerRegistryShape as r, decodeReducerState as s, EDAReducer as t, encodeReducerState as u };
69
+ //# sourceMappingURL=reducer-registry-C0svUa63.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { m as SequenceNumber, n as CommandId } from "./core-Hv3cFydL.js";
2
+ import { r as EDACommand } from "./commands-Ce1ec6kH.js";
3
+ import { S as CommandFailedEvent, _ as CommandCancelledEvent, y as CommandCompletedEvent } from "./durable-DlScwmCy.js";
4
+ import { t as CommittedDurableEvent } from "./session-store-D2Ore1QC.js";
5
+ import { a as SessionCommandAdmissionError, i as EDASubmittable, n as EDASessionQueryShape, o as SessionState, t as EDASessionQuery } from "./session-query-DlRo5Ufc.js";
6
+ import * as Context from "effect/Context";
7
+ import * as Effect from "effect/Effect";
8
+ import * as Layer from "effect/Layer";
9
+ import * as Schema from "effect/Schema";
10
+
11
+ //#region src/services/runtime.d.ts
12
+ /** Configuration for one scoped session runtime instance. */
13
+ declare const EDARuntimeConfig: Schema.Struct<{
14
+ readonly modelSelection: Schema.Struct<{
15
+ readonly provider: Schema.NonEmptyString;
16
+ readonly modelId: Schema.NonEmptyString;
17
+ readonly settings: Schema.optionalKey<Schema.Unknown>;
18
+ }>; /** Maximum framework-owned tool calls one model run may execute before failing safely. */
19
+ readonly maxToolCallsPerRun: Schema.optionalKey<Schema.Int>;
20
+ readonly systemPrompt: Schema.optionalKey<Schema.NonEmptyString>;
21
+ }>;
22
+ type EDARuntimeConfig = typeof EDARuntimeConfig.Type;
23
+ /** Public runtime error surface for command admission helpers. */
24
+ type EDARuntimeError = SessionCommandAdmissionError;
25
+ /** Command terminal events observed by blocking runtime helpers. */
26
+ type EDACommandTerminalEvent = CommandCompletedEvent | CommandFailedEvent | CommandCancelledEvent;
27
+ /** Committed durable event narrowed to a command terminal boundary. */
28
+ type CommittedCommandTerminalEvent = CommittedDurableEvent & {
29
+ readonly event: EDACommandTerminalEvent;
30
+ };
31
+ /** Overloaded public submit API for single commands or ordered durable batches. */
32
+ interface EDARuntimeSubmit {
33
+ /** Submit one command and return its committed CommandAdmitted event. */
34
+ (command: EDACommand): Effect.Effect<CommittedDurableEvent, EDARuntimeError>;
35
+ /** Submit one ordered durable batch of commands and/or app events. */
36
+ (input: ReadonlyArray<EDASubmittable>): Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDARuntimeError>;
37
+ }
38
+ /** Public facade exposed to hosts and route handlers for one live session runtime. */
39
+ interface EDARuntimeShape {
40
+ /** Submit commands and/or app durable events durably and wake the dispatch process if needed. */
41
+ readonly submit: EDARuntimeSubmit;
42
+ /** Block until the command reaches CommandCompleted, CommandFailed, or CommandCancelled. */
43
+ readonly blockOnCommand: (commandId: CommandId, afterSeq?: SequenceNumber) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;
44
+ /** Admit one command and block until that command reaches a terminal command boundary. */
45
+ readonly submitAndBlock: (command: EDACommand) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;
46
+ /** Read the authoritative live session snapshot. */
47
+ readonly snapshot: EDASessionQueryShape["snapshot"];
48
+ /** Read durable user/assistant messages in committed order. */
49
+ readonly messages: EDASessionQueryShape["messages"];
50
+ /** Backfill durable events after a committed sequence, then follow live events. */
51
+ readonly eventsAfter: EDASessionQueryShape["eventsAfter"];
52
+ }
53
+ declare const EDARuntime_base: Context.ServiceClass<EDARuntime, "@effect-durable-agent/EDARuntime", EDARuntimeShape>;
54
+ /** Top-level public facade for one effect-durable-agent session runtime. */
55
+ declare class EDARuntime extends EDARuntime_base {
56
+ static readonly Live: (config: EDARuntimeConfig) => Layer.Layer<EDARuntime, SessionCommandAdmissionError, EDASessionQuery | SessionState>;
57
+ }
58
+ //#endregion
59
+ export { EDARuntimeError as a, EDARuntimeConfig as i, EDACommandTerminalEvent as n, EDARuntimeShape as o, EDARuntime as r, EDARuntimeSubmit as s, CommittedCommandTerminalEvent as t };
60
+ //# sourceMappingURL=runtime-C56FQxiL.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { _ as defaultCompactionRetainTailTokens, a as CompactionExecutorShape, c as CompactionPolicy, d as CompactionRunner, f as CompactionRunnerInput, g as defaultCompactionMinSummarizableTokens, h as defaultCompactionCharsPerToken, i as CompactionExecutorInput, l as CompactionPolicyInput, m as LanguageModelSummaryCompactionExecutorOptions, n as CompactionError, o as CompactionOutput, p as CompactionRunnerShape, r as CompactionExecutor, s as CompactionPlan, t as ApproximateTokenThresholdCompactionPolicyOptions, u as CompactionPolicyShape, v as defaultCompactionThresholdTokens } from "../compaction-YayFKo_1.js";
2
+ export { ApproximateTokenThresholdCompactionPolicyOptions, CompactionError, CompactionExecutor, CompactionExecutorInput, CompactionExecutorShape, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionPolicyInput, CompactionPolicyShape, CompactionRunner, CompactionRunnerInput, CompactionRunnerShape, LanguageModelSummaryCompactionExecutorOptions, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionThresholdTokens };