effect-durable-agent 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/CONTRIBUTING.md +26 -0
- package/LICENSE +21 -0
- package/README.md +305 -0
- package/SECURITY.md +8 -0
- package/dist/command-queues-CQ9cwRP7.d.ts +468 -0
- package/dist/commands-Ce1ec6kH.d.ts +104 -0
- package/dist/compaction-YayFKo_1.d.ts +144 -0
- package/dist/core-Hv3cFydL.d.ts +81 -0
- package/dist/domain/command-queues.d.ts +2 -0
- package/dist/domain/command-queues.js +97 -0
- package/dist/domain/command-queues.js.map +1 -0
- package/dist/domain/message-transcript.d.ts +2 -0
- package/dist/domain/message-transcript.js +111 -0
- package/dist/domain/message-transcript.js.map +1 -0
- package/dist/domain/reduced-state-schema.d.ts +996 -0
- package/dist/domain/reduced-state-schema.js +286 -0
- package/dist/domain/reduced-state-schema.js.map +1 -0
- package/dist/domain/reduced-state.d.ts +2 -0
- package/dist/domain/reduced-state.js +2 -0
- package/dist/durable-C3Rz7kg3.js +625 -0
- package/dist/durable-C3Rz7kg3.js.map +1 -0
- package/dist/durable-DlScwmCy.d.ts +7424 -0
- package/dist/durable-object-runtime-B7jwBY2R.js +1494 -0
- package/dist/durable-object-runtime-B7jwBY2R.js.map +1 -0
- package/dist/durable-object-runtime-pWv0ohlz.d.ts +257 -0
- package/dist/durable-object-storage-Czy7IPrh.d.ts +41 -0
- package/dist/events-Bb9-Cu-7.d.ts +918 -0
- package/dist/host/durable-object-runtime.d.ts +2 -0
- package/dist/host/durable-object-runtime.js +2 -0
- package/dist/host/durable-object-storage.d.ts +2 -0
- package/dist/host/durable-object-storage.js +0 -0
- package/dist/host/durable-object.d.ts +83 -0
- package/dist/host/durable-object.js +191 -0
- package/dist/host/durable-object.js.map +1 -0
- package/dist/host/websocket-wire.d.ts +2 -0
- package/dist/host/websocket-wire.js +88 -0
- package/dist/host/websocket-wire.js.map +1 -0
- package/dist/id-generator-C2Q15uZM.d.ts +33 -0
- package/dist/index-BVVgDSdq.d.ts +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/keep-alive-DYDsH6qN.d.ts +111 -0
- package/dist/keep-alive-p8dIcSVy.js +109 -0
- package/dist/keep-alive-p8dIcSVy.js.map +1 -0
- package/dist/message-transcript-BCHdHAe2.d.ts +32 -0
- package/dist/prompt-projector-9_02lk5-.d.ts +40 -0
- package/dist/reduced-state-C4nVVzz9.js +910 -0
- package/dist/reduced-state-C4nVVzz9.js.map +1 -0
- package/dist/reducer-registry-C0svUa63.d.ts +69 -0
- package/dist/runtime-C56FQxiL.d.ts +60 -0
- package/dist/services/compaction.d.ts +2 -0
- package/dist/services/compaction.js +426 -0
- package/dist/services/compaction.js.map +1 -0
- package/dist/services/id-generator.d.ts +2 -0
- package/dist/services/id-generator.js +56 -0
- package/dist/services/id-generator.js.map +1 -0
- package/dist/services/prompt-projector.d.ts +2 -0
- package/dist/services/prompt-projector.js +27 -0
- package/dist/services/prompt-projector.js.map +1 -0
- package/dist/services/reducer-registry.d.ts +2 -0
- package/dist/services/reducer-registry.js +71 -0
- package/dist/services/reducer-registry.js.map +1 -0
- package/dist/services/runtime.d.ts +2 -0
- package/dist/services/runtime.js +84 -0
- package/dist/services/runtime.js.map +1 -0
- package/dist/services/session-query.d.ts +2 -0
- package/dist/services/session-query.js +2 -0
- package/dist/services/session-store.d.ts +2 -0
- package/dist/services/session-store.js +2 -0
- package/dist/services/sink-registry.d.ts +2 -0
- package/dist/services/sink-registry.js +2 -0
- package/dist/services/span-names.d.ts +28 -0
- package/dist/services/span-names.js +42 -0
- package/dist/services/span-names.js.map +1 -0
- package/dist/services/tool-registry.d.ts +2 -0
- package/dist/services/tool-registry.js +46 -0
- package/dist/services/tool-registry.js.map +1 -0
- package/dist/services/tracing.d.ts +76 -0
- package/dist/services/tracing.js +116 -0
- package/dist/services/tracing.js.map +1 -0
- package/dist/session-query-DOc1KanA.js +2930 -0
- package/dist/session-query-DOc1KanA.js.map +1 -0
- package/dist/session-query-DlRo5Ufc.d.ts +769 -0
- package/dist/session-store-D2Ore1QC.d.ts +295 -0
- package/dist/session-store-pYxQW9qh.js +214 -0
- package/dist/session-store-pYxQW9qh.js.map +1 -0
- package/dist/sink-registry-CFC6xjsN.js +312 -0
- package/dist/sink-registry-CFC6xjsN.js.map +1 -0
- package/dist/sink-registry-CIU0LD3m.d.ts +158 -0
- package/dist/testkit/layers.d.ts +101 -0
- package/dist/testkit/layers.js +108 -0
- package/dist/testkit/layers.js.map +1 -0
- package/dist/tool-registry-CcnkAAQK.d.ts +51 -0
- package/dist/tracing-BXHAkxkx.d.ts +111 -0
- package/dist/types/commands.d.ts +2 -0
- package/dist/types/commands.js +60 -0
- package/dist/types/commands.js.map +1 -0
- package/dist/types/core.d.ts +2 -0
- package/dist/types/core.js +68 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/events/durable.d.ts +2 -0
- package/dist/types/events/durable.js +2 -0
- package/dist/types/events.d.ts +4 -0
- package/dist/types/events.js +90 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/tracing.d.ts +2 -0
- package/dist/types/tracing.js +99 -0
- package/dist/types/tracing.js.map +1 -0
- package/dist/websocket-wire-DvOu_6BJ.d.ts +16773 -0
- package/docs/assets/architecture.svg +106 -0
- package/docs/assets/event-sequence.svg +143 -0
- package/docs/assets/gcp-trace.png +0 -0
- package/docs/message-steering.md +831 -0
- package/docs/releasing.md +57 -0
- package/docs/spec.md +774 -0
- package/docs/subagents.md +725 -0
- package/docs/testing.md +64 -0
- package/docs/ui-projection.md +742 -0
- package/docs/websocket-protocol.md +613 -0
- package/examples/001-no-tools/README.md +65 -0
- package/examples/001-no-tools/worker.ts +79 -0
- package/examples/002-slack-bridge/README.md +134 -0
- package/examples/002-slack-bridge/events.ts +115 -0
- package/examples/002-slack-bridge/reducer.ts +216 -0
- package/examples/002-slack-bridge/scenario.test.ts +223 -0
- package/examples/002-slack-bridge/sinks.ts +109 -0
- package/examples/002-slack-bridge/worker.ts +140 -0
- package/examples/003-sandbox-lifecycle/README.md +78 -0
- package/examples/003-sandbox-lifecycle/events.ts +203 -0
- package/examples/003-sandbox-lifecycle/reducer.ts +305 -0
- package/examples/003-sandbox-lifecycle/scenario.test.ts +202 -0
- package/examples/_shared/event-id.ts +12 -0
- package/examples/_shared/http.ts +27 -0
- package/examples/_shared/openai.ts +33 -0
- package/package.json +181 -0
- package/testing/offline-trace/README.md +63 -0
- package/tooling/oxlint/index.mjs +15 -0
- package/tooling/oxlint/rules/effect-span-from-catalog.mjs +152 -0
- package/tooling/oxlint/rules/span-catalog-format.mjs +74 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import { BaseStateId, CommandId, CompactionId, ContextVersion, CorrelationId, EventId, InferenceId, MessageId, Position, RunId, SequenceNumber, SessionId, SummaryId, ToolCallId, TurnId } from "./types/core.js";
|
|
2
|
+
import { EDACommand, UserMessageContent } from "./types/commands.js";
|
|
3
|
+
import { EDAEventTrace, EDARunTrace, makeEDARunTrace, makeRootEDAEventTrace } from "./types/tracing.js";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
7
|
+
//#region src/types/events/envelope.ts
|
|
8
|
+
/** Event namespace, such as `effect-durable-agent`, `sandbox`, or `gia`. */
|
|
9
|
+
const EventNamespace = Schema.NonEmptyString;
|
|
10
|
+
/** Event type within a namespace, such as `CommandAdmitted` or `TextDelta`. */
|
|
11
|
+
const EventType = Schema.NonEmptyString;
|
|
12
|
+
/** Build a non-empty event type while preserving its string literal for exhaustive unions. */
|
|
13
|
+
const makeEventType = (value) => value;
|
|
14
|
+
/** Provider-supplied stream part identity, preserved for correlation/debugging. */
|
|
15
|
+
const ProviderPartId = Schema.NonEmptyString.pipe(Schema.brand("ProviderPartId"));
|
|
16
|
+
/** Positive schema version for one namespace/type payload contract. */
|
|
17
|
+
const SchemaVersion = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
18
|
+
/** Milliseconds since unix epoch, represented as a non-negative integer. */
|
|
19
|
+
const UnixEpochMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("UnixEpochMillis"));
|
|
20
|
+
/** Whether an event is persisted or live-only. */
|
|
21
|
+
const EventDurability = Schema.Literals(["durable", "ephemeral"]);
|
|
22
|
+
/** Common event envelope decoded before payload-specific schemas. */
|
|
23
|
+
const EventEnvelope = Schema.Struct({
|
|
24
|
+
namespace: EventNamespace,
|
|
25
|
+
type: EventType,
|
|
26
|
+
schemaVersion: SchemaVersion,
|
|
27
|
+
durability: EventDurability,
|
|
28
|
+
eventId: EventId,
|
|
29
|
+
sessionId: SessionId,
|
|
30
|
+
correlationId: Schema.optionalKey(CorrelationId),
|
|
31
|
+
createdAtMs: UnixEpochMillis,
|
|
32
|
+
trace: EDAEventTrace.pipe(Schema.withConstructorDefault(Effect.sync(makeRootEDAEventTrace))),
|
|
33
|
+
payload: Schema.Unknown
|
|
34
|
+
});
|
|
35
|
+
/** Common envelope narrowed to committed durable events. */
|
|
36
|
+
const DurableEventEnvelope = Schema.Struct({
|
|
37
|
+
...EventEnvelope.fields,
|
|
38
|
+
durability: Schema.Literal("durable")
|
|
39
|
+
});
|
|
40
|
+
/** Common envelope narrowed to live-only ephemeral events. */
|
|
41
|
+
const EphemeralEventEnvelope = Schema.Struct({
|
|
42
|
+
...EventEnvelope.fields,
|
|
43
|
+
durability: Schema.Literal("ephemeral")
|
|
44
|
+
});
|
|
45
|
+
/** Event delivered to live subscribers with its durable/ephemeral position. */
|
|
46
|
+
const PositionedEvent = Schema.Struct({
|
|
47
|
+
position: Position,
|
|
48
|
+
event: EventEnvelope
|
|
49
|
+
});
|
|
50
|
+
/** Built-in framework event namespace. */
|
|
51
|
+
const effectDurableAgentNamespace = EventNamespace.make("effect-durable-agent");
|
|
52
|
+
/** Initial schema version for built-in event payloads. */
|
|
53
|
+
const schemaV1 = SchemaVersion.make(1);
|
|
54
|
+
/** Non-negative integer used by token counts and similar counters. */
|
|
55
|
+
const NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
56
|
+
/** Registered tool name; plain non-empty text, not a lifecycle identity. */
|
|
57
|
+
const ToolName = Schema.NonEmptyString;
|
|
58
|
+
/** Error details stored on failed lifecycle events. */
|
|
59
|
+
const FailurePayload = Schema.Struct({
|
|
60
|
+
message: Schema.String,
|
|
61
|
+
code: Schema.optionalKey(Schema.String),
|
|
62
|
+
details: Schema.optionalKey(Schema.Unknown)
|
|
63
|
+
});
|
|
64
|
+
/** Token usage reported by a model provider when available. */
|
|
65
|
+
const UsagePayload = Schema.Struct({
|
|
66
|
+
inputTokens: Schema.optionalKey(NonNegativeInt),
|
|
67
|
+
cachedInputTokens: Schema.optionalKey(NonNegativeInt),
|
|
68
|
+
outputTokens: Schema.optionalKey(NonNegativeInt),
|
|
69
|
+
textTokens: Schema.optionalKey(NonNegativeInt),
|
|
70
|
+
reasoningTokens: Schema.optionalKey(NonNegativeInt)
|
|
71
|
+
});
|
|
72
|
+
/** Intended provider/model selection known before a model request starts. */
|
|
73
|
+
const ModelSelectionPayload = Schema.Struct({
|
|
74
|
+
provider: Schema.NonEmptyString,
|
|
75
|
+
modelId: Schema.NonEmptyString,
|
|
76
|
+
settings: Schema.optionalKey(Schema.Unknown)
|
|
77
|
+
});
|
|
78
|
+
/** App-owned instructions inserted into model context as a system message. */
|
|
79
|
+
const SystemPromptText = Schema.NonEmptyString;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/types/events/internal.ts
|
|
82
|
+
/** Build a built-in durable event schema from its fixed event type and payload schema. */
|
|
83
|
+
const durableEventSchema = (type, payload) => Schema.Struct({
|
|
84
|
+
...DurableEventEnvelope.fields,
|
|
85
|
+
namespace: Schema.Literal(effectDurableAgentNamespace),
|
|
86
|
+
type: Schema.Literal(type),
|
|
87
|
+
schemaVersion: Schema.Literal(schemaV1),
|
|
88
|
+
payload
|
|
89
|
+
});
|
|
90
|
+
/** Build a built-in ephemeral event schema from its fixed event type and payload schema. */
|
|
91
|
+
const ephemeralEventSchema = (type, payload) => Schema.Struct({
|
|
92
|
+
...EphemeralEventEnvelope.fields,
|
|
93
|
+
namespace: Schema.Literal(effectDurableAgentNamespace),
|
|
94
|
+
type: Schema.Literal(type),
|
|
95
|
+
schemaVersion: Schema.Literal(schemaV1),
|
|
96
|
+
payload
|
|
97
|
+
});
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/types/events/durable.ts
|
|
100
|
+
/** Event type values for durable command lifecycle events. */
|
|
101
|
+
const commandAdmittedEventType = makeEventType("CommandAdmitted");
|
|
102
|
+
const commandStartedEventType = makeEventType("CommandStarted");
|
|
103
|
+
const commandCompletedEventType = makeEventType("CommandCompleted");
|
|
104
|
+
const commandFailedEventType = makeEventType("CommandFailed");
|
|
105
|
+
const commandCancelledEventType = makeEventType("CommandCancelled");
|
|
106
|
+
/** Payload recorded when a command enters the durable session log. */
|
|
107
|
+
const CommandAdmittedPayload = Schema.Struct({ command: EDACommand });
|
|
108
|
+
const CommandAdmittedEvent = durableEventSchema(commandAdmittedEventType, CommandAdmittedPayload);
|
|
109
|
+
/** Payload recorded when command execution starts. */
|
|
110
|
+
const CommandStartedPayload = Schema.Struct({ commandId: CommandId });
|
|
111
|
+
const CommandStartedEvent = durableEventSchema(commandStartedEventType, CommandStartedPayload);
|
|
112
|
+
/** Payload recorded when command execution completes normally. */
|
|
113
|
+
const CommandCompletedPayload = Schema.Struct({ commandId: CommandId });
|
|
114
|
+
const CommandCompletedEvent = durableEventSchema(commandCompletedEventType, CommandCompletedPayload);
|
|
115
|
+
/** Payload recorded when command execution fails. */
|
|
116
|
+
const CommandFailedPayload = Schema.Struct({
|
|
117
|
+
commandId: CommandId,
|
|
118
|
+
error: FailurePayload
|
|
119
|
+
});
|
|
120
|
+
const CommandFailedEvent = durableEventSchema(commandFailedEventType, CommandFailedPayload);
|
|
121
|
+
/** Payload recorded when a command is cancelled before completion. */
|
|
122
|
+
const CommandCancelledPayload = Schema.Struct({
|
|
123
|
+
commandId: CommandId,
|
|
124
|
+
reason: Schema.String
|
|
125
|
+
});
|
|
126
|
+
const CommandCancelledEvent = durableEventSchema(commandCancelledEventType, CommandCancelledPayload);
|
|
127
|
+
/** Durable event union for the command lifecycle. */
|
|
128
|
+
const CommandEvent = Schema.Union([
|
|
129
|
+
CommandAdmittedEvent,
|
|
130
|
+
CommandStartedEvent,
|
|
131
|
+
CommandCompletedEvent,
|
|
132
|
+
CommandFailedEvent,
|
|
133
|
+
CommandCancelledEvent
|
|
134
|
+
]);
|
|
135
|
+
/** Event type values for durable message lifecycle events. */
|
|
136
|
+
const systemMessageCommittedEventType = makeEventType("SystemMessageCommitted");
|
|
137
|
+
const userMessageCommittedEventType = makeEventType("UserMessageCommitted");
|
|
138
|
+
const steeringMessageQueuedEventType = makeEventType("SteeringMessageQueued");
|
|
139
|
+
const steeringMessageCancelledEventType = makeEventType("SteeringMessageCancelled");
|
|
140
|
+
const userMessageSubmittedEventType = makeEventType("UserMessageSubmitted");
|
|
141
|
+
const userMessagePromotedEventType = makeEventType("UserMessagePromoted");
|
|
142
|
+
const userMessageCancelledEventType = makeEventType("UserMessageCancelled");
|
|
143
|
+
const messageQueuePausedEventType = makeEventType("MessageQueuePaused");
|
|
144
|
+
const pendingMessagesPausedEventType = makeEventType("PendingMessagesPaused");
|
|
145
|
+
const assistantMessageCommittedEventType = makeEventType("AssistantMessageCommitted");
|
|
146
|
+
const assistantPartialCommittedEventType = makeEventType("AssistantPartialCommitted");
|
|
147
|
+
/** Semantic assistant content derived from canonical prompt parts for query convenience. */
|
|
148
|
+
const AssistantMessageContent = Schema.Struct({
|
|
149
|
+
text: Schema.String,
|
|
150
|
+
reasoning: Schema.optionalKey(Schema.String)
|
|
151
|
+
});
|
|
152
|
+
/** Exact assistant-role prompt parts sent to the model for cache-faithful replay. */
|
|
153
|
+
const AssistantPromptPart = Schema.Union([
|
|
154
|
+
Prompt.TextPart,
|
|
155
|
+
Prompt.FilePart,
|
|
156
|
+
Prompt.ReasoningPart,
|
|
157
|
+
Prompt.ToolCallPart,
|
|
158
|
+
Prompt.ToolResultPart,
|
|
159
|
+
Prompt.ToolApprovalRequestPart
|
|
160
|
+
]);
|
|
161
|
+
/** Exact non-empty assistant-role prompt content sent to the model. */
|
|
162
|
+
const AssistantPromptParts = Schema.NonEmptyArray(AssistantPromptPart);
|
|
163
|
+
/** Exact assistant tool-call prompt part with EDA-branded provider identity. */
|
|
164
|
+
const ToolCallPromptPart = Schema.Struct({
|
|
165
|
+
...Prompt.ToolCallPart.fields,
|
|
166
|
+
id: ProviderPartId,
|
|
167
|
+
name: ToolName
|
|
168
|
+
});
|
|
169
|
+
/** Exact tool-role prompt part sent to the model with EDA-branded provider identity. */
|
|
170
|
+
const ToolPromptPart = Schema.Struct({
|
|
171
|
+
...Prompt.ToolResultPart.fields,
|
|
172
|
+
id: ProviderPartId,
|
|
173
|
+
name: ToolName
|
|
174
|
+
});
|
|
175
|
+
/** Payload recorded when app instructions become durable system-message context. */
|
|
176
|
+
const SystemMessageCommittedPayload = Schema.Struct({
|
|
177
|
+
messageId: MessageId,
|
|
178
|
+
content: SystemPromptText
|
|
179
|
+
});
|
|
180
|
+
const SystemMessageCommittedEvent = durableEventSchema(systemMessageCommittedEventType, SystemMessageCommittedPayload);
|
|
181
|
+
/** Payload recorded when a user message becomes durable session context. */
|
|
182
|
+
const UserMessageCommittedPayload = Schema.Struct({
|
|
183
|
+
commandId: CommandId,
|
|
184
|
+
messageId: MessageId,
|
|
185
|
+
content: UserMessageContent
|
|
186
|
+
});
|
|
187
|
+
const UserMessageCommittedEvent = durableEventSchema(userMessageCommittedEventType, UserMessageCommittedPayload);
|
|
188
|
+
/** Payload recorded when steering context is queued for a future turn. */
|
|
189
|
+
const SteeringMessageQueuedPayload = Schema.Struct({
|
|
190
|
+
commandId: CommandId,
|
|
191
|
+
messageId: MessageId,
|
|
192
|
+
runId: RunId,
|
|
193
|
+
content: UserMessageContent
|
|
194
|
+
});
|
|
195
|
+
const SteeringMessageQueuedEvent = durableEventSchema(steeringMessageQueuedEventType, SteeringMessageQueuedPayload);
|
|
196
|
+
/** Payload recorded when queued steering will never be consumed by its target run. */
|
|
197
|
+
const SteeringMessageCancelledPayload = Schema.Struct({
|
|
198
|
+
messageId: MessageId,
|
|
199
|
+
runId: RunId,
|
|
200
|
+
reason: Schema.String
|
|
201
|
+
});
|
|
202
|
+
const SteeringMessageCancelledEvent = durableEventSchema(steeringMessageCancelledEventType, SteeringMessageCancelledPayload);
|
|
203
|
+
const UserMessageDisposition = Schema.Literals(["queue", "steer"]);
|
|
204
|
+
const UserMessageSubmittedPayload = Schema.Struct({
|
|
205
|
+
commandId: CommandId,
|
|
206
|
+
messageId: MessageId,
|
|
207
|
+
disposition: UserMessageDisposition,
|
|
208
|
+
content: UserMessageContent
|
|
209
|
+
});
|
|
210
|
+
const UserMessageSubmittedEvent = durableEventSchema(userMessageSubmittedEventType, UserMessageSubmittedPayload);
|
|
211
|
+
const UserMessagePromotedPayload = Schema.Struct({
|
|
212
|
+
commandId: CommandId,
|
|
213
|
+
messageId: MessageId,
|
|
214
|
+
from: Schema.Literal("queue"),
|
|
215
|
+
to: Schema.Literal("steer")
|
|
216
|
+
});
|
|
217
|
+
const UserMessagePromotedEvent = durableEventSchema(userMessagePromotedEventType, UserMessagePromotedPayload);
|
|
218
|
+
const UserMessageCancellationReason = Schema.Literals([
|
|
219
|
+
"edit",
|
|
220
|
+
"user-cancel",
|
|
221
|
+
"clear-paused-queue"
|
|
222
|
+
]);
|
|
223
|
+
const UserMessageCancelledPayload = Schema.Struct({
|
|
224
|
+
commandId: CommandId,
|
|
225
|
+
messageId: MessageId,
|
|
226
|
+
reason: UserMessageCancellationReason
|
|
227
|
+
});
|
|
228
|
+
const UserMessageCancelledEvent = durableEventSchema(userMessageCancelledEventType, UserMessageCancelledPayload);
|
|
229
|
+
/** Legacy V1 pause fact retained for replay compatibility. */
|
|
230
|
+
const MessageQueuePausedPayload = Schema.Struct({
|
|
231
|
+
stopCommandId: CommandId,
|
|
232
|
+
runId: RunId,
|
|
233
|
+
messageIds: Schema.Array(MessageId),
|
|
234
|
+
reason: Schema.Literal("user-interrupted")
|
|
235
|
+
});
|
|
236
|
+
const MessageQueuePausedEvent = durableEventSchema(messageQueuePausedEventType, MessageQueuePausedPayload);
|
|
237
|
+
const PendingMessagesPausedPayload = Schema.Struct({
|
|
238
|
+
interruptionCommandId: CommandId,
|
|
239
|
+
runId: RunId,
|
|
240
|
+
messageIds: Schema.NonEmptyArray(MessageId),
|
|
241
|
+
reason: Schema.Literal("user-interrupted")
|
|
242
|
+
});
|
|
243
|
+
const PendingMessagesPausedEvent = durableEventSchema(pendingMessagesPausedEventType, PendingMessagesPausedPayload);
|
|
244
|
+
/** Payload recorded when an assistant message is durably finalized. */
|
|
245
|
+
const AssistantMessageCommittedPayload = Schema.Struct({
|
|
246
|
+
messageId: MessageId,
|
|
247
|
+
runId: RunId,
|
|
248
|
+
turnId: TurnId,
|
|
249
|
+
inferenceId: InferenceId,
|
|
250
|
+
promptParts: AssistantPromptParts
|
|
251
|
+
});
|
|
252
|
+
const AssistantMessageCommittedEvent = durableEventSchema(assistantMessageCommittedEventType, AssistantMessageCommittedPayload);
|
|
253
|
+
/** Payload recorded when a partial assistant message is preserved durably. */
|
|
254
|
+
const AssistantPartialCommittedPayload = Schema.Struct({
|
|
255
|
+
messageId: MessageId,
|
|
256
|
+
runId: RunId,
|
|
257
|
+
turnId: TurnId,
|
|
258
|
+
inferenceId: InferenceId,
|
|
259
|
+
promptParts: AssistantPromptParts,
|
|
260
|
+
reason: Schema.String
|
|
261
|
+
});
|
|
262
|
+
const AssistantPartialCommittedEvent = durableEventSchema(assistantPartialCommittedEventType, AssistantPartialCommittedPayload);
|
|
263
|
+
/** Durable event union for message commit/queue boundaries. */
|
|
264
|
+
const MessageEvent = Schema.Union([
|
|
265
|
+
SystemMessageCommittedEvent,
|
|
266
|
+
UserMessageCommittedEvent,
|
|
267
|
+
SteeringMessageQueuedEvent,
|
|
268
|
+
SteeringMessageCancelledEvent,
|
|
269
|
+
UserMessageSubmittedEvent,
|
|
270
|
+
UserMessagePromotedEvent,
|
|
271
|
+
UserMessageCancelledEvent,
|
|
272
|
+
MessageQueuePausedEvent,
|
|
273
|
+
PendingMessagesPausedEvent,
|
|
274
|
+
AssistantMessageCommittedEvent,
|
|
275
|
+
AssistantPartialCommittedEvent
|
|
276
|
+
]);
|
|
277
|
+
/** Event type values for durable run lifecycle events. */
|
|
278
|
+
const runStartedEventType = makeEventType("RunStarted");
|
|
279
|
+
const runCompletedEventType = makeEventType("RunCompleted");
|
|
280
|
+
const runFailedEventType = makeEventType("RunFailed");
|
|
281
|
+
/** @deprecated Legacy terminal retained for durable replay. Emit `RunFailed` with an interruption-coded `FailurePayload` instead. */
|
|
282
|
+
const runInterruptedEventType = makeEventType("RunInterrupted");
|
|
283
|
+
/** Payload recorded when a run starts with its intended model selection. */
|
|
284
|
+
const RunStartedPayload = Schema.Struct({
|
|
285
|
+
runId: RunId,
|
|
286
|
+
commandIds: Schema.Array(CommandId),
|
|
287
|
+
modelSelection: ModelSelectionPayload,
|
|
288
|
+
trace: EDARunTrace.pipe(Schema.withConstructorDefault(Effect.sync(() => makeEDARunTrace())))
|
|
289
|
+
});
|
|
290
|
+
const RunStartedEvent = durableEventSchema(runStartedEventType, RunStartedPayload);
|
|
291
|
+
/** Payload recorded when a run completes. */
|
|
292
|
+
const RunCompletedPayload = Schema.Struct({ runId: RunId });
|
|
293
|
+
const RunCompletedEvent = durableEventSchema(runCompletedEventType, RunCompletedPayload);
|
|
294
|
+
/** Payload recorded when a run fails. */
|
|
295
|
+
const RunFailedPayload = Schema.Struct({
|
|
296
|
+
runId: RunId,
|
|
297
|
+
error: FailurePayload
|
|
298
|
+
});
|
|
299
|
+
const RunFailedEvent = durableEventSchema(runFailedEventType, RunFailedPayload);
|
|
300
|
+
/** @deprecated Legacy payload retained for durable replay. New interruptions use `RunFailedPayload` with `error.code = "run.interrupted"`. */
|
|
301
|
+
const RunInterruptedPayload = Schema.Struct({
|
|
302
|
+
runId: RunId,
|
|
303
|
+
reason: Schema.String
|
|
304
|
+
});
|
|
305
|
+
/** @deprecated Legacy event schema retained for durable replay; new producers emit `RunFailedEvent`. */
|
|
306
|
+
const RunInterruptedEvent = durableEventSchema(runInterruptedEventType, RunInterruptedPayload);
|
|
307
|
+
/** Durable event union for run lifecycle boundaries. */
|
|
308
|
+
const RunEvent = Schema.Union([
|
|
309
|
+
RunStartedEvent,
|
|
310
|
+
RunCompletedEvent,
|
|
311
|
+
RunFailedEvent,
|
|
312
|
+
RunInterruptedEvent
|
|
313
|
+
]);
|
|
314
|
+
/** Event type value for the durable barrier written after real startup recovery work. */
|
|
315
|
+
const recoveryCompletedEventType = makeEventType("RecoveryCompleted");
|
|
316
|
+
/** Explicit relationship between an interrupted run and its startup-recovery replacement. */
|
|
317
|
+
const RecoveryContinuation = Schema.Struct({
|
|
318
|
+
commandId: CommandId,
|
|
319
|
+
interruptedRunId: RunId,
|
|
320
|
+
replacementRunId: RunId
|
|
321
|
+
});
|
|
322
|
+
/**
|
|
323
|
+
* Durable completion barrier for a startup recovery transaction that repaired
|
|
324
|
+
* unfinished state. Idle runtime construction does not emit this event.
|
|
325
|
+
*/
|
|
326
|
+
const RecoveryCompletedPayload = Schema.Struct({
|
|
327
|
+
trigger: Schema.Literal("runtime-restart"),
|
|
328
|
+
continuation: Schema.optionalKey(RecoveryContinuation)
|
|
329
|
+
});
|
|
330
|
+
const RecoveryCompletedEvent = durableEventSchema(recoveryCompletedEventType, RecoveryCompletedPayload);
|
|
331
|
+
/** Durable facts written only by the framework startup-recovery transaction. */
|
|
332
|
+
const RecoveryEvent = RecoveryCompletedEvent;
|
|
333
|
+
/** Event type values for durable turn lifecycle events. */
|
|
334
|
+
const turnStartedEventType = makeEventType("TurnStarted");
|
|
335
|
+
const turnCompletedEventType = makeEventType("TurnCompleted");
|
|
336
|
+
const turnFailedEventType = makeEventType("TurnFailed");
|
|
337
|
+
/** @deprecated Legacy terminal retained for durable replay. Emit `TurnFailed` with an interruption-coded `FailurePayload` instead. */
|
|
338
|
+
const turnStoppedEventType = makeEventType("TurnStopped");
|
|
339
|
+
/** Payload recorded when one turn starts inside a run. */
|
|
340
|
+
const TurnStartedPayload = Schema.Struct({
|
|
341
|
+
runId: RunId,
|
|
342
|
+
turnId: TurnId,
|
|
343
|
+
inputMessageIds: Schema.optionalKey(Schema.Array(MessageId))
|
|
344
|
+
});
|
|
345
|
+
const TurnStartedEvent = durableEventSchema(turnStartedEventType, TurnStartedPayload);
|
|
346
|
+
/** Payload recorded when one turn completes. */
|
|
347
|
+
const TurnCompletedPayload = Schema.Struct({
|
|
348
|
+
runId: RunId,
|
|
349
|
+
turnId: TurnId,
|
|
350
|
+
usage: Schema.optionalKey(UsagePayload)
|
|
351
|
+
});
|
|
352
|
+
const TurnCompletedEvent = durableEventSchema(turnCompletedEventType, TurnCompletedPayload);
|
|
353
|
+
/** Payload recorded when one turn fails. */
|
|
354
|
+
const TurnFailedPayload = Schema.Struct({
|
|
355
|
+
runId: RunId,
|
|
356
|
+
turnId: TurnId,
|
|
357
|
+
error: FailurePayload
|
|
358
|
+
});
|
|
359
|
+
const TurnFailedEvent = durableEventSchema(turnFailedEventType, TurnFailedPayload);
|
|
360
|
+
/** @deprecated Legacy payload retained for durable replay. New stops use `TurnFailedPayload` with `error.code = "turn.interrupted"`. */
|
|
361
|
+
const TurnStoppedPayload = Schema.Struct({
|
|
362
|
+
runId: RunId,
|
|
363
|
+
turnId: TurnId,
|
|
364
|
+
reason: Schema.String
|
|
365
|
+
});
|
|
366
|
+
/** @deprecated Legacy event schema retained for durable replay; new producers emit `TurnFailedEvent`. */
|
|
367
|
+
const TurnStoppedEvent = durableEventSchema(turnStoppedEventType, TurnStoppedPayload);
|
|
368
|
+
/** Durable event union for turn lifecycle boundaries. */
|
|
369
|
+
const TurnEvent = Schema.Union([
|
|
370
|
+
TurnStartedEvent,
|
|
371
|
+
TurnCompletedEvent,
|
|
372
|
+
TurnFailedEvent,
|
|
373
|
+
TurnStoppedEvent
|
|
374
|
+
]);
|
|
375
|
+
/** Event type values for durable model-inference lifecycle events. */
|
|
376
|
+
const inferenceStartedEventType = makeEventType("InferenceStarted");
|
|
377
|
+
const inferenceCompletedEventType = makeEventType("InferenceCompleted");
|
|
378
|
+
const inferenceFailedEventType = makeEventType("InferenceFailed");
|
|
379
|
+
/** Payload recorded when one model inference starts for a turn. */
|
|
380
|
+
const InferenceStartedPayload = Schema.Struct({
|
|
381
|
+
runId: RunId,
|
|
382
|
+
turnId: TurnId,
|
|
383
|
+
inferenceId: InferenceId
|
|
384
|
+
});
|
|
385
|
+
const InferenceStartedEvent = durableEventSchema(inferenceStartedEventType, InferenceStartedPayload);
|
|
386
|
+
/** Payload recorded when one model inference completes. */
|
|
387
|
+
const InferenceCompletedPayload = Schema.Struct({
|
|
388
|
+
runId: RunId,
|
|
389
|
+
turnId: TurnId,
|
|
390
|
+
inferenceId: InferenceId,
|
|
391
|
+
finishReason: Schema.optionalKey(Schema.String),
|
|
392
|
+
usage: Schema.optionalKey(UsagePayload),
|
|
393
|
+
responseMetadata: Schema.optionalKey(Schema.Unknown),
|
|
394
|
+
finishMetadata: Schema.optionalKey(Schema.Unknown)
|
|
395
|
+
});
|
|
396
|
+
const InferenceCompletedEvent = durableEventSchema(inferenceCompletedEventType, InferenceCompletedPayload);
|
|
397
|
+
/** Payload recorded when one model inference fails or is interrupted. */
|
|
398
|
+
const InferenceFailedPayload = Schema.Struct({
|
|
399
|
+
runId: RunId,
|
|
400
|
+
turnId: TurnId,
|
|
401
|
+
inferenceId: InferenceId,
|
|
402
|
+
error: FailurePayload
|
|
403
|
+
});
|
|
404
|
+
const InferenceFailedEvent = durableEventSchema(inferenceFailedEventType, InferenceFailedPayload);
|
|
405
|
+
/** Durable event union for canonical model-inference lifecycle boundaries. */
|
|
406
|
+
const InferenceEvent = Schema.Union([
|
|
407
|
+
InferenceStartedEvent,
|
|
408
|
+
InferenceCompletedEvent,
|
|
409
|
+
InferenceFailedEvent
|
|
410
|
+
]);
|
|
411
|
+
/** Event type values for durable tool lifecycle events. */
|
|
412
|
+
const toolCallCreatedEventType = makeEventType("ToolCallCreated");
|
|
413
|
+
const toolCallRejectedEventType = makeEventType("ToolCallRejected");
|
|
414
|
+
const toolCallStartedEventType = makeEventType("ToolCallStarted");
|
|
415
|
+
const toolCallCompletedEventType = makeEventType("ToolCallCompleted");
|
|
416
|
+
const toolCallFailedEventType = makeEventType("ToolCallFailed");
|
|
417
|
+
/** Reason a model-requested tool call was rejected before execution. */
|
|
418
|
+
const ToolCallRejectionReason = Schema.Literals(["unknown-tool", "invalid-params"]);
|
|
419
|
+
/** Exact synthetic tool-result feedback for a rejected model-requested tool call. */
|
|
420
|
+
const ToolCallRejectionFeedback = Schema.Struct({
|
|
421
|
+
message: Schema.String,
|
|
422
|
+
reason: ToolCallRejectionReason,
|
|
423
|
+
modelFeedback: Schema.NonEmptyString
|
|
424
|
+
});
|
|
425
|
+
/** Exact prompt part for a rejected model-requested tool call. */
|
|
426
|
+
const ToolRejectionPromptPart = Schema.Struct({
|
|
427
|
+
...ToolPromptPart.fields,
|
|
428
|
+
isFailure: Schema.Literal(true),
|
|
429
|
+
result: ToolCallRejectionFeedback
|
|
430
|
+
});
|
|
431
|
+
/** Exact prompt part for a successful framework-owned tool result. */
|
|
432
|
+
const ToolSuccessPromptPart = Schema.Struct({
|
|
433
|
+
...ToolPromptPart.fields,
|
|
434
|
+
isFailure: Schema.Literal(false),
|
|
435
|
+
result: Schema.Unknown
|
|
436
|
+
});
|
|
437
|
+
/** Exact prompt part for a failed framework-owned tool result. */
|
|
438
|
+
const ToolFailurePromptPart = Schema.Struct({
|
|
439
|
+
...ToolPromptPart.fields,
|
|
440
|
+
isFailure: Schema.Literal(true),
|
|
441
|
+
result: FailurePayload
|
|
442
|
+
});
|
|
443
|
+
/** Payload recorded once streamed tool parameters validate and become executable. */
|
|
444
|
+
const ToolCallCreatedPayload = Schema.Struct({
|
|
445
|
+
runId: RunId,
|
|
446
|
+
turnId: TurnId,
|
|
447
|
+
inferenceId: InferenceId,
|
|
448
|
+
toolCallId: ToolCallId,
|
|
449
|
+
promptPart: ToolCallPromptPart
|
|
450
|
+
});
|
|
451
|
+
const ToolCallCreatedEvent = durableEventSchema(toolCallCreatedEventType, ToolCallCreatedPayload);
|
|
452
|
+
/** Payload recorded when a model-requested tool call is not executable. */
|
|
453
|
+
const ToolCallRejectedPayload = Schema.Struct({
|
|
454
|
+
runId: RunId,
|
|
455
|
+
turnId: TurnId,
|
|
456
|
+
inferenceId: InferenceId,
|
|
457
|
+
toolCallId: ToolCallId,
|
|
458
|
+
promptPart: ToolRejectionPromptPart
|
|
459
|
+
});
|
|
460
|
+
const ToolCallRejectedEvent = durableEventSchema(toolCallRejectedEventType, ToolCallRejectedPayload);
|
|
461
|
+
/** Payload recorded when framework-owned tool execution starts. */
|
|
462
|
+
const ToolCallStartedPayload = Schema.Struct({ toolCallId: ToolCallId });
|
|
463
|
+
const ToolCallStartedEvent = durableEventSchema(toolCallStartedEventType, ToolCallStartedPayload);
|
|
464
|
+
/** Payload recorded when a tool call completes with a result. */
|
|
465
|
+
const ToolCallCompletedPayload = Schema.Struct({
|
|
466
|
+
toolCallId: ToolCallId,
|
|
467
|
+
promptPart: ToolSuccessPromptPart
|
|
468
|
+
});
|
|
469
|
+
const ToolCallCompletedEvent = durableEventSchema(toolCallCompletedEventType, ToolCallCompletedPayload);
|
|
470
|
+
/** Payload recorded when a tool call fails. */
|
|
471
|
+
const ToolCallFailedPayload = Schema.Struct({
|
|
472
|
+
toolCallId: ToolCallId,
|
|
473
|
+
error: Schema.optionalKey(FailurePayload),
|
|
474
|
+
promptPart: ToolFailurePromptPart
|
|
475
|
+
});
|
|
476
|
+
const ToolCallFailedEvent = durableEventSchema(toolCallFailedEventType, ToolCallFailedPayload);
|
|
477
|
+
/** Durable event union for tool lifecycle boundaries. */
|
|
478
|
+
const ToolCallEvent = Schema.Union([
|
|
479
|
+
ToolCallCreatedEvent,
|
|
480
|
+
ToolCallRejectedEvent,
|
|
481
|
+
ToolCallStartedEvent,
|
|
482
|
+
ToolCallCompletedEvent,
|
|
483
|
+
ToolCallFailedEvent
|
|
484
|
+
]);
|
|
485
|
+
/** Event type values for durable stop-control events. */
|
|
486
|
+
const stopTurnRequestedEventType = makeEventType("StopTurnRequested");
|
|
487
|
+
const stopTurnAppliedEventType = makeEventType("StopTurnApplied");
|
|
488
|
+
/** Payload recorded when a stop command targets active or future turn work. */
|
|
489
|
+
const StopTurnRequestedPayload = Schema.Struct({
|
|
490
|
+
commandId: CommandId,
|
|
491
|
+
runId: Schema.optionalKey(RunId),
|
|
492
|
+
turnId: Schema.optionalKey(TurnId)
|
|
493
|
+
});
|
|
494
|
+
const StopTurnRequestedEvent = durableEventSchema(stopTurnRequestedEventType, StopTurnRequestedPayload);
|
|
495
|
+
/** Payload recorded when a stop request has affected runtime work. */
|
|
496
|
+
const StopTurnAppliedPayload = Schema.Struct({
|
|
497
|
+
commandId: CommandId,
|
|
498
|
+
runId: RunId,
|
|
499
|
+
turnId: TurnId,
|
|
500
|
+
inferenceId: Schema.optionalKey(InferenceId)
|
|
501
|
+
});
|
|
502
|
+
const StopTurnAppliedEvent = durableEventSchema(stopTurnAppliedEventType, StopTurnAppliedPayload);
|
|
503
|
+
/** Durable event union for stop-request lifecycle boundaries. */
|
|
504
|
+
const StopControlEvent = Schema.Union([StopTurnRequestedEvent, StopTurnAppliedEvent]);
|
|
505
|
+
/** Event type values for durable context and compaction events. */
|
|
506
|
+
const contextProjectedEventType = makeEventType("ContextProjected");
|
|
507
|
+
const compactionRequestedEventType = makeEventType("CompactionRequested");
|
|
508
|
+
const compactionStartedEventType = makeEventType("CompactionStarted");
|
|
509
|
+
const summaryCreatedEventType = makeEventType("SummaryCreated");
|
|
510
|
+
const compactionCompletedEventType = makeEventType("CompactionCompleted");
|
|
511
|
+
const contextRebasedEventType = makeEventType("ContextRebased");
|
|
512
|
+
const compactionFailedEventType = makeEventType("CompactionFailed");
|
|
513
|
+
/** Payload recorded when the prompt context projection advances. */
|
|
514
|
+
const ContextProjectedPayload = Schema.Struct({
|
|
515
|
+
contextVersion: ContextVersion,
|
|
516
|
+
throughSeq: SequenceNumber
|
|
517
|
+
});
|
|
518
|
+
const ContextProjectedEvent = durableEventSchema(contextProjectedEventType, ContextProjectedPayload);
|
|
519
|
+
/** Payload recorded when compaction is requested for a durable range. */
|
|
520
|
+
const CompactionRequestedPayload = Schema.Struct({
|
|
521
|
+
compactionId: CompactionId,
|
|
522
|
+
sourceFromSeq: SequenceNumber,
|
|
523
|
+
sourceToSeq: SequenceNumber
|
|
524
|
+
});
|
|
525
|
+
const CompactionRequestedEvent = durableEventSchema(compactionRequestedEventType, CompactionRequestedPayload);
|
|
526
|
+
/** Payload recorded when compaction starts. */
|
|
527
|
+
const CompactionStartedPayload = Schema.Struct({ compactionId: CompactionId });
|
|
528
|
+
const CompactionStartedEvent = durableEventSchema(compactionStartedEventType, CompactionStartedPayload);
|
|
529
|
+
/** Payload recorded when a summary artifact is created. */
|
|
530
|
+
const SummaryCreatedPayload = Schema.Struct({
|
|
531
|
+
compactionId: CompactionId,
|
|
532
|
+
summaryId: SummaryId,
|
|
533
|
+
sourceFromSeq: SequenceNumber,
|
|
534
|
+
sourceToSeq: SequenceNumber,
|
|
535
|
+
summary: Schema.Unknown
|
|
536
|
+
});
|
|
537
|
+
const SummaryCreatedEvent = durableEventSchema(summaryCreatedEventType, SummaryCreatedPayload);
|
|
538
|
+
/** Payload recorded when compaction completes. */
|
|
539
|
+
const CompactionCompletedPayload = Schema.Struct({ compactionId: CompactionId });
|
|
540
|
+
const CompactionCompletedEvent = durableEventSchema(compactionCompletedEventType, CompactionCompletedPayload);
|
|
541
|
+
/** Payload recorded when durable context is rebased onto a summary. */
|
|
542
|
+
const ContextRebasedPayload = Schema.Struct({
|
|
543
|
+
compactionId: CompactionId,
|
|
544
|
+
summaryId: SummaryId,
|
|
545
|
+
contextVersion: ContextVersion,
|
|
546
|
+
retainedFromContextSeq: SequenceNumber
|
|
547
|
+
});
|
|
548
|
+
const ContextRebasedEvent = durableEventSchema(contextRebasedEventType, ContextRebasedPayload);
|
|
549
|
+
/** Payload recorded when compaction fails. */
|
|
550
|
+
const CompactionFailedPayload = Schema.Struct({
|
|
551
|
+
compactionId: CompactionId,
|
|
552
|
+
error: FailurePayload
|
|
553
|
+
});
|
|
554
|
+
const CompactionFailedEvent = durableEventSchema(compactionFailedEventType, CompactionFailedPayload);
|
|
555
|
+
/** Durable event union for context projection and compaction boundaries. */
|
|
556
|
+
const ContextAndCompactionEvent = Schema.Union([
|
|
557
|
+
ContextProjectedEvent,
|
|
558
|
+
CompactionRequestedEvent,
|
|
559
|
+
CompactionStartedEvent,
|
|
560
|
+
SummaryCreatedEvent,
|
|
561
|
+
CompactionCompletedEvent,
|
|
562
|
+
ContextRebasedEvent,
|
|
563
|
+
CompactionFailedEvent
|
|
564
|
+
]);
|
|
565
|
+
/** Event type values for durable BaseState lifecycle events. */
|
|
566
|
+
const baseStateRequestedEventType = makeEventType("BaseStateRequested");
|
|
567
|
+
const baseStateCreatedEventType = makeEventType("BaseStateCreated");
|
|
568
|
+
const baseStateFailedEventType = makeEventType("BaseStateFailed");
|
|
569
|
+
/** Payload recorded when durable BaseState generation is requested. */
|
|
570
|
+
const BaseStateRequestedPayload = Schema.Struct({
|
|
571
|
+
baseStateId: BaseStateId,
|
|
572
|
+
requestedThroughSeq: SequenceNumber
|
|
573
|
+
});
|
|
574
|
+
const BaseStateRequestedEvent = durableEventSchema(baseStateRequestedEventType, BaseStateRequestedPayload);
|
|
575
|
+
/** Payload recorded when a BaseState snapshot is created. */
|
|
576
|
+
const BaseStateCreatedPayload = Schema.Struct({
|
|
577
|
+
baseStateId: BaseStateId,
|
|
578
|
+
coversThroughSeq: SequenceNumber
|
|
579
|
+
});
|
|
580
|
+
const BaseStateCreatedEvent = durableEventSchema(baseStateCreatedEventType, BaseStateCreatedPayload);
|
|
581
|
+
/** Payload recorded when BaseState generation fails. */
|
|
582
|
+
const BaseStateFailedPayload = Schema.Struct({
|
|
583
|
+
baseStateId: BaseStateId,
|
|
584
|
+
error: FailurePayload
|
|
585
|
+
});
|
|
586
|
+
const BaseStateFailedEvent = durableEventSchema(baseStateFailedEventType, BaseStateFailedPayload);
|
|
587
|
+
/** Durable event union for BaseState lifecycle boundaries. */
|
|
588
|
+
const BaseStateEvent = Schema.Union([
|
|
589
|
+
BaseStateRequestedEvent,
|
|
590
|
+
BaseStateCreatedEvent,
|
|
591
|
+
BaseStateFailedEvent
|
|
592
|
+
]);
|
|
593
|
+
/** Built-in durable event union for framework-owned session facts. */
|
|
594
|
+
const EDADurableEvent = Schema.Union([
|
|
595
|
+
CommandEvent,
|
|
596
|
+
MessageEvent,
|
|
597
|
+
RunEvent,
|
|
598
|
+
RecoveryEvent,
|
|
599
|
+
TurnEvent,
|
|
600
|
+
InferenceEvent,
|
|
601
|
+
ToolCallEvent,
|
|
602
|
+
StopControlEvent,
|
|
603
|
+
ContextAndCompactionEvent,
|
|
604
|
+
BaseStateEvent
|
|
605
|
+
]);
|
|
606
|
+
/** Current V1 framework durable event schema. Future versions route beside this alias. */
|
|
607
|
+
const EDADurableEventV1 = EDADurableEvent;
|
|
608
|
+
/** Decode one framework-owned durable event through the namespace/type/version router. */
|
|
609
|
+
const decodeUnknownEDADurableEventSync = (input) => {
|
|
610
|
+
const envelope = Schema.decodeUnknownSync(DurableEventEnvelope)(input);
|
|
611
|
+
if (envelope.namespace !== effectDurableAgentNamespace) throw new Error(`EDADurableEvent decoder only accepts namespace ${effectDurableAgentNamespace}; received ${envelope.namespace}`);
|
|
612
|
+
switch (envelope.schemaVersion) {
|
|
613
|
+
case schemaV1: return Schema.decodeUnknownSync(EDADurableEventV1)(envelope);
|
|
614
|
+
default: throw new Error(`Unsupported EDA durable event schemaVersion ${envelope.schemaVersion} for ${envelope.type}`);
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
/** Effectful V1+ router for untrusted framework-owned durable event boundaries. */
|
|
618
|
+
const decodeUnknownEDADurableEvent = (input) => Effect.try({
|
|
619
|
+
try: () => decodeUnknownEDADurableEventSync(input),
|
|
620
|
+
catch: (error) => error
|
|
621
|
+
});
|
|
622
|
+
//#endregion
|
|
623
|
+
export { RecoveryCompletedEvent as $, userMessagePromotedEventType as $n, UserMessageCancelledEvent as $t, CompactionRequestedEvent as A, pendingMessagesPausedEventType as An, ToolCallFailedEvent as At, EDADurableEventV1 as B, summaryCreatedEventType as Bn, ToolPromptPart as Bt, CommandFailedPayload as C, contextRebasedEventType as Cn, SystemMessageCommittedEvent as Ct, CompactionCompletedPayload as D, inferenceFailedEventType as Dn, ToolCallCreatedEvent as Dt, CompactionCompletedEvent as E, inferenceCompletedEventType as En, ToolCallCompletedPayload as Et, ContextProjectedEvent as F, runStartedEventType as Fn, ToolCallRejectionFeedback as Ft, InferenceFailedPayload as G, toolCallRejectedEventType as Gn, TurnEvent as Gt, InferenceCompletedPayload as H, toolCallCompletedEventType as Hn, ToolSuccessPromptPart as Ht, ContextProjectedPayload as I, steeringMessageCancelledEventType as In, ToolCallRejectionReason as It, MessageEvent as J, turnFailedEventType as Jn, TurnStartedEvent as Jt, InferenceStartedEvent as K, toolCallStartedEventType as Kn, TurnFailedEvent as Kt, ContextRebasedEvent as L, steeringMessageQueuedEventType as Ln, ToolCallStartedEvent as Lt, CompactionStartedEvent as M, runCompletedEventType as Mn, ToolCallPromptPart as Mt, CompactionStartedPayload as N, runFailedEventType as Nn, ToolCallRejectedEvent as Nt, CompactionFailedEvent as O, inferenceStartedEventType as On, ToolCallCreatedPayload as Ot, ContextAndCompactionEvent as P, runInterruptedEventType as Pn, ToolCallRejectedPayload as Pt, PendingMessagesPausedPayload as Q, userMessageCommittedEventType as Qn, UserMessageCancellationReason as Qt, ContextRebasedPayload as R, stopTurnAppliedEventType as Rn, ToolCallStartedPayload as Rt, CommandFailedEvent as S, contextProjectedEventType as Sn, SummaryCreatedPayload as St, CommandStartedPayload as T, decodeUnknownEDADurableEventSync as Tn, ToolCallCompletedEvent as Tt, InferenceEvent as U, toolCallCreatedEventType as Un, TurnCompletedEvent as Ut, InferenceCompletedEvent as V, systemMessageCommittedEventType as Vn, ToolRejectionPromptPart as Vt, InferenceFailedEvent as W, toolCallFailedEventType as Wn, TurnCompletedPayload as Wt, MessageQueuePausedPayload as X, turnStoppedEventType as Xn, TurnStoppedEvent as Xt, MessageQueuePausedEvent as Y, turnStartedEventType as Yn, TurnStartedPayload as Yt, PendingMessagesPausedEvent as Z, userMessageCancelledEventType as Zn, TurnStoppedPayload as Zt, CommandCancelledEvent as _, commandStartedEventType as _n, UsagePayload as _r, StopTurnAppliedEvent as _t, AssistantPartialCommittedPayload as a, UserMessagePromotedPayload as an, EventEnvelope as ar, RunEvent as at, CommandCompletedPayload as b, compactionRequestedEventType as bn, schemaV1 as br, StopTurnRequestedPayload as bt, BaseStateCreatedEvent as c, assistantMessageCommittedEventType as cn, FailurePayload as cr, RunInterruptedEvent as ct, BaseStateFailedEvent as d, baseStateFailedEventType as dn, PositionedEvent as dr, RunStartedPayload as dt, UserMessageCancelledPayload as en, userMessageSubmittedEventType as er, RecoveryCompletedPayload as et, BaseStateFailedPayload as f, baseStateRequestedEventType as fn, ProviderPartId as fr, SteeringMessageCancelledEvent as ft, CommandAdmittedPayload as g, commandFailedEventType as gn, UnixEpochMillis as gr, StopControlEvent as gt, CommandAdmittedEvent as h, commandCompletedEventType as hn, ToolName as hr, SteeringMessageQueuedPayload as ht, AssistantPartialCommittedEvent as i, UserMessagePromotedEvent as in, EventDurability as ir, RunCompletedPayload as it, CompactionRequestedPayload as j, recoveryCompletedEventType as jn, ToolCallFailedPayload as jt, CompactionFailedPayload as k, messageQueuePausedEventType as kn, ToolCallEvent as kt, BaseStateCreatedPayload as l, assistantPartialCommittedEventType as ln, ModelSelectionPayload as lr, RunInterruptedPayload as lt, BaseStateRequestedPayload as m, commandCancelledEventType as mn, SystemPromptText as mr, SteeringMessageQueuedEvent as mt, AssistantMessageCommittedPayload as n, UserMessageCommittedPayload as nn, DurableEventEnvelope as nr, RecoveryEvent as nt, AssistantPromptPart as o, UserMessageSubmittedEvent as on, EventNamespace as or, RunFailedEvent as ot, BaseStateRequestedEvent as p, commandAdmittedEventType as pn, SchemaVersion as pr, SteeringMessageCancelledPayload as pt, InferenceStartedPayload as q, turnCompletedEventType as qn, TurnFailedPayload as qt, AssistantMessageContent as r, UserMessageDisposition as rn, EphemeralEventEnvelope as rr, RunCompletedEvent as rt, AssistantPromptParts as s, UserMessageSubmittedPayload as sn, EventType as sr, RunFailedPayload as st, AssistantMessageCommittedEvent as t, UserMessageCommittedEvent as tn, ephemeralEventSchema as tr, RecoveryContinuation as tt, BaseStateEvent as u, baseStateCreatedEventType as un, NonNegativeInt as ur, RunStartedEvent as ut, CommandCancelledPayload as v, compactionCompletedEventType as vn, effectDurableAgentNamespace as vr, StopTurnAppliedPayload as vt, CommandStartedEvent as w, decodeUnknownEDADurableEvent as wn, SystemMessageCommittedPayload as wt, CommandEvent as x, compactionStartedEventType as xn, SummaryCreatedEvent as xt, CommandCompletedEvent as y, compactionFailedEventType as yn, makeEventType as yr, StopTurnRequestedEvent as yt, EDADurableEvent as z, stopTurnRequestedEventType as zn, ToolFailurePromptPart as zt };
|
|
624
|
+
|
|
625
|
+
//# sourceMappingURL=durable-C3Rz7kg3.js.map
|