effect-durable-agent-cloudflare 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{durable-object-BDEZt4Ei.js → durable-object-bmMjpZbM.js} +2 -2
- package/dist/durable-object-bmMjpZbM.js.map +1 -0
- package/dist/durable-object.d.ts +2 -2
- package/dist/durable-object.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{session-controller-lxEYKeOb.js → session-controller-BhbkW0Iw.js} +36 -16
- package/dist/session-controller-BhbkW0Iw.js.map +1 -0
- package/dist/{session-controller-v7nzm-hF.d.ts → session-controller-CG5le-8n.d.ts} +13 -3
- package/dist/session-controller.d.ts +1 -1
- package/dist/session-controller.js +1 -1
- package/package.json +2 -2
- package/dist/durable-object-BDEZt4Ei.js.map +0 -1
- package/dist/session-controller-lxEYKeOb.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as encodeEdaRpcDurableEvent, _ as DurableObjectTranscriptStore, a as SessionGrantRunInput, c as SessionTranscriptBodyInput, f as SessionTranscriptWindowInput, g as DurableObjectTranscriptBuilder, h as edaSessionRpc, i as SessionDecideInput, n as SessionBlockInput, o as SessionOutcomeInput, r as SessionCommandInput, s as SessionScopedInput, t as SessionBatchInput, u as SessionTranscriptSummaryInput } from "./rpc-spec-BU5bGUWF.js";
|
|
2
2
|
import { i as readDurableObjectSummary, m as resolveTranscriptSliceLimits, r as readDurableObjectCommittedEvent, s as defaultTranscriptSliceLimits } from "./durable-object-store-lJkqwvIj.js";
|
|
3
|
-
import { t as EDASessionController } from "./session-controller-
|
|
3
|
+
import { t as EDASessionController } from "./session-controller-BhbkW0Iw.js";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import { durableEventEnvelope } from "effect-durable-agent/types/events/durable";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
@@ -630,4 +630,4 @@ const encodeEdaRpcSessionSnapshot = Schema.encodeSync(edaSessionRpc.snapshot.out
|
|
|
630
630
|
//#endregion
|
|
631
631
|
export { encodeEdaRpcCommittedDurableEvent as a, DurableObjectAlarmScheduler as c, edaRuntimeConfig as i, EDA_WEB_SOCKET_PROJECTION_HEADER as n, encodeEdaRpcSessionSnapshot as o, EDA_WEB_SOCKET_STREAM_PARAM as r, getEDASessionDurableObjectByName as s, EDASessionDurableObject as t };
|
|
632
632
|
|
|
633
|
-
//# sourceMappingURL=durable-object-
|
|
633
|
+
//# sourceMappingURL=durable-object-bmMjpZbM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-object-bmMjpZbM.js","names":["#wakeup","#write","#rows","#tail","#controller","#webSocketProjectionId","#alarms","#transcriptOptions","#transcriptEnabled","#transcript"],"sources":["../src/durable-object-alarm-handler.ts","../src/durable-object-alarms.ts","../src/durable-object.ts"],"sourcesContent":["import type { DurableObjectAlarmScheduler } from \"./durable-object-alarms\";\n\n/** What one session object's alarm fires for, and the policy bounding builder retries. */\nexport interface EDASessionAlarmParticipants {\n readonly alarms: DurableObjectAlarmScheduler;\n readonly now: () => number;\n /** The runtime's alarm work: keep-alive and run-scheduling redelivery. */\n readonly runRuntime: () => Promise<void>;\n /**\n * Bounded builder slices; resolves whether work remains. Undefined when this object's session\n * maintains no transcript (it is not enabled, or the object is unnamed).\n */\n readonly runBuilderSlices: (() => Promise<boolean>) | undefined;\n /** Consecutive failed builder alarms before the builder stops scheduling itself. */\n readonly maxBuilderFailures: number;\n /** First retry delay after a failed builder alarm; doubled per consecutive failure. */\n readonly builderRetryDelayMs: number;\n readonly onBuilderFailure: (failure: {\n readonly error: unknown;\n readonly consecutiveFailures: number;\n readonly stopped: boolean;\n }) => void;\n}\n\n/** Longest delay between builder retries. */\nconst maxBuilderRetryDelayMs = 3_600_000;\n\n/**\n * Handle one platform alarm shared by the runtime and the transcript builder.\n *\n * - The runtime runs for its own wakeup, or for an alarm no owner recorded (one armed by a\n * release before wakeups were recorded). The builder runs for its wakeup even when the runtime\n * failed.\n * - No wakeup is consumed up front: each owner's is cleared only after its work succeeds, so a\n * handler that throws or dies mid-work leaves the platform's retry attributed to every owner it\n * fired for.\n * - A failed builder retries with exponential backoff; its consecutive failures persist with its\n * wakeup, so eviction cannot reset them, and at `maxBuilderFailures` it stops scheduling itself.\n * No failure re-arms the alarm sooner than the backoff, so no object can loop on its alarm.\n * - A failed runtime rethrows without re-arming the platform alarm, so the platform's own retry\n * (backoff and retry cap) applies; otherwise the alarm is pointed at the earliest wakeup left.\n */\nexport const runEDASessionAlarm = async (participants: EDASessionAlarmParticipants) => {\n const { alarms } = participants;\n const now = participants.now();\n const due = alarms.due(now);\n let runtimeFailure: { readonly error: unknown } | undefined;\n if (due.has(\"runtime\") || due.size === 0) {\n try {\n await participants.runRuntime();\n alarms.clearThrough(\"runtime\", due.get(\"runtime\") ?? now);\n } catch (error) {\n runtimeFailure = { error };\n }\n }\n const builderWakeup = due.get(\"transcript\");\n if (builderWakeup !== undefined) {\n const runBuilderSlices = participants.runBuilderSlices;\n if (runBuilderSlices === undefined) {\n alarms.clear(\"transcript\");\n } else {\n try {\n if (await runBuilderSlices()) alarms.retain(\"transcript\", participants.now());\n else alarms.clearThrough(\"transcript\", builderWakeup);\n } catch (error) {\n const consecutiveFailures = alarms.failures(\"transcript\") + 1;\n const stopped = consecutiveFailures >= participants.maxBuilderFailures;\n if (stopped) {\n alarms.clear(\"transcript\");\n } else {\n const delayMs = Math.min(\n participants.builderRetryDelayMs * 2 ** (consecutiveFailures - 1),\n maxBuilderRetryDelayMs,\n );\n alarms.retain(\"transcript\", participants.now() + delayMs, consecutiveFailures);\n }\n participants.onBuilderFailure({ error, consecutiveFailures, stopped });\n }\n }\n }\n if (runtimeFailure !== undefined) throw runtimeFailure.error;\n await alarms.sync();\n};\n","import type { DurableObjectAlarmStorage } from \"./durable-object-keepalive\";\nimport type { DurableObjectSessionStorage } from \"./durable-object-storage\";\n\n/**\n * The independent owners of a session object's single platform alarm.\n *\n * - `runtime`: the keep-alive heartbeat and run-scheduling redelivery; its wakeup builds the model\n * runtime.\n * - `transcript`: the transcript builder; its wakeup runs storage-only slices and must never\n * build the model runtime.\n */\nexport type DurableObjectAlarmOwner = \"runtime\" | \"transcript\";\n\n/**\n * Shares one Durable Object alarm between owners that each keep a durable wakeup.\n *\n * Each owner's wakeup is a row in `_eda_alarm_wakeups`, and the platform alarm is always set to the\n * earliest row, so no owner can delete or postpone another's wakeup, and after an eviction the\n * alarm handler still knows which owners it fired for. An owner's view (`owner(...)`) has the\n * same shape as the platform alarm API, so the keep-alive heartbeat uses it unchanged.\n */\nexport class DurableObjectAlarmScheduler {\n #tail: Promise<void> = Promise.resolve();\n\n constructor(\n private readonly storage: DurableObjectSessionStorage & DurableObjectAlarmStorage,\n private readonly now: () => number = () => Date.now(),\n ) {}\n\n /**\n * One owner's alarm, behaving like the platform alarm restricted to that owner. Like the\n * platform's, it reports no alarm once its time has come: a wakeup left behind when the\n * platform gave up retrying a failed alarm must not look armed, or its owner would never re-arm.\n * \"Come\" includes the exact millisecond: inside the alarm it fired for, the Workers clock\n * commonly reads exactly the scheduled time, and a wakeup that still looked armed then would\n * keep the keep-alive from re-arming before the handler clears it.\n */\n owner(owner: DurableObjectAlarmOwner): DurableObjectAlarmStorage {\n return {\n getAlarm: () => {\n const wakeup = this.#wakeup(owner);\n return wakeup === undefined || wakeup <= this.now() ? null : wakeup;\n },\n setAlarm: (scheduledTimeMs) => {\n this.#write(owner, scheduledTimeMs);\n return this.sync();\n },\n deleteAlarm: () => {\n this.#write(owner, undefined);\n return this.sync();\n },\n };\n }\n\n /**\n * Adopt a platform alarm no owner recorded (one armed before wakeups were recorded) as the\n * runtime's, so the first wakeup another owner requests cannot replace it. Call once at startup,\n * before any owner writes a wakeup.\n */\n async adoptUnrecordedAlarm(): Promise<void> {\n if (this.#rows().length > 0) return;\n const armed = await this.storage.getAlarm();\n if (armed !== null && this.#rows().length === 0) this.#write(\"runtime\", armed);\n }\n\n /**\n * Record `owner`'s wakeup without touching the platform alarm, for use inside `alarm()`: the\n * caller syncs once at the end, or not at all when it rethrows, which leaves the platform's own\n * retry (with its backoff and cap) in force.\n */\n retain(owner: DurableObjectAlarmOwner, atMs: number, failures = 0): void {\n this.#write(owner, atMs, failures);\n }\n\n /** Consecutive failures recorded with `owner`'s wakeup; 0 without one. */\n failures(owner: DurableObjectAlarmOwner): number {\n return (\n this.storage.sql\n .exec<{ readonly failures: number }>(\n \"SELECT failures FROM _eda_alarm_wakeups WHERE owner = ?\",\n owner,\n )\n .toArray()[0]?.failures ?? 0\n );\n }\n\n /** Remove `owner`'s wakeup whatever its time; call `sync` afterwards. */\n clear(owner: DurableObjectAlarmOwner): void {\n this.#write(owner, undefined);\n }\n\n /** Wake `owner` no later than `atMs`; an earlier wakeup it already holds is kept. */\n request(owner: DurableObjectAlarmOwner, atMs: number): Promise<void> {\n const current = this.#wakeup(owner);\n if (current !== undefined && current <= atMs) return this.sync();\n this.#write(owner, atMs);\n return this.sync();\n }\n\n /**\n * Called when the platform alarm fires: the owners it fired for (every wakeup at or before now,\n * and always the earliest one) and the wakeup each held. Nothing is consumed here: each owner\n * `clearThrough`s its wakeup only after its work succeeds, so a handler that throws, or dies\n * mid-work (eviction, deploy, a resource limit), leaves the platform's retry attributed to every\n * owner it fired for. An owner's view already reports a past wakeup as no alarm, so the runtime's\n * keep-alive re-arms during its work as it did with the platform alarm.\n */\n due(nowMs: number): ReadonlyMap<DurableObjectAlarmOwner, number> {\n const rows = this.#rows();\n const earliest = rows.reduce((min, row) => Math.min(min, row.at_ms), Number.POSITIVE_INFINITY);\n const threshold = Math.max(nowMs, earliest);\n const due = new Map<DurableObjectAlarmOwner, number>();\n for (const row of rows) {\n if (row.at_ms <= threshold && isOwner(row.owner)) due.set(row.owner, row.at_ms);\n }\n return due;\n }\n\n /**\n * Remove `owner`'s wakeup if it is still at or before `atMs`, once the work it fired for has\n * succeeded. A later wakeup the owner re-armed during that work is kept.\n */\n clearThrough(owner: DurableObjectAlarmOwner, atMs: number): void {\n this.storage.sql.exec(\n \"DELETE FROM _eda_alarm_wakeups WHERE owner = ? AND at_ms <= ?\",\n owner,\n atMs,\n );\n }\n\n /** Point the platform alarm at the earliest wakeup, or clear it when none remains. */\n sync(): Promise<void> {\n this.#tail = this.#tail\n .catch(() => undefined)\n .then(async () => {\n const earliest = this.storage.sql\n .exec<{ readonly at_ms: number | null }>(\n \"SELECT MIN(at_ms) AS at_ms FROM _eda_alarm_wakeups\",\n )\n .one().at_ms;\n if (earliest === null) {\n await this.storage.deleteAlarm();\n return;\n }\n if ((await this.storage.getAlarm()) !== earliest) {\n await this.storage.setAlarm(earliest);\n }\n });\n return this.#tail;\n }\n\n #rows(): ReadonlyArray<{ readonly owner: string; readonly at_ms: number }> {\n return this.storage.sql\n .exec<{ readonly owner: string; readonly at_ms: number }>(\n \"SELECT owner, at_ms FROM _eda_alarm_wakeups\",\n )\n .toArray();\n }\n\n #wakeup(owner: DurableObjectAlarmOwner): number | undefined {\n return this.storage.sql\n .exec<{ readonly at_ms: number }>(\n \"SELECT at_ms FROM _eda_alarm_wakeups WHERE owner = ?\",\n owner,\n )\n .toArray()[0]?.at_ms;\n }\n\n /** Upsert or delete `owner`'s wakeup. Without `failures`, an existing count is kept. */\n #write(owner: DurableObjectAlarmOwner, atMs: number | undefined, failures?: number): void {\n if (atMs === undefined) {\n this.storage.sql.exec(\"DELETE FROM _eda_alarm_wakeups WHERE owner = ?\", owner);\n return;\n }\n if (failures === undefined) {\n this.storage.sql.exec(\n `INSERT INTO _eda_alarm_wakeups (owner, at_ms) VALUES (?, ?)\n ON CONFLICT(owner) DO UPDATE SET at_ms = excluded.at_ms`,\n owner,\n atMs,\n );\n return;\n }\n this.storage.sql.exec(\n `INSERT INTO _eda_alarm_wakeups (owner, at_ms, failures) VALUES (?, ?, ?)\n ON CONFLICT(owner) DO UPDATE SET at_ms = excluded.at_ms, failures = excluded.failures`,\n owner,\n atMs,\n failures,\n );\n }\n}\n\nconst isOwner = (owner: string): owner is DurableObjectAlarmOwner =>\n owner === \"runtime\" || owner === \"transcript\";\n","import type { CommittedDurableEvent } from \"effect-durable-agent/services/session-store\";\nimport { durableEventEnvelope } from \"effect-durable-agent/types/events/durable\";\nimport { encodeEdaRpcDurableEvent } from \"./rpc-codec\";\nimport {\n SessionScopedInput,\n SessionTranscriptBodyInput,\n SessionTranscriptSummaryInput,\n SessionTranscriptWindowInput,\n SessionCommandInput,\n SessionGrantRunInput,\n SessionBatchInput,\n SessionDecideInput,\n SessionBlockInput,\n SessionOutcomeInput,\n edaSessionRpc,\n} from \"./rpc-spec\";\nimport { DurableObject } from \"cloudflare:workers\";\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\n\nimport type { EDARuntimeConfig } from \"effect-durable-agent/services/runtime\";\nimport {\n CommandId,\n RunRequestId,\n SequenceNumber,\n SessionId,\n} from \"effect-durable-agent/types/core\";\nimport {\n EDATraceMetadata,\n makeEDATraceMetadataFromParent,\n makeRootEDATraceMetadata,\n parseEDATraceparent,\n} from \"effect-durable-agent/types/tracing\";\nimport {\n EDASessionController,\n type EDASessionControllerOptions,\n type EDASessionDurableObjectStorage,\n} from \"./session-controller\";\nimport {\n EDA_WEB_SOCKET_PING_MESSAGE,\n EDA_WEB_SOCKET_PONG_MESSAGE,\n} from \"effect-durable-agent/websocket\";\nimport * as Result from \"effect/Result\";\nimport {\n defaultTranscriptWindowLimits,\n emptyTranscriptMappings,\n makeTranscriptDefinition,\n resolveTranscriptBody,\n type EDATranscriptStoreShape,\n type TranscriptLogIncarnation,\n type TranscriptMaintenanceConfig,\n} from \"effect-durable-agent/transcript\";\nimport { runEDASessionAlarm } from \"./durable-object-alarm-handler\";\nimport { DurableObjectAlarmScheduler } from \"./durable-object-alarms\";\nimport { readDurableObjectCommittedEvent, readDurableObjectSummary } from \"./durable-object-store\";\nimport type { EDATranscriptSocketOptions } from \"./websocket/transcript-sockets\";\nimport { EDASessionStoreError } from \"effect-durable-agent/services/session-store\";\nimport {\n DurableObjectTranscriptBuilder,\n DurableObjectTranscriptStore,\n} from \"./durable-object-transcript\";\nimport {\n defaultTranscriptSliceLimits,\n resolveTranscriptSliceLimits,\n type DurableObjectTranscriptObserver,\n type DurableObjectTranscriptOptions,\n type DurableObjectTranscriptSliceLimits,\n type TranscriptAlert,\n} from \"./durable-object-transcript-maintenance\";\n\nexport type { EDAWebSocketProjection, EDAWebSocketProjectionContext } from \"./websocket/projection\";\n/** Internal Worker-to-object header selecting an app-owned WebSocket projection. */\nexport const EDA_WEB_SOCKET_PROJECTION_HEADER = \"x-eda-websocket-projection\";\n\n/**\n * Upgrade query parameter selecting the socket's stream: `transcript` selects the ordered\n * transcript-window stream; anything else keeps the raw event stream.\n */\nexport const EDA_WEB_SOCKET_STREAM_PARAM = \"stream\";\n\n/** Encoded session RPC inputs, decoded before invoking the controller. */\nexport type EDASessionCommandRpcInput = typeof SessionCommandInput.Encoded;\nexport type EDASessionGrantRunRpcInput = typeof SessionGrantRunInput.Encoded;\nexport type EDASessionSubmitBatchRpcInput = typeof SessionBatchInput.Encoded;\nexport type EDASessionDecideRpcInput = typeof SessionDecideInput.Encoded;\nexport type EDASessionScopedRpcInput = typeof SessionScopedInput.Encoded;\nexport type EDASessionEventsRpcInput = EDASessionScopedRpcInput & { readonly afterSeq?: number };\nexport type EDASessionBlockOnCommandRpcInput = typeof SessionBlockInput.Encoded;\nexport type EDASessionRunRequestOutcomeRpcInput = typeof SessionOutcomeInput.Encoded;\n\n/** EDA RPC methods required by the session namespace helper. */\nexport interface EDASessionRpcSurface {\n readonly runRequestOutcome: (\n input: EDASessionRunRequestOutcomeRpcInput,\n ) => Promise<typeof edaSessionRpc.runRequestOutcome.output.Encoded>;\n readonly grantRun: (\n input: EDASessionGrantRunRpcInput,\n ) => Promise<typeof edaSessionRpc.grantRun.output.Encoded>;\n readonly submit: (\n input: EDASessionCommandRpcInput,\n ) => Promise<typeof edaSessionRpc.submit.output.Encoded>;\n readonly submitBatch: (\n input: EDASessionSubmitBatchRpcInput,\n ) => Promise<typeof edaSessionRpc.submitBatch.output.Encoded>;\n readonly decide: (\n input: EDASessionDecideRpcInput,\n ) => Promise<typeof edaSessionRpc.decide.output.Encoded>;\n readonly submitAndBlock: (\n input: EDASessionCommandRpcInput,\n ) => Promise<typeof edaSessionRpc.submitAndBlock.output.Encoded>;\n readonly blockOnCommand: (\n input: EDASessionBlockOnCommandRpcInput,\n ) => Promise<typeof edaSessionRpc.blockOnCommand.output.Encoded>;\n readonly snapshot: (\n input: EDASessionScopedRpcInput,\n ) => Promise<typeof edaSessionRpc.snapshot.output.Encoded>;\n readonly destroySession: (\n input: EDASessionScopedRpcInput,\n ) => Promise<typeof edaSessionRpc.destroySession.output.Encoded>;\n readonly transcriptStatus: (\n input: EDASessionScopedRpcInput,\n ) => Promise<typeof edaSessionRpc.transcriptStatus.output.Encoded>;\n readonly readTranscriptWindow: (\n input: typeof SessionTranscriptWindowInput.Encoded,\n ) => Promise<typeof edaSessionRpc.readTranscriptWindow.output.Encoded>;\n readonly readTranscriptBody: (\n input: typeof SessionTranscriptBodyInput.Encoded,\n ) => Promise<typeof edaSessionRpc.readTranscriptBody.output.Encoded>;\n readonly readTranscriptSummary: (\n input: typeof SessionTranscriptSummaryInput.Encoded,\n ) => Promise<typeof edaSessionRpc.readTranscriptSummary.output.Encoded>;\n}\n\n/** Host transcript configuration of a session Durable Object. */\nexport interface EDASessionTranscriptOptions {\n /**\n * Which sessions maintain a transcript; default **off**. A disabled session gets no transcript\n * writes, builder slices or wakeups: `readTranscriptWindow` answers `Disabled`,\n * `transcriptStatus` reports `Disabled` without writing, and transcript sockets are\n * refused. Enabling a session takes the first-introduction path (a build from the log, then\n * activation). Rollout rings use a deterministic predicate (for example a hash of the session\n * id under a percentage); disabling leaves a session's rows untouched, and re-enabling catches\n * an active version up to the head before it is served as current. Evaluated once per object\n * instance, so a change takes effect when the object next starts.\n */\n readonly enabled?: boolean | ((sessionId: SessionId) => boolean);\n /**\n * Builder bounds: events per slice, rows deleted per slice, and `maxSliceFailures` (default 5),\n * the consecutive failures after which a build freezes as failed and a failing builder alarm\n * stops scheduling itself.\n */\n readonly sliceLimits?: Partial<DurableObjectTranscriptSliceLimits>;\n /**\n * The transcript definitions this release carries. Defaults to the definition with no host\n * mappings. A host changing its mappings ships `current` = new, `previous` = old, then runs\n * its backfill through `transcriptStatus` (see `docs/transcript-history.md` §7).\n */\n readonly definitions?: TranscriptMaintenanceConfig;\n /**\n * Adopt the host's existing log incarnation from this `ctx.storage.kv` key (Gia:\n * `gia.log_incarnation`). Without it the adapter mints its own.\n */\n readonly adoptIncarnationKey?: string;\n /** Alerts (frozen versions, missed sessions). Defaults to `console.error`. */\n readonly onAlert?: (alert: TranscriptAlert) => void;\n /** A rebuilt version became active. */\n readonly onActivated?: DurableObjectTranscriptObserver[\"onActivated\"];\n}\n\n/** Constructor options for concrete app subclasses of the EDA Durable Object base. */\nexport type EDASessionDurableObjectOptions<ProjectionState extends object = never> = Omit<\n EDASessionControllerOptions<ProjectionState>,\n \"alarmStorage\" | \"background\" | \"getWebSockets\" | \"storage\" | \"transcript\" | \"transcriptSockets\"\n> & {\n readonly transcript?: EDASessionTranscriptOptions;\n /**\n * Serve transcript-window sockets (`?stream=transcript`). `transcriptStore` defaults to this\n * object's own runtime-free Durable Object transcript store.\n */\n readonly transcriptSockets?: Omit<EDATranscriptSocketOptions, \"transcriptStore\"> & {\n readonly transcriptStore?: EDATranscriptSocketOptions[\"transcriptStore\"];\n };\n};\n\n/** Slices a backfill `transcriptStatus` call may run before it returns. */\nconst transcriptStatusMaxSlices = 16;\n/** Server bounds on one `readTranscriptWindow` RPC, whatever limits the caller asks for. */\nconst transcriptWindowMaxRecords = 500;\nconst transcriptWindowMaxBytes = 8 * 1_048_576;\n/** First retry delay after a failed builder alarm; doubled per consecutive failure. */\nconst transcriptBuilderRetryDelayMs = 30_000;\n/** Slices one builder alarm runs before rescheduling itself. */\nconst transcriptAlarmMaxSlices = 4;\n\n/** Resolve a concrete EDA session Durable Object binding by domain session id. */\nexport const getEDASessionDurableObjectByName = <\n T extends Rpc.DurableObjectBranded & EDASessionRpcSurface,\n>(\n namespace: DurableObjectNamespace<T>,\n sessionId: string,\n): DurableObjectStub<T> => namespace.getByName(sessionId);\n\n/**\n * Base class for raw Cloudflare Durable Object hosts of one EDA session.\n *\n * Concrete products should extend this class, pass provider/tool layers from\n * their own constructor, and register only that subclass in Wrangler. The base\n * class is deliberately not exported from `workers/app.ts` and owns no binding\n * name or routing convention.\n */\nexport abstract class EDASessionDurableObject<\n EnvType extends object = object,\n ProjectionState extends object = never,\n> extends DurableObject<EnvType> {\n readonly #controller: EDASessionController<ProjectionState>;\n readonly #webSocketProjectionId: string | undefined;\n readonly #alarms: DurableObjectAlarmScheduler;\n readonly #transcriptOptions: DurableObjectTranscriptOptions;\n #transcript:\n | {\n readonly sessionId: SessionId;\n /** Whether the host enabled transcript maintenance for this session. */\n readonly enabled: boolean;\n readonly store: DurableObjectTranscriptStore;\n readonly builder: DurableObjectTranscriptBuilder;\n }\n | undefined;\n readonly #transcriptEnabled: (sessionId: SessionId) => boolean;\n\n protected constructor(\n ctx: DurableObjectState,\n env: EnvType,\n options: EDASessionDurableObjectOptions<ProjectionState>,\n ) {\n super(ctx, env);\n this.#webSocketProjectionId = options.webSocketProjection?.id;\n const storage = toEDASessionStorage(this.ctx.storage);\n this.#alarms = new DurableObjectAlarmScheduler(storage);\n const { transcript: transcriptHostOptions, transcriptSockets, ...controllerOptions } = options;\n const transcript = this.transcriptOptions(transcriptHostOptions);\n this.#transcriptOptions = transcript;\n const enabled = transcriptHostOptions?.enabled ?? false;\n this.#transcriptEnabled = typeof enabled === \"function\" ? enabled : () => enabled;\n this.#controller = new EDASessionController({\n ...controllerOptions,\n alarmStorage: this.#alarms.owner(\"runtime\"),\n background: this.ctx,\n getWebSockets: () => this.ctx.getWebSockets(),\n storage,\n // The runtime's store maintains the transcript only for an enabled session.\n transcript: ({ sessionId }) =>\n this.transcriptFor(sessionId).enabled ? transcript : undefined,\n ...(transcriptSockets === undefined\n ? {}\n : {\n transcriptSockets: {\n ...transcriptSockets,\n transcriptStore: transcriptSockets.transcriptStore ?? this.transcriptPort(),\n },\n }),\n });\n\n // Answer client liveness pings at the runtime layer so idle sockets never\n // wake a hibernated object.\n this.ctx.setWebSocketAutoResponse(\n new WebSocketRequestResponsePair(EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE),\n );\n\n this.ctx.blockConcurrencyWhile(async () => {\n await Effect.runPromise(EDASessionController.migrate(storage));\n // Keep an alarm armed by an earlier release for the runtime, then resume any builder\n // work an earlier instance left (or a new release created).\n await this.#alarms.adoptUnrecordedAlarm();\n await this.maintainedTranscript()?.builder.start();\n });\n }\n\n async fetch(request: Request): Promise<Response> {\n const upgrade = request.headers.get(\"Upgrade\");\n if (upgrade?.toLowerCase() !== \"websocket\") {\n return new Response(\"Expected WebSocket upgrade.\", { status: 426 });\n }\n\n const url = new URL(request.url);\n const sessionIdRaw = url.searchParams.get(\"sessionId\");\n if (sessionIdRaw === null) {\n return new Response(\"Missing sessionId.\", { status: 400 });\n }\n const afterSeqRaw = url.searchParams.get(\"afterSeq\");\n const afterSeq = afterSeqRaw === null ? undefined : Number(afterSeqRaw);\n if (afterSeq !== undefined && (!Number.isInteger(afterSeq) || afterSeq < 0)) {\n return new Response(\"Invalid afterSeq.\", { status: 400 });\n }\n const projectionId = request.headers.get(EDA_WEB_SOCKET_PROJECTION_HEADER) ?? undefined;\n if (projectionId !== undefined && projectionId !== this.#webSocketProjectionId) {\n return new Response(\"Unsupported WebSocket projection.\", { status: 400 });\n }\n\n const sessionId = this.parseSessionIdOrUndefined(sessionIdRaw);\n if (sessionId === undefined) {\n return new Response(\"This object does not serve that session.\", { status: 400 });\n }\n const trace = traceMetadataFromRequest(request);\n\n if (url.searchParams.get(EDA_WEB_SOCKET_STREAM_PARAM) === \"transcript\") {\n if (projectionId !== undefined || !this.#controller.supportsTranscriptWebSocket) {\n return new Response(\"Unsupported transcript stream.\", { status: 400 });\n }\n if (!this.transcriptFor(sessionId).enabled) {\n return new Response(\"Transcript is not enabled for this session.\", { status: 409 });\n }\n const pair = new WebSocketPair();\n this.ctx.acceptWebSocket(pair[1]);\n this.#controller.acceptTranscriptWebSocket({ sessionId, trace, webSocket: pair[1] });\n return new Response(null, { status: 101, webSocket: pair[0] });\n }\n\n const prepared = await this.#controller.prepareEventWebSocket({\n ...(afterSeq === undefined ? {} : { afterSeq: SequenceNumber.make(afterSeq) }),\n sessionId,\n trace,\n ...(projectionId === undefined ? {} : { projectionId }),\n });\n\n const pair = new WebSocketPair();\n const client = pair[0];\n const server = pair[1];\n this.ctx.acceptWebSocket(server);\n await this.#controller.acceptPreparedEventWebSocket({\n ...prepared,\n webSocket: server,\n });\n return new Response(null, { status: 101, webSocket: client });\n }\n\n async submit(\n raw: typeof SessionCommandInput.Encoded,\n ): Promise<typeof edaSessionRpc.submit.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionCommandInput)(raw);\n const committed = await this.#controller.submit({\n command: input.command,\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return encodeEdaRpcCommittedDurableEvent(committed);\n }\n\n /** Reconcile lost grant replies from durable request and run facts. */\n async runRequestOutcome(\n raw: typeof SessionOutcomeInput.Encoded,\n ): Promise<typeof edaSessionRpc.runRequestOutcome.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionOutcomeInput)(raw);\n const result = await this.#controller.runRequestOutcome({\n requestId: Schema.decodeUnknownSync(RunRequestId)(input.requestId),\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return Schema.encodeSync(edaSessionRpc.runRequestOutcome.output)(result);\n }\n\n /** Trusted RPC only: the calling Worker owns scheduler authentication and authorization. */\n async grantRun(\n raw: typeof SessionGrantRunInput.Encoded,\n ): Promise<typeof edaSessionRpc.grantRun.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionGrantRunInput)(raw);\n const command = input.command;\n const result = await this.#controller.grantRun({\n command,\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return Schema.encodeSync(edaSessionRpc.grantRun.output)(result);\n }\n\n async submitBatch(\n raw: typeof SessionBatchInput.Encoded,\n ): Promise<typeof edaSessionRpc.submitBatch.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionBatchInput)(raw);\n const committed = await this.#controller.submitBatch({\n items: input.items,\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return committed.map(encodeEdaRpcCommittedDurableEvent);\n }\n\n /** Trusted RPC, like `submitBatch`: run a registered decider. The calling Worker authorizes. */\n async decide(\n raw: typeof SessionDecideInput.Encoded,\n ): Promise<typeof edaSessionRpc.decide.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionDecideInput)(raw);\n const outcome = await this.#controller.decide({\n decider: input.decider,\n input: input.input,\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return Schema.encodeSync(edaSessionRpc.decide.output)(outcome);\n }\n\n async submitAndBlock(\n raw: typeof SessionCommandInput.Encoded,\n ): Promise<typeof edaSessionRpc.submitAndBlock.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionCommandInput)(raw);\n const committed = await this.#controller.submitAndBlock({\n command: input.command,\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return Schema.encodeSync(edaSessionRpc.submitAndBlock.output)(committed);\n }\n\n async blockOnCommand(\n raw: typeof SessionBlockInput.Encoded,\n ): Promise<typeof edaSessionRpc.blockOnCommand.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionBlockInput)(raw);\n const committed = await this.#controller.blockOnCommand({\n ...(input.afterSeq === undefined ? {} : { afterSeq: SequenceNumber.make(input.afterSeq) }),\n commandId: CommandId.make(input.commandId),\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return Schema.encodeSync(edaSessionRpc.blockOnCommand.output)(committed);\n }\n\n async snapshot(\n raw: typeof SessionScopedInput.Encoded,\n ): Promise<typeof edaSessionRpc.snapshot.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionScopedInput)(raw);\n const snapshot = await this.#controller.snapshot({\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n return Schema.encodeSync(edaSessionRpc.snapshot.output)(snapshot);\n }\n\n async webSocketMessage(webSocket: WebSocket, message: string | ArrayBuffer): Promise<void> {\n await this.#controller.webSocketMessage(webSocket, message);\n }\n\n async webSocketClose(\n webSocket: WebSocket,\n _code: number,\n _reason: string,\n _wasClean: boolean,\n ): Promise<void> {\n this.#controller.webSocketClose(webSocket);\n }\n\n async webSocketError(webSocket: WebSocket, _error: unknown): Promise<void> {\n this.#controller.webSocketError(webSocket);\n }\n\n async destroySession(\n raw: typeof SessionScopedInput.Encoded,\n ): Promise<typeof edaSessionRpc.destroySession.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionScopedInput)(raw);\n await this.#controller.destroy({\n sessionId: this.parseSessionId(input.sessionId),\n trace: decodeTraceMetadata(input.trace),\n });\n await this.ctx.storage.deleteAlarm();\n await this.ctx.storage.deleteAll();\n // The wiped storage is a brand-new log: recreate the tables storage-only entry points read,\n // synchronously, so no other work observes the object without them.\n Effect.runSync(EDASessionController.migrate(toEDASessionStorage(this.ctx.storage)));\n }\n\n /**\n * Storage-only backfill entry point: advance pending transcript build work by bounded slices\n * and return the transcript status. It never starts the model runtime, reducers or sinks.\n */\n async transcriptStatus(\n raw: typeof SessionScopedInput.Encoded,\n ): Promise<typeof edaSessionRpc.transcriptStatus.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionScopedInput)(raw);\n const transcript = this.transcriptFor(this.parseSessionId(input.sessionId));\n if (!transcript.enabled) {\n return Schema.encodeSync(edaSessionRpc.transcriptStatus.output)(\n transcript.store.disabledStatus(),\n );\n }\n await transcript.builder.run(transcriptStatusMaxSlices);\n return Schema.encodeSync(edaSessionRpc.transcriptStatus.output)(transcript.store.status());\n }\n\n /** Runtime-free transcript window read for SSR and CLIs. Hosts authorize the caller. */\n async readTranscriptWindow(\n raw: typeof SessionTranscriptWindowInput.Encoded,\n ): Promise<typeof edaSessionRpc.readTranscriptWindow.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionTranscriptWindowInput)(raw);\n const transcript = this.transcriptFor(this.parseSessionId(input.sessionId));\n if (!transcript.enabled) {\n return Schema.encodeSync(edaSessionRpc.readTranscriptWindow.output)({ _tag: \"Disabled\" });\n }\n const limits = input.limits ?? defaultTranscriptWindowLimits;\n const window = transcript.store.readWindow(input.selector, {\n ...limits,\n maxRecords: Math.min(limits.maxRecords, transcriptWindowMaxRecords),\n maxBytes: Math.min(limits.maxBytes, transcriptWindowMaxBytes),\n });\n return Schema.encodeSync(edaSessionRpc.readTranscriptWindow.output)(\n Result.isSuccess(window)\n ? { _tag: \"Window\", window: window.success }\n : { _tag: \"CursorMismatch\", message: window.failure.message },\n );\n }\n\n /**\n * Runtime-free read of the body a transcript `Ref` names, resolved through the immutable log\n * (so it stays valid after projection rows are rebuilt). Hosts authorize the caller.\n */\n async readTranscriptBody(\n raw: typeof SessionTranscriptBodyInput.Encoded,\n ): Promise<typeof edaSessionRpc.readTranscriptBody.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionTranscriptBodyInput)(raw);\n const scope = this.transcriptReadScope(input.sessionId, input.incarnation);\n if (scope._tag !== \"Scope\") {\n return Schema.encodeSync(edaSessionRpc.readTranscriptBody.output)(scope);\n }\n const sessionId = scope.sessionId;\n const committed = readDurableObjectCommittedEvent(\n toEDASessionStorage(this.ctx.storage).sql,\n sessionId,\n input.source.seq,\n );\n const resolved =\n committed === undefined\n ? ({ _tag: \"Missing\", message: `no event at seq ${input.source.seq}` } as const)\n : resolveTranscriptBody(committed.event, input.source.path);\n return Schema.encodeSync(edaSessionRpc.readTranscriptBody.output)(\n resolved._tag === \"Found\"\n ? { _tag: \"Body\", value: resolved.value }\n : { _tag: \"NotFound\", message: resolved.message },\n );\n }\n\n /** Runtime-free read of a compaction summary's text. Hosts authorize the caller. */\n async readTranscriptSummary(\n raw: typeof SessionTranscriptSummaryInput.Encoded,\n ): Promise<typeof edaSessionRpc.readTranscriptSummary.output.Encoded> {\n const input = Schema.decodeUnknownSync(SessionTranscriptSummaryInput)(raw);\n const scope = this.transcriptReadScope(input.sessionId, input.incarnation);\n if (scope._tag !== \"Scope\") {\n return Schema.encodeSync(edaSessionRpc.readTranscriptSummary.output)(scope);\n }\n const artifact = readDurableObjectSummary(\n toEDASessionStorage(this.ctx.storage).sql,\n input.summaryId,\n );\n return Schema.encodeSync(edaSessionRpc.readTranscriptSummary.output)(\n artifact === undefined\n ? { _tag: \"NotFound\", message: `no summary ${input.summaryId}` }\n : {\n _tag: \"Summary\",\n summary: {\n compactionId: artifact.compactionId,\n summaryId: artifact.summaryId,\n text: artifact.text,\n sourceFromSeq: artifact.sourceFromSeq,\n sourceToSeq: artifact.sourceToSeq,\n },\n },\n );\n }\n\n /**\n * The alarm is shared by the runtime heartbeat and the transcript builder; see\n * `runEDASessionAlarm`.\n */\n async alarm(): Promise<void> {\n const transcript = this.maintainedTranscript();\n await runEDASessionAlarm({\n alarms: this.#alarms,\n now: () => Date.now(),\n runRuntime: async () => {\n const sessionId = this.sessionIdFromObjectName();\n await this.#controller.alarm(\n sessionId === undefined ? undefined : { sessionId, trace: makeRootEDATraceMetadata() },\n );\n },\n runBuilderSlices:\n transcript === undefined\n ? undefined\n : () => transcript.builder.runSlices(transcriptAlarmMaxSlices),\n maxBuilderFailures:\n this.#transcriptOptions.sliceLimits?.maxSliceFailures ??\n defaultTranscriptSliceLimits.maxSliceFailures,\n builderRetryDelayMs: transcriptBuilderRetryDelayMs,\n onBuilderFailure: ({ error, consecutiveFailures, stopped }) => {\n console.error(\"EDA transcript builder slice failed\", error);\n if (stopped) {\n transcript?.store.alert({\n _tag: \"BuilderStopped\",\n consecutiveFailures,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n },\n });\n }\n\n private transcriptOptions(\n options: EDASessionTranscriptOptions | undefined,\n ): DurableObjectTranscriptOptions {\n const key = options?.adoptIncarnationKey;\n return {\n definitions: options?.definitions ?? {\n current: Effect.runSync(makeTranscriptDefinition(emptyTranscriptMappings)),\n },\n ...(key === undefined ? {} : { adoptIncarnation: { key, kv: this.ctx.storage.kv } }),\n // Validated here so a misconfigured host fails at construction, not on a failing slice.\n sliceLimits: resolveTranscriptSliceLimits(options?.sliceLimits),\n observer: {\n onAlert:\n options?.onAlert ??\n ((alert) => console.error(\"EDA transcript alert\", JSON.stringify(alert))),\n onPendingWork: () => {\n const builder = this.maintainedTranscript()?.builder;\n if (builder !== undefined) this.ctx.waitUntil(builder.kick());\n },\n onServedChanged: () => {\n // A behind active version reached the head, the active version froze, or a build froze\n // while no version was active (Building becomes Unreadable): sockets re-read.\n this.ctx.waitUntil(this.#controller.refreshTranscriptWebSockets());\n },\n onActivated: (activation) => {\n // Connected transcript sockets get one complete replacement in the new version.\n this.ctx.waitUntil(this.#controller.refreshTranscriptWebSockets());\n options?.onActivated?.(activation);\n },\n },\n };\n }\n\n /** This object's transcript store as the port transcript sockets read, resolved per call. */\n private transcriptPort(): EDATranscriptStoreShape {\n const port = () => this.maintainedTranscript()?.store.port;\n const unbound = () =>\n Effect.fail(\n new EDASessionStoreError({\n message:\n this.objectTranscript()?.enabled === false\n ? \"EDA transcript is not enabled for this session\"\n : \"EDA transcript read before the session was named\",\n }),\n );\n return {\n readTranscriptWindow: (selector, limits) =>\n Effect.suspend(() => port()?.readTranscriptWindow(selector, limits) ?? unbound()),\n readTranscriptMeta: Effect.suspend(() => port()?.readTranscriptMeta ?? unbound()),\n };\n }\n\n /**\n * The session and log a body or summary read may serve: pinned to the session this object's\n * transcript serves, like window reads, and to the incarnation the caller's reference names.\n */\n private transcriptReadScope(\n rawSessionId: string,\n incarnation: TranscriptLogIncarnation,\n ):\n | { readonly _tag: \"Scope\"; readonly sessionId: SessionId }\n | { readonly _tag: \"Disabled\" }\n | { readonly _tag: \"IncarnationMismatch\"; readonly incarnation: TranscriptLogIncarnation } {\n const transcript = this.transcriptFor(this.parseSessionId(rawSessionId));\n // Outside the rollout nothing is initialized or minted, and no reference was ever served.\n if (!transcript.enabled) return { _tag: \"Disabled\" };\n const current = transcript.store.incarnation();\n return incarnation === current\n ? { _tag: \"Scope\", sessionId: transcript.sessionId }\n : { _tag: \"IncarnationMismatch\", incarnation: current };\n }\n\n /** The transcript service of this object's session, created on first use. */\n private transcriptFor(sessionId: SessionId) {\n if (this.#transcript !== undefined) {\n if (this.#transcript.sessionId !== sessionId) {\n throw new Error(\n `EDA transcript is scoped to session ${this.#transcript.sessionId}; received ${sessionId}`,\n );\n }\n return this.#transcript;\n }\n const store = new DurableObjectTranscriptStore({\n sessionId,\n storage: toEDASessionStorage(this.ctx.storage),\n transcript: this.#transcriptOptions,\n });\n const builder = new DurableObjectTranscriptBuilder(store, () =>\n this.#alarms.request(\"transcript\", Date.now()),\n );\n this.#transcript = { sessionId, enabled: this.#transcriptEnabled(sessionId), store, builder };\n return this.#transcript;\n }\n\n /** The transcript service when this object's session is enabled for maintenance. */\n private maintainedTranscript() {\n const transcript = this.objectTranscript();\n return transcript?.enabled === true ? transcript : undefined;\n }\n\n /** The transcript service when the object is named by a valid session id. */\n private objectTranscript() {\n if (this.#transcript !== undefined) return this.#transcript;\n const name = this.ctx.id.name;\n return name !== undefined && Schema.is(SessionId)(name)\n ? this.transcriptFor(SessionId.make(name))\n : undefined;\n }\n\n /** `parseSessionId` for request paths that answer a foreign session with a 400. */\n private parseSessionIdOrUndefined(input: string): SessionId | undefined {\n if (!Schema.is(SessionId)(input)) return undefined;\n const name = this.ctx.id.name;\n if (name !== undefined && name !== input) return undefined;\n const bound = this.#transcript?.sessionId;\n return bound === undefined || bound === input ? SessionId.make(input) : undefined;\n }\n\n private parseSessionId(input: string): SessionId {\n const sessionId = SessionId.make(input);\n const objectName = this.ctx.id.name;\n if (objectName !== undefined && objectName !== sessionId) {\n throw new Error(`EDA Durable Object name ${objectName} cannot serve session ${sessionId}`);\n }\n return sessionId;\n }\n\n private sessionIdFromObjectName(): SessionId | undefined {\n return this.ctx.id.name === undefined ? undefined : SessionId.make(this.ctx.id.name);\n }\n}\n\nconst toEDASessionStorage = (storage: DurableObjectStorage): EDASessionDurableObjectStorage => {\n // SAFETY: the adapter interface is the exact SQL, transaction, and alarm subset\n // of DurableObjectStorage; its looser row generic also supports test implementations.\n return storage as EDASessionDurableObjectStorage;\n};\n\nconst decodeTraceMetadata = (input: unknown): EDATraceMetadata =>\n Schema.decodeUnknownSync(EDATraceMetadata)(input);\n\nconst traceMetadataFromRequest = (request: Request): EDATraceMetadata => {\n const parent = parseEDATraceparent(\n request.headers.get(\"traceparent\"),\n request.headers.get(\"tracestate\"),\n );\n return parent === null ? makeRootEDATraceMetadata() : makeEDATraceMetadataFromParent(parent);\n};\n\n/** Convenience config constructor for subclasses that need only provider/model ids. */\nexport const edaRuntimeConfig = (input: {\n readonly maxToolCallsPerRun?: number;\n readonly modelId: string;\n readonly provider: string;\n readonly systemPrompt?: string;\n}): EDARuntimeConfig => ({\n modelSelection: { modelId: input.modelId, provider: input.provider },\n ...(input.maxToolCallsPerRun === undefined\n ? {}\n : { maxToolCallsPerRun: input.maxToolCallsPerRun }),\n ...(input.systemPrompt === undefined ? {} : { systemPrompt: input.systemPrompt }),\n});\n\n/** Encode committed events into the existing structured-clone envelope. */\nexport const encodeEdaRpcCommittedDurableEvent = (\n entry: CommittedDurableEvent,\n): typeof edaSessionRpc.submit.output.Encoded => ({\n position: entry.position,\n event: encodeEdaRpcDurableEvent(durableEventEnvelope(entry.event)),\n});\n/** Encode query snapshots without asserting that encoded command values are decoded classes. */\nexport const encodeEdaRpcSessionSnapshot = Schema.encodeSync(edaSessionRpc.sn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1,6 +1,6 @@
|
|
|
1
1
|
import { a as DurableObjectTranscriptObserver, c as TranscriptAlert, s as DurableObjectTranscriptSliceLimits } from "./durable-object-storage-Dec6HWQ9.js";
|
|
2
2
|
import { a as SessionGrantRunInput, c as SessionTranscriptBodyInput, f as SessionTranscriptWindowInput, h as edaSessionRpc, i as SessionDecideInput, n as SessionBlockInput, o as SessionOutcomeInput, r as SessionCommandInput, s as SessionScopedInput, t as SessionBatchInput, u as SessionTranscriptSummaryInput } from "./rpc-spec-NAf8Yjnd.js";
|
|
3
|
-
import { d as EDATranscriptSocketOptions, i as EDASessionControllerOptions, p as EDAWebSocketProjection } from "./session-controller-
|
|
3
|
+
import { d as EDATranscriptSocketOptions, i as EDASessionControllerOptions, m as EDAWebSocketProjectionContext, p as EDAWebSocketProjection } from "./session-controller-CG5le-8n.js";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import { SessionId } from "effect-durable-agent/types/core";
|
|
6
6
|
import { CommittedDurableEvent } from "effect-durable-agent/services/session-store";
|
|
@@ -2391,5 +2391,5 @@ declare const encodeEdaRpcSessionSnapshot: (input: {
|
|
|
2391
2391
|
readonly reducerStates: ReadonlyMap<string, unknown>;
|
|
2392
2392
|
};
|
|
2393
2393
|
//#endregion
|
|
2394
|
-
export { EDASessionBlockOnCommandRpcInput, EDASessionCommandRpcInput, EDASessionDecideRpcInput, EDASessionDurableObject, EDASessionDurableObjectOptions, EDASessionEventsRpcInput, EDASessionGrantRunRpcInput, EDASessionRpcSurface, EDASessionRunRequestOutcomeRpcInput, EDASessionScopedRpcInput, EDASessionSubmitBatchRpcInput, EDASessionTranscriptOptions, type EDAWebSocketProjection, EDA_WEB_SOCKET_PROJECTION_HEADER, EDA_WEB_SOCKET_STREAM_PARAM, edaRuntimeConfig, encodeEdaRpcCommittedDurableEvent, encodeEdaRpcSessionSnapshot, getEDASessionDurableObjectByName };
|
|
2394
|
+
export { EDASessionBlockOnCommandRpcInput, EDASessionCommandRpcInput, EDASessionDecideRpcInput, EDASessionDurableObject, EDASessionDurableObjectOptions, EDASessionEventsRpcInput, EDASessionGrantRunRpcInput, EDASessionRpcSurface, EDASessionRunRequestOutcomeRpcInput, EDASessionScopedRpcInput, EDASessionSubmitBatchRpcInput, EDASessionTranscriptOptions, type EDAWebSocketProjection, type EDAWebSocketProjectionContext, EDA_WEB_SOCKET_PROJECTION_HEADER, EDA_WEB_SOCKET_STREAM_PARAM, edaRuntimeConfig, encodeEdaRpcCommittedDurableEvent, encodeEdaRpcSessionSnapshot, getEDASessionDurableObjectByName };
|
|
2395
2395
|
//# sourceMappingURL=durable-object.d.ts.map
|
package/dist/durable-object.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as encodeEdaRpcCommittedDurableEvent, i as edaRuntimeConfig, n as EDA_WEB_SOCKET_PROJECTION_HEADER, o as encodeEdaRpcSessionSnapshot, r as EDA_WEB_SOCKET_STREAM_PARAM, s as getEDASessionDurableObjectByName, t as EDASessionDurableObject } from "./durable-object-
|
|
1
|
+
import { a as encodeEdaRpcCommittedDurableEvent, i as edaRuntimeConfig, n as EDA_WEB_SOCKET_PROJECTION_HEADER, o as encodeEdaRpcSessionSnapshot, r as EDA_WEB_SOCKET_STREAM_PARAM, s as getEDASessionDurableObjectByName, t as EDASessionDurableObject } from "./durable-object-bmMjpZbM.js";
|
|
2
2
|
export { EDASessionDurableObject, EDA_WEB_SOCKET_PROJECTION_HEADER, EDA_WEB_SOCKET_STREAM_PARAM, edaRuntimeConfig, encodeEdaRpcCommittedDurableEvent, encodeEdaRpcSessionSnapshot, getEDASessionDurableObjectByName };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as DurableObjectTranscriptObserver, c as TranscriptAlert, i as DurableObjectSqlStorage, l as AdoptedLogIncarnation, n as DurableObjectSessionStoreOptions, o as DurableObjectTranscriptOptions, r as DurableObjectSqlCursor, s as DurableObjectTranscriptSliceLimits, t as DurableObjectSessionStorage } from "./durable-object-storage-Dec6HWQ9.js";
|
|
2
2
|
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";
|
|
3
|
-
import { _ as
|
|
3
|
+
import { _ as EDAWebSocketProjectionResult, a as EDASessionDecideInput, b as makeEDADurableObjectRuntimeLayer, c as EDASessionScopedInput, d as EDATranscriptSocketOptions, f as defaultActiveContentCadenceMs, g as EDAWebSocketProjectionInitial, h as EDAWebSocketProjectionId, i as EDASessionControllerOptions, l as EDASessionSubmitBatchInput, m as EDAWebSocketProjectionContext, n as EDASessionBlockOnCommandInput, o as EDASessionDecideResult, p as EDAWebSocketProjection, r as EDASessionController, s as EDASessionEventsInput, t as EDAPreparedEventWebSocket, u as EDASessionSubmitInput, v as EDADurableObjectRuntimeLayerOptions, x as DurableObjectAlarmStorage, y as EDASessionDurableObjectStorage } from "./session-controller-CG5le-8n.js";
|
|
4
4
|
import { EDASessionBlockOnCommandRpcInput, EDASessionCommandRpcInput, EDASessionDecideRpcInput, EDASessionDurableObject, EDASessionDurableObjectOptions, EDASessionEventsRpcInput, EDASessionGrantRunRpcInput, EDASessionRpcSurface, EDASessionRunRequestOutcomeRpcInput, EDASessionScopedRpcInput, EDASessionSubmitBatchRpcInput, EDASessionTranscriptOptions, EDA_WEB_SOCKET_PROJECTION_HEADER, EDA_WEB_SOCKET_STREAM_PARAM, edaRuntimeConfig, encodeEdaRpcCommittedDurableEvent, encodeEdaRpcSessionSnapshot, getEDASessionDurableObjectByName } from "./durable-object.js";
|
|
5
5
|
import { EDAOpenAiModelConfig, makeEDADurableObjectOpenAiModelLayer, makeEDADurableObjectOpenAiModelResolverLayer, makeEDAOpenAiClientLayer } from "./openai.js";
|
|
6
6
|
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";
|
|
@@ -223,5 +223,5 @@ declare class DurableObjectSessionStore {
|
|
|
223
223
|
static readonly layer: (options: DurableObjectSessionStoreOptions) => Layer.Layer<EDASessionStore, EDASessionStoreError, never>;
|
|
224
224
|
}
|
|
225
225
|
//#endregion
|
|
226
|
-
export { type AdoptedLogIncarnation, DurableObjectAlarmOwner, DurableObjectAlarmScheduler, DurableObjectSessionStorage, DurableObjectSessionStore, DurableObjectSessionStoreOptions, DurableObjectSqlCursor, DurableObjectSqlStorage, DurableObjectTranscriptBuilder, type DurableObjectTranscriptObserver, type DurableObjectTranscriptOptions, type DurableObjectTranscriptSliceLimits, DurableObjectTranscriptStore, DurableObjectTranscriptStoreOptions, EDADurableObjectRuntimeLayerOptions, EDAOpenAiModelConfig, EDAPreparedEventWebSocket, EDARpcSubmittable, EDASessionBlockOnCommandInput, EDASessionBlockOnCommandRpcInput, EDASessionCommandRpcInput, EDASessionController, EDASessionControllerOptions, EDASessionDecideInput, EDASessionDecideResult, EDASessionDecideRpcInput, EDASessionDurableObject, EDASessionDurableObjectOptions, EDASessionDurableObjectStorage, EDASessionEventsInput, EDASessionEventsRpcInput, EDASessionGrantRunRpcInput, EDASessionRpcSurface, EDASessionRunRequestOutcomeRpcInput, EDASessionScopedInput, EDASessionScopedRpcInput, EDASessionSubmitBatchInput, EDASessionSubmitBatchRpcInput, EDASessionSubmitInput, EDASessionTranscriptOptions, type EDATranscriptSocketOptions, EDAWebSocketProjection, EDAWebSocketProjectionId, EDAWebSocketProjectionInitial, EDAWebSocketProjectionResult, EDA_WEB_SOCKET_PROJECTION_HEADER, EDA_WEB_SOCKET_STREAM_PARAM, SessionBatchInput, SessionBlockInput, SessionCommandInput, SessionDecideInput, SessionDecideResult, SessionGrantRunInput, SessionOutcomeInput, SessionScopedInput, SessionTranscriptBodyInput, SessionTranscriptBodyResult, SessionTranscriptSummaryInput, SessionTranscriptSummaryResult, SessionTranscriptWindowInput, SessionTranscriptWindowResult, type TranscriptAlert, TranscriptCompactionSummary, TranscriptStorageStatus, decodeDecideOutcome, decodeEdaRpcCommand, decodeEdaRpcSubmittables, defaultActiveContentCadenceMs, edaRuntimeConfig, edaSessionRpc, encodeDecideInput, encodeEdaRpcCommand, encodeEdaRpcCommittedDurableEvent, encodeEdaRpcDurableEvent, encodeEdaRpcSessionSnapshot, encodeEdaRpcSubmittables, getEDASessionDurableObjectByName, makeEDADurableObjectOpenAiModelLayer, makeEDADurableObjectOpenAiModelResolverLayer, makeEDADurableObjectRuntimeLayer, makeEDAOpenAiClientLayer };
|
|
226
|
+
export { type AdoptedLogIncarnation, DurableObjectAlarmOwner, DurableObjectAlarmScheduler, DurableObjectSessionStorage, DurableObjectSessionStore, DurableObjectSessionStoreOptions, DurableObjectSqlCursor, DurableObjectSqlStorage, DurableObjectTranscriptBuilder, type DurableObjectTranscriptObserver, type DurableObjectTranscriptOptions, type DurableObjectTranscriptSliceLimits, DurableObjectTranscriptStore, DurableObjectTranscriptStoreOptions, EDADurableObjectRuntimeLayerOptions, EDAOpenAiModelConfig, EDAPreparedEventWebSocket, EDARpcSubmittable, EDASessionBlockOnCommandInput, EDASessionBlockOnCommandRpcInput, EDASessionCommandRpcInput, EDASessionController, EDASessionControllerOptions, EDASessionDecideInput, EDASessionDecideResult, EDASessionDecideRpcInput, EDASessionDurableObject, EDASessionDurableObjectOptions, EDASessionDurableObjectStorage, EDASessionEventsInput, EDASessionEventsRpcInput, EDASessionGrantRunRpcInput, EDASessionRpcSurface, EDASessionRunRequestOutcomeRpcInput, EDASessionScopedInput, EDASessionScopedRpcInput, EDASessionSubmitBatchInput, EDASessionSubmitBatchRpcInput, EDASessionSubmitInput, EDASessionTranscriptOptions, type EDATranscriptSocketOptions, EDAWebSocketProjection, EDAWebSocketProjectionContext, EDAWebSocketProjectionId, EDAWebSocketProjectionInitial, EDAWebSocketProjectionResult, EDA_WEB_SOCKET_PROJECTION_HEADER, EDA_WEB_SOCKET_STREAM_PARAM, SessionBatchInput, SessionBlockInput, SessionCommandInput, SessionDecideInput, SessionDecideResult, SessionGrantRunInput, SessionOutcomeInput, SessionScopedInput, SessionTranscriptBodyInput, SessionTranscriptBodyResult, SessionTranscriptSummaryInput, SessionTranscriptSummaryResult, SessionTranscriptWindowInput, SessionTranscriptWindowResult, type TranscriptAlert, TranscriptCompactionSummary, TranscriptStorageStatus, decodeDecideOutcome, decodeEdaRpcCommand, decodeEdaRpcSubmittables, defaultActiveContentCadenceMs, edaRuntimeConfig, edaSessionRpc, encodeDecideInput, encodeEdaRpcCommand, encodeEdaRpcCommittedDurableEvent, encodeEdaRpcDurableEvent, encodeEdaRpcSessionSnapshot, encodeEdaRpcSubmittables, getEDASessionDurableObjectByName, makeEDADurableObjectOpenAiModelLayer, makeEDADurableObjectOpenAiModelResolverLayer, makeEDADurableObjectRuntimeLayer, makeEDAOpenAiClientLayer };
|
|
227
227
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as decodeEdaRpcSubmittables, D as encodeEdaRpcSubmittables, E as encodeEdaRpcDurableEvent, S as decodeEdaRpcCommand, T as encodeEdaRpcCommand, _ as DurableObjectTranscriptStore, a as SessionGrantRunInput, b as SessionDecideResult, c as SessionTranscriptBodyInput, d as SessionTranscriptSummaryResult, f as SessionTranscriptWindowInput, g as DurableObjectTranscriptBuilder, 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, v as TranscriptStorageStatus, w as encodeDecideInput, x as decodeDecideOutcome, y as EDARpcSubmittable } from "./rpc-spec-BU5bGUWF.js";
|
|
2
2
|
import { t as DurableObjectSessionStore } from "./durable-object-store-lJkqwvIj.js";
|
|
3
|
-
import { i as makeEDADurableObjectRuntimeLayer, n as defaultActiveContentCadenceMs, r as EDAWebSocketProjectionId, t as EDASessionController } from "./session-controller-
|
|
4
|
-
import { a as encodeEdaRpcCommittedDurableEvent, c as DurableObjectAlarmScheduler, i as edaRuntimeConfig, n as EDA_WEB_SOCKET_PROJECTION_HEADER, o as encodeEdaRpcSessionSnapshot, r as EDA_WEB_SOCKET_STREAM_PARAM, s as getEDASessionDurableObjectByName, t as EDASessionDurableObject } from "./durable-object-
|
|
3
|
+
import { i as makeEDADurableObjectRuntimeLayer, n as defaultActiveContentCadenceMs, r as EDAWebSocketProjectionId, t as EDASessionController } from "./session-controller-BhbkW0Iw.js";
|
|
4
|
+
import { a as encodeEdaRpcCommittedDurableEvent, c as DurableObjectAlarmScheduler, i as edaRuntimeConfig, n as EDA_WEB_SOCKET_PROJECTION_HEADER, o as encodeEdaRpcSessionSnapshot, r as EDA_WEB_SOCKET_STREAM_PARAM, s as getEDASessionDurableObjectByName, t as EDASessionDurableObject } from "./durable-object-bmMjpZbM.js";
|
|
5
5
|
import "./storage.js";
|
|
6
6
|
import { makeEDADurableObjectOpenAiModelLayer, makeEDADurableObjectOpenAiModelResolverLayer, makeEDAOpenAiClientLayer } from "./openai.js";
|
|
7
7
|
export { DurableObjectAlarmScheduler, DurableObjectSessionStore, DurableObjectTranscriptBuilder, DurableObjectTranscriptStore, EDARpcSubmittable, EDASessionController, EDASessionDurableObject, EDAWebSocketProjectionId, EDA_WEB_SOCKET_PROJECTION_HEADER, EDA_WEB_SOCKET_STREAM_PARAM, SessionBatchInput, SessionBlockInput, SessionCommandInput, SessionDecideInput, SessionDecideResult, SessionGrantRunInput, SessionOutcomeInput, SessionScopedInput, SessionTranscriptBodyInput, SessionTranscriptBodyResult, SessionTranscriptSummaryInput, SessionTranscriptSummaryResult, SessionTranscriptWindowInput, SessionTranscriptWindowResult, TranscriptCompactionSummary, TranscriptStorageStatus, decodeDecideOutcome, decodeEdaRpcCommand, decodeEdaRpcSubmittables, defaultActiveContentCadenceMs, edaRuntimeConfig, edaSessionRpc, encodeDecideInput, encodeEdaRpcCommand, encodeEdaRpcCommittedDurableEvent, encodeEdaRpcDurableEvent, encodeEdaRpcSessionSnapshot, encodeEdaRpcSubmittables, getEDASessionDurableObjectByName, makeEDADurableObjectOpenAiModelLayer, makeEDADurableObjectOpenAiModelResolverLayer, makeEDADurableObjectRuntimeLayer, makeEDAOpenAiClientLayer };
|
|
@@ -920,8 +920,14 @@ const toSubscriptionRequest = (frame) => {
|
|
|
920
920
|
*/
|
|
921
921
|
var EDAWebSocketConnectionManager = class {
|
|
922
922
|
options;
|
|
923
|
-
observerLayer = SessionEventObserver.FromHandler((event) => Effect.tryPromise(() => this.fanoutPublishedEvent(event)).pipe(Effect.catchCause((cause) => Effect.logError("EDA WebSocket event observer recovered from a host failure", { cause }))));
|
|
923
|
+
observerLayer = SessionEventObserver.FromHandler((event, state) => Effect.tryPromise(() => this.fanoutPublishedEvent(event, state)).pipe(Effect.catchCause((cause) => Effect.logError("EDA WebSocket event observer recovered from a host failure", { cause }))));
|
|
924
924
|
sockets = /* @__PURE__ */ new Map();
|
|
925
|
+
/**
|
|
926
|
+
* The newest reduced state seen from a publication or a page read. One object serves one
|
|
927
|
+
* session, and every events frame starts from one of those two, so it is set before any
|
|
928
|
+
* events frame is encoded.
|
|
929
|
+
*/
|
|
930
|
+
reduced;
|
|
925
931
|
transcript;
|
|
926
932
|
constructor(options) {
|
|
927
933
|
this.options = options;
|
|
@@ -943,11 +949,6 @@ var EDAWebSocketConnectionManager = class {
|
|
|
943
949
|
this.transcript.accept(input);
|
|
944
950
|
}
|
|
945
951
|
/**
|
|
946
|
-
* The session's log was destroyed: drop live content and close every transcript socket,
|
|
947
|
-
* including those still hibernated, which a just-woken object has not restored yet. They are
|
|
948
|
-
* recognised by their attachment kind without being restored.
|
|
949
|
-
*/
|
|
950
|
-
/**
|
|
951
952
|
* Re-read every transcript socket, held or hibernated, at the current cut. The served version
|
|
952
953
|
* changed without a publication (a rebuilt version activated), so each subscriber receives a
|
|
953
954
|
* complete replacement (design §7 step 4, §9.4).
|
|
@@ -963,7 +964,14 @@ var EDAWebSocketConnectionManager = class {
|
|
|
963
964
|
}
|
|
964
965
|
this.transcript.serveRestored(sockets);
|
|
965
966
|
}
|
|
966
|
-
|
|
967
|
+
/**
|
|
968
|
+
* The session's log was destroyed. Forget its reduced state, since the new log restarts at
|
|
969
|
+
* seq 0, then drop live content and close every transcript socket, including those still
|
|
970
|
+
* hibernated, which a just-woken object has not restored yet. They are recognised by their
|
|
971
|
+
* attachment kind without being restored.
|
|
972
|
+
*/
|
|
973
|
+
async sessionDestroyed() {
|
|
974
|
+
this.reduced = void 0;
|
|
967
975
|
if (this.transcript === void 0) return;
|
|
968
976
|
const hibernated = [];
|
|
969
977
|
for (const webSocket of this.options.getWebSockets?.() ?? []) {
|
|
@@ -1058,7 +1066,8 @@ var EDAWebSocketConnectionManager = class {
|
|
|
1058
1066
|
}
|
|
1059
1067
|
await Promise.all(deliveries);
|
|
1060
1068
|
}
|
|
1061
|
-
async fanoutPublishedEvent(event) {
|
|
1069
|
+
async fanoutPublishedEvent(event, reduced) {
|
|
1070
|
+
this.observeReduced(reduced);
|
|
1062
1071
|
const heldTranscriptSockets = new Set(this.transcript?.webSockets() ?? []);
|
|
1063
1072
|
this.transcript?.onPublished(event, [...heldTranscriptSockets]);
|
|
1064
1073
|
const webSockets = /* @__PURE__ */ new Set([
|
|
@@ -1086,10 +1095,6 @@ var EDAWebSocketConnectionManager = class {
|
|
|
1086
1095
|
await this.interpret(webSocket, state, onDurableEvents(state.delivery, [event], state.head, Date.now()));
|
|
1087
1096
|
return;
|
|
1088
1097
|
}
|
|
1089
|
-
if (!this.options.isSessionReady(state.sessionId)) {
|
|
1090
|
-
state.catchUpDeferred = true;
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
1098
|
await this.readAndDeliver(webSocket, state, state.delivery.sentDurableThroughSeq);
|
|
1094
1099
|
}));
|
|
1095
1100
|
}
|
|
@@ -1170,6 +1175,10 @@ var EDAWebSocketConnectionManager = class {
|
|
|
1170
1175
|
return true;
|
|
1171
1176
|
}
|
|
1172
1177
|
async readAndDeliver(webSocket, state, afterSeq) {
|
|
1178
|
+
if (!this.options.isSessionReady(state.sessionId)) {
|
|
1179
|
+
state.catchUpDeferred = true;
|
|
1180
|
+
return true;
|
|
1181
|
+
}
|
|
1173
1182
|
const page = await this.options.readEventPage({
|
|
1174
1183
|
afterSeq,
|
|
1175
1184
|
limit: state.delivery.policy.maxInFlightFrames * state.delivery.policy.maxFrameEvents,
|
|
@@ -1177,10 +1186,14 @@ var EDAWebSocketConnectionManager = class {
|
|
|
1177
1186
|
subscriberId: state.subscriberId,
|
|
1178
1187
|
trace: state.trace
|
|
1179
1188
|
});
|
|
1189
|
+
this.observeReduced(page.reduced);
|
|
1180
1190
|
state.head = SequenceNumber.make(Math.max(state.head, page.head));
|
|
1181
1191
|
if (page.events.length === 0) return true;
|
|
1182
1192
|
return await this.interpret(webSocket, state, onDurableEvents(state.delivery, page.events, state.head, Date.now()));
|
|
1183
1193
|
}
|
|
1194
|
+
observeReduced(reduced) {
|
|
1195
|
+
if (this.reduced === void 0 || reduced.lastSeq >= this.reduced.lastSeq) this.reduced = reduced;
|
|
1196
|
+
}
|
|
1184
1197
|
persist(webSocket, state) {
|
|
1185
1198
|
try {
|
|
1186
1199
|
const projection = state.projectionState === void 0 ? void 0 : this.options.webSocketProjection;
|
|
@@ -1214,7 +1227,7 @@ var EDAWebSocketConnectionManager = class {
|
|
|
1214
1227
|
const encodedFrames = [];
|
|
1215
1228
|
const followUpActions = [];
|
|
1216
1229
|
for (const frame of frames) {
|
|
1217
|
-
const projected = state.projectionState === void 0 ? void 0 : this.options.webSocketProjection?.encodeServerFrame(frame, state.projectionState);
|
|
1230
|
+
const projected = state.projectionState === void 0 ? void 0 : this.options.webSocketProjection?.encodeServerFrame(frame, state.projectionState, { reduced: this.reduced });
|
|
1218
1231
|
if (state.projectionState !== void 0 && projected === void 0) {
|
|
1219
1232
|
this.close(webSocket, EDA_WS_CLOSE_PROTOCOL_ERROR, "protocol");
|
|
1220
1233
|
return false;
|
|
@@ -1318,7 +1331,14 @@ var EDASessionController = class {
|
|
|
1318
1331
|
getWebSockets: options.getWebSockets,
|
|
1319
1332
|
isSessionReady: (sessionId) => this.runtime.isReady(sessionId),
|
|
1320
1333
|
prepareSession: (sessionId) => this.prepareSession(sessionId),
|
|
1321
|
-
readEventPage: async ({ afterSeq, limit, sessionId, subscriberId, trace }) => await this.runtime.run(sessionId, (eda) =>
|
|
1334
|
+
readEventPage: async ({ afterSeq, limit, sessionId, subscriberId, trace }) => await this.runtime.run(sessionId, (eda) => Effect.gen(function* () {
|
|
1335
|
+
const page = yield* eda.readEventPage(afterSeq, limit);
|
|
1336
|
+
const snapshot = yield* eda.snapshot();
|
|
1337
|
+
return {
|
|
1338
|
+
...page,
|
|
1339
|
+
reduced: snapshot.state
|
|
1340
|
+
};
|
|
1341
|
+
}).pipe(Effect.withSpan("agent.events.page", hostSpanOptions(trace, {
|
|
1322
1342
|
"eda.session.id": sessionId,
|
|
1323
1343
|
"eda.subscriber.id": subscriberId,
|
|
1324
1344
|
"eda.seq.after": afterSeq
|
|
@@ -1472,7 +1492,7 @@ var EDASessionController = class {
|
|
|
1472
1492
|
}
|
|
1473
1493
|
async destroy(_input) {
|
|
1474
1494
|
await this.runtime.destroy();
|
|
1475
|
-
await this.webSockets.
|
|
1495
|
+
await this.webSockets.sessionDestroyed();
|
|
1476
1496
|
}
|
|
1477
1497
|
async alarm(input) {
|
|
1478
1498
|
if (input !== void 0) await this.prepareSession(input.sessionId);
|
|
@@ -1521,4 +1541,4 @@ const hostSpanOptions = (trace, attributes) => ({
|
|
|
1521
1541
|
//#endregion
|
|
1522
1542
|
export { makeEDADurableObjectRuntimeLayer as i, defaultActiveContentCadenceMs as n, EDAWebSocketProjectionId as r, EDASessionController as t };
|
|
1523
1543
|
|
|
1524
|
-
//# sourceMappingURL=session-controller-
|
|
1544
|
+
//# sourceMappingURL=session-controller-BhbkW0Iw.js.map
|