effect-durable-agent 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{compaction-D7WJa899.js → compaction-Dlq4wgZE.js} +12 -9
- package/dist/compaction-Dlq4wgZE.js.map +1 -0
- package/dist/{delivery-GCO7QmXQ.d.ts → delivery-BKYmgnKC.d.ts} +2 -2
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/message-transcript.js +15 -7
- package/dist/domain/message-transcript.js.map +1 -1
- package/dist/domain/reduced-state.d.ts +2 -2
- package/dist/domain/reduced-state.js +21 -5
- package/dist/domain/reduced-state.js.map +1 -1
- package/dist/domain/run-scheduling.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{reduced-state-BGI8EJN5.d.ts → reduced-state-DV0696_s.d.ts} +16 -4
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/compaction.js +1 -1
- package/dist/services/decider.d.ts +1 -1
- package/dist/services/decider.js +1 -1
- package/dist/services/model-call.d.ts +1 -1
- package/dist/services/prompt-projector.d.ts +1 -1
- package/dist/services/run-scheduler.d.ts +1 -1
- package/dist/services/runtime-layer.d.ts +1 -1
- package/dist/services/runtime-layer.js +4 -4
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +1 -1
- package/dist/services/session-query.d.ts +1 -1
- package/dist/services/session-query.js +1 -1
- package/dist/services/session-state.d.ts +1 -1
- package/dist/services/session-state.js +2 -2
- package/dist/services/session-store.js +1 -1
- package/dist/services/sink-registry.d.ts +1 -1
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/{session-admission-WE8J_0z9.js → session-admission-DC98zwtj.js} +1 -2
- package/dist/session-admission-DC98zwtj.js.map +1 -0
- package/dist/{session-state-OY3Wih8X.js → session-state-BbJW2_P0.js} +8 -19
- package/dist/session-state-BbJW2_P0.js.map +1 -0
- package/dist/{sink-registry-AOjX5_A1.js → sink-registry-CjdKeTUM.js} +2 -2
- package/dist/{sink-registry-AOjX5_A1.js.map → sink-registry-CjdKeTUM.js.map} +1 -1
- package/dist/testkit/layers.d.ts +1 -1
- package/dist/testkit/layers.js +4 -4
- package/dist/websocket/events.d.ts +1 -1
- package/dist/websocket.d.ts +1 -1
- package/package.json +1 -1
- package/dist/compaction-D7WJa899.js.map +0 -1
- package/dist/session-admission-WE8J_0z9.js.map +0 -1
- package/dist/session-state-OY3Wih8X.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduced-state.js","names":[],"sources":["../../src/domain/reduced-state.ts"],"sourcesContent":["import { ReducedStateSchema } from \"./reduced-state-schema\";\nimport { RunSchedulingRequest, RunSchedulingRequestRecord } from \"./run-scheduling\";\nimport { interpretLegacyAttemptForReduction } from \"../types/events/durable\";\nimport * as Schema from \"effect/Schema\";\nimport type * as Prompt from \"effect/ai/Prompt\";\nimport { addModelUsage, TokenConsumptionState } from \"./model-usage\";\nexport { type TokenUsageTotals, TokenConsumptionState } from \"./model-usage\";\n\nimport { assertNever } from \"./assert-never\";\nimport { deriveCommandQueues, emptyCommandQueues } 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 assistantMessageImportedEventType,\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 runSchedulingRequestedEventType,\n runSchedulingDeliveredEventType,\n runSchedulingInvalidatedEventType,\n runSchedulingGrantedEventType,\n sessionConfiguredEventType,\n deciderAcceptedEventType,\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 ModelSelectionPayload,\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 modelSelection?: ModelSelectionPayload;\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 /** First start; `startedAtMs` is its time. Later attempts keep both. */\n readonly startedSeq?: SequenceNumber;\n /** Latest execution attempt (1 when only the first start is recorded). */\n readonly attempt?: number;\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 /** True when the assistant message originated outside this EDA session. */\n readonly imported?: true;\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/** 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 type ReducedState = typeof ReducedStateSchema.Type;\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 emptyTokenConsumptionState: TokenConsumptionState = {\n byModel: [],\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 = 7;\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 runSchedulingRequest?: RunSchedulingRequestRecord;\n readonly modelSelection?: ModelSelectionPayload;\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 ...(state.runSchedulingRequest === undefined\n ? {}\n : { runSchedulingRequest: state.runSchedulingRequest }),\n ...(state.modelSelection === undefined ? {} : { modelSelection: state.modelSelection }),\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 ...(checkpoint.runSchedulingRequest === undefined\n ? {}\n : {\n runSchedulingRequest: Schema.decodeUnknownSync(RunSchedulingRequestRecord)(\n checkpoint.runSchedulingRequest,\n ),\n }),\n ...(checkpoint.modelSelection === undefined\n ? {}\n : { modelSelection: checkpoint.modelSelection }),\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.attempt === undefined ? {} : { attempt: record.attempt }),\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.attempt === undefined ? {} : { attempt: record.attempt }),\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 record.imported === true\n ? assistantMessageImportedEventType\n : 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 => value ?? emptyTokenConsumptionState;\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 let runSchedulingRequest = state.runSchedulingRequest;\n let modelSelection = state.modelSelection;\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 if (entry.event.namespace !== effectDurableAgentNamespace) {\n continue;\n }\n\n const event = interpretLegacyAttemptForReduction(entry.event);\n const seq = entry.position.seq;\n const eventCreatedAtMs = Number(event.createdAtMs);\n\n switch (event.type) {\n case runSchedulingRequestedEventType:\n runSchedulingRequest = Schema.decodeUnknownSync(RunSchedulingRequestRecord)({\n ...Schema.decodeUnknownSync(RunSchedulingRequest)(event.payload),\n requestedSeq: seq,\n });\n break;\n case runSchedulingDeliveredEventType:\n if (\n runSchedulingRequest !== undefined &&\n runSchedulingRequest.requestId === event.payload.requestId\n ) {\n runSchedulingRequest = { ...runSchedulingRequest, deliveredSeq: seq };\n }\n break;\n case runSchedulingInvalidatedEventType:\n case runSchedulingGrantedEventType:\n if (runSchedulingRequest?.requestId === event.payload.requestId)\n runSchedulingRequest = undefined;\n break;\n case commandAdmittedEventType: {\n const { command } = event.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 } = event.payload;\n upsert(commands, commandId, { commandId }, (record) => ({ ...record, startedSeq: seq }));\n break;\n }\n case commandCompletedEventType: {\n const { commandId } = event.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 } = event.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 } = event.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 } = event.payload;\n modelSelection ??= event.payload.modelSelection;\n const terminal = runs.get(runId)?.terminal;\n runs.set(runId, {\n runId,\n commandIds,\n startedAtMs: eventCreatedAtMs,\n startedSeq: seq,\n trace,\n modelSelection: event.payload.modelSelection,\n ...(terminal === undefined ? {} : { terminal }),\n });\n break;\n }\n case runCompletedEventType: {\n const { runId } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 const model = runs.get(event.payload.runId)?.modelSelection;\n if (model !== undefined) tokenConsumption = addModelUsage(tokenConsumption, model, usage);\n }\n break;\n }\n case inferenceFailedEventType: {\n const { inferenceId, error } = event.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 } = event.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 } = event.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, attempt } = event.payload;\n upsert(toolCalls, toolCallId, { toolCallId }, (record) =>\n attempt === undefined\n ? { ...record, startedAtMs: eventCreatedAtMs, startedSeq: seq }\n : {\n ...record,\n ...(record.startedSeq === undefined\n ? { startedAtMs: eventCreatedAtMs, startedSeq: seq }\n : {}),\n attempt,\n },\n );\n break;\n }\n case toolCallCompletedEventType: {\n const { toolCallId, promptPart } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 = event.payload.messageIds;\n const interruptionCommandId =\n event.type === messageQueuePausedEventType\n ? event.payload.stopCommandId\n : event.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 } = event.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 } = event.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 } = event.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 assistantMessageImportedEventType: {\n const { messageId, runId, turnId, inferenceId, promptParts } = event.payload;\n messages.set(messageId, {\n _tag: \"Assistant\",\n messageId,\n runId,\n turnId,\n inferenceId,\n imported: true,\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 } = event.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 } = event.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 } = event.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 } = event.payload;\n context = { ...context, version: contextVersion };\n break;\n }\n case compactionRequestedEventType: {\n const { compactionId, sourceFromSeq, sourceToSeq } = event.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 } = event.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 } = event.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 } = event.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 } = event.payload;\n if (\n compactions.get(compactionId)?.terminal?._tag !== \"Completed\" &&\n event.payload.modelSelection !== undefined\n ) {\n tokenConsumption = addModelUsage(\n tokenConsumption,\n event.payload.modelSelection,\n event.payload.usage,\n );\n }\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 } = event.payload;\n if (event.payload.modelSelection !== undefined) {\n tokenConsumption = addModelUsage(\n tokenConsumption,\n event.payload.modelSelection,\n event.payload.usage,\n );\n }\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 } = event.payload;\n if (continuation !== undefined) {\n recoveryContinuations.set(continuation.replacementRunId, { ...continuation, seq });\n }\n break;\n }\n case sessionConfiguredEventType:\n modelSelection ??= event.payload.modelSelection;\n break;\n case deciderAcceptedEventType:\n // A decider's acceptance marker: its items carry the state change.\n break;\n case baseStateRequestedEventType:\n case baseStateCreatedEventType:\n case baseStateFailedEventType:\n break;\n default:\n assertNever(event, \"reduced-state durable event\");\n }\n }\n\n return {\n lastSeq,\n ...(runSchedulingRequest === undefined ? {} : { runSchedulingRequest }),\n ...(modelSelection === undefined ? {} : { modelSelection }),\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\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) =>\n command.startedSeq !== undefined &&\n command.terminal === undefined &&\n command.commandId !== state.runSchedulingRequest?.work.commandId,\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":";;;;;;;;;AAmXA,MAAM,6BAAoD,EACxD,SAAS,CAAC,EACZ;;AAGA,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,8BAAc,IAAI,IAAI;CACtB,6BAAa,IAAI,IAAI;CACrB,SAAS,EAAE,SAAS,eAAe,K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CAAC;AAE/B;AAEA,MAAM,iBAAiB,WACrB,QAAQ,eAAe,KAAA,IACnB,CAAC,IACD;CACE,YAAY,OAAO;CACnB,cAAc,OAAO;CACrB,eAAe,OAAO;CACtB,GAAI,OAAO,uBAAuB,KAAA,IAC9B,CAAC,IACD,EAAE,oBAAoB,OAAO,mBAAmB;AACtD"}
|
|
1
|
+
{"version":3,"file":"reduced-state.js","names":[],"sources":["../../src/domain/reduced-state.ts"],"sourcesContent":["import { ReducedStateSchema } from \"./reduced-state-schema\";\nimport { RunSchedulingRequest, RunSchedulingRequestRecord } from \"./run-scheduling\";\nimport { interpretLegacyAttemptForReduction } from \"../types/events/durable\";\nimport * as Schema from \"effect/Schema\";\nimport type * as Prompt from \"effect/ai/Prompt\";\nimport { addModelUsage, TokenConsumptionState } from \"./model-usage\";\nexport { type TokenUsageTotals, TokenConsumptionState } from \"./model-usage\";\n\nimport { assertNever } from \"./assert-never\";\nimport { deriveCommandQueues, emptyCommandQueues } 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 assistantMessageImportedEventType,\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 runSchedulingRequestedEventType,\n runSchedulingDeliveredEventType,\n runSchedulingInvalidatedEventType,\n runSchedulingGrantedEventType,\n sessionConfiguredEventType,\n deciderAcceptedEventType,\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 ModelSelectionPayload,\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 modelSelection?: ModelSelectionPayload;\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 /** First start; `startedAtMs` is its time. Later attempts keep both. */\n readonly startedSeq?: SequenceNumber;\n /** Latest execution attempt (1 when only the first start is recorded). */\n readonly attempt?: number;\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 /** True when the assistant message originated outside this EDA session. */\n readonly imported?: true;\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/** 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 type ReducedState = typeof ReducedStateSchema.Type;\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 emptyTokenConsumptionState: TokenConsumptionState = {\n byModel: [],\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 = 8;\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 runSchedulingRequest?: RunSchedulingRequestRecord;\n readonly modelSelection?: ModelSelectionPayload;\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 ...(state.runSchedulingRequest === undefined\n ? {}\n : { runSchedulingRequest: state.runSchedulingRequest }),\n ...(state.modelSelection === undefined ? {} : { modelSelection: state.modelSelection }),\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 ...(checkpoint.runSchedulingRequest === undefined\n ? {}\n : {\n runSchedulingRequest: Schema.decodeUnknownSync(RunSchedulingRequestRecord)(\n checkpoint.runSchedulingRequest,\n ),\n }),\n ...(checkpoint.modelSelection === undefined\n ? {}\n : { modelSelection: checkpoint.modelSelection }),\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.attempt === undefined ? {} : { attempt: record.attempt }),\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.attempt === undefined ? {} : { attempt: record.attempt }),\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 record.imported === true\n ? assistantMessageImportedEventType\n : 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 => value ?? emptyTokenConsumptionState;\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 let runSchedulingRequest = state.runSchedulingRequest;\n let modelSelection = state.modelSelection;\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 if (entry.event.namespace !== effectDurableAgentNamespace) {\n continue;\n }\n\n const event = interpretLegacyAttemptForReduction(entry.event);\n const seq = entry.position.seq;\n const eventCreatedAtMs = Number(event.createdAtMs);\n\n switch (event.type) {\n case runSchedulingRequestedEventType:\n runSchedulingRequest = Schema.decodeUnknownSync(RunSchedulingRequestRecord)({\n ...Schema.decodeUnknownSync(RunSchedulingRequest)(event.payload),\n requestedSeq: seq,\n });\n break;\n case runSchedulingDeliveredEventType:\n if (\n runSchedulingRequest !== undefined &&\n runSchedulingRequest.requestId === event.payload.requestId\n ) {\n runSchedulingRequest = { ...runSchedulingRequest, deliveredSeq: seq };\n }\n break;\n case runSchedulingInvalidatedEventType:\n case runSchedulingGrantedEventType:\n if (runSchedulingRequest?.requestId === event.payload.requestId)\n runSchedulingRequest = undefined;\n break;\n case commandAdmittedEventType: {\n const { command } = event.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 } = event.payload;\n upsert(commands, commandId, { commandId }, (record) => ({ ...record, startedSeq: seq }));\n break;\n }\n case commandCompletedEventType: {\n const { commandId } = event.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 } = event.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 } = event.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 } = event.payload;\n modelSelection ??= event.payload.modelSelection;\n const terminal = runs.get(runId)?.terminal;\n runs.set(runId, {\n runId,\n commandIds,\n startedAtMs: eventCreatedAtMs,\n startedSeq: seq,\n trace,\n modelSelection: event.payload.modelSelection,\n ...(terminal === undefined ? {} : { terminal }),\n });\n break;\n }\n case runCompletedEventType: {\n const { runId } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 } = event.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 const model = runs.get(event.payload.runId)?.modelSelection;\n if (model !== undefined) tokenConsumption = addModelUsage(tokenConsumption, model, usage);\n }\n break;\n }\n case inferenceFailedEventType: {\n const { inferenceId, error } = event.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 } = event.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 } = event.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, attempt } = event.payload;\n upsert(toolCalls, toolCallId, { toolCallId }, (record) =>\n attempt === undefined\n ? { ...record, startedAtMs: eventCreatedAtMs, startedSeq: seq }\n : {\n ...record,\n ...(record.startedSeq === undefined\n ? { startedAtMs: eventCreatedAtMs, startedSeq: seq }\n : {}),\n attempt,\n },\n );\n break;\n }\n case toolCallCompletedEventType: {\n const { toolCallId, promptPart } = event.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 } = event.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 } = event.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 } = event.payload;\n // Up to 0.2.2 a rebase pruned a pending submission, and its command then committed the\n // same content under a new message id at run start. That commit replaces the submission,\n // which would otherwise stay pending forever. A current runtime commits a user message\n // only for a command with no submission, so this matches only those logs.\n for (const [submittedId, submitted] of messages) {\n if (\n submitted._tag === \"User\" &&\n submitted.commandId === commandId &&\n submittedId !== messageId &&\n submitted.requestedDisposition !== undefined &&\n submitted.consumedSeq === undefined\n ) {\n messages.delete(submittedId);\n }\n }\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 } = event.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 } = event.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 } = event.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 = event.payload.messageIds;\n const interruptionCommandId =\n event.type === messageQueuePausedEventType\n ? event.payload.stopCommandId\n : event.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 } = event.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 } = event.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 } = event.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 assistantMessageImportedEventType: {\n const { messageId, runId, turnId, inferenceId, promptParts } = event.payload;\n messages.set(messageId, {\n _tag: \"Assistant\",\n messageId,\n runId,\n turnId,\n inferenceId,\n imported: true,\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 } = event.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 } = event.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 } = event.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 } = event.payload;\n context = { ...context, version: contextVersion };\n break;\n }\n case compactionRequestedEventType: {\n const { compactionId, sourceFromSeq, sourceToSeq } = event.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 } = event.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 } = event.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 } = event.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 } = event.payload;\n if (\n compactions.get(compactionId)?.terminal?._tag !== \"Completed\" &&\n event.payload.modelSelection !== undefined\n ) {\n tokenConsumption = addModelUsage(\n tokenConsumption,\n event.payload.modelSelection,\n event.payload.usage,\n );\n }\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 } = event.payload;\n if (event.payload.modelSelection !== undefined) {\n tokenConsumption = addModelUsage(\n tokenConsumption,\n event.payload.modelSelection,\n event.payload.usage,\n );\n }\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 } = event.payload;\n if (continuation !== undefined) {\n recoveryContinuations.set(continuation.replacementRunId, { ...continuation, seq });\n }\n break;\n }\n case sessionConfiguredEventType:\n modelSelection ??= event.payload.modelSelection;\n break;\n case deciderAcceptedEventType:\n // A decider's acceptance marker: its items carry the state change.\n break;\n case baseStateRequestedEventType:\n case baseStateCreatedEventType:\n case baseStateFailedEventType:\n break;\n default:\n assertNever(event, \"reduced-state durable event\");\n }\n }\n\n return {\n lastSeq,\n ...(runSchedulingRequest === undefined ? {} : { runSchedulingRequest }),\n ...(modelSelection === undefined ? {} : { modelSelection }),\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\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\n/**\n * Sequence at which a message entered the model's context, or `undefined` while it has not.\n *\n * An admitted message (one with a submission disposition) enters context when a turn consumes\n * it, not when it is submitted: it can wait queued, paused or steering past any number of\n * responses. A legacy committed user message entered at its own commit. Rebase pruning,\n * compaction planning and the prompt projection all read this one definition, so a message the\n * prompt has not shown the model is never summarised and never pruned.\n */\nexport const messageContextSeq = (\n message: Exclude<MessageRecord, { readonly _tag: \"System\" }>,\n): SequenceNumber | undefined => {\n switch (message._tag) {\n case \"Assistant\":\n case \"AssistantPartial\":\n return message.seq;\n case \"Steering\":\n return message.consumedSeq;\n case \"User\":\n return (\n message.consumedSeq ??\n (message.requestedDisposition === undefined ? message.seq : undefined)\n );\n }\n};\n\n/** A message leaves reduced state once it has left context, or once it is cancelled unconsumed. */\nconst messagePruneSeq = (message: Exclude<MessageRecord, { readonly _tag: \"System\" }>): number =>\n messageContextSeq(message) ??\n (message._tag === \"User\" || message._tag === \"Steering\" ? message.cancelledSeq : undefined) ??\n Number.POSITIVE_INFINITY;\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) =>\n command.startedSeq !== undefined &&\n command.terminal === undefined &&\n command.commandId !== state.runSchedulingRequest?.work.commandId,\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":";;;;;;;;;AAmXA,MAAM,6BAAoD,EACxD,SAAS,CAAC,EACZ;;AAGA,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,8BAAc,IAAI,IAAI;CACtB,6BAAa,IAAI,IAAI;CACrB,SAAS,EAAE,SAAS,eAAe,KAAK,CAAC,EAAE;CAC3C,kBAAkB;CAClB,eAAe;AACjB;;AAGA,MAAa,mCAAmC;;AAGhD,MAAa,4CAA4C;;AAyDzD,MAAa,gCACX,WACmC;CACnC,SAAS,MAAM;CACf,GAAI,MAAM,yBAAyB,KAAA,IAC/B,CAAC,IACD,EAAE,sBAAsB,MAAM,qBAAqB;CACvD,GAAI,MAAM,mBAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB,MAAM,eAAe;CACrF,UAAU,MAAM,KAAK,MAAM,SAAS,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,YAAY,CAC1E,WACA,8BAA8B,MAAM,CACtC,CAAC;CACD,MAAM,MAAM,KAAK,MAAM,KAAK,QAAQ,CAAC;CACrC,uBAAuB,MAAM,KAAK,MAAM,sBAAsB,QAAQ,CAAC;CACvE,OAAO,MAAM,KAAK,MAAM,MAAM,QAAQ,CAAC;CACvC,YAAY,MAAM,KAAK,MAAM,WAAW,QA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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { An as
|
|
1
|
+
import { An as RunSchedulingRequest, Cn as LocalRunResolution, Dn as RunResolution, En as RunRequestOutcome, Fn as planWaitingRunInterruption, In as runGrantability, Ln as runSchedulingInputMessageIds, Mn as RunSchedulingWork, Nn as canGrantRun, On as RunSchedulingCancellationPlan, Pn as planRunSchedulingCancellation, Rn as waitingRunControl, Sn as DeferredRunResolution, Tn as RunGrantability, jn as RunSchedulingRequestRecord, kn as RunSchedulingInput, wn as RunGrantResult } from "../reduced-state-DV0696_s.js";
|
|
2
2
|
export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunGrantability, RunRequestOutcome, RunResolution, RunSchedulingCancellationPlan, RunSchedulingInput, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runGrantability, runSchedulingInputMessageIds, waitingRunControl };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ import { _ as parseEDATraceparent, a as EDATraceAttributes, c as EDATraceLink, d
|
|
|
4
4
|
import { C as schemaV1, S as maxAppEventBytes, _ as ToolName, a as EventEnvelope, b as effectDurableAgentNamespace, c as EventTypeName, d as ModelSelectionPayload, f as NonNegativeInt, g as SystemPromptText, h as SchemaVersion, i as EventDurability, l as FailurePayload, m as ProviderPartId, n as EphemeralEventEnvelope, o as EventNamespace, p as PositionedEvent, r as EventDedupeKey, s as EventType, t as DurableEventEnvelope, u as ForeignDurableEvent, v as UnixEpochMillis, x as makeEventType, y as UsagePayload } from "./envelope-CJnPfbjC.js";
|
|
5
5
|
import { $ as InferenceStartedPayload, $n as inferenceStartedEventType, $t as ToolCallPromptPart, A as CompactionFailedEvent, An as assistantMessageImportedEventType, Ar as userMessagePromotedEventType, At as RunStartedEvent, B as ContextRebasedPayload, Bn as compactionCompletedEventType, Bt as StopTurnRequestedEvent, C as CommandEvent, Cn as UserMessageCommittedPayload, Cr as toolCallStartedEventType, Ct as RunSchedulingEvent, D as CommandStartedPayload, Dn as UserMessageSubmittedEvent, Dr as turnStoppedEventType, Dt as RunSchedulingInvalidatedPayload, E as CommandStartedEvent, En as UserMessagePromotedPayload, Er as turnStartedEventType, Et as RunSchedulingInvalidatedEvent, F as CompactionStartedPayload, Fn as commandAdmittedEventType, Ft as SteeringMessageQueuedEvent, G as EDADurableEvent, Gn as contextRebasedEventType, Gt as SystemMessageCommittedPayload, H as DeciderAcceptedEvent, Hn as compactionRequestedEventType, Ht as SummaryCreatedEvent, I as ContextAndCompactionEvent, In as commandCancelledEventType, It as SteeringMessageQueuedPayload, J as InferenceCompletedPayload, Jn as decodeUnknownEDADurableEvent, Jt as ToolCallCreatedEvent, K as EDADurableEventV1, Kn as deciderAcceptedEventType, Kt as ToolCallCompletedEvent, L as ContextProjectedEvent, Ln as commandCompletedEventType, Lt as StopControlEvent, M as CompactionRequestedEvent, Mn as baseStateCreatedEventType, Mt as SessionConfiguredEvent, N as CompactionRequestedPayload, Nn as baseStateFailedEventType, Nt as SteeringMessageCancelledEvent, O as CompactionCompletedEvent, On as UserMessageSubmittedPayload, Or as userMessageCancelledEventType, Ot as RunSchedulingRequestedEvent, P as CompactionStartedEvent, Pn as baseStateRequestedEventType, Pt as SteeringMessageCancelledPayload, Q as InferenceStartedEvent, Qn as inferenceFailedEventType, Qt as ToolCallFailedPayload, R as ContextProjectedPayload, Rn as commandFailedEventType, Rt as StopTurnAppliedEvent, S as CommandCompletedPayload, Sn as UserMessageCommittedEvent, Sr as toolCallRejectedEventType, St as RunSchedulingDeliveredPayload, T as CommandFailedPayload, Tn as UserMessagePromotedEvent, Tr as turnFailedEventType, Tt as RunSchedulingGrantedPayload, U as DeciderAcceptedPayload, Un as compactionStartedEventType, Ut as SummaryCreatedPayload, V as CurrentEDADurableEvent, Vn as compactionFailedEventType, Vt as StopTurnRequestedPayload, W as DecodedDurableEvent, Wn as contextProjectedEventType, Wt as SystemMessageCommittedEvent, X as InferenceFailedEvent, Xn as durableEventEnvelope, Xt as ToolCallEvent, Y as InferenceEvent, Yn as decodeUnknownEDADurableEventSync, Yt as ToolCallCreatedPayload, Z as InferenceFailedPayload, Zn as inferenceCompletedEventType, Zt as ToolCallFailedEvent, _ as CommandAdmittedEvent, _n as TurnStoppedEvent, _r as summaryCreatedEventType, _t as RunFailedEvent, a as AssistantMessageImportedPayload, an as ToolCallStartedPayload, ar as runFailedEventType, at as MessageEvent, b as CommandCancelledPayload, bn as UserMessageCancelledEvent, br as toolCallCreatedEventType, bt as RunInterruptedPayload, c as AssistantPromptPart, cn as ToolRejectionPromptPart, cr as runSchedulingGrantedEventType, ct as PendingMessagesPausedEvent, d as BaseStateCreatedPayload, dn as TurnCompletedPayload, dr as runStartedEventType, dt as RecoveryCompletedPayload, en as ToolCallRejectedEvent, er as interpretLegacyAttemptForReduction, et as LegacyAssistantMessageCommittedEvent, f as BaseStateEvent, fn as TurnEvent, fr as sessionConfiguredEventType, ft as RecoveryContinuation, g as BaseStateRequestedPayload, gn as TurnStartedPayload, gr as stopTurnRequestedEventType, gt as RunEvent, h as BaseStateRequestedEvent, hn as TurnStartedEvent, hr as stopTurnAppliedEventType, ht as RunCompletedPayload, i as AssistantMessageImportedEvent, in as ToolCallStartedEvent, ir as runCompletedEventType, it as LegacyTurnAttemptStartedEvent, j as CompactionFailedPayload, jn as assistantPartialCommittedEventType, jr as userMessageSubmittedEventType, jt as RunStartedPayload, k as CompactionCompletedPayload, kn as assistantMessageCommittedEventType, kr as userMessageCommittedEventType, kt as RunSchedulingRequestedPayload, l as AssistantPromptParts, ln as ToolSuccessPromptPart, lr as runSchedulingInvalidatedEventType, lt as PendingMessagesPausedPayload, m as BaseStateFailedPayload, mn as TurnFailedPayload, mr as steeringMessageQueuedEventType, mt as RunCompletedEvent, n as AssistantMessageCommittedPayload, nn as ToolCallRejectionFeedback, nr as pendingMessagesPausedEventType, nt as LegacyToolCallCreatedEvent, o as AssistantPartialCommittedEvent, on as ToolFailurePromptPart, or as runInterruptedEventType, ot as MessageQueuePausedEvent, p as BaseStateFailedEvent, pn as TurnFailedEvent, pr as steeringMessageCancelledEventType, pt as RecoveryEvent, q as InferenceCompletedEvent, qn as decodeDurableEventSync, qt as ToolCallCompletedPayload, r as AssistantMessageContent, rn as ToolCallRejectionReason, rr as recoveryCompletedEventType, rt as LegacyTurnAttemptCompletedEvent, s as AssistantPartialCommittedPayload, sn as ToolPromptPart, sr as runSchedulingDeliveredEventType, st as MessageQueuePausedPayload, t as AssistantMessageCommittedEvent, tn as ToolCallRejectedPayload, tr as messageQueuePausedEventType, tt as LegacyAttemptEvent, u as BaseStateCreatedEvent, un as TurnCompletedEvent, ur as runSchedulingRequestedEventType, ut as RecoveryCompletedEvent, v as CommandAdmittedPayload, vn as TurnStoppedPayload, vr as systemMessageCommittedEventType, vt as RunFailedPayload, w as CommandFailedEvent, wn as UserMessageDisposition, wr as turnCompletedEventType, wt as RunSchedulingGrantedEvent, x as CommandCompletedEvent, xn as UserMessageCancelledPayload, xr as toolCallFailedEventType, xt as RunSchedulingDeliveredEvent, y as CommandCancelledEvent, yn as UserMessageCancellationReason, yr as toolCallCompletedEventType, yt as RunInterruptedEvent, z as ContextRebasedEvent, zn as commandStartedEventType, zt as StopTurnAppliedPayload } from "./durable-BXqwM70o.js";
|
|
6
6
|
import { C as toolParamsDeltaEventType, E as traceStatusEventType, S as textDeltaEventType, T as toolParamsStartEventType, _ as TraceStatusEvent, a as RuntimeStatusEvent, b as reasoningDeltaEventType, c as SubscriberStatusPayload, d as ToolParamsDeltaEvent, f as ToolParamsDeltaPayload, g as ToolParamsStartPayload, h as ToolParamsStartEvent, i as ReasoningDeltaPayload, l as TextDeltaEvent, m as ToolParamsEndPayload, n as ModelStreamEvent, o as SubscriberStatusEvent, p as ToolParamsEndEvent, r as ReasoningDeltaEvent, s as SubscriberStatusKind, t as EDAEphemeralEvent, u as TextDeltaPayload, v as TraceStatusKind, w as toolParamsEndEventType, x as subscriberStatusEventType, y as TraceStatusPayload } from "./events-AIIwZ6dS.js";
|
|
7
|
-
import { G as
|
|
7
|
+
import { G as CommittedCommandTerminalEvent, J as EDARuntimeConfig, K as EDACommandTerminalEvent, X as EDARuntimeShape, Y as EDARuntimeError, Z as EDARuntimeSubmit, q as EDARuntime } from "./reduced-state-DV0696_s.js";
|
|
8
8
|
export { AssistantMessageCommittedEvent, AssistantMessageCommittedPayload, AssistantMessageContent, AssistantMessageImportedEvent, AssistantMessageImportedPayload, AssistantPartialCommittedEvent, AssistantPartialCommittedPayload, AssistantPromptPart, AssistantPromptParts, BaseStateCreatedEvent, BaseStateCreatedPayload, BaseStateEvent, BaseStateFailedEvent, BaseStateFailedPayload, BaseStateId, BaseStateRequestedEvent, BaseStateRequestedPayload, CancelPendingMessageCommand, CommandAdmittedEvent, CommandAdmittedPayload, CommandCancelledEvent, CommandCancelledPayload, CommandCompletedEvent, CommandCompletedPayload, CommandEvent, CommandFailedEvent, CommandFailedPayload, CommandId, CommandIdempotencyKey, CommandStartedEvent, CommandStartedPayload, CommittedCommandTerminalEvent, CompactionCompletedEvent, CompactionCompletedPayload, CompactionFailedEvent, CompactionFailedPayload, CompactionId, CompactionRequestedEvent, CompactionRequestedPayload, CompactionStartedEvent, CompactionStartedPayload, ContextAndCompactionEvent, ContextProjectedEvent, ContextProjectedPayload, ContextRebasedEvent, ContextRebasedPayload, ContextVersion, CorrelationId, CurrentEDADurableEvent, DeciderAcceptedEvent, DeciderAcceptedPayload, DecodedDurableEvent, DurableEventEnvelope, DurablePosition, DurableSubSequenceNumber, EDACommand, EDACommandTerminalEvent, EDADurableEvent, EDADurableEventV1, EDAEphemeralEvent, EDAEventTrace, EDARunTrace, EDARuntime, EDARuntimeConfig, EDARuntimeError, EDARuntimeShape, EDARuntimeSubmit, EDASpanId, EDATraceAttributeValue, EDATraceAttributes, EDATraceContext, EDATraceId, EDATraceLink, EDATraceMetadata, EphemeralEventEnvelope, EventDedupeKey, EventDurability, EventEnvelope, EventId, EventNamespace, EventType, EventTypeName, FailurePayload, ForeignDurableEvent, GrantRunCommand, InferenceCompletedEvent, InferenceCompletedPayload, InferenceEvent, InferenceFailedEvent, InferenceFailedPayload, InferenceId, InferenceStartedEvent, InferenceStartedPayload, LegacyAssistantMessageCommittedEvent, LegacyAttemptEvent, LegacyToolCallCreatedEvent, LegacyTurnAttemptCompletedEvent, LegacyTurnAttemptStartedEvent, MessageEvent, MessageId, MessageQueuePausedEvent, MessageQueuePausedPayload, ModelSelectionPayload, ModelStreamEvent, NonNegativeInt, PendingMessageCancellationReason, PendingMessagesPausedEvent, PendingMessagesPausedPayload, Position, PositionOrder, PositionedEvent, PromotePendingMessageCommand, ProviderPartId, ReasoningDeltaEvent, ReasoningDeltaPayload, RecoveryCompletedEvent, RecoveryCompletedPayload, RecoveryContinuation, RecoveryEvent, ResumePendingMessagesCommand, RunCompletedEvent, RunCompletedPayload, RunEvent, RunFailedEvent, RunFailedPayload, RunId, RunInterruptedEvent, RunInterruptedPayload, RunRequestId, RunSchedulingDeliveredEvent, RunSchedulingDeliveredPayload, RunSchedulingEvent, RunSchedulingGrantedEvent, RunSchedulingGrantedPayload, RunSchedulingInvalidatedEvent, RunSchedulingInvalidatedPayload, RunSchedulingRequestedEvent, RunSchedulingRequestedPayload, RunStartedEvent, RunStartedPayload, RuntimeStatusEvent, SchemaVersion, SequenceNumber, SessionConfiguredEvent, SessionId, SteeringMessageCancelledEvent, SteeringMessageCancelledPayload, SteeringMessageQueuedEvent, SteeringMessageQueuedPayload, StopControlEvent, StopTurnAppliedEvent, StopTurnAppliedPayload, StopTurnCommand, StopTurnRequestedEvent, StopTurnRequestedPayload, SubSequenceNumber, SubmitMessageCommand, SubmitMessageDisposition, SubscriberStatusEvent, SubscriberStatusKind, SubscriberStatusPayload, SummaryCreatedEvent, SummaryCreatedPayload, SummaryId, SystemMessageCommittedEvent, SystemMessageCommittedPayload, SystemPromptText, TextDeltaEvent, TextDeltaPayload, ToolCallCompletedEvent, ToolCallCompletedPayload, ToolCallCreatedEvent, ToolCallCreatedPayload, ToolCallEvent, ToolCallFailedEvent, ToolCallFailedPayload, ToolCallId, ToolCallPromptPart, ToolCallRejectedEvent, ToolCallRejectedPayload, ToolCallRejectionFeedback, ToolCallRejectionReason, ToolCallStartedEvent, ToolCallStartedPayload, ToolFailurePromptPart, ToolName, ToolParamsDeltaEvent, ToolParamsDeltaPayload, ToolParamsEndEvent, ToolParamsEndPayload, ToolParamsStartEvent, ToolParamsStartPayload, ToolPromptPart, ToolRejectionPromptPart, ToolSuccessPromptPart, TraceStatusEvent, TraceStatusKind, TraceStatusPayload, TurnCompletedEvent, TurnCompletedPayload, TurnEvent, TurnFailedEvent, TurnFailedPayload, TurnId, TurnStartedEvent, TurnStartedPayload, TurnStoppedEvent, TurnStoppedPayload, UnixEpochMillis, UsagePayload, UserMessageCancellationReason, UserMessageCancelledEvent, UserMessageCancelledPayload, UserMessageCommittedEvent, UserMessageCommittedPayload, UserMessageContent, UserMessageDisposition, UserMessagePart, UserMessagePromotedEvent, UserMessagePromotedPayload, UserMessageSubmittedEvent, UserMessageSubmittedPayload, assistantMessageCommittedEventType, assistantMessageImportedEventType, assistantPartialCommittedEventType, baseStateCreatedEventType, baseStateFailedEventType, baseStateRequestedEventType, buildEDATraceparent, commandAdmittedEventType, commandCancelledEventType, commandCompletedEventType, commandFailedEventType, commandStartedEventType, compactionCompletedEventType, compactionFailedEventType, compactionRequestedEventType, compactionStartedEventType, comparePosition, contextProjectedEventType, contextRebasedEventType, deciderAcceptedEventType, decodeDurableEventSync, decodeUnknownEDADurableEvent, decodeUnknownEDADurableEventSync, durableEventEnvelope, durablePosition, effectDurableAgentNamespace, inferenceCompletedEventType, inferenceFailedEventType, inferenceStartedEventType, interpretLegacyAttemptForReduction, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEventType, makeRootEDAEventTrace, makeRootEDATraceMetadata, maxAppEventBytes, messageQueuePausedEventType, parseEDATraceparent, pendingMessagesPausedEventType, reasoningDeltaEventType, recoveryCompletedEventType, runCompletedEventType, runFailedEventType, runInterruptedEventType, runSchedulingDeliveredEventType, runSchedulingGrantedEventType, runSchedulingInvalidatedEventType, runSchedulingRequestedEventType, runStartedEventType, schemaV1, sessionConfiguredEventType, steeringMessageCancelledEventType, steeringMessageQueuedEventType, stopTurnAppliedEventType, stopTurnRequestedEventType, subscriberStatusEventType, summaryCreatedEventType, systemMessageCommittedEventType, textDeltaEventType, toolCallCompletedEventType, toolCallCreatedEventType, toolCallFailedEventType, toolCallRejectedEventType, toolCallStartedEventType, toolParamsDeltaEventType, toolParamsEndEventType, toolParamsStartEventType, traceStatusEventType, turnCompletedEventType, turnFailedEventType, turnStartedEventType, turnStoppedEventType, userMessageCancelledEventType, userMessageCommittedEventType, userMessagePromotedEventType, userMessageSubmittedEventType };
|
|
@@ -226,7 +226,7 @@ declare const makeEDADeciderRegistry: (deciders: ReadonlyArray<EDADecider>, appE
|
|
|
226
226
|
//#endregion
|
|
227
227
|
//#region src/services/session-admission.d.ts
|
|
228
228
|
declare const SessionCommandAdmissionConflict_base: Schema.Class<SessionCommandAdmissionConflict, Schema.TaggedStruct<"SessionCommandAdmissionConflict", {
|
|
229
|
-
readonly code: Schema.Literals<readonly ["
|
|
229
|
+
readonly code: Schema.Literals<readonly ["paused_queue_changed", "event_too_large", "framework_event", "invalid_event", "payload_not_json"]>;
|
|
230
230
|
readonly message: Schema.String;
|
|
231
231
|
readonly pausedMessageIds: Schema.$Array<Schema.brand<Schema.String, "MessageId">>;
|
|
232
232
|
}>, import("effect/Cause").YieldableError>;
|
|
@@ -51925,7 +51925,7 @@ declare const initialReducedState: ReducedState;
|
|
|
51925
51925
|
/** Reserved reducer checkpoint name for the framework-owned `ReducedState`. */
|
|
51926
51926
|
declare const frameworkReducedStateReducerName = "_eda.framework.reduced-state";
|
|
51927
51927
|
/** Schema version for the framework-owned `ReducedState` checkpoint payload. */
|
|
51928
|
-
declare const frameworkReducedStateReducerSchemaVersion =
|
|
51928
|
+
declare const frameworkReducedStateReducerSchemaVersion = 8;
|
|
51929
51929
|
/** JSON payload stored for the framework-owned reduced-state reducer checkpoint. */
|
|
51930
51930
|
type ReducedStateCheckpointCommandRecord = Omit<CommandRecord, "command">;
|
|
51931
51931
|
type SystemMessageRecord = Extract<MessageRecord, {
|
|
@@ -52955,6 +52955,18 @@ declare const reduceCommittedEvents: (committed: ReadonlyArray<CommittedDurableE
|
|
|
52955
52955
|
}[];
|
|
52956
52956
|
};
|
|
52957
52957
|
};
|
|
52958
|
+
/**
|
|
52959
|
+
* Sequence at which a message entered the model's context, or `undefined` while it has not.
|
|
52960
|
+
*
|
|
52961
|
+
* An admitted message (one with a submission disposition) enters context when a turn consumes
|
|
52962
|
+
* it, not when it is submitted: it can wait queued, paused or steering past any number of
|
|
52963
|
+
* responses. A legacy committed user message entered at its own commit. Rebase pruning,
|
|
52964
|
+
* compaction planning and the prompt projection all read this one definition, so a message the
|
|
52965
|
+
* prompt has not shown the model is never summarised and never pruned.
|
|
52966
|
+
*/
|
|
52967
|
+
declare const messageContextSeq: (message: Exclude<MessageRecord, {
|
|
52968
|
+
readonly _tag: "System";
|
|
52969
|
+
}>) => SequenceNumber | undefined;
|
|
52958
52970
|
/** Pending admitted commands in deterministic scheduler order. */
|
|
52959
52971
|
declare const pendingCommands: (state: ReducedState) => ReadonlyArray<PendingCommand>;
|
|
52960
52972
|
/** First pending StopTurn control command, when one is waiting. */
|
|
@@ -52966,5 +52978,5 @@ declare const activeTurnIdentityForCommand: (state: ReducedState, commandId: Com
|
|
|
52966
52978
|
/** Classify unfinished durable lifecycles that recovery may need to repair. */
|
|
52967
52979
|
declare const classifyRecoverableWork: (state: ReducedState) => RecoverableWork;
|
|
52968
52980
|
//#endregion
|
|
52969
|
-
export {
|
|
52970
|
-
//# sourceMappingURL=reduced-state-
|
|
52981
|
+
export { SessionCommandAdmissionError as $, edaReservedDeciderNamePrefix as $n, PromptPrefixSummaryCompactionExecutorOptions as $t, TurnTerminal as A, RunSchedulingRequest as An, EDASink as At, messageContextSeq as B, EDADecider as Bn, CompactionError as Bt, RunRecord as C, LocalRunResolution as Cn, RunSchedulingDeliveryError as Ct, ToolDecision as D, RunResolution as Dn, EDAProjectedSink as Dt, ToolCallRecord as E, RunRequestOutcome as En, EDAProjectedDurableSinkDefinition as Et, encodeReducedStateCheckpoint as F, planWaitingRunInterruption as Fn, EDASinkRawDurableBatch as Ft, CommittedCommandTerminalEvent as G, EDADeciderRegistry as Gn, CompactionPlan as Gt, pendingStopCommand as H, EDADeciderError as Hn, CompactionExecutorInput as Ht, foldReducedState as I, runGrantability as In, EDASinkRegistry as It, EDARuntimeConfig as J, EDAErasedDecision as Jn, CompactionPolicyShape as Jt, EDACommandTerminalEvent as K, EDADeciderView as Kn, CompactionPolicy as Kt, frameworkReducedStateReducerName as L, runSchedulingInputMessageIds as Ln, EDASinkRegistryShape as Lt, activeTurnIdentityForCommand as M, RunSchedulingWork as Mn, EDASinkContext as Mt, classifyRecoverableWork as N, canGrantRun as Nn, EDASinkDurableBatch as Nt, ToolTerminal as O, RunSchedulingCancellationPlan as On, EDARawDurableSinkDefinition as Ot, decodeReducedStateCheckpoint as P, planRunSchedulingCancellation as Pn, EDASinkInterests as Pt, EDASubmittable as Q, deciderNamePattern as Qn, LanguageModelSummaryCompactionExecutorOptions as Qt, frameworkReducedStateReducerSchemaVersion as R, waitingRunControl as Rn, EDASinkRunnerStartInput as Rt, ReducedStateCheckpointToolTerminal as S, DeferredRunResolution as Sn, RunSchedulingDelivery as St, StopRequestRecord as T, RunGrantability as Tn, EDAEphemeralSinkDefinition as Tt, reduceCommittedEvents as U, EDADeciderItem as Un, CompactionExecutorShape as Ut, pendingCommands as V, EDADeciderDefinition as Vn, CompactionExecutor as Vt, reducedStateCheckpointEventSeqs as W, EDADeciderOutcome as Wn, CompactionOutput as Wt, EDARuntimeShape as X, deciderIdempotencyKeyViolation as Xn, CompactionRunnerInput as Xt, EDARuntimeError as Y, EDAEventDraft as Yn, CompactionRunner as Yt, EDARuntimeSubmit as Z, deciderMarkerDedupeKey as Zn, CompactionRunnerShape as Zt, ReducedStateCheckpointCommandRecord as _, EDASessionEventPage as _n, InferenceRunner as _t, CompactionRecord as a, promptPrefixSummaryCompactionExecutor as an, EDANativeCompaction as ar, SessionDecideError as at, ReducedStateCheckpointToolCallRecord as b, EDASessionSnapshot as bn, RunScheduler as bt, InferenceRecord as c, EDAToolExecutionContext as cn, EDAPromptProjector as cr, SessionForkedCommand as ct, LifecycleTiming as d, ToolParamsSchema as dn, buildEDAPrompt as dr, SessionRunInput as dt, defaultCompactionCharsPerToken as en, encodeDeciderJson as er, SessionCommandCancelled as et, MessageRecord as f, ToolRecovery as fn, getNativeCompaction as fr, SessionState as ft, ReducedState as g, toolRecoveryPolicy as gn, TurnRunner as gt, RecoveryContinuationRecord as h, maxToolCallAttempts as hn, SessionStateSnapshotData as ht, CommandTerminal as i, defaultCompactionThresholdTokens as in, SessionContext as ir, SessionCommandResult as it, activeCommand as j, RunSchedulingRequestRecord as jn, EDASinkCheckpoint as jt, TurnRecord as k, RunSchedulingInput as kn, EDARawSink as kt, InferenceTerminal as l, EDAToolRegistry as ln, EDAPromptProjectorShape as lr, SessionNoRunnableCommand as lt, RecoverableWork as m, makeEDAToolkit as mn, nativeCompactionSummaryMessage as mr, SessionStateShape as mt, ActiveTurnIdentity as n, defaultCompactionRetainTailTokens as nn, maxDeciderIdempotencyKeyLength as nr, SessionCommandFailed as nt, CompactionTerminal as o, EventFactory as on, EDAProjectedPromptContext as or, SessionDrainProcessed as ot, PendingCommand as p, ToolRecoveryPolicy as pn, isEDACacheBreakpoint as pr, SessionStateError as pt, EDARuntime as q, EDADecision as qn, CompactionPolicyInput as qt, CommandRecord as r, defaultCompactionSummaryInstructions as rn, maxDeciderResultBytes as rr, SessionCommandOutcome as rt, ContextRecord as s, EDAModelToolkit as sn, EDAPromptProjectionInput as sr, SessionDrainResult as st, ActiveCommandEvidence as t, defaultCompactionMinSummarizableTokens as tn, makeEDADeciderRegistry as tr, SessionCommandCompleted as tt, LifecycleFailure as u, EDAToolRegistryShape as un, EDA_PROMPT_OPTIONS_KEY as ur, SessionNoRunnableReason as ut, ReducedStateCheckpointMessageRecord as v, EDASessionQuery as vn, InferenceRunnerStreamPart as vt, RunTerminal as w, RunGrantResult as wn, EDADurableSinkDefinition as wt, ReducedStateCheckpointToolDecision as x, LiveEventBus as xn, RunSchedulerShape as xt, ReducedStateCheckpointPayload as y, EDASessionQueryShape as yn, ToolExecutor as yt, initialReducedState as z, SessionCommandAdmissionConflict as zn, ApproximateTokenThresholdCompactionPolicyOptions as zt };
|
|
52982
|
+
//# sourceMappingURL=reduced-state-DV0696_s.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $t as PromptPrefixSummaryCompactionExecutorOptions, Bt as CompactionError, Gt as CompactionPlan, Ht as CompactionExecutorInput, Jt as CompactionPolicyShape, Kt as CompactionPolicy, Qt as LanguageModelSummaryCompactionExecutorOptions, Ut as CompactionExecutorShape, Vt as CompactionExecutor, Wt as CompactionOutput, Xt as CompactionRunnerInput, Yt as CompactionRunner, Zt as CompactionRunnerShape, an as promptPrefixSummaryCompactionExecutor, en as defaultCompactionCharsPerToken, in as defaultCompactionThresholdTokens, nn as defaultCompactionRetainTailTokens, qt as CompactionPolicyInput, rn as defaultCompactionSummaryInstructions, tn as defaultCompactionMinSummarizableTokens, zt as ApproximateTokenThresholdCompactionPolicyOptions } from "../reduced-state-DV0696_s.js";
|
|
2
2
|
export { ApproximateTokenThresholdCompactionPolicyOptions, CompactionError, CompactionExecutor, CompactionExecutorInput, CompactionExecutorShape, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionPolicyInput, CompactionPolicyShape, CompactionRunner, CompactionRunnerInput, CompactionRunnerShape, LanguageModelSummaryCompactionExecutorOptions, PromptPrefixSummaryCompactionExecutorOptions, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionSummaryInstructions, defaultCompactionThresholdTokens, promptPrefixSummaryCompactionExecutor };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as CompactionPolicy, c as defaultCompactionMinSummarizableTokens, d as defaultCompactionThresholdTokens, f as promptPrefixSummaryCompactionExecutor, i as CompactionPlan, l as defaultCompactionRetainTailTokens, n as CompactionExecutor, o as CompactionRunner, r as CompactionOutput, s as defaultCompactionCharsPerToken, t as CompactionError, u as defaultCompactionSummaryInstructions } from "../compaction-
|
|
1
|
+
import { a as CompactionPolicy, c as defaultCompactionMinSummarizableTokens, d as defaultCompactionThresholdTokens, f as promptPrefixSummaryCompactionExecutor, i as CompactionPlan, l as defaultCompactionRetainTailTokens, n as CompactionExecutor, o as CompactionRunner, r as CompactionOutput, s as defaultCompactionCharsPerToken, t as CompactionError, u as defaultCompactionSummaryInstructions } from "../compaction-Dlq4wgZE.js";
|
|
2
2
|
export { CompactionError, CompactionExecutor, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionRunner, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionSummaryInstructions, defaultCompactionThresholdTokens, promptPrefixSummaryCompactionExecutor };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as edaReservedDeciderNamePrefix, Bn as EDADecider, Gn as EDADeciderRegistry, Hn as EDADeciderError, Jn as EDAErasedDecision, Kn as EDADeciderView, Qn as deciderNamePattern, Un as EDADeciderItem, Vn as EDADeciderDefinition, Wn as EDADeciderOutcome, Xn as deciderIdempotencyKeyViolation, Yn as EDAEventDraft, Zn as deciderMarkerDedupeKey, er as encodeDeciderJson, nr as maxDeciderIdempotencyKeyLength, qn as EDADecision, rr as maxDeciderResultBytes, tr as makeEDADeciderRegistry } from "../reduced-state-DV0696_s.js";
|
|
2
2
|
export { EDADecider, EDADeciderDefinition, EDADeciderError, EDADeciderItem, EDADeciderOutcome, EDADeciderRegistry, EDADeciderView, EDADecision, EDAErasedDecision, EDAEventDraft, deciderIdempotencyKeyViolation, deciderMarkerDedupeKey, deciderNamePattern, edaReservedDeciderNamePrefix, encodeDeciderJson, makeEDADeciderRegistry, maxDeciderIdempotencyKeyLength, maxDeciderResultBytes };
|
package/dist/services/decider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../envelope-BSI_Xh-f.js";
|
|
2
|
-
import { i as eventSchemaNamespaces, s as storedJsonForm } from "../session-admission-
|
|
2
|
+
import { i as eventSchemaNamespaces, s as storedJsonForm } from "../session-admission-DC98zwtj.js";
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as Result from "effect/Result";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sn as EDAModelToolkit } from "../reduced-state-DV0696_s.js";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as LanguageModel from "effect/ai/LanguageModel";
|
|
4
4
|
import * as Prompt from "effect/ai/Prompt";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ar as
|
|
1
|
+
import { ar as EDANativeCompaction, cr as EDAPromptProjector, dr as buildEDAPrompt, fr as getNativeCompaction, lr as EDAPromptProjectorShape, mr as nativeCompactionSummaryMessage, or as EDAProjectedPromptContext, pr as isEDACacheBreakpoint, sr as EDAPromptProjectionInput, ur as EDA_PROMPT_OPTIONS_KEY } from "../reduced-state-DV0696_s.js";
|
|
2
2
|
export { EDANativeCompaction, EDAProjectedPromptContext, EDAPromptProjectionInput, EDAPromptProjector, EDAPromptProjectorShape, EDA_PROMPT_OPTIONS_KEY, buildEDAPrompt, getNativeCompaction, isEDACacheBreakpoint, nativeCompactionSummaryMessage };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cn as LocalRunResolution, Ct as RunSchedulingDeliveryError, Dn as RunResolution, Sn as DeferredRunResolution, St as RunSchedulingDelivery, bt as RunScheduler, kn as RunSchedulingInput, xt as RunSchedulerShape } from "../reduced-state-DV0696_s.js";
|
|
2
2
|
export { DeferredRunResolution, LocalRunResolution, type RunResolution, RunScheduler, RunSchedulerShape, RunSchedulingDelivery, RunSchedulingDeliveryError, type RunSchedulingInput };
|
|
@@ -2,7 +2,7 @@ import { g as SessionId } from "../core-BcimKMIv.js";
|
|
|
2
2
|
import { i as EDAAppEvents, o as EDASessionStore, s as EDASessionStoreError } from "../session-store-DaSHeg8Q.js";
|
|
3
3
|
import { t as ModelResolver } from "../model-resolver-O8Kn27GH.js";
|
|
4
4
|
import { r as EDAReducerRegistry } from "../reducer-registry-Bqn5B4JO.js";
|
|
5
|
-
import {
|
|
5
|
+
import { $ as SessionCommandAdmissionError, At as EDASink, Bn as EDADecider, J as EDARuntimeConfig, Kt as CompactionPolicy, Vt as CompactionExecutor, bt as RunScheduler, cr as EDAPromptProjector, q as EDARuntime, sn as EDAModelToolkit, un as EDAToolRegistryShape } from "../reduced-state-DV0696_s.js";
|
|
6
6
|
import { t as SessionEventObserver } from "../session-event-observer-BWQUJTcN.js";
|
|
7
7
|
import { t as IdGenerator } from "../id-generator-BKGoKjt-.js";
|
|
8
8
|
import { t as EDAKeepAlive } from "../keep-alive-_zFCUvt3.js";
|