effect-durable-agent-cloudflare 0.1.0-alpha.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/anthropic.d.ts +44 -0
- package/dist/anthropic.js +66 -0
- package/dist/anthropic.js.map +1 -0
- package/dist/durable-object-DIoz2TqE.js +633 -0
- package/dist/durable-object-DIoz2TqE.js.map +1 -0
- package/dist/durable-object-storage-Dec6HWQ9.d.ts +136 -0
- package/dist/durable-object-store-lJkqwvIj.js +1263 -0
- package/dist/durable-object-store-lJkqwvIj.js.map +1 -0
- package/dist/durable-object.d.ts +2356 -55
- package/dist/durable-object.js +2 -193
- package/dist/index.d.ts +227 -6
- package/dist/index.js +6 -5
- package/dist/openai.d.ts +10 -5
- package/dist/openai.js +20 -48
- package/dist/openai.js.map +1 -1
- package/dist/providers.d.ts +53 -0
- package/dist/providers.js +221 -0
- package/dist/providers.js.map +1 -0
- package/dist/rpc-codec-Nci-sCgQ.d.ts +68 -0
- package/dist/rpc-spec-BU5bGUWF.js +447 -0
- package/dist/rpc-spec-BU5bGUWF.js.map +1 -0
- package/dist/rpc-spec-NAf8Yjnd.d.ts +9139 -0
- package/dist/rpc.d.ts +3 -16
- package/dist/rpc.js +2 -26
- package/dist/{session-controller-Dp07FnPn.d.ts → session-controller-Cfd5Zjd5.d.ts} +140 -32
- package/dist/session-controller-UhUFR3i_.js +1517 -0
- package/dist/session-controller-UhUFR3i_.js.map +1 -0
- package/dist/session-controller.d.ts +2 -2
- package/dist/session-controller.js +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/transport-BzgK07l4.js +205 -0
- package/dist/transport-BzgK07l4.js.map +1 -0
- package/package.json +29 -11
- package/dist/durable-object-storage-DCL2IyUe.d.ts +0 -41
- package/dist/durable-object.js.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/session-controller-COHH8vA6.js +0 -1434
- package/dist/session-controller-COHH8vA6.js.map +0 -1
package/dist/rpc.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { DurableEventEnvelope } from "effect-durable-agent/types/events";
|
|
5
|
-
import { EDASubmittable } from "effect-durable-agent/services/session-state";
|
|
6
|
-
|
|
7
|
-
//#region src/rpc-codec.d.ts
|
|
8
|
-
/** Encode one durable event into a structured-clone-safe Durable Object RPC value. */
|
|
9
|
-
declare const encodeEdaRpcDurableEvent: (event: DurableEventEnvelope) => DurableEventEnvelope;
|
|
10
|
-
declare const encodeEdaRpcCommand: (input: EDACommand) => unknown;
|
|
11
|
-
declare const encodeEdaRpcSubmittables: (input: ReadonlyArray<EDASubmittable>) => ReadonlyArray<unknown>;
|
|
12
|
-
declare const decodeEdaRpcCommand: (input: unknown) => Effect.Effect<EDACommand, Schema.SchemaError>;
|
|
13
|
-
declare const decodeEdaRpcSubmittables: (input: ReadonlyArray<unknown>) => Effect.Effect<ReadonlyArray<EDASubmittable>, Schema.SchemaError>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { decodeEdaRpcCommand, decodeEdaRpcSubmittables, encodeEdaRpcCommand, encodeEdaRpcDurableEvent, encodeEdaRpcSubmittables };
|
|
16
|
-
//# sourceMappingURL=rpc.d.ts.map
|
|
1
|
+
import { a as SessionGrantRunInput, c as SessionTranscriptBodyInput, d as SessionTranscriptSummaryResult, f as SessionTranscriptWindowInput, h as edaSessionRpc, i as SessionDecideInput, l as SessionTranscriptBodyResult, m as TranscriptCompactionSummary, n as SessionBlockInput, o as SessionOutcomeInput, p as SessionTranscriptWindowResult, r as SessionCommandInput, s as SessionScopedInput, t as SessionBatchInput, u as SessionTranscriptSummaryInput } from "./rpc-spec-NAf8Yjnd.js";
|
|
2
|
+
import { a as decodeEdaRpcSubmittables, c as encodeEdaRpcDurableEvent, i as decodeEdaRpcCommand, l as encodeEdaRpcSubmittables, n as SessionDecideResult, o as encodeDecideInput, r as decodeDecideOutcome, s as encodeEdaRpcCommand, t as EDARpcSubmittable } from "./rpc-codec-Nci-sCgQ.js";
|
|
3
|
+
export { EDARpcSubmittable, SessionBatchInput, SessionBlockInput, SessionCommandInput, SessionDecideInput, SessionDecideResult, SessionGrantRunInput, SessionOutcomeInput, SessionScopedInput, SessionTranscriptBodyInput, SessionTranscriptBodyResult, SessionTranscriptSummaryInput, SessionTranscriptSummaryResult, SessionTranscriptWindowInput, SessionTranscriptWindowResult, TranscriptCompactionSummary, decodeDecideOutcome, decodeEdaRpcCommand, decodeEdaRpcSubmittables, edaSessionRpc, encodeDecideInput, encodeEdaRpcCommand, encodeEdaRpcDurableEvent, encodeEdaRpcSubmittables };
|
package/dist/rpc.js
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import * as Exit from "effect/Exit";
|
|
4
|
-
import { EDACommand } from "effect-durable-agent/types/commands";
|
|
5
|
-
import { DurableEventEnvelope, EDADurableEvent, effectDurableAgentNamespace } from "effect-durable-agent/types/events";
|
|
6
|
-
//#region src/rpc-codec.ts
|
|
7
|
-
/** Encode one durable event into a structured-clone-safe Durable Object RPC value. */
|
|
8
|
-
const encodeEdaRpcDurableEvent = (event) => {
|
|
9
|
-
const encoded = event.namespace === effectDurableAgentNamespace ? Schema.encodeSync(EDADurableEvent)(Schema.decodeUnknownSync(EDADurableEvent)(event)) : Schema.encodeSync(DurableEventEnvelope)(event);
|
|
10
|
-
return Schema.decodeUnknownSync(DurableEventEnvelope)(encoded);
|
|
11
|
-
};
|
|
12
|
-
const EDARpcSubmittable = Schema.Union([EDACommand, DurableEventEnvelope]);
|
|
13
|
-
const encodeEdaRpcCommand = (input) => Schema.encodeSync(EDACommand)(input);
|
|
14
|
-
const encodeEdaRpcSubmittables = (input) => input.map((item) => Schema.encodeSync(EDARpcSubmittable)(item));
|
|
15
|
-
const decodeEdaRpcCommand = (input) => Schema.decodeUnknownExit(EDACommand)(input).pipe(Exit.match({
|
|
16
|
-
onFailure: Effect.failCause,
|
|
17
|
-
onSuccess: Effect.succeed
|
|
18
|
-
}));
|
|
19
|
-
const decodeEdaRpcSubmittables = (input) => Effect.forEach(input, (item) => Schema.decodeUnknownExit(EDARpcSubmittable)(item).pipe(Exit.match({
|
|
20
|
-
onFailure: Effect.failCause,
|
|
21
|
-
onSuccess: Effect.succeed
|
|
22
|
-
})));
|
|
23
|
-
//#endregion
|
|
24
|
-
export { decodeEdaRpcCommand, decodeEdaRpcSubmittables, encodeEdaRpcCommand, encodeEdaRpcDurableEvent, encodeEdaRpcSubmittables };
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=rpc.js.map
|
|
1
|
+
import { C as decodeEdaRpcSubmittables, D as encodeEdaRpcSubmittables, E as encodeEdaRpcDurableEvent, S as decodeEdaRpcCommand, T as encodeEdaRpcCommand, a as SessionGrantRunInput, b as SessionDecideResult, c as SessionTranscriptBodyInput, d as SessionTranscriptSummaryResult, f as SessionTranscriptWindowInput, h as edaSessionRpc, i as SessionDecideInput, l as SessionTranscriptBodyResult, m as TranscriptCompactionSummary, n as SessionBlockInput, o as SessionOutcomeInput, p as SessionTranscriptWindowResult, r as SessionCommandInput, s as SessionScopedInput, t as SessionBatchInput, u as SessionTranscriptSummaryInput, w as encodeDecideInput, x as decodeDecideOutcome, y as EDARpcSubmittable } from "./rpc-spec-BU5bGUWF.js";
|
|
2
|
+
export { EDARpcSubmittable, SessionBatchInput, SessionBlockInput, SessionCommandInput, SessionDecideInput, SessionDecideResult, SessionGrantRunInput, SessionOutcomeInput, SessionScopedInput, SessionTranscriptBodyInput, SessionTranscriptBodyResult, SessionTranscriptSummaryInput, SessionTranscriptSummaryResult, SessionTranscriptWindowInput, SessionTranscriptWindowResult, TranscriptCompactionSummary, decodeDecideOutcome, decodeEdaRpcCommand, decodeEdaRpcSubmittables, edaSessionRpc, encodeDecideInput, encodeEdaRpcCommand, encodeEdaRpcDurableEvent, encodeEdaRpcSubmittables };
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import { t as DurableObjectSessionStorage } from "./durable-object-storage-
|
|
1
|
+
import { o as DurableObjectTranscriptOptions, t as DurableObjectSessionStorage } from "./durable-object-storage-Dec6HWQ9.js";
|
|
2
|
+
import { EDAPromptProjector } from "effect-durable-agent/services/prompt-projector";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
2
4
|
import * as Effect from "effect/Effect";
|
|
3
5
|
import * as Schema from "effect/Schema";
|
|
4
|
-
import { EDACommand } from "effect-durable-agent/types/commands";
|
|
5
|
-
import { CommandId, SequenceNumber, SessionId } from "effect-durable-agent/types/core";
|
|
6
|
+
import { EDACommand, GrantRunCommand } from "effect-durable-agent/types/commands";
|
|
7
|
+
import { CommandId, RunRequestId, SequenceNumber, SessionId } from "effect-durable-agent/types/core";
|
|
8
|
+
import "effect-durable-agent/types/events";
|
|
6
9
|
import { EDATraceMetadata } from "effect-durable-agent/types/tracing";
|
|
7
|
-
import
|
|
10
|
+
import { CommittedDurableEvent, EDAAppEvents } from "effect-durable-agent/services/session-store";
|
|
8
11
|
import { CommittedCommandTerminalEvent, EDARuntime, EDARuntimeConfig } from "effect-durable-agent/services/runtime";
|
|
9
|
-
import {
|
|
12
|
+
import { EDASessionSnapshot } from "effect-durable-agent/services/session-query";
|
|
13
|
+
import { RunGrantResult, RunRequestOutcome } from "effect-durable-agent/domain/run-scheduling";
|
|
14
|
+
import { EDATranscriptStoreShape, TranscriptSubscriptionPolicy } from "effect-durable-agent/transcript";
|
|
15
|
+
import { IdGenerator } from "effect-durable-agent/services/id-generator";
|
|
16
|
+
import { EDADecider } from "effect-durable-agent/services/decider";
|
|
10
17
|
import { CompactionExecutor, CompactionPolicy } from "effect-durable-agent/services/compaction";
|
|
11
|
-
import { EDAPromptProjector } from "effect-durable-agent/services/prompt-projector";
|
|
12
18
|
import { EDAReducer } from "effect-durable-agent/services/reducer-registry";
|
|
13
19
|
import { SessionEventObserver } from "effect-durable-agent/services/session-event-observer";
|
|
14
|
-
import { EDAWebSocketClientFrame, EDAWebSocketServerFrameEncoder, EDAWebSocketServerFrameInput } from "effect-durable-agent/websocket";
|
|
20
|
+
import { EDATranscriptDeliveryLimits, EDAWebSocketClientFrame, EDAWebSocketFlowControl, EDAWebSocketServerFrameEncoder, EDAWebSocketServerFrameInput } from "effect-durable-agent/websocket";
|
|
15
21
|
import { ModelResolver } from "effect-durable-agent/services/model-resolver";
|
|
16
|
-
import { DurableTranscriptMessage } from "effect-durable-agent/domain/message-transcript";
|
|
17
|
-
import { EDASessionSnapshot } from "effect-durable-agent/services/session-query";
|
|
18
22
|
import { EDASubmittable, SessionCommandAdmissionError } from "effect-durable-agent/services/session-state";
|
|
19
23
|
import { RunScheduler } from "effect-durable-agent/services/run-scheduler";
|
|
20
24
|
import * as Tracer from "effect/Tracer";
|
|
21
25
|
import { EDASink } from "effect-durable-agent/services/sink-registry";
|
|
22
26
|
import { EDAModelToolkit, EDAToolRegistryShape } from "effect-durable-agent/services/tool-registry";
|
|
23
27
|
import * as Fiber from "effect/Fiber";
|
|
24
|
-
|
|
25
28
|
//#region src/durable-object-keepalive.d.ts
|
|
26
29
|
/** Minimal Durable Object storage alarm surface needed by the EDA host keepalive. */
|
|
27
30
|
interface DurableObjectAlarmStorage {
|
|
@@ -53,6 +56,14 @@ interface DurableObjectKeepAliveLease {
|
|
|
53
56
|
/**
|
|
54
57
|
* Alarm-backed in-memory keepalive for a raw Durable Object host.
|
|
55
58
|
*
|
|
59
|
+
* Inbound events (requests, alarms) are what reliably keep an object resident: sessions streaming
|
|
60
|
+
* model responses and sandbox output were evicted 70-140 seconds after their last inbound event.
|
|
61
|
+
* The heartbeat therefore has to be delivered, not just scheduled: an armed alarm is never
|
|
62
|
+
* deleted or postponed when work is released, because finite work (model turns, sink catch-up)
|
|
63
|
+
* releases and re-acquires between steps, and moving the alarm on every step would keep it from
|
|
64
|
+
* ever firing. Only the alarm handler, finding no work left, or {@link shutdown} clears it, so a
|
|
65
|
+
* session that goes idle receives one final heartbeat.
|
|
66
|
+
*
|
|
56
67
|
* The active lease count is intentionally not durable: if the object is evicted
|
|
57
68
|
* or crashes, the fibers the leases represented are gone too, and normal EDA
|
|
58
69
|
* durable recovery must explain any escaped lifecycle boundaries.
|
|
@@ -64,12 +75,15 @@ declare class DurableObjectKeepAlive {
|
|
|
64
75
|
private readonly now;
|
|
65
76
|
private readonly onBackgroundError;
|
|
66
77
|
private activeLeases;
|
|
78
|
+
private runSchedulingPending;
|
|
67
79
|
private generation;
|
|
68
80
|
private scheduleTail;
|
|
69
81
|
private shutdownRequested;
|
|
70
82
|
constructor(storage: DurableObjectAlarmStorage, background?: DurableObjectBackgroundWaiter | undefined, options?: DurableObjectKeepAliveOptions);
|
|
71
83
|
/** Number of active unsettled host roots currently holding the heartbeat. */
|
|
72
84
|
get activeLeaseCount(): number;
|
|
85
|
+
/** Durable delivery work survives the release of every in-memory active lease. */
|
|
86
|
+
setRunSchedulingPending(pending: boolean): Promise<void>;
|
|
73
87
|
/** Acquire one active-work lease and arm the heartbeat if this is the first lease. */
|
|
74
88
|
acquire(): Promise<DurableObjectKeepAliveLease>;
|
|
75
89
|
/** Run a promise while holding a lease. Intended for host adapters, not EDA internals. */
|
|
@@ -90,13 +104,14 @@ declare class DurableObjectKeepAlive {
|
|
|
90
104
|
* internals or try to classify runnable vs suspended fibers.
|
|
91
105
|
*/
|
|
92
106
|
fork<A, E>(effect: Effect.Effect<A, E>): Promise<Fiber.Fiber<A, E>>;
|
|
93
|
-
/** Handle the Durable Object `alarm()` callback
|
|
107
|
+
/** Handle the Durable Object `alarm()` callback: re-arm while work remains, else clear. */
|
|
94
108
|
alarm(): Promise<void>;
|
|
95
109
|
/** Permanently stop the heartbeat and prevent later lease releases from re-arming it. */
|
|
96
110
|
shutdown(): Promise<void>;
|
|
97
111
|
/** Start a fresh lease generation after the host intentionally resets its durable state. */
|
|
98
112
|
restart(): void;
|
|
99
113
|
private waitUntil;
|
|
114
|
+
/** `clearWhenIdle`: only the alarm handler and shutdown may remove an idle object's alarm. */
|
|
100
115
|
private reschedule;
|
|
101
116
|
private syncAlarm;
|
|
102
117
|
}
|
|
@@ -106,7 +121,12 @@ declare class DurableObjectKeepAlive {
|
|
|
106
121
|
type EDASessionDurableObjectStorage = DurableObjectSessionStorage & DurableObjectAlarmStorage;
|
|
107
122
|
/** Host adapters and application policy needed to build one session runtime. */
|
|
108
123
|
interface EDADurableObjectRuntimeLayerOptions {
|
|
124
|
+
readonly appEvents?: EDAAppEvents;
|
|
109
125
|
readonly config: EDARuntimeConfig;
|
|
126
|
+
/** Deciders this session runs; the `decide` RPC and `EDARuntime.decide` share the registry. */
|
|
127
|
+
readonly deciders?: ReadonlyArray<EDADecider>;
|
|
128
|
+
/** Host-owned identity source, shared by every lifecycle service. Defaults to `IdGenerator.Live`. */
|
|
129
|
+
readonly idGeneratorLayer?: Layer.Layer<IdGenerator>;
|
|
110
130
|
readonly compactionExecutorLayer?: Layer.Layer<CompactionExecutor>;
|
|
111
131
|
readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;
|
|
112
132
|
readonly keepAlive?: DurableObjectKeepAlive;
|
|
@@ -121,25 +141,11 @@ interface EDADurableObjectRuntimeLayerOptions {
|
|
|
121
141
|
readonly toolkit?: EDAModelToolkit;
|
|
122
142
|
readonly toolRegistry?: EDAToolRegistryShape;
|
|
123
143
|
readonly tracer?: Tracer.Tracer;
|
|
144
|
+
/** Transcript definitions the session store maintains in every append. */
|
|
145
|
+
readonly transcript?: DurableObjectTranscriptOptions;
|
|
124
146
|
}
|
|
125
147
|
/** Compose the platform-neutral runtime with Cloudflare persistence and lifecycle adapters. */
|
|
126
|
-
declare const makeEDADurableObjectRuntimeLayer: ({
|
|
127
|
-
config,
|
|
128
|
-
compactionExecutorLayer,
|
|
129
|
-
compactionPolicyLayer,
|
|
130
|
-
keepAlive,
|
|
131
|
-
modelResolverLayer,
|
|
132
|
-
promptProjectorLayer,
|
|
133
|
-
reducers,
|
|
134
|
-
runSchedulerLayer,
|
|
135
|
-
sessionEventObserverLayer,
|
|
136
|
-
sessionId,
|
|
137
|
-
sinks,
|
|
138
|
-
storage,
|
|
139
|
-
toolkit,
|
|
140
|
-
toolRegistry,
|
|
141
|
-
tracer
|
|
142
|
-
}: EDADurableObjectRuntimeLayerOptions) => Layer.Layer<EDARuntime, SessionCommandAdmissionError>;
|
|
148
|
+
declare const makeEDADurableObjectRuntimeLayer: ({ appEvents, config, deciders, idGeneratorLayer, compactionExecutorLayer, compactionPolicyLayer, keepAlive, modelResolverLayer, promptProjectorLayer, reducers, runSchedulerLayer, sessionEventObserverLayer, sessionId, sinks, storage, toolkit, toolRegistry, tracer, transcript }: EDADurableObjectRuntimeLayerOptions) => Layer.Layer<EDARuntime, SessionCommandAdmissionError>;
|
|
143
149
|
//#endregion
|
|
144
150
|
//#region src/runtime/session-runtime.d.ts
|
|
145
151
|
type EDAToolkitFactory = (input: {
|
|
@@ -153,8 +159,23 @@ type EDATracerFactory = (input: {
|
|
|
153
159
|
}) => Tracer.Tracer;
|
|
154
160
|
/** Configuration owned by the lazy per-isolate Effect runtime. */
|
|
155
161
|
interface EDASessionRuntimeOptions {
|
|
162
|
+
/**
|
|
163
|
+
* The runtime's own view of the object's alarm. Hosts that share the alarm with other owners
|
|
164
|
+
* (the session Durable Object shares it with the transcript builder) pass that owner's view, so
|
|
165
|
+
* the keep-alive heartbeat never deletes another owner's wakeup. Defaults to `storage`.
|
|
166
|
+
*/
|
|
167
|
+
readonly alarmStorage?: DurableObjectAlarmStorage;
|
|
156
168
|
readonly background?: DurableObjectBackgroundWaiter;
|
|
169
|
+
readonly appEvents?: EDAAppEvents;
|
|
157
170
|
readonly config: EDARuntimeConfig;
|
|
171
|
+
/**
|
|
172
|
+
* Deciders this session runs, called in process with `EDARuntime.decide` or over the `decide`
|
|
173
|
+
* RPC by name. Construction fails on a duplicate or reserved name, or when a decider emits an
|
|
174
|
+
* app namespace `appEvents` does not register.
|
|
175
|
+
*/
|
|
176
|
+
readonly deciders?: ReadonlyArray<EDADecider>;
|
|
177
|
+
/** Host-owned identity source, shared by every lifecycle service. Defaults to `IdGenerator.Live`. */
|
|
178
|
+
readonly idGeneratorLayer?: Layer.Layer<IdGenerator>;
|
|
158
179
|
readonly compactionExecutorLayer?: Layer.Layer<CompactionExecutor>;
|
|
159
180
|
readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;
|
|
160
181
|
readonly keepAlive?: DurableObjectKeepAlive;
|
|
@@ -168,6 +189,13 @@ interface EDASessionRuntimeOptions {
|
|
|
168
189
|
readonly toolkit?: EDAModelToolkit | EDAToolkitFactory;
|
|
169
190
|
readonly toolRegistry?: EDAToolRegistryShape | EDAToolRegistryFactory;
|
|
170
191
|
readonly tracer?: Tracer.Tracer | EDATracerFactory;
|
|
192
|
+
/**
|
|
193
|
+
* Transcript definitions the session store maintains in every append, or a factory that
|
|
194
|
+
* returns none for a session whose transcript is not enabled.
|
|
195
|
+
*/
|
|
196
|
+
readonly transcript?: DurableObjectTranscriptOptions | ((input: {
|
|
197
|
+
readonly sessionId: SessionId;
|
|
198
|
+
}) => DurableObjectTranscriptOptions | undefined);
|
|
171
199
|
}
|
|
172
200
|
//#endregion
|
|
173
201
|
//#region src/websocket/projection.d.ts
|
|
@@ -185,7 +213,8 @@ type EDAWebSocketProjectionResult<State extends object> = {
|
|
|
185
213
|
readonly frame: string;
|
|
186
214
|
readonly state: State;
|
|
187
215
|
} | {
|
|
188
|
-
/** Suppress an internal-only events frame and advance its ACK in the host. */
|
|
216
|
+
/** Suppress an internal-only events frame and advance its ACK in the host. */
|
|
217
|
+
readonly _tag: "SuppressAndAck";
|
|
189
218
|
readonly state: State;
|
|
190
219
|
};
|
|
191
220
|
/**
|
|
@@ -213,12 +242,47 @@ interface EDAWebSocketProjection<State extends object> {
|
|
|
213
242
|
}) => EDAWebSocketProjectionInitial<State>;
|
|
214
243
|
}
|
|
215
244
|
//#endregion
|
|
245
|
+
//#region src/websocket/transcript-sockets.d.ts
|
|
246
|
+
/** Tuning for transcript-window sockets; every field has a production default. */
|
|
247
|
+
interface EDATranscriptSocketOptions {
|
|
248
|
+
/** Runtime-free transcript reads for this session. */
|
|
249
|
+
readonly transcriptStore: EDATranscriptStoreShape;
|
|
250
|
+
readonly flowControl?: EDAWebSocketFlowControl;
|
|
251
|
+
readonly subscriptionPolicy?: TranscriptSubscriptionPolicy;
|
|
252
|
+
readonly deliveryLimits?: EDATranscriptDeliveryLimits;
|
|
253
|
+
/**
|
|
254
|
+
* Display cadence for live content: changed active content is published as one complete
|
|
255
|
+
* replacement at most once per interval, never as raw deltas.
|
|
256
|
+
*/
|
|
257
|
+
readonly activeContentCadenceMs?: number;
|
|
258
|
+
/**
|
|
259
|
+
* How long a capture may wait for publication to catch up with a commit before it is served
|
|
260
|
+
* without live content. Publication normally follows commit within one append.
|
|
261
|
+
*/
|
|
262
|
+
readonly fenceWaitMs?: number;
|
|
263
|
+
/**
|
|
264
|
+
* Bytes of chunked updates staged across all sockets of the object. A socket whose update would
|
|
265
|
+
* exceed it is closed with `4009` and resubscribes later. Each socket is also bounded by
|
|
266
|
+
* `deliveryLimits.maxStagedBytes`.
|
|
267
|
+
*/
|
|
268
|
+
readonly maxTotalStagedBytes?: number;
|
|
269
|
+
/** Timer seam for the cadence; the default uses `setTimeout`. */
|
|
270
|
+
readonly schedule?: (delayMs: number, run: () => void) => void;
|
|
271
|
+
readonly now?: () => number;
|
|
272
|
+
}
|
|
273
|
+
declare const defaultActiveContentCadenceMs = 50;
|
|
274
|
+
//#endregion
|
|
216
275
|
//#region src/session-controller.d.ts
|
|
217
276
|
/** Composition options for the session use cases and Cloudflare adapters. */
|
|
218
277
|
interface EDASessionControllerOptions<ProjectionState extends object = never> extends Omit<EDASessionRuntimeOptions, "sessionEventObserverLayer"> {
|
|
219
278
|
readonly getWebSockets?: () => ReadonlyArray<WebSocket>;
|
|
220
279
|
readonly webSocketProjection?: EDAWebSocketProjection<ProjectionState>;
|
|
221
280
|
readonly webSocketProtocol?: EDAWebSocketServerFrameEncoder;
|
|
281
|
+
/**
|
|
282
|
+
* Serves transcript-window sockets (`?stream=transcript`) from this transcript store. Without
|
|
283
|
+
* it, only raw event sockets are accepted.
|
|
284
|
+
*/
|
|
285
|
+
readonly transcriptSockets?: EDATranscriptSocketOptions;
|
|
222
286
|
}
|
|
223
287
|
interface EDASessionSubmitInput {
|
|
224
288
|
readonly command: EDACommand;
|
|
@@ -230,6 +294,24 @@ interface EDASessionSubmitBatchInput {
|
|
|
230
294
|
readonly sessionId: SessionId;
|
|
231
295
|
readonly trace?: EDATraceMetadata;
|
|
232
296
|
}
|
|
297
|
+
interface EDASessionDecideInput {
|
|
298
|
+
/** A registered decider's name. */
|
|
299
|
+
readonly decider: string;
|
|
300
|
+
/** The decider's input, encoded with its `input` schema. */
|
|
301
|
+
readonly input: unknown;
|
|
302
|
+
readonly sessionId: SessionId;
|
|
303
|
+
readonly trace?: EDATraceMetadata;
|
|
304
|
+
}
|
|
305
|
+
/** A decider outcome with its result or rejection encoded by the decider's schemas. */
|
|
306
|
+
type EDASessionDecideResult = {
|
|
307
|
+
readonly _tag: "Accepted";
|
|
308
|
+
readonly result: Schema.Json;
|
|
309
|
+
readonly acceptedSeq: SequenceNumber;
|
|
310
|
+
readonly replayed: boolean;
|
|
311
|
+
} | {
|
|
312
|
+
readonly _tag: "Rejected";
|
|
313
|
+
readonly rejection: Schema.Json;
|
|
314
|
+
};
|
|
233
315
|
interface EDASessionBlockOnCommandInput {
|
|
234
316
|
readonly afterSeq?: SequenceNumber;
|
|
235
317
|
readonly commandId: CommandId;
|
|
@@ -261,14 +343,27 @@ interface EDAPreparedEventWebSocket<ProjectionState extends object = never> {
|
|
|
261
343
|
declare class EDASessionController<ProjectionState extends object = never> {
|
|
262
344
|
private readonly runtime;
|
|
263
345
|
private readonly webSockets;
|
|
346
|
+
private readonly deciders;
|
|
264
347
|
constructor(options: EDASessionControllerOptions<ProjectionState>);
|
|
265
348
|
static readonly migrate: (storage: EDASessionDurableObjectStorage) => Effect.Effect<void, import("effect-durable-agent/services/session-store").EDASessionStoreError>;
|
|
349
|
+
/** Trusted reconciliation read; never submits or grants replacement work. */
|
|
350
|
+
runRequestOutcome(input: EDASessionScopedInput & {
|
|
351
|
+
readonly requestId: RunRequestId;
|
|
352
|
+
}): Promise<RunRequestOutcome>;
|
|
353
|
+
/** Trusted scheduler ingress. Hosts must authorize callers before invoking this method. */
|
|
354
|
+
grantRun(input: EDASessionScopedInput & {
|
|
355
|
+
readonly command: GrantRunCommand;
|
|
356
|
+
}): Promise<RunGrantResult>;
|
|
266
357
|
submit(input: EDASessionSubmitInput): Promise<CommittedDurableEvent>;
|
|
267
358
|
submitBatch(input: EDASessionSubmitBatchInput): Promise<ReadonlyArray<CommittedDurableEvent>>;
|
|
359
|
+
/**
|
|
360
|
+
* Trusted ingress, like `submitBatch`: run a registered decider by name. Decodes `input` with
|
|
361
|
+
* the decider's `input` schema and encodes the outcome with its `result` or `rejection` schema.
|
|
362
|
+
*/
|
|
363
|
+
decide(input: EDASessionDecideInput): Promise<EDASessionDecideResult>;
|
|
268
364
|
submitAndBlock(input: EDASessionSubmitInput): Promise<CommittedCommandTerminalEvent>;
|
|
269
365
|
blockOnCommand(input: EDASessionBlockOnCommandInput): Promise<CommittedCommandTerminalEvent>;
|
|
270
366
|
snapshot(input: EDASessionScopedInput): Promise<EDASessionSnapshot>;
|
|
271
|
-
messages(input: EDASessionScopedInput): Promise<ReadonlyArray<DurableTranscriptMessage>>;
|
|
272
367
|
acceptEventWebSocket(input: EDASessionEventsInput & {
|
|
273
368
|
readonly projectionId?: string;
|
|
274
369
|
readonly webSocket: WebSocket;
|
|
@@ -280,6 +375,19 @@ declare class EDASessionController<ProjectionState extends object = never> {
|
|
|
280
375
|
acceptPreparedEventWebSocket(input: EDAPreparedEventWebSocket<ProjectionState> & {
|
|
281
376
|
readonly webSocket: WebSocket;
|
|
282
377
|
}): Promise<void>;
|
|
378
|
+
/** The served transcript version changed: give every transcript socket a replacement. */
|
|
379
|
+
refreshTranscriptWebSockets(): Promise<void>;
|
|
380
|
+
/** Whether transcript-window sockets are served. */
|
|
381
|
+
get supportsTranscriptWebSocket(): boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Register a transcript-window socket right after the host accepted it. Never prepares the
|
|
384
|
+
* model runtime: windows are storage-level reads.
|
|
385
|
+
*/
|
|
386
|
+
acceptTranscriptWebSocket(input: {
|
|
387
|
+
readonly sessionId: SessionId;
|
|
388
|
+
readonly trace?: EDATraceMetadata;
|
|
389
|
+
readonly webSocket: WebSocket;
|
|
390
|
+
}): void;
|
|
283
391
|
webSocketMessage(webSocket: WebSocket, message: string | ArrayBuffer): Promise<void>;
|
|
284
392
|
webSocketClose(webSocket: WebSocket): void;
|
|
285
393
|
webSocketError(webSocket: WebSocket): void;
|
|
@@ -291,5 +399,5 @@ declare class EDASessionController<ProjectionState extends object = never> {
|
|
|
291
399
|
private run;
|
|
292
400
|
}
|
|
293
401
|
//#endregion
|
|
294
|
-
export {
|
|
295
|
-
//# sourceMappingURL=session-controller-
|
|
402
|
+
export { EDADurableObjectRuntimeLayerOptions as _, EDASessionDecideInput as a, DurableObjectAlarmStorage as b, EDASessionScopedInput as c, EDATranscriptSocketOptions as d, defaultActiveContentCadenceMs as f, EDAWebSocketProjectionResult as g, EDAWebSocketProjectionInitial as h, EDASessionControllerOptions as i, EDASessionSubmitBatchInput as l, EDAWebSocketProjectionId as m, EDASessionBlockOnCommandInput as n, EDASessionDecideResult as o, EDAWebSocketProjection as p, EDASessionController as r, EDASessionEventsInput as s, EDAPreparedEventWebSocket as t, EDASessionSubmitInput as u, EDASessionDurableObjectStorage as v, makeEDADurableObjectRuntimeLayer as y };
|
|
403
|
+
//# sourceMappingURL=session-controller-Cfd5Zjd5.d.ts.map
|