effect-durable-agent 0.1.0-alpha.21 → 0.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/assert-never-CoyUpoRB.js +18 -0
- package/dist/assert-never-CoyUpoRB.js.map +1 -0
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/reduced-state.d.ts +1 -1
- package/dist/domain/reduced-state.js +927 -2
- package/dist/domain/reduced-state.js.map +1 -0
- package/dist/domain/run-scheduling.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{reduced-state-BGd_yCBT.d.ts → reduced-state-PJdig48e.d.ts} +4171 -4171
- package/dist/{reducer-registry-BIhncOHH.d.ts → reducer-registry-BAbhZs6d.d.ts} +2 -2
- package/dist/{run-scheduling-wakeup-BH2pHE0U.d.ts → run-scheduling-wakeup-QLK87OqG.d.ts} +2 -2
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/model-call.d.ts +1 -1
- package/dist/services/prompt-projector.d.ts +1 -1
- package/dist/services/reducer-registry.d.ts +1 -1
- package/dist/services/reducer-registry.js +1 -1
- package/dist/services/run-scheduler.d.ts +1 -1
- package/dist/services/run-scheduling-wakeup.d.ts +1 -1
- package/dist/services/runtime-layer.d.ts +6 -6
- package/dist/services/runtime-layer.js +3 -3
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +1 -1
- package/dist/services/session-query.d.ts +1 -1
- package/dist/services/session-query.js +2 -2
- package/dist/services/session-state.d.ts +1 -1
- package/dist/services/session-state.js +1 -1
- package/dist/services/session-store.d.ts +2 -2
- package/dist/services/session-store.js +1 -251
- package/dist/services/sink-checkpoint-store.d.ts +1 -1
- package/dist/services/sink-registry.d.ts +1 -1
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/{session-state-C_1XxhvE.js → session-state-StlO5B2N.js} +5 -4
- package/dist/{session-state-C_1XxhvE.js.map → session-state-StlO5B2N.js.map} +1 -1
- package/dist/session-store-ByDjS03N.d.ts +3184 -0
- package/dist/session-store-DcJjs4Fd.js +413 -0
- package/dist/session-store-DcJjs4Fd.js.map +1 -0
- package/dist/{sink-checkpoint-store-C-SY0cG2.d.ts → sink-checkpoint-store-BHb8YRTw.d.ts} +2 -2
- package/dist/{sink-registry-CjK5MC90.js → sink-registry-DEneTH8u.js} +3 -3
- package/dist/{sink-registry-CjK5MC90.js.map → sink-registry-DEneTH8u.js.map} +1 -1
- package/dist/testkit/layers.d.ts +6 -6
- package/dist/testkit/layers.js +3 -3
- package/dist/{tool-registry-wPsHagF_.d.ts → tool-registry-CxZ0iuYb.d.ts} +2 -2
- package/dist/transcript.d.ts +137 -0
- package/dist/transcript.js +178 -0
- package/dist/transcript.js.map +1 -0
- package/dist/websocket.d.ts +1 -1
- package/dist/window-read-B8aF_hDq.js +2173 -0
- package/dist/window-read-B8aF_hDq.js.map +1 -0
- package/package.json +5 -1
- package/dist/reduced-state-Vuud6LCM.js +0 -942
- package/dist/reduced-state-Vuud6LCM.js.map +0 -1
- package/dist/services/session-store.js.map +0 -1
- package/dist/session-store-BpitF4Wg.d.ts +0 -191
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink-registry-CjK5MC90.js","names":[],"sources":["../src/services/sink-inbox.ts","../src/services/sink-registry.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as Queue from \"effect/Queue\";\nimport * as Schema from \"effect/Schema\";\n\nimport { SequenceNumber } from \"../types/core\";\nimport type { PositionedEvent } from \"../types/events\";\n\n/** Durable payloads stay in the log; only bounded best-effort ephemeral work is retained. */\nconst ephemeralCapacity = 128;\nconst ephemeralByteCapacity = 256 * 1024;\n\n/** An ephemeral update could not be measured as a JSON wire value. */\nexport class SinkEphemeralEncodingError extends Schema.TaggedError<SinkEphemeralEncodingError>()(\n \"SinkEphemeralEncodingError\",\n { cause: Schema.Defect() },\n) {}\n\n/** One ordered step on a sink's serialized delivery lane. */\ntype SinkWork =\n | { readonly _tag: \"Durable\"; readonly throughSeq: SequenceNumber }\n | { readonly _tag: \"Ephemeral\"; readonly event: PositionedEvent };\n\n/**\n * Coalesces durable heads without losing ephemeral ordering barriers. Publication never\n * waits for delivery. Overflow drops the newest ephemeral update, never durable work.\n */\nexport const makeSinkInbox = Effect.fnUntraced(function* (initialHead: SequenceNumber) {\n const wake = yield* Effect.acquireRelease(Queue.sliding<void>(1), Queue.shutdown);\n let head = initialHead;\n const pending: Array<{ readonly event: PositionedEvent; readonly bytes: number }> = [];\n let pendingBytes = 0;\n\n const notify = (throughSeq: SequenceNumber) =>\n Effect.sync(() => {\n head = SequenceNumber.make(Math.max(head, throughSeq));\n Queue.offerUnsafe(wake, undefined);\n });\n\n const offerEphemeral = (event: PositionedEvent) =>\n Effect.try({\n try: () => {\n const bytes = new TextEncoder().encode(JSON.stringify(event)).byteLength;\n if (pending.length >= ephemeralCapacity || bytes > ephemeralByteCapacity - pendingBytes) {\n return false;\n }\n pending.push({ event, bytes });\n pendingBytes += bytes;\n Queue.offerUnsafe(wake, undefined);\n return true;\n },\n catch: (cause) => new SinkEphemeralEncodingError({ cause }),\n });\n\n const poll = (cursor: SequenceNumber): Effect.Effect<SinkWork | undefined> =>\n Effect.sync(() => {\n while (pending.length > 0) {\n const first = pending[0];\n if (first === undefined) break;\n if (first.event.position.seq > cursor) {\n return { _tag: \"Durable\", throughSeq: first.event.position.seq };\n }\n pending.shift();\n pendingBytes -= first.bytes;\n if (first.event.position.seq === cursor) {\n return { _tag: \"Ephemeral\", event: first.event };\n }\n }\n return cursor < head ? { _tag: \"Durable\", throughSeq: head } : undefined;\n });\n\n return { notify, offerEphemeral, poll, awaitWork: Queue.take(wake) };\n});\n","import * as Cause from \"effect/Cause\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport { type DecodedDurableEvent } from \"../types/events/durable\";\nimport { selectCommittedEvent } from \"./session-store\";\nimport * as Scope from \"effect/Scope\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport * as Stream from \"effect/Stream\";\nimport * as SynchronizedRef from \"effect/SynchronizedRef\";\n\nimport { foldReducedState, initialReducedState, type ReducedState } from \"../domain/reduced-state\";\nimport { EDAReducerRegistry, type EDAReducerStateSnapshot } from \"./reducer-registry\";\nimport { EventId, SessionId, SequenceNumber } from \"../types/core\";\nimport type {\n DurableEventEnvelope,\n EphemeralEventEnvelope,\n PositionedEvent,\n} from \"../types/events\";\nimport type { EDASessionStoreShape } from \"./session-store\";\nimport { type CommittedDurableEvent, EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { EventFactory } from \"./event-factory\";\nimport type { EventFactoryShape } from \"./event-factory\";\nimport { IdGenerator } from \"./id-generator\";\nimport { EDAKeepAlive } from \"./keep-alive\";\nimport { makeSinkInbox } from \"./sink-inbox\";\nimport { SessionContext } from \"./session-context\";\nimport {\n EDASinkName,\n SinkCheckpointStore,\n type SinkCheckpointStoreShape,\n type StoredSinkCheckpoint,\n} from \"./sink-checkpoint-store\";\nimport { annotateEdaSpan } from \"./tracing\";\n\n/** Cursor-window input delivered to one durable sink drain. */\nexport interface EDASinkRawDurableBatch<E = DecodedDurableEvent> {\n /** All durable events replayed for this cursor window, including uninterested events. */\n readonly allEvents: ReadonlyArray<CommittedDurableEvent>;\n /** Events matching the sink's durable interests. */\n readonly events: ReadonlyArray<CommittedDurableEvent<E>>;\n /** Durable sequence through which the sink may advance after success. */\n readonly throughSeq: SequenceNumber;\n}\n\n/** Cursor window with framework and app projections, enabled by default. */\nexport interface EDASinkDurableBatch<E = DecodedDurableEvent> extends EDASinkRawDurableBatch<E> {\n /** Authoritative reduced state folded exactly through `throughSeq`. */\n readonly stateAfter: ReducedState;\n /** App-specific durable reducer states folded exactly through `throughSeq`. */\n readonly reducerStates: EDAReducerStateSnapshot;\n}\n\n/** Typed, sink-owned durable state stored independently from cursor advancement. */\nexport interface EDASinkCheckpoint {\n /** Decode current durable state, or return `initial` for a new or legacy cursor row. */\n readonly get: <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n initial: State,\n ) => Effect.Effect<State, EDASessionStoreError>;\n /** Validate, encode, and durably save state without advancing the sink cursor. */\n readonly save: <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n state: State,\n ) => Effect.Effect<void, EDASessionStoreError>;\n}\n\n/** Capabilities exposed to sink processors without granting raw store or bus access. */\nexport interface EDASinkContext {\n readonly sessionId: SessionId;\n /** Sink-owned checkpoint state, serialized with cursor commits and background writes. */\n readonly checkpoint: EDASinkCheckpoint;\n /** Build a framework durable event if the sink needs to emit one. */\n readonly events: EventFactoryShape;\n /** Mint an app durable event id for staged custom events. */\n readonly makeEventId: () => Effect.Effect<EventId>;\n /** Publish a best-effort live-only event. */\n readonly emitEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>;\n /** Stage durable events; the runner commits them after the sink succeeds. */\n readonly stageDurable: (event: DurableEventEnvelope) => Effect.Effect<void>;\n /** Fork background sink work into the session scope. */\n readonly forkScoped: (effect: Effect.Effect<unknown, unknown>) => Effect.Effect<void>;\n}\n\n/** `\"*\"` and omission select every fact; a schema selects and narrows matching envelopes. */\nexport type EDASinkInterests = \"*\" | Schema.Codec<DurableEventEnvelope, unknown, never, never>;\n\n/** Delivery policy shared by raw and projected durable consumers. */\ninterface EDADurableSinkOptions {\n readonly interests?: EDASinkInterests;\n readonly batchSize?: number;\n}\n\n/** Default durable consumer with framework and app projections at each cursor window. */\nexport interface EDAProjectedDurableSinkDefinition extends EDADurableSinkOptions {\n readonly process: (batch: EDASinkDurableBatch, ctx: EDASinkContext) => Effect.Effect<void, never>;\n}\n\n/** Raw consumer that never hydrates, folds, or retains a session projection. */\nexport interface EDARawDurableSinkDefinition extends EDADurableSinkOptions {\n readonly process: (\n batch: EDASinkRawDurableBatch,\n ctx: EDASinkContext,\n ) => Effect.Effect<void, never>;\n}\n\n/** Durable sink definition backed by a checkpoint and an app-owned delivery policy. */\nexport type EDADurableSinkDefinition = EDAProjectedDurableSinkDefinition;\n\n/** Best-effort live-only sink definition. */\nexport interface EDAEphemeralSinkDefinition {\n readonly interests?:\n | \"*\"\n | Schema.Codec<import(\"../types/events\").EventEnvelope, unknown, never, never>;\n readonly process: (event: PositionedEvent, ctx: EDASinkContext) => Effect.Effect<void, never>;\n}\n\n/**\n * Named app integration hook with optional durable and ephemeral filters.\n *\n * Every sink runs on one serialized position-ordered lane. Sinks own retry and\n * terminal failure handling, so callbacks must have an infallible typed error\n * channel. An unexpected defect is logged and skipped before the durable checkpoint\n * advances. Ephemeral callbacks are best-effort and are only processed after the\n * durable prefix at their anchor sequence has been projected.\n */\ninterface EDASinkOptions {\n readonly name: string;\n readonly ephemeral?: EDAEphemeralSinkDefinition;\n}\n\n/** Existing consumers receive framework and app projections unless explicitly opted out. */\nexport interface EDAProjectedSink extends EDASinkOptions {\n readonly state?: \"projected\";\n readonly durable?: EDAProjectedDurableSinkDefinition;\n}\n\n/** Raw consumers retain only their cursor and sink-owned checkpoint payload. */\nexport interface EDARawSink extends EDASinkOptions {\n readonly state: \"none\";\n readonly durable?: EDARawDurableSinkDefinition;\n}\n\n/** The outer discriminant preserves contextual callback typing for inline default sinks. */\nexport type EDASink = EDAProjectedSink | EDARawSink;\n\n/** Projected and raw overloads preserve contextual callback inference and literal names. */\nfunction makeSink<const Sink extends EDAProjectedSink>(sink: Sink): Sink;\nfunction makeSink<const Sink extends EDARawSink>(sink: Sink): Sink;\nfunction makeSink<const Sink extends EDASink>(sink: Sink): Sink;\nfunction makeSink(sink: EDASink): EDASink {\n return sink;\n}\n\n/** Convenience constructor preserving a sink's literal name/type information. */\nexport const EDASink = {\n make: makeSink,\n /** The live-event schema owns both subscription filtering and callback typing. */\n forEphemeralEvents: <E extends import(\"../types/events\").EventEnvelope>(\n interests: Schema.Codec<E, unknown, never, never>,\n process: (event: PositionedEvent<E>, ctx: EDASinkContext) => Effect.Effect<void, never>,\n ): EDAEphemeralSinkDefinition => ({\n interests,\n process: (entry, ctx) =>\n Schema.is(interests)(entry.event)\n ? process({ position: entry.position, event: entry.event }, ctx)\n : Effect.void,\n }),\n /** One schema selects and narrows the facts delivered to a projected durable consumer. */\n forEvents: <E extends DurableEventEnvelope>(\n interests: Schema.Codec<E, unknown, never, never>,\n sink: Omit<EDAProjectedSink, \"durable\"> & {\n readonly durable: {\n readonly batchSize?: number;\n readonly process: (\n batch: EDASinkDurableBatch<E>,\n ctx: EDASinkContext,\n ) => Effect.Effect<void, never>;\n };\n },\n ): EDAProjectedSink => ({\n ...sink,\n durable: {\n ...sink.durable,\n interests,\n process: (batch, ctx) =>\n sink.durable.process(\n {\n ...batch,\n events: batch.events.flatMap((entry) => {\n const selected = selectCommittedEvent(interests, entry);\n return selected === undefined ? [] : [selected];\n }),\n },\n ctx,\n ),\n },\n }),\n};\n\n/** Session-owned capabilities needed to start all registered sink runners. */\nexport interface EDASinkRunnerStartInput {\n readonly appendDurableBatch: (\n events: ReadonlyArray<DurableEventEnvelope>,\n ) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;\n /** Immutable framework and app projections at one common durable head. */\n readonly initialProjection: {\n readonly reduced: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n };\n readonly publishEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>;\n readonly scope: Scope.Scope;\n}\n\n/** Registry service coordinating durable checkpoints and live sink delivery. */\nexport interface EDASinkRegistryShape {\n readonly sinks: ReadonlyArray<EDASink>;\n /** Start long-lived sink runners. Safe to call once during session-state acquisition. */\n readonly startSinkRunners: (\n input: EDASinkRunnerStartInput,\n ) => Effect.Effect<void, EDASessionStoreError>;\n /** Coalesced non-blocking nudge that the durable log head advanced. */\n readonly notifyDurableHeadAdvanced: (head: SequenceNumber) => Effect.Effect<void>;\n /** Best-effort non-blocking delivery to ephemeral sink workers. */\n readonly publishEphemeralToSinks: (event: PositionedEvent) => Effect.Effect<void>;\n}\n\n/** Registry and runner for app-provided EDA sinks. */\nexport class EDASinkRegistry extends Context.Service<EDASinkRegistry, EDASinkRegistryShape>()(\n \"@effect-durable-agent/EDASinkRegistry\",\n) {\n static readonly Empty = Layer.succeed(EDASinkRegistry, {\n sinks: [],\n startSinkRunners: () => Effect.void,\n notifyDurableHeadAdvanced: () => Effect.void,\n publishEphemeralToSinks: () => Effect.void,\n } satisfies EDASinkRegistryShape);\n\n static readonly Live = (sinks: ReadonlyArray<EDASink>) =>\n Layer.effect(EDASinkRegistry, makeSinkRegistry(sinks));\n}\n\nconst defaultBatchSize = 100;\nconst sinkCheckpointFormatVersion = 1;\n\ninterface SinkProjection {\n readonly reduced: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n}\n\ninterface SerializedSinkState {\n readonly formatVersion: typeof sinkCheckpointFormatVersion;\n readonly state: unknown;\n readonly updatedAtMs: number;\n}\n\nconst makeSinkRegistry = (sinks: ReadonlyArray<EDASink>) =>\n Effect.gen(function* () {\n const session = yield* SessionContext;\n const store = yield* EDASessionStore;\n const checkpointStore = yield* SinkCheckpointStore;\n const eventFactory = yield* EventFactory;\n const ids = yield* IdGenerator;\n const reducerRegistry = yield* EDAReducerRegistry;\n const keepAlive = yield* EDAKeepAlive;\n const started = yield* Ref.make(false);\n const hydrationGate = yield* Semaphore.make(1);\n const deliveries: Array<{\n readonly sink: EDASink;\n readonly inbox: Effect.Success<ReturnType<typeof makeSinkInbox>>;\n }> = [];\n\n const baseContext = (\n staged: Array<DurableEventEnvelope>,\n publishEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>,\n scope: Scope.Scope,\n checkpoint: EDASinkCheckpoint,\n ): EDASinkContext => ({\n sessionId: session.sessionId,\n checkpoint,\n events: eventFactory,\n makeEventId: ids.makeEventId,\n emitEphemeral: publishEphemeral,\n stageDurable: (event) => Effect.sync(() => staged.push(event)),\n forkScoped: (effect) => effect.pipe(Effect.forkIn(scope), Effect.asVoid),\n });\n\n const makeSinkRunner = Effect.fnUntraced(function* (\n sink: EDASink,\n { initialProjection, appendDurableBatch, publishEphemeral, scope }: EDASinkRunnerStartInput,\n ) {\n // Long-lived fibers capture the head and capabilities, not the initial projection.\n const initialHead = initialProjection.reduced.lastSeq;\n const sinkName = EDASinkName.make(sink.name);\n const storedCheckpoint = yield* checkpointStore.load(sinkName);\n const checkpointRef = yield* SynchronizedRef.make(storedCheckpoint);\n const checkpoint = makeSinkCheckpoint(checkpointStore, sinkName, checkpointRef);\n const cursor = storedCheckpoint.afterSeq;\n const cursorRef = yield* Ref.make(cursor);\n if (cursor > initialHead) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} cursor exceeds session head`,\n });\n }\n // Keep only an exact projection seed; lagging workers reconstruct in their own scope.\n const state = yield* Ref.make<SinkProjection | undefined>(\n sink.state === \"none\"\n ? undefined\n : cursor === initialHead\n ? {\n reduced: initialProjection.reduced,\n reducerStates: initialProjection.reducerStates,\n }\n : cursor === 0\n ? { reduced: initialReducedState, reducerStates: reducerRegistry.initial }\n : undefined,\n );\n const inbox = yield* makeSinkInbox(initialHead).pipe(Scope.provide(scope));\n deliveries.push({ sink, inbox });\n const ensureProjection = Effect.fnUntraced(function* () {\n const existing = yield* Ref.get(state);\n if (existing !== undefined) return existing;\n const hydrated = yield* store.eventsAfter(SequenceNumber.make(0)).pipe(\n Stream.takeWhile((event) => event.position.seq <= cursor),\n Stream.chunks,\n Stream.runFold(\n (): SinkProjection => ({\n reduced: initialReducedState,\n reducerStates: reducerRegistry.initial,\n }),\n (current, page): SinkProjection => ({\n reduced: foldReducedState(current.reduced, page),\n reducerStates: reducerRegistry.reduce(current.reducerStates, page),\n }),\n ),\n Effect.withSpan(\"agent.sink.hydrate\", {\n attributes: {\n \"eda.sink.name\": sink.name,\n \"eda.session.id\": session.sessionId,\n \"eda.seq.through\": cursor,\n },\n }),\n hydrationGate.withPermits(1),\n );\n if (hydrated.reduced.lastSeq !== cursor) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} could not reconstruct its cursor`,\n });\n }\n yield* Ref.set(state, hydrated);\n return hydrated;\n });\n\n const processDurableBatch = Effect.fnUntraced(function* (\n allEvents: ReadonlyArray<CommittedDurableEvent>,\n ) {\n if (allEvents.length === 0) {\n return;\n }\n\n const currentCursor = yield* Ref.get(cursorRef);\n const fresh = allEvents.filter((entry) => entry.position.seq > currentCursor);\n if (fresh.length === 0) {\n return;\n }\n\n const durable = sink.durable;\n const last = fresh.at(-1);\n if (last === undefined) return;\n const throughSeq = last.position.seq;\n const nextProjection =\n sink.state === \"none\"\n ? undefined\n : yield* Effect.gen(function* () {\n const current = yield* ensureProjection();\n return {\n reduced: foldReducedState(current.reduced, fresh),\n reducerStates: reducerRegistry.reduce(current.reducerStates, fresh),\n };\n });\n const eventsForSink =\n durable === undefined ? [] : filterInterested(fresh, durable.interests);\n\n if (durable !== undefined && eventsForSink.length > 0) {\n yield* Effect.gen(function* () {\n const staged: Array<DurableEventEnvelope> = [];\n const rawBatch: EDASinkRawDurableBatch = {\n allEvents: fresh,\n events: eventsForSink,\n throughSeq,\n };\n const context = baseContext(staged, publishEphemeral, scope, checkpoint);\n const delivery = Effect.gen(function* () {\n if (sink.durable === undefined) return;\n if (sink.state === \"none\") return yield* sink.durable.process(rawBatch, context);\n // The projected branch owns both construction and delivery of these fields.\n if (nextProjection === undefined)\n return yield* Effect.die(\"Projected sink missing its projection\");\n return yield* sink.durable.process(\n {\n ...rawBatch,\n stateAfter: nextProjection.reduced,\n reducerStates: nextProjection.reducerStates,\n },\n context,\n );\n });\n const completed = yield* delivery.pipe(\n Effect.as(true),\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA durable sink violated its infallible contract\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }).pipe(Effect.as(false)),\n ),\n );\n if (completed && staged.length > 0) {\n yield* annotateEdaSpan({ \"eda.sink.staged_events\": staged.length });\n yield* appendDurableBatch(staged);\n }\n }).pipe(\n Effect.withSpan(\"agent.sink.drain\", {\n attributes: {\n \"eda.sink.name\": sink.name,\n \"eda.sink.cursor.before\": currentCursor,\n \"eda.sink.events.read\": fresh.length,\n \"eda.sink.events.interested\": eventsForSink.length,\n \"eda.sink.cursor.after\": throughSeq,\n },\n }),\n );\n }\n\n yield* commitSinkCheckpoint(checkpointStore, sinkName, checkpointRef, throughSeq);\n yield* Ref.set(cursorRef, throughSeq);\n yield* Ref.set(state, nextProjection);\n });\n\n const drainDurablesThrough = Effect.fnUntraced(function* (targetHead: SequenceNumber) {\n const currentCursor = yield* Ref.get(cursorRef);\n if (currentCursor >= targetHead) return;\n const allEvents = yield* readCursorBatchThrough(\n store,\n currentCursor,\n targetHead,\n sink.durable?.batchSize,\n );\n if (allEvents.length === 0) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} could not read its durable backlog`,\n });\n }\n yield* processDurableBatch(allEvents);\n });\n\n const processEphemeral = Effect.fnUntraced(function* (event: PositionedEvent) {\n if (sink.ephemeral === undefined) return;\n if (sink.state !== \"none\") yield* ensureProjection();\n yield* sink.ephemeral\n .process(event, baseContext([], publishEphemeral, scope, checkpoint))\n .pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA sink ephemeral projection failed\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }),\n ),\n );\n });\n\n const runLoop = Effect.forever(\n Effect.gen(function* () {\n const currentCursor = yield* Ref.get(cursorRef);\n const work = yield* inbox.poll(currentCursor);\n if (work === undefined) {\n yield* inbox.awaitWork;\n return;\n }\n yield* keepAlive.withActiveWork(\n `sink:${sink.name}`,\n work._tag === \"Durable\"\n ? drainDurablesThrough(work.throughSeq)\n : processEphemeral(work.event),\n );\n yield* Effect.yieldNow;\n }),\n ).pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA sink runner failed\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }),\n ),\n );\n\n return {\n runLoop,\n initialization:\n sink.state === \"none\"\n ? \"raw\"\n : cursor === initialHead\n ? \"reused\"\n : cursor > 0\n ? \"deferred\"\n : \"empty\",\n };\n });\n\n return {\n sinks,\n startSinkRunners: Effect.fnUntraced(function* (input: EDASinkRunnerStartInput) {\n const wasStarted = yield* Ref.getAndSet(started, true);\n if (wasStarted) {\n return;\n }\n const runners = yield* Effect.gen(function* () {\n const runners = yield* Effect.forEach(sinks, (sink) => makeSinkRunner(sink, input), {\n concurrency: 1,\n });\n yield* Effect.annotateCurrentSpan({\n \"eda.sinks.raw\": runners.filter((runner) => runner.initialization === \"raw\").length,\n \"eda.sinks.reused\": runners.filter((runner) => runner.initialization === \"reused\")\n .length,\n \"eda.sinks.deferred\": runners.filter((runner) => runner.initialization === \"deferred\")\n .length,\n \"eda.sinks.empty\": runners.filter((runner) => runner.initialization === \"empty\").length,\n });\n return runners;\n }).pipe(\n Effect.withSpan(\"agent.sinks.initialize\", {\n attributes: {\n sessionId: session.sessionId,\n \"eda.session.id\": session.sessionId,\n \"eda.seq.head\": input.initialProjection.reduced.lastSeq,\n \"eda.sinks.count\": sinks.length,\n },\n }),\n );\n // Catch-up can append events. Register every inbox before starting any delivery fiber.\n yield* Effect.forEach(\n runners,\n (runner) => runner.runLoop.pipe(Effect.forkIn(input.scope)),\n {\n discard: true,\n },\n );\n }),\n notifyDurableHeadAdvanced: (head) =>\n Effect.forEach(deliveries, ({ inbox }) => inbox.notify(head), { discard: true }),\n publishEphemeralToSinks: (event) =>\n Effect.forEach(\n deliveries,\n ({ sink, inbox }) => {\n if (\n sink.ephemeral === undefined ||\n !matchesInterest(event.event, sink.ephemeral.interests)\n )\n return Effect.void;\n return Effect.gen(function* () {\n const accepted = yield* inbox.offerEphemeral(event);\n if (!accepted) {\n yield* Effect.logWarning(\"EDA sink ephemeral buffer full\", { sink: sink.name });\n }\n }).pipe(\n Effect.catchTag(\"SinkEphemeralEncodingError\", (error) =>\n Effect.logWarning(\"EDA sink ephemeral serialization failed\", {\n cause: error.cause,\n sink: sink.name,\n }),\n ),\n );\n },\n { discard: true },\n ),\n } satisfies EDASinkRegistryShape;\n });\n\nconst makeSinkCheckpoint = (\n store: SinkCheckpointStoreShape,\n sinkName: EDASinkName,\n checkpointRef: SynchronizedRef.SynchronizedRef<StoredSinkCheckpoint>,\n): EDASinkCheckpoint => ({\n get: (schema, initial) =>\n SynchronizedRef.get(checkpointRef).pipe(\n Effect.flatMap((checkpoint) => {\n const serialized = serializedSinkState(checkpoint.payload);\n return serialized === undefined\n ? Effect.succeed(initial)\n : decodeSinkState(schema, serialized.state);\n }),\n ),\n save: (schema, state) =>\n encodeSinkState(schema, state).pipe(\n Effect.flatMap((encoded) => {\n const payload: SerializedSinkState = {\n formatVersion: sinkCheckpointFormatVersion,\n state: encoded,\n updatedAtMs: Date.now(),\n };\n return SynchronizedRef.modifyEffect(checkpointRef, (checkpoint) =>\n store.saveState(sinkName, payload).pipe(\n Effect.as([\n undefined,\n {\n afterSeq: checkpoint.afterSeq,\n payload,\n },\n ] as const),\n ),\n );\n }),\n ),\n});\n\nconst commitSinkCheckpoint = (\n store: SinkCheckpointStoreShape,\n sinkName: EDASinkName,\n checkpointRef: SynchronizedRef.SynchronizedRef<StoredSinkCheckpoint>,\n afterSeq: SequenceNumber,\n): Effect.Effect<void, EDASessionStoreError> =>\n SynchronizedRef.modifyEffect(checkpointRef, (checkpoint) =>\n store.commit(sinkName, afterSeq, checkpoint.payload).pipe(\n Effect.as([\n undefined,\n {\n afterSeq,\n payload: checkpoint.payload,\n },\n ] as const),\n ),\n );\n\nconst serializedSinkState = (payload: unknown): SerializedSinkState | undefined => {\n if (\n typeof payload !== \"object\" ||\n payload === null ||\n !(\"formatVersion\" in payload) ||\n payload.formatVersion !== sinkCheckpointFormatVersion ||\n !(\"state\" in payload) ||\n !(\"updatedAtMs\" in payload) ||\n typeof payload.updatedAtMs !== \"number\"\n ) {\n return undefined;\n }\n return {\n formatVersion: sinkCheckpointFormatVersion,\n state: payload.state,\n updatedAtMs: payload.updatedAtMs,\n };\n};\n\nconst decodeSinkState = <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n encoded: unknown,\n): Effect.Effect<State, EDASessionStoreError> =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(schema)(encoded),\n catch: (cause) => sinkCheckpointCodecError(\"decoding\", cause),\n });\n\nconst encodeSinkState = <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n state: State,\n): Effect.Effect<unknown, EDASessionStoreError> =>\n Effect.try({\n try: () => Schema.encodeUnknownSync(schema)(state),\n catch: (cause) => sinkCheckpointCodecError(\"encoding\", cause),\n });\n\nconst sinkCheckpointCodecError = (operation: string, cause: unknown) =>\n new EDASessionStoreError({\n message:\n cause instanceof Error\n ? `${operation} sink checkpoint: ${cause.message}`\n : `${operation} sink checkpoint: ${String(cause)}`,\n });\n\nconst readCursorBatchThrough = (\n store: EDASessionStoreShape,\n afterSeq: SequenceNumber,\n throughSeq: SequenceNumber,\n batchSize = defaultBatchSize,\n) =>\n store.eventsAfter(afterSeq).pipe(\n Stream.takeWhile((event) => event.position.seq <= throughSeq),\n Stream.take(batchSize),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n\nconst filterInterested = (\n events: ReadonlyArray<CommittedDurableEvent>,\n interests: EDASinkInterests | undefined,\n): ReadonlyArray<CommittedDurableEvent> =>\n events.filter(\n (entry) =>\n interests === undefined ||\n interests === \"*\" ||\n selectCommittedEvent(interests, entry) !== undefined,\n );\n\nconst matchesInterest = (\n event: import(\"../types/events\").EventEnvelope,\n interests:\n | \"*\"\n | Schema.Codec<import(\"../types/events\").EventEnvelope, unknown, never, never>\n |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EAAE,mBAAmB,YACrB,QAAQ,kBAAkB,+BAC1B,EAAE,WAAW,YACb,EAAE,iBAAiB,YACnB,OAAO,QAAQ,gBAAgB,UAE/B;CAEF,OAAO;EACL,eAAe;EACf,OAAO,QAAQ;EACf,aAAa,QAAQ;CACvB;AACF;AAEA,MAAM,mBACJ,QACA,YAEA,OAAO,IAAI;CACT,WAAW,OAAO,kBAAkB,MAAM,CAAC,CAAC,OAAO;CACnD,QAAQ,UAAU,yBAAyB,YAAY,KAAK;AAC9D,CAAC;AAEH,MAAM,mBACJ,QACA,UAEA,OAAO,IAAI;CACT,WAAW,OAAO,kBAAkB,MAAM,CAAC,CAAC,KAAK;CACjD,QAAQ,UAAU,yBAAyB,YAAY,KAAK;AAC9D,CAAC;AAEH,MAAM,4BAA4B,WAAmB,UACnD,IAAI,qBAAqB,EACvB,SACE,iBAAiB,QACb,GAAG,UAAU,oBAAoB,MAAM,YACvC,GAAG,UAAU,oBAAoB,OAAO,KAAK,IACrD,CAAC;AAEH,MAAM,0BACJ,OACA,UACA,YACA,YAAY,qBAEZ,MAAM,YAAY,QAAQ,CAAC,CAAC,KAC1B,OAAO,WAAW,UAAU,MAAM,SAAS,OAAO,UAAU,GAC5D,OAAO,KAAK,SAAS,GACrB,OAAO,YACP,OAAO,KAAK,WAAW,MAAM,KAAK,MAAM,CAAC,CAC3C;AAEF,MAAM,oBACJ,QACA,cAEA,OAAO,QACJ,UACC,cAAc,KAAA,KACd,cAAc,OACd,qBAAqB,WAAW,KAAK,MAAM,KAAA,CAC/C;AAEF,MAAM,mBACJ,OACA,cAIY,cAAc,KAAA,KAAa,cAAc,OAAO,OAAO,GAAG,SAAS,CAAC,CAAC,KAAK"}
|
|
1
|
+
{"version":3,"file":"sink-registry-DEneTH8u.js","names":[],"sources":["../src/services/sink-inbox.ts","../src/services/sink-registry.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as Queue from \"effect/Queue\";\nimport * as Schema from \"effect/Schema\";\n\nimport { SequenceNumber } from \"../types/core\";\nimport type { PositionedEvent } from \"../types/events\";\n\n/** Durable payloads stay in the log; only bounded best-effort ephemeral work is retained. */\nconst ephemeralCapacity = 128;\nconst ephemeralByteCapacity = 256 * 1024;\n\n/** An ephemeral update could not be measured as a JSON wire value. */\nexport class SinkEphemeralEncodingError extends Schema.TaggedError<SinkEphemeralEncodingError>()(\n \"SinkEphemeralEncodingError\",\n { cause: Schema.Defect() },\n) {}\n\n/** One ordered step on a sink's serialized delivery lane. */\ntype SinkWork =\n | { readonly _tag: \"Durable\"; readonly throughSeq: SequenceNumber }\n | { readonly _tag: \"Ephemeral\"; readonly event: PositionedEvent };\n\n/**\n * Coalesces durable heads without losing ephemeral ordering barriers. Publication never\n * waits for delivery. Overflow drops the newest ephemeral update, never durable work.\n */\nexport const makeSinkInbox = Effect.fnUntraced(function* (initialHead: SequenceNumber) {\n const wake = yield* Effect.acquireRelease(Queue.sliding<void>(1), Queue.shutdown);\n let head = initialHead;\n const pending: Array<{ readonly event: PositionedEvent; readonly bytes: number }> = [];\n let pendingBytes = 0;\n\n const notify = (throughSeq: SequenceNumber) =>\n Effect.sync(() => {\n head = SequenceNumber.make(Math.max(head, throughSeq));\n Queue.offerUnsafe(wake, undefined);\n });\n\n const offerEphemeral = (event: PositionedEvent) =>\n Effect.try({\n try: () => {\n const bytes = new TextEncoder().encode(JSON.stringify(event)).byteLength;\n if (pending.length >= ephemeralCapacity || bytes > ephemeralByteCapacity - pendingBytes) {\n return false;\n }\n pending.push({ event, bytes });\n pendingBytes += bytes;\n Queue.offerUnsafe(wake, undefined);\n return true;\n },\n catch: (cause) => new SinkEphemeralEncodingError({ cause }),\n });\n\n const poll = (cursor: SequenceNumber): Effect.Effect<SinkWork | undefined> =>\n Effect.sync(() => {\n while (pending.length > 0) {\n const first = pending[0];\n if (first === undefined) break;\n if (first.event.position.seq > cursor) {\n return { _tag: \"Durable\", throughSeq: first.event.position.seq };\n }\n pending.shift();\n pendingBytes -= first.bytes;\n if (first.event.position.seq === cursor) {\n return { _tag: \"Ephemeral\", event: first.event };\n }\n }\n return cursor < head ? { _tag: \"Durable\", throughSeq: head } : undefined;\n });\n\n return { notify, offerEphemeral, poll, awaitWork: Queue.take(wake) };\n});\n","import * as Cause from \"effect/Cause\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport { type DecodedDurableEvent } from \"../types/events/durable\";\nimport { selectCommittedEvent } from \"./session-store\";\nimport * as Scope from \"effect/Scope\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport * as Stream from \"effect/Stream\";\nimport * as SynchronizedRef from \"effect/SynchronizedRef\";\n\nimport { foldReducedState, initialReducedState, type ReducedState } from \"../domain/reduced-state\";\nimport { EDAReducerRegistry, type EDAReducerStateSnapshot } from \"./reducer-registry\";\nimport { EventId, SessionId, SequenceNumber } from \"../types/core\";\nimport type {\n DurableEventEnvelope,\n EphemeralEventEnvelope,\n PositionedEvent,\n} from \"../types/events\";\nimport type { EDASessionStoreShape } from \"./session-store\";\nimport { type CommittedDurableEvent, EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { EventFactory } from \"./event-factory\";\nimport type { EventFactoryShape } from \"./event-factory\";\nimport { IdGenerator } from \"./id-generator\";\nimport { EDAKeepAlive } from \"./keep-alive\";\nimport { makeSinkInbox } from \"./sink-inbox\";\nimport { SessionContext } from \"./session-context\";\nimport {\n EDASinkName,\n SinkCheckpointStore,\n type SinkCheckpointStoreShape,\n type StoredSinkCheckpoint,\n} from \"./sink-checkpoint-store\";\nimport { annotateEdaSpan } from \"./tracing\";\n\n/** Cursor-window input delivered to one durable sink drain. */\nexport interface EDASinkRawDurableBatch<E = DecodedDurableEvent> {\n /** All durable events replayed for this cursor window, including uninterested events. */\n readonly allEvents: ReadonlyArray<CommittedDurableEvent>;\n /** Events matching the sink's durable interests. */\n readonly events: ReadonlyArray<CommittedDurableEvent<E>>;\n /** Durable sequence through which the sink may advance after success. */\n readonly throughSeq: SequenceNumber;\n}\n\n/** Cursor window with framework and app projections, enabled by default. */\nexport interface EDASinkDurableBatch<E = DecodedDurableEvent> extends EDASinkRawDurableBatch<E> {\n /** Authoritative reduced state folded exactly through `throughSeq`. */\n readonly stateAfter: ReducedState;\n /** App-specific durable reducer states folded exactly through `throughSeq`. */\n readonly reducerStates: EDAReducerStateSnapshot;\n}\n\n/** Typed, sink-owned durable state stored independently from cursor advancement. */\nexport interface EDASinkCheckpoint {\n /** Decode current durable state, or return `initial` for a new or legacy cursor row. */\n readonly get: <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n initial: State,\n ) => Effect.Effect<State, EDASessionStoreError>;\n /** Validate, encode, and durably save state without advancing the sink cursor. */\n readonly save: <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n state: State,\n ) => Effect.Effect<void, EDASessionStoreError>;\n}\n\n/** Capabilities exposed to sink processors without granting raw store or bus access. */\nexport interface EDASinkContext {\n readonly sessionId: SessionId;\n /** Sink-owned checkpoint state, serialized with cursor commits and background writes. */\n readonly checkpoint: EDASinkCheckpoint;\n /** Build a framework durable event if the sink needs to emit one. */\n readonly events: EventFactoryShape;\n /** Mint an app durable event id for staged custom events. */\n readonly makeEventId: () => Effect.Effect<EventId>;\n /** Publish a best-effort live-only event. */\n readonly emitEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>;\n /** Stage durable events; the runner commits them after the sink succeeds. */\n readonly stageDurable: (event: DurableEventEnvelope) => Effect.Effect<void>;\n /** Fork background sink work into the session scope. */\n readonly forkScoped: (effect: Effect.Effect<unknown, unknown>) => Effect.Effect<void>;\n}\n\n/** `\"*\"` and omission select every fact; a schema selects and narrows matching envelopes. */\nexport type EDASinkInterests = \"*\" | Schema.Codec<DurableEventEnvelope, unknown, never, never>;\n\n/** Delivery policy shared by raw and projected durable consumers. */\ninterface EDADurableSinkOptions {\n readonly interests?: EDASinkInterests;\n readonly batchSize?: number;\n}\n\n/** Default durable consumer with framework and app projections at each cursor window. */\nexport interface EDAProjectedDurableSinkDefinition extends EDADurableSinkOptions {\n readonly process: (batch: EDASinkDurableBatch, ctx: EDASinkContext) => Effect.Effect<void, never>;\n}\n\n/** Raw consumer that never hydrates, folds, or retains a session projection. */\nexport interface EDARawDurableSinkDefinition extends EDADurableSinkOptions {\n readonly process: (\n batch: EDASinkRawDurableBatch,\n ctx: EDASinkContext,\n ) => Effect.Effect<void, never>;\n}\n\n/** Durable sink definition backed by a checkpoint and an app-owned delivery policy. */\nexport type EDADurableSinkDefinition = EDAProjectedDurableSinkDefinition;\n\n/** Best-effort live-only sink definition. */\nexport interface EDAEphemeralSinkDefinition {\n readonly interests?:\n | \"*\"\n | Schema.Codec<import(\"../types/events\").EventEnvelope, unknown, never, never>;\n readonly process: (event: PositionedEvent, ctx: EDASinkContext) => Effect.Effect<void, never>;\n}\n\n/**\n * Named app integration hook with optional durable and ephemeral filters.\n *\n * Every sink runs on one serialized position-ordered lane. Sinks own retry and\n * terminal failure handling, so callbacks must have an infallible typed error\n * channel. An unexpected defect is logged and skipped before the durable checkpoint\n * advances. Ephemeral callbacks are best-effort and are only processed after the\n * durable prefix at their anchor sequence has been projected.\n */\ninterface EDASinkOptions {\n readonly name: string;\n readonly ephemeral?: EDAEphemeralSinkDefinition;\n}\n\n/** Existing consumers receive framework and app projections unless explicitly opted out. */\nexport interface EDAProjectedSink extends EDASinkOptions {\n readonly state?: \"projected\";\n readonly durable?: EDAProjectedDurableSinkDefinition;\n}\n\n/** Raw consumers retain only their cursor and sink-owned checkpoint payload. */\nexport interface EDARawSink extends EDASinkOptions {\n readonly state: \"none\";\n readonly durable?: EDARawDurableSinkDefinition;\n}\n\n/** The outer discriminant preserves contextual callback typing for inline default sinks. */\nexport type EDASink = EDAProjectedSink | EDARawSink;\n\n/** Projected and raw overloads preserve contextual callback inference and literal names. */\nfunction makeSink<const Sink extends EDAProjectedSink>(sink: Sink): Sink;\nfunction makeSink<const Sink extends EDARawSink>(sink: Sink): Sink;\nfunction makeSink<const Sink extends EDASink>(sink: Sink): Sink;\nfunction makeSink(sink: EDASink): EDASink {\n return sink;\n}\n\n/** Convenience constructor preserving a sink's literal name/type information. */\nexport const EDASink = {\n make: makeSink,\n /** The live-event schema owns both subscription filtering and callback typing. */\n forEphemeralEvents: <E extends import(\"../types/events\").EventEnvelope>(\n interests: Schema.Codec<E, unknown, never, never>,\n process: (event: PositionedEvent<E>, ctx: EDASinkContext) => Effect.Effect<void, never>,\n ): EDAEphemeralSinkDefinition => ({\n interests,\n process: (entry, ctx) =>\n Schema.is(interests)(entry.event)\n ? process({ position: entry.position, event: entry.event }, ctx)\n : Effect.void,\n }),\n /** One schema selects and narrows the facts delivered to a projected durable consumer. */\n forEvents: <E extends DurableEventEnvelope>(\n interests: Schema.Codec<E, unknown, never, never>,\n sink: Omit<EDAProjectedSink, \"durable\"> & {\n readonly durable: {\n readonly batchSize?: number;\n readonly process: (\n batch: EDASinkDurableBatch<E>,\n ctx: EDASinkContext,\n ) => Effect.Effect<void, never>;\n };\n },\n ): EDAProjectedSink => ({\n ...sink,\n durable: {\n ...sink.durable,\n interests,\n process: (batch, ctx) =>\n sink.durable.process(\n {\n ...batch,\n events: batch.events.flatMap((entry) => {\n const selected = selectCommittedEvent(interests, entry);\n return selected === undefined ? [] : [selected];\n }),\n },\n ctx,\n ),\n },\n }),\n};\n\n/** Session-owned capabilities needed to start all registered sink runners. */\nexport interface EDASinkRunnerStartInput {\n readonly appendDurableBatch: (\n events: ReadonlyArray<DurableEventEnvelope>,\n ) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;\n /** Immutable framework and app projections at one common durable head. */\n readonly initialProjection: {\n readonly reduced: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n };\n readonly publishEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>;\n readonly scope: Scope.Scope;\n}\n\n/** Registry service coordinating durable checkpoints and live sink delivery. */\nexport interface EDASinkRegistryShape {\n readonly sinks: ReadonlyArray<EDASink>;\n /** Start long-lived sink runners. Safe to call once during session-state acquisition. */\n readonly startSinkRunners: (\n input: EDASinkRunnerStartInput,\n ) => Effect.Effect<void, EDASessionStoreError>;\n /** Coalesced non-blocking nudge that the durable log head advanced. */\n readonly notifyDurableHeadAdvanced: (head: SequenceNumber) => Effect.Effect<void>;\n /** Best-effort non-blocking delivery to ephemeral sink workers. */\n readonly publishEphemeralToSinks: (event: PositionedEvent) => Effect.Effect<void>;\n}\n\n/** Registry and runner for app-provided EDA sinks. */\nexport class EDASinkRegistry extends Context.Service<EDASinkRegistry, EDASinkRegistryShape>()(\n \"@effect-durable-agent/EDASinkRegistry\",\n) {\n static readonly Empty = Layer.succeed(EDASinkRegistry, {\n sinks: [],\n startSinkRunners: () => Effect.void,\n notifyDurableHeadAdvanced: () => Effect.void,\n publishEphemeralToSinks: () => Effect.void,\n } satisfies EDASinkRegistryShape);\n\n static readonly Live = (sinks: ReadonlyArray<EDASink>) =>\n Layer.effect(EDASinkRegistry, makeSinkRegistry(sinks));\n}\n\nconst defaultBatchSize = 100;\nconst sinkCheckpointFormatVersion = 1;\n\ninterface SinkProjection {\n readonly reduced: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n}\n\ninterface SerializedSinkState {\n readonly formatVersion: typeof sinkCheckpointFormatVersion;\n readonly state: unknown;\n readonly updatedAtMs: number;\n}\n\nconst makeSinkRegistry = (sinks: ReadonlyArray<EDASink>) =>\n Effect.gen(function* () {\n const session = yield* SessionContext;\n const store = yield* EDASessionStore;\n const checkpointStore = yield* SinkCheckpointStore;\n const eventFactory = yield* EventFactory;\n const ids = yield* IdGenerator;\n const reducerRegistry = yield* EDAReducerRegistry;\n const keepAlive = yield* EDAKeepAlive;\n const started = yield* Ref.make(false);\n const hydrationGate = yield* Semaphore.make(1);\n const deliveries: Array<{\n readonly sink: EDASink;\n readonly inbox: Effect.Success<ReturnType<typeof makeSinkInbox>>;\n }> = [];\n\n const baseContext = (\n staged: Array<DurableEventEnvelope>,\n publishEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>,\n scope: Scope.Scope,\n checkpoint: EDASinkCheckpoint,\n ): EDASinkContext => ({\n sessionId: session.sessionId,\n checkpoint,\n events: eventFactory,\n makeEventId: ids.makeEventId,\n emitEphemeral: publishEphemeral,\n stageDurable: (event) => Effect.sync(() => staged.push(event)),\n forkScoped: (effect) => effect.pipe(Effect.forkIn(scope), Effect.asVoid),\n });\n\n const makeSinkRunner = Effect.fnUntraced(function* (\n sink: EDASink,\n { initialProjection, appendDurableBatch, publishEphemeral, scope }: EDASinkRunnerStartInput,\n ) {\n // Long-lived fibers capture the head and capabilities, not the initial projection.\n const initialHead = initialProjection.reduced.lastSeq;\n const sinkName = EDASinkName.make(sink.name);\n const storedCheckpoint = yield* checkpointStore.load(sinkName);\n const checkpointRef = yield* SynchronizedRef.make(storedCheckpoint);\n const checkpoint = makeSinkCheckpoint(checkpointStore, sinkName, checkpointRef);\n const cursor = storedCheckpoint.afterSeq;\n const cursorRef = yield* Ref.make(cursor);\n if (cursor > initialHead) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} cursor exceeds session head`,\n });\n }\n // Keep only an exact projection seed; lagging workers reconstruct in their own scope.\n const state = yield* Ref.make<SinkProjection | undefined>(\n sink.state === \"none\"\n ? undefined\n : cursor === initialHead\n ? {\n reduced: initialProjection.reduced,\n reducerStates: initialProjection.reducerStates,\n }\n : cursor === 0\n ? { reduced: initialReducedState, reducerStates: reducerRegistry.initial }\n : undefined,\n );\n const inbox = yield* makeSinkInbox(initialHead).pipe(Scope.provide(scope));\n deliveries.push({ sink, inbox });\n const ensureProjection = Effect.fnUntraced(function* () {\n const existing = yield* Ref.get(state);\n if (existing !== undefined) return existing;\n const hydrated = yield* store.eventsAfter(SequenceNumber.make(0)).pipe(\n Stream.takeWhile((event) => event.position.seq <= cursor),\n Stream.chunks,\n Stream.runFold(\n (): SinkProjection => ({\n reduced: initialReducedState,\n reducerStates: reducerRegistry.initial,\n }),\n (current, page): SinkProjection => ({\n reduced: foldReducedState(current.reduced, page),\n reducerStates: reducerRegistry.reduce(current.reducerStates, page),\n }),\n ),\n Effect.withSpan(\"agent.sink.hydrate\", {\n attributes: {\n \"eda.sink.name\": sink.name,\n \"eda.session.id\": session.sessionId,\n \"eda.seq.through\": cursor,\n },\n }),\n hydrationGate.withPermits(1),\n );\n if (hydrated.reduced.lastSeq !== cursor) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} could not reconstruct its cursor`,\n });\n }\n yield* Ref.set(state, hydrated);\n return hydrated;\n });\n\n const processDurableBatch = Effect.fnUntraced(function* (\n allEvents: ReadonlyArray<CommittedDurableEvent>,\n ) {\n if (allEvents.length === 0) {\n return;\n }\n\n const currentCursor = yield* Ref.get(cursorRef);\n const fresh = allEvents.filter((entry) => entry.position.seq > currentCursor);\n if (fresh.length === 0) {\n return;\n }\n\n const durable = sink.durable;\n const last = fresh.at(-1);\n if (last === undefined) return;\n const throughSeq = last.position.seq;\n const nextProjection =\n sink.state === \"none\"\n ? undefined\n : yield* Effect.gen(function* () {\n const current = yield* ensureProjection();\n return {\n reduced: foldReducedState(current.reduced, fresh),\n reducerStates: reducerRegistry.reduce(current.reducerStates, fresh),\n };\n });\n const eventsForSink =\n durable === undefined ? [] : filterInterested(fresh, durable.interests);\n\n if (durable !== undefined && eventsForSink.length > 0) {\n yield* Effect.gen(function* () {\n const staged: Array<DurableEventEnvelope> = [];\n const rawBatch: EDASinkRawDurableBatch = {\n allEvents: fresh,\n events: eventsForSink,\n throughSeq,\n };\n const context = baseContext(staged, publishEphemeral, scope, checkpoint);\n const delivery = Effect.gen(function* () {\n if (sink.durable === undefined) return;\n if (sink.state === \"none\") return yield* sink.durable.process(rawBatch, context);\n // The projected branch owns both construction and delivery of these fields.\n if (nextProjection === undefined)\n return yield* Effect.die(\"Projected sink missing its projection\");\n return yield* sink.durable.process(\n {\n ...rawBatch,\n stateAfter: nextProjection.reduced,\n reducerStates: nextProjection.reducerStates,\n },\n context,\n );\n });\n const completed = yield* delivery.pipe(\n Effect.as(true),\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA durable sink violated its infallible contract\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }).pipe(Effect.as(false)),\n ),\n );\n if (completed && staged.length > 0) {\n yield* annotateEdaSpan({ \"eda.sink.staged_events\": staged.length });\n yield* appendDurableBatch(staged);\n }\n }).pipe(\n Effect.withSpan(\"agent.sink.drain\", {\n attributes: {\n \"eda.sink.name\": sink.name,\n \"eda.sink.cursor.before\": currentCursor,\n \"eda.sink.events.read\": fresh.length,\n \"eda.sink.events.interested\": eventsForSink.length,\n \"eda.sink.cursor.after\": throughSeq,\n },\n }),\n );\n }\n\n yield* commitSinkCheckpoint(checkpointStore, sinkName, checkpointRef, throughSeq);\n yield* Ref.set(cursorRef, throughSeq);\n yield* Ref.set(state, nextProjection);\n });\n\n const drainDurablesThrough = Effect.fnUntraced(function* (targetHead: SequenceNumber) {\n const currentCursor = yield* Ref.get(cursorRef);\n if (currentCursor >= targetHead) return;\n const allEvents = yield* readCursorBatchThrough(\n store,\n currentCursor,\n targetHead,\n sink.durable?.batchSize,\n );\n if (allEvents.length === 0) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} could not read its durable backlog`,\n });\n }\n yield* processDurableBatch(allEvents);\n });\n\n const processEphemeral = Effect.fnUntraced(function* (event: PositionedEvent) {\n if (sink.ephemeral === undefined) return;\n if (sink.state !== \"none\") yield* ensureProjection();\n yield* sink.ephemeral\n .process(event, baseContext([], publishEphemeral, scope, checkpoint))\n .pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA sink ephemeral projection failed\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }),\n ),\n );\n });\n\n const runLoop = Effect.forever(\n Effect.gen(function* () {\n const currentCursor = yield* Ref.get(cursorRef);\n const work = yield* inbox.poll(currentCursor);\n if (work === undefined) {\n yield* inbox.awaitWork;\n return;\n }\n yield* keepAlive.withActiveWork(\n `sink:${sink.name}`,\n work._tag === \"Durable\"\n ? drainDurablesThrough(work.throughSeq)\n : processEphemeral(work.event),\n );\n yield* Effect.yieldNow;\n }),\n ).pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA sink runner failed\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }),\n ),\n );\n\n return {\n runLoop,\n initialization:\n sink.state === \"none\"\n ? \"raw\"\n : cursor === initialHead\n ? \"reused\"\n : cursor > 0\n ? \"deferred\"\n : \"empty\",\n };\n });\n\n return {\n sinks,\n startSinkRunners: Effect.fnUntraced(function* (input: EDASinkRunnerStartInput) {\n const wasStarted = yield* Ref.getAndSet(started, true);\n if (wasStarted) {\n return;\n }\n const runners = yield* Effect.gen(function* () {\n const runners = yield* Effect.forEach(sinks, (sink) => makeSinkRunner(sink, input), {\n concurrency: 1,\n });\n yield* Effect.annotateCurrentSpan({\n \"eda.sinks.raw\": runners.filter((runner) => runner.initialization === \"raw\").length,\n \"eda.sinks.reused\": runners.filter((runner) => runner.initialization === \"reused\")\n .length,\n \"eda.sinks.deferred\": runners.filter((runner) => runner.initialization === \"deferred\")\n .length,\n \"eda.sinks.empty\": runners.filter((runner) => runner.initialization === \"empty\").length,\n });\n return runners;\n }).pipe(\n Effect.withSpan(\"agent.sinks.initialize\", {\n attributes: {\n sessionId: session.sessionId,\n \"eda.session.id\": session.sessionId,\n \"eda.seq.head\": input.initialProjection.reduced.lastSeq,\n \"eda.sinks.count\": sinks.length,\n },\n }),\n );\n // Catch-up can append events. Register every inbox before starting any delivery fiber.\n yield* Effect.forEach(\n runners,\n (runner) => runner.runLoop.pipe(Effect.forkIn(input.scope)),\n {\n discard: true,\n },\n );\n }),\n notifyDurableHeadAdvanced: (head) =>\n Effect.forEach(deliveries, ({ inbox }) => inbox.notify(head), { discard: true }),\n publishEphemeralToSinks: (event) =>\n Effect.forEach(\n deliveries,\n ({ sink, inbox }) => {\n if (\n sink.ephemeral === undefined ||\n !matchesInterest(event.event, sink.ephemeral.interests)\n )\n return Effect.void;\n return Effect.gen(function* () {\n const accepted = yield* inbox.offerEphemeral(event);\n if (!accepted) {\n yield* Effect.logWarning(\"EDA sink ephemeral buffer full\", { sink: sink.name });\n }\n }).pipe(\n Effect.catchTag(\"SinkEphemeralEncodingError\", (error) =>\n Effect.logWarning(\"EDA sink ephemeral serialization failed\", {\n cause: error.cause,\n sink: sink.name,\n }),\n ),\n );\n },\n { discard: true },\n ),\n } satisfies EDASinkRegistryShape;\n });\n\nconst makeSinkCheckpoint = (\n store: SinkCheckpointStoreShape,\n sinkName: EDASinkName,\n checkpointRef: SynchronizedRef.SynchronizedRef<StoredSinkCheckpoint>,\n): EDASinkCheckpoint => ({\n get: (schema, initial) =>\n SynchronizedRef.get(checkpointRef).pipe(\n Effect.flatMap((checkpoint) => {\n const serialized = serializedSinkState(checkpoint.payload);\n return serialized === undefined\n ? Effect.succeed(initial)\n : decodeSinkState(schema, serialized.state);\n }),\n ),\n save: (schema, state) =>\n encodeSinkState(schema, state).pipe(\n Effect.flatMap((encoded) => {\n const payload: SerializedSinkState = {\n formatVersion: sinkCheckpointFormatVersion,\n state: encoded,\n updatedAtMs: Date.now(),\n };\n return SynchronizedRef.modifyEffect(checkpointRef, (checkpoint) =>\n store.saveState(sinkName, payload).pipe(\n Effect.as([\n undefined,\n {\n afterSeq: checkpoint.afterSeq,\n payload,\n },\n ] as const),\n ),\n );\n }),\n ),\n});\n\nconst commitSinkCheckpoint = (\n store: SinkCheckpointStoreShape,\n sinkName: EDASinkName,\n checkpointRef: SynchronizedRef.SynchronizedRef<StoredSinkCheckpoint>,\n afterSeq: SequenceNumber,\n): Effect.Effect<void, EDASessionStoreError> =>\n SynchronizedRef.modifyEffect(checkpointRef, (checkpoint) =>\n store.commit(sinkName, afterSeq, checkpoint.payload).pipe(\n Effect.as([\n undefined,\n {\n afterSeq,\n payload: checkpoint.payload,\n },\n ] as const),\n ),\n );\n\nconst serializedSinkState = (payload: unknown): SerializedSinkState | undefined => {\n if (\n typeof payload !== \"object\" ||\n payload === null ||\n !(\"formatVersion\" in payload) ||\n payload.formatVersion !== sinkCheckpointFormatVersion ||\n !(\"state\" in payload) ||\n !(\"updatedAtMs\" in payload) ||\n typeof payload.updatedAtMs !== \"number\"\n ) {\n return undefined;\n }\n return {\n formatVersion: sinkCheckpointFormatVersion,\n state: payload.state,\n updatedAtMs: payload.updatedAtMs,\n };\n};\n\nconst decodeSinkState = <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n encoded: unknown,\n): Effect.Effect<State, EDASessionStoreError> =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(schema)(encoded),\n catch: (cause) => sinkCheckpointCodecError(\"decoding\", cause),\n });\n\nconst encodeSinkState = <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n state: State,\n): Effect.Effect<unknown, EDASessionStoreError> =>\n Effect.try({\n try: () => Schema.encodeUnknownSync(schema)(state),\n catch: (cause) => sinkCheckpointCodecError(\"encoding\", cause),\n });\n\nconst sinkCheckpointCodecError = (operation: string, cause: unknown) =>\n new EDASessionStoreError({\n message:\n cause instanceof Error\n ? `${operation} sink checkpoint: ${cause.message}`\n : `${operation} sink checkpoint: ${String(cause)}`,\n });\n\nconst readCursorBatchThrough = (\n store: EDASessionStoreShape,\n afterSeq: SequenceNumber,\n throughSeq: SequenceNumber,\n batchSize = defaultBatchSize,\n) =>\n store.eventsAfter(afterSeq).pipe(\n Stream.takeWhile((event) => event.position.seq <= throughSeq),\n Stream.take(batchSize),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n\nconst filterInterested = (\n events: ReadonlyArray<CommittedDurableEvent>,\n interests: EDASinkInterests | undefined,\n): ReadonlyArray<CommittedDurableEvent> =>\n events.filter(\n (entry) =>\n interests === undefined ||\n interests === \"*\" ||\n selectCommittedEvent(interests, entry) !== undefined,\n );\n\nconst matchesInterest = (\n event: import(\"../types/events\").EventEnvelope,\n interests:\n | \"*\"\n | Schema.Codec<import(\"../types/events\").EventEnvelope, unknown, never, never>\n | undefined,\n): boolean => interests === undefined || interests === \"*\" || Schema.is(interests)(event);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;;AAG9B,IAAa,6BAAb,cAAgD,OAAO,YAAwC,CAAC,CAC9F,8BACA,EAAE,OAAO,OAAO,OAAO,EAAE,CAC3B,CAAC,CAAC,CAAC;;;;;AAWH,MAAa,gBAAgB,OAAO,WAAW,WAAW,aAA6B;CACrF,MAAM,OAAO,OAAO,OAAO,eAAe,MAAM,QAAc,CAAC,GAAG,MAAM,QAAQ;CAChF,IAAI,OAAO;CACX,MAAM,UAA8E,CAAC;CACrF,IAAI,eAAe;CAEnB,MAAM,UAAU,eACd,OAAO,WAAW;EAChB,OAAO,eAAe,KAAK,KAAK,IAAI,MAAM,UAAU,CAAC;EACrD,MAAM,YAAY,MAAM,KAAA,CAAS;CACnC,CAAC;CAEH,MAAM,kBAAkB,UACtB,OAAO,IAAI;EACT,WAAW;GACT,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU,KAAK,CAAC,CAAC,CAAC;GAC9D,IAAI,QAAQ,UAAU,qBAAqB,QAAQ,wBAAwB,cACzE,OAAO;GAET,QAAQ,KAAK;IAAE;IAAO;GAAM,CAAC;GAC7B,gBAAgB;GAChB,MAAM,YAAY,MAAM,KAAA,CAAS;GACjC,OAAO;EACT;EACA,QAAQ,UAAU,IAAI,2BAA2B,EAAE,MAAM,CAAC;CAC5D,CAAC;CAEH,MAAM,QAAQ,WACZ,OAAO,WA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,OACA,cAIY,cAAc,KAAA,KAAa,cAAc,OAAO,OAAO,GAAG,SAAS,CAAC,CAAC,KAAK"}
|
package/dist/testkit/layers.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { g as SessionId } from "../core-BcimKMIv.js";
|
|
2
2
|
import { t as DurableEventEnvelope } from "../envelope-Che6KatU.js";
|
|
3
3
|
import "../events-BWuvzVml.js";
|
|
4
|
-
import { c as EDASessionStoreShape, o as EDASessionStore, s as EDASessionStoreError } from "../session-store-
|
|
4
|
+
import { c as EDASessionStoreShape, o as EDASessionStore, s as EDASessionStoreError } from "../session-store-ByDjS03N.js";
|
|
5
5
|
import { t as ModelResolver } from "../model-resolver-DUms5p6X.js";
|
|
6
|
-
import { r as EDAReducerRegistry, t as EDAReducer } from "../reducer-registry-
|
|
7
|
-
import { $ as EDASessionQuery, At as InferenceRunnerStreamPart, Cn as CompactionRunner, Fn as SessionContext, Mt as RunScheduler, Ot as TurnRunner, Pn as EventFactory, bn as CompactionPolicy, fn as LiveEventBus, hn as CompactionExecutor, jt as ToolExecutor, kt as InferenceRunner, ln as EDASinkRegistry, rn as EDASink, wt as SessionState, zn as EDAPromptProjector } from "../reduced-state-
|
|
8
|
-
import { a as ToolParamsSchema, r as EDAToolRegistry, t as EDAModelToolkit } from "../tool-registry-
|
|
6
|
+
import { r as EDAReducerRegistry, t as EDAReducer } from "../reducer-registry-BAbhZs6d.js";
|
|
7
|
+
import { $ as EDASessionQuery, At as InferenceRunnerStreamPart, Cn as CompactionRunner, Fn as SessionContext, Mt as RunScheduler, Ot as TurnRunner, Pn as EventFactory, bn as CompactionPolicy, fn as LiveEventBus, hn as CompactionExecutor, jt as ToolExecutor, kt as InferenceRunner, ln as EDASinkRegistry, rn as EDASink, wt as SessionState, zn as EDAPromptProjector } from "../reduced-state-PJdig48e.js";
|
|
8
|
+
import { a as ToolParamsSchema, r as EDAToolRegistry, t as EDAModelToolkit } from "../tool-registry-CxZ0iuYb.js";
|
|
9
9
|
import { t as IdGenerator } from "../id-generator-BKGoKjt-.js";
|
|
10
10
|
import { t as EDAKeepAlive } from "../keep-alive-_zFCUvt3.js";
|
|
11
|
-
import { n as SinkCheckpointStore } from "../sink-checkpoint-store-
|
|
12
|
-
import { t as RunSchedulingWakeup } from "../run-scheduling-wakeup-
|
|
11
|
+
import { n as SinkCheckpointStore } from "../sink-checkpoint-store-BHb8YRTw.js";
|
|
12
|
+
import { t as RunSchedulingWakeup } from "../run-scheduling-wakeup-QLK87OqG.js";
|
|
13
13
|
import * as Layer from "effect/Layer";
|
|
14
14
|
import * as LanguageModel from "effect/ai/LanguageModel";
|
|
15
15
|
import * as Stream from "effect/Stream";
|
package/dist/testkit/layers.js
CHANGED
|
@@ -2,8 +2,8 @@ import { RunSchedulingWakeup } from "../services/run-scheduling-wakeup.js";
|
|
|
2
2
|
import { RunScheduler } from "../services/run-scheduler.js";
|
|
3
3
|
import { ModelResolver } from "../services/model-resolver.js";
|
|
4
4
|
import { g as UnixEpochMillis } from "../envelope-BCzKUq_z.js";
|
|
5
|
-
import { d as TurnRunner, f as InferenceRunner, m as LiveEventBus, p as ToolExecutor, u as SessionState } from "../session-state-
|
|
6
|
-
import { EDASessionStore } from "../
|
|
5
|
+
import { d as TurnRunner, f as InferenceRunner, m as LiveEventBus, p as ToolExecutor, u as SessionState } from "../session-state-StlO5B2N.js";
|
|
6
|
+
import { i as EDASessionStore } from "../session-store-DcJjs4Fd.js";
|
|
7
7
|
import { a as CompactionPolicy, n as CompactionExecutor, o as CompactionRunner } from "../compaction-ajHZ5l7f.js";
|
|
8
8
|
import { EDAPromptProjector } from "../services/prompt-projector.js";
|
|
9
9
|
import { n as SessionContext, t as EventFactory } from "../event-factory-VAci3NJb.js";
|
|
@@ -11,7 +11,7 @@ import { EDAToolRegistry } from "../services/tool-registry.js";
|
|
|
11
11
|
import { IdGenerator } from "../services/id-generator.js";
|
|
12
12
|
import { EDAKeepAlive } from "../services/keep-alive.js";
|
|
13
13
|
import { EDAReducerRegistry } from "../services/reducer-registry.js";
|
|
14
|
-
import { n as EDASinkRegistry } from "../sink-registry-
|
|
14
|
+
import { n as EDASinkRegistry } from "../sink-registry-DEneTH8u.js";
|
|
15
15
|
import { SinkCheckpointStore } from "../services/sink-checkpoint-store.js";
|
|
16
16
|
import { EDASessionQuery } from "../services/session-query.js";
|
|
17
17
|
import * as Effect from "effect/Effect";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as TurnId, c as EventId, g as SessionId, p as RunId, y as ToolCallId } from "./core-BcimKMIv.js";
|
|
2
2
|
import { g as ToolName, t as DurableEventEnvelope } from "./envelope-Che6KatU.js";
|
|
3
3
|
import "./events-BWuvzVml.js";
|
|
4
|
-
import { s as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-
|
|
4
|
+
import { s as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-ByDjS03N.js";
|
|
5
5
|
import * as Context from "effect/Context";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
@@ -55,4 +55,4 @@ declare class EDAToolRegistry extends EDAToolRegistry_base {
|
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
export { ToolParamsSchema as a, EDAToolRegistryShape as i, EDAToolExecutionContext as n, makeEDAToolkit as o, EDAToolRegistry as r, EDAModelToolkit as t };
|
|
58
|
-
//# sourceMappingURL=tool-registry-
|
|
58
|
+
//# sourceMappingURL=tool-registry-CxZ0iuYb.d.ts.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { h as SequenceNumber } from "./core-BcimKMIv.js";
|
|
2
|
+
import { $ as TranscriptAssistantRecord, A as TranscriptDefinitionError, At as TranscriptUnknownRecord, B as transcriptMappingBounds, Bt as transcriptRecordId, C as TranscriptVersionStatus, Ct as TranscriptRunGroupRecord, D as defaultTranscriptWindowLimits, Dt as TranscriptToolLifecycle, E as TranscriptWindowSelector, Et as TranscriptSessionContextRecord, F as TranscriptMappingTarget, Ft as isPendingTranscriptUserRecord, G as ImportAssistantRecordId, H as CompactionRecordId, I as TranscriptMappings, It as isTopLevelTranscriptRecord, J as RunGroupRecordId, K as InferenceAssistantRecordId, L as TranscriptUserFallback, Lt as runGroupStatus, M as TranscriptMappedEvent, Mt as TranscriptUserState, N as TranscriptMapping, Nt as TranscriptVersion, O as transcriptCursorOf, Ot as TranscriptToolRecord, P as TranscriptMappingOperation, Pt as UserRecordId, Q as TranscriptAssistantPart, R as emptyTranscriptMappings, Rt as transcriptDecorationBufferLimit, S as TranscriptVersionMeta, St as TranscriptRecordViewFromEnvelope, T as TranscriptWindowLimits, Tt as TranscriptRunOutcome, U as ConsumedTranscriptUserRecord, V as AssistantRecordId, Vt as transcriptStoredInlineBodyLimit, W as DecorationBufferRecordId, X as ToolRecordId, Y as SessionContextRecordId, Z as TranscriptAssistantLifecycle, _ as EDATranscriptStoreShape, _t as TranscriptRecordEnvelope, at as TranscriptCursor, b as TranscriptActiveContent, bt as TranscriptRecordKind, ct as TranscriptDecorationEntryKey, dt as TranscriptFieldPath, et as TranscriptBody, ft as TranscriptLogIncarnation, g as EDATranscriptStore, gt as TranscriptRecord, ht as TranscriptPosition, it as TranscriptCompactionRecord, j as TranscriptListEntryKey, jt as TranscriptUserRecord, k as TranscriptDefinition, kt as TranscriptTopLevelRecord, lt as TranscriptDecorationKey, mt as TranscriptOrderKey, nt as TranscriptBufferedDecoration, ot as TranscriptDecoration, pt as TranscriptOrder, q as PendingTranscriptUserRecord, rt as TranscriptClassification, st as TranscriptDecorationBufferRecord, t as CommittedDurableEvent, tt as TranscriptBodySource, ut as TranscriptDecorations, v as TranscriptCursorMismatch, vt as TranscriptRecordFromEnvelope, w as TranscriptWindow, wt as TranscriptRunMember, x as TranscriptReadiness, xt as TranscriptRecordView, y as TranscriptMaintenanceConfig, yt as TranscriptRecordId, z as makeTranscriptDefinition, zt as transcriptRecordEnvelopeFormat } from "./session-store-ByDjS03N.js";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Result from "effect/Result";
|
|
5
|
+
//#region src/transcript/plan.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Secondary keys that resolve to a record through an indexed join, never an in-memory map.
|
|
8
|
+
*
|
|
9
|
+
* - `messageId`: every message id a user submission has carried, including replacement ids.
|
|
10
|
+
* - `idempotencyKey`: a submitting command's caller-owned retry key.
|
|
11
|
+
* - `runId`: every run of a run group, so continuations resolve to the root's group.
|
|
12
|
+
* - `runCommand`: commands owned by a run group; a run that reuses them continues the group.
|
|
13
|
+
* - `toolPart`: `<inferenceId>/<providerPartId>`, linking an assistant tool-call part to its tool.
|
|
14
|
+
*/
|
|
15
|
+
declare const TranscriptAliasNamespace: Schema.Literals<readonly ["messageId", "idempotencyKey", "runId", "runCommand", "toolPart"]>;
|
|
16
|
+
type TranscriptAliasNamespace = typeof TranscriptAliasNamespace.Type;
|
|
17
|
+
/** One alias row: `(namespace, key)` resolves to `recordId` within one version. */
|
|
18
|
+
interface TranscriptAlias {
|
|
19
|
+
readonly namespace: TranscriptAliasNamespace;
|
|
20
|
+
readonly key: string;
|
|
21
|
+
readonly recordId: TranscriptRecordId;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Synchronous indexed reads of one transcript version, as committed before the batch.
|
|
25
|
+
*
|
|
26
|
+
* Adapters back this with indexed storage reads so the interpreter can run inside a synchronous
|
|
27
|
+
* transaction (Cloudflare `storage.transactionSync`). Reads see no uncommitted plan; the
|
|
28
|
+
* interpreter overlays its own in-batch changes.
|
|
29
|
+
*/
|
|
30
|
+
interface TranscriptLookup {
|
|
31
|
+
/** Last seq already projected into this version. Events at or below it are skipped. */
|
|
32
|
+
readonly cursor: SequenceNumber;
|
|
33
|
+
readonly record: (id: TranscriptRecordId) => TranscriptRecord | undefined;
|
|
34
|
+
readonly alias: (namespace: TranscriptAliasNamespace, key: string) => TranscriptRecordId | undefined;
|
|
35
|
+
/** Next free ordinal among records positioned at `anchorSeq`; 0 when none are. */
|
|
36
|
+
readonly nextOrdinal: (anchorSeq: SequenceNumber) => number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Deterministic changes for one committed batch: the final state of every record the batch
|
|
40
|
+
* touched, in first-touch order, the aliases it introduced, and the new cursor.
|
|
41
|
+
*
|
|
42
|
+
* There are no deletions. Aliases are inserts only: an alias never moves to another record.
|
|
43
|
+
* Applying the plan and advancing the cursor must commit atomically with each other.
|
|
44
|
+
*/
|
|
45
|
+
interface TranscriptChangePlan {
|
|
46
|
+
readonly records: ReadonlyArray<TranscriptRecord>;
|
|
47
|
+
readonly aliases: ReadonlyArray<TranscriptAlias>;
|
|
48
|
+
readonly throughSeq: SequenceNumber;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The interpretation boundary: a pure, synchronous function from a lookup, committed events and
|
|
52
|
+
* a definition to a change plan.
|
|
53
|
+
*
|
|
54
|
+
* It throws `TranscriptProjectionError` when the stored projection is inconsistent with the log.
|
|
55
|
+
* The adapter treats any throw as a recoverable projection failure of that version only.
|
|
56
|
+
*/
|
|
57
|
+
type PlanTranscriptBatch = (lookup: TranscriptLookup, committed: ReadonlyArray<CommittedDurableEvent>, definition: TranscriptDefinition) => TranscriptChangePlan;
|
|
58
|
+
declare const TranscriptProjectionError_base: Schema.Class<TranscriptProjectionError, Schema.TaggedStruct<"TranscriptProjectionError", {
|
|
59
|
+
readonly message: Schema.String;
|
|
60
|
+
}>, import("effect/Cause").YieldableError>;
|
|
61
|
+
/** The stored projection cannot be advanced from the given lookup and batch. */
|
|
62
|
+
declare class TranscriptProjectionError extends TranscriptProjectionError_base {}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/transcript/interpreter.d.ts
|
|
65
|
+
/**
|
|
66
|
+
* Interpret one committed batch into a transcript change plan.
|
|
67
|
+
*
|
|
68
|
+
* Mirrors the `ReducedState` message, tool and inference fold without pruning: a
|
|
69
|
+
* `ContextRebased` only adds a compaction marker. Events at or below the lookup cursor are
|
|
70
|
+
* skipped, so an idempotent re-append is harmless. Foreign events are ignored unless a mapping
|
|
71
|
+
* of `definition` names their namespace, type and schema version.
|
|
72
|
+
*/
|
|
73
|
+
declare const planTranscriptBatch: PlanTranscriptBatch;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/transcript/version.d.ts
|
|
76
|
+
/**
|
|
77
|
+
* EDA's transcript semantic revision.
|
|
78
|
+
*
|
|
79
|
+
* Bump it deliberately whenever the interpreter, the legacy-attempt normalizer, the record
|
|
80
|
+
* decoders or the mapping executor would interpret any existing log differently. A bump changes
|
|
81
|
+
* every transcript version, so every session rebuilds and every host must run its backfill.
|
|
82
|
+
* A new durable event type needs a bump only if this release gives it transcript meaning;
|
|
83
|
+
* events the interpreter ignores leave the revision and every version unchanged.
|
|
84
|
+
*
|
|
85
|
+
* A CI fingerprint over a fixed scenario corpus (added with the interpreter) fails when
|
|
86
|
+
* interpretation output changes and this constant does not; re-record it together with the bump.
|
|
87
|
+
*/
|
|
88
|
+
declare const transcriptSemanticRevision = 1;
|
|
89
|
+
/**
|
|
90
|
+
* Deterministic JSON: object keys sorted by code unit, no whitespace. Only JSON values are
|
|
91
|
+
* accepted, so equal data always produces equal bytes.
|
|
92
|
+
*/
|
|
93
|
+
declare const canonicalJson: (value: unknown) => string;
|
|
94
|
+
/** Transcript version for a semantic revision and already-encoded canonical mapping data. */
|
|
95
|
+
declare const computeTranscriptVersion: (semanticRevision: number, encodedMappings: unknown) => TranscriptVersion;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/transcript/window-read.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* Synchronous indexed reads of the served version at one cut, as a store provides them.
|
|
100
|
+
*
|
|
101
|
+
* Window assembly (paging, dependency collection, byte budgeting and body references) is shared
|
|
102
|
+
* by every store through `readTranscriptWindowFrom`; a store only supplies these reads.
|
|
103
|
+
*/
|
|
104
|
+
interface TranscriptWindowSource {
|
|
105
|
+
readonly incarnation: TranscriptLogIncarnation;
|
|
106
|
+
/** Maintenance state of the served (active) version; its cursor is the window's `throughSeq`. */
|
|
107
|
+
readonly meta: TranscriptVersionMeta;
|
|
108
|
+
/** False when this release no longer carries the served version (a missed session). */
|
|
109
|
+
readonly carried: boolean;
|
|
110
|
+
/** Top-level records before `key` (or before the end), newest first. */
|
|
111
|
+
readonly topLevelBefore: (key: TranscriptOrderKey | undefined, limit: number, inclusive: boolean) => ReadonlyArray<TranscriptTopLevelRecord>;
|
|
112
|
+
/** Top-level records after `key` (or after the start), oldest first. */
|
|
113
|
+
readonly topLevelAfter: (key: TranscriptOrderKey | undefined, limit: number, inclusive: boolean) => ReadonlyArray<TranscriptTopLevelRecord>;
|
|
114
|
+
readonly record: (id: TranscriptRecordId) => TranscriptRecord | undefined;
|
|
115
|
+
readonly alias: (namespace: TranscriptAliasNamespace, key: string) => TranscriptRecordId | undefined;
|
|
116
|
+
/** Tool records of one assistant (the typed dependency lookup). */
|
|
117
|
+
readonly toolsOf: (assistantId: AssistantRecordId) => ReadonlyArray<TranscriptToolRecord>;
|
|
118
|
+
/** Every user record still waiting for the agent (the pending-membership index). */
|
|
119
|
+
readonly pendingUsers: () => ReadonlyArray<TranscriptUserRecord>;
|
|
120
|
+
}
|
|
121
|
+
/** Readiness of a served version: why its cut may be behind the log. */
|
|
122
|
+
declare const transcriptReadiness: (meta: TranscriptVersionMeta, carried: boolean) => TranscriptReadiness;
|
|
123
|
+
/** The empty window served while no version is servable yet. */
|
|
124
|
+
declare const buildingTranscriptWindow: (incarnation: TranscriptLogIncarnation, version: TranscriptVersion) => TranscriptWindow;
|
|
125
|
+
/**
|
|
126
|
+
* Assemble one window from a source at a single cut.
|
|
127
|
+
*
|
|
128
|
+
* The response never contains anything newer than the served version's cursor: a frozen (failed
|
|
129
|
+
* or no longer carried) version's rows, pending users and session context all stop at its last
|
|
130
|
+
* good cut, which is the degraded-read rule. Bodies above the inline limit become references;
|
|
131
|
+
* if the response still exceeds the byte budget, records are dropped from the far end of the
|
|
132
|
+
* selection, keeping at least one so paging always progresses.
|
|
133
|
+
*/
|
|
134
|
+
declare const readTranscriptWindowFrom: (source: TranscriptWindowSource, selector: TranscriptWindowSelector, limits: TranscriptWindowLimits) => Result.Result<TranscriptWindow, TranscriptCursorMismatch>;
|
|
135
|
+
//#endregion
|
|
136
|
+
export { AssistantRecordId, CompactionRecordId, ConsumedTranscriptUserRecord, DecorationBufferRecordId, EDATranscriptStore, EDATranscriptStoreShape, ImportAssistantRecordId, InferenceAssistantRecordId, PendingTranscriptUserRecord, PlanTranscriptBatch, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptAlias, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptChangePlan, TranscriptClassification, TranscriptCompactionRecord, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, 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, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptTopLevelRecord, TranscriptUnknownRecord, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, type TranscriptWindowSource, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptWindowLimits, emptyTranscriptMappings, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, readTranscriptWindowFrom, runGroupStatus, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit };
|
|
137
|
+
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { SequenceNumber } from "./types/core.js";
|
|
2
|
+
import { u as NonNegativeInt } from "./envelope-BCzKUq_z.js";
|
|
3
|
+
import { $ as TranscriptRecordId, A as SessionContextRecordId, B as TranscriptCursor, C as transcriptSemanticRevision, D as ImportAssistantRecordId, E as DecorationBufferRecordId, F as TranscriptBody, G as TranscriptDecorations, H as TranscriptDecorationBufferRecord, I as TranscriptBodySource, J as TranscriptOrder, K as TranscriptFieldPath, L as TranscriptBufferedDecoration, M as TranscriptAssistantLifecycle, N as TranscriptAssistantPart, O as InferenceAssistantRecordId, P as TranscriptAssistantRecord, Q as TranscriptRecordFromEnvelope, R as TranscriptClassification, S as computeTranscriptVersion, T as CompactionRecordId, U as TranscriptDecorationEntryKey, V as TranscriptDecoration, W as TranscriptDecorationKey, X as TranscriptRecord, Y as TranscriptPosition, Z as TranscriptRecordEnvelope, _ as TranscriptUserFallback, _t as transcriptRecordId, a as TranscriptCursorMismatch, at as TranscriptToolLifecycle, b as transcriptMappingBounds, c as TranscriptProjectionError, ct as TranscriptUserRecord, d as TranscriptListEntryKey, dt as UserRecordId, et as TranscriptRecordViewFromEnvelope, f as TranscriptMappedEvent, ft as isPendingTranscriptUserRecord, g as TranscriptMappings, gt as transcriptRecordEnvelopeFormat, h as TranscriptMappingTarget, ht as transcriptDecorationBufferLimit, i as EDATranscriptStore, it as TranscriptSessionContextRecord, j as ToolRecordId, k as RunGroupRecordId, l as TranscriptDefinition, lt as TranscriptUserState, m as TranscriptMappingOperation, mt as runGroupStatus, n as readTranscriptWindowFrom, nt as TranscriptRunMember, o as planTranscriptBatch, ot as TranscriptToolRecord, p as TranscriptMapping, pt as isTopLevelTranscriptRecord, q as TranscriptLogIncarnation, r as transcriptReadiness, rt as TranscriptRunOutcome, s as TranscriptAliasNamespace, st as TranscriptUnknownRecord, t as buildingTranscriptWindow, tt as TranscriptRunGroupRecord, u as TranscriptDefinitionError, ut as TranscriptVersion, v as emptyTranscriptMappings, vt as transcriptStoredInlineBodyLimit, w as AssistantRecordId, x as canonicalJson, y as makeTranscriptDefinition, z as TranscriptCompactionRecord } from "./window-read-B8aF_hDq.js";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import * as SchemaGetter from "effect/SchemaGetter";
|
|
6
|
+
//#region src/transcript/window.ts
|
|
7
|
+
const PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
8
|
+
const orderKeyOfCursor = (cursor) => ({
|
|
9
|
+
anchorSeq: cursor.anchorSeq,
|
|
10
|
+
ordinal: cursor.ordinal,
|
|
11
|
+
recordId: cursor.recordId
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Which slice of history to read.
|
|
15
|
+
*
|
|
16
|
+
* `Latest` serves first paint (SSR, CLIs); `Page` walks either direction from a cursor;
|
|
17
|
+
* `Range` re-reads exactly the span a client retains, inclusive of both ends, at one new cut.
|
|
18
|
+
*/
|
|
19
|
+
const TranscriptWindowSelector = Schema.Union([
|
|
20
|
+
Schema.TaggedStruct("Latest", { count: PositiveInt }),
|
|
21
|
+
Schema.TaggedStruct("Page", {
|
|
22
|
+
direction: Schema.Literals(["before", "after"]),
|
|
23
|
+
cursor: TranscriptCursor,
|
|
24
|
+
count: PositiveInt
|
|
25
|
+
}),
|
|
26
|
+
Schema.TaggedStruct("Range", {
|
|
27
|
+
from: TranscriptCursor,
|
|
28
|
+
to: TranscriptCursor
|
|
29
|
+
}).check(Schema.makeFilter((range) => range.from.incarnation === range.to.incarnation && range.from.version === range.to.version || "a range is scoped to one incarnation and version"), Schema.makeFilter((range) => TranscriptOrder(orderKeyOfCursor(range.from), orderKeyOfCursor(range.to)) <= 0 || "a range starts at or before its end"))
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Bounds on one window. `maxRecords` caps top-level records (a selector's `count` is further
|
|
33
|
+
* capped by it); `maxBytes` caps the whole response, dependencies included; bodies above
|
|
34
|
+
* `maxInlineBodyBytes` are sent as references.
|
|
35
|
+
*/
|
|
36
|
+
const TranscriptWindowLimits = Schema.Struct({
|
|
37
|
+
maxRecords: PositiveInt,
|
|
38
|
+
maxBytes: PositiveInt,
|
|
39
|
+
maxInlineBodyBytes: NonNegativeInt
|
|
40
|
+
});
|
|
41
|
+
/** Default bounds: the first window holds 100 top-level records (design decision 4). */
|
|
42
|
+
const defaultTranscriptWindowLimits = {
|
|
43
|
+
maxRecords: 100,
|
|
44
|
+
maxBytes: 1048576,
|
|
45
|
+
maxInlineBodyBytes: 16384
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Whether the window is the current interpretation of the log, and if not, why its cut is
|
|
49
|
+
* behind.
|
|
50
|
+
*
|
|
51
|
+
* Every state other than `Ready` is a degraded read and obeys one rule: the response contains
|
|
52
|
+
* nothing newer than `throughSeq` — no newer pending users, session context or live content.
|
|
53
|
+
*/
|
|
54
|
+
const KnownReadiness = Schema.TaggedUnion({
|
|
55
|
+
/** The active version is healthy and projected through the log head at read time. */
|
|
56
|
+
Ready: {},
|
|
57
|
+
/** The active version failed while projecting `failedAtSeq`; this is its last good cut. */
|
|
58
|
+
Degraded: {
|
|
59
|
+
failedAtSeq: SequenceNumber,
|
|
60
|
+
error: Schema.String
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* The active version is no longer carried by this release; history is being rebuilt under
|
|
64
|
+
* the current definition, and clients receive one replacement when it activates.
|
|
65
|
+
*/
|
|
66
|
+
UpdatingHistory: {},
|
|
67
|
+
/** No version is servable yet; the window is empty. */
|
|
68
|
+
Building: {},
|
|
69
|
+
/**
|
|
70
|
+
* A stored row of the served version cannot be decoded by this release. Nothing is served
|
|
71
|
+
* until a rebuild finishes, rather than a wrong view; the window is empty.
|
|
72
|
+
*/
|
|
73
|
+
Unreadable: { error: Schema.String },
|
|
74
|
+
/** A readiness this reader does not know; treated as degraded. */
|
|
75
|
+
Unknown: { readinessType: Schema.String }
|
|
76
|
+
});
|
|
77
|
+
const knownReadinessTags = /* @__PURE__ */ new Set([
|
|
78
|
+
"Ready",
|
|
79
|
+
"Degraded",
|
|
80
|
+
"UpdatingHistory",
|
|
81
|
+
"Building",
|
|
82
|
+
"Unreadable",
|
|
83
|
+
"Unknown"
|
|
84
|
+
]);
|
|
85
|
+
const UnrecognizedReadiness = Schema.Struct({ _tag: Schema.String.check(Schema.makeFilter((tag) => !knownReadinessTags.has(tag) || "a known readiness must decode as that readiness")) }).pipe(Schema.decodeTo(Schema.toType(KnownReadiness.cases.Unknown), {
|
|
86
|
+
decode: SchemaGetter.transform((readiness) => ({
|
|
87
|
+
_tag: "Unknown",
|
|
88
|
+
readinessType: readiness._tag
|
|
89
|
+
})),
|
|
90
|
+
encode: SchemaGetter.transform((readiness) => ({ _tag: readiness.readinessType }))
|
|
91
|
+
}));
|
|
92
|
+
/**
|
|
93
|
+
* Whether the window is the current interpretation of the log. A readiness this reader does not
|
|
94
|
+
* know decodes as `Unknown` and is treated as degraded: it carries no live content. A malformed
|
|
95
|
+
* readiness with a known tag is a decode failure.
|
|
96
|
+
*/
|
|
97
|
+
const TranscriptReadiness = Schema.Union([KnownReadiness, UnrecognizedReadiness]);
|
|
98
|
+
/**
|
|
99
|
+
* Accumulated parts of the inference streaming now, captured at the same publication boundary as
|
|
100
|
+
* the window. Owned by the live runtime; storage-level reads never include it.
|
|
101
|
+
*/
|
|
102
|
+
const TranscriptActiveContent = Schema.Struct({
|
|
103
|
+
assistantId: InferenceAssistantRecordId,
|
|
104
|
+
parts: Schema.Array(TranscriptAssistantPart)
|
|
105
|
+
});
|
|
106
|
+
const recordUpdatedSeq = (record) => record.updatedSeq;
|
|
107
|
+
const recordPosition = (record) => "position" in record ? record.position : void 0;
|
|
108
|
+
/** Positioned history, which is served only as a top-level record and never as a dependency. */
|
|
109
|
+
const isHistoryRecord = (record) => record.kind === "unknown" ? record.position !== void 0 : isTopLevelTranscriptRecord(record);
|
|
110
|
+
/**
|
|
111
|
+
* One complete, consistent read of a transcript version.
|
|
112
|
+
*
|
|
113
|
+
* `records` are top-level records in transcript order; `dependencies` are the tools and run
|
|
114
|
+
* groups they reference, the session context, and every pending user record. Every record is
|
|
115
|
+
* projected through `throughSeq` and none is newer, which is what makes a cut complete. A client
|
|
116
|
+
* replaces, never merges, what a window covers.
|
|
117
|
+
*/
|
|
118
|
+
const TranscriptWindow = Schema.Struct({
|
|
119
|
+
incarnation: TranscriptLogIncarnation,
|
|
120
|
+
version: TranscriptVersion,
|
|
121
|
+
throughSeq: SequenceNumber,
|
|
122
|
+
records: Schema.Array(TranscriptRecordViewFromEnvelope),
|
|
123
|
+
dependencies: Schema.Array(TranscriptRecordViewFromEnvelope),
|
|
124
|
+
activeContent: Schema.optionalKey(Schema.Array(TranscriptActiveContent)),
|
|
125
|
+
hasOlder: Schema.Boolean,
|
|
126
|
+
hasNewer: Schema.Boolean,
|
|
127
|
+
readiness: TranscriptReadiness
|
|
128
|
+
}).check(Schema.makeFilter((window) => [...window.records, ...window.dependencies].every((record) => recordUpdatedSeq(record) <= window.throughSeq) || "every record must be projected through throughSeq and none may be newer"), Schema.makeFilter((window) => window.readiness._tag === "Ready" || window.activeContent === void 0 || "a degraded read never attaches live content"), Schema.makeFilter((window) => window.readiness._tag !== "Degraded" || window.readiness.failedAtSeq > window.throughSeq || "a degraded cut ends before the seq that failed"), Schema.makeFilter((window) => [...window.records, ...window.dependencies].every((record) => record.kind !== "decorationBuffer" && (record.kind !== "unknown" || record.originalKind !== "decorationBuffer")) || "decoration buffers are never served"), Schema.makeFilter((window) => {
|
|
129
|
+
const ids = [...window.records, ...window.dependencies].map((record) => record.id);
|
|
130
|
+
return new Set(ids).size === ids.length || "a record is served at most once";
|
|
131
|
+
}), Schema.makeFilter((window) => window.records.every((record, index) => {
|
|
132
|
+
const position = recordPosition(record);
|
|
133
|
+
if (position === void 0 || !isHistoryRecord(record)) return false;
|
|
134
|
+
const previous = index === 0 ? void 0 : window.records[index - 1];
|
|
135
|
+
const previousPosition = previous === void 0 ? void 0 : recordPosition(previous);
|
|
136
|
+
return previous === void 0 || previousPosition === void 0 || TranscriptOrder({
|
|
137
|
+
...previousPosition,
|
|
138
|
+
recordId: previous.id
|
|
139
|
+
}, {
|
|
140
|
+
...position,
|
|
141
|
+
recordId: record.id
|
|
142
|
+
}) < 0;
|
|
143
|
+
}) || "records are positioned history records in transcript order"), Schema.makeFilter((window) => window.dependencies.every((record) => !isHistoryRecord(record)) || "dependencies never contain history records"), Schema.makeFilter((window) => window.dependencies.every((record) => record.kind !== "user" || isPendingTranscriptUserRecord(record)) || "the only user dependencies are pending users; cancelled users are never served"), Schema.makeFilter((window) => window.readiness._tag !== "Building" && window.readiness._tag !== "Unreadable" || window.records.length === 0 && window.dependencies.length === 0 && !window.hasOlder && !window.hasNewer || "a building or unreadable window is empty"));
|
|
144
|
+
/** Paging cursor for one top-level record of a window. */
|
|
145
|
+
const transcriptCursorOf = (window, record) => {
|
|
146
|
+
const position = "position" in record ? record.position : void 0;
|
|
147
|
+
return position === void 0 ? void 0 : {
|
|
148
|
+
incarnation: window.incarnation,
|
|
149
|
+
version: window.version,
|
|
150
|
+
anchorSeq: position.anchorSeq,
|
|
151
|
+
ordinal: position.ordinal,
|
|
152
|
+
recordId: record.id
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
/** Health of one stored transcript version. A failed version is frozen at its last good cursor. */
|
|
156
|
+
const TranscriptVersionStatus = Schema.TaggedUnion({
|
|
157
|
+
Ok: {},
|
|
158
|
+
Failed: {
|
|
159
|
+
failedAtSeq: SequenceNumber,
|
|
160
|
+
error: Schema.String
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
/**
|
|
164
|
+
* Per-version maintenance state, one per version present in a session's storage.
|
|
165
|
+
*
|
|
166
|
+
* `cursor` is the last fully projected seq, committed together with that version's rows. At most
|
|
167
|
+
* one version is `active` (served) and at most one is `building` (catching up from the log).
|
|
168
|
+
*/
|
|
169
|
+
const TranscriptVersionMeta = Schema.Struct({
|
|
170
|
+
version: TranscriptVersion,
|
|
171
|
+
role: Schema.Literals(["active", "building"]),
|
|
172
|
+
cursor: SequenceNumber,
|
|
173
|
+
status: TranscriptVersionStatus
|
|
174
|
+
}).check(Schema.makeFilter((meta) => meta.status._tag !== "Failed" || meta.status.failedAtSeq > meta.cursor || "a failed version is frozen before the seq that failed"));
|
|
175
|
+
//#endregion
|
|
176
|
+
export { AssistantRecordId, CompactionRecordId, DecorationBufferRecordId, EDATranscriptStore, ImportAssistantRecordId, InferenceAssistantRecordId, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptClassification, TranscriptCompactionRecord, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordViewFromEnvelope, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptUnknownRecord, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptWindowLimits, emptyTranscriptMappings, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, readTranscriptWindowFrom, runGroupStatus, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit };
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=transcript.js.map
|