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,769 @@
|
|
|
1
|
+
import { m as SequenceNumber } from "./core-Hv3cFydL.js";
|
|
2
|
+
import { r as EDACommand } from "./commands-Ce1ec6kH.js";
|
|
3
|
+
import { D as DurableEventEnvelope, F as ModelSelectionPayload, I as NonNegativeInt, L as PositionedEvent, O as EphemeralEventEnvelope } from "./events-Bb9-Cu-7.js";
|
|
4
|
+
import { Dt as ToolCallCreatedEvent } from "./durable-DlScwmCy.js";
|
|
5
|
+
import { a as EDASessionStore, o as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-D2Ore1QC.js";
|
|
6
|
+
import { S as ReducedState } from "./command-queues-CQ9cwRP7.js";
|
|
7
|
+
import { t as DurableTranscriptMessage } from "./message-transcript-BCHdHAe2.js";
|
|
8
|
+
import { i as EDAReducerStateSnapshot, n as EDAReducerRegistry } from "./reducer-registry-C0svUa63.js";
|
|
9
|
+
import { d as LiveEventBus, s as EDASinkRegistry } from "./sink-registry-CIU0LD3m.js";
|
|
10
|
+
import { t as IdGenerator } from "./id-generator-C2Q15uZM.js";
|
|
11
|
+
import { i as SessionContext, n as EventFactory, t as EDAKeepAlive } from "./keep-alive-DYDsH6qN.js";
|
|
12
|
+
import { d as CompactionRunner } from "./compaction-YayFKo_1.js";
|
|
13
|
+
import { n as EDAPromptProjector } from "./prompt-projector-9_02lk5-.js";
|
|
14
|
+
import { r as EDAToolRegistry } from "./tool-registry-CcnkAAQK.js";
|
|
15
|
+
import * as Context from "effect/Context";
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
17
|
+
import * as Layer from "effect/Layer";
|
|
18
|
+
import * as Schema from "effect/Schema";
|
|
19
|
+
import * as Stream from "effect/Stream";
|
|
20
|
+
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
21
|
+
import * as Cause from "effect/Cause";
|
|
22
|
+
import * as Scope from "effect/Scope";
|
|
23
|
+
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
24
|
+
import * as Response from "effect/unstable/ai/Response";
|
|
25
|
+
|
|
26
|
+
//#region src/services/session-event-sink.d.ts
|
|
27
|
+
/**
|
|
28
|
+
* Narrow write/publish capability passed from `SessionState` into execution subcomponents.
|
|
29
|
+
*
|
|
30
|
+
* This intentionally excludes `snapshot`, admission, and scheduler methods so
|
|
31
|
+
* turns, inferences, and tools can emit events without becoming session-state
|
|
32
|
+
* authorities.
|
|
33
|
+
*/
|
|
34
|
+
interface SessionEventSink {
|
|
35
|
+
/** Commit one durable event through the authoritative session write path. */
|
|
36
|
+
readonly appendDurable: (event: DurableEventEnvelope) => Effect.Effect<CommittedDurableEvent, EDASessionStoreError>;
|
|
37
|
+
/** Commit an ordered durable batch through the authoritative session write path. */
|
|
38
|
+
readonly appendDurableBatch: (events: ReadonlyArray<DurableEventEnvelope>) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;
|
|
39
|
+
/** Position and publish a live-only event against the session's durable head. */
|
|
40
|
+
readonly publishEphemeral: (event: EphemeralEventEnvelope) => Effect.Effect<PositionedEvent, EDASessionStoreError>;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/services/tool-executor.d.ts
|
|
44
|
+
/** Committed durable event narrowed to a framework-owned ToolCallCreated boundary. */
|
|
45
|
+
type CommittedToolCallCreated = CommittedDurableEvent & {
|
|
46
|
+
readonly event: ToolCallCreatedEvent;
|
|
47
|
+
};
|
|
48
|
+
/** Runtime input for executing one sealed tool-call decision. */
|
|
49
|
+
interface ExecuteToolCallInput {
|
|
50
|
+
readonly created: CommittedDurableEvent;
|
|
51
|
+
readonly eventSink: SessionEventSink;
|
|
52
|
+
}
|
|
53
|
+
/** Result variant for one framework tool execution attempt. */
|
|
54
|
+
declare const ToolExecutionOutcome: Schema.Union<readonly [Schema.TaggedStruct<"ToolExecutionCompleted", {
|
|
55
|
+
readonly committed: Schema.Struct<{
|
|
56
|
+
readonly position: Schema.Struct<{
|
|
57
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
58
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
59
|
+
}>;
|
|
60
|
+
readonly event: Schema.Struct<{
|
|
61
|
+
readonly durability: Schema.Literal<"durable">;
|
|
62
|
+
readonly namespace: Schema.NonEmptyString;
|
|
63
|
+
readonly type: Schema.NonEmptyString;
|
|
64
|
+
readonly schemaVersion: Schema.Int;
|
|
65
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
66
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
67
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
68
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
69
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
70
|
+
readonly span: Schema.Struct<{
|
|
71
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
72
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
73
|
+
readonly sampled: Schema.Boolean;
|
|
74
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
75
|
+
}>;
|
|
76
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
77
|
+
readonly context: Schema.Struct<{
|
|
78
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
79
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
80
|
+
readonly sampled: Schema.Boolean;
|
|
81
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
82
|
+
}>;
|
|
83
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
84
|
+
}>>;
|
|
85
|
+
}>>;
|
|
86
|
+
readonly payload: Schema.Unknown;
|
|
87
|
+
}>;
|
|
88
|
+
}>;
|
|
89
|
+
readonly result: Schema.Unknown;
|
|
90
|
+
}>, Schema.TaggedStruct<"ToolExecutionFailed", {
|
|
91
|
+
readonly committed: Schema.Struct<{
|
|
92
|
+
readonly position: Schema.Struct<{
|
|
93
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
94
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
95
|
+
}>;
|
|
96
|
+
readonly event: Schema.Struct<{
|
|
97
|
+
readonly durability: Schema.Literal<"durable">;
|
|
98
|
+
readonly namespace: Schema.NonEmptyString;
|
|
99
|
+
readonly type: Schema.NonEmptyString;
|
|
100
|
+
readonly schemaVersion: Schema.Int;
|
|
101
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
102
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
103
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
104
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
105
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
106
|
+
readonly span: Schema.Struct<{
|
|
107
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
108
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
109
|
+
readonly sampled: Schema.Boolean;
|
|
110
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
111
|
+
}>;
|
|
112
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
113
|
+
readonly context: Schema.Struct<{
|
|
114
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
115
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
116
|
+
readonly sampled: Schema.Boolean;
|
|
117
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
118
|
+
}>;
|
|
119
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
120
|
+
}>>;
|
|
121
|
+
}>>;
|
|
122
|
+
readonly payload: Schema.Unknown;
|
|
123
|
+
}>;
|
|
124
|
+
}>;
|
|
125
|
+
}>, Schema.TaggedStruct<"ToolExecutionSkipped", {
|
|
126
|
+
readonly reason: Schema.Literal<"provider-executed">;
|
|
127
|
+
}>]>;
|
|
128
|
+
type ToolExecutionOutcome = typeof ToolExecutionOutcome.Type;
|
|
129
|
+
/** Execution result paired with the committed ToolCallCreated event that caused it. */
|
|
130
|
+
interface ToolExecutionResult {
|
|
131
|
+
readonly created: CommittedToolCallCreated;
|
|
132
|
+
readonly outcome: ToolExecutionOutcome;
|
|
133
|
+
}
|
|
134
|
+
declare const ToolExecutionEventNotCreated_base: Schema.Class<ToolExecutionEventNotCreated, Schema.TaggedStruct<"ToolExecutionEventNotCreated", {
|
|
135
|
+
readonly eventType: Schema.String;
|
|
136
|
+
}>, Cause.YieldableError>;
|
|
137
|
+
/** Failure when tool execution receives a committed event that is not ToolCallCreated. */
|
|
138
|
+
declare class ToolExecutionEventNotCreated extends ToolExecutionEventNotCreated_base {}
|
|
139
|
+
/** Error surface for validating and committing framework tool execution. */
|
|
140
|
+
type ToolExecutorError = ToolExecutionEventNotCreated | EDASessionStoreError;
|
|
141
|
+
/** Runtime service that executes sealed framework-owned tool calls. */
|
|
142
|
+
interface ToolExecutorShape {
|
|
143
|
+
/** Execute one sealed, framework-owned ToolCallCreated event. */
|
|
144
|
+
readonly executeCreated: (input: ExecuteToolCallInput) => Effect.Effect<ToolExecutionResult, ToolExecutorError>;
|
|
145
|
+
}
|
|
146
|
+
declare const ToolExecutor_base: Context.ServiceClass<ToolExecutor, "@effect-durable-agent/ToolExecutor", ToolExecutorShape>;
|
|
147
|
+
/** Executes sealed framework-owned tool calls and commits tool lifecycle boundaries. */
|
|
148
|
+
declare class ToolExecutor extends ToolExecutor_base {
|
|
149
|
+
static readonly Live: Layer.Layer<ToolExecutor, never, IdGenerator | EventFactory | SessionContext | EDAToolRegistry>;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/services/inference-runner.d.ts
|
|
153
|
+
/** Provider stream parts this runner explicitly handles or rejects with policy. */
|
|
154
|
+
type InferenceRunnerStreamPart = Response.TextStartPart | Response.TextDeltaPart | Response.TextEndPart | Response.ReasoningStartPart | Response.ReasoningDeltaPart | Response.ReasoningEndPart | Response.ToolParamsStartPart | Response.ToolParamsDeltaPart | Response.ToolParamsEndPart | Response.ToolCallPart<string, unknown> | Response.ToolResultPart<string, unknown, unknown> | Response.ToolApprovalRequestPart | Response.FilePart | Response.DocumentSourcePart | Response.UrlSourcePart | Response.ResponseMetadataPart | Response.FinishPart | Response.ErrorPart;
|
|
155
|
+
/** Input identity for running one model inference stream. */
|
|
156
|
+
declare const RunInferenceContext: Schema.Struct<{
|
|
157
|
+
readonly runId: Schema.brand<Schema.String, "RunId">;
|
|
158
|
+
readonly turnId: Schema.brand<Schema.String, "TurnId">;
|
|
159
|
+
readonly inferenceId: Schema.brand<Schema.String, "InferenceId">;
|
|
160
|
+
}>;
|
|
161
|
+
type RunInferenceContext = typeof RunInferenceContext.Type;
|
|
162
|
+
/** Effectful inputs for running one provider inference stream. */
|
|
163
|
+
interface RunInferenceInput extends RunInferenceContext {
|
|
164
|
+
readonly prompt: Prompt.RawInput;
|
|
165
|
+
readonly eventSink: SessionEventSink;
|
|
166
|
+
readonly modelSelection?: ModelSelectionPayload;
|
|
167
|
+
}
|
|
168
|
+
/** Summary returned after one provider inference stream is consumed. */
|
|
169
|
+
declare const InferenceRunResult: Schema.Struct<{
|
|
170
|
+
readonly started: Schema.Struct<{
|
|
171
|
+
readonly position: Schema.Struct<{
|
|
172
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
173
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
174
|
+
}>;
|
|
175
|
+
readonly event: Schema.Struct<{
|
|
176
|
+
readonly durability: Schema.Literal<"durable">;
|
|
177
|
+
readonly namespace: Schema.NonEmptyString;
|
|
178
|
+
readonly type: Schema.NonEmptyString;
|
|
179
|
+
readonly schemaVersion: Schema.Int;
|
|
180
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
181
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
182
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
183
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
184
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
185
|
+
readonly span: Schema.Struct<{
|
|
186
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
187
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
188
|
+
readonly sampled: Schema.Boolean;
|
|
189
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
190
|
+
}>;
|
|
191
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
192
|
+
readonly context: Schema.Struct<{
|
|
193
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
194
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
195
|
+
readonly sampled: Schema.Boolean;
|
|
196
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
197
|
+
}>;
|
|
198
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
199
|
+
}>>;
|
|
200
|
+
}>>;
|
|
201
|
+
readonly payload: Schema.Unknown;
|
|
202
|
+
}>;
|
|
203
|
+
}>;
|
|
204
|
+
readonly partsRecorded: Schema.Int;
|
|
205
|
+
readonly terminal: Schema.Union<readonly [Schema.TaggedStruct<"InferenceRunFinished", {
|
|
206
|
+
readonly committed: Schema.$Array<Schema.Struct<{
|
|
207
|
+
readonly position: Schema.Struct<{
|
|
208
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
209
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
210
|
+
}>;
|
|
211
|
+
readonly event: Schema.Struct<{
|
|
212
|
+
readonly durability: Schema.Literal<"durable">;
|
|
213
|
+
readonly namespace: Schema.NonEmptyString;
|
|
214
|
+
readonly type: Schema.NonEmptyString;
|
|
215
|
+
readonly schemaVersion: Schema.Int;
|
|
216
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
217
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
218
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
219
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
220
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
221
|
+
readonly span: Schema.Struct<{
|
|
222
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
223
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
224
|
+
readonly sampled: Schema.Boolean;
|
|
225
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
226
|
+
}>;
|
|
227
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
228
|
+
readonly context: Schema.Struct<{
|
|
229
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
230
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
231
|
+
readonly sampled: Schema.Boolean;
|
|
232
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
233
|
+
}>;
|
|
234
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
235
|
+
}>>;
|
|
236
|
+
}>>;
|
|
237
|
+
readonly payload: Schema.Unknown;
|
|
238
|
+
}>;
|
|
239
|
+
}>>;
|
|
240
|
+
readonly assistantText: Schema.String;
|
|
241
|
+
readonly reasoningText: Schema.String;
|
|
242
|
+
readonly responseParts: Schema.$Array<Schema.Any>;
|
|
243
|
+
}>, Schema.TaggedStruct<"InferenceRunFailed", {
|
|
244
|
+
readonly committed: Schema.$Array<Schema.Struct<{
|
|
245
|
+
readonly position: Schema.Struct<{
|
|
246
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
247
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
248
|
+
}>;
|
|
249
|
+
readonly event: Schema.Struct<{
|
|
250
|
+
readonly durability: Schema.Literal<"durable">;
|
|
251
|
+
readonly namespace: Schema.NonEmptyString;
|
|
252
|
+
readonly type: Schema.NonEmptyString;
|
|
253
|
+
readonly schemaVersion: Schema.Int;
|
|
254
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
255
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
256
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
257
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
258
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
259
|
+
readonly span: Schema.Struct<{
|
|
260
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
261
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
262
|
+
readonly sampled: Schema.Boolean;
|
|
263
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
264
|
+
}>;
|
|
265
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
266
|
+
readonly context: Schema.Struct<{
|
|
267
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
268
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
269
|
+
readonly sampled: Schema.Boolean;
|
|
270
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
271
|
+
}>;
|
|
272
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
273
|
+
}>>;
|
|
274
|
+
}>>;
|
|
275
|
+
readonly payload: Schema.Unknown;
|
|
276
|
+
}>;
|
|
277
|
+
}>>;
|
|
278
|
+
}>]>;
|
|
279
|
+
}>;
|
|
280
|
+
type InferenceRunResult = typeof InferenceRunResult.Type;
|
|
281
|
+
declare const UnsupportedInferencePart_base: Schema.Class<UnsupportedInferencePart, Schema.TaggedStruct<"UnsupportedInferencePart", {
|
|
282
|
+
readonly partType: Schema.String;
|
|
283
|
+
readonly reason: Schema.String;
|
|
284
|
+
}>, Cause.YieldableError>;
|
|
285
|
+
/** Failure for provider sideband parts without current EDA storage/UI semantics. */
|
|
286
|
+
declare class UnsupportedInferencePart extends UnsupportedInferencePart_base {}
|
|
287
|
+
/** Error surface for model inference streaming and part policy. */
|
|
288
|
+
type InferenceRunnerError = EDASessionStoreError | UnsupportedInferencePart;
|
|
289
|
+
/** Runtime service that owns one provider stream fold and durable finalization. */
|
|
290
|
+
interface InferenceRunnerShape {
|
|
291
|
+
/** Run one provider inference stream and fold provider parts into inference state. */
|
|
292
|
+
readonly runInference: (input: RunInferenceInput) => Effect.Effect<InferenceRunResult, InferenceRunnerError>;
|
|
293
|
+
}
|
|
294
|
+
declare const InferenceRunner_base: Context.ServiceClass<InferenceRunner, "@effect-durable-agent/InferenceRunner", InferenceRunnerShape>;
|
|
295
|
+
/** Owns provider inference streams and routes them into durable/live inference emissions. */
|
|
296
|
+
declare class InferenceRunner extends InferenceRunner_base {
|
|
297
|
+
static readonly Live: Layer.Layer<InferenceRunner, never, IdGenerator | LanguageModel.LanguageModel | EventFactory | EDAToolRegistry>;
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/services/turn-runner.d.ts
|
|
301
|
+
/** Input identity for running one turn with one provider inference stream. */
|
|
302
|
+
declare const RunTurnContext: Schema.Struct<{
|
|
303
|
+
readonly runId: Schema.brand<Schema.String, "RunId">;
|
|
304
|
+
readonly turnId: Schema.brand<Schema.String, "TurnId">;
|
|
305
|
+
}>;
|
|
306
|
+
type RunTurnContext = typeof RunTurnContext.Type;
|
|
307
|
+
/** Effectful inputs for running an already-started turn body. */
|
|
308
|
+
interface RunTurnInput extends RunTurnContext {
|
|
309
|
+
readonly prompt: Prompt.RawInput;
|
|
310
|
+
readonly eventSink: SessionEventSink;
|
|
311
|
+
readonly started: CommittedDurableEvent;
|
|
312
|
+
readonly modelSelection?: ModelSelectionPayload;
|
|
313
|
+
/** Maximum framework-owned tool calls this model run may execute before failing safely. */
|
|
314
|
+
readonly maxToolCallsPerRun?: NonNegativeInt;
|
|
315
|
+
/** Remaining rejected-tool correction turns before this turn must fail closed. */
|
|
316
|
+
readonly remainingToolRejectionCorrections?: NonNegativeInt;
|
|
317
|
+
/** Configured rejected-tool correction limit used in failure details. */
|
|
318
|
+
readonly maxToolRejectionCorrections?: NonNegativeInt;
|
|
319
|
+
}
|
|
320
|
+
/** Summary returned after the turn runner processes one inference stream. */
|
|
321
|
+
declare const TurnRunResult: Schema.Struct<{
|
|
322
|
+
readonly started: Schema.Struct<{
|
|
323
|
+
readonly position: Schema.Struct<{
|
|
324
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
325
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
326
|
+
}>;
|
|
327
|
+
readonly event: Schema.Struct<{
|
|
328
|
+
readonly durability: Schema.Literal<"durable">;
|
|
329
|
+
readonly namespace: Schema.NonEmptyString;
|
|
330
|
+
readonly type: Schema.NonEmptyString;
|
|
331
|
+
readonly schemaVersion: Schema.Int;
|
|
332
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
333
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
334
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
335
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
336
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
337
|
+
readonly span: Schema.Struct<{
|
|
338
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
339
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
340
|
+
readonly sampled: Schema.Boolean;
|
|
341
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
342
|
+
}>;
|
|
343
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
344
|
+
readonly context: Schema.Struct<{
|
|
345
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
346
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
347
|
+
readonly sampled: Schema.Boolean;
|
|
348
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
349
|
+
}>;
|
|
350
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
351
|
+
}>>;
|
|
352
|
+
}>>;
|
|
353
|
+
readonly payload: Schema.Unknown;
|
|
354
|
+
}>;
|
|
355
|
+
}>;
|
|
356
|
+
readonly inference: Schema.Struct<{
|
|
357
|
+
readonly started: Schema.Struct<{
|
|
358
|
+
readonly position: Schema.Struct<{
|
|
359
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
360
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
361
|
+
}>;
|
|
362
|
+
readonly event: Schema.Struct<{
|
|
363
|
+
readonly durability: Schema.Literal<"durable">;
|
|
364
|
+
readonly namespace: Schema.NonEmptyString;
|
|
365
|
+
readonly type: Schema.NonEmptyString;
|
|
366
|
+
readonly schemaVersion: Schema.Int;
|
|
367
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
368
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
369
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
370
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
371
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
372
|
+
readonly span: Schema.Struct<{
|
|
373
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
374
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
375
|
+
readonly sampled: Schema.Boolean;
|
|
376
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
377
|
+
}>;
|
|
378
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
379
|
+
readonly context: Schema.Struct<{
|
|
380
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
381
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
382
|
+
readonly sampled: Schema.Boolean;
|
|
383
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
384
|
+
}>;
|
|
385
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
386
|
+
}>>;
|
|
387
|
+
}>>;
|
|
388
|
+
readonly payload: Schema.Unknown;
|
|
389
|
+
}>;
|
|
390
|
+
}>;
|
|
391
|
+
readonly partsRecorded: Schema.Int;
|
|
392
|
+
readonly terminal: Schema.Union<readonly [Schema.TaggedStruct<"InferenceRunFinished", {
|
|
393
|
+
readonly committed: Schema.$Array<Schema.Struct<{
|
|
394
|
+
readonly position: Schema.Struct<{
|
|
395
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
396
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
397
|
+
}>;
|
|
398
|
+
readonly event: Schema.Struct<{
|
|
399
|
+
readonly durability: Schema.Literal<"durable">;
|
|
400
|
+
readonly namespace: Schema.NonEmptyString;
|
|
401
|
+
readonly type: Schema.NonEmptyString;
|
|
402
|
+
readonly schemaVersion: Schema.Int;
|
|
403
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
404
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
405
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
406
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
407
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
408
|
+
readonly span: Schema.Struct<{
|
|
409
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
410
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
411
|
+
readonly sampled: Schema.Boolean;
|
|
412
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
413
|
+
}>;
|
|
414
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
415
|
+
readonly context: Schema.Struct<{
|
|
416
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
417
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
418
|
+
readonly sampled: Schema.Boolean;
|
|
419
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
420
|
+
}>;
|
|
421
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
422
|
+
}>>;
|
|
423
|
+
}>>;
|
|
424
|
+
readonly payload: Schema.Unknown;
|
|
425
|
+
}>;
|
|
426
|
+
}>>;
|
|
427
|
+
readonly assistantText: Schema.String;
|
|
428
|
+
readonly reasoningText: Schema.String;
|
|
429
|
+
readonly responseParts: Schema.$Array<Schema.Any>;
|
|
430
|
+
}>, Schema.TaggedStruct<"InferenceRunFailed", {
|
|
431
|
+
readonly committed: Schema.$Array<Schema.Struct<{
|
|
432
|
+
readonly position: Schema.Struct<{
|
|
433
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
434
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
435
|
+
}>;
|
|
436
|
+
readonly event: Schema.Struct<{
|
|
437
|
+
readonly durability: Schema.Literal<"durable">;
|
|
438
|
+
readonly namespace: Schema.NonEmptyString;
|
|
439
|
+
readonly type: Schema.NonEmptyString;
|
|
440
|
+
readonly schemaVersion: Schema.Int;
|
|
441
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
442
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
443
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
444
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
445
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
446
|
+
readonly span: Schema.Struct<{
|
|
447
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
448
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
449
|
+
readonly sampled: Schema.Boolean;
|
|
450
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
451
|
+
}>;
|
|
452
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
453
|
+
readonly context: Schema.Struct<{
|
|
454
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
455
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
456
|
+
readonly sampled: Schema.Boolean;
|
|
457
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
458
|
+
}>;
|
|
459
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
460
|
+
}>>;
|
|
461
|
+
}>>;
|
|
462
|
+
readonly payload: Schema.Unknown;
|
|
463
|
+
}>;
|
|
464
|
+
}>>;
|
|
465
|
+
}>]>;
|
|
466
|
+
}>;
|
|
467
|
+
readonly outcome: Schema.Union<readonly [Schema.TaggedStruct<"TurnRunCompleted", {
|
|
468
|
+
readonly committed: Schema.Struct<{
|
|
469
|
+
readonly position: Schema.Struct<{
|
|
470
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
471
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
472
|
+
}>;
|
|
473
|
+
readonly event: Schema.Struct<{
|
|
474
|
+
readonly durability: Schema.Literal<"durable">;
|
|
475
|
+
readonly namespace: Schema.NonEmptyString;
|
|
476
|
+
readonly type: Schema.NonEmptyString;
|
|
477
|
+
readonly schemaVersion: Schema.Int;
|
|
478
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
479
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
480
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
481
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
482
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
483
|
+
readonly span: Schema.Struct<{
|
|
484
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
485
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
486
|
+
readonly sampled: Schema.Boolean;
|
|
487
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
488
|
+
}>;
|
|
489
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
490
|
+
readonly context: Schema.Struct<{
|
|
491
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
492
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
493
|
+
readonly sampled: Schema.Boolean;
|
|
494
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
495
|
+
}>;
|
|
496
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
497
|
+
}>>;
|
|
498
|
+
}>>;
|
|
499
|
+
readonly payload: Schema.Unknown;
|
|
500
|
+
}>;
|
|
501
|
+
}>;
|
|
502
|
+
}>, Schema.TaggedStruct<"TurnRunFailed", {
|
|
503
|
+
readonly committed: Schema.Struct<{
|
|
504
|
+
readonly position: Schema.Struct<{
|
|
505
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
506
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
507
|
+
}>;
|
|
508
|
+
readonly event: Schema.Struct<{
|
|
509
|
+
readonly durability: Schema.Literal<"durable">;
|
|
510
|
+
readonly namespace: Schema.NonEmptyString;
|
|
511
|
+
readonly type: Schema.NonEmptyString;
|
|
512
|
+
readonly schemaVersion: Schema.Int;
|
|
513
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
514
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
515
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
516
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
517
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
518
|
+
readonly span: Schema.Struct<{
|
|
519
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
520
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
521
|
+
readonly sampled: Schema.Boolean;
|
|
522
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
523
|
+
}>;
|
|
524
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
525
|
+
readonly context: Schema.Struct<{
|
|
526
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
527
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
528
|
+
readonly sampled: Schema.Boolean;
|
|
529
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
530
|
+
}>;
|
|
531
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
532
|
+
}>>;
|
|
533
|
+
}>>;
|
|
534
|
+
readonly payload: Schema.Unknown;
|
|
535
|
+
}>;
|
|
536
|
+
}>;
|
|
537
|
+
}>]>;
|
|
538
|
+
}>;
|
|
539
|
+
type TurnRunResult = typeof TurnRunResult.Type;
|
|
540
|
+
/** Error surface for the turn runner's inference and tool orchestration. */
|
|
541
|
+
type TurnRunnerError = EDASessionStoreError | InferenceRunnerError | ToolExecutorError;
|
|
542
|
+
/** Runtime service that owns inferences, tool execution, and turn terminalization. */
|
|
543
|
+
interface TurnRunnerShape {
|
|
544
|
+
/** Run one turn around a provider inference stream. */
|
|
545
|
+
readonly runTurn: (input: RunTurnInput) => Effect.Effect<TurnRunResult, TurnRunnerError>;
|
|
546
|
+
}
|
|
547
|
+
declare const TurnRunner_base: Context.ServiceClass<TurnRunner, "@effect-durable-agent/TurnRunner", TurnRunnerShape>;
|
|
548
|
+
/** Owns one turn: turn boundaries, inferences, tool handoff, and terminal turn events. */
|
|
549
|
+
declare class TurnRunner extends TurnRunner_base {
|
|
550
|
+
static readonly Live: Layer.Layer<TurnRunner, never, IdGenerator | EventFactory | InferenceRunner | ToolExecutor>;
|
|
551
|
+
}
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region src/services/session-state.d.ts
|
|
554
|
+
/** Authoritative framework and app reducer state snapshot. */
|
|
555
|
+
interface SessionStateSnapshotData {
|
|
556
|
+
readonly reduced: ReducedState;
|
|
557
|
+
readonly reducerStates: EDAReducerStateSnapshot;
|
|
558
|
+
}
|
|
559
|
+
/** Input for one session control pass or long-lived control process. */
|
|
560
|
+
declare const SessionRunInput: Schema.Struct<{
|
|
561
|
+
readonly modelSelection: Schema.Struct<{
|
|
562
|
+
readonly provider: Schema.NonEmptyString;
|
|
563
|
+
readonly modelId: Schema.NonEmptyString;
|
|
564
|
+
readonly settings: Schema.optionalKey<Schema.Unknown>;
|
|
565
|
+
}>;
|
|
566
|
+
readonly maxToolCallsPerRun: Schema.optionalKey<Schema.Int>;
|
|
567
|
+
readonly systemPrompt: Schema.optionalKey<Schema.NonEmptyString>;
|
|
568
|
+
}>;
|
|
569
|
+
type SessionRunInput = typeof SessionRunInput.Type;
|
|
570
|
+
/** Terminal command-processing variants returned from one control action. */
|
|
571
|
+
declare const SessionCommandOutcome: Schema.Union<readonly [Schema.TaggedStruct<"SessionCommandCompleted", {
|
|
572
|
+
readonly committed: Schema.Struct<{
|
|
573
|
+
readonly position: Schema.Struct<{
|
|
574
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
575
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
576
|
+
}>;
|
|
577
|
+
readonly event: Schema.Struct<{
|
|
578
|
+
readonly durability: Schema.Literal<"durable">;
|
|
579
|
+
readonly namespace: Schema.NonEmptyString;
|
|
580
|
+
readonly type: Schema.NonEmptyString;
|
|
581
|
+
readonly schemaVersion: Schema.Int;
|
|
582
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
583
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
584
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
585
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
586
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
587
|
+
readonly span: Schema.Struct<{
|
|
588
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
589
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
590
|
+
readonly sampled: Schema.Boolean;
|
|
591
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
592
|
+
}>;
|
|
593
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
594
|
+
readonly context: Schema.Struct<{
|
|
595
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
596
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
597
|
+
readonly sampled: Schema.Boolean;
|
|
598
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
599
|
+
}>;
|
|
600
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
601
|
+
}>>;
|
|
602
|
+
}>>;
|
|
603
|
+
readonly payload: Schema.Unknown;
|
|
604
|
+
}>;
|
|
605
|
+
}>;
|
|
606
|
+
}>, Schema.TaggedStruct<"SessionCommandFailed", {
|
|
607
|
+
readonly committed: Schema.Struct<{
|
|
608
|
+
readonly position: Schema.Struct<{
|
|
609
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
610
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
611
|
+
}>;
|
|
612
|
+
readonly event: Schema.Struct<{
|
|
613
|
+
readonly durability: Schema.Literal<"durable">;
|
|
614
|
+
readonly namespace: Schema.NonEmptyString;
|
|
615
|
+
readonly type: Schema.NonEmptyString;
|
|
616
|
+
readonly schemaVersion: Schema.Int;
|
|
617
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
618
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
619
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
620
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
621
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
622
|
+
readonly span: Schema.Struct<{
|
|
623
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
624
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
625
|
+
readonly sampled: Schema.Boolean;
|
|
626
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
627
|
+
}>;
|
|
628
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
629
|
+
readonly context: Schema.Struct<{
|
|
630
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
631
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
632
|
+
readonly sampled: Schema.Boolean;
|
|
633
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
634
|
+
}>;
|
|
635
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
636
|
+
}>>;
|
|
637
|
+
}>>;
|
|
638
|
+
readonly payload: Schema.Unknown;
|
|
639
|
+
}>;
|
|
640
|
+
}>;
|
|
641
|
+
}>, Schema.TaggedStruct<"SessionCommandCancelled", {
|
|
642
|
+
readonly committed: Schema.Struct<{
|
|
643
|
+
readonly position: Schema.Struct<{
|
|
644
|
+
readonly seq: Schema.brand<Schema.Int, "SequenceNumber">;
|
|
645
|
+
readonly subSeq: Schema.brand<Schema.Literal<0>, "SubSequenceNumber">;
|
|
646
|
+
}>;
|
|
647
|
+
readonly event: Schema.Struct<{
|
|
648
|
+
readonly durability: Schema.Literal<"durable">;
|
|
649
|
+
readonly namespace: Schema.NonEmptyString;
|
|
650
|
+
readonly type: Schema.NonEmptyString;
|
|
651
|
+
readonly schemaVersion: Schema.Int;
|
|
652
|
+
readonly eventId: Schema.brand<Schema.String, "EventId">;
|
|
653
|
+
readonly sessionId: Schema.brand<Schema.String, "SessionId">;
|
|
654
|
+
readonly correlationId: Schema.optionalKey<Schema.brand<Schema.String, "CorrelationId">>;
|
|
655
|
+
readonly createdAtMs: Schema.brand<Schema.Int, "UnixEpochMillis">;
|
|
656
|
+
readonly trace: Schema.withConstructorDefault<Schema.Struct<{
|
|
657
|
+
readonly span: Schema.Struct<{
|
|
658
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
659
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
660
|
+
readonly sampled: Schema.Boolean;
|
|
661
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
662
|
+
}>;
|
|
663
|
+
readonly links: Schema.$Array<Schema.Struct<{
|
|
664
|
+
readonly context: Schema.Struct<{
|
|
665
|
+
readonly traceId: Schema.brand<Schema.String, "EDATraceId">;
|
|
666
|
+
readonly spanId: Schema.brand<Schema.String, "EDASpanId">;
|
|
667
|
+
readonly sampled: Schema.Boolean;
|
|
668
|
+
readonly tracestate: Schema.NullOr<Schema.String>;
|
|
669
|
+
}>;
|
|
670
|
+
readonly attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
671
|
+
}>>;
|
|
672
|
+
}>>;
|
|
673
|
+
readonly payload: Schema.Unknown;
|
|
674
|
+
}>;
|
|
675
|
+
}>;
|
|
676
|
+
}>]>;
|
|
677
|
+
type SessionCommandOutcome = typeof SessionCommandOutcome.Type;
|
|
678
|
+
/** Summary returned after processing one admitted command. */
|
|
679
|
+
interface SessionCommandResult {
|
|
680
|
+
readonly started: CommittedDurableEvent;
|
|
681
|
+
readonly outcome: SessionCommandOutcome;
|
|
682
|
+
}
|
|
683
|
+
/** Session control result when no admitted command is runnable. */
|
|
684
|
+
declare const SessionNoRunnableCommand: Schema.TaggedStruct<"SessionNoRunnableCommand", {
|
|
685
|
+
readonly reason: Schema.Literals<readonly ["active-command", "no-pending-command"]>;
|
|
686
|
+
readonly active: Schema.optionalKey<Schema.TaggedStruct<"DispatchActiveCommand", {
|
|
687
|
+
readonly commandId: Schema.brand<Schema.String, "CommandId">;
|
|
688
|
+
readonly runId: Schema.optionalKey<Schema.brand<Schema.String, "RunId">>;
|
|
689
|
+
}>>;
|
|
690
|
+
}>;
|
|
691
|
+
type SessionNoRunnableCommand = typeof SessionNoRunnableCommand.Type;
|
|
692
|
+
/** Control result when command execution was started in an active child scope. */
|
|
693
|
+
declare const SessionForkedCommand: Schema.TaggedStruct<"SessionForkedCommand", {
|
|
694
|
+
readonly commandId: Schema.brand<Schema.String, "CommandId">;
|
|
695
|
+
}>;
|
|
696
|
+
type SessionForkedCommand = typeof SessionForkedCommand.Type;
|
|
697
|
+
/** One processed control-loop action from a drain pass. */
|
|
698
|
+
type SessionDrainProcessed = SessionCommandResult | SessionForkedCommand;
|
|
699
|
+
/** Summary of a control-loop drain pass and the reason it stopped. */
|
|
700
|
+
interface SessionDrainResult {
|
|
701
|
+
readonly _tag: "SessionDrainResult";
|
|
702
|
+
readonly processed: ReadonlyArray<SessionDrainProcessed>;
|
|
703
|
+
readonly stop: SessionNoRunnableCommand;
|
|
704
|
+
}
|
|
705
|
+
/** Error surface for session control-loop execution. */
|
|
706
|
+
type SessionStateError = EDASessionStoreError | TurnRunnerError;
|
|
707
|
+
declare const SessionCommandAdmissionConflict_base: Schema.Class<SessionCommandAdmissionConflict, Schema.TaggedStruct<"SessionCommandAdmissionConflict", {
|
|
708
|
+
readonly code: Schema.Literals<readonly ["queue_paused", "paused_queue_changed"]>;
|
|
709
|
+
readonly message: Schema.String;
|
|
710
|
+
readonly pausedMessageIds: Schema.$Array<Schema.brand<Schema.String, "MessageId">>;
|
|
711
|
+
}>, Cause.YieldableError>;
|
|
712
|
+
declare class SessionCommandAdmissionConflict extends SessionCommandAdmissionConflict_base {}
|
|
713
|
+
/** Error surface for durable command admission and batched submit. */
|
|
714
|
+
type SessionCommandAdmissionError = EDASessionStoreError | SessionCommandAdmissionConflict;
|
|
715
|
+
/** Ordered item admitted through the public runtime submit batch. */
|
|
716
|
+
type EDASubmittable = EDACommand | DurableEventEnvelope;
|
|
717
|
+
/** Internal live-process authority for commands, durable writes, and scheduling. */
|
|
718
|
+
interface SessionStateShape extends SessionEventSink {
|
|
719
|
+
/** Commit session-initial context, such as app-owned system prompt, before command work starts. */
|
|
720
|
+
readonly initialize: (input: SessionRunInput) => Effect.Effect<void, SessionCommandAdmissionError>;
|
|
721
|
+
/** Submit commands and/or app durable events as one ordered durable batch. */
|
|
722
|
+
readonly submitBatch: (input: ReadonlyArray<EDASubmittable>) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, SessionCommandAdmissionError>;
|
|
723
|
+
/** Admit an external command durably and wake the control loop. */
|
|
724
|
+
readonly admitCommand: (command: EDACommand) => Effect.Effect<CommittedDurableEvent, SessionCommandAdmissionError>;
|
|
725
|
+
/** Observe the authoritative live reduced state. Use for reads only, not detached mutation. */
|
|
726
|
+
readonly snapshot: () => Effect.Effect<ReducedState>;
|
|
727
|
+
/** Observe the authoritative framework state plus app reducer states. */
|
|
728
|
+
readonly snapshotData: () => Effect.Effect<SessionStateSnapshotData>;
|
|
729
|
+
/**
|
|
730
|
+
* Process runnable work until blocked or empty after startup recovery has completed.
|
|
731
|
+
*
|
|
732
|
+
* This is a post-recovery dispatch helper. If durable replay says a command is
|
|
733
|
+
* already active while no in-memory execution owner exists, that is a fatal
|
|
734
|
+
* live-runtime invariant violation rather than an inline recovery case.
|
|
735
|
+
*/
|
|
736
|
+
readonly drainReadyWork: (input: SessionRunInput) => Effect.Effect<SessionDrainResult, SessionStateError>;
|
|
737
|
+
/** Initialize, recover exactly once, then enter the long-lived live control loop. */
|
|
738
|
+
readonly start: (input: SessionRunInput) => Effect.Effect<void, SessionCommandAdmissionError>;
|
|
739
|
+
}
|
|
740
|
+
declare const SessionState_base: Context.ServiceClass<SessionState, "@effect-durable-agent/SessionState", SessionStateShape>;
|
|
741
|
+
/** Internal authoritative live state and root control loop for one session. */
|
|
742
|
+
declare class SessionState extends SessionState_base {
|
|
743
|
+
static readonly Live: Layer.Layer<SessionState, EDASessionStoreError, IdGenerator | EDAPromptProjector | LiveEventBus | EDASessionStore | CompactionRunner | EventFactory | EDAKeepAlive | EDAReducerRegistry | TurnRunner | SessionContext | EDASinkRegistry>;
|
|
744
|
+
}
|
|
745
|
+
//#endregion
|
|
746
|
+
//#region src/services/session-query.d.ts
|
|
747
|
+
/** Authoritative live snapshot for one EDA session plus its derived durable transcript. */
|
|
748
|
+
interface EDASessionSnapshot {
|
|
749
|
+
readonly state: ReducedState;
|
|
750
|
+
readonly reducerStates: EDAReducerStateSnapshot;
|
|
751
|
+
readonly messages: ReadonlyArray<DurableTranscriptMessage>;
|
|
752
|
+
}
|
|
753
|
+
/** Read-only query facade over authoritative live state and reconnect-safe event streams. */
|
|
754
|
+
interface EDASessionQueryShape {
|
|
755
|
+
/** Read the authoritative live state and derive its durable transcript. */
|
|
756
|
+
readonly snapshot: () => Effect.Effect<EDASessionSnapshot, EDASessionStoreError>;
|
|
757
|
+
/** Read durable user/assistant messages in committed sequence order from the live snapshot. */
|
|
758
|
+
readonly messages: () => Effect.Effect<ReadonlyArray<DurableTranscriptMessage>, EDASessionStoreError>;
|
|
759
|
+
/** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */
|
|
760
|
+
readonly eventsAfter: (afterSeq: SequenceNumber) => Effect.Effect<Stream.Stream<PositionedEvent, EDASessionStoreError>, EDASessionStoreError, Scope.Scope>;
|
|
761
|
+
}
|
|
762
|
+
declare const EDASessionQuery_base: Context.ServiceClass<EDASessionQuery, "@effect-durable-agent/EDASessionQuery", EDASessionQueryShape>;
|
|
763
|
+
/** Read-only session query facade backed by authoritative SessionState plus durable backfill. */
|
|
764
|
+
declare class EDASessionQuery extends EDASessionQuery_base {
|
|
765
|
+
static readonly Live: Layer.Layer<EDASessionQuery, never, SessionState | LiveEventBus | EDASessionStore>;
|
|
766
|
+
}
|
|
767
|
+
//#endregion
|
|
768
|
+
export { SessionCommandAdmissionError as a, InferenceRunner as c, EDASubmittable as i, InferenceRunnerStreamPart as l, EDASessionQueryShape as n, SessionState as o, EDASessionSnapshot as r, TurnRunner as s, EDASessionQuery as t, ToolExecutor as u };
|
|
769
|
+
//# sourceMappingURL=session-query-DlRo5Ufc.d.ts.map
|