effect-durable-agent 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{delivery-v42MAMEP.d.ts → delivery-GCO7QmXQ.d.ts} +2 -2
  2. package/dist/domain/command-queues.d.ts +1 -1
  3. package/dist/domain/message-transcript.d.ts +1 -1
  4. package/dist/domain/reduced-state.d.ts +1 -1
  5. package/dist/domain/run-scheduling.d.ts +2 -2
  6. package/dist/domain/run-scheduling.js +95 -26
  7. package/dist/domain/run-scheduling.js.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/{reduced-state-DB_iANjR.d.ts → reduced-state-BGI8EJN5.d.ts} +378 -341
  10. package/dist/services/compaction.d.ts +1 -1
  11. package/dist/services/decider.d.ts +1 -1
  12. package/dist/services/model-call.d.ts +1 -1
  13. package/dist/services/prompt-projector.d.ts +1 -1
  14. package/dist/services/run-scheduler.d.ts +1 -1
  15. package/dist/services/runtime-layer.d.ts +1 -1
  16. package/dist/services/runtime-layer.js +1 -1
  17. package/dist/services/runtime.d.ts +1 -1
  18. package/dist/services/runtime.js +1 -1
  19. package/dist/services/session-query.d.ts +1 -1
  20. package/dist/services/session-query.js +1 -1
  21. package/dist/services/session-state.d.ts +1 -1
  22. package/dist/services/session-state.js +1 -1
  23. package/dist/services/sink-registry.d.ts +1 -1
  24. package/dist/services/tool-registry.d.ts +1 -1
  25. package/dist/{session-state-BII-Jhf-.js → session-state-OY3Wih8X.js} +59 -12
  26. package/dist/session-state-OY3Wih8X.js.map +1 -0
  27. package/dist/testkit/layers.d.ts +1 -1
  28. package/dist/testkit/layers.js +1 -1
  29. package/dist/websocket/events.d.ts +1 -1
  30. package/dist/websocket.d.ts +1 -1
  31. package/package.json +1 -1
  32. package/dist/session-state-BII-Jhf-.js.map +0 -1
@@ -2,7 +2,7 @@ import { c as StopTurnCommand, l as SubmitMessageCommand, o as PromotePendingMes
2
2
  import { h as SequenceNumber } from "./core-BcimKMIv.js";
3
3
  import { a as EventEnvelope, p as PositionedEvent } from "./envelope-CJnPfbjC.js";
4
4
  import "./events-AIIwZ6dS.js";
5
- import "./reduced-state-DB_iANjR.js";
5
+ import "./reduced-state-BGI8EJN5.js";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Schema from "effect/Schema";
8
8
  //#region src/websocket/protocol.d.ts
@@ -3166,4 +3166,4 @@ declare const onClientAck: (state: EDAWebSocketDeliveryState, ack: EDAWebSocketA
3166
3166
  declare const onHostSuppressedFrame: (state: EDAWebSocketDeliveryState, frame: Pick<EDAWebSocketEventsFrame, "durableThroughSeq" | "frameId">, nowMs: number) => EDAWebSocketDeliveryResult;
3167
3167
  //#endregion
3168
3168
  export { EDAWebSocketWireProtocol as $, EDA_WS_CLOSE_LAGGED as A, EDAFrameworkWebSocketEvent as B, EDAWebSocketHelloFrame as C, EDAWebSocketServerFrame as D, EDAWebSocketPongFrame as E, SubscriberId as F, EDAWebSocketWireClientFrame as G, EDAWebSocketServerFrameEncoder as H, decodeEDAWebSocketClientMessage as I, EDAWebSocketWireHeartbeatFrame as J, EDAWebSocketWireErrorFrame as K, defaultEDAWebSocketFlowControl as L, EDA_WS_CLOSE_SEND_FAILED as M, EDA_WS_CLOSE_UNSUPPORTED_DATA as N, EDA_WEB_SOCKET_PROTOCOL_VERSION as O, FrameId as P, EDAWebSocketWirePongFrame as Q, encodeEDAWebSocketServerFrame as R, EDAWebSocketHeartbeatFrame as S, EDAWebSocketPingFrame as T, EDAWebSocketServerFrameInput as U, EDAWebSocketEventConsumerPolicy as V, EDAWebSocketWireAckFrame as W, EDAWebSocketWireLaggedFrame as X, EDAWebSocketWireHelloFrame as Y, EDAWebSocketWirePingFrame as Z, EDAWebSocketAckFrame as _, EDAWebSocketInFlightFrame as a, EDAWebSocketEventsFrame as b, SubscriberLagReason as c, makeWebSocketDeliveryState as d, EDA_WEB_SOCKET_PING_MESSAGE as et, onClientAck as f, restoreWebSocketDeliveryState as g, onHostSuppressedFrame as h, EDAWebSocketDeliveryState as i, makeEDAWebSocketWireProtocol as it, EDA_WS_CLOSE_PROTOCOL_ERROR as j, EDA_WS_CLOSE_GOING_AWAY as k, checkpointWebSocketDeliveryState as l, onEphemeralEvent as m, EDAWebSocketDeliveryCheckpoint as n, EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION as nt, EDAWebSocketSuppressedRange as o, onDurableEvents as p, EDAWebSocketWireFlowControl as q, EDAWebSocketDeliveryResult as r, edaFrameworkWebSocketWireProtocol as rt, MakeDeliveryStateInput as s, EDAWebSocketDeliveryAction as t, EDA_WEB_SOCKET_PONG_MESSAGE as tt, deliveryHelloFrame as u, EDAWebSocketClientFrame as v, EDAWebSocketLaggedFrame as w, EDAWebSocketFlowControl as x, EDAWebSocketErrorFrame as y, laggedCloseReason as z };
3169
- //# sourceMappingURL=delivery-v42MAMEP.d.ts.map
3169
+ //# sourceMappingURL=delivery-GCO7QmXQ.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { d as UserMessageContent } from "../commands-BUquEZVP.js";
2
2
  import { b as TurnId, h as SequenceNumber, p as RunId, u as MessageId } from "../core-BcimKMIv.js";
3
- import { C as RunRecord, f as MessageRecord, p as PendingCommand, r as CommandRecord, t as ActiveCommandEvidence } from "../reduced-state-DB_iANjR.js";
3
+ import { C as RunRecord, f as MessageRecord, p as PendingCommand, r as CommandRecord, t as ActiveCommandEvidence } from "../reduced-state-BGI8EJN5.js";
4
4
  //#region src/domain/command-queues.d.ts
5
5
  /**
6
6
  * A steering message admitted for an active run but not necessarily consumed
@@ -1,6 +1,6 @@
1
1
  import { d as UserMessageContent } from "../commands-BUquEZVP.js";
2
2
  import { i as ContextProjection } from "../context-projection-Bezx3drD.js";
3
- import { f as MessageRecord, g as ReducedState } from "../reduced-state-DB_iANjR.js";
3
+ import { f as MessageRecord, g as ReducedState } from "../reduced-state-BGI8EJN5.js";
4
4
  import * as Prompt from "effect/ai/Prompt";
5
5
  //#region src/domain/message-transcript.d.ts
6
6
  /** Durable user/assistant message records suitable for a session transcript. */
@@ -1,3 +1,3 @@
1
- import { A as TurnTerminal, B as pendingCommands, C as RunRecord, D as ToolDecision, E as ToolCallRecord, F as encodeReducedStateCheckpoint, H as reduceCommittedEvents, I as foldReducedState, L as frameworkReducedStateReducerName, M as activeTurnIdentityForCommand, N as classifyRecoverableWork, O as ToolTerminal, P as decodeReducedStateCheckpoint, R as frameworkReducedStateReducerSchemaVersion, S as ReducedStateCheckpointToolTerminal, T as StopRequestRecord, U as reducedStateCheckpointEventSeqs, V as pendingStopCommand, _ as ReducedStateCheckpointCommandRecord, a as CompactionRecord, b as ReducedStateCheckpointToolCallRecord, c as InferenceRecord, d as LifecycleTiming, f as MessageRecord, g as ReducedState, h as RecoveryContinuationRecord, i as CommandTerminal, j as activeCommand, k as TurnRecord, l as InferenceTerminal, m as RecoverableWork, n as ActiveTurnIdentity, o as CompactionTerminal, p as PendingCommand, r as CommandRecord, s as ContextRecord, t as ActiveCommandEvidence, u as LifecycleFailure, v as ReducedStateCheckpointMessageRecord, w as RunTerminal, x as ReducedStateCheckpointToolDecision, y as ReducedStateCheckpointPayload, z as initialReducedState } from "../reduced-state-DB_iANjR.js";
1
+ import { A as TurnTerminal, B as pendingCommands, C as RunRecord, D as ToolDecision, E as ToolCallRecord, F as encodeReducedStateCheckpoint, H as reduceCommittedEvents, I as foldReducedState, L as frameworkReducedStateReducerName, M as activeTurnIdentityForCommand, N as classifyRecoverableWork, O as ToolTerminal, P as decodeReducedStateCheckpoint, R as frameworkReducedStateReducerSchemaVersion, S as ReducedStateCheckpointToolTerminal, T as StopRequestRecord, U as reducedStateCheckpointEventSeqs, V as pendingStopCommand, _ as ReducedStateCheckpointCommandRecord, a as CompactionRecord, b as ReducedStateCheckpointToolCallRecord, c as InferenceRecord, d as LifecycleTiming, f as MessageRecord, g as ReducedState, h as RecoveryContinuationRecord, i as CommandTerminal, j as activeCommand, k as TurnRecord, l as InferenceTerminal, m as RecoverableWork, n as ActiveTurnIdentity, o as CompactionTerminal, p as PendingCommand, r as CommandRecord, s as ContextRecord, t as ActiveCommandEvidence, u as LifecycleFailure, v as ReducedStateCheckpointMessageRecord, w as RunTerminal, x as ReducedStateCheckpointToolDecision, y as ReducedStateCheckpointPayload, z as initialReducedState } from "../reduced-state-BGI8EJN5.js";
2
2
  import { n as TokenConsumptionState, r as TokenUsageTotals } from "../model-usage-mttrPN0j.js";
3
3
  export { ActiveCommandEvidence, ActiveTurnIdentity, CommandRecord, CommandTerminal, CompactionRecord, CompactionTerminal, ContextRecord, InferenceRecord, InferenceTerminal, LifecycleFailure, LifecycleTiming, MessageRecord, PendingCommand, RecoverableWork, RecoveryContinuationRecord, ReducedState, ReducedStateCheckpointCommandRecord, ReducedStateCheckpointMessageRecord, ReducedStateCheckpointPayload, ReducedStateCheckpointToolCallRecord, ReducedStateCheckpointToolDecision, ReducedStateCheckpointToolTerminal, RunRecord, RunTerminal, StopRequestRecord, TokenConsumptionState, type TokenUsageTotals, ToolCallRecord, ToolDecision, ToolTerminal, TurnRecord, TurnTerminal, activeCommand, activeTurnIdentityForCommand, classifyRecoverableWork, decodeReducedStateCheckpoint, encodeReducedStateCheckpoint, foldReducedState, frameworkReducedStateReducerName, frameworkReducedStateReducerSchemaVersion, initialReducedState, pendingCommands, pendingStopCommand, reduceCommittedEvents, reducedStateCheckpointEventSeqs };
@@ -1,2 +1,2 @@
1
- import { An as RunSchedulingWork, Cn as RunGrantResult, Dn as RunSchedulingInput, En as RunSchedulingCancellationPlan, Fn as waitingRunControl, Mn as planRunSchedulingCancellation, Nn as planWaitingRunInterruption, On as RunSchedulingRequest, Pn as runSchedulingInputMessageIds, Sn as LocalRunResolution, Tn as RunResolution, jn as canGrantRun, kn as RunSchedulingRequestRecord, wn as RunRequestOutcome, xn as DeferredRunResolution } from "../reduced-state-DB_iANjR.js";
2
- export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunRequestOutcome, RunResolution, RunSchedulingCancellationPlan, RunSchedulingInput, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runSchedulingInputMessageIds, waitingRunControl };
1
+ import { An as RunSchedulingRequestRecord, Cn as RunGrantResult, Dn as RunSchedulingCancellationPlan, En as RunResolution, Fn as runGrantability, In as runSchedulingInputMessageIds, Ln as waitingRunControl, Mn as canGrantRun, Nn as planRunSchedulingCancellation, On as RunSchedulingInput, Pn as planWaitingRunInterruption, Sn as LocalRunResolution, Tn as RunRequestOutcome, jn as RunSchedulingWork, kn as RunSchedulingRequest, wn as RunGrantability, xn as DeferredRunResolution } from "../reduced-state-BGI8EJN5.js";
2
+ export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunGrantability, RunRequestOutcome, RunResolution, RunSchedulingCancellationPlan, RunSchedulingInput, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runGrantability, runSchedulingInputMessageIds, waitingRunControl };
@@ -44,40 +44,109 @@ const RunRequestOutcome = Schema.Union([
44
44
  ])
45
45
  })
46
46
  ]);
47
- /** Still-unconsumed inputs owned by a reservation, derived from the existing message records. */
48
- const runSchedulingInputMessageIds = (state, work) => {
47
+ /** A work's selected messages: those a run would consume, and those a pause still holds. */
48
+ const runSchedulingInputs = (state, work) => {
49
49
  const command = state.commands.get(work.commandId)?.command;
50
- return (work._tag === "Recovery" ? work.inputMessageIds : command?._tag === "ResumePendingMessages" ? command.messageIds : Array.from(state.messages.values()).flatMap((message) => (message._tag === "User" || message._tag === "Steering") && message.commandId === work.commandId ? [message.messageId] : [])).filter((messageId) => {
50
+ const resumed = command?._tag === "ResumePendingMessages" ? command.messageIds : [];
51
+ const candidates = work._tag === "Recovery" ? work.inputMessageIds : command?._tag === "ResumePendingMessages" ? command.messageIds : Array.from(state.messages.values()).flatMap((message) => (message._tag === "User" || message._tag === "Steering") && message.commandId === work.commandId ? [message.messageId] : []);
52
+ const eligible = [];
53
+ const held = [];
54
+ for (const messageId of candidates) {
51
55
  const message = state.messages.get(messageId);
52
- return (message?._tag === "User" || message?._tag === "Steering") && message.consumedSeq === void 0 && message.cancelledSeq === void 0 && message.pausedByCommandId === void 0;
53
- });
54
- };
55
- /** Revalidate durable ownership and pending controls immediately before granting permission. */
56
- const canGrantRun = (state, requestId) => {
57
- const request = state.runSchedulingRequest;
58
- if (request?.requestId !== requestId) return false;
59
- const command = state.commands.get(request.work.commandId);
60
- if (command?.command === void 0 || command.terminal !== void 0) return false;
61
- if (Array.from(state.runs.values()).some((run) => run.terminal === void 0)) return false;
62
- const inputs = runSchedulingInputMessageIds(state, request.work);
63
- if (request.work._tag === "Command") {
64
- if (command.startedSeq !== void 0) return false;
65
- const legacySubmit = command.command._tag === "SubmitMessage" && !Array.from(state.messages.values()).some((message) => (message._tag === "User" || message._tag === "Steering") && message.commandId === command.commandId);
66
- if (inputs.length === 0 && !legacySubmit) return false;
67
- } else {
68
- const predecessor = state.runs.get(request.work.interruptedRunId);
69
- if (command.startedSeq === void 0 || predecessor?.terminal === void 0 || !predecessor.commandIds.includes(command.commandId) || request.work.inputMessageIds.length > 0 && inputs.length === 0) return false;
56
+ if (message?._tag !== "User" && message?._tag !== "Steering" || message.consumedSeq !== void 0 || message.cancelledSeq !== void 0) continue;
57
+ if (message.pausedByCommandId === void 0 || resumed.includes(messageId)) eligible.push(messageId);
58
+ else held.push(messageId);
70
59
  }
71
- return !state.commandQueues.activeControlCommands.some((pending) => {
72
- if (pending.commandId === command.commandId) return false;
60
+ return {
61
+ eligible,
62
+ held
63
+ };
64
+ };
65
+ /**
66
+ * The messages a run for this work would consume: its selected user and steering messages that
67
+ * are neither consumed nor cancelled. Dispatch, grant, cancellation and startup recovery all read
68
+ * this one function, so dispatch never reserves a run that grant rejects for want of inputs,
69
+ * cancelling an input always finds the reservation that owns it, and a replacement run selects
70
+ * the inputs its interrupted run would have consumed.
71
+ *
72
+ * A paused message is an input only of the `ResumePendingMessages` that names it, for that
73
+ * command's own work and for a recovery of it alike, because resuming paused messages is that
74
+ * command's purpose: a host's interrupt-with-pending-message submits
75
+ * `[StopTurn, ResumePendingMessages([m])]`, and the Stop pauses `m` before the Resume runs. Until
76
+ * a turn consumes `m` it stays paused, so a run that dies before its first turn leaves it paused
77
+ * for recovery. For any other work, and for any message the Resume does not name, a pause holds
78
+ * the message until the user promotes or resumes it.
79
+ */
80
+ const runSchedulingInputMessageIds = (state, work) => runSchedulingInputs(state, work).eligible;
81
+ /**
82
+ * Whether a reservation's work can start a run now. Grant starts a run only from `Grantable`,
83
+ * whose inputs are the ones the run consumes.
84
+ *
85
+ * `Blocked` clears without intervention: a non-terminal run finishes, a pending Stop, interrupt
86
+ * or cancellation of an input resolves the reservation itself, or a promotion releases a paused
87
+ * input. It is checked first, so a pending control always decides its reservation's fate.
88
+ *
89
+ * `Ineligible` never clears, because every fact behind it is absorbing: an owner command that is
90
+ * missing, terminal, or (for ordinary work) already started; a recovery predecessor that does not
91
+ * match; inputs that were all consumed or cancelled. The session retires such a reservation
92
+ * rather than leave every later message waiting behind it.
93
+ */
94
+ const RunGrantability = Schema.Union([
95
+ Schema.TaggedStruct("Grantable", { inputMessageIds: Schema.Array(MessageId) }),
96
+ Schema.TaggedStruct("Blocked", { reason: Schema.Literals([
97
+ "active-run",
98
+ "pending-control",
99
+ "paused-inputs"
100
+ ]) }),
101
+ Schema.TaggedStruct("Ineligible", { reason: Schema.Literals([
102
+ "owner-missing",
103
+ "owner-terminal",
104
+ "owner-started",
105
+ "owner-not-started",
106
+ "predecessor-mismatch",
107
+ "inputs-gone"
108
+ ]) })
109
+ ]);
110
+ const blocked = (reason) => ({
111
+ _tag: "Blocked",
112
+ reason
113
+ });
114
+ const ineligible = (reason) => ({
115
+ _tag: "Ineligible",
116
+ reason
117
+ });
118
+ /** Classify a reservation's work against durable ownership, runs and pending controls. */
119
+ const runGrantability = (state, work) => {
120
+ const inputs = runSchedulingInputs(state, work);
121
+ if (Array.from(state.runs.values()).some((run) => run.terminal === void 0)) return blocked("active-run");
122
+ if (state.commandQueues.activeControlCommands.some((pending) => {
123
+ if (pending.commandId === work.commandId) return false;
73
124
  switch (pending.command._tag) {
74
125
  case "StopTurn": return true;
75
126
  case "SubmitMessage": return pending.command.disposition === "interrupt";
76
- case "CancelPendingMessage": return inputs.includes(pending.command.messageId);
127
+ case "CancelPendingMessage": return inputs.eligible.includes(pending.command.messageId);
77
128
  default: return false;
78
129
  }
79
- });
130
+ })) return blocked("pending-control");
131
+ const command = state.commands.get(work.commandId);
132
+ if (command?.command === void 0) return ineligible("owner-missing");
133
+ if (command.terminal !== void 0) return ineligible("owner-terminal");
134
+ const inputsRequired = work._tag === "Command" ? !(command.command._tag === "SubmitMessage" && !Array.from(state.messages.values()).some((message) => (message._tag === "User" || message._tag === "Steering") && message.commandId === command.commandId)) : work.inputMessageIds.length > 0;
135
+ if (work._tag === "Command") {
136
+ if (command.startedSeq !== void 0) return ineligible("owner-started");
137
+ } else {
138
+ if (command.startedSeq === void 0) return ineligible("owner-not-started");
139
+ const predecessor = state.runs.get(work.interruptedRunId);
140
+ if (predecessor === void 0 || !predecessor.commandIds.includes(command.commandId)) return ineligible("predecessor-mismatch");
141
+ }
142
+ if (inputsRequired && inputs.eligible.length === 0) return inputs.held.length > 0 ? blocked("paused-inputs") : ineligible("inputs-gone");
143
+ return {
144
+ _tag: "Grantable",
145
+ inputMessageIds: inputs.eligible
146
+ };
80
147
  };
148
+ /** Whether a grant of `requestId` would start a run now; `runGrantability` says why not. */
149
+ const canGrantRun = (state, requestId) => state.runSchedulingRequest?.requestId === requestId && runGrantability(state, state.runSchedulingRequest.work)._tag === "Grantable";
81
150
  /** Controls may change waiting work; later messages cannot take its reserved slot. */
82
151
  const waitingRunControl = (state) => {
83
152
  const owner = state.runSchedulingRequest?.work.commandId;
@@ -122,6 +191,6 @@ const planWaitingRunInterruption = (state, controlCommandId) => {
122
191
  };
123
192
  };
124
193
  //#endregion
125
- export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunRequestOutcome, RunResolution, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runSchedulingInputMessageIds, waitingRunControl };
194
+ export { DeferredRunResolution, LocalRunResolution, RunGrantResult, RunGrantability, RunRequestOutcome, RunResolution, RunSchedulingRequest, RunSchedulingRequestRecord, RunSchedulingWork, canGrantRun, planRunSchedulingCancellation, planWaitingRunInterruption, runGrantability, runSchedulingInputMessageIds, waitingRunControl };
126
195
 
127
196
  //# sourceMappingURL=run-scheduling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-scheduling.js","names":[],"sources":["../../src/domain/run-scheduling.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport {\n CommandId,\n MessageId,\n RunId,\n RunRequestId,\n SequenceNumber,\n type SessionId,\n} from \"../types/core\";\nimport type { PendingCommand, ReducedState } from \"./reduced-state\";\n\n/**\n * Identity of the admitted work selected by dispatch or recovery for a new run.\n * This is not a durable request identity: recovery can resolve the same command again.\n */\nexport interface RunSchedulingInput {\n readonly sessionId: SessionId;\n readonly commandId: CommandId;\n}\n\n/**\n * Permission to start the selected run in this session's current runtime.\n * This value is never persisted and allocates no scheduling identity.\n */\nexport const LocalRunResolution = Schema.TaggedStruct(\"Local\", {});\nexport type LocalRunResolution = typeof LocalRunResolution.Type;\n\n/** Intent to request external permission; resolution itself must perform no delivery. */\nexport const DeferredRunResolution = Schema.TaggedStruct(\"Deferred\", {});\nexport type DeferredRunResolution = typeof DeferredRunResolution.Type;\n\n/** Prompt selection result interpreted by SessionState before any run is started. */\nexport const RunResolution = Schema.Union([LocalRunResolution, DeferredRunResolution]);\nexport type RunResolution = typeof RunResolution.Type;\n\n/** Selected work and the durable predecessor needed to authorize a recovery replacement. */\nexport const RunSchedulingWork = Schema.Union([\n Schema.TaggedStruct(\"Command\", { commandId: CommandId }),\n Schema.TaggedStruct(\"Recovery\", {\n commandId: CommandId,\n interruptedRunId: RunId,\n inputMessageIds: Schema.Array(MessageId),\n }),\n]);\nexport type RunSchedulingWork = typeof RunSchedulingWork.Type;\n\n/** One run-slot reservation. External schedulers must deduplicate delivery by requestId. */\nexport const RunSchedulingRequest = Schema.Struct({\n requestId: RunRequestId,\n work: RunSchedulingWork,\n});\nexport type RunSchedulingRequest = typeof RunSchedulingRequest.Type;\n\n/** Current reservation, folded solely from request and successful delivery facts. */\nexport const RunSchedulingRequestRecord = Schema.Struct({\n ...RunSchedulingRequest.fields,\n requestedSeq: SequenceNumber,\n deliveredSeq: Schema.optionalKey(SequenceNumber),\n});\nexport type RunSchedulingRequestRecord = typeof RunSchedulingRequestRecord.Type;\n\n/** A stale/duplicate permission is harmless and cannot allocate another run. */\nexport const RunGrantResult = Schema.Union([\n Schema.TaggedStruct(\"Granted\", { runId: RunId }),\n Schema.TaggedStruct(\"Stale\", {}),\n]);\nexport type RunGrantResult = typeof RunGrantResult.Type;\n\n/** Durable answer for reconciling an ambiguous grant delivery. Unknown never authorizes replacement work. */\nexport const RunRequestOutcome = Schema.Union([\n Schema.TaggedStruct(\"Unknown\", {}),\n Schema.TaggedStruct(\"Waiting\", {}),\n Schema.TaggedStruct(\"Invalidated\", {}),\n Schema.TaggedStruct(\"Granted\", {\n runId: RunId,\n status: Schema.Literals([\"Running\", \"Completed\", \"Failed\", \"Interrupted\"]),\n }),\n]);\nexport type RunRequestOutcome = typeof RunRequestOutcome.Type;\n\n/** Canonical records consulted by authorization policy, without an Effect-layer snapshot. */\ntype SchedulingState = Pick<\n ReducedState,\n \"commands\" | \"runs\" | \"messages\" | \"commandQueues\" | \"runSchedulingRequest\"\n>;\n\n/** Still-unconsumed inputs owned by a reservation, derived from the existing message records. */\nexport const runSchedulingInputMessageIds = (\n state: SchedulingState,\n work: RunSchedulingWork,\n): ReadonlyArray<MessageId> => {\n const command = state.commands.get(work.commandId)?.command;\n const candidates =\n work._tag === \"Recovery\"\n ? work.inputMessageIds\n : command?._tag === \"ResumePendingMessages\"\n ? command.messageIds\n : Array.from(state.messages.values()).flatMap((message) =>\n (message._tag === \"User\" || message._tag === \"Steering\") &&\n message.commandId === work.commandId\n ? [message.messageId]\n : [],\n );\n return candidates.filter((messageId) => {\n const message = state.messages.get(messageId);\n return (\n (message?._tag === \"User\" || message?._tag === \"Steering\") &&\n message.consumedSeq === undefined &&\n message.cancelledSeq === undefined &&\n message.pausedByCommandId === undefined\n );\n });\n};\n\n/** Revalidate durable ownership and pending controls immediately before granting permission. */\nexport const canGrantRun = (state: SchedulingState, requestId: RunRequestId): boolean => {\n const request = state.runSchedulingRequest;\n if (request?.requestId !== requestId) return false;\n const command = state.commands.get(request.work.commandId);\n if (command?.command === undefined || command.terminal !== undefined) return false;\n if (Array.from(state.runs.values()).some((run) => run.terminal === undefined)) return false;\n const inputs = runSchedulingInputMessageIds(state, request.work);\n if (request.work._tag === \"Command\") {\n if (command.startedSeq !== undefined) return false;\n // Older admitted commands did not commit their User message until run start.\n const legacySubmit =\n command.command._tag === \"SubmitMessage\" &&\n !Array.from(state.messages.values()).some(\n (message) =>\n (message._tag === \"User\" || message._tag === \"Steering\") &&\n message.commandId === command.commandId,\n );\n if (inputs.length === 0 && !legacySubmit) return false;\n } else {\n const predecessor = state.runs.get(request.work.interruptedRunId);\n if (\n command.startedSeq === undefined ||\n predecessor?.terminal === undefined ||\n !predecessor.commandIds.includes(command.commandId) ||\n (request.work.inputMessageIds.length > 0 && inputs.length === 0)\n )\n return false;\n }\n return !state.commandQueues.activeControlCommands.some((pending) => {\n if (pending.commandId === command.commandId) return false;\n switch (pending.command._tag) {\n case \"StopTurn\":\n return true;\n case \"SubmitMessage\":\n return pending.command.disposition === \"interrupt\";\n case \"CancelPendingMessage\":\n return inputs.includes(pending.command.messageId);\n default:\n return false;\n }\n });\n};\n\n/** Controls may change waiting work; later messages cannot take its reserved slot. */\nexport const waitingRunControl = (state: SchedulingState): PendingCommand | undefined => {\n const owner = state.runSchedulingRequest?.work.commandId;\n const controls = state.commandQueues.activeControlCommands.filter(\n (pending) =>\n pending.commandId !== owner &&\n (pending.command._tag !== \"SubmitMessage\" || pending.command.disposition === \"interrupt\"),\n );\n const priority = (pending: PendingCommand): number => {\n switch (pending.command._tag) {\n case \"StopTurn\":\n return 0;\n case \"CancelPendingMessage\":\n return 1;\n case \"PromotePendingMessage\":\n return 2;\n default:\n return 3;\n }\n };\n return controls.sort((a, b) => priority(a) - priority(b) || a.admittedSeq - b.admittedSeq)[0];\n};\n\n/** Atomic request changes required when one of its selected messages is cancelled. */\nexport interface RunSchedulingCancellationPlan {\n readonly requestId: RunRequestId;\n readonly cancelCommandId?: CommandId;\n readonly replacementWork?: RunSchedulingWork;\n}\n\n/** Preserve a recovery predecessor when cancellation leaves other selected inputs eligible. */\nexport const planRunSchedulingCancellation = (\n state: SchedulingState,\n messageId: MessageId,\n): RunSchedulingCancellationPlan | undefined => {\n const request = state.runSchedulingRequest;\n if (request === undefined) return undefined;\n const inputs = runSchedulingInputMessageIds(state, request.work);\n if (!inputs.includes(messageId)) return undefined;\n if (request.work._tag === \"Command\") return { requestId: request.requestId };\n const remainingInputs = inputs.filter((id) => id !== messageId);\n return remainingInputs.length === 0\n ? { requestId: request.requestId, cancelCommandId: request.work.commandId }\n : {\n requestId: request.requestId,\n replacementWork: { ...request.work, inputMessageIds: remainingInputs },\n };\n};\n\n/** Stop/interrupt facts that invalidate authorization and pause pending work before any run. */\nexport const planWaitingRunInterruption = (state: SchedulingState, controlCommandId: CommandId) => {\n const request = state.runSchedulingRequest;\n if (request === undefined) return undefined;\n return {\n requestId: request.requestId,\n messageIds: [...state.commandQueues.pendingQueue, ...state.commandQueues.pendingSteers]\n .filter((message) => message.commandId !== controlCommandId)\n .map((message) => message.messageId),\n cancelCommandId: request.work.commandId,\n };\n};\n"],"mappings":";;;;;;;AAyBA,MAAa,qBAAqB,OAAO,aAAa,SAAS,CAAC,CAAC;;AAIjE,MAAa,wBAAwB,OAAO,aAAa,YAAY,CAAC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,cAAc,cAAc,GAAG,MAAM,cAAc,aAAa,CAAC,CACpF,QAAQ,YAAY,QAAQ,cAAc,gBAAgB,CAAC,CAC3D,KAAK,YAAY,QAAQ,SAAS;EACrC,iBAAiB,QAAQ,KAAK;CAChC;AACF"}
1
+ {"version":3,"file":"run-scheduling.js","names":[],"sources":["../../src/domain/run-scheduling.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport {\n CommandId,\n MessageId,\n RunId,\n RunRequestId,\n SequenceNumber,\n type SessionId,\n} from \"../types/core\";\nimport type { PendingCommand, ReducedState } from \"./reduced-state\";\n\n/**\n * Identity of the admitted work selected by dispatch or recovery for a new run.\n * This is not a durable request identity: recovery can resolve the same command again.\n */\nexport interface RunSchedulingInput {\n readonly sessionId: SessionId;\n readonly commandId: CommandId;\n}\n\n/**\n * Permission to start the selected run in this session's current runtime.\n * This value is never persisted and allocates no scheduling identity.\n */\nexport const LocalRunResolution = Schema.TaggedStruct(\"Local\", {});\nexport type LocalRunResolution = typeof LocalRunResolution.Type;\n\n/** Intent to request external permission; resolution itself must perform no delivery. */\nexport const DeferredRunResolution = Schema.TaggedStruct(\"Deferred\", {});\nexport type DeferredRunResolution = typeof DeferredRunResolution.Type;\n\n/** Prompt selection result interpreted by SessionState before any run is started. */\nexport const RunResolution = Schema.Union([LocalRunResolution, DeferredRunResolution]);\nexport type RunResolution = typeof RunResolution.Type;\n\n/** Selected work and the durable predecessor needed to authorize a recovery replacement. */\nexport const RunSchedulingWork = Schema.Union([\n Schema.TaggedStruct(\"Command\", { commandId: CommandId }),\n Schema.TaggedStruct(\"Recovery\", {\n commandId: CommandId,\n interruptedRunId: RunId,\n inputMessageIds: Schema.Array(MessageId),\n }),\n]);\nexport type RunSchedulingWork = typeof RunSchedulingWork.Type;\n\n/** One run-slot reservation. External schedulers must deduplicate delivery by requestId. */\nexport const RunSchedulingRequest = Schema.Struct({\n requestId: RunRequestId,\n work: RunSchedulingWork,\n});\nexport type RunSchedulingRequest = typeof RunSchedulingRequest.Type;\n\n/** Current reservation, folded solely from request and successful delivery facts. */\nexport const RunSchedulingRequestRecord = Schema.Struct({\n ...RunSchedulingRequest.fields,\n requestedSeq: SequenceNumber,\n deliveredSeq: Schema.optionalKey(SequenceNumber),\n});\nexport type RunSchedulingRequestRecord = typeof RunSchedulingRequestRecord.Type;\n\n/** A stale/duplicate permission is harmless and cannot allocate another run. */\nexport const RunGrantResult = Schema.Union([\n Schema.TaggedStruct(\"Granted\", { runId: RunId }),\n Schema.TaggedStruct(\"Stale\", {}),\n]);\nexport type RunGrantResult = typeof RunGrantResult.Type;\n\n/** Durable answer for reconciling an ambiguous grant delivery. Unknown never authorizes replacement work. */\nexport const RunRequestOutcome = Schema.Union([\n Schema.TaggedStruct(\"Unknown\", {}),\n Schema.TaggedStruct(\"Waiting\", {}),\n Schema.TaggedStruct(\"Invalidated\", {}),\n Schema.TaggedStruct(\"Granted\", {\n runId: RunId,\n status: Schema.Literals([\"Running\", \"Completed\", \"Failed\", \"Interrupted\"]),\n }),\n]);\nexport type RunRequestOutcome = typeof RunRequestOutcome.Type;\n\n/** Canonical records consulted by authorization policy, without an Effect-layer snapshot. */\ntype SchedulingState = Pick<\n ReducedState,\n \"commands\" | \"runs\" | \"messages\" | \"commandQueues\" | \"runSchedulingRequest\"\n>;\n\n/** A work's selected messages: those a run would consume, and those a pause still holds. */\nconst runSchedulingInputs = (state: SchedulingState, work: RunSchedulingWork) => {\n const command = state.commands.get(work.commandId)?.command;\n const resumed: ReadonlyArray<MessageId> =\n command?._tag === \"ResumePendingMessages\" ? command.messageIds : [];\n const candidates =\n work._tag === \"Recovery\"\n ? work.inputMessageIds\n : command?._tag === \"ResumePendingMessages\"\n ? command.messageIds\n : Array.from(state.messages.values()).flatMap((message) =>\n (message._tag === \"User\" || message._tag === \"Steering\") &&\n message.commandId === work.commandId\n ? [message.messageId]\n : [],\n );\n const eligible: Array<MessageId> = [];\n const held: Array<MessageId> = [];\n for (const messageId of candidates) {\n const message = state.messages.get(messageId);\n if (\n (message?._tag !== \"User\" && message?._tag !== \"Steering\") ||\n message.consumedSeq !== undefined ||\n message.cancelledSeq !== undefined\n )\n continue;\n if (message.pausedByCommandId === undefined || resumed.includes(messageId))\n eligible.push(messageId);\n else held.push(messageId);\n }\n return { eligible, held };\n};\n\n/**\n * The messages a run for this work would consume: its selected user and steering messages that\n * are neither consumed nor cancelled. Dispatch, grant, cancellation and startup recovery all read\n * this one function, so dispatch never reserves a run that grant rejects for want of inputs,\n * cancelling an input always finds the reservation that owns it, and a replacement run selects\n * the inputs its interrupted run would have consumed.\n *\n * A paused message is an input only of the `ResumePendingMessages` that names it, for that\n * command's own work and for a recovery of it alike, because resuming paused messages is that\n * command's purpose: a host's interrupt-with-pending-message submits\n * `[StopTurn, ResumePendingMessages([m])]`, and the Stop pauses `m` before the Resume runs. Until\n * a turn consumes `m` it stays paused, so a run that dies before its first turn leaves it paused\n * for recovery. For any other work, and for any message the Resume does not name, a pause holds\n * the message until the user promotes or resumes it.\n */\nexport const runSchedulingInputMessageIds = (\n state: SchedulingState,\n work: RunSchedulingWork,\n): ReadonlyArray<MessageId> => runSchedulingInputs(state, work).eligible;\n\n/**\n * Whether a reservation's work can start a run now. Grant starts a run only from `Grantable`,\n * whose inputs are the ones the run consumes.\n *\n * `Blocked` clears without intervention: a non-terminal run finishes, a pending Stop, interrupt\n * or cancellation of an input resolves the reservation itself, or a promotion releases a paused\n * input. It is checked first, so a pending control always decides its reservation's fate.\n *\n * `Ineligible` never clears, because every fact behind it is absorbing: an owner command that is\n * missing, terminal, or (for ordinary work) already started; a recovery predecessor that does not\n * match; inputs that were all consumed or cancelled. The session retires such a reservation\n * rather than leave every later message waiting behind it.\n */\nexport const RunGrantability = Schema.Union([\n Schema.TaggedStruct(\"Grantable\", { inputMessageIds: Schema.Array(MessageId) }),\n Schema.TaggedStruct(\"Blocked\", {\n reason: Schema.Literals([\"active-run\", \"pending-control\", \"paused-inputs\"]),\n }),\n Schema.TaggedStruct(\"Ineligible\", {\n reason: Schema.Literals([\n \"owner-missing\",\n \"owner-terminal\",\n \"owner-started\",\n \"owner-not-started\",\n \"predecessor-mismatch\",\n \"inputs-gone\",\n ]),\n }),\n]);\nexport type RunGrantability = typeof RunGrantability.Type;\n\nconst blocked = (reason: Extract<RunGrantability, { _tag: \"Blocked\" }>[\"reason\"]) =>\n ({ _tag: \"Blocked\", reason }) as const;\nconst ineligible = (reason: Extract<RunGrantability, { _tag: \"Ineligible\" }>[\"reason\"]) =>\n ({ _tag: \"Ineligible\", reason }) as const;\n\n/** Classify a reservation's work against durable ownership, runs and pending controls. */\nexport const runGrantability = (\n state: SchedulingState,\n work: RunSchedulingWork,\n): RunGrantability => {\n const inputs = runSchedulingInputs(state, work);\n if (Array.from(state.runs.values()).some((run) => run.terminal === undefined))\n return blocked(\"active-run\");\n const controlPending = state.commandQueues.activeControlCommands.some((pending) => {\n if (pending.commandId === work.commandId) return false;\n switch (pending.command._tag) {\n case \"StopTurn\":\n return true;\n case \"SubmitMessage\":\n return pending.command.disposition === \"interrupt\";\n case \"CancelPendingMessage\":\n return inputs.eligible.includes(pending.command.messageId);\n default:\n return false;\n }\n });\n if (controlPending) return blocked(\"pending-control\");\n const command = state.commands.get(work.commandId);\n if (command?.command === undefined) return ineligible(\"owner-missing\");\n if (command.terminal !== undefined) return ineligible(\"owner-terminal\");\n const inputsRequired =\n work._tag === \"Command\"\n ? // Older admitted commands did not commit their User message until run start.\n !(\n command.command._tag === \"SubmitMessage\" &&\n !Array.from(state.messages.values()).some(\n (message) =>\n (message._tag === \"User\" || message._tag === \"Steering\") &&\n message.commandId === command.commandId,\n )\n )\n : work.inputMessageIds.length > 0;\n if (work._tag === \"Command\") {\n if (command.startedSeq !== undefined) return ineligible(\"owner-started\");\n } else {\n if (command.startedSeq === undefined) return ineligible(\"owner-not-started\");\n const predecessor = state.runs.get(work.interruptedRunId);\n if (predecessor === undefined || !predecessor.commandIds.includes(command.commandId))\n return ineligible(\"predecessor-mismatch\");\n }\n if (inputsRequired && inputs.eligible.length === 0)\n return inputs.held.length > 0 ? blocked(\"paused-inputs\") : ineligible(\"inputs-gone\");\n return { _tag: \"Grantable\", inputMessageIds: inputs.eligible };\n};\n\n/** Whether a grant of `requestId` would start a run now; `runGrantability` says why not. */\nexport const canGrantRun = (state: SchedulingState, requestId: RunRequestId): boolean =>\n state.runSchedulingRequest?.requestId === requestId &&\n runGrantability(state, state.runSchedulingRequest.work)._tag === \"Grantable\";\n\n/** Controls may change waiting work; later messages cannot take its reserved slot. */\nexport const waitingRunControl = (state: SchedulingState): PendingCommand | undefined => {\n const owner = state.runSchedulingRequest?.work.commandId;\n const controls = state.commandQueues.activeControlCommands.filter(\n (pending) =>\n pending.commandId !== owner &&\n (pending.command._tag !== \"SubmitMessage\" || pending.command.disposition === \"interrupt\"),\n );\n const priority = (pending: PendingCommand): number => {\n switch (pending.command._tag) {\n case \"StopTurn\":\n return 0;\n case \"CancelPendingMessage\":\n return 1;\n case \"PromotePendingMessage\":\n return 2;\n default:\n return 3;\n }\n };\n return controls.sort((a, b) => priority(a) - priority(b) || a.admittedSeq - b.admittedSeq)[0];\n};\n\n/** Atomic request changes required when one of its selected messages is cancelled. */\nexport interface RunSchedulingCancellationPlan {\n readonly requestId: RunRequestId;\n readonly cancelCommandId?: CommandId;\n readonly replacementWork?: RunSchedulingWork;\n}\n\n/** Preserve a recovery predecessor when cancellation leaves other selected inputs eligible. */\nexport const planRunSchedulingCancellation = (\n state: SchedulingState,\n messageId: MessageId,\n): RunSchedulingCancellationPlan | undefined => {\n const request = state.runSchedulingRequest;\n if (request === undefined) return undefined;\n const inputs = runSchedulingInputMessageIds(state, request.work);\n if (!inputs.includes(messageId)) return undefined;\n if (request.work._tag === \"Command\") return { requestId: request.requestId };\n const remainingInputs = inputs.filter((id) => id !== messageId);\n return remainingInputs.length === 0\n ? { requestId: request.requestId, cancelCommandId: request.work.commandId }\n : {\n requestId: request.requestId,\n replacementWork: { ...request.work, inputMessageIds: remainingInputs },\n };\n};\n\n/** Stop/interrupt facts that invalidate authorization and pause pending work before any run. */\nexport const planWaitingRunInterruption = (state: SchedulingState, controlCommandId: CommandId) => {\n const request = state.runSchedulingRequest;\n if (request === undefined) return undefined;\n return {\n requestId: request.requestId,\n messageIds: [...state.commandQueues.pendingQueue, ...state.commandQueues.pendingSteers]\n .filter((message) => message.commandId !== controlCommandId)\n .map((message) => message.messageId),\n cancelCommandId: request.work.commandId,\n };\n};\n"],"mappings":";;;;;;;AAyBA,MAAa,qBAAqB,OAAO,aAAa,SAAS,CAAC,CAAC;;AAIjE,MAAa,wBAAwB,OAAO,aAAa,YAAY,CAAC,CAAC;;AAIvE,MAAa,gBAAgB,OAAO,MAAM,CAAC,oBAAoB,qBAAqB,CAAC;;AAIrF,MAAa,oBAAoB,OAAO,MAAM,CAC5C,OAAO,aAAa,WAAW,EAAE,WAAW,UAAU,CAAC,GACvD,OAAO,aAAa,YAAY;CAC9B,WAAW;CACX,kBAAkB;CAClB,iBAAiB,OAAO,MAAM,SAAS;AACzC,CAAC,CACH,CAAC;;AAID,MAAa,uBAAuB,OAAO,OAAO;CAChD,WAAW;CACX,MAAM;AACR,CAAC;;AAID,MAAa,6BAA6B,OAAO,OAAO;CACtD,GAAG,qBAAqB;CACxB,cAAc;CACd,cAAc,OAAO,YAAY,cAAc;AACjD,CAAC;;AAID,MAAa,iBAAiB,OAAO,MAAM,CACzC,OAAO,aAAa,WAAW,EAAE,OAAO,MAAM,CAAC,GAC/C,OAAO,aAAa,SAAS,CAAC,CAAC,CACjC,CAAC;;AAID,MAAa,oBAAoB,OAAO,MAAM;CAC5C,OAAO,aAAa,WAAW,CAAC,CAAC;CACjC,OAAO,aAAa,WAAW,CAAC,CAAC;CACjC,OAAO,aAAa,eAAe,CAAC,CAAC;CACrC,OAAO,aAAa,WAAW;EAC7B,OAAO;EACP,QAAQ,OAAO,SAAS;GAAC;GAAW;GAAa;GAAU;EAAa,CAAC;CAC3E,CAAC;AACH,CAAC;;AAUD,MA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CACvE;AACN;;AAGA,MAAa,8BAA8B,OAAwB,qBAAgC;CACjG,MAAM,UAAU,MAAM;CACtB,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAClC,OAAO;EACL,WAAW,QAAQ;EACnB,YAAY,CAAC,GAAG,MAAM,cAAc,cAAc,GAAG,MAAM,cAAc,aAAa,CAAC,CACpF,QAAQ,YAAY,QAAQ,cAAc,gBAAgB,CAAC,CAC3D,KAAK,YAAY,QAAQ,SAAS;EACrC,iBAAiB,QAAQ,KAAK;CAChC;AACF"}
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 EDACommandTerminalEvent, J as EDARuntimeError, K as EDARuntime, W as CommittedCommandTerminalEvent, X as EDARuntimeSubmit, Y as EDARuntimeShape, q as EDARuntimeConfig } from "./reduced-state-DB_iANjR.js";
7
+ import { G as EDACommandTerminalEvent, J as EDARuntimeError, K as EDARuntime, W as CommittedCommandTerminalEvent, X as EDARuntimeSubmit, Y as EDARuntimeShape, q as EDARuntimeConfig } from "./reduced-state-BGI8EJN5.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 };