effect-durable-agent 0.1.0-alpha.5 → 0.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{command-queues-Dwdf41mq.d.ts → command-queues-C8muEqeQ.d.ts} +2 -2
- package/dist/{compaction-DpHOf-g7.d.ts → compaction-D7W0-Ur1.d.ts} +4 -4
- package/dist/{context-projection-B4DWOZgi.d.ts → context-projection-C43pyxn2.d.ts} +2 -2
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/context-projection.d.ts +1 -1
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/reduced-state.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{message-transcript-CFn_D3MH.d.ts → message-transcript-DsKTT47f.d.ts} +3 -3
- package/dist/{prompt-projector-C2meuNrV.d.ts → prompt-projector-hqPh5-NI.d.ts} +4 -4
- package/dist/{reducer-registry-K9FqZq5-.d.ts → reducer-registry--vQFATXb.d.ts} +16 -6
- package/dist/{runtime-5NEJngu3.d.ts → runtime-DXvMCq-J.d.ts} +7 -10
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/prompt-projector.d.ts +1 -1
- package/dist/services/reducer-registry.d.ts +2 -2
- package/dist/services/reducer-registry.js +7 -3
- package/dist/services/reducer-registry.js.map +1 -1
- package/dist/services/runtime-layer.d.ts +12 -9
- package/dist/services/runtime-layer.js +6 -4
- package/dist/services/runtime-layer.js.map +1 -1
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +2 -5
- package/dist/services/runtime.js.map +1 -1
- package/dist/services/session-event-observer.d.ts +2 -0
- package/dist/services/session-event-observer.js +13 -0
- package/dist/services/session-event-observer.js.map +1 -0
- package/dist/services/session-query.d.ts +2 -2
- package/dist/services/session-query.js +5 -5
- package/dist/services/session-query.js.map +1 -1
- package/dist/services/session-state.d.ts +1 -1
- package/dist/services/session-state.js +1 -1
- package/dist/services/session-store.d.ts +1 -1
- package/dist/services/session-store.js +1 -1
- 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/span-names.d.ts +1 -1
- package/dist/services/span-names.js +1 -1
- package/dist/services/span-names.js.map +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/services/tracing.js +23 -2
- package/dist/services/tracing.js.map +1 -1
- package/dist/session-event-observer-D_aoFnQs.d.ts +24 -0
- package/dist/{session-query-5oyZRaQL.d.ts → session-query-lUZQpMvM.d.ts} +11 -11
- package/dist/{session-state-CI1xeT6f.d.ts → session-state-Bi3oEbJU.d.ts} +10 -10
- package/dist/{session-state-D7dqko7r.js → session-state-C4m0j6CJ.js} +3 -3
- package/dist/{session-state-D7dqko7r.js.map → session-state-C4m0j6CJ.js.map} +1 -1
- package/dist/{session-store-BLg6UvZa.d.ts → session-store-ofm8FFxs.d.ts} +2 -2
- package/dist/{sink-checkpoint-store-B9WNvDtY.d.ts → sink-checkpoint-store-BQVbI9DQ.d.ts} +2 -2
- package/dist/{sink-registry-CO3YPS1p.d.ts → sink-registry-CE-hL7cB.d.ts} +11 -19
- package/dist/{sink-registry-BbmoI9uv.js → sink-registry-DH6uiEgP.js} +14 -9
- package/dist/sink-registry-DH6uiEgP.js.map +1 -0
- package/dist/testkit/layers.d.ts +10 -10
- package/dist/testkit/layers.js +4 -4
- package/dist/testkit/layers.js.map +1 -1
- package/dist/{tool-registry-B8H1P6Pu.d.ts → tool-registry-ClHdr_G5.d.ts} +2 -2
- package/dist/{websocket-wire-DPxwY4G5.d.ts → websocket.d.ts} +316 -4
- package/dist/websocket.js +497 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +8 -12
- package/dist/host/websocket-protocol.d.ts +0 -252
- package/dist/host/websocket-protocol.js +0 -111
- package/dist/host/websocket-protocol.js.map +0 -1
- package/dist/host/websocket-wire.d.ts +0 -2
- package/dist/host/websocket-wire.js +0 -122
- package/dist/host/websocket-wire.js.map +0 -1
- package/dist/services/websocket-delivery.d.ts +0 -90
- package/dist/services/websocket-delivery.js +0 -221
- package/dist/services/websocket-delivery.js.map +0 -1
- package/dist/sink-registry-BbmoI9uv.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-query.js","names":[],"sources":["../../src/services/session-query.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as PubSub from \"effect/PubSub\";\nimport type * as Scope from \"effect/Scope\";\nimport * as Stream from \"effect/Stream\";\n\nimport { durableMessageTranscript } from \"../domain/message-transcript\";\nimport type { DurableTranscriptMessage } from \"../domain/message-transcript\";\nimport type { ReducedState } from \"../domain/reduced-state\";\nimport type { EDAReducerStateSnapshot } from \"./reducer-registry\";\nimport { SequenceNumber } from \"../types/core\";\nimport { PositionedEvent } from \"../types/events\";\nimport { EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { SessionState } from \"./session-state\";\nimport { annotateEdaSpan } from \"./tracing\";\n\n/** Authoritative live snapshot for one EDA session plus its derived durable transcript. */\nexport interface EDASessionSnapshot {\n readonly state: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n readonly messages: ReadonlyArray<DurableTranscriptMessage>;\n}\n\n/** Read-only query facade over authoritative live state and reconnect-safe event streams. */\nexport interface EDASessionQueryShape {\n /** Read the authoritative live state and derive its durable transcript. */\n readonly snapshot: () => Effect.Effect<EDASessionSnapshot, EDASessionStoreError>;\n /** Read durable user/assistant messages in committed sequence order from the live snapshot. */\n readonly messages: () => Effect.Effect<\n ReadonlyArray<DurableTranscriptMessage>,\n EDASessionStoreError\n >;\n /** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */\n readonly eventsAfter: (\n afterSeq: SequenceNumber,\n ) => Effect.Effect<\n Stream.Stream<PositionedEvent, EDASessionStoreError>,\n EDASessionStoreError,\n Scope.Scope\n >;\n /** Read one bounded committed durable slice after `afterSeq` plus the committed head. */\n readonly
|
|
1
|
+
{"version":3,"file":"session-query.js","names":[],"sources":["../../src/services/session-query.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as PubSub from \"effect/PubSub\";\nimport type * as Scope from \"effect/Scope\";\nimport * as Stream from \"effect/Stream\";\n\nimport { durableMessageTranscript } from \"../domain/message-transcript\";\nimport type { DurableTranscriptMessage } from \"../domain/message-transcript\";\nimport type { ReducedState } from \"../domain/reduced-state\";\nimport type { EDAReducerStateSnapshot } from \"./reducer-registry\";\nimport { SequenceNumber } from \"../types/core\";\nimport { PositionedEvent } from \"../types/events\";\nimport { EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { LiveEventBus } from \"./live-event-bus\";\nimport { SessionState } from \"./session-state\";\nimport { annotateEdaSpan } from \"./tracing\";\n\n/** Authoritative live snapshot for one EDA session plus its derived durable transcript. */\nexport interface EDASessionSnapshot {\n readonly state: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n readonly messages: ReadonlyArray<DurableTranscriptMessage>;\n}\n\n/** Read-only query facade over authoritative live state and reconnect-safe event streams. */\nexport interface EDASessionQueryShape {\n /** Read the authoritative live state and derive its durable transcript. */\n readonly snapshot: () => Effect.Effect<EDASessionSnapshot, EDASessionStoreError>;\n /** Read durable user/assistant messages in committed sequence order from the live snapshot. */\n readonly messages: () => Effect.Effect<\n ReadonlyArray<DurableTranscriptMessage>,\n EDASessionStoreError\n >;\n /** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */\n readonly eventsAfter: (\n afterSeq: SequenceNumber,\n ) => Effect.Effect<\n Stream.Stream<PositionedEvent, EDASessionStoreError>,\n EDASessionStoreError,\n Scope.Scope\n >;\n /** Read one bounded committed durable slice after `afterSeq` plus the committed head. */\n readonly readEventPage: (\n afterSeq: SequenceNumber,\n limit: number,\n ) => Effect.Effect<EDASessionEventPage, EDASessionStoreError>;\n}\n\n/** Bounded committed durable event page for pull-based host delivery. */\nexport interface EDASessionEventPage {\n readonly events: ReadonlyArray<PositionedEvent>;\n readonly head: SequenceNumber;\n}\n\n/** Read-only session query facade backed by authoritative SessionState plus durable backfill. */\nexport class EDASessionQuery extends Context.Service<EDASessionQuery, EDASessionQueryShape>()(\n \"@effect-durable-agent/EDASessionQuery\",\n) {\n static readonly Live = Layer.effect(\n EDASessionQuery,\n Effect.gen(function* () {\n const store = yield* EDASessionStore;\n const liveBus = yield* LiveEventBus;\n const sessionState = yield* SessionState;\n\n const snapshot = Effect.gen(function* () {\n const data = yield* sessionState.snapshotData();\n return {\n state: data.reduced,\n reducerStates: data.reducerStates,\n messages: durableMessageTranscript(data.reduced),\n } satisfies EDASessionSnapshot;\n });\n\n return {\n snapshot: () => snapshot,\n messages: () => snapshot.pipe(Effect.map((snapshot) => snapshot.messages)),\n eventsAfter: (afterSeq: SequenceNumber) =>\n Effect.gen(function* () {\n const live = yield* liveBus.subscribeQueue();\n const replayHead = (yield* sessionState.snapshot()).lastSeq;\n // TODO(backpressure): this runCollect drains the store stream eagerly and buffers the\n // whole durable reconnect prefix, defeating host-level paged replay/backpressure for\n // slow clients. Stream this prefix into the live follow stream instead.\n const replay = yield* store.eventsAfter(afterSeq).pipe(\n Stream.filter((entry) => entry.position.seq <= replayHead),\n Stream.map((entry) =>\n PositionedEvent.make({ position: entry.position, event: entry.event }),\n ),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n const activeTurnReplay = yield* liveBus.activeTurnReplay();\n const pendingLive = (yield* PubSub.takeUpTo(live, Number.POSITIVE_INFINITY)).filter(\n (event) => shouldEmitLiveEvent(event, replayHead),\n );\n const reconnectPrefix: ReadonlyArray<PositionedEvent> = Array.from(\n uniquePositionedEvents([...replay, ...activeTurnReplay.events, ...pendingLive]),\n ).sort(comparePositionedEvents);\n yield* annotateEdaSpan({\n \"eda.seq.after\": afterSeq,\n \"eda.seq.head\": replayHead,\n \"eda.replay.events\": replay.length,\n \"eda.live.active_turn_events\": activeTurnReplay.events.length,\n \"eda.live.active_turn_overflowed\": activeTurnReplay.overflowed,\n \"eda.live.buffered_events\": pendingLive.length,\n });\n const follow: Stream.Stream<PositionedEvent> = Stream.fromEffectRepeat(\n PubSub.take(live),\n ).pipe(Stream.filter((event) => shouldEmitLiveEvent(event, replayHead)));\n return Stream.fromIterable(reconnectPrefix).pipe(Stream.concat(follow));\n }).pipe(\n Effect.withSpan(\"agent.events.follow\", {\n attributes: { \"eda.seq.after\": afterSeq },\n }),\n ),\n readEventPage: (afterSeq: SequenceNumber, limit: number) =>\n Effect.gen(function* () {\n const head = (yield* sessionState.snapshot()).lastSeq;\n if (limit <= 0 || afterSeq >= head) {\n return { events: [], head } satisfies EDASessionEventPage;\n }\n const events = yield* store.eventsAfter(afterSeq).pipe(\n Stream.filter((entry) => entry.position.seq <= head),\n Stream.take(limit),\n Stream.map((entry) =>\n PositionedEvent.make({ position: entry.position, event: entry.event }),\n ),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n return { events, head } satisfies EDASessionEventPage;\n }).pipe(\n Effect.withSpan(\"agent.events.page\", {\n attributes: { \"eda.seq.after\": afterSeq, \"eda.page.limit\": limit },\n }),\n ),\n };\n }),\n );\n}\n\nconst shouldEmitLiveEvent = (event: PositionedEvent, replayHead: SequenceNumber): boolean =>\n event.event.durability === \"ephemeral\" || event.position.seq > replayHead;\n\nconst comparePositionedEvents = (left: PositionedEvent, right: PositionedEvent): number => {\n const seq = left.position.seq - right.position.seq;\n return seq === 0 ? left.position.subSeq - right.position.subSeq : seq;\n};\n\nconst uniquePositionedEvents = (\n events: ReadonlyArray<PositionedEvent>,\n): ReadonlyArray<PositionedEvent> => {\n const seen = new Set<string>();\n const output: PositionedEvent[] = [];\n for (const event of events) {\n const key = `${event.position.seq}:${event.position.subSeq}:${event.event.eventId}`;\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n output.push(event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AAM,SAA4B,CAAC;CACnC,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,MAAM,GAAG,MAAM,SAAS,IAAI,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM,MAAM;EAC1E,IAAI,KAAK,IAAI,GAAG,GACd;EAEF,KAAK,IAAI,GAAG;EACZ,OAAO,KAAK,KAAK;CACnB;CACA,OAAO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as SessionStateShape, a as SessionCommandCompleted, c as SessionCommandResult, d as SessionForkedCommand, f as SessionNoRunnableCommand, g as SessionStateError, h as SessionState, i as SessionCommandCancelled, l as SessionDrainProcessed, m as SessionRunInput, n as SessionCommandAdmissionConflict, o as SessionCommandFailed, p as SessionNoRunnableReason, r as SessionCommandAdmissionError, s as SessionCommandOutcome, t as EDASubmittable, u as SessionDrainResult, v as SessionStateSnapshotData } from "../session-state-
|
|
1
|
+
import { _ as SessionStateShape, a as SessionCommandCompleted, c as SessionCommandResult, d as SessionForkedCommand, f as SessionNoRunnableCommand, g as SessionStateError, h as SessionState, i as SessionCommandCancelled, l as SessionDrainProcessed, m as SessionRunInput, n as SessionCommandAdmissionConflict, o as SessionCommandFailed, p as SessionNoRunnableReason, r as SessionCommandAdmissionError, s as SessionCommandOutcome, t as EDASubmittable, u as SessionDrainResult, v as SessionStateSnapshotData } from "../session-state-Bi3oEbJU.js";
|
|
2
2
|
export { EDASubmittable, SessionCommandAdmissionConflict, SessionCommandAdmissionError, SessionCommandCancelled, SessionCommandCompleted, SessionCommandFailed, SessionCommandOutcome, SessionCommandResult, SessionDrainProcessed, SessionDrainResult, SessionForkedCommand, SessionNoRunnableCommand, SessionNoRunnableReason, SessionRunInput, SessionState, SessionStateError, SessionStateShape, SessionStateSnapshotData };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SessionCommandOutcome, c as SessionNoRunnableReason, i as SessionCommandFailed, l as SessionRunInput, n as SessionCommandCancelled, o as SessionForkedCommand, r as SessionCommandCompleted, s as SessionNoRunnableCommand, t as SessionCommandAdmissionConflict, u as SessionState } from "../session-state-
|
|
1
|
+
import { a as SessionCommandOutcome, c as SessionNoRunnableReason, i as SessionCommandFailed, l as SessionRunInput, n as SessionCommandCancelled, o as SessionForkedCommand, r as SessionCommandCompleted, s as SessionNoRunnableCommand, t as SessionCommandAdmissionConflict, u as SessionState } from "../session-state-C4m0j6CJ.js";
|
|
2
2
|
export { SessionCommandAdmissionConflict, SessionCommandCancelled, SessionCommandCompleted, SessionCommandFailed, SessionCommandOutcome, SessionForkedCommand, SessionNoRunnableCommand, SessionNoRunnableReason, SessionRunInput, SessionState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as EDASessionStore, c as FindCommandAdmissionInput, i as EDAReducerCheckpoint, l as SaveReducerCheckpointInput, n as DurableAppendBatch, o as EDASessionStoreError, r as DurableAppendEntry, s as EDASessionStoreShape, t as CommittedDurableEvent, u as hasEDASessionStoreError } from "../session-store-
|
|
1
|
+
import { a as EDASessionStore, c as FindCommandAdmissionInput, i as EDAReducerCheckpoint, l as SaveReducerCheckpointInput, n as DurableAppendBatch, o as EDASessionStoreError, r as DurableAppendEntry, s as EDASessionStoreShape, t as CommittedDurableEvent, u as hasEDASessionStoreError } from "../session-store-ofm8FFxs.js";
|
|
2
2
|
export { CommittedDurableEvent, DurableAppendBatch, DurableAppendEntry, EDAReducerCheckpoint, EDASessionStore, EDASessionStoreError, EDASessionStoreShape, FindCommandAdmissionInput, SaveReducerCheckpointInput, hasEDASessionStoreError };
|
|
@@ -6,8 +6,8 @@ import * as Effect from "effect/Effect";
|
|
|
6
6
|
import * as Layer from "effect/Layer";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import * as Stream from "effect/Stream";
|
|
9
|
-
import * as Ref from "effect/Ref";
|
|
10
9
|
import * as Cause from "effect/Cause";
|
|
10
|
+
import * as Ref from "effect/Ref";
|
|
11
11
|
//#region src/services/session-store.ts
|
|
12
12
|
/** A durable event after the store has assigned its replay position. */
|
|
13
13
|
const CommittedDurableEvent = Schema.Struct({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as StoredSinkCheckpoint, n as SinkCheckpointStore, r as SinkCheckpointStoreShape, t as EDASinkName } from "../sink-checkpoint-store-
|
|
1
|
+
import { i as StoredSinkCheckpoint, n as SinkCheckpointStore, r as SinkCheckpointStoreShape, t as EDASinkName } from "../sink-checkpoint-store-BQVbI9DQ.js";
|
|
2
2
|
export { EDASinkName, SinkCheckpointStore, SinkCheckpointStoreShape, StoredSinkCheckpoint };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as EDASinkContext, c as EDASinkRegistryShape, i as EDASinkCheckpoint, l as EDASinkRunnerStartInput, n as EDAEphemeralSinkDefinition, o as EDASinkDurableBatch, r as EDASink, s as EDASinkRegistry, t as EDADurableSinkDefinition } from "../sink-registry-
|
|
1
|
+
import { a as EDASinkContext, c as EDASinkRegistryShape, i as EDASinkCheckpoint, l as EDASinkRunnerStartInput, n as EDAEphemeralSinkDefinition, o as EDASinkDurableBatch, r as EDASink, s as EDASinkRegistry, t as EDADurableSinkDefinition } from "../sink-registry-CE-hL7cB.js";
|
|
2
2
|
export { EDADurableSinkDefinition, EDAEphemeralSinkDefinition, EDASink, EDASinkCheckpoint, EDASinkContext, EDASinkDurableBatch, EDASinkRegistry, EDASinkRegistryShape, EDASinkRunnerStartInput };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as EDASinkRegistry, t as EDASink } from "../sink-registry-
|
|
1
|
+
import { n as EDASinkRegistry, t as EDASink } from "../sink-registry-DH6uiEgP.js";
|
|
2
2
|
export { EDASink, EDASinkRegistry };
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*
|
|
21
21
|
* Application-specific operations belong in the application catalog, not this reusable catalog.
|
|
22
22
|
*/
|
|
23
|
-
declare const SpanNames: readonly ["agent.command.submit", "agent.command.submit.wait", "agent.command.wait", "agent.compaction", "agent.events.follow", "agent.events.
|
|
23
|
+
declare const SpanNames: readonly ["agent.command.submit", "agent.command.submit.wait", "agent.command.wait", "agent.compaction", "agent.events.follow", "agent.events.page", "agent.events.stream", "agent.inference", "agent.messages.list", "agent.run", "agent.session.snapshot", "agent.sink.drain", "agent.tool", "agent.turn"];
|
|
24
24
|
/** Union of values admitted by the centralized EDA span-name catalog. */
|
|
25
25
|
type SpanName = (typeof SpanNames)[number];
|
|
26
26
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span-names.js","names":[],"sources":["../../src/services/span-names.ts"],"sourcesContent":["type CanonicalSpanName = `${string}.${string}`;\n\nconst defineSpanNames = <const Names extends ReadonlyArray<CanonicalSpanName>>(\n names: Names,\n): Names => names;\n\n/**\n * Allowlist of meaningful spans owned by the reusable durable-agent runtime.\n *\n * Add a name only when the span:\n * - represents a recognizable agent operation in the end-to-end execution flow;\n * - owns non-trivial work whose duration, failure, or interruption is useful to diagnose; and\n * - has a lifetime that matches that work rather than acting as an instantaneous marker.\n *\n * Names are stable, lowercase, dot-separated semantic paths. Start with the owning subsystem and\n * move from general to specific, ending with the operation, for example `agent.command.submit`.\n * Describe domain work, not TypeScript symbols, class names, EDA prefixes, or helper mechanics.\n * Keep names low-cardinality: IDs, tool or sink names, providers, models, attempts, and outcomes are\n * span attributes, never name segments.\n *\n * Prefer `Effect.fn(\"...\")` when a function owns the operation and `Effect.withSpan(\"...\")` around\n * an existing effect boundary. Do not add spans for pure transforms, bookkeeping, condition checks,\n * retry-delay calculations, or other near-zero-width implementation steps. Use unnamed `Effect.fn`\n * when a function benefits from Effect structure but would not add a useful node to the trace.\n *\n * Application-specific operations belong in the application catalog, not this reusable catalog.\n */\nexport const SpanNames = defineSpanNames([\n \"agent.command.submit\",\n \"agent.command.submit.wait\",\n \"agent.command.wait\",\n \"agent.compaction\",\n \"agent.events.follow\",\n \"agent.events.
|
|
1
|
+
{"version":3,"file":"span-names.js","names":[],"sources":["../../src/services/span-names.ts"],"sourcesContent":["type CanonicalSpanName = `${string}.${string}`;\n\nconst defineSpanNames = <const Names extends ReadonlyArray<CanonicalSpanName>>(\n names: Names,\n): Names => names;\n\n/**\n * Allowlist of meaningful spans owned by the reusable durable-agent runtime.\n *\n * Add a name only when the span:\n * - represents a recognizable agent operation in the end-to-end execution flow;\n * - owns non-trivial work whose duration, failure, or interruption is useful to diagnose; and\n * - has a lifetime that matches that work rather than acting as an instantaneous marker.\n *\n * Names are stable, lowercase, dot-separated semantic paths. Start with the owning subsystem and\n * move from general to specific, ending with the operation, for example `agent.command.submit`.\n * Describe domain work, not TypeScript symbols, class names, EDA prefixes, or helper mechanics.\n * Keep names low-cardinality: IDs, tool or sink names, providers, models, attempts, and outcomes are\n * span attributes, never name segments.\n *\n * Prefer `Effect.fn(\"...\")` when a function owns the operation and `Effect.withSpan(\"...\")` around\n * an existing effect boundary. Do not add spans for pure transforms, bookkeeping, condition checks,\n * retry-delay calculations, or other near-zero-width implementation steps. Use unnamed `Effect.fn`\n * when a function benefits from Effect structure but would not add a useful node to the trace.\n *\n * Application-specific operations belong in the application catalog, not this reusable catalog.\n */\nexport const SpanNames = defineSpanNames([\n \"agent.command.submit\",\n \"agent.command.submit.wait\",\n \"agent.command.wait\",\n \"agent.compaction\",\n \"agent.events.follow\",\n \"agent.events.page\",\n \"agent.events.stream\",\n \"agent.inference\",\n \"agent.messages.list\",\n \"agent.run\",\n \"agent.session.snapshot\",\n \"agent.sink.drain\",\n \"agent.tool\",\n \"agent.turn\",\n]);\n\n/** Union of values admitted by the centralized EDA span-name catalog. */\nexport type SpanName = (typeof SpanNames)[number];\n"],"mappings":";AAEA,MAAM,mBACJ,UACU;;;;;;;;;;;;;;;;;;;;;;AAuBZ,MAAa,YAAY,gBAAgB;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ToolParamsSchema, i as EDAToolRegistryShape, n as EDAToolExecutionContext, o as makeEDAToolkit, r as EDAToolRegistry, t as EDAModelToolkit } from "../tool-registry-
|
|
1
|
+
import { a as ToolParamsSchema, i as EDAToolRegistryShape, n as EDAToolExecutionContext, o as makeEDAToolkit, r as EDAToolRegistry, t as EDAModelToolkit } from "../tool-registry-ClHdr_G5.js";
|
|
2
2
|
export { EDAModelToolkit, EDAToolExecutionContext, EDAToolRegistry, EDAToolRegistryShape, ToolParamsSchema, makeEDAToolkit };
|
package/dist/services/tracing.js
CHANGED
|
@@ -5,6 +5,8 @@ import * as Exit from "effect/Exit";
|
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
6
|
import * as Tracer from "effect/Tracer";
|
|
7
7
|
//#region src/services/tracing.ts
|
|
8
|
+
/** Maximum primitive attributes copied from one native Effect span or link. */
|
|
9
|
+
const MAX_EXPORTED_SPAN_ATTRIBUTES = 256;
|
|
8
10
|
/** Compact undefined tracing attributes before handing them to Effect spans. */
|
|
9
11
|
const compactSpanAttributes = (attributes) => {
|
|
10
12
|
const compacted = {};
|
|
@@ -12,9 +14,28 @@ const compactSpanAttributes = (attributes) => {
|
|
|
12
14
|
return compacted;
|
|
13
15
|
};
|
|
14
16
|
const compactUnknownAttributes = (attributes) => {
|
|
15
|
-
const entries = attributes instanceof Map ? attributes.entries() : Object.entries(attributes);
|
|
16
17
|
const compacted = {};
|
|
17
|
-
|
|
18
|
+
try {
|
|
19
|
+
if (attributes instanceof Map) {
|
|
20
|
+
let count = 0;
|
|
21
|
+
for (const [key, value] of attributes) {
|
|
22
|
+
if (count >= MAX_EXPORTED_SPAN_ATTRIBUTES) break;
|
|
23
|
+
count += 1;
|
|
24
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") compacted[key] = value;
|
|
25
|
+
}
|
|
26
|
+
return compacted;
|
|
27
|
+
}
|
|
28
|
+
const keys = Object.keys(attributes).slice(0, MAX_EXPORTED_SPAN_ATTRIBUTES);
|
|
29
|
+
for (const key of keys) {
|
|
30
|
+
let value;
|
|
31
|
+
try {
|
|
32
|
+
value = Reflect.get(attributes, key);
|
|
33
|
+
} catch {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") compacted[key] = value;
|
|
37
|
+
}
|
|
38
|
+
} catch {}
|
|
18
39
|
return compacted;
|
|
19
40
|
};
|
|
20
41
|
const toEdaExternalSpan = (context) => Tracer.externalSpan({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.js","names":["#emit"],"sources":["../../src/services/tracing.ts"],"sourcesContent":["import * as Cause from \"effect/Cause\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport * as Option from \"effect/Option\";\nimport * as Tracer from \"effect/Tracer\";\n\nimport type { UsagePayload } from \"../types/events\";\nimport {\n EDATraceContext,\n type EDAEventTrace,\n type EDATraceAttributeValue,\n type EDATraceMetadata,\n makeEDAEventTrace,\n makeEDATraceContext,\n makeRootEDAEventTrace,\n} from \"../types/tracing\";\n\nexport {\n EDATraceContext,\n EDARunTrace,\n EDATraceLink,\n EDATraceMetadata,\n EDAEventTrace,\n makeEDAEventTrace,\n makeEDARunTrace,\n makeEDATraceContext,\n makeEDATraceMetadataFromParent,\n makeRootEDAEventTrace,\n makeRootEDATraceMetadata,\n} from \"../types/tracing\";\n\nexport { buildEDATraceparent, parseEDATraceparent } from \"../types/tracing\";\n\n/** Attribute value types accepted by Effect span annotations after compaction. */\nexport type EdaSpanAttributeValue = EDATraceAttributeValue | undefined;\n\n/** EDA span attribute map; undefined values are intentionally dropped before annotation. */\nexport type EdaSpanAttributes = Record<string, EdaSpanAttributeValue>;\n\nexport interface EDATracingOptions {\n readonly disableTracing?: boolean;\n readonly disableSpanPropagation?: boolean;\n readonly spanAttributes?: EdaSpanAttributes;\n readonly spanPrefix?: string;\n}\n\nexport interface EDAExportedSpanLink {\n readonly attributes: Record<string, string | number | boolean>;\n readonly sampled: boolean;\n readonly spanId: string;\n readonly traceId: string;\n}\n\nexport interface EDAExportedSpan {\n readonly attributes: Record<string, string | number | boolean>;\n readonly endedAtMs: number;\n readonly endedAtUnixNano: string;\n readonly kind: Tracer.SpanKind;\n readonly links: ReadonlyArray<EDAExportedSpanLink>;\n readonly name: string;\n readonly outcome: \"ok\" | \"error\" | \"timeout\" | \"canceled\";\n readonly parentSpanId?: string;\n readonly sampled: boolean;\n readonly spanId: string;\n readonly startedAtMs: number;\n readonly startedAtUnixNano: string;\n readonly statusCode: \"OK\" | \"ERROR\";\n readonly statusMessage?: string;\n readonly traceId: string;\n}\n\ninterface EventLike {\n readonly event?: { readonly type?: unknown; readonly durability?: unknown };\n readonly type?: unknown;\n}\n\ninterface PositionedEventLike {\n readonly position?: { readonly seq?: unknown; readonly subSeq?: unknown };\n readonly event?: { readonly type?: unknown; readonly durability?: unknown };\n}\n\n/** Compact undefined tracing attributes before handing them to Effect spans. */\nexport const compactSpanAttributes = (\n attributes: EdaSpanAttributes,\n): Record<string, string | number | boolean> => {\n const compacted: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n compacted[key] = value;\n }\n }\n return compacted;\n};\n\nconst compactUnknownAttributes = (\n attributes: Readonly<Record<string, unknown>> | ReadonlyMap<string, unknown>,\n): Record<string, string | number | boolean> => {\n const entries = attributes instanceof Map ? attributes.entries() : Object.entries(attributes);\n const compacted: Record<string, string | number | boolean> = {};\n for (const [key, value] of entries) {\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n compacted[key] = value;\n }\n }\n return compacted;\n};\n\nexport const toEdaExternalSpan = (context: EDATraceContext): Tracer.ExternalSpan =>\n Tracer.externalSpan({\n traceId: context.traceId,\n spanId: context.spanId,\n sampled: context.sampled,\n });\n\nexport const edaTraceContextFromSpan = (span: Tracer.AnySpan): EDATraceContext =>\n makeEDATraceContext({\n traceId: span.traceId,\n spanId: span.spanId,\n sampled: span.sampled,\n tracestate: null,\n });\n\nexport const currentEDATraceContext: Effect.Effect<EDATraceContext, unknown> =\n Effect.currentSpan.pipe(Effect.map(edaTraceContextFromSpan));\n\nexport const currentOrRootEDAEventTrace: Effect.Effect<EDAEventTrace> = Effect.currentSpan.pipe(\n Effect.map((span) => makeEDAEventTrace(edaTraceContextFromSpan(span))),\n Effect.catch(() => Effect.sync(makeRootEDAEventTrace)),\n);\n\nexport const withEdaTraceMetadata =\n (metadata: EDATraceMetadata) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>\n effect.pipe(Effect.annotateSpans(metadata.attributes));\n\n/** Add EDA attributes to the currently active span. */\nexport const annotateEdaSpan = (attributes: EdaSpanAttributes): Effect.Effect<void> =>\n Effect.annotateCurrentSpan(compactSpanAttributes(attributes));\n\nconst nanosToMillis = (nanos: bigint): number => Number(nanos / 1_000_000n);\n\nconst outcomeFromExit = (exit: Exit.Exit<unknown, unknown>): EDAExportedSpan[\"outcome\"] => {\n if (Exit.isSuccess(exit)) {\n return \"ok\";\n }\n return Cause.hasInterruptsOnly(exit.cause) ? \"canceled\" : \"error\";\n};\n\nconst statusMessageFromExit = (exit: Exit.Exit<unknown, unknown>): string | undefined => {\n if (Exit.isSuccess(exit)) {\n return undefined;\n }\n const error = Cause.squash(exit.cause);\n return error instanceof Error ? error.message : String(error);\n};\n\nclass ExportingNativeSpan extends Tracer.NativeSpan {\n readonly #emit: (span: EDAExportedSpan) => void;\n\n constructor(\n options: ConstructorParameters<typeof Tracer.NativeSpan>[0],\n emit: (span: EDAExportedSpan) => void,\n ) {\n super(options);\n this.#emit = emit;\n }\n\n override end(endTime: bigint, exit: Exit.Exit<unknown, unknown>): void {\n super.end(endTime, exit);\n // Workers can report the same clock tick for very fast operations. Such spans\n // add noise without describing execution, so keep them out of exported traces.\n if (endTime <= this.startTime) {\n return;\n }\n const parent = Option.getOrUndefined(this.parent);\n this.#emit({\n attributes: compactUnknownAttributes(this.attributes),\n endedAtMs: nanosToMillis(endTime),\n endedAtUnixNano: endTime.toString(),\n kind: this.kind,\n links: this.links.map((link) => ({\n attributes: compactUnknownAttributes(link.attributes),\n traceId: link.span.traceId,\n spanId: link.span.spanId,\n sampled: link.span.sampled,\n })),\n name: this.name,\n outcome: outcomeFromExit(exit),\n ...(parent === undefined ? {} : { parentSpanId: parent.spanId }),\n sampled: this.sampled,\n spanId: this.spanId,\n startedAtMs: nanosToMillis(this.startTime),\n startedAtUnixNano: this.startTime.toString(),\n statusCode: Exit.isSuccess(exit) ? \"OK\" : \"ERROR\",\n ...(statusMessageFromExit(exit) === undefined\n ? {}\n : { statusMessage: statusMessageFromExit(exit) }),\n traceId: this.traceId,\n });\n }\n}\n\n/** Create an Effect tracer that exports only spans with observable duration. */\nexport const makeEdaExportingTracer = (emit: (span: EDAExportedSpan) => void): Tracer.Tracer =>\n Tracer.make({\n span: (options) => new ExportingNativeSpan(options, emit),\n });\n\n/** Summarize a durable/logical event collection for span attributes. */\nexport const eventBatchAttributes = (events: ReadonlyArray<EventLike>): EdaSpanAttributes => ({\n \"eda.event.count\": events.length,\n \"eda.event.types\": eventTypeSummary(events),\n});\n\n/** Summarize a committed positioned event collection for span attributes. */\nexport const committedBatchAttributes = (\n events: ReadonlyArray<PositionedEventLike>,\n): EdaSpanAttributes => {\n const seqs = events\n .map((entry) => entry.position?.seq)\n .filter((seq): seq is number => typeof seq === \"number\");\n return {\n ...eventBatchAttributes(events),\n \"eda.seq.min\": seqs.length === 0 ? undefined : Math.min(...seqs),\n \"eda.seq.max\": seqs.length === 0 ? undefined : Math.max(...seqs),\n };\n};\n\n/** Stable, low-cardinality usage attributes for model lifecycle spans. */\nexport const usageAttributes = (usage: UsagePayload | undefined): EdaSpanAttributes => ({\n \"eda.usage.input_tokens\": usage?.inputTokens,\n \"eda.usage.cached_input_tokens\": usage?.cachedInputTokens,\n \"eda.usage.output_tokens\": usage?.outputTokens,\n \"eda.usage.text_tokens\": usage?.textTokens,\n \"eda.usage.reasoning_tokens\": usage?.reasoningTokens,\n});\n\nconst eventTypeSummary = (events: ReadonlyArray<EventLike>): string | undefined => {\n if (events.length === 0) {\n return undefined;\n }\n const seen = new Set<string>();\n for (const event of events) {\n const type = event.event?.type ?? event.type;\n if (typeof type === \"string\") {\n seen.add(type);\n }\n }\n return seen.size === 0 ? undefined : Array.from(seen).join(\",\");\n};\n"],"mappings":";;;;;;;;AAkFA,MAAa,yBACX,eAC8C;CAC9C,MAAM,YAAuD,CAAC;CAC9D,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GAClD,IAAI,UAAU,KAAA,GACZ,UAAU,OAAO;CAGrB,OAAO;AACT;AAEA,MAAM,4BACJ,eAC8C;CAC9C,MAAM,UAAU,sBAAsB,MAAM,WAAW,QAAQ,IAAI,OAAO,QAAQ,UAAU;CAC5F,MAAM,YAAuD,CAAC;CAC9D,KAAK,MAAM,CAAC,KAAK,UAAU,SACzB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,UAAU,OAAO;CAGrB,OAAO;AACT;AAEA,MAAa,qBAAqB,YAChC,OAAO,aAAa;CAClB,SAAS,QAAQ;CACjB,QAAQ,QAAQ;CAChB,SAAS,QAAQ;AACnB,CAAC;AAEH,MAAa,2BAA2B,SACtC,oBAAoB;CAClB,SAAS,KAAK;CACd,QAAQ,KAAK;CACb,SAAS,KAAK;CACd,YAAY;AACd,CAAC;AAEH,MAAa,yBACX,OAAO,YAAY,KAAK,OAAO,IAAI,uBAAuB,CAAC;AAE7D,MAAa,6BAA2D,OAAO,YAAY,KACzF,OAAO,KAAK,SAAS,kBAAkB,wBAAwB,IAAI,CAAC,CAAC,GACrE,OAAO,YAAY,OAAO,KAAK,qBAAqB,CAAC,CACvD;AAEA,MAAa,wBACV,cACS,WACR,OAAO,KAAK,OAAO,cAAc,SAAS,UAAU,CAAC;;AAGzD,MAAa,mBAAmB,eAC9B,OAAO,oBAAoB,sBAAsB,U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;CACH;AACF;;AAGA,MAAa,0BAA0B,SACrC,OAAO,KAAK,EACV,OAAO,YAAY,IAAI,oBAAoB,SAAS,IAAI,EAC1D,CAAC;;AAGH,MAAa,wBAAwB,YAAyD;CAC5F,mBAAmB,OAAO;CAC1B,mBAAmB,iBAAiB,MAAM;AAC5C;;AAGA,MAAa,4BACX,WACsB;CACtB,MAAM,OAAO,OACV,KAAK,UAAU,MAAM,UAAU,GAAG,EAClC,QAAQ,QAAuB,OAAO,QAAQ,QAAQ;CACzD,OAAO;EACL,GAAG,qBAAqB,MAAM;EAC9B,eAAe,KAAK,WAAW,IAAI,KAAA,IAAY,KAAK,IAAI,GAAG,IAAI;EAC/D,eAAe,KAAK,WAAW,IAAI,KAAA,IAAY,KAAK,IAAI,GAAG,IAAI;CACjE;AACF;;AAGA,MAAa,mBAAmB,WAAwD;CACtF,0BAA0B,OAAO;CACjC,iCAAiC,OAAO;CACxC,2BAA2B,OAAO;CAClC,yBAAyB,OAAO;CAChC,8BAA8B,OAAO;AACvC;AAEA,MAAM,oBAAoB,WAAyD;CACjF,IAAI,OAAO,WAAW,GACpB;CAEF,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAO,MAAM,OAAO,QAAQ,MAAM;EACxC,IAAI,OAAO,SAAS,UAClB,KAAK,IAAI,IAAI;CAEjB;CACA,OAAO,KAAK,SAAS,IAAI,KAAA,IAAY,MAAM,KAAK,IAAI,EAAE,KAAK,GAAG;AAChE"}
|
|
1
|
+
{"version":3,"file":"tracing.js","names":["#emit"],"sources":["../../src/services/tracing.ts"],"sourcesContent":["import * as Cause from \"effect/Cause\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport * as Option from \"effect/Option\";\nimport * as Tracer from \"effect/Tracer\";\n\nimport type { UsagePayload } from \"../types/events\";\nimport {\n EDATraceContext,\n type EDAEventTrace,\n type EDATraceAttributeValue,\n type EDATraceMetadata,\n makeEDAEventTrace,\n makeEDATraceContext,\n makeRootEDAEventTrace,\n} from \"../types/tracing\";\n\nexport {\n EDATraceContext,\n EDARunTrace,\n EDATraceLink,\n EDATraceMetadata,\n EDAEventTrace,\n makeEDAEventTrace,\n makeEDARunTrace,\n makeEDATraceContext,\n makeEDATraceMetadataFromParent,\n makeRootEDAEventTrace,\n makeRootEDATraceMetadata,\n} from \"../types/tracing\";\n\nexport { buildEDATraceparent, parseEDATraceparent } from \"../types/tracing\";\n\n/** Attribute value types accepted by Effect span annotations after compaction. */\nexport type EdaSpanAttributeValue = EDATraceAttributeValue | undefined;\n\n/** EDA span attribute map; undefined values are intentionally dropped before annotation. */\nexport type EdaSpanAttributes = Record<string, EdaSpanAttributeValue>;\n\nexport interface EDATracingOptions {\n readonly disableTracing?: boolean;\n readonly disableSpanPropagation?: boolean;\n readonly spanAttributes?: EdaSpanAttributes;\n readonly spanPrefix?: string;\n}\n\nexport interface EDAExportedSpanLink {\n readonly attributes: Record<string, string | number | boolean>;\n readonly sampled: boolean;\n readonly spanId: string;\n readonly traceId: string;\n}\n\nexport interface EDAExportedSpan {\n readonly attributes: Record<string, string | number | boolean>;\n readonly endedAtMs: number;\n readonly endedAtUnixNano: string;\n readonly kind: Tracer.SpanKind;\n readonly links: ReadonlyArray<EDAExportedSpanLink>;\n readonly name: string;\n readonly outcome: \"ok\" | \"error\" | \"timeout\" | \"canceled\";\n readonly parentSpanId?: string;\n readonly sampled: boolean;\n readonly spanId: string;\n readonly startedAtMs: number;\n readonly startedAtUnixNano: string;\n readonly statusCode: \"OK\" | \"ERROR\";\n readonly statusMessage?: string;\n readonly traceId: string;\n}\n\n/** Maximum primitive attributes copied from one native Effect span or link. */\nconst MAX_EXPORTED_SPAN_ATTRIBUTES = 256;\n\ninterface EventLike {\n readonly event?: { readonly type?: unknown; readonly durability?: unknown };\n readonly type?: unknown;\n}\n\ninterface PositionedEventLike {\n readonly position?: { readonly seq?: unknown; readonly subSeq?: unknown };\n readonly event?: { readonly type?: unknown; readonly durability?: unknown };\n}\n\n/** Compact undefined tracing attributes before handing them to Effect spans. */\nexport const compactSpanAttributes = (\n attributes: EdaSpanAttributes,\n): Record<string, string | number | boolean> => {\n const compacted: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n compacted[key] = value;\n }\n }\n return compacted;\n};\n\nconst compactUnknownAttributes = (\n attributes: Readonly<Record<string, unknown>> | ReadonlyMap<string, unknown>,\n): Record<string, string | number | boolean> => {\n const compacted: Record<string, string | number | boolean> = {};\n try {\n if (attributes instanceof Map) {\n let count = 0;\n for (const [key, value] of attributes) {\n if (count >= MAX_EXPORTED_SPAN_ATTRIBUTES) {\n break;\n }\n count += 1;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n compacted[key] = value;\n }\n }\n return compacted;\n }\n\n const keys = Object.keys(attributes).slice(0, MAX_EXPORTED_SPAN_ATTRIBUTES);\n for (const key of keys) {\n let value: unknown;\n try {\n value = Reflect.get(attributes, key);\n } catch {\n continue;\n }\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n compacted[key] = value;\n }\n }\n } catch {\n // Tracing diagnostics must not replace the operation whose span is ending.\n }\n return compacted;\n};\n\nexport const toEdaExternalSpan = (context: EDATraceContext): Tracer.ExternalSpan =>\n Tracer.externalSpan({\n traceId: context.traceId,\n spanId: context.spanId,\n sampled: context.sampled,\n });\n\nexport const edaTraceContextFromSpan = (span: Tracer.AnySpan): EDATraceContext =>\n makeEDATraceContext({\n traceId: span.traceId,\n spanId: span.spanId,\n sampled: span.sampled,\n tracestate: null,\n });\n\nexport const currentEDATraceContext: Effect.Effect<EDATraceContext, unknown> =\n Effect.currentSpan.pipe(Effect.map(edaTraceContextFromSpan));\n\nexport const currentOrRootEDAEventTrace: Effect.Effect<EDAEventTrace> = Effect.currentSpan.pipe(\n Effect.map((span) => makeEDAEventTrace(edaTraceContextFromSpan(span))),\n Effect.catch(() => Effect.sync(makeRootEDAEventTrace)),\n);\n\nexport const withEdaTraceMetadata =\n (metadata: EDATraceMetadata) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>\n effect.pipe(Effect.annotateSpans(metadata.attributes));\n\n/** Add EDA attributes to the currently active span. */\nexport const annotateEdaSpan = (attributes: EdaSpanAttributes): Effect.Effect<void> =>\n Effect.annotateCurrentSpan(compactSpanAttributes(attributes));\n\nconst nanosToMillis = (nanos: bigint): number => Number(nanos / 1_000_000n);\n\nconst outcomeFromExit = (exit: Exit.Exit<unknown, unknown>): EDAExportedSpan[\"outcome\"] => {\n if (Exit.isSuccess(exit)) {\n return \"ok\";\n }\n return Cause.hasInterruptsOnly(exit.cause) ? \"canceled\" : \"error\";\n};\n\nconst statusMessageFromExit = (exit: Exit.Exit<unknown, unknown>): string | undefined => {\n if (Exit.isSuccess(exit)) {\n return undefined;\n }\n const error = Cause.squash(exit.cause);\n return error instanceof Error ? error.message : String(error);\n};\n\nclass ExportingNativeSpan extends Tracer.NativeSpan {\n readonly #emit: (span: EDAExportedSpan) => void;\n\n constructor(\n options: ConstructorParameters<typeof Tracer.NativeSpan>[0],\n emit: (span: EDAExportedSpan) => void,\n ) {\n super(options);\n this.#emit = emit;\n }\n\n override end(endTime: bigint, exit: Exit.Exit<unknown, unknown>): void {\n super.end(endTime, exit);\n // Workers can report the same clock tick for very fast operations. Such spans\n // add noise without describing execution, so keep them out of exported traces.\n if (endTime <= this.startTime) {\n return;\n }\n const parent = Option.getOrUndefined(this.parent);\n this.#emit({\n attributes: compactUnknownAttributes(this.attributes),\n endedAtMs: nanosToMillis(endTime),\n endedAtUnixNano: endTime.toString(),\n kind: this.kind,\n links: this.links.map((link) => ({\n attributes: compactUnknownAttributes(link.attributes),\n traceId: link.span.traceId,\n spanId: link.span.spanId,\n sampled: link.span.sampled,\n })),\n name: this.name,\n outcome: outcomeFromExit(exit),\n ...(parent === undefined ? {} : { parentSpanId: parent.spanId }),\n sampled: this.sampled,\n spanId: this.spanId,\n startedAtMs: nanosToMillis(this.startTime),\n startedAtUnixNano: this.startTime.toString(),\n statusCode: Exit.isSuccess(exit) ? \"OK\" : \"ERROR\",\n ...(statusMessageFromExit(exit) === undefined\n ? {}\n : { statusMessage: statusMessageFromExit(exit) }),\n traceId: this.traceId,\n });\n }\n}\n\n/** Create an Effect tracer that exports only spans with observable duration. */\nexport const makeEdaExportingTracer = (emit: (span: EDAExportedSpan) => void): Tracer.Tracer =>\n Tracer.make({\n span: (options) => new ExportingNativeSpan(options, emit),\n });\n\n/** Summarize a durable/logical event collection for span attributes. */\nexport const eventBatchAttributes = (events: ReadonlyArray<EventLike>): EdaSpanAttributes => ({\n \"eda.event.count\": events.length,\n \"eda.event.types\": eventTypeSummary(events),\n});\n\n/** Summarize a committed positioned event collection for span attributes. */\nexport const committedBatchAttributes = (\n events: ReadonlyArray<PositionedEventLike>,\n): EdaSpanAttributes => {\n const seqs = events\n .map((entry) => entry.position?.seq)\n .filter((seq): seq is number => typeof seq === \"number\");\n return {\n ...eventBatchAttributes(events),\n \"eda.seq.min\": seqs.length === 0 ? undefined : Math.min(...seqs),\n \"eda.seq.max\": seqs.length === 0 ? undefined : Math.max(...seqs),\n };\n};\n\n/** Stable, low-cardinality usage attributes for model lifecycle spans. */\nexport const usageAttributes = (usage: UsagePayload | undefined): EdaSpanAttributes => ({\n \"eda.usage.input_tokens\": usage?.inputTokens,\n \"eda.usage.cached_input_tokens\": usage?.cachedInputTokens,\n \"eda.usage.output_tokens\": usage?.outputTokens,\n \"eda.usage.text_tokens\": usage?.textTokens,\n \"eda.usage.reasoning_tokens\": usage?.reasoningTokens,\n});\n\nconst eventTypeSummary = (events: ReadonlyArray<EventLike>): string | undefined => {\n if (events.length === 0) {\n return undefined;\n }\n const seen = new Set<string>();\n for (const event of events) {\n const type = event.event?.type ?? event.type;\n if (typeof type === \"string\") {\n seen.add(type);\n }\n }\n return seen.size === 0 ? undefined : Array.from(seen).join(\",\");\n};\n"],"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I,sBAAsB,IAAI,MAAM,KAAA,IAChC,CAAC,IACD,EAAE,eAAe,sBAAsB,IAAI,EAAE;GACjD,SAAS,KAAK;EAChB,CAAC;CACH;AACF;;AAGA,MAAa,0BAA0B,SACrC,OAAO,KAAK,EACV,OAAO,YAAY,IAAI,oBAAoB,SAAS,IAAI,EAC1D,CAAC;;AAGH,MAAa,wBAAwB,YAAyD;CAC5F,mBAAmB,OAAO;CAC1B,mBAAmB,iBAAiB,MAAM;AAC5C;;AAGA,MAAa,4BACX,WACsB;CACtB,MAAM,OAAO,OACV,KAAK,UAAU,MAAM,UAAU,GAAG,EAClC,QAAQ,QAAuB,OAAO,QAAQ,QAAQ;CACzD,OAAO;EACL,GAAG,qBAAqB,MAAM;EAC9B,eAAe,KAAK,WAAW,IAAI,KAAA,IAAY,KAAK,IAAI,GAAG,IAAI;EAC/D,eAAe,KAAK,WAAW,IAAI,KAAA,IAAY,KAAK,IAAI,GAAG,IAAI;CACjE;AACF;;AAGA,MAAa,mBAAmB,WAAwD;CACtF,0BAA0B,OAAO;CACjC,iCAAiC,OAAO;CACxC,2BAA2B,OAAO;CAClC,yBAAyB,OAAO;CAChC,8BAA8B,OAAO;AACvC;AAEA,MAAM,oBAAoB,WAAyD;CACjF,IAAI,OAAO,WAAW,GACpB;CAEF,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAO,MAAM,OAAO,QAAQ,MAAM;EACxC,IAAI,OAAO,SAAS,UAClB,KAAK,IAAI,IAAI;CAEjB;CACA,OAAO,KAAK,SAAS,IAAI,KAAA,IAAY,MAAM,KAAK,IAAI,EAAE,KAAK,GAAG;AAChE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { L as PositionedEvent } from "./events-Bb9-Cu-7.js";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
|
|
6
|
+
//#region src/services/session-event-observer.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Outbound integration point notified synchronously after EDA publishes an event.
|
|
9
|
+
*
|
|
10
|
+
* Hosts provide this service while composing the runtime. Implementations own
|
|
11
|
+
* their failures and never expose host errors to the session runtime.
|
|
12
|
+
*/
|
|
13
|
+
interface SessionEventObserverShape {
|
|
14
|
+
readonly onEvent: (event: PositionedEvent) => Effect.Effect<void>;
|
|
15
|
+
}
|
|
16
|
+
declare const SessionEventObserver_base: Context.ServiceClass<SessionEventObserver, "@effect-durable-agent/SessionEventObserver", SessionEventObserverShape>;
|
|
17
|
+
/** Host-provided observer for append-driven integrations such as hibernatable WebSockets. */
|
|
18
|
+
declare class SessionEventObserver extends SessionEventObserver_base {
|
|
19
|
+
static readonly Noop: Layer.Layer<SessionEventObserver, never, never>;
|
|
20
|
+
static readonly FromHandler: (onEvent: SessionEventObserverShape["onEvent"]) => Layer.Layer<SessionEventObserver>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SessionEventObserverShape as n, SessionEventObserver as t };
|
|
24
|
+
//# sourceMappingURL=session-event-observer-D_aoFnQs.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { m as SequenceNumber } from "./core-CYT6DBaS.js";
|
|
2
2
|
import { L as PositionedEvent } from "./events-Bb9-Cu-7.js";
|
|
3
|
-
import { a as EDASessionStore, o as EDASessionStoreError } from "./session-store-
|
|
4
|
-
import { S as ReducedState } from "./command-queues-
|
|
5
|
-
import { t as DurableTranscriptMessage } from "./message-transcript-
|
|
6
|
-
import { u as LiveEventBus } from "./sink-registry-
|
|
7
|
-
import {
|
|
8
|
-
import { h as SessionState } from "./session-state-
|
|
3
|
+
import { a as EDASessionStore, o as EDASessionStoreError } from "./session-store-ofm8FFxs.js";
|
|
4
|
+
import { S as ReducedState } from "./command-queues-C8muEqeQ.js";
|
|
5
|
+
import { t as DurableTranscriptMessage } from "./message-transcript-DsKTT47f.js";
|
|
6
|
+
import { u as LiveEventBus } from "./sink-registry-CE-hL7cB.js";
|
|
7
|
+
import { a as EDAReducerStateSnapshot } from "./reducer-registry--vQFATXb.js";
|
|
8
|
+
import { h as SessionState } from "./session-state-Bi3oEbJU.js";
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
11
11
|
import * as Layer from "effect/Layer";
|
|
@@ -28,10 +28,10 @@ interface EDASessionQueryShape {
|
|
|
28
28
|
/** Backfill durable events after `afterSeq`, then follow live durable/ephemeral events. */
|
|
29
29
|
readonly eventsAfter: (afterSeq: SequenceNumber) => Effect.Effect<Stream.Stream<PositionedEvent, EDASessionStoreError>, EDASessionStoreError, Scope.Scope>;
|
|
30
30
|
/** Read one bounded committed durable slice after `afterSeq` plus the committed head. */
|
|
31
|
-
readonly
|
|
31
|
+
readonly readEventPage: (afterSeq: SequenceNumber, limit: number) => Effect.Effect<EDASessionEventPage, EDASessionStoreError>;
|
|
32
32
|
}
|
|
33
|
-
/** Bounded committed durable
|
|
34
|
-
interface
|
|
33
|
+
/** Bounded committed durable event page for pull-based host delivery. */
|
|
34
|
+
interface EDASessionEventPage {
|
|
35
35
|
readonly events: ReadonlyArray<PositionedEvent>;
|
|
36
36
|
readonly head: SequenceNumber;
|
|
37
37
|
}
|
|
@@ -41,5 +41,5 @@ declare class EDASessionQuery extends EDASessionQuery_base {
|
|
|
41
41
|
static readonly Live: Layer.Layer<EDASessionQuery, never, SessionState | EDASessionStore | LiveEventBus>;
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
-
export { EDASessionSnapshot as i, EDASessionQuery as n, EDASessionQueryShape as r,
|
|
45
|
-
//# sourceMappingURL=session-query-
|
|
44
|
+
export { EDASessionSnapshot as i, EDASessionQuery as n, EDASessionQueryShape as r, EDASessionEventPage as t };
|
|
45
|
+
//# sourceMappingURL=session-query-lUZQpMvM.d.ts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { r as EDACommand } from "./commands-Ce1ec6kH.js";
|
|
2
2
|
import { D as DurableEventEnvelope, F as ModelSelectionPayload, I as NonNegativeInt, L as PositionedEvent, O as EphemeralEventEnvelope } from "./events-Bb9-Cu-7.js";
|
|
3
3
|
import { kt as ToolCallCreatedEvent } from "./durable-B7M6TD_0.js";
|
|
4
|
-
import { a as EDASessionStore, o as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-
|
|
5
|
-
import { S as ReducedState } from "./command-queues-
|
|
6
|
-
import { s as EDASinkRegistry, u as LiveEventBus } from "./sink-registry-CO3YPS1p.js";
|
|
4
|
+
import { a as EDASessionStore, o as EDASessionStoreError, t as CommittedDurableEvent } from "./session-store-ofm8FFxs.js";
|
|
5
|
+
import { S as ReducedState } from "./command-queues-C8muEqeQ.js";
|
|
7
6
|
import { t as IdGenerator } from "./id-generator-Ckl8_XWW.js";
|
|
8
7
|
import { r as SessionContext, t as EventFactory } from "./event-factory-CLJcyymV.js";
|
|
9
8
|
import { t as EDAKeepAlive } from "./keep-alive-Chl5SJxy.js";
|
|
10
|
-
import { d as CompactionRunner } from "./compaction-
|
|
11
|
-
import {
|
|
12
|
-
import { r as
|
|
13
|
-
import { r as
|
|
9
|
+
import { d as CompactionRunner } from "./compaction-D7W0-Ur1.js";
|
|
10
|
+
import { s as EDASinkRegistry, u as LiveEventBus } from "./sink-registry-CE-hL7cB.js";
|
|
11
|
+
import { a as EDAReducerStateSnapshot, r as EDAReducerRegistry } from "./reducer-registry--vQFATXb.js";
|
|
12
|
+
import { r as EDAPromptProjector } from "./prompt-projector-hqPh5-NI.js";
|
|
13
|
+
import { r as EDAToolRegistry } from "./tool-registry-ClHdr_G5.js";
|
|
14
14
|
import * as Context from "effect/Context";
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
16
16
|
import * as Layer from "effect/Layer";
|
|
@@ -143,7 +143,7 @@ interface ToolExecutorShape {
|
|
|
143
143
|
declare const ToolExecutor_base: Context.ServiceClass<ToolExecutor, "@effect-durable-agent/ToolExecutor", ToolExecutorShape>;
|
|
144
144
|
/** Executes sealed framework-owned tool calls and commits tool lifecycle boundaries. */
|
|
145
145
|
declare class ToolExecutor extends ToolExecutor_base {
|
|
146
|
-
static readonly Live: Layer.Layer<ToolExecutor, never,
|
|
146
|
+
static readonly Live: Layer.Layer<ToolExecutor, never, IdGenerator | EventFactory | SessionContext | EDAToolRegistry>;
|
|
147
147
|
}
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/services/inference-runner.d.ts
|
|
@@ -291,7 +291,7 @@ interface InferenceRunnerShape {
|
|
|
291
291
|
declare const InferenceRunner_base: Context.ServiceClass<InferenceRunner, "@effect-durable-agent/InferenceRunner", InferenceRunnerShape>;
|
|
292
292
|
/** Owns provider inference streams and routes them into durable/live inference emissions. */
|
|
293
293
|
declare class InferenceRunner extends InferenceRunner_base {
|
|
294
|
-
static readonly Live: Layer.Layer<InferenceRunner, never,
|
|
294
|
+
static readonly Live: Layer.Layer<InferenceRunner, never, IdGenerator | EventFactory | EDAToolRegistry | LanguageModel.LanguageModel>;
|
|
295
295
|
}
|
|
296
296
|
//#endregion
|
|
297
297
|
//#region src/services/turn-runner.d.ts
|
|
@@ -858,4 +858,4 @@ declare class SessionState extends SessionState_base {
|
|
|
858
858
|
}
|
|
859
859
|
//#endregion
|
|
860
860
|
export { ToolExecutor as S, SessionStateShape as _, SessionCommandCompleted as a, InferenceRunner as b, SessionCommandResult as c, SessionForkedCommand as d, SessionNoRunnableCommand as f, SessionStateError as g, SessionState as h, SessionCommandCancelled as i, SessionDrainProcessed as l, SessionRunInput as m, SessionCommandAdmissionConflict as n, SessionCommandFailed as o, SessionNoRunnableReason as p, SessionCommandAdmissionError as r, SessionCommandOutcome as s, EDASubmittable as t, SessionDrainResult as u, SessionStateSnapshotData as v, InferenceRunnerStreamPart as x, TurnRunner as y };
|
|
861
|
-
//# sourceMappingURL=session-state-
|
|
861
|
+
//# sourceMappingURL=session-state-Bi3oEbJU.d.ts.map
|
|
@@ -2,7 +2,6 @@ import { CommandId, InferenceId, MessageId, Position, RunId, SequenceNumber, Sub
|
|
|
2
2
|
import { CancelPendingMessageCommand, PromotePendingMessageCommand, ResumePendingMessagesCommand, StopTurnCommand, SubmitMessageCommand } from "./types/commands.js";
|
|
3
3
|
import { makeEDARunTrace } from "./types/tracing.js";
|
|
4
4
|
import { An as inferenceFailedEventType, Jn as toolCallRejectedEventType, Kn as toolCallCreatedEventType, Zn as turnFailedEventType, _r as SystemPromptText, br as UsagePayload, dr as FailurePayload, fr as ModelSelectionPayload, gn as commandAdmittedEventType, hr as ProviderPartId, kn as inferenceCompletedEventType, mr as PositionedEvent, pr as NonNegativeInt, vr as ToolName } from "./durable-DsV9PxZC.js";
|
|
5
|
-
import { n as EDASinkRegistry, r as LiveEventBus } from "./sink-registry-BbmoI9uv.js";
|
|
6
5
|
import { a as encodeReducedStateCheckpoint, h as assertNeverError, i as decodeReducedStateCheckpoint, l as initialReducedState, m as assertNever, n as activeTurnIdentityForCommand, o as foldReducedState, p as reducedStateCheckpointEventSeqs, r as classifyRecoverableWork, s as frameworkReducedStateReducerName } from "./reduced-state-TMi7ISla.js";
|
|
7
6
|
import { ContextProjection, emptyContextProjection } from "./domain/context-projection.js";
|
|
8
7
|
import { CommittedDurableEvent, EDASessionStore, EDASessionStoreError, hasEDASessionStoreError } from "./services/session-store.js";
|
|
@@ -11,6 +10,7 @@ import { n as SessionContext, t as EventFactory } from "./event-factory-tcpLgdMN
|
|
|
11
10
|
import { annotateEdaSpan, committedBatchAttributes, edaTraceContextFromSpan, eventBatchAttributes, toEdaExternalSpan, usageAttributes } from "./services/tracing.js";
|
|
12
11
|
import { EDAKeepAlive } from "./services/keep-alive.js";
|
|
13
12
|
import { CompactionRunner } from "./services/compaction.js";
|
|
13
|
+
import { n as EDASinkRegistry, r as LiveEventBus } from "./sink-registry-DH6uiEgP.js";
|
|
14
14
|
import { EDAPromptProjector, buildEDAPrompt } from "./services/prompt-projector.js";
|
|
15
15
|
import { EDAReducerRegistry, decodeReducerState, encodeReducerState, reducerSchemaVersion } from "./services/reducer-registry.js";
|
|
16
16
|
import { EDAToolRegistry } from "./services/tool-registry.js";
|
|
@@ -20,12 +20,12 @@ import * as Layer from "effect/Layer";
|
|
|
20
20
|
import * as Schema from "effect/Schema";
|
|
21
21
|
import * as Stream from "effect/Stream";
|
|
22
22
|
import * as Prompt from "effect/unstable/ai/Prompt";
|
|
23
|
-
import * as Ref from "effect/Ref";
|
|
24
23
|
import * as Cause from "effect/Cause";
|
|
25
24
|
import * as Clock from "effect/Clock";
|
|
26
25
|
import * as Exit from "effect/Exit";
|
|
27
26
|
import * as Fiber from "effect/Fiber";
|
|
28
27
|
import * as Queue from "effect/Queue";
|
|
28
|
+
import * as Ref from "effect/Ref";
|
|
29
29
|
import * as Scope from "effect/Scope";
|
|
30
30
|
import * as Semaphore from "effect/Semaphore";
|
|
31
31
|
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
@@ -2824,4 +2824,4 @@ const isSessionNoRunnableCommand = (result) => "_tag" in result && result._tag =
|
|
|
2824
2824
|
//#endregion
|
|
2825
2825
|
export { SessionCommandOutcome as a, SessionNoRunnableReason as c, TurnRunner as d, InferenceRunner as f, SessionCommandFailed as i, SessionRunInput as l, SessionCommandCancelled as n, SessionForkedCommand as o, ToolExecutor as p, SessionCommandCompleted as r, SessionNoRunnableCommand as s, SessionCommandAdmissionConflict as t, SessionState as u };
|
|
2826
2826
|
|
|
2827
|
-
//# sourceMappingURL=session-state-
|
|
2827
|
+
//# sourceMappingURL=session-state-C4m0j6CJ.js.map
|