effect-durable-agent 0.1.0-alpha.24 → 0.1.0-alpha.25

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-Dzr5LqPX.js","names":["PositiveInt"],"sources":["../src/transcript/window.ts","../src/transcript/subscription.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\n\nimport { SequenceNumber } from \"../types/core\";\nimport { NonNegativeInt } from \"../types/events/envelope\";\nimport {\n InferenceAssistantRecordId,\n TranscriptAssistantPart,\n TranscriptCursor,\n TranscriptLogIncarnation,\n TranscriptOrder,\n TranscriptRecordViewFromEnvelope,\n isPendingTranscriptUserRecord,\n isTopLevelTranscriptRecord,\n TranscriptVersion,\n type TranscriptOrderKey,\n type TranscriptRecordView,\n} from \"./records\";\n\nconst PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));\n\nconst orderKeyOfCursor = (cursor: TranscriptCursor): TranscriptOrderKey => ({\n anchorSeq: cursor.anchorSeq,\n ordinal: cursor.ordinal,\n recordId: cursor.recordId,\n});\n\n/**\n * Which slice of history to read.\n *\n * `Latest` serves first paint (SSR, CLIs); `Page` walks either direction from a cursor;\n * `Range` re-reads exactly the span a client retains, inclusive of both ends, at one new cut.\n */\nexport const TranscriptWindowSelector = Schema.Union([\n Schema.TaggedStruct(\"Latest\", { count: PositiveInt }),\n Schema.TaggedStruct(\"Page\", {\n direction: Schema.Literals([\"before\", \"after\"]),\n cursor: TranscriptCursor,\n count: PositiveInt,\n }),\n Schema.TaggedStruct(\"Range\", { from: TranscriptCursor, to: TranscriptCursor }).check(\n Schema.makeFilter(\n (range) =>\n (range.from.incarnation === range.to.incarnation &&\n range.from.version === range.to.version) ||\n \"a range is scoped to one incarnation and version\",\n ),\n Schema.makeFilter(\n (range) =>\n TranscriptOrder(orderKeyOfCursor(range.from), orderKeyOfCursor(range.to)) <= 0 ||\n \"a range starts at or before its end\",\n ),\n ),\n]);\nexport type TranscriptWindowSelector = typeof TranscriptWindowSelector.Type;\n\n/**\n * Bounds on one window. `maxRecords` caps top-level records (a selector's `count` is further\n * capped by it); `maxBytes` caps the whole response, dependencies included; bodies above\n * `maxInlineBodyBytes` are sent as references.\n */\nexport const TranscriptWindowLimits = Schema.Struct({\n maxRecords: PositiveInt,\n maxBytes: PositiveInt,\n maxInlineBodyBytes: NonNegativeInt,\n});\nexport type TranscriptWindowLimits = typeof TranscriptWindowLimits.Type;\n\n/** Default bounds: the first window holds 100 top-level records (design decision 4). */\nexport const defaultTranscriptWindowLimits: TranscriptWindowLimits = {\n maxRecords: 100,\n maxBytes: 1_048_576,\n maxInlineBodyBytes: 16_384,\n};\n\n/**\n * Whether the window is the current interpretation of the log, and if not, why its cut is\n * behind.\n *\n * Every state other than `Ready` is a degraded read and obeys one rule: the response contains\n * nothing newer than `throughSeq` — no newer pending users, session context or live content.\n */\nconst KnownReadiness = Schema.TaggedUnion({\n /** The active version is healthy and projected through the log head at read time. */\n Ready: {},\n /** The active version failed while projecting `failedAtSeq`; this is its last good cut. */\n Degraded: { failedAtSeq: SequenceNumber, error: Schema.String },\n /**\n * The served cut is consistent but behind the log: either the active version is no longer\n * carried by this release and history is being rebuilt under the current definition (clients\n * receive one replacement when it activates), or the active version is catching up to the head\n * (a session re-enabled after it was disabled; clients receive a re-read when it gets there).\n */\n UpdatingHistory: {},\n /** No version is servable yet; the window is empty. */\n Building: {},\n /**\n * A stored row of the served version cannot be decoded by this release. Nothing is served\n * until a rebuild finishes, rather than a wrong view; the window is empty.\n */\n Unreadable: { error: Schema.String },\n /** A readiness this reader does not know; treated as degraded. */\n Unknown: { readinessType: Schema.String },\n});\n\nconst knownReadinessTags: ReadonlySet<string> = new Set([\n \"Ready\",\n \"Degraded\",\n \"UpdatingHistory\",\n \"Building\",\n \"Unreadable\",\n \"Unknown\",\n]);\n\nconst UnrecognizedReadiness = Schema.Struct({\n _tag: Schema.String.check(\n Schema.makeFilter(\n (tag) => !knownReadinessTags.has(tag) || \"a known readiness must decode as that readiness\",\n ),\n ),\n}).pipe(\n Schema.decodeTo(Schema.toType(KnownReadiness.cases.Unknown), {\n decode: SchemaGetter.transform((readiness) => ({\n _tag: \"Unknown\" as const,\n readinessType: readiness._tag,\n })),\n encode: SchemaGetter.transform((readiness) => ({ _tag: readiness.readinessType })),\n }),\n);\n\n/**\n * Whether the window is the current interpretation of the log. A readiness this reader does not\n * know decodes as `Unknown` and is treated as degraded: it carries no live content. A malformed\n * readiness with a known tag is a decode failure.\n */\nexport const TranscriptReadiness = Schema.Union([KnownReadiness, UnrecognizedReadiness]);\nexport type TranscriptReadiness = typeof TranscriptReadiness.Type;\n\n/**\n * One live part of the inference streaming now.\n *\n * `id` is stable for the life of the part (`text:<providerPartId>`, `reasoning:<providerPartId>`,\n * `tool:<toolCallId>`), so a client keys a streaming part by it and replaces it in place as it\n * grows. `paramsText` is the tool-call parameter text streamed so far; it is speculative until\n * the call is sealed into a tool record.\n */\nexport const TranscriptActivePart = Schema.Struct({\n id: Schema.NonEmptyString,\n part: TranscriptAssistantPart,\n paramsText: Schema.optionalKey(Schema.String),\n}).check(\n Schema.makeFilter(\n (active) =>\n (active.part._tag === \"Text\"\n ? active.id.startsWith(\"text:\")\n : active.part._tag === \"Reasoning\"\n ? active.id.startsWith(\"reasoning:\")\n : active.part._tag === \"ToolCall\"\n ? active.id.startsWith(\"tool:\")\n : true) || \"a live part's id names its kind\",\n ),\n Schema.makeFilter(\n (active) =>\n active.paramsText === undefined ||\n active.part._tag === \"ToolCall\" ||\n \"only a tool call streams parameter text\",\n ),\n);\nexport type TranscriptActivePart = typeof TranscriptActivePart.Type;\n\n/**\n * Accumulated parts of the inference streaming now, captured at the same publication boundary as\n * the window. Owned by the live runtime; storage-level reads never include it.\n */\nexport const TranscriptActiveContent = Schema.Struct({\n assistantId: InferenceAssistantRecordId,\n parts: Schema.Array(TranscriptActivePart),\n});\nexport type TranscriptActiveContent = typeof TranscriptActiveContent.Type;\n\nconst recordUpdatedSeq = (record: TranscriptRecordView): number => record.updatedSeq;\n\nconst recordPosition = (record: TranscriptRecordView) =>\n \"position\" in record ? record.position : undefined;\n\n/** Positioned history, which is served only as a top-level record and never as a dependency. */\nconst isHistoryRecord = (record: TranscriptRecordView): boolean =>\n record.kind === \"unknown\" ? record.position !== undefined : isTopLevelTranscriptRecord(record);\n\n/**\n * One complete, consistent read of a transcript version.\n *\n * `records` are top-level records in transcript order; `dependencies` are the tools and run\n * groups they reference, the session context, and every pending user record. Every record is\n * projected through `throughSeq` and none is newer, which is what makes a cut complete. A client\n * replaces, never merges, what a window covers.\n */\nexport const TranscriptWindow = Schema.Struct({\n incarnation: TranscriptLogIncarnation,\n version: TranscriptVersion,\n throughSeq: SequenceNumber,\n records: Schema.Array(TranscriptRecordViewFromEnvelope),\n dependencies: Schema.Array(TranscriptRecordViewFromEnvelope),\n activeContent: Schema.optionalKey(Schema.Array(TranscriptActiveContent)),\n hasOlder: Schema.Boolean,\n hasNewer: Schema.Boolean,\n readiness: TranscriptReadiness,\n}).check(\n Schema.makeFilter(\n (window) =>\n [...window.records, ...window.dependencies].every(\n (record) => recordUpdatedSeq(record) <= window.throughSeq,\n ) || \"every record must be projected through throughSeq and none may be newer\",\n ),\n Schema.makeFilter(\n (window) =>\n window.readiness._tag === \"Ready\" ||\n window.activeContent === undefined ||\n \"a degraded read never attaches live content\",\n ),\n Schema.makeFilter(\n (window) =>\n window.readiness._tag !== \"Degraded\" ||\n window.readiness.failedAtSeq > window.throughSeq ||\n \"a degraded cut ends before the seq that failed\",\n ),\n Schema.makeFilter(\n (window) =>\n [...window.records, ...window.dependencies].every(\n (record) =>\n record.kind !== \"decorationBuffer\" &&\n (record.kind !== \"unknown\" || record.originalKind !== \"decorationBuffer\"),\n ) || \"decoration buffers are never served\",\n ),\n Schema.makeFilter((window) => {\n const ids = [...window.records, ...window.dependencies].map((record) => record.id);\n return new Set(ids).size === ids.length || \"a record is served at most once\";\n }),\n Schema.makeFilter(\n (window) =>\n window.records.every((record, index) => {\n const position = recordPosition(record);\n if (position === undefined || !isHistoryRecord(record)) return false;\n const previous = index === 0 ? undefined : window.records[index - 1];\n const previousPosition = previous === undefined ? undefined : recordPosition(previous);\n return (\n previous === undefined ||\n previousPosition === undefined ||\n TranscriptOrder(\n { ...previousPosition, recordId: previous.id },\n { ...position, recordId: record.id },\n ) < 0\n );\n }) || \"records are positioned history records in transcript order\",\n ),\n Schema.makeFilter(\n (window) =>\n window.dependencies.every((record) => !isHistoryRecord(record)) ||\n \"dependencies never contain history records\",\n ),\n Schema.makeFilter(\n (window) =>\n window.dependencies.every(\n (record) => record.kind !== \"user\" || isPendingTranscriptUserRecord(record),\n ) || \"the only user dependencies are pending users; cancelled users are never served\",\n ),\n Schema.makeFilter(\n (window) =>\n (window.readiness._tag !== \"Building\" && window.readiness._tag !== \"Unreadable\") ||\n (window.records.length === 0 &&\n window.dependencies.length === 0 &&\n !window.hasOlder &&\n !window.hasNewer) ||\n \"a building or unreadable window is empty\",\n ),\n);\nexport type TranscriptWindow = typeof TranscriptWindow.Type;\n\n/** Paging cursor for one top-level record of a window. */\nexport const transcriptCursorOf = (\n window: Pick<TranscriptWindow, \"incarnation\" | \"version\">,\n record: TranscriptRecordView,\n): TranscriptCursor | undefined => {\n const position = \"position\" in record ? record.position : undefined;\n return position === undefined\n ? undefined\n : {\n incarnation: window.incarnation,\n version: window.version,\n anchorSeq: position.anchorSeq,\n ordinal: position.ordinal,\n recordId: record.id,\n };\n};\n\n/** Health of one stored transcript version. A failed version is frozen at its last good cursor. */\nexport const TranscriptVersionStatus = Schema.TaggedUnion({\n Ok: {},\n Failed: { failedAtSeq: SequenceNumber, error: Schema.String },\n});\nexport type TranscriptVersionStatus = typeof TranscriptVersionStatus.Type;\n\n/**\n * Per-version maintenance state, one per version present in a session's storage.\n *\n * `cursor` is the last fully projected seq, committed together with that version's rows. At most\n * one version is `active` (served) and at most one is `building` (catching up from the log).\n */\nexport const TranscriptVersionMeta = Schema.Struct({\n version: TranscriptVersion,\n role: Schema.Literals([\"active\", \"building\"]),\n cursor: SequenceNumber,\n status: TranscriptVersionStatus,\n}).check(\n Schema.makeFilter(\n (meta) =>\n meta.status._tag !== \"Failed\" ||\n meta.status.failedAtSeq > meta.cursor ||\n \"a failed version is frozen before the seq that failed\",\n ),\n);\nexport type TranscriptVersionMeta = typeof TranscriptVersionMeta.Type;\n","import * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\n\nimport { SequenceNumber } from \"../types/core\";\nimport type { EDASessionStoreError } from \"../services/session-store\";\nimport {\n TranscriptCursor,\n TranscriptLogIncarnation,\n TranscriptOrder,\n TranscriptRecordViewFromEnvelope,\n TranscriptVersion,\n type TranscriptOrderKey,\n type TranscriptRecordView,\n} from \"./records\";\nimport type { EDATranscriptStoreShape, TranscriptCursorMismatch } from \"./store\";\nimport {\n TranscriptActiveContent,\n TranscriptReadiness,\n transcriptCursorOf,\n type TranscriptWindow,\n type TranscriptWindowLimits,\n type TranscriptWindowSelector,\n} from \"./window\";\n\nconst PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));\n\n/** Client-chosen correlation id echoed on the update that answers a request. */\nexport const TranscriptRequestId = Schema.NonEmptyString.check(Schema.isMaxLength(64));\nexport type TranscriptRequestId = typeof TranscriptRequestId.Type;\n\n/**\n * The contiguous span of top-level records a subscriber holds, both ends inclusive. Absent when\n * the subscriber holds no top-level records (an empty session, or a window still building).\n */\nexport const TranscriptCoverage = Schema.Struct({\n from: TranscriptCursor,\n to: TranscriptCursor,\n});\nexport type TranscriptCoverage = typeof TranscriptCoverage.Type;\n\n/**\n * What a subscriber holds after its last complete update: the cut it was read at and the span it\n * covers. Every update is planned relative to this base, which is also persisted with the socket\n * so a hibernated subscription resumes without volatile state.\n *\n * `tail` is true when the coverage reaches the newest record of its cut; new history then joins\n * the coverage as it is committed. A subscriber that paged back past the tail sees `hasNewer`\n * instead and pages forward to rejoin it.\n */\nexport const TranscriptSubscriptionBase = Schema.Struct({\n incarnation: TranscriptLogIncarnation,\n version: TranscriptVersion,\n throughSeq: SequenceNumber,\n coverage: Schema.optionalKey(TranscriptCoverage),\n tail: Schema.Boolean,\n});\nexport type TranscriptSubscriptionBase = typeof TranscriptSubscriptionBase.Type;\n\n/**\n * One ordered, complete change to a subscriber's window: the only way a live client's window\n * changes.\n *\n * - `replace` discards everything the client holds and installs this window.\n * - `patch` is relative to the client's previous complete update: `records` and `dependencies`\n * carry every record that changed or newly entered the window, `dependencyIds` lists the\n * complete dependency membership of the new cut (the client drops any other dependency), and\n * the client drops top-level records outside `coverage`.\n *\n * Either way the client ends at exactly the window read at `throughSeq`: a complete cut. When\n * present, `activeContent` replaces the client's active content completely (an empty array\n * clears it); when absent, active content is unchanged. A degraded update carries no live\n * content, and a client shows none while readiness is not `Ready`.\n */\nexport const TranscriptUpdate = Schema.Struct({\n updateSeq: PositiveInt,\n mode: Schema.Literals([\"replace\", \"patch\"]),\n incarnation: TranscriptLogIncarnation,\n version: TranscriptVersion,\n throughSeq: SequenceNumber,\n coverage: Schema.optionalKey(TranscriptCoverage),\n hasOlder: Schema.Boolean,\n hasNewer: Schema.Boolean,\n readiness: TranscriptReadiness,\n records: Schema.Array(TranscriptRecordViewFromEnvelope),\n dependencies: Schema.Array(TranscriptRecordViewFromEnvelope),\n dependencyIds: Schema.Array(Schema.NonEmptyString),\n activeContent: Schema.optionalKey(Schema.Array(TranscriptActiveContent)),\n requestId: Schema.optionalKey(TranscriptRequestId),\n}).check(\n Schema.makeFilter(\n (update) =>\n [...update.records, ...update.dependencies].every(\n (record) => record.updatedSeq <= update.throughSeq,\n ) || \"every record must be projected through throughSeq and none may be newer\",\n ),\n Schema.makeFilter(\n (update) =>\n update.readiness._tag === \"Ready\" ||\n update.activeContent === undefined ||\n update.activeContent.length === 0 ||\n \"a degraded update never carries live content\",\n ),\n Schema.makeFilter((update) => {\n const dependencyIds = new Set(update.dependencyIds);\n return (\n update.dependencies.every((record) => dependencyIds.has(record.id)) ||\n \"every sent dependency is a member of the cut\"\n );\n }),\n);\nexport type TranscriptUpdate = typeof TranscriptUpdate.Type;\n\n/** Bounds of one subscription. Retained coverage never exceeds `limits.maxRecords`. */\nexport interface TranscriptSubscriptionPolicy {\n /** Top-level records of a fresh subscription (design decision 4). */\n readonly initialCount: number;\n /** Largest page a client may request at once. */\n readonly maxPageCount: number;\n readonly limits: TranscriptWindowLimits;\n}\n\nexport const defaultTranscriptSubscriptionPolicy: TranscriptSubscriptionPolicy = {\n initialCount: 100,\n maxPageCount: 100,\n limits: { maxRecords: 300, maxBytes: 2 * 1_048_576, maxInlineBodyBytes: 16_384 },\n};\n\n/** A subscriber's request, decoded from its socket and handled strictly in arrival order. */\nexport type TranscriptSubscriptionRequest =\n /** Re-read the held coverage at a new cut, after committed changes. */\n | { readonly _tag: \"Refresh\" }\n /**\n * Start (or restart) a subscription. With `range` and `since` (what SSR rendered, or what a\n * reconnecting client last applied), the first update is a patch over that range; otherwise\n * it is a replacement of the latest `count` records.\n */\n | {\n readonly _tag: \"Subscribe\";\n readonly range?: TranscriptCoverage;\n readonly tail: boolean;\n readonly since?: SequenceNumber;\n readonly count?: number;\n }\n /** Extend the coverage by `count` records from its `before` or `after` edge. */\n | {\n readonly _tag: \"Page\";\n readonly direction: \"before\" | \"after\";\n readonly cursor: TranscriptCursor;\n readonly count: number;\n }\n /** Narrow the coverage to a span inside it, releasing the rest. */\n | { readonly _tag: \"Retain\"; readonly from: TranscriptCursor; readonly to: TranscriptCursor };\n\n/** One window read at a single cut, and the base the update for it is relative to. */\nexport interface TranscriptSubscriptionRead {\n readonly window: TranscriptWindow;\n /** What the client holds; `undefined` makes the update a replacement. */\n readonly patchBase: TranscriptSubscriptionBase | undefined;\n}\n\nconst orderKey = (cursor: TranscriptCursor): TranscriptOrderKey => ({\n anchorSeq: cursor.anchorSeq,\n ordinal: cursor.ordinal,\n recordId: cursor.recordId,\n});\n\nconst sameCursor = (left: TranscriptCursor, right: TranscriptCursor): boolean =>\n left.incarnation === right.incarnation &&\n left.version === right.version &&\n TranscriptOrder(orderKey(left), orderKey(right)) === 0;\n\n/**\n * A cursor after every possible record of one version, so a `Range` ending at it reads from a\n * point to the newest record. Never sent to clients.\n */\nconst tailCursor = (from: TranscriptCursor): TranscriptCursor => ({\n incarnation: from.incarnation,\n version: from.version,\n anchorSeq: SequenceNumber.make(Number.MAX_SAFE_INTEGER),\n ordinal: Number.MAX_SAFE_INTEGER,\n recordId: \"￿\",\n});\n\n/** The span a window's top-level records cover, or `undefined` when it has none. */\nexport const transcriptCoverageOf = (window: TranscriptWindow): TranscriptCoverage | undefined => {\n const first = window.records[0];\n const last = window.records[window.records.length - 1];\n const from = first === undefined ? undefined : transcriptCursorOf(window, first);\n const to = last === undefined ? undefined : transcriptCursorOf(window, last);\n return from === undefined || to === undefined ? undefined : { from, to };\n};\n\nconst withinCoverage = (\n coverage: TranscriptCoverage | undefined,\n record: TranscriptRecordView,\n): boolean => {\n if (coverage === undefined || !(\"position\" in record) || record.position === undefined) {\n return false;\n }\n const key = { ...record.position, recordId: record.id };\n return (\n TranscriptOrder(orderKey(coverage.from), key) <= 0 &&\n TranscriptOrder(key, orderKey(coverage.to)) <= 0\n );\n};\n\n/** The base a client holds after applying an update for `window`. */\nexport const transcriptSubscriptionBaseOf = (\n window: TranscriptWindow,\n): TranscriptSubscriptionBase => {\n const coverage = transcriptCoverageOf(window);\n return {\n incarnation: window.incarnation,\n version: window.version,\n throughSeq: window.throughSeq,\n ...(coverage === undefined ? {} : { coverage }),\n tail: !window.hasNewer,\n };\n};\n\n/**\n * Plan the one update that moves a client from `patchBase` to `window`.\n *\n * A patch sends a top-level record when it changed after the base cut or was outside the base\n * coverage. It sends a tool dependency when the tool changed or its assistant is sent, and any\n * other dependency (run groups, session context, pending users) when it changed or any top-level\n * record is sent. Everything else the client already holds unchanged from the base cut, because\n * the base cut was itself complete. A different incarnation or version, or a base cut ahead of\n * the window, makes the update a replacement.\n */\nexport const planTranscriptUpdate = (input: {\n readonly patchBase: TranscriptSubscriptionBase | undefined;\n readonly window: TranscriptWindow;\n readonly updateSeq: number;\n /** The live content captured at the same publication boundary as `window`. */\n readonly activeContent: ReadonlyArray<TranscriptActiveContent>;\n /**\n * Whether the client's active content must be replaced. A replacement always carries it;\n * otherwise the caller sends it only when it changed since its last send.\n */\n readonly includeActiveContent: boolean;\n readonly requestId?: TranscriptRequestId;\n}): TranscriptUpdate => {\n const { window } = input;\n const base = input.patchBase;\n const patch =\n base !== undefined &&\n base.incarnation === window.incarnation &&\n base.version === window.version &&\n base.throughSeq <= window.throughSeq;\n const records = patch\n ? window.records.filter(\n (record) => record.updatedSeq > base.throughSeq || !withinCoverage(base.coverage, record),\n )\n : window.records;\n const sentIds = new Set(records.map((record) => record.id));\n const dependencies = patch\n ? window.dependencies.filter(\n (record) =>\n record.updatedSeq > base.throughSeq ||\n (record.kind === \"tool\" ? sentIds.has(record.assistantId) : records.length > 0),\n )\n : window.dependencies;\n const coverage = transcriptCoverageOf(window);\n const activeContent =\n patch && !input.includeActiveContent\n ? undefined\n : servedActiveContent(window, input.activeContent);\n return {\n updateSeq: input.updateSeq,\n mode: patch ? \"patch\" : \"replace\",\n incarnation: window.incarnation,\n version: window.version,\n throughSeq: window.throughSeq,\n ...(coverage === undefined ? {} : { coverage }),\n hasOlder: window.hasOlder,\n hasNewer: window.hasNewer,\n readiness: window.readiness,\n records,\n dependencies,\n dependencyIds: window.dependencies.map((record) => record.id),\n ...(activeContent === undefined ? {} : { activeContent }),\n ...(input.requestId === undefined ? {} : { requestId: input.requestId }),\n };\n};\n\n/**\n * Live content as served with a window: none on a degraded read, and never for an inference the\n * window already shows as committed or failed, so a stale live part cannot override a terminal.\n */\nconst servedActiveContent = (\n window: TranscriptWindow,\n activeContent: ReadonlyArray<TranscriptActiveContent>,\n): ReadonlyArray<TranscriptActiveContent> => {\n if (window.readiness._tag !== \"Ready\") return [];\n const settled = new Set(\n window.records.flatMap((record) =>\n record.kind === \"assistant\" && record.lifecycle._tag !== \"Streaming\" ? [record.id] : [],\n ),\n );\n return activeContent.filter((content) => !settled.has(content.assistantId));\n};\n\n/**\n * Read the window that answers one request, at one cut.\n *\n * Helper reads (to find a page's far edge) may see other cuts; only the final read is served,\n * so the update is always one synchronous read. Coverage stays within `limits.maxRecords`:\n * paging back evicts the newest records, paging forward evicts the oldest, and a tail that\n * outgrows the bound keeps its newest records. A cursor minted for another incarnation or version\n * falls back to a replacement of the latest records.\n */\nexport const readTranscriptSubscription = (\n store: EDATranscriptStoreShape,\n base: TranscriptSubscriptionBase | undefined,\n request: TranscriptSubscriptionRequest,\n policy: TranscriptSubscriptionPolicy,\n): Effect.Effect<TranscriptSubscriptionRead, EDASessionStoreError> => {\n const read = (selector: TranscriptWindowSelector) =>\n store.readTranscriptWindow(selector, policy.limits);\n const latest = read({\n _tag: \"Latest\",\n count: Math.min(policy.initialCount, policy.limits.maxRecords),\n }).pipe(Effect.map((window) => ({ window, patchBase: undefined })));\n\n const readCoverage = Effect.fnUntraced(function* (\n coverage: TranscriptCoverage | undefined,\n tail: boolean,\n overflowToNewest: boolean,\n ) {\n if (coverage === undefined) {\n return yield* read({\n _tag: \"Latest\",\n count: Math.min(policy.initialCount, policy.limits.maxRecords),\n });\n }\n if (!tail) return yield* read({ _tag: \"Range\", ...coverage });\n const window = yield* read({\n _tag: \"Range\",\n from: coverage.from,\n to: tailCursor(coverage.from),\n });\n // The span outgrew the bound: keep as many of its newest records as the Range read held.\n return window.hasNewer && overflowToNewest\n ? yield* read({ _tag: \"Latest\", count: Math.max(1, window.records.length) })\n : window;\n });\n\n const handle = Effect.fnUntraced(function* () {\n switch (request._tag) {\n case \"Subscribe\": {\n const count = Math.min(request.count ?? policy.initialCount, policy.limits.maxRecords);\n if (request.range === undefined) {\n const window = yield* read({ _tag: \"Latest\", count });\n return { window, patchBase: undefined };\n }\n const claimed: TranscriptSubscriptionBase = {\n incarnation: request.range.from.incarnation,\n version: request.range.from.version,\n throughSeq: request.since ?? SequenceNumber.make(0),\n coverage: request.range,\n tail: request.tail,\n };\n const window = yield* readCoverage(request.range, request.tail, true);\n return { window, patchBase: request.since === undefined ? undefined : claimed };\n }\n case \"Refresh\": {\n if (base === undefined) return yield* latest;\n const window = yield* readCoverage(base.coverage, base.tail, true);\n return { window, patchBase: base };\n }\n case \"Page\": {\n const coverage = base?.coverage;\n const edge = request.direction === \"before\" ? coverage?.from : coverage?.to;\n if (base === undefined || coverage === undefined || edge === undefined) {\n return base === undefined\n ? yield* latest\n : { window: yield* readCoverage(base.coverage, base.tail, true), patchBase: base };\n }\n if (!sameCursor(edge, request.cursor)) {\n return { window: yield* readCoverage(coverage, base.tail, true), patchBase: base };\n }\n const page = yield* read({\n _tag: \"Page\",\n direction: request.direction,\n cursor: request.cursor,\n count: Math.min(request.count, policy.maxPageCount, policy.limits.maxRecords),\n });\n const first = page.records[0];\n const last = page.records[page.records.length - 1];\n const pageFrom = first === undefined ? undefined : transcriptCursorOf(page, first);\n const pageTo = last === undefined ? undefined : transcriptCursorOf(page, last);\n if (pageFrom === undefined || pageTo === undefined) {\n return { window: yield* readCoverage(coverage, base.tail, true), patchBase: base };\n }\n if (request.direction === \"before\") {\n // A Range keeps its oldest records when it is over a bound, evicting the newest.\n const window = yield* readCoverage({ from: pageFrom, to: coverage.to }, base.tail, false);\n return { window, patchBase: base };\n }\n const from = yield* evictOldest(read, coverage.from, pageTo, policy.limits.maxRecords);\n const window = yield* readCoverage({ from, to: pageTo }, !page.hasNewer, false);\n return { window, patchBase: base };\n }\n case \"Retain\": {\n const coverage = base?.coverage;\n if (base === undefined || coverage === undefined) {\n return base === undefined\n ? yield* latest\n : { window: yield* readCoverage(base.coverage, base.tail, true), patchBase: base };\n }\n const inside =\n request.from.incarnation === base.incarnation &&\n request.from.version === base.version &&\n request.to.incarnation === base.incarnation &&\n request.to.version === base.version &&\n TranscriptOrder(orderKey(coverage.from), orderKey(request.from)) <= 0 &&\n TranscriptOrder(orderKey(request.from), orderKey(request.to)) <= 0 &&\n TranscriptOrder(orderKey(request.to), orderKey(coverage.to)) <= 0;\n const retained = inside ? { from: request.from, to: request.to } : coverage;\n const tail = base.tail && sameCursor(retained.to, coverage.to);\n return { window: yield* readCoverage(retained, tail, true), patchBase: base };\n }\n }\n });\n\n // A Latest read names no cursor, so it cannot mismatch.\n return handle().pipe(\n Effect.catchTag(\"TranscriptCursorMismatch\", () =>\n latest.pipe(Effect.catchTag(\"TranscriptCursorMismatch\", Effect.die)),\n ),\n );\n};\n\n/**\n * The oldest cursor a span ending at `to` may start from without exceeding `maxRecords`: the\n * current `from`, or later when the span would be over the bound.\n */\nconst evictOldest = Effect.fnUntraced(function* (\n read: (\n selector: TranscriptWindowSelector,\n ) => Effect.Effect<TranscriptWindow, EDASessionStoreError | TranscriptCursorMismatch>,\n from: TranscriptCursor,\n to: TranscriptCursor,\n maxRecords: number,\n) {\n if (maxRecords <= 1) return to;\n const before = yield* read({\n _tag: \"Page\",\n direction: \"before\",\n cursor: to,\n count: maxRecords - 1,\n });\n const first = before.records[0];\n const oldest = first === undefined ? undefined : transcriptCursorOf(before, first);\n return oldest === undefined || TranscriptOrder(orderKey(oldest), orderKey(from)) <= 0\n ? from\n : oldest;\n});\n"],"mappings":";;;;;;;AAmBA,MAAMA,gBAAc,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAErE,MAAM,oBAAoB,YAAkD;CAC1E,WAAW,OAAO;CAClB,SAAS,OAAO;CAChB,UAAU,OAAO;AACnB;;;;;;;AAQA,MAAa,2BAA2B,OAAO,MAAM;CACnD,OAAO,aAAa,UAAU,EAAE,OAAOA,cAAY,CAAC;CACpD,OAAO,aAAa,QAAQ;EAC1B,WAAW,OAAO,SAAS,CAAC,UAAU,OAAO,CAAC;EAC9C,QAAQ;EACR,OAAOA;CACT,CAAC;CACD,OAAO,aAAa,SAAS;EAAE,MAAM;EAAkB,IAAI;CAAiB,CAAC,CAAC,C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QAAQ,IAAI,GAAG,SAAS,QAAQ,EAAE,CAAC,KAAK,KACjE,gBAAgB,SAAS,QAAQ,EAAE,GAAG,SAAS,SAAS,EAAE,CAAC,KAAK,IACxC;KAAE,MAAM,QAAQ;KAAM,IAAI,QAAQ;IAAG,IAAI;IACnE,MAAM,OAAO,KAAK,QAAQ,WAAW,SAAS,IAAI,SAAS,EAAE;IAC7D,OAAO;KAAE,QAAQ,OAAO,aAAa,UAAU,MAAM,IAAI;KAAG,WAAW;IAAK;GAC9E;EACF;CACF,CAGY,CAAC,CAAC,CAAC,CAAC,KACd,OAAO,SAAS,kCACd,OAAO,KAAK,OAAO,SAAS,4BAA4B,OAAO,GAAG,CAAC,CACrE,CACF;AACF;;;;;AAMA,MAAM,cAAc,OAAO,WAAW,WACpC,MAGA,MACA,IACA,YACA;CACA,IAAI,cAAc,GAAG,OAAO;CAC5B,MAAM,SAAS,OAAO,KAAK;EACzB,MAAM;EACN,WAAW;EACX,QAAQ;EACR,OAAO,aAAa;CACtB,CAAC;CACD,MAAM,QAAQ,OAAO,QAAQ;CAC7B,MAAM,SAAS,UAAU,KAAA,IAAY,KAAA,IAAY,mBAAmB,QAAQ,KAAK;CACjF,OAAO,WAAW,KAAA,KAAa,gBAAgB,SAAS,MAAM,GAAG,SAAS,IAAI,CAAC,KAAK,IAChF,OACA;AACN,CAAC"}
@@ -23,8 +23,14 @@ declare const testNowMs: number & import("effect/Brand").Brand<"UnixEpochMillis"
23
23
  declare const makeFixedClock: (nowMs: number) => Clock.Clock;
24
24
  /** Layer pinning the ambient Clock reference to a fixed instant. */
25
25
  declare const FixedClock: (nowMs: number) => Layer.Layer<never, never, never>;
26
- /** Fake provider stream input; arrays are consumed one streamText call at a time. */
27
- type TestModelParts = Stream.Stream<InferenceRunnerStreamPart, unknown> | ReadonlyArray<Stream.Stream<InferenceRunnerStreamPart, unknown>>;
26
+ /**
27
+ * Fake provider stream input; arrays are consumed one streamText call at a time, and a function
28
+ * chooses each call's stream from its prompt (for hosts serving many sessions at once).
29
+ */
30
+ type TestModelParts = Stream.Stream<InferenceRunnerStreamPart, unknown> | ReadonlyArray<Stream.Stream<InferenceRunnerStreamPart, unknown>> | ((input: {
31
+ readonly index: number;
32
+ readonly prompt: Prompt.RawInput;
33
+ }) => Stream.Stream<InferenceRunnerStreamPart, unknown>);
28
34
  /** Options for the fake Effect AI LanguageModel used by EDA runtime tests. */
29
35
  interface TestLanguageModelOptions {
30
36
  readonly parts: TestModelParts;
@@ -49,6 +49,10 @@ const makeLanguageModelLayer = (options) => {
49
49
  prompt: input.prompt,
50
50
  toolNames: Object.keys(inputToolkit(input)?.tools ?? {})
51
51
  });
52
+ if (typeof config.parts === "function") return config.parts({
53
+ index,
54
+ prompt: input.prompt
55
+ });
52
56
  if (!Array.isArray(config.parts)) return config.parts;
53
57
  const stream = config.parts[index];
54
58
  return stream === void 0 ? yield* Effect.die(/* @__PURE__ */ new Error(`No fake LanguageModel stream configured for call ${index}`)) : stream;
@@ -1 +1 @@
1
- {"version":3,"file":"layers.js","names":[],"sources":["../../src/testkit/layers.ts"],"sourcesContent":["import * as Clock from \"effect/Clock\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport * as Stream from \"effect/Stream\";\nimport * as LanguageModel from \"effect/ai/LanguageModel\";\nimport type * as Prompt from \"effect/ai/Prompt\";\nimport * as Response from \"effect/ai/Response\";\n\nimport { SessionId } from \"../types/core\";\nimport { type DurableEventEnvelope, UnixEpochMillis } from \"../types/events\";\n\nimport { EDASessionStore } from \"../services/session-store\";\nimport { CompactionExecutor, CompactionPolicy, CompactionRunner } from \"../services/compaction\";\nimport type { EDASessionStoreShape } from \"../services/session-store\";\nimport { EventFactory } from \"../services/event-factory\";\nimport { IdGenerator } from \"../services/id-generator\";\nimport { EDAKeepAlive } from \"../services/keep-alive\";\nimport { LiveEventBus } from \"../services/live-event-bus\";\nimport type { SessionEventObserver } from \"../services/session-event-observer\";\nimport { EDAPromptProjector } from \"../services/prompt-projector\";\nimport { EDAReducerRegistry, type EDAReducer } from \"../services/reducer-registry\";\nimport { EDASinkRegistry, type EDASink } from \"../services/sink-registry\";\nimport { SinkCheckpointStore } from \"../services/sink-checkpoint-store\";\nimport { RunScheduler } from \"../services/run-scheduler\";\nimport { RunSchedulingWakeup } from \"../services/run-scheduling-wakeup\";\nimport { SessionContext } from \"../services/session-context\";\nimport { EDASessionQuery } from \"../services/session-query\";\nimport { SessionState } from \"../services/session-state\";\nimport { ToolExecutor } from \"../services/tool-executor\";\nimport { EDAToolRegistry } from \"../services/tool-registry\";\nimport type { EDAModelToolkit, ToolParamsSchema } from \"../services/tool-registry\";\nimport { InferenceRunner } from \"../services/inference-runner\";\nimport { ModelResolver } from \"../services/model-resolver\";\nimport type { InferenceRunnerStreamPart } from \"../services/inference-runner\";\nimport { TurnRunner } from \"../services/turn-runner\";\n\n/** Default fixed test wall-clock; matches the historical CREATED_AT_MS test constant. */\nexport const testNowMs = UnixEpochMillis.make(1_715_000_000_000);\n\n/** A Clock whose current time never advances; sleep resolves immediately. */\nexport const makeFixedClock = (nowMs: number): Clock.Clock => ({\n currentTimeMillisUnsafe: () => nowMs,\n currentTimeMillis: Effect.sync(() => nowMs),\n currentTimeNanosUnsafe: () => BigInt(nowMs) * 1_000_000n,\n currentTimeNanos: Effect.sync(() => BigInt(nowMs) * 1_000_000n),\n monotonicTimeNanosUnsafe: () => BigInt(nowMs) * 1_000_000n,\n monotonicTimeNanos: Effect.sync(() => BigInt(nowMs) * 1_000_000n),\n sleep: () => Effect.void,\n});\n\n/** Layer pinning the ambient Clock reference to a fixed instant. */\nexport const FixedClock = (nowMs: number) => Layer.succeed(Clock.Clock, makeFixedClock(nowMs));\n\n/** Fake provider stream input; arrays are consumed one streamText call at a time. */\nexport type TestModelParts =\n | Stream.Stream<InferenceRunnerStreamPart, unknown>\n | ReadonlyArray<Stream.Stream<InferenceRunnerStreamPart, unknown>>;\n\n/** Options for the fake Effect AI LanguageModel used by EDA runtime tests. */\nexport interface TestLanguageModelOptions {\n readonly parts: TestModelParts;\n /** Optional fake generateText output for compaction/summarization tests. */\n readonly generateText?: string | ((input: { readonly prompt: Prompt.RawInput }) => string);\n readonly onGenerateText?: (input: { readonly prompt: Prompt.RawInput }) => void;\n readonly onStreamText?: (input: {\n readonly index: number;\n readonly prompt: Prompt.RawInput;\n readonly toolNames: ReadonlyArray<string>;\n }) => void;\n}\n\n/** Fake provider whose streamText returns configured test streams; other methods die. */\nexport const makeLanguageModelLayer = (options: TestModelParts | TestLanguageModelOptions) => {\n const config = isTestLanguageModelOptions(options) ? options : { parts: options };\n const unused = () => Effect.die(new Error(\"unused fake LanguageModel method\"));\n return Layer.effect(\n LanguageModel.LanguageModel,\n Effect.gen(function* () {\n const nextIndex = yield* Ref.make(0);\n const streamText = ((input: { readonly prompt: Prompt.RawInput }) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const index = yield* Ref.getAndUpdate(nextIndex, (current) => current + 1);\n config.onStreamText?.({\n index,\n prompt: input.prompt,\n toolNames: Object.keys(inputToolkit(input)?.tools ?? {}),\n });\n if (!Array.isArray(config.parts)) {\n return config.parts;\n }\n const stream = config.parts[index];\n return stream === undefined\n ? yield* Effect.die(\n new Error(`No fake LanguageModel stream configured for call ${index}`),\n )\n : stream;\n }),\n )) as LanguageModel.LanguageModel[\"streamText\"];\n const generateText = ((input: { readonly prompt: Prompt.RawInput }) =>\n Effect.sync(() => {\n config.onGenerateText?.({ prompt: input.prompt });\n if (config.generateText === undefined) {\n return Effect.runSync(unused()) as never;\n }\n const text =\n typeof config.generateText === \"function\"\n ? config.generateText({ prompt: input.prompt })\n : config.generateText;\n return new LanguageModel.GenerateTextResponse([Response.makePart(\"text\", { text })]);\n })) as unknown as LanguageModel.LanguageModel[\"generateText\"];\n return {\n [LanguageModel.TypeId]: LanguageModel.TypeId,\n generateText,\n generateObject: unused as LanguageModel.LanguageModel[\"generateObject\"],\n streamText,\n };\n }),\n );\n};\n\nconst inputToolkit = (input: {\n readonly prompt: Prompt.RawInput;\n readonly toolkit?: unknown;\n}): { readonly tools: Record<string, unknown> } | undefined => {\n const toolkit = input.toolkit;\n return typeof toolkit === \"object\" && toolkit !== null && \"tools\" in toolkit\n ? (toolkit as { readonly tools: Record<string, unknown> })\n : undefined;\n};\n\nconst isTestLanguageModelOptions = (\n options: TestModelParts | TestLanguageModelOptions,\n): options is TestLanguageModelOptions =>\n typeof options === \"object\" &&\n options !== null &&\n \"parts\" in options &&\n !Stream.isStream(options);\n\n/** Single-session in-memory layer graph options for EDA service tests. */\nexport interface EdaTestLayerOptions {\n readonly runSchedulerLayer?: Layer.Layer<RunScheduler>;\n readonly runSchedulingWakeupLayer?: Layer.Layer<RunSchedulingWakeup>;\n readonly sessionId: SessionId;\n /** Explicit ID sequence (Deterministic); omit for counter-based Sequential IDs. */\n readonly ids?: ReadonlyArray<string>;\n /** Real/alternate provider layer; when absent, the fake stream provider is used. */\n readonly modelLayer?: Layer.Layer<LanguageModel.LanguageModel>;\n /** Replaces the external model-selection boundary when testing execution policy. */\n readonly modelResolverLayer?: Layer.Layer<ModelResolver>;\n /** Fake provider stream parts; defaults to an empty stream. Ignored when `modelLayer` is provided. */\n readonly parts?: TestModelParts;\n /** Optional fake generateText output for compaction/summarization tests. */\n readonly generateText?: string | ((input: { readonly prompt: Prompt.RawInput }) => string);\n /** Test hook for inspecting each fake generateText call. */\n readonly onGenerateText?: (input: { readonly prompt: Prompt.RawInput }) => void;\n /** Test hook for inspecting each fake streamText call. */\n readonly onStreamText?: (input: {\n readonly index: number;\n readonly prompt: Prompt.RawInput;\n readonly toolNames: ReadonlyArray<string>;\n }) => void;\n /** Handler-backed Effect Toolkit; overrides `toolSchemas` when present. */\n readonly toolkit?: EDAModelToolkit;\n /** Test/convenience schema-only tools; execution fails unless `toolkit` is provided. */\n readonly toolSchemas?: ReadonlyMap<string, ToolParamsSchema>;\n /** Durable prefix used when constructing a fresh in-memory runtime for recovery tests. */\n readonly seedEvents?: ReadonlyArray<DurableEventEnvelope>;\n /** Fixed wall-clock for event timestamps; defaults to `testNowMs`. */\n readonly nowMs?: number;\n /** Use the ambient live Clock instead of pinning test time. Intended for offline trace latency runs. */\n readonly clock?: \"fixed\" | \"live\";\n /** Wrap the in-memory store shape, e.g. to inject one-shot failures. Test-only. */\n readonly wrapStore?: (inner: EDASessionStoreShape) => EDASessionStoreShape;\n /** Override host keepAlive tracking. Test-only. */\n readonly keepAliveLayer?: Layer.Layer<EDAKeepAlive>;\n /** Override compaction policy; defaults to disabled. */\n readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;\n /** Override compaction executor; defaults to disabled. */\n readonly compactionExecutorLayer?: Layer.Layer<CompactionExecutor>;\n /** App-specific durable metadata reducers. */\n readonly reducers?: ReadonlyArray<EDAReducer>;\n /** Override state-to-LLM context projection. */\n readonly promptProjectorLayer?: Layer.Layer<EDAPromptProjector>;\n /** App-provided EDA sinks. */\n readonly sinks?: ReadonlyArray<EDASink>;\n /** Host publication observer, such as a WebSocket connection manager. */\n readonly sessionEventObserverLayer?: Layer.Layer<SessionEventObserver>;\n}\n\n/**\n * One in-memory layer graph for the whole session runtime, exposing every\n * EDA service plus the fixed Clock. Layer constants are shared by reference,\n * so all services see the same store, bus, and ID counter.\n */\nexport const makeEdaTestLayer = (options: EdaTestLayerOptions) => {\n const BaseStore =\n options.seedEvents === undefined\n ? EDASessionStore.InMemory(options.sessionId)\n : EDASessionStore.InMemorySeeded(options.sessionId, options.seedEvents);\n const Store =\n options.wrapStore === undefined\n ? BaseStore\n : Layer.effect(\n EDASessionStore,\n Effect.gen(function* () {\n const inner = yield* EDASessionStore;\n return options.wrapStore!(inner);\n }),\n ).pipe(Layer.provide(BaseStore));\n const Bus =\n options.sessionEventObserverLayer === undefined\n ? LiveEventBus.Noop\n : LiveEventBus.Live.pipe(Layer.provide(options.sessionEventObserverLayer));\n const KeepAlive = options.keepAliveLayer ?? EDAKeepAlive.Noop;\n const SinkCheckpoints = SinkCheckpointStore.InMemory;\n const Ids =\n options.ids === undefined ? IdGenerator.Sequential : IdGenerator.Deterministic(options.ids);\n const Session = SessionContext.Live(options.sessionId);\n const TestClock = options.clock === \"live\" ? Layer.empty : FixedClock(options.nowMs ?? testNowMs);\n const Factory = EventFactory.Live.pipe(Layer.provideMerge(Layer.mergeAll(Session, Ids)));\n const ReducerRegistry = EDAReducerRegistry.Live(options.reducers ?? []);\n const PromptProjector = options.promptProjectorLayer ?? EDAPromptProjector.Default;\n const Model =\n options.modelLayer ??\n makeLanguageModelLayer({\n generateText: options.generateText,\n onGenerateText: options.onGenerateText,\n onStreamText: options.onStreamText,\n parts: options.parts ?? Stream.empty,\n });\n const CompactionPolicyLayer = options.compactionPolicyLayer ?? CompactionPolicy.Disabled;\n const Models = options.modelResolverLayer ?? ModelResolver.Fixed.pipe(Layer.provideMerge(Model));\n const CompactionExecutorLayer = options.compactionExecutorLayer ?? CompactionExecutor.Disabled;\n const Registry =\n options.toolkit !== undefined\n ? EDAToolRegistry.FromToolkit(options.toolkit)\n : options.toolSchemas === undefined\n ? EDAToolRegistry.Empty\n : EDAToolRegistry.FromSchemas(options.toolSchemas);\n const Compaction = CompactionRunner.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Factory,\n Ids,\n KeepAlive,\n Models,\n Session,\n PromptProjector,\n Registry,\n CompactionPolicyLayer,\n CompactionExecutorLayer,\n ),\n ),\n );\n const SinkRegistry = EDASinkRegistry.Live(options.sinks ?? []).pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Session,\n Store,\n Bus,\n SinkCheckpoints,\n Factory,\n Ids,\n ReducerRegistry,\n KeepAlive,\n ),\n ),\n );\n const State = SessionState.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Bus,\n Session,\n ReducerRegistry,\n SinkRegistry,\n KeepAlive,\n Compaction,\n PromptProjector,\n options.runSchedulerLayer ?? RunScheduler.Immediate,\n options.runSchedulingWakeupLayer ?? RunSchedulingWakeup.Unsupported,\n ),\n ),\n );\n const InferenceRunnerLayer = InferenceRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Models, Registry, Ids)),\n );\n const ToolExec = ToolExecutor.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Registry, Ids, Session, Store)),\n );\n const Turn = TurnRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(InferenceRunnerLayer, ToolExec, Factory, Ids)),\n );\n const StateWithRun = State.pipe(Layer.provideMerge(Layer.mergeAll(Turn, Factory, Ids)));\n const Query = EDASessionQuery.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Store, Bus)),\n );\n\n return Layer.mergeAll(StateWithRun, Query, InferenceRunnerLayer, ToolExec, TestClock);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,YAAY,gBAAgB,KAAK,MAAiB;;AAG/D,MAAa,kBAAkB,WAAgC;CAC7D,+BAA+B;CAC/B,mBAAmB,OAAO,WAAW,KAAK;CAC1C,8BAA8B,OAAO,KAAK,IAAI;CAC9C,kBAAkB,OAAO,WAAW,OAAO,KAAK,IAAI,QAAU;CAC9D,gCAAgC,OAAO,KAAK,IAAI;CAChD,oBAAoB,OAAO,WAAW,OAAO,KAAK,IAAI,QAAU;CAChE,aAAa,OAAO;AACtB;;AAGA,MAAa,cAAc,UAAkB,MAAM,QAAQ,MAAM,OAAO,eAAe,KAAK,CAAC;;AAqB7F,MAAa,0BAA0B,YAAuD;CAC5F,MAAM,SAAS,2BAA2B,OAAO,IAAI,UAAU,EAAE,OAAO,QAAQ;CAChF,MAAM,eAAe,OAAO,oBAAI,IAAI,MAAM,kCAAkC,CAAC;CAC7E,OAAO,MAAM,OACX,cAAc,eACd,OAAO,IAAI,aAAa;EACtB,MAAM,YAAY,OAAO,IAAI,KAAK,CAAC;EACnC,MAAM,eAAe,UACnB,OAAO,OACL,OAAO,IAAI,aAAa;GACtB,MAAM,QAAQ,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,OACA,SACA,KACA,WACA,QACA,SACA,iBACA,UACA,uBACA,uBACF,CACF,CACF;CACA,MAAM,eAAe,gBAAgB,KAAK,QAAQ,SAAS,CAAC,CAAC,CAAC,CAAC,KAC7D,MAAM,aACJ,MAAM,SACJ,SACA,OACA,KACA,iBACA,SACA,KACA,iBACA,SACF,CACF,CACF;CACA,MAAM,QAAQ,aAAa,KAAK,KAC9B,MAAM,aACJ,MAAM,SACJ,OACA,KACA,SACA,iBACA,cACA,WACA,YACA,iBACA,QAAQ,qBAAqB,aAAa,WAC1C,QAAQ,4BAA4B,oBAAoB,WAC1D,CACF,CACF;CACA,MAAM,uBAAuB,gBAAgB,KAAK,KAChD,MAAM,aAAa,MAAM,SAAS,SAAS,QAAQ,UAAU,GAAG,CAAC,CACnE;CACA,MAAM,WAAW,aAAa,KAAK,KACjC,MAAM,aAAa,MAAM,SAAS,SAAS,UAAU,KAAK,SAAS,KAAK,CAAC,CAC3E;CACA,MAAM,OAAO,WAAW,KAAK,KAC3B,MAAM,aAAa,MAAM,SAAS,sBAAsB,UAAU,SAAS,GAAG,CAAC,CACjF;CACA,MAAM,eAAe,MAAM,KAAK,MAAM,aAAa,MAAM,SAAS,MAAM,SAAS,GAAG,CAAC,CAAC;CACtF,MAAM,QAAQ,gBAAgB,KAAK,KACjC,MAAM,aAAa,MAAM,SAAS,cAAc,OAAO,GAAG,CAAC,CAC7D;CAEA,OAAO,MAAM,SAAS,cAAc,OAAO,sBAAsB,UAAU,SAAS;AACtF"}
1
+ {"version":3,"file":"layers.js","names":[],"sources":["../../src/testkit/layers.ts"],"sourcesContent":["import * as Clock from \"effect/Clock\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport * as Stream from \"effect/Stream\";\nimport * as LanguageModel from \"effect/ai/LanguageModel\";\nimport type * as Prompt from \"effect/ai/Prompt\";\nimport * as Response from \"effect/ai/Response\";\n\nimport { SessionId } from \"../types/core\";\nimport { type DurableEventEnvelope, UnixEpochMillis } from \"../types/events\";\n\nimport { EDASessionStore } from \"../services/session-store\";\nimport { CompactionExecutor, CompactionPolicy, CompactionRunner } from \"../services/compaction\";\nimport type { EDASessionStoreShape } from \"../services/session-store\";\nimport { EventFactory } from \"../services/event-factory\";\nimport { IdGenerator } from \"../services/id-generator\";\nimport { EDAKeepAlive } from \"../services/keep-alive\";\nimport { LiveEventBus } from \"../services/live-event-bus\";\nimport type { SessionEventObserver } from \"../services/session-event-observer\";\nimport { EDAPromptProjector } from \"../services/prompt-projector\";\nimport { EDAReducerRegistry, type EDAReducer } from \"../services/reducer-registry\";\nimport { EDASinkRegistry, type EDASink } from \"../services/sink-registry\";\nimport { SinkCheckpointStore } from \"../services/sink-checkpoint-store\";\nimport { RunScheduler } from \"../services/run-scheduler\";\nimport { RunSchedulingWakeup } from \"../services/run-scheduling-wakeup\";\nimport { SessionContext } from \"../services/session-context\";\nimport { EDASessionQuery } from \"../services/session-query\";\nimport { SessionState } from \"../services/session-state\";\nimport { ToolExecutor } from \"../services/tool-executor\";\nimport { EDAToolRegistry } from \"../services/tool-registry\";\nimport type { EDAModelToolkit, ToolParamsSchema } from \"../services/tool-registry\";\nimport { InferenceRunner } from \"../services/inference-runner\";\nimport { ModelResolver } from \"../services/model-resolver\";\nimport type { InferenceRunnerStreamPart } from \"../services/inference-runner\";\nimport { TurnRunner } from \"../services/turn-runner\";\n\n/** Default fixed test wall-clock; matches the historical CREATED_AT_MS test constant. */\nexport const testNowMs = UnixEpochMillis.make(1_715_000_000_000);\n\n/** A Clock whose current time never advances; sleep resolves immediately. */\nexport const makeFixedClock = (nowMs: number): Clock.Clock => ({\n currentTimeMillisUnsafe: () => nowMs,\n currentTimeMillis: Effect.sync(() => nowMs),\n currentTimeNanosUnsafe: () => BigInt(nowMs) * 1_000_000n,\n currentTimeNanos: Effect.sync(() => BigInt(nowMs) * 1_000_000n),\n monotonicTimeNanosUnsafe: () => BigInt(nowMs) * 1_000_000n,\n monotonicTimeNanos: Effect.sync(() => BigInt(nowMs) * 1_000_000n),\n sleep: () => Effect.void,\n});\n\n/** Layer pinning the ambient Clock reference to a fixed instant. */\nexport const FixedClock = (nowMs: number) => Layer.succeed(Clock.Clock, makeFixedClock(nowMs));\n\n/**\n * Fake provider stream input; arrays are consumed one streamText call at a time, and a function\n * chooses each call's stream from its prompt (for hosts serving many sessions at once).\n */\nexport type TestModelParts =\n | Stream.Stream<InferenceRunnerStreamPart, unknown>\n | ReadonlyArray<Stream.Stream<InferenceRunnerStreamPart, unknown>>\n | ((input: {\n readonly index: number;\n readonly prompt: Prompt.RawInput;\n }) => Stream.Stream<InferenceRunnerStreamPart, unknown>);\n\n/** Options for the fake Effect AI LanguageModel used by EDA runtime tests. */\nexport interface TestLanguageModelOptions {\n readonly parts: TestModelParts;\n /** Optional fake generateText output for compaction/summarization tests. */\n readonly generateText?: string | ((input: { readonly prompt: Prompt.RawInput }) => string);\n readonly onGenerateText?: (input: { readonly prompt: Prompt.RawInput }) => void;\n readonly onStreamText?: (input: {\n readonly index: number;\n readonly prompt: Prompt.RawInput;\n readonly toolNames: ReadonlyArray<string>;\n }) => void;\n}\n\n/** Fake provider whose streamText returns configured test streams; other methods die. */\nexport const makeLanguageModelLayer = (options: TestModelParts | TestLanguageModelOptions) => {\n const config = isTestLanguageModelOptions(options) ? options : { parts: options };\n const unused = () => Effect.die(new Error(\"unused fake LanguageModel method\"));\n return Layer.effect(\n LanguageModel.LanguageModel,\n Effect.gen(function* () {\n const nextIndex = yield* Ref.make(0);\n const streamText = ((input: { readonly prompt: Prompt.RawInput }) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const index = yield* Ref.getAndUpdate(nextIndex, (current) => current + 1);\n config.onStreamText?.({\n index,\n prompt: input.prompt,\n toolNames: Object.keys(inputToolkit(input)?.tools ?? {}),\n });\n if (typeof config.parts === \"function\") {\n return config.parts({ index, prompt: input.prompt });\n }\n if (!Array.isArray(config.parts)) {\n return config.parts;\n }\n const stream = config.parts[index];\n return stream === undefined\n ? yield* Effect.die(\n new Error(`No fake LanguageModel stream configured for call ${index}`),\n )\n : stream;\n }),\n )) as LanguageModel.LanguageModel[\"streamText\"];\n const generateText = ((input: { readonly prompt: Prompt.RawInput }) =>\n Effect.sync(() => {\n config.onGenerateText?.({ prompt: input.prompt });\n if (config.generateText === undefined) {\n return Effect.runSync(unused()) as never;\n }\n const text =\n typeof config.generateText === \"function\"\n ? config.generateText({ prompt: input.prompt })\n : config.generateText;\n return new LanguageModel.GenerateTextResponse([Response.makePart(\"text\", { text })]);\n })) as unknown as LanguageModel.LanguageModel[\"generateText\"];\n return {\n [LanguageModel.TypeId]: LanguageModel.TypeId,\n generateText,\n generateObject: unused as LanguageModel.LanguageModel[\"generateObject\"],\n streamText,\n };\n }),\n );\n};\n\nconst inputToolkit = (input: {\n readonly prompt: Prompt.RawInput;\n readonly toolkit?: unknown;\n}): { readonly tools: Record<string, unknown> } | undefined => {\n const toolkit = input.toolkit;\n return typeof toolkit === \"object\" && toolkit !== null && \"tools\" in toolkit\n ? (toolkit as { readonly tools: Record<string, unknown> })\n : undefined;\n};\n\nconst isTestLanguageModelOptions = (\n options: TestModelParts | TestLanguageModelOptions,\n): options is TestLanguageModelOptions =>\n typeof options === \"object\" &&\n options !== null &&\n \"parts\" in options &&\n !Stream.isStream(options);\n\n/** Single-session in-memory layer graph options for EDA service tests. */\nexport interface EdaTestLayerOptions {\n readonly runSchedulerLayer?: Layer.Layer<RunScheduler>;\n readonly runSchedulingWakeupLayer?: Layer.Layer<RunSchedulingWakeup>;\n readonly sessionId: SessionId;\n /** Explicit ID sequence (Deterministic); omit for counter-based Sequential IDs. */\n readonly ids?: ReadonlyArray<string>;\n /** Real/alternate provider layer; when absent, the fake stream provider is used. */\n readonly modelLayer?: Layer.Layer<LanguageModel.LanguageModel>;\n /** Replaces the external model-selection boundary when testing execution policy. */\n readonly modelResolverLayer?: Layer.Layer<ModelResolver>;\n /** Fake provider stream parts; defaults to an empty stream. Ignored when `modelLayer` is provided. */\n readonly parts?: TestModelParts;\n /** Optional fake generateText output for compaction/summarization tests. */\n readonly generateText?: string | ((input: { readonly prompt: Prompt.RawInput }) => string);\n /** Test hook for inspecting each fake generateText call. */\n readonly onGenerateText?: (input: { readonly prompt: Prompt.RawInput }) => void;\n /** Test hook for inspecting each fake streamText call. */\n readonly onStreamText?: (input: {\n readonly index: number;\n readonly prompt: Prompt.RawInput;\n readonly toolNames: ReadonlyArray<string>;\n }) => void;\n /** Handler-backed Effect Toolkit; overrides `toolSchemas` when present. */\n readonly toolkit?: EDAModelToolkit;\n /** Test/convenience schema-only tools; execution fails unless `toolkit` is provided. */\n readonly toolSchemas?: ReadonlyMap<string, ToolParamsSchema>;\n /** Durable prefix used when constructing a fresh in-memory runtime for recovery tests. */\n readonly seedEvents?: ReadonlyArray<DurableEventEnvelope>;\n /** Fixed wall-clock for event timestamps; defaults to `testNowMs`. */\n readonly nowMs?: number;\n /** Use the ambient live Clock instead of pinning test time. Intended for offline trace latency runs. */\n readonly clock?: \"fixed\" | \"live\";\n /** Wrap the in-memory store shape, e.g. to inject one-shot failures. Test-only. */\n readonly wrapStore?: (inner: EDASessionStoreShape) => EDASessionStoreShape;\n /** Override host keepAlive tracking. Test-only. */\n readonly keepAliveLayer?: Layer.Layer<EDAKeepAlive>;\n /** Override compaction policy; defaults to disabled. */\n readonly compactionPolicyLayer?: Layer.Layer<CompactionPolicy>;\n /** Override compaction executor; defaults to disabled. */\n readonly compactionExecutorLayer?: Layer.Layer<CompactionExecutor>;\n /** App-specific durable metadata reducers. */\n readonly reducers?: ReadonlyArray<EDAReducer>;\n /** Override state-to-LLM context projection. */\n readonly promptProjectorLayer?: Layer.Layer<EDAPromptProjector>;\n /** App-provided EDA sinks. */\n readonly sinks?: ReadonlyArray<EDASink>;\n /** Host publication observer, such as a WebSocket connection manager. */\n readonly sessionEventObserverLayer?: Layer.Layer<SessionEventObserver>;\n}\n\n/**\n * One in-memory layer graph for the whole session runtime, exposing every\n * EDA service plus the fixed Clock. Layer constants are shared by reference,\n * so all services see the same store, bus, and ID counter.\n */\nexport const makeEdaTestLayer = (options: EdaTestLayerOptions) => {\n const BaseStore =\n options.seedEvents === undefined\n ? EDASessionStore.InMemory(options.sessionId)\n : EDASessionStore.InMemorySeeded(options.sessionId, options.seedEvents);\n const Store =\n options.wrapStore === undefined\n ? BaseStore\n : Layer.effect(\n EDASessionStore,\n Effect.gen(function* () {\n const inner = yield* EDASessionStore;\n return options.wrapStore!(inner);\n }),\n ).pipe(Layer.provide(BaseStore));\n const Bus =\n options.sessionEventObserverLayer === undefined\n ? LiveEventBus.Noop\n : LiveEventBus.Live.pipe(Layer.provide(options.sessionEventObserverLayer));\n const KeepAlive = options.keepAliveLayer ?? EDAKeepAlive.Noop;\n const SinkCheckpoints = SinkCheckpointStore.InMemory;\n const Ids =\n options.ids === undefined ? IdGenerator.Sequential : IdGenerator.Deterministic(options.ids);\n const Session = SessionContext.Live(options.sessionId);\n const TestClock = options.clock === \"live\" ? Layer.empty : FixedClock(options.nowMs ?? testNowMs);\n const Factory = EventFactory.Live.pipe(Layer.provideMerge(Layer.mergeAll(Session, Ids)));\n const ReducerRegistry = EDAReducerRegistry.Live(options.reducers ?? []);\n const PromptProjector = options.promptProjectorLayer ?? EDAPromptProjector.Default;\n const Model =\n options.modelLayer ??\n makeLanguageModelLayer({\n generateText: options.generateText,\n onGenerateText: options.onGenerateText,\n onStreamText: options.onStreamText,\n parts: options.parts ?? Stream.empty,\n });\n const CompactionPolicyLayer = options.compactionPolicyLayer ?? CompactionPolicy.Disabled;\n const Models = options.modelResolverLayer ?? ModelResolver.Fixed.pipe(Layer.provideMerge(Model));\n const CompactionExecutorLayer = options.compactionExecutorLayer ?? CompactionExecutor.Disabled;\n const Registry =\n options.toolkit !== undefined\n ? EDAToolRegistry.FromToolkit(options.toolkit)\n : options.toolSchemas === undefined\n ? EDAToolRegistry.Empty\n : EDAToolRegistry.FromSchemas(options.toolSchemas);\n const Compaction = CompactionRunner.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Factory,\n Ids,\n KeepAlive,\n Models,\n Session,\n PromptProjector,\n Registry,\n CompactionPolicyLayer,\n CompactionExecutorLayer,\n ),\n ),\n );\n const SinkRegistry = EDASinkRegistry.Live(options.sinks ?? []).pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Session,\n Store,\n Bus,\n SinkCheckpoints,\n Factory,\n Ids,\n ReducerRegistry,\n KeepAlive,\n ),\n ),\n );\n const State = SessionState.Live.pipe(\n Layer.provideMerge(\n Layer.mergeAll(\n Store,\n Bus,\n Session,\n ReducerRegistry,\n SinkRegistry,\n KeepAlive,\n Compaction,\n PromptProjector,\n options.runSchedulerLayer ?? RunScheduler.Immediate,\n options.runSchedulingWakeupLayer ?? RunSchedulingWakeup.Unsupported,\n ),\n ),\n );\n const InferenceRunnerLayer = InferenceRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Models, Registry, Ids)),\n );\n const ToolExec = ToolExecutor.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(Factory, Registry, Ids, Session, Store)),\n );\n const Turn = TurnRunner.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(InferenceRunnerLayer, ToolExec, Factory, Ids)),\n );\n const StateWithRun = State.pipe(Layer.provideMerge(Layer.mergeAll(Turn, Factory, Ids)));\n const Query = EDASessionQuery.Live.pipe(\n Layer.provideMerge(Layer.mergeAll(StateWithRun, Store, Bus)),\n );\n\n return Layer.mergeAll(StateWithRun, Query, InferenceRunnerLayer, ToolExec, TestClock);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,YAAY,gBAAgB,KAAK,MAAiB;;AAG/D,MAAa,kBAAkB,WAAgC;CAC7D,+BAA+B;CAC/B,mBAAmB,OAAO,WAAW,KAAK;CAC1C,8BAA8B,OAAO,KAAK,IAAI;CAC9C,kBAAkB,OAAO,WAAW,OAAO,KAAK,IAAI,QAAU;CAC9D,gCA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AAsB,UAAU,SAAS,GAAG,CAAC,CACjF;CACA,MAAM,eAAe,MAAM,KAAK,MAAM,aAAa,MAAM,SAAS,MAAM,SAAS,GAAG,CAAC,CAAC;CACtF,MAAM,QAAQ,gBAAgB,KAAK,KACjC,MAAM,aAAa,MAAM,SAAS,cAAc,OAAO,GAAG,CAAC,CAC7D;CAEA,OAAO,MAAM,SAAS,cAAc,OAAO,sBAAsB,UAAU,SAAS;AACtF"}
@@ -2,9 +2,9 @@ import { SequenceNumber, SessionId, durablePosition } from "../types/core.js";
2
2
  import { makeEDATraceContext } from "../types/tracing.js";
3
3
  import { v as effectDurableAgentNamespace } from "../envelope-BCzKUq_z.js";
4
4
  import { Wn as decodeDurableEventSync } from "../durable-CD__3ztN.js";
5
+ import { m as makeTranscriptDefinition, p as emptyTranscriptMappings } from "../interpreter-BdRoYrfL.js";
5
6
  import { A as TranscriptRecordFromEnvelope } from "../records-DWKEjuqb.js";
6
- import { m as makeTranscriptDefinition, p as emptyTranscriptMappings } from "../interpreter-BYstFpr4.js";
7
- import { n as emptyTranscriptVersion, t as advanceTranscriptVersion } from "../in-memory-D8qQXNc5.js";
7
+ import { n as emptyTranscriptVersion, t as advanceTranscriptVersion } from "../in-memory-IgxnTbGb.js";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Schema from "effect/Schema";
10
10
  import * as Prompt from "effect/ai/Prompt";
@@ -4,6 +4,7 @@ import "./events-BWuvzVml.js";
4
4
  import { $ as TranscriptAssistantPart, A as TranscriptDefinition, At as TranscriptToolRecord, B as makeTranscriptDefinition, Bt as transcriptDecorationBufferLimit, C as TranscriptVersionMeta, Ct as TranscriptRecordView, D as TranscriptWindowSelector, Dt as TranscriptRunOutcome, E as TranscriptWindowLimits, Et as TranscriptRunMember, F as TranscriptMappingOperation, Ft as TranscriptVersion, G as DecorationBufferRecordId, H as AssistantRecordId, Ht as transcriptRecordId, I as TranscriptMappingTarget, It as UserRecordId, J as PendingTranscriptUserRecord, K as ImportAssistantRecordId, L as TranscriptMappings, Lt as isPendingTranscriptUserRecord, M as TranscriptListEntryKey, Mt as TranscriptUnknownRecord, N as TranscriptMappedEvent, Nt as TranscriptUserRecord, O as defaultTranscriptWindowLimits, Ot as TranscriptSessionContextRecord, P as TranscriptMapping, Pt as TranscriptUserState, Q as TranscriptAssistantLifecycle, R as TranscriptUserFallback, Rt as isTopLevelTranscriptRecord, S as TranscriptReadiness, St as TranscriptRecordKind, T as TranscriptWindow, Tt as TranscriptRunGroupRecord, U as CompactionRecordId, Ut as transcriptStoredInlineBodyLimit, V as transcriptMappingBounds, Vt as transcriptRecordEnvelopeFormat, W as ConsumedTranscriptUserRecord, X as SessionContextRecordId, Y as RunGroupRecordId, Z as ToolRecordId, _ as EDATranscriptStoreShape, _t as TranscriptPosition, at as TranscriptCompactionRecord, b as TranscriptActiveContent, bt as TranscriptRecordFromEnvelope, ct as TranscriptDecorationBufferRecord, dt as TranscriptDecorationKey, et as TranscriptAssistantRecord, ft as TranscriptDecorations, g as EDATranscriptStore, gt as TranscriptOrderKey, ht as TranscriptOrder, it as TranscriptClassification, j as TranscriptDefinitionError, jt as TranscriptTopLevelRecord, k as transcriptCursorOf, kt as TranscriptToolLifecycle, lt as TranscriptDecorationEntryId, mt as TranscriptLogIncarnation, nt as TranscriptBodySource, ot as TranscriptCursor, pt as TranscriptFieldPath, q as InferenceAssistantRecordId, rt as TranscriptBufferedDecoration, st as TranscriptDecoration, tt as TranscriptBody, ut as TranscriptDecorationEntryKey, v as TranscriptCursorMismatch, vt as TranscriptRecord, w as TranscriptVersionStatus, wt as TranscriptRecordViewFromEnvelope, x as TranscriptActivePart, xt as TranscriptRecordId, y as TranscriptMaintenanceConfig, yt as TranscriptRecordEnvelope, z as emptyTranscriptMappings, zt as runGroupStatus } from "./session-store-CWYZ29CV.js";
5
5
  import { a as PlanTranscriptBatch, c as TranscriptChangePlan, i as transcriptReadiness, l as TranscriptLookup, n as buildingTranscriptWindow, o as TranscriptAlias, r as readTranscriptWindowFrom, s as TranscriptAliasNamespace, t as TranscriptWindowSource, u as TranscriptProjectionError } from "./window-read-DBf1Iktt.js";
6
6
  import { a as TranscriptSubscriptionRead, c as defaultTranscriptSubscriptionPolicy, d as transcriptCoverageOf, f as transcriptSubscriptionBaseOf, i as TranscriptSubscriptionPolicy, l as planTranscriptUpdate, n as TranscriptRequestId, o as TranscriptSubscriptionRequest, r as TranscriptSubscriptionBase, s as TranscriptUpdate, t as TranscriptCoverage, u as readTranscriptSubscription } from "./subscription-DelB8L87.js";
7
+ import * as Schema from "effect/Schema";
7
8
  //#region src/transcript/interpreter.d.ts
8
9
  /**
9
10
  * Interpret one committed batch into a transcript change plan.
@@ -74,5 +75,27 @@ declare const foldTranscriptActiveContent: (state: TranscriptActiveContentState,
74
75
  /** The active content to serve, in the window's shape; empty when nothing is streaming. */
75
76
  declare const transcriptActiveContentOf: (state: TranscriptActiveContentState) => ReadonlyArray<TranscriptActiveContent>;
76
77
  //#endregion
77
- export { AssistantRecordId, CompactionRecordId, ConsumedTranscriptUserRecord, DecorationBufferRecordId, EDATranscriptStore, EDATranscriptStoreShape, ImportAssistantRecordId, InferenceAssistantRecordId, PendingTranscriptUserRecord, PlanTranscriptBatch, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActiveContentState, TranscriptActivePart, TranscriptAlias, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptChangePlan, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptLookup, TranscriptMaintenanceConfig, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptOrderKey, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordKind, TranscriptRecordView, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptSubscriptionPolicy, TranscriptSubscriptionRead, TranscriptSubscriptionRequest, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptTopLevelRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, type TranscriptWindowSource, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
78
+ //#region src/transcript/body.d.ts
79
+ /** The committed-event fields that decide where its bodies are. */
80
+ interface TranscriptBodyEvent {
81
+ readonly namespace: string;
82
+ readonly type: string;
83
+ readonly payload: unknown;
84
+ }
85
+ /** A resolved body: the JSON the interpreter inlined there, or why there is none. */
86
+ type ResolvedTranscriptBody = {
87
+ readonly _tag: "Found";
88
+ readonly value: Schema.Json;
89
+ } | {
90
+ readonly _tag: "Missing";
91
+ readonly message: string;
92
+ };
93
+ /**
94
+ * Resolve a body reference against the committed event it names: the read side of the
95
+ * interpreter's body rule. Resolving through the log keeps a `Ref` valid after projection rows are
96
+ * rebuilt or deleted; any path that is not a body site resolves to nothing.
97
+ */
98
+ declare const resolveTranscriptBody: (event: TranscriptBodyEvent, path: TranscriptFieldPath) => ResolvedTranscriptBody;
99
+ //#endregion
100
+ export { AssistantRecordId, CompactionRecordId, ConsumedTranscriptUserRecord, DecorationBufferRecordId, EDATranscriptStore, EDATranscriptStoreShape, ImportAssistantRecordId, InferenceAssistantRecordId, PendingTranscriptUserRecord, PlanTranscriptBatch, type ResolvedTranscriptBody, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActiveContentState, TranscriptActivePart, TranscriptAlias, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptChangePlan, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptLookup, TranscriptMaintenanceConfig, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptOrderKey, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordKind, TranscriptRecordView, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptSubscriptionPolicy, TranscriptSubscriptionRead, TranscriptSubscriptionRequest, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptTopLevelRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, type TranscriptWindowSource, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, resolveTranscriptBody, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
78
101
  //# sourceMappingURL=transcript.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import { SequenceNumber } from "./types/core.js";
2
2
  import { G as InferenceCompletedEvent, J as InferenceFailedEvent, X as InferenceStartedEvent, cn as TurnCompletedEvent, dn as TurnFailedEvent, hn as TurnStoppedEvent } from "./durable-CD__3ztN.js";
3
3
  import { ReasoningDeltaEvent, TextDeltaEvent, ToolParamsDeltaEvent, ToolParamsStartEvent } from "./types/events.js";
4
+ import { _ as computeTranscriptVersion, a as TranscriptDefinitionError, c as TranscriptMapping, d as TranscriptMappings, f as TranscriptUserFallback, g as canonicalJson, h as transcriptMappingBounds, i as TranscriptDefinition, l as TranscriptMappingOperation, m as makeTranscriptDefinition, n as TranscriptAliasNamespace, o as TranscriptListEntryKey, p as emptyTranscriptMappings, r as TranscriptProjectionError, s as TranscriptMappedEvent, t as planTranscriptBatch, u as TranscriptMappingTarget, v as transcriptSemanticRevision, y as resolveTranscriptBody } from "./interpreter-BdRoYrfL.js";
4
5
  import { A as TranscriptRecordFromEnvelope, B as TranscriptUserRecord, C as TranscriptDecorations, D as TranscriptPosition, E as TranscriptOrder, F as TranscriptRunOutcome, G as isTopLevelTranscriptRecord, H as TranscriptVersion, I as TranscriptSessionContextRecord, J as transcriptRecordEnvelopeFormat, K as runGroupStatus, L as TranscriptToolLifecycle, M as TranscriptRecordViewFromEnvelope, N as TranscriptRunGroupRecord, O as TranscriptRecord, P as TranscriptRunMember, R as TranscriptToolRecord, S as TranscriptDecorationKey, T as TranscriptLogIncarnation, U as UserRecordId, V as TranscriptUserState, W as isPendingTranscriptUserRecord, X as transcriptStoredInlineBodyLimit, Y as transcriptRecordId, _ as TranscriptCursor, a as InferenceAssistantRecordId, b as TranscriptDecorationEntryId, c as ToolRecordId, d as TranscriptAssistantRecord, f as TranscriptBody, g as TranscriptCompactionRecord, h as TranscriptClassification, i as ImportAssistantRecordId, j as TranscriptRecordId, k as TranscriptRecordEnvelope, l as TranscriptAssistantLifecycle, m as TranscriptBufferedDecoration, n as CompactionRecordId, o as RunGroupRecordId, p as TranscriptBodySource, q as transcriptDecorationBufferLimit, r as DecorationBufferRecordId, s as SessionContextRecordId, t as AssistantRecordId, u as TranscriptAssistantPart, v as TranscriptDecoration, w as TranscriptFieldPath, x as TranscriptDecorationEntryKey, y as TranscriptDecorationBufferRecord, z as TranscriptUnknownRecord } from "./records-DWKEjuqb.js";
5
- import { _ as computeTranscriptVersion, a as TranscriptDefinitionError, c as TranscriptMapping, d as TranscriptMappings, f as TranscriptUserFallback, g as canonicalJson, h as transcriptMappingBounds, i as TranscriptDefinition, l as TranscriptMappingOperation, m as makeTranscriptDefinition, n as TranscriptAliasNamespace, o as TranscriptListEntryKey, p as emptyTranscriptMappings, r as TranscriptProjectionError, s as TranscriptMappedEvent, t as planTranscriptBatch, u as TranscriptMappingTarget, v as transcriptSemanticRevision } from "./interpreter-BYstFpr4.js";
6
6
  import { a as TranscriptCursorMismatch, i as EDATranscriptStore, n as readTranscriptWindowFrom, r as transcriptReadiness, t as buildingTranscriptWindow } from "./window-read-U55aAeuz.js";
7
- import { _ as TranscriptWindowSelector, a as defaultTranscriptSubscriptionPolicy, c as transcriptCoverageOf, d as TranscriptActivePart, f as TranscriptReadiness, g as TranscriptWindowLimits, h as TranscriptWindow, i as TranscriptUpdate, l as transcriptSubscriptionBaseOf, m as TranscriptVersionStatus, n as TranscriptRequestId, o as planTranscriptUpdate, p as TranscriptVersionMeta, r as TranscriptSubscriptionBase, s as readTranscriptSubscription, t as TranscriptCoverage, u as TranscriptActiveContent, v as defaultTranscriptWindowLimits, y as transcriptCursorOf } from "./subscription-g5W0Ggqx.js";
7
+ import { _ as TranscriptWindowSelector, a as defaultTranscriptSubscriptionPolicy, c as transcriptCoverageOf, d as TranscriptActivePart, f as TranscriptReadiness, g as TranscriptWindowLimits, h as TranscriptWindow, i as TranscriptUpdate, l as transcriptSubscriptionBaseOf, m as TranscriptVersionStatus, n as TranscriptRequestId, o as planTranscriptUpdate, p as TranscriptVersionMeta, r as TranscriptSubscriptionBase, s as readTranscriptSubscription, t as TranscriptCoverage, u as TranscriptActiveContent, v as defaultTranscriptWindowLimits, y as transcriptCursorOf } from "./subscription-Dzr5LqPX.js";
8
8
  import * as Schema from "effect/Schema";
9
9
  //#region src/transcript/active-content.ts
10
10
  /** The accumulator before anything is published in this isolate. */
@@ -102,6 +102,6 @@ const transcriptActiveContentOf = (state) => state.inference === void 0 ? [] : [
102
102
  parts: state.inference.parts
103
103
  }];
104
104
  //#endregion
105
- export { AssistantRecordId, CompactionRecordId, DecorationBufferRecordId, EDATranscriptStore, ImportAssistantRecordId, InferenceAssistantRecordId, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActivePart, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
105
+ export { AssistantRecordId, CompactionRecordId, DecorationBufferRecordId, EDATranscriptStore, ImportAssistantRecordId, InferenceAssistantRecordId, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActivePart, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, resolveTranscriptBody, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
106
106
 
107
107
  //# sourceMappingURL=transcript.js.map
@@ -0,0 +1,2 @@
1
+ import { $ as EDAWebSocketWireProtocol, A as EDA_WS_CLOSE_LAGGED, B as EDAFrameworkWebSocketEvent, C as EDAWebSocketHelloFrame, D as EDAWebSocketServerFrame, E as EDAWebSocketPongFrame, F as SubscriberId, G as EDAWebSocketWireClientFrame, H as EDAWebSocketServerFrameEncoder, I as decodeEDAWebSocketClientMessage, J as EDAWebSocketWireHeartbeatFrame, K as EDAWebSocketWireErrorFrame, L as defaultEDAWebSocketFlowControl, M as EDA_WS_CLOSE_SEND_FAILED, N as EDA_WS_CLOSE_UNSUPPORTED_DATA, O as EDA_WEB_SOCKET_PROTOCOL_VERSION, P as FrameId, Q as EDAWebSocketWirePongFrame, R as encodeEDAWebSocketServerFrame, S as EDAWebSocketHeartbeatFrame, T as EDAWebSocketPingFrame, U as EDAWebSocketServerFrameInput, V as EDAWebSocketEventConsumerPolicy, W as EDAWebSocketWireAckFrame, X as EDAWebSocketWireLaggedFrame, Y as EDAWebSocketWireHelloFrame, Z as EDAWebSocketWirePingFrame, _ as EDAWebSocketAckFrame, a as EDAWebSocketInFlightFrame, b as EDAWebSocketEventsFrame, c as SubscriberLagReason, d as makeWebSocketDeliveryState, et as EDA_WEB_SOCKET_PING_MESSAGE, f as onClientAck, g as restoreWebSocketDeliveryState, h as onHostSuppressedFrame, i as EDAWebSocketDeliveryState, it as makeEDAWebSocketWireProtocol, j as EDA_WS_CLOSE_PROTOCOL_ERROR, k as EDA_WS_CLOSE_GOING_AWAY, l as checkpointWebSocketDeliveryState, m as onEphemeralEvent, n as EDAWebSocketDeliveryCheckpoint, nt as EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, o as EDAWebSocketSuppressedRange, p as onDurableEvents, q as EDAWebSocketWireFlowControl, r as EDAWebSocketDeliveryResult, rt as edaFrameworkWebSocketWireProtocol, s as MakeDeliveryStateInput, t as EDAWebSocketDeliveryAction, tt as EDA_WEB_SOCKET_PONG_MESSAGE, u as deliveryHelloFrame, v as EDAWebSocketClientFrame, w as EDAWebSocketLaggedFrame, x as EDAWebSocketFlowControl, y as EDAWebSocketErrorFrame, z as laggedCloseReason } from "../delivery-o6sDIiwO.js";
2
+ export { EDAFrameworkWebSocketEvent, EDAWebSocketAckFrame, EDAWebSocketClientFrame, EDAWebSocketDeliveryAction, EDAWebSocketDeliveryCheckpoint, EDAWebSocketDeliveryResult, EDAWebSocketDeliveryState, EDAWebSocketErrorFrame, EDAWebSocketEventConsumerPolicy, EDAWebSocketEventsFrame, EDAWebSocketFlowControl, EDAWebSocketHeartbeatFrame, EDAWebSocketHelloFrame, EDAWebSocketInFlightFrame, EDAWebSocketLaggedFrame, EDAWebSocketPingFrame, EDAWebSocketPongFrame, EDAWebSocketServerFrame, EDAWebSocketServerFrameEncoder, EDAWebSocketServerFrameInput, EDAWebSocketSuppressedRange, EDAWebSocketWireAckFrame, EDAWebSocketWireClientFrame, EDAWebSocketWireErrorFrame, EDAWebSocketWireFlowControl, EDAWebSocketWireHeartbeatFrame, EDAWebSocketWireHelloFrame, EDAWebSocketWireLaggedFrame, EDAWebSocketWirePingFrame, EDAWebSocketWirePongFrame, EDAWebSocketWireProtocol, EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE, EDA_WEB_SOCKET_PROTOCOL_VERSION, EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, EDA_WS_CLOSE_GOING_AWAY, EDA_WS_CLOSE_LAGGED, EDA_WS_CLOSE_PROTOCOL_ERROR, EDA_WS_CLOSE_SEND_FAILED, EDA_WS_CLOSE_UNSUPPORTED_DATA, FrameId, MakeDeliveryStateInput, SubscriberId, SubscriberLagReason, checkpointWebSocketDeliveryState, decodeEDAWebSocketClientMessage, defaultEDAWebSocketFlowControl, deliveryHelloFrame, edaFrameworkWebSocketWireProtocol, encodeEDAWebSocketServerFrame, laggedCloseReason, makeEDAWebSocketWireProtocol, makeWebSocketDeliveryState, onClientAck, onDurableEvents, onEphemeralEvent, onHostSuppressedFrame, restoreWebSocketDeliveryState };
@@ -0,0 +1,2 @@
1
+ import { A as FrameId, B as EDAWebSocketWireFlowControl, C as EDAWebSocketServerFrame, D as EDA_WS_CLOSE_PROTOCOL_ERROR, E as EDA_WS_CLOSE_LAGGED, F as laggedCloseReason, G as EDAWebSocketWirePongFrame, H as EDAWebSocketWireHelloFrame, I as EDAFrameworkWebSocketEvent, J as EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, K as EDA_WEB_SOCKET_PING_MESSAGE, L as EDAWebSocketWireAckFrame, M as decodeEDAWebSocketClientMessage, N as defaultEDAWebSocketFlowControl, O as EDA_WS_CLOSE_SEND_FAILED, P as encodeEDAWebSocketServerFrame, R as EDAWebSocketWireClientFrame, S as EDAWebSocketPongFrame, T as EDA_WS_CLOSE_GOING_AWAY, U as EDAWebSocketWireLaggedFrame, V as EDAWebSocketWireHeartbeatFrame, W as EDAWebSocketWirePingFrame, X as makeEDAWebSocketWireProtocol, Y as edaFrameworkWebSocketWireProtocol, _ as EDAWebSocketFlowControl, a as checkpointWebSocketDeliveryState, b as EDAWebSocketLaggedFrame, c as onClientAck, d as onHostSuppressedFrame, f as restoreWebSocketDeliveryState, g as EDAWebSocketEventsFrame, h as EDAWebSocketErrorFrame, i as SubscriberLagReason, j as SubscriberId, k as EDA_WS_CLOSE_UNSUPPORTED_DATA, l as onDurableEvents, m as EDAWebSocketClientFrame, n as EDAWebSocketInFlightFrame, o as deliveryHelloFrame, p as EDAWebSocketAckFrame, q as EDA_WEB_SOCKET_PONG_MESSAGE, r as EDAWebSocketSuppressedRange, s as makeWebSocketDeliveryState, t as EDAWebSocketDeliveryCheckpoint, u as onEphemeralEvent, v as EDAWebSocketHeartbeatFrame, w as EDA_WEB_SOCKET_PROTOCOL_VERSION, x as EDAWebSocketPingFrame, y as EDAWebSocketHelloFrame, z as EDAWebSocketWireErrorFrame } from "../delivery-Bb7pkQ9o.js";
2
+ export { EDAFrameworkWebSocketEvent, EDAWebSocketAckFrame, EDAWebSocketClientFrame, EDAWebSocketDeliveryCheckpoint, EDAWebSocketErrorFrame, EDAWebSocketEventsFrame, EDAWebSocketFlowControl, EDAWebSocketHeartbeatFrame, EDAWebSocketHelloFrame, EDAWebSocketInFlightFrame, EDAWebSocketLaggedFrame, EDAWebSocketPingFrame, EDAWebSocketPongFrame, EDAWebSocketServerFrame, EDAWebSocketSuppressedRange, EDAWebSocketWireAckFrame, EDAWebSocketWireClientFrame, EDAWebSocketWireErrorFrame, EDAWebSocketWireFlowControl, EDAWebSocketWireHeartbeatFrame, EDAWebSocketWireHelloFrame, EDAWebSocketWireLaggedFrame, EDAWebSocketWirePingFrame, EDAWebSocketWirePongFrame, EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE, EDA_WEB_SOCKET_PROTOCOL_VERSION, EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, EDA_WS_CLOSE_GOING_AWAY, EDA_WS_CLOSE_LAGGED, EDA_WS_CLOSE_PROTOCOL_ERROR, EDA_WS_CLOSE_SEND_FAILED, EDA_WS_CLOSE_UNSUPPORTED_DATA, FrameId, SubscriberId, SubscriberLagReason, checkpointWebSocketDeliveryState, decodeEDAWebSocketClientMessage, defaultEDAWebSocketFlowControl, deliveryHelloFrame, edaFrameworkWebSocketWireProtocol, encodeEDAWebSocketServerFrame, laggedCloseReason, makeEDAWebSocketWireProtocol, makeWebSocketDeliveryState, onClientAck, onDurableEvents, onEphemeralEvent, onHostSuppressedFrame, restoreWebSocketDeliveryState };