effect-durable-agent 0.1.0-alpha.1
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/CHANGELOG.md +10 -0
- package/CONTRIBUTING.md +26 -0
- package/LICENSE +21 -0
- package/README.md +305 -0
- package/SECURITY.md +8 -0
- package/dist/command-queues-CQ9cwRP7.d.ts +468 -0
- package/dist/commands-Ce1ec6kH.d.ts +104 -0
- package/dist/compaction-YayFKo_1.d.ts +144 -0
- package/dist/core-Hv3cFydL.d.ts +81 -0
- package/dist/domain/command-queues.d.ts +2 -0
- package/dist/domain/command-queues.js +97 -0
- package/dist/domain/command-queues.js.map +1 -0
- package/dist/domain/message-transcript.d.ts +2 -0
- package/dist/domain/message-transcript.js +111 -0
- package/dist/domain/message-transcript.js.map +1 -0
- package/dist/domain/reduced-state-schema.d.ts +996 -0
- package/dist/domain/reduced-state-schema.js +286 -0
- package/dist/domain/reduced-state-schema.js.map +1 -0
- package/dist/domain/reduced-state.d.ts +2 -0
- package/dist/domain/reduced-state.js +2 -0
- package/dist/durable-C3Rz7kg3.js +625 -0
- package/dist/durable-C3Rz7kg3.js.map +1 -0
- package/dist/durable-DlScwmCy.d.ts +7424 -0
- package/dist/durable-object-runtime-B7jwBY2R.js +1494 -0
- package/dist/durable-object-runtime-B7jwBY2R.js.map +1 -0
- package/dist/durable-object-runtime-pWv0ohlz.d.ts +257 -0
- package/dist/durable-object-storage-Czy7IPrh.d.ts +41 -0
- package/dist/events-Bb9-Cu-7.d.ts +918 -0
- package/dist/host/durable-object-runtime.d.ts +2 -0
- package/dist/host/durable-object-runtime.js +2 -0
- package/dist/host/durable-object-storage.d.ts +2 -0
- package/dist/host/durable-object-storage.js +0 -0
- package/dist/host/durable-object.d.ts +83 -0
- package/dist/host/durable-object.js +191 -0
- package/dist/host/durable-object.js.map +1 -0
- package/dist/host/websocket-wire.d.ts +2 -0
- package/dist/host/websocket-wire.js +88 -0
- package/dist/host/websocket-wire.js.map +1 -0
- package/dist/id-generator-C2Q15uZM.d.ts +33 -0
- package/dist/index-BVVgDSdq.d.ts +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/keep-alive-DYDsH6qN.d.ts +111 -0
- package/dist/keep-alive-p8dIcSVy.js +109 -0
- package/dist/keep-alive-p8dIcSVy.js.map +1 -0
- package/dist/message-transcript-BCHdHAe2.d.ts +32 -0
- package/dist/prompt-projector-9_02lk5-.d.ts +40 -0
- package/dist/reduced-state-C4nVVzz9.js +910 -0
- package/dist/reduced-state-C4nVVzz9.js.map +1 -0
- package/dist/reducer-registry-C0svUa63.d.ts +69 -0
- package/dist/runtime-C56FQxiL.d.ts +60 -0
- package/dist/services/compaction.d.ts +2 -0
- package/dist/services/compaction.js +426 -0
- package/dist/services/compaction.js.map +1 -0
- package/dist/services/id-generator.d.ts +2 -0
- package/dist/services/id-generator.js +56 -0
- package/dist/services/id-generator.js.map +1 -0
- package/dist/services/prompt-projector.d.ts +2 -0
- package/dist/services/prompt-projector.js +27 -0
- package/dist/services/prompt-projector.js.map +1 -0
- package/dist/services/reducer-registry.d.ts +2 -0
- package/dist/services/reducer-registry.js +71 -0
- package/dist/services/reducer-registry.js.map +1 -0
- package/dist/services/runtime.d.ts +2 -0
- package/dist/services/runtime.js +84 -0
- package/dist/services/runtime.js.map +1 -0
- package/dist/services/session-query.d.ts +2 -0
- package/dist/services/session-query.js +2 -0
- package/dist/services/session-store.d.ts +2 -0
- package/dist/services/session-store.js +2 -0
- package/dist/services/sink-registry.d.ts +2 -0
- package/dist/services/sink-registry.js +2 -0
- package/dist/services/span-names.d.ts +28 -0
- package/dist/services/span-names.js +42 -0
- package/dist/services/span-names.js.map +1 -0
- package/dist/services/tool-registry.d.ts +2 -0
- package/dist/services/tool-registry.js +46 -0
- package/dist/services/tool-registry.js.map +1 -0
- package/dist/services/tracing.d.ts +76 -0
- package/dist/services/tracing.js +116 -0
- package/dist/services/tracing.js.map +1 -0
- package/dist/session-query-DOc1KanA.js +2930 -0
- package/dist/session-query-DOc1KanA.js.map +1 -0
- package/dist/session-query-DlRo5Ufc.d.ts +769 -0
- package/dist/session-store-D2Ore1QC.d.ts +295 -0
- package/dist/session-store-pYxQW9qh.js +214 -0
- package/dist/session-store-pYxQW9qh.js.map +1 -0
- package/dist/sink-registry-CFC6xjsN.js +312 -0
- package/dist/sink-registry-CFC6xjsN.js.map +1 -0
- package/dist/sink-registry-CIU0LD3m.d.ts +158 -0
- package/dist/testkit/layers.d.ts +101 -0
- package/dist/testkit/layers.js +108 -0
- package/dist/testkit/layers.js.map +1 -0
- package/dist/tool-registry-CcnkAAQK.d.ts +51 -0
- package/dist/tracing-BXHAkxkx.d.ts +111 -0
- package/dist/types/commands.d.ts +2 -0
- package/dist/types/commands.js +60 -0
- package/dist/types/commands.js.map +1 -0
- package/dist/types/core.d.ts +2 -0
- package/dist/types/core.js +68 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/events/durable.d.ts +2 -0
- package/dist/types/events/durable.js +2 -0
- package/dist/types/events.d.ts +4 -0
- package/dist/types/events.js +90 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/tracing.d.ts +2 -0
- package/dist/types/tracing.js +99 -0
- package/dist/types/tracing.js.map +1 -0
- package/dist/websocket-wire-DvOu_6BJ.d.ts +16773 -0
- package/docs/assets/architecture.svg +106 -0
- package/docs/assets/event-sequence.svg +143 -0
- package/docs/assets/gcp-trace.png +0 -0
- package/docs/message-steering.md +831 -0
- package/docs/releasing.md +57 -0
- package/docs/spec.md +774 -0
- package/docs/subagents.md +725 -0
- package/docs/testing.md +64 -0
- package/docs/ui-projection.md +742 -0
- package/docs/websocket-protocol.md +613 -0
- package/examples/001-no-tools/README.md +65 -0
- package/examples/001-no-tools/worker.ts +79 -0
- package/examples/002-slack-bridge/README.md +134 -0
- package/examples/002-slack-bridge/events.ts +115 -0
- package/examples/002-slack-bridge/reducer.ts +216 -0
- package/examples/002-slack-bridge/scenario.test.ts +223 -0
- package/examples/002-slack-bridge/sinks.ts +109 -0
- package/examples/002-slack-bridge/worker.ts +140 -0
- package/examples/003-sandbox-lifecycle/README.md +78 -0
- package/examples/003-sandbox-lifecycle/events.ts +203 -0
- package/examples/003-sandbox-lifecycle/reducer.ts +305 -0
- package/examples/003-sandbox-lifecycle/scenario.test.ts +202 -0
- package/examples/_shared/event-id.ts +12 -0
- package/examples/_shared/http.ts +27 -0
- package/examples/_shared/openai.ts +33 -0
- package/package.json +181 -0
- package/testing/offline-trace/README.md +63 -0
- package/tooling/oxlint/index.mjs +15 -0
- package/tooling/oxlint/rules/effect-span-from-catalog.mjs +152 -0
- package/tooling/oxlint/rules/span-catalog-format.mjs +74 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as EDAReducersFor, c as defineEDAReducerRegistry, d as getEDAReducerState, f as reducerSchemaVersion, i as EDAReducerStateSnapshot, l as edaReservedReducerNamePrefix, n as EDAReducerRegistry, o as EDATypedReducerRegistry, r as EDAReducerRegistryShape, s as decodeReducerState, t as EDAReducer, u as encodeReducerState } from "../reducer-registry-C0svUa63.js";
|
|
2
|
+
export { EDAReducer, EDAReducerRegistry, EDAReducerRegistryShape, EDAReducerStateSnapshot, EDAReducersFor, EDATypedReducerRegistry, decodeReducerState, defineEDAReducerRegistry, edaReservedReducerNamePrefix, encodeReducerState, getEDAReducerState, reducerSchemaVersion };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
//#region src/services/reducer-registry.ts
|
|
5
|
+
/** Convenience constructor preserving a reducer's literal name and schema-derived state type. */
|
|
6
|
+
const EDAReducer = { make: (reducer) => reducer };
|
|
7
|
+
const reducerValues = (reducers) => Object.values(reducers);
|
|
8
|
+
/**
|
|
9
|
+
* Register an app's complete reducer set against its public serialized-state union.
|
|
10
|
+
*
|
|
11
|
+
* Missing reducers, extra reducers, reducer-name drift, and state-schema drift are
|
|
12
|
+
* rejected by TypeScript at the registration site.
|
|
13
|
+
*/
|
|
14
|
+
const defineEDAReducerRegistry = (entrySchema, reducers) => {
|
|
15
|
+
const values = reducerValues(reducers);
|
|
16
|
+
const serializedStatesSchema = Schema.Array(entrySchema);
|
|
17
|
+
return {
|
|
18
|
+
entrySchema,
|
|
19
|
+
reducers: values,
|
|
20
|
+
serialize: (snapshot) => Schema.decodeUnknownSync(serializedStatesSchema)(values.map((reducer) => ({
|
|
21
|
+
name: reducer.name,
|
|
22
|
+
state: snapshot.get(reducer.name) ?? reducer.initial
|
|
23
|
+
})))
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/** Prefix reserved for framework-owned reducer checkpoints. */
|
|
27
|
+
const edaReservedReducerNamePrefix = "_eda.";
|
|
28
|
+
/** Return the persisted schema version for one reducer. */
|
|
29
|
+
const reducerSchemaVersion = (reducer) => reducer.schemaVersion ?? 1;
|
|
30
|
+
/** Encode one reducer state for durable checkpoint storage. */
|
|
31
|
+
const encodeReducerState = (reducer, state) => reducer.encode === void 0 ? Schema.encodeUnknownSync(reducer.stateSchema)(state) : reducer.encode(state);
|
|
32
|
+
/** Decode one reducer state from durable checkpoint storage. */
|
|
33
|
+
const decodeReducerState = (reducer, payload) => reducer.decode === void 0 ? Schema.decodeUnknownSync(reducer.stateSchema)(payload) : reducer.decode(payload);
|
|
34
|
+
/** Registry for app-specific durable metadata reducers. */
|
|
35
|
+
var EDAReducerRegistry = class EDAReducerRegistry extends Context.Service()("@effect-durable-agent/EDAReducerRegistry") {
|
|
36
|
+
static Empty = Layer.succeed(EDAReducerRegistry, makeReducerRegistry([]));
|
|
37
|
+
static Live = (reducers) => Layer.succeed(EDAReducerRegistry, makeReducerRegistry(reducers));
|
|
38
|
+
};
|
|
39
|
+
/** Read one typed reducer state from a snapshot. */
|
|
40
|
+
const getEDAReducerState = (snapshot, reducer) => {
|
|
41
|
+
const state = snapshot.get(reducer.name);
|
|
42
|
+
return state === void 0 ? reducer.initial : Schema.decodeUnknownSync(reducer.stateSchema)(state);
|
|
43
|
+
};
|
|
44
|
+
function makeReducerRegistry(reducers) {
|
|
45
|
+
validateReducerNames(reducers);
|
|
46
|
+
return {
|
|
47
|
+
reducers,
|
|
48
|
+
initial: new Map(reducers.map((reducer) => [reducer.name, reducer.initial])),
|
|
49
|
+
reduce: (state, events) => {
|
|
50
|
+
if (events.length === 0 || reducers.length === 0) return state;
|
|
51
|
+
const next = new Map(state);
|
|
52
|
+
for (const event of events) for (const reducer of reducers) {
|
|
53
|
+
const current = next.get(reducer.name) ?? reducer.initial;
|
|
54
|
+
next.set(reducer.name, reducer.reduce(current, event));
|
|
55
|
+
}
|
|
56
|
+
return next;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function validateReducerNames(reducers) {
|
|
61
|
+
const seen = /* @__PURE__ */ new Set();
|
|
62
|
+
for (const reducer of reducers) {
|
|
63
|
+
if (reducer.name.startsWith("_eda.")) throw new Error(`Reducer name ${reducer.name} uses reserved EDA prefix ${edaReservedReducerNamePrefix}`);
|
|
64
|
+
if (seen.has(reducer.name)) throw new Error(`Duplicate EDA reducer name ${reducer.name}`);
|
|
65
|
+
seen.add(reducer.name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { EDAReducer, EDAReducerRegistry, decodeReducerState, defineEDAReducerRegistry, edaReservedReducerNamePrefix, encodeReducerState, getEDAReducerState, reducerSchemaVersion };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=reducer-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer-registry.js","names":[],"sources":["../../src/services/reducer-registry.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport type { CommittedDurableEvent } from \"./session-store\";\n\n/** App-specific pure reducer over the durable session event log. */\nexport interface EDAReducer<State = unknown, Name extends string = string> {\n readonly name: Name;\n readonly initial: State;\n readonly stateSchema: Schema.Codec<State, unknown, never, never>;\n readonly schemaVersion?: number;\n readonly encode?: (state: State) => unknown;\n readonly decode?: (payload: unknown) => State;\n reduce(state: State, event: CommittedDurableEvent): State;\n}\n\n/** Convenience constructor preserving a reducer's literal name and schema-derived state type. */\nexport const EDAReducer = {\n make: <State, const Name extends string = string>(\n reducer: EDAReducer<State, Name>,\n ): EDAReducer<State, Name> => reducer,\n};\n\n/** Snapshot of all app reducer states, keyed by reducer name. */\nexport type EDAReducerStateSnapshot = ReadonlyMap<string, unknown>;\n\ninterface EDASerializedReducerState {\n readonly name: string;\n readonly state: unknown;\n}\n\ntype EDAReducerStateForName<\n Entry extends EDASerializedReducerState,\n Name extends Entry[\"name\"],\n> = Extract<Entry, { readonly name: Name }>[\"state\"];\n\n/** Exact reducer object required for every member of a serialized state union. */\nexport type EDAReducersFor<Entry extends EDASerializedReducerState> = {\n readonly [Name in Entry[\"name\"]]: EDAReducer<EDAReducerStateForName<Entry, Name>, Name>;\n};\n\n/** Schema-backed app reducer registry used by both runtime folding and snapshot serialization. */\nexport interface EDATypedReducerRegistry<\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n> {\n readonly entrySchema: EntrySchema;\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly serialize: (snapshot: EDAReducerStateSnapshot) => ReadonlyArray<EntrySchema[\"Type\"]>;\n}\n\nconst reducerValues = (reducers: Readonly<Record<string, EDAReducer>>): ReadonlyArray<EDAReducer> =>\n Object.values(reducers);\n\n/**\n * Register an app's complete reducer set against its public serialized-state union.\n *\n * Missing reducers, extra reducers, reducer-name drift, and state-schema drift are\n * rejected by TypeScript at the registration site.\n */\nexport const defineEDAReducerRegistry = <\n EntrySchema extends Schema.Codec<EDASerializedReducerState, unknown, never, never>,\n>(\n entrySchema: EntrySchema,\n reducers: EDAReducersFor<EntrySchema[\"Type\"]>,\n): EDATypedReducerRegistry<EntrySchema> => {\n const values = reducerValues(reducers);\n const serializedStatesSchema = Schema.Array(entrySchema);\n return {\n entrySchema,\n reducers: values,\n serialize: (snapshot) =>\n Schema.decodeUnknownSync(serializedStatesSchema)(\n values.map((reducer) => ({\n name: reducer.name,\n state: snapshot.get(reducer.name) ?? reducer.initial,\n })),\n ),\n };\n};\n\n/** Registry that folds app-specific read-model state beside EDA reduced state. */\nexport interface EDAReducerRegistryShape {\n readonly reducers: ReadonlyArray<EDAReducer>;\n readonly initial: EDAReducerStateSnapshot;\n readonly reduce: (\n state: EDAReducerStateSnapshot,\n events: ReadonlyArray<CommittedDurableEvent>,\n ) => EDAReducerStateSnapshot;\n}\n\n/** Prefix reserved for framework-owned reducer checkpoints. */\nexport const edaReservedReducerNamePrefix = \"_eda.\";\n\n/** Return the persisted schema version for one reducer. */\nexport const reducerSchemaVersion = (reducer: EDAReducer): number => reducer.schemaVersion ?? 1;\n\n/** Encode one reducer state for durable checkpoint storage. */\nexport const encodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n state: State,\n): unknown =>\n reducer.encode === undefined\n ? Schema.encodeUnknownSync(reducer.stateSchema)(state)\n : reducer.encode(state);\n\n/** Decode one reducer state from durable checkpoint storage. */\nexport const decodeReducerState = <State, Name extends string>(\n reducer: EDAReducer<State, Name>,\n payload: unknown,\n): State =>\n reducer.decode === undefined\n ? Schema.decodeUnknownSync(reducer.stateSchema)(payload)\n : reducer.decode(payload);\n\n/** Registry for app-specific durable metadata reducers. */\nexport class EDAReducerRegistry extends Context.Service<\n EDAReducerRegistry,\n EDAReducerRegistryShape\n>()(\"@effect-durable-agent/EDAReducerRegistry\") {\n static readonly Empty = Layer.succeed(EDAReducerRegistry, makeReducerRegistry([]));\n\n static readonly Live = (reducers: ReadonlyArray<EDAReducer>) =>\n Layer.succeed(EDAReducerRegistry, makeReducerRegistry(reducers));\n}\n\n/** Read one typed reducer state from a snapshot. */\nexport const getEDAReducerState = <State, Name extends string>(\n snapshot: EDAReducerStateSnapshot,\n reducer: EDAReducer<State, Name>,\n): State => {\n const state = snapshot.get(reducer.name);\n return state === undefined\n ? reducer.initial\n : Schema.decodeUnknownSync(reducer.stateSchema)(state);\n};\n\nfunction makeReducerRegistry(reducers: ReadonlyArray<EDAReducer>): EDAReducerRegistryShape {\n validateReducerNames(reducers);\n const initial = new Map(reducers.map((reducer) => [reducer.name, reducer.initial]));\n return {\n reducers,\n initial,\n reduce: (state, events) => {\n if (events.length === 0 || reducers.length === 0) {\n return state;\n }\n const next = new Map(state);\n for (const event of events) {\n for (const reducer of reducers) {\n const current = next.get(reducer.name) ?? reducer.initial;\n next.set(reducer.name, reducer.reduce(current, event));\n }\n }\n return next;\n },\n };\n}\n\nfunction validateReducerNames(reducers: ReadonlyArray<EDAReducer>): void {\n const seen = new Set<string>();\n for (const reducer of reducers) {\n if (reducer.name.startsWith(edaReservedReducerNamePrefix)) {\n throw new Error(\n `Reducer name ${reducer.name} uses reserved EDA prefix ${edaReservedReducerNamePrefix}`,\n );\n }\n if (seen.has(reducer.name)) {\n throw new Error(`Duplicate EDA reducer name ${reducer.name}`);\n }\n seen.add(reducer.name);\n }\n}\n"],"mappings":";;;;;AAkBA,MAAa,aAAa,EACxB,OACE,YAC4B,QAChC;AA6BA,MAAM,iBAAiB,aACrB,OAAO,OAAO,QAAQ;;;;;;;AAQxB,MAAa,4BAGX,aACA,aACyC;CACzC,MAAM,SAAS,cAAc,QAAQ;CACrC,MAAM,yBAAyB,OAAO,MAAM,WAAW;CACvD,OAAO;EACL;EACA,UAAU;EACV,YAAY,aACV,OAAO,kBAAkB,sBAAsB,EAC7C,OAAO,KAAK,aAAa;GACvB,MAAM,QAAQ;GACd,OAAO,SAAS,IAAI,QAAQ,IAAI,KAAK,QAAQ;EAC/C,EAAE,CACJ;CACJ;AACF;;AAaA,MAAa,+BAA+B;;AAG5C,MAAa,wBAAwB,YAAgC,QAAQ,iBAAiB;;AAG9F,MAAa,sBACX,SACA,UAEA,QAAQ,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AA4B,8BAC3D;EAEF,IAAI,KAAK,IAAI,QAAQ,IAAI,GACvB,MAAM,IAAI,MAAM,8BAA8B,QAAQ,MAAM;EAE9D,KAAK,IAAI,QAAQ,IAAI;CACvB;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as EDARuntimeError, i as EDARuntimeConfig, n as EDACommandTerminalEvent, o as EDARuntimeShape, r as EDARuntime, s as EDARuntimeSubmit, t as CommittedCommandTerminalEvent } from "../runtime-C56FQxiL.js";
|
|
2
|
+
export { CommittedCommandTerminalEvent, EDACommandTerminalEvent, EDARuntime, EDARuntimeConfig, EDARuntimeError, EDARuntimeShape, EDARuntimeSubmit };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { SequenceNumber, durablePosition } from "../types/core.js";
|
|
2
|
+
import { gn as commandFailedEventType, hn as commandCompletedEventType, lr as ModelSelectionPayload, mn as commandCancelledEventType, mr as SystemPromptText, ur as NonNegativeInt } from "../durable-C3Rz7kg3.js";
|
|
3
|
+
import { n as SessionState, t as EDASessionQuery } from "../session-query-DOc1KanA.js";
|
|
4
|
+
import { t as CommittedDurableEvent } from "../session-store-pYxQW9qh.js";
|
|
5
|
+
import { annotateEdaSpan, committedBatchAttributes } from "./tracing.js";
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
import * as Stream from "effect/Stream";
|
|
11
|
+
//#region src/services/runtime.ts
|
|
12
|
+
/** Configuration for one scoped session runtime instance. */
|
|
13
|
+
const EDARuntimeConfig = Schema.Struct({
|
|
14
|
+
modelSelection: ModelSelectionPayload,
|
|
15
|
+
/** Maximum framework-owned tool calls one model run may execute before failing safely. */
|
|
16
|
+
maxToolCallsPerRun: Schema.optionalKey(NonNegativeInt),
|
|
17
|
+
systemPrompt: Schema.optionalKey(SystemPromptText)
|
|
18
|
+
});
|
|
19
|
+
/** Top-level public facade for one effect-durable-agent session runtime. */
|
|
20
|
+
var EDARuntime = class EDARuntime extends Context.Service()("@effect-durable-agent/EDARuntime") {
|
|
21
|
+
static Live = (config) => Layer.effect(EDARuntime, makeLiveRuntime(config));
|
|
22
|
+
};
|
|
23
|
+
const makeLiveRuntime = (config) => Effect.gen(function* () {
|
|
24
|
+
const sessionState = yield* SessionState;
|
|
25
|
+
const query = yield* EDASessionQuery;
|
|
26
|
+
const runInput = {
|
|
27
|
+
modelSelection: config.modelSelection,
|
|
28
|
+
...config.maxToolCallsPerRun === void 0 ? {} : { maxToolCallsPerRun: config.maxToolCallsPerRun },
|
|
29
|
+
...config.systemPrompt === void 0 ? {} : { systemPrompt: config.systemPrompt }
|
|
30
|
+
};
|
|
31
|
+
yield* sessionState.start(runInput);
|
|
32
|
+
const blockOnCommand = Effect.fn(function* (commandId, afterSeq = SequenceNumber.make(0)) {
|
|
33
|
+
yield* annotateEdaSpan({
|
|
34
|
+
"eda.command.id": commandId,
|
|
35
|
+
"eda.seq.after": afterSeq
|
|
36
|
+
});
|
|
37
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
38
|
+
const terminal = yield* (yield* query.eventsAfter(afterSeq)).pipe(Stream.filter(isCommandTerminalFor(commandId)), Stream.take(1), Stream.map(toCommittedCommandTerminal), Stream.runCollect, Effect.map((events) => events[0]));
|
|
39
|
+
return terminal === void 0 ? yield* Effect.die(/* @__PURE__ */ new Error("Expected command terminal event")) : terminal;
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
submit: Effect.fn(function* (input) {
|
|
44
|
+
const items = Array.isArray(input) ? input : [input];
|
|
45
|
+
yield* annotateEdaSpan({
|
|
46
|
+
"eda.command.submittable_count": items.length,
|
|
47
|
+
"eda.command.count": items.filter((item) => "_tag" in item).length
|
|
48
|
+
});
|
|
49
|
+
const committed = Array.isArray(input) ? yield* sessionState.submitBatch(input) : [yield* sessionState.admitCommand(input)];
|
|
50
|
+
yield* annotateEdaSpan(committedBatchAttributes(committed));
|
|
51
|
+
return Array.isArray(input) ? committed : committed[0];
|
|
52
|
+
}),
|
|
53
|
+
blockOnCommand,
|
|
54
|
+
submitAndBlock: Effect.fn(function* (command) {
|
|
55
|
+
yield* annotateEdaSpan({
|
|
56
|
+
"eda.command.kind": command._tag,
|
|
57
|
+
"eda.command.id": command.commandId,
|
|
58
|
+
"eda.command.disposition": "disposition" in command ? command.disposition : void 0
|
|
59
|
+
});
|
|
60
|
+
const admitted = yield* sessionState.admitCommand(command);
|
|
61
|
+
return yield* blockOnCommand(commandIdFromCommandAdmitted(admitted), admitted.position.seq);
|
|
62
|
+
}),
|
|
63
|
+
snapshot: () => query.snapshot(),
|
|
64
|
+
messages: () => query.messages(),
|
|
65
|
+
eventsAfter: (afterSeq) => query.eventsAfter(afterSeq)
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const isCommandTerminalFor = (commandId) => (event) => {
|
|
69
|
+
if (event.event.type !== commandCompletedEventType && event.event.type !== commandFailedEventType && event.event.type !== commandCancelledEventType) return false;
|
|
70
|
+
return event.event.payload.commandId === commandId;
|
|
71
|
+
};
|
|
72
|
+
const toCommittedCommandTerminal = (event) => CommittedDurableEvent.make({
|
|
73
|
+
position: durablePosition(event.position.seq),
|
|
74
|
+
event: event.event
|
|
75
|
+
});
|
|
76
|
+
const commandIdFromCommandAdmitted = (committed) => {
|
|
77
|
+
const commandId = committed.event.payload.command?.commandId;
|
|
78
|
+
if (commandId === void 0) throw new Error("CommandAdmitted event is missing a framework commandId");
|
|
79
|
+
return commandId;
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
export { EDARuntime, EDARuntimeConfig };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","names":[],"sources":["../../src/services/runtime.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nimport { EDACommand } from \"../types/commands\";\nimport { CommandId, SequenceNumber, durablePosition } from \"../types/core\";\nimport {\n ModelSelectionPayload,\n NonNegativeInt,\n SystemPromptText,\n commandCancelledEventType,\n commandCompletedEventType,\n commandFailedEventType,\n} from \"../types/events\";\nimport type {\n CommandCancelledEvent,\n CommandCompletedEvent,\n CommandFailedEvent,\n PositionedEvent,\n} from \"../types/events\";\nimport { SessionState } from \"./session-state\";\nimport type { EDASubmittable, SessionCommandAdmissionError } from \"./session-state\";\nimport { CommittedDurableEvent } from \"./session-store\";\nimport { EDASessionQuery } from \"./session-query\";\nimport { annotateEdaSpan, committedBatchAttributes } from \"./tracing\";\nimport type { EDASessionQueryShape } from \"./session-query\";\n\n/** Configuration for one scoped session runtime instance. */\nexport const EDARuntimeConfig = Schema.Struct({\n modelSelection: ModelSelectionPayload,\n /** Maximum framework-owned tool calls one model run may execute before failing safely. */\n maxToolCallsPerRun: Schema.optionalKey(NonNegativeInt),\n systemPrompt: Schema.optionalKey(SystemPromptText),\n});\nexport type EDARuntimeConfig = typeof EDARuntimeConfig.Type;\n\n/** Public runtime error surface for command admission helpers. */\nexport type EDARuntimeError = SessionCommandAdmissionError;\n\n/** Command terminal events observed by blocking runtime helpers. */\nexport type EDACommandTerminalEvent =\n | CommandCompletedEvent\n | CommandFailedEvent\n | CommandCancelledEvent;\n\n/** Committed durable event narrowed to a command terminal boundary. */\nexport type CommittedCommandTerminalEvent = CommittedDurableEvent & {\n readonly event: EDACommandTerminalEvent;\n};\n\n/** Overloaded public submit API for single commands or ordered durable batches. */\nexport interface EDARuntimeSubmit {\n /** Submit one command and return its committed CommandAdmitted event. */\n (command: EDACommand): Effect.Effect<CommittedDurableEvent, EDARuntimeError>;\n /** Submit one ordered durable batch of commands and/or app events. */\n (\n input: ReadonlyArray<EDASubmittable>,\n ): Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDARuntimeError>;\n}\n\n/** Public facade exposed to hosts and route handlers for one live session runtime. */\nexport interface EDARuntimeShape {\n /** Submit commands and/or app durable events durably and wake the dispatch process if needed. */\n readonly submit: EDARuntimeSubmit;\n /** Block until the command reaches CommandCompleted, CommandFailed, or CommandCancelled. */\n readonly blockOnCommand: (\n commandId: CommandId,\n afterSeq?: SequenceNumber,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Admit one command and block until that command reaches a terminal command boundary. */\n readonly submitAndBlock: (\n command: EDACommand,\n ) => Effect.Effect<CommittedCommandTerminalEvent, EDARuntimeError>;\n /** Read the authoritative live session snapshot. */\n readonly snapshot: EDASessionQueryShape[\"snapshot\"];\n /** Read durable user/assistant messages in committed order. */\n readonly messages: EDASessionQueryShape[\"messages\"];\n /** Backfill durable events after a committed sequence, then follow live events. */\n readonly eventsAfter: EDASessionQueryShape[\"eventsAfter\"];\n}\n\n/** Top-level public facade for one effect-durable-agent session runtime. */\nexport class EDARuntime extends Context.Service<EDARuntime, EDARuntimeShape>()(\n \"@effect-durable-agent/EDARuntime\",\n) {\n static readonly Live = (config: EDARuntimeConfig) =>\n Layer.effect(EDARuntime, makeLiveRuntime(config));\n}\n\nconst makeLiveRuntime = (config: EDARuntimeConfig) =>\n Effect.gen(function* () {\n const sessionState = yield* SessionState;\n const query = yield* EDASessionQuery;\n\n const runInput = {\n modelSelection: config.modelSelection,\n ...(config.maxToolCallsPerRun === undefined\n ? {}\n : { maxToolCallsPerRun: config.maxToolCallsPerRun }),\n ...(config.systemPrompt === undefined ? {} : { systemPrompt: config.systemPrompt }),\n };\n yield* sessionState.start(runInput);\n\n const blockOnCommand = Effect.fn(function* (\n commandId: CommandId,\n afterSeq: SequenceNumber = SequenceNumber.make(0),\n ) {\n yield* annotateEdaSpan({ \"eda.command.id\": commandId, \"eda.seq.after\": afterSeq });\n return yield* Effect.scoped(\n Effect.gen(function* () {\n const events = yield* query.eventsAfter(afterSeq);\n const terminal = yield* events.pipe(\n Stream.filter(isCommandTerminalFor(commandId)),\n Stream.take(1),\n Stream.map(toCommittedCommandTerminal),\n Stream.runCollect,\n Effect.map((events) => events[0]),\n );\n return terminal === undefined\n ? yield* Effect.die(new Error(\"Expected command terminal event\"))\n : terminal;\n }),\n );\n });\n\n const submit = Effect.fn(function* (input: EDACommand | ReadonlyArray<EDASubmittable>) {\n const items = Array.isArray(input) ? input : [input as EDACommand];\n yield* annotateEdaSpan({\n \"eda.command.submittable_count\": items.length,\n \"eda.command.count\": items.filter((item) => \"_tag\" in item).length,\n });\n const committed = Array.isArray(input)\n ? yield* sessionState.submitBatch(input)\n : [yield* sessionState.admitCommand(input as EDACommand)];\n yield* annotateEdaSpan(committedBatchAttributes(committed));\n return Array.isArray(input) ? committed : committed[0]!;\n }) as EDARuntimeSubmit;\n\n return {\n submit,\n blockOnCommand,\n submitAndBlock: Effect.fn(function* (command: EDACommand) {\n yield* annotateEdaSpan({\n \"eda.command.kind\": command._tag,\n \"eda.command.id\": command.commandId,\n \"eda.command.disposition\": \"disposition\" in command ? command.disposition : undefined,\n });\n const admitted = yield* sessionState.admitCommand(command);\n return yield* blockOnCommand(commandIdFromCommandAdmitted(admitted), admitted.position.seq);\n }),\n snapshot: () => query.snapshot(),\n messages: () => query.messages(),\n eventsAfter: (afterSeq: SequenceNumber) => query.eventsAfter(afterSeq),\n };\n });\n\nconst isCommandTerminalFor =\n (commandId: CommandId) =>\n (event: PositionedEvent): boolean => {\n if (\n event.event.type !== commandCompletedEventType &&\n event.event.type !== commandFailedEventType &&\n event.event.type !== commandCancelledEventType\n ) {\n return false;\n }\n return (event.event.payload as { readonly commandId: CommandId }).commandId === commandId;\n };\n\nconst toCommittedCommandTerminal = (event: PositionedEvent): CommittedCommandTerminalEvent =>\n CommittedDurableEvent.make({\n position: durablePosition(event.position.seq),\n event: event.event as EDACommandTerminalEvent,\n }) as CommittedCommandTerminalEvent;\n\nconst commandIdFromCommandAdmitted = (committed: CommittedDurableEvent): CommandId => {\n const commandId = (committed.event.payload as { readonly command?: EDACommand }).command\n ?.commandId;\n if (commandId === undefined) {\n throw new Error(\"CommandAdmitted event is missing a framework commandId\");\n }\n return commandId;\n};\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAa,mBAAmB,OAAO,OAAO;CAC5C,gBAAgB;;CAEhB,oBAAoB,OAAO,YAAY,cAAc;CACrD,cAAc,OAAO,YAAY,gBAAgB;AACnD,CAAC;;AAiDD,IAAa,aAAb,MAAa,mBAAmB,QAAQ,QAAqC,EAC3E,kCACF,EAAE;CACA,OAAgB,QAAQ,WACtB,MAAM,OAAO,YAAY,gBAAgB,MAAM,CAAC;AACpD;AAEA,MAAM,mBAAmB,WACvB,OAAO,IAAI,aAAa;CACtB,MAAM,eAAe,OAAO;CAC5B,MAAM,QAAQ,OAAO;CAErB,MAAM,WAAW;EACf,gBAAgB,OAAO;EACvB,GAAI,OAAO,uBAAuB,KAAA,IAC9B,CAAC,IACD,EAAE,oBAAoB,OAAO,mBAAmB;EACpD,GAAI,OAAO,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc,OAAO,aAAa;CACnF;CACA,OAAO,aAAa,MAAM,QAAQ;CAElC,MAAM,iBAAiB,OAAO,GAAG,WAC/B,WACA,WAA2B,eAAe,KAAK,CAAC,GAChD;EACA,OAAO,gBAAgB;GAAE,kBAAkB;GAAW,iBAAiB;EAAS,CAAC;EACjF,OAAO,OAAO,OAAO,OACnB,OAAO,IAAI,aAAa;GAEtB,MAAM,WAAW,QAAO,OADF,MAAM,YAAY,QAAQ,GACjB,KAC7B,OAAO,OAAO,qBAAqB,SAAS,CAAC,GAC7C,OAAO,KAAK,CAAC,GACb,OAAO,IAAI,0BAA0B,GACrC,OAAO,YACP,OAAO,KAAK,WAAW,OAAO,EAAE,CAClC;GACA,OAAO,aAAa,KAAA,IAChB,OAAO,OAAO,oBAAI,IAAI,MAAM,iCAAiC,CAAC,IAC9D;EACN,CAAC,C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I,MAAM,wDAAwD;CAE1E,OAAO;AACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as EDASessionStore, c as FindCommandAdmissionInput, d as hasEDASessionStoreError, i as EDAReducerCheckpoint, l as SaveReducerCheckpointInput, n as DurableAppendBatch, o as EDASessionStoreError, r as DurableAppendEntry, s as EDASessionStoreShape, t as CommittedDurableEvent, u as durableObjectSerializedJsonHardCapBytes } from "../session-store-D2Ore1QC.js";
|
|
2
|
+
export { CommittedDurableEvent, DurableAppendBatch, DurableAppendEntry, EDAReducerCheckpoint, EDASessionStore, EDASessionStoreError, EDASessionStoreShape, FindCommandAdmissionInput, SaveReducerCheckpointInput, durableObjectSerializedJsonHardCapBytes, hasEDASessionStoreError };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as EDASessionStoreError, c as hasEDASessionStoreError, i as EDASessionStore, n as DurableAppendBatch, o as FindCommandAdmissionInput, r as DurableAppendEntry, s as durableObjectSerializedJsonHardCapBytes, t as CommittedDurableEvent } from "../session-store-pYxQW9qh.js";
|
|
2
|
+
export { CommittedDurableEvent, DurableAppendBatch, DurableAppendEntry, EDASessionStore, EDASessionStoreError, FindCommandAdmissionInput, durableObjectSerializedJsonHardCapBytes, hasEDASessionStoreError };
|
|
@@ -0,0 +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-CIU0LD3m.js";
|
|
2
|
+
export { EDADurableSinkDefinition, EDAEphemeralSinkDefinition, EDASink, EDASinkCheckpoint, EDASinkContext, EDASinkDurableBatch, EDASinkRegistry, EDASinkRegistryShape, EDASinkRunnerStartInput };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/services/span-names.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Allowlist of meaningful spans owned by the reusable durable-agent runtime.
|
|
4
|
+
*
|
|
5
|
+
* Add a name only when the span:
|
|
6
|
+
* - represents a recognizable agent operation in the end-to-end execution flow;
|
|
7
|
+
* - owns non-trivial work whose duration, failure, or interruption is useful to diagnose; and
|
|
8
|
+
* - has a lifetime that matches that work rather than acting as an instantaneous marker.
|
|
9
|
+
*
|
|
10
|
+
* Names are stable, lowercase, dot-separated semantic paths. Start with the owning subsystem and
|
|
11
|
+
* move from general to specific, ending with the operation, for example `agent.command.submit`.
|
|
12
|
+
* Describe domain work, not TypeScript symbols, class names, EDA prefixes, or helper mechanics.
|
|
13
|
+
* Keep names low-cardinality: IDs, tool or sink names, providers, models, attempts, and outcomes are
|
|
14
|
+
* span attributes, never name segments.
|
|
15
|
+
*
|
|
16
|
+
* Prefer `Effect.fn("...")` when a function owns the operation and `Effect.withSpan("...")` around
|
|
17
|
+
* an existing effect boundary. Do not add spans for pure transforms, bookkeeping, condition checks,
|
|
18
|
+
* retry-delay calculations, or other near-zero-width implementation steps. Use unnamed `Effect.fn`
|
|
19
|
+
* when a function benefits from Effect structure but would not add a useful node to the trace.
|
|
20
|
+
*
|
|
21
|
+
* Application-specific operations belong in the application catalog, not this reusable catalog.
|
|
22
|
+
*/
|
|
23
|
+
declare const SpanNames: readonly ["agent.command.submit", "agent.command.submit.wait", "agent.command.wait", "agent.compaction", "agent.events.follow", "agent.events.stream", "agent.inference", "agent.messages.list", "agent.run", "agent.session.snapshot", "agent.sink.drain", "agent.tool", "agent.turn"];
|
|
24
|
+
/** Union of values admitted by the centralized EDA span-name catalog. */
|
|
25
|
+
type SpanName = (typeof SpanNames)[number];
|
|
26
|
+
//#endregion
|
|
27
|
+
export { SpanName, SpanNames };
|
|
28
|
+
//# sourceMappingURL=span-names.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/services/span-names.ts
|
|
2
|
+
const defineSpanNames = (names) => names;
|
|
3
|
+
/**
|
|
4
|
+
* Allowlist of meaningful spans owned by the reusable durable-agent runtime.
|
|
5
|
+
*
|
|
6
|
+
* Add a name only when the span:
|
|
7
|
+
* - represents a recognizable agent operation in the end-to-end execution flow;
|
|
8
|
+
* - owns non-trivial work whose duration, failure, or interruption is useful to diagnose; and
|
|
9
|
+
* - has a lifetime that matches that work rather than acting as an instantaneous marker.
|
|
10
|
+
*
|
|
11
|
+
* Names are stable, lowercase, dot-separated semantic paths. Start with the owning subsystem and
|
|
12
|
+
* move from general to specific, ending with the operation, for example `agent.command.submit`.
|
|
13
|
+
* Describe domain work, not TypeScript symbols, class names, EDA prefixes, or helper mechanics.
|
|
14
|
+
* Keep names low-cardinality: IDs, tool or sink names, providers, models, attempts, and outcomes are
|
|
15
|
+
* span attributes, never name segments.
|
|
16
|
+
*
|
|
17
|
+
* Prefer `Effect.fn("...")` when a function owns the operation and `Effect.withSpan("...")` around
|
|
18
|
+
* an existing effect boundary. Do not add spans for pure transforms, bookkeeping, condition checks,
|
|
19
|
+
* retry-delay calculations, or other near-zero-width implementation steps. Use unnamed `Effect.fn`
|
|
20
|
+
* when a function benefits from Effect structure but would not add a useful node to the trace.
|
|
21
|
+
*
|
|
22
|
+
* Application-specific operations belong in the application catalog, not this reusable catalog.
|
|
23
|
+
*/
|
|
24
|
+
const SpanNames = defineSpanNames([
|
|
25
|
+
"agent.command.submit",
|
|
26
|
+
"agent.command.submit.wait",
|
|
27
|
+
"agent.command.wait",
|
|
28
|
+
"agent.compaction",
|
|
29
|
+
"agent.events.follow",
|
|
30
|
+
"agent.events.stream",
|
|
31
|
+
"agent.inference",
|
|
32
|
+
"agent.messages.list",
|
|
33
|
+
"agent.run",
|
|
34
|
+
"agent.session.snapshot",
|
|
35
|
+
"agent.sink.drain",
|
|
36
|
+
"agent.tool",
|
|
37
|
+
"agent.turn"
|
|
38
|
+
]);
|
|
39
|
+
//#endregion
|
|
40
|
+
export { SpanNames };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=span-names.js.map
|
|
@@ -0,0 +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.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;AACF,CAAC"}
|
|
@@ -0,0 +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-CcnkAAQK.js";
|
|
2
|
+
export { EDAModelToolkit, EDAToolExecutionContext, EDAToolRegistry, EDAToolRegistryShape, ToolParamsSchema, makeEDAToolkit };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import "effect/Schema";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
6
|
+
import * as Tool from "effect/unstable/ai/Tool";
|
|
7
|
+
import * as Toolkit from "effect/unstable/ai/Toolkit";
|
|
8
|
+
//#region src/services/tool-registry.ts
|
|
9
|
+
/** Build a handler-backed Effect Toolkit from tools and handlers. */
|
|
10
|
+
const makeEDAToolkit = (tools, handlers) => {
|
|
11
|
+
const toolkit = Toolkit.make(...tools);
|
|
12
|
+
return toolkit.pipe(Effect.provide(toolkit.toLayer(handlers)), Effect.map((withHandlers) => withHandlers));
|
|
13
|
+
};
|
|
14
|
+
const makeToolRegistry = (toolkit) => ({
|
|
15
|
+
getParamsSchema: (toolName) => Effect.succeed(toolkit?.tools[toolName]?.parametersSchema),
|
|
16
|
+
getModelToolkit: () => Effect.succeed(toolkit),
|
|
17
|
+
execute: (toolName, params, _context) => Effect.gen(function* () {
|
|
18
|
+
if (toolkit === void 0 || toolkit.tools[toolName] === void 0) return yield* Effect.fail(/* @__PURE__ */ new Error(`No handler registered for tool ${toolName}`));
|
|
19
|
+
const results = yield* (yield* toolkit.handle(toolName, params)).pipe(Stream.runCollect);
|
|
20
|
+
const final = Array.from(results).filter((result) => !result.preliminary).at(-1);
|
|
21
|
+
if (final === void 0) return yield* Effect.fail(/* @__PURE__ */ new Error(`Tool ${toolName} completed without a final result`));
|
|
22
|
+
if (final.isFailure) return yield* Effect.fail(final.result);
|
|
23
|
+
return final.encodedResult;
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
const toolkitFromSchemas = (schemas) => {
|
|
27
|
+
if (schemas.size === 0) return;
|
|
28
|
+
return {
|
|
29
|
+
tools: Object.fromEntries(Array.from(schemas.entries()).map(([name, schema]) => [name, Tool.dynamic(name, { parameters: schema })])),
|
|
30
|
+
handle: ((name) => Effect.die(/* @__PURE__ */ new Error(`No test handler registered for schema-only tool ${name}`)))
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Registry of Effect AI tools available to the model and EDA lifecycle executor. */
|
|
34
|
+
var EDAToolRegistry = class EDAToolRegistry extends Context.Service()("@effect-durable-agent/EDAToolRegistry") {
|
|
35
|
+
static Empty = Layer.succeed(EDAToolRegistry, makeToolRegistry(void 0));
|
|
36
|
+
static FromToolkit = (toolkit) => Layer.succeed(EDAToolRegistry, makeToolRegistry(toolkit));
|
|
37
|
+
static FromToolkitEffect = (toolkit) => Layer.effect(EDAToolRegistry, toolkit.pipe(Effect.map((withHandlers) => makeToolRegistry(withHandlers))));
|
|
38
|
+
static FromShape = (shape) => Layer.succeed(EDAToolRegistry, shape);
|
|
39
|
+
static FromShapeEffect = (shape) => Layer.effect(EDAToolRegistry, shape);
|
|
40
|
+
/** Test/convenience schema-only tools. Runtime execution will fail unless a real Toolkit is provided. */
|
|
41
|
+
static FromSchemas = (schemas) => Layer.succeed(EDAToolRegistry, makeToolRegistry(toolkitFromSchemas(schemas)));
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { EDAToolRegistry, makeEDAToolkit };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","names":[],"sources":["../../src/services/tool-registry.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\nimport * as Tool from \"effect/unstable/ai/Tool\";\nimport * as Toolkit from \"effect/unstable/ai/Toolkit\";\n\nimport { EventId, SessionId, ToolCallId } from \"../types/core\";\nimport { DurableEventEnvelope, ToolName } from \"../types/events\";\nimport type { CommittedDurableEvent, EDASessionStoreError } from \"./session-store\";\n\n/** Runtime parameter schema associated with a provider-visible tool name. */\nexport type ToolParamsSchema = Schema.Top;\n\n/** Provider-visible Effect AI toolkit with handlers available for local execution. */\nexport type EDAModelToolkit = Toolkit.WithHandler<Record<string, Tool.Any>>;\n\n/** Framework context passed to product tool handlers without model-visible params. */\nexport interface EDAToolExecutionContext {\n /** Framework-owned tool-call identity for this execution. */\n readonly toolCallId: ToolCallId;\n /** Session identity fixed for this runtime instance. */\n readonly sessionId: SessionId;\n /** Mint an app durable event id for tool-emitted facts. */\n readonly makeEventId: () => Effect.Effect<EventId>;\n /** Emit an app durable event through `SessionState`, never directly through the store. */\n readonly emitDurable: (\n event: DurableEventEnvelope,\n ) => Effect.Effect<CommittedDurableEvent, EDASessionStoreError>;\n}\n\n/** Registry contract used by model streaming and post-finish tool execution. */\nexport interface EDAToolRegistryShape {\n /** Look up the parameter schema for a registered tool name. */\n readonly getParamsSchema: (toolName: ToolName) => Effect.Effect<ToolParamsSchema | undefined>;\n /** Build provider-visible tool definitions while keeping EDA in charge of lifecycle events. */\n readonly getModelToolkit: () => Effect.Effect<EDAModelToolkit | undefined>;\n /** Execute a tool. EDA records the durable lifecycle around this effect. */\n readonly execute: (\n toolName: ToolName,\n params: unknown,\n context: EDAToolExecutionContext,\n ) => Effect.Effect<unknown, unknown>;\n}\n\n/** Build a handler-backed Effect Toolkit from tools and handlers. */\nexport const makeEDAToolkit = <const Tools extends ReadonlyArray<Tool.Any>>(\n tools: Tools,\n handlers: Toolkit.HandlersFrom<Toolkit.ToolsByName<Tools>>,\n): Effect.Effect<EDAModelToolkit> => {\n const toolkit = Toolkit.make(...tools);\n return toolkit.pipe(\n Effect.provide(toolkit.toLayer(handlers)),\n Effect.map((withHandlers) => withHandlers as unknown as EDAModelToolkit),\n );\n};\n\nconst makeToolRegistry = (toolkit: EDAModelToolkit | undefined): EDAToolRegistryShape => ({\n getParamsSchema: (toolName) => Effect.succeed(toolkit?.tools[toolName]?.parametersSchema),\n getModelToolkit: () => Effect.succeed(toolkit),\n execute: (toolName, params, _context) =>\n Effect.gen(function* () {\n if (toolkit === undefined || toolkit.tools[toolName] === undefined) {\n return yield* Effect.fail(new Error(`No handler registered for tool ${toolName}`));\n }\n\n const results = yield* (yield* toolkit.handle(toolName, params)).pipe(Stream.runCollect);\n const final = Array.from(results)\n .filter((result) => !result.preliminary)\n .at(-1);\n if (final === undefined) {\n return yield* Effect.fail(new Error(`Tool ${toolName} completed without a final result`));\n }\n if (final.isFailure) {\n return yield* Effect.fail(final.result);\n }\n return final.encodedResult;\n }) as Effect.Effect<unknown, unknown>,\n});\n\nconst toolkitFromSchemas = (\n schemas: ReadonlyMap<string, ToolParamsSchema>,\n): EDAModelToolkit | undefined => {\n if (schemas.size === 0) {\n return undefined;\n }\n\n const tools = Object.fromEntries(\n Array.from(schemas.entries()).map(([name, schema]) => [\n name,\n Tool.dynamic(name, { parameters: schema }),\n ]),\n );\n\n return {\n tools,\n handle: ((name: string) =>\n Effect.die(\n new Error(`No test handler registered for schema-only tool ${name}`),\n )) as unknown as EDAModelToolkit[\"handle\"],\n };\n};\n\n/** Registry of Effect AI tools available to the model and EDA lifecycle executor. */\nexport class EDAToolRegistry extends Context.Service<EDAToolRegistry, EDAToolRegistryShape>()(\n \"@effect-durable-agent/EDAToolRegistry\",\n) {\n static readonly Empty = Layer.succeed(EDAToolRegistry, makeToolRegistry(undefined));\n\n static readonly FromToolkit = (toolkit: EDAModelToolkit) =>\n Layer.succeed(EDAToolRegistry, makeToolRegistry(toolkit));\n\n static readonly FromToolkitEffect = <E, R>(toolkit: Effect.Effect<EDAModelToolkit, E, R>) =>\n Layer.effect(\n EDAToolRegistry,\n toolkit.pipe(Effect.map((withHandlers) => makeToolRegistry(withHandlers))),\n );\n\n static readonly FromShape = (shape: EDAToolRegistryShape) =>\n Layer.succeed(EDAToolRegistry, shape);\n\n static readonly FromShapeEffect = <E, R>(shape: Effect.Effect<EDAToolRegistryShape, E, R>) =>\n Layer.effect(EDAToolRegistry, shape);\n\n /** Test/convenience schema-only tools. Runtime execution will fail unless a real Toolkit is provided. */\n static readonly FromSchemas = (schemas: ReadonlyMap<string, ToolParamsSchema>) =>\n Layer.succeed(EDAToolRegistry, makeToolRegistry(toolkitFromSchemas(schemas)));\n}\n"],"mappings":";;;;;;;;;AA+CA,MAAa,kBACX,OACA,aACmC;CACnC,MAAM,UAAU,QAAQ,KAAK,GAAG,KAAK;CACrC,OAAO,QAAQ,KACb,OAAO,QAAQ,QAAQ,QAAQ,QAAQ,CAAC,GACxC,OAAO,KAAK,iBAAiB,YAA0C,CACzE;AACF;AAEA,MAAM,oBAAoB,aAAgE;CACxF,kBAAkB,aAAa,OAAO,QAAQ,SAAS,MAAM,WAAW,gBAAgB;CACxF,uBAAuB,OAAO,QAAQ,OAAO;CAC7C,UAAU,UAAU,QAAQ,aAC1B,OAAO,IAAI,aAAa;EACtB,IAAI,YAAY,KAAA,KAAa,QAAQ,MAAM,cAAc,KAAA,GACvD,OAAO,OAAO,OAAO,qBAAK,IAAI,MAAM,kCAAkC,UAAU,CAAC;EAGnF,MAAM,UAAU,QAAQ,OAAO,QAAQ,OAAO,UAAU,MAAM,GAAG,KAAK,OAAO,UAAU;EACvF,MAAM,QAAQ,MAAM,KAAK,OAAO,EAC7B,QAAQ,WAAW,CAAC,OAAO,WAAW,EACtC,GAAG,EAAE;EACR,IAAI,UAAU,KAAA,GACZ,OAAO,OAAO,OAAO,qBAAK,IAAI,MAAM,QAAQ,SAAS,kCAAkC,CAAC;EAE1F,IAAI,MAAM,WACR,OAAO,OAAO,OAAO,KAAK,MAAM,MAAM;EAExC,OAAO,MAAM;CACf,CAAC;AACL;AAEA,MAAM,sBACJ,YACgC;CAChC,IAAI,QAAQ,SAAS,GACnB;CAUF,OAAO;EACL,OARY,OAAO,YACnB,MAAM,KAAK,QAAQ,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,YAAY,CACpD,MACA,KAAK,QAAQ,MAAM,EAAE,YAAY,OAAO,CAAC,CAC3C,CAAC,CAIG;EACJ,UAAU,SACR,OAAO,oBACL,IAAI,MAAM,mDAAmD,MAAM,CACrE;CACJ;AACF;;AAGA,IAAa,kBAAb,MAAa,wBAAwB,QAAQ,QAA+C,EAC1F,uCACF,EAAE;CACA,OAAgB,QAAQ,MAAM,QAAQ,iBAAiB,iBAAiB,KAAA,CAAS,CAAC;CAElF,OAAgB,eAAe,YAC7B,MAAM,QAAQ,iBAAiB,iBAAiB,OAAO,CAAC;CAE1D,OAAgB,qBAA2B,YACzC,MAAM,OACJ,iBACA,QAAQ,KAAK,OAAO,KAAK,iBAAiB,iBAAiB,YAAY,CAAC,CAAC,CAC3E;CAEF,OAAgB,aAAa,UAC3B,MAAM,QAAQ,iBAAiB,KAAK;CAEtC,OAAgB,mBAAyB,UACvC,MAAM,OAAO,iBAAiB,KAAK;;CAGrC,OAAgB,eAAe,YAC7B,MAAM,QAAQ,iBAAiB,iBAAiB,mBAAmB,OAAO,CAAC,CAAC;AAChF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { _ as parseEDATraceparent, c as EDATraceLink, d as makeEDAEventTrace, f as makeEDARunTrace, g as makeRootEDATraceMetadata, h as makeRootEDAEventTrace, i as EDATraceAttributeValue, l as EDATraceMetadata, m as makeEDATraceMetadataFromParent, n as EDARunTrace, o as EDATraceContext, p as makeEDATraceContext, t as EDAEventTrace, u as buildEDATraceparent } from "../tracing-BXHAkxkx.js";
|
|
2
|
+
import { U as UsagePayload } from "../events-Bb9-Cu-7.js";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Tracer from "effect/Tracer";
|
|
5
|
+
|
|
6
|
+
//#region src/services/tracing.d.ts
|
|
7
|
+
/** Attribute value types accepted by Effect span annotations after compaction. */
|
|
8
|
+
type EdaSpanAttributeValue = EDATraceAttributeValue | undefined;
|
|
9
|
+
/** EDA span attribute map; undefined values are intentionally dropped before annotation. */
|
|
10
|
+
type EdaSpanAttributes = Record<string, EdaSpanAttributeValue>;
|
|
11
|
+
interface EDATracingOptions {
|
|
12
|
+
readonly disableTracing?: boolean;
|
|
13
|
+
readonly disableSpanPropagation?: boolean;
|
|
14
|
+
readonly spanAttributes?: EdaSpanAttributes;
|
|
15
|
+
readonly spanPrefix?: string;
|
|
16
|
+
}
|
|
17
|
+
interface EDAExportedSpanLink {
|
|
18
|
+
readonly attributes: Record<string, string | number | boolean>;
|
|
19
|
+
readonly sampled: boolean;
|
|
20
|
+
readonly spanId: string;
|
|
21
|
+
readonly traceId: string;
|
|
22
|
+
}
|
|
23
|
+
interface EDAExportedSpan {
|
|
24
|
+
readonly attributes: Record<string, string | number | boolean>;
|
|
25
|
+
readonly endedAtMs: number;
|
|
26
|
+
readonly endedAtUnixNano: string;
|
|
27
|
+
readonly kind: Tracer.SpanKind;
|
|
28
|
+
readonly links: ReadonlyArray<EDAExportedSpanLink>;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly outcome: "ok" | "error" | "timeout" | "canceled";
|
|
31
|
+
readonly parentSpanId?: string;
|
|
32
|
+
readonly sampled: boolean;
|
|
33
|
+
readonly spanId: string;
|
|
34
|
+
readonly startedAtMs: number;
|
|
35
|
+
readonly startedAtUnixNano: string;
|
|
36
|
+
readonly statusCode: "OK" | "ERROR";
|
|
37
|
+
readonly statusMessage?: string;
|
|
38
|
+
readonly traceId: string;
|
|
39
|
+
}
|
|
40
|
+
interface EventLike {
|
|
41
|
+
readonly event?: {
|
|
42
|
+
readonly type?: unknown;
|
|
43
|
+
readonly durability?: unknown;
|
|
44
|
+
};
|
|
45
|
+
readonly type?: unknown;
|
|
46
|
+
}
|
|
47
|
+
interface PositionedEventLike {
|
|
48
|
+
readonly position?: {
|
|
49
|
+
readonly seq?: unknown;
|
|
50
|
+
readonly subSeq?: unknown;
|
|
51
|
+
};
|
|
52
|
+
readonly event?: {
|
|
53
|
+
readonly type?: unknown;
|
|
54
|
+
readonly durability?: unknown;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Compact undefined tracing attributes before handing them to Effect spans. */
|
|
58
|
+
declare const compactSpanAttributes: (attributes: EdaSpanAttributes) => Record<string, string | number | boolean>;
|
|
59
|
+
declare const toEdaExternalSpan: (context: EDATraceContext) => Tracer.ExternalSpan;
|
|
60
|
+
declare const edaTraceContextFromSpan: (span: Tracer.AnySpan) => EDATraceContext;
|
|
61
|
+
declare const currentEDATraceContext: Effect.Effect<EDATraceContext, unknown>;
|
|
62
|
+
declare const currentOrRootEDAEventTrace: Effect.Effect<EDAEventTrace>;
|
|
63
|
+
declare const withEdaTraceMetadata: (metadata: EDATraceMetadata) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
64
|
+
/** Add EDA attributes to the currently active span. */
|
|
65
|
+
declare const annotateEdaSpan: (attributes: EdaSpanAttributes) => Effect.Effect<void>;
|
|
66
|
+
/** Create an Effect tracer that exports only spans with observable duration. */
|
|
67
|
+
declare const makeEdaExportingTracer: (emit: (span: EDAExportedSpan) => void) => Tracer.Tracer;
|
|
68
|
+
/** Summarize a durable/logical event collection for span attributes. */
|
|
69
|
+
declare const eventBatchAttributes: (events: ReadonlyArray<EventLike>) => EdaSpanAttributes;
|
|
70
|
+
/** Summarize a committed positioned event collection for span attributes. */
|
|
71
|
+
declare const committedBatchAttributes: (events: ReadonlyArray<PositionedEventLike>) => EdaSpanAttributes;
|
|
72
|
+
/** Stable, low-cardinality usage attributes for model lifecycle spans. */
|
|
73
|
+
declare const usageAttributes: (usage: UsagePayload | undefined) => EdaSpanAttributes;
|
|
74
|
+
//#endregion
|
|
75
|
+
export { EDAEventTrace, EDAExportedSpan, EDAExportedSpanLink, EDARunTrace, EDATraceContext, EDATraceLink, EDATraceMetadata, EDATracingOptions, EdaSpanAttributeValue, EdaSpanAttributes, annotateEdaSpan, buildEDATraceparent, committedBatchAttributes, compactSpanAttributes, currentEDATraceContext, currentOrRootEDAEventTrace, edaTraceContextFromSpan, eventBatchAttributes, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEdaExportingTracer, makeRootEDAEventTrace, makeRootEDATraceMetadata, parseEDATraceparent, toEdaExternalSpan, usageAttributes, withEdaTraceMetadata };
|
|
76
|
+
//# sourceMappingURL=tracing.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { EDAEventTrace, EDARunTrace, EDATraceContext, EDATraceLink, EDATraceMetadata, buildEDATraceparent, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeRootEDAEventTrace, makeRootEDATraceMetadata, parseEDATraceparent } from "../types/tracing.js";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Cause from "effect/Cause";
|
|
4
|
+
import * as Exit from "effect/Exit";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
import * as Tracer from "effect/Tracer";
|
|
7
|
+
//#region src/services/tracing.ts
|
|
8
|
+
/** Compact undefined tracing attributes before handing them to Effect spans. */
|
|
9
|
+
const compactSpanAttributes = (attributes) => {
|
|
10
|
+
const compacted = {};
|
|
11
|
+
for (const [key, value] of Object.entries(attributes)) if (value !== void 0) compacted[key] = value;
|
|
12
|
+
return compacted;
|
|
13
|
+
};
|
|
14
|
+
const compactUnknownAttributes = (attributes) => {
|
|
15
|
+
const entries = attributes instanceof Map ? attributes.entries() : Object.entries(attributes);
|
|
16
|
+
const compacted = {};
|
|
17
|
+
for (const [key, value] of entries) if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") compacted[key] = value;
|
|
18
|
+
return compacted;
|
|
19
|
+
};
|
|
20
|
+
const toEdaExternalSpan = (context) => Tracer.externalSpan({
|
|
21
|
+
traceId: context.traceId,
|
|
22
|
+
spanId: context.spanId,
|
|
23
|
+
sampled: context.sampled
|
|
24
|
+
});
|
|
25
|
+
const edaTraceContextFromSpan = (span) => makeEDATraceContext({
|
|
26
|
+
traceId: span.traceId,
|
|
27
|
+
spanId: span.spanId,
|
|
28
|
+
sampled: span.sampled,
|
|
29
|
+
tracestate: null
|
|
30
|
+
});
|
|
31
|
+
const currentEDATraceContext = Effect.currentSpan.pipe(Effect.map(edaTraceContextFromSpan));
|
|
32
|
+
const currentOrRootEDAEventTrace = Effect.currentSpan.pipe(Effect.map((span) => makeEDAEventTrace(edaTraceContextFromSpan(span))), Effect.catch(() => Effect.sync(makeRootEDAEventTrace)));
|
|
33
|
+
const withEdaTraceMetadata = (metadata) => (effect) => effect.pipe(Effect.annotateSpans(metadata.attributes));
|
|
34
|
+
/** Add EDA attributes to the currently active span. */
|
|
35
|
+
const annotateEdaSpan = (attributes) => Effect.annotateCurrentSpan(compactSpanAttributes(attributes));
|
|
36
|
+
const nanosToMillis = (nanos) => Number(nanos / 1000000n);
|
|
37
|
+
const outcomeFromExit = (exit) => {
|
|
38
|
+
if (Exit.isSuccess(exit)) return "ok";
|
|
39
|
+
return Cause.hasInterruptsOnly(exit.cause) ? "canceled" : "error";
|
|
40
|
+
};
|
|
41
|
+
const statusMessageFromExit = (exit) => {
|
|
42
|
+
if (Exit.isSuccess(exit)) return;
|
|
43
|
+
const error = Cause.squash(exit.cause);
|
|
44
|
+
return error instanceof Error ? error.message : String(error);
|
|
45
|
+
};
|
|
46
|
+
var ExportingNativeSpan = class extends Tracer.NativeSpan {
|
|
47
|
+
#emit;
|
|
48
|
+
constructor(options, emit) {
|
|
49
|
+
super(options);
|
|
50
|
+
this.#emit = emit;
|
|
51
|
+
}
|
|
52
|
+
end(endTime, exit) {
|
|
53
|
+
super.end(endTime, exit);
|
|
54
|
+
if (endTime <= this.startTime) return;
|
|
55
|
+
const parent = Option.getOrUndefined(this.parent);
|
|
56
|
+
this.#emit({
|
|
57
|
+
attributes: compactUnknownAttributes(this.attributes),
|
|
58
|
+
endedAtMs: nanosToMillis(endTime),
|
|
59
|
+
endedAtUnixNano: endTime.toString(),
|
|
60
|
+
kind: this.kind,
|
|
61
|
+
links: this.links.map((link) => ({
|
|
62
|
+
attributes: compactUnknownAttributes(link.attributes),
|
|
63
|
+
traceId: link.span.traceId,
|
|
64
|
+
spanId: link.span.spanId,
|
|
65
|
+
sampled: link.span.sampled
|
|
66
|
+
})),
|
|
67
|
+
name: this.name,
|
|
68
|
+
outcome: outcomeFromExit(exit),
|
|
69
|
+
...parent === void 0 ? {} : { parentSpanId: parent.spanId },
|
|
70
|
+
sampled: this.sampled,
|
|
71
|
+
spanId: this.spanId,
|
|
72
|
+
startedAtMs: nanosToMillis(this.startTime),
|
|
73
|
+
startedAtUnixNano: this.startTime.toString(),
|
|
74
|
+
statusCode: Exit.isSuccess(exit) ? "OK" : "ERROR",
|
|
75
|
+
...statusMessageFromExit(exit) === void 0 ? {} : { statusMessage: statusMessageFromExit(exit) },
|
|
76
|
+
traceId: this.traceId
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/** Create an Effect tracer that exports only spans with observable duration. */
|
|
81
|
+
const makeEdaExportingTracer = (emit) => Tracer.make({ span: (options) => new ExportingNativeSpan(options, emit) });
|
|
82
|
+
/** Summarize a durable/logical event collection for span attributes. */
|
|
83
|
+
const eventBatchAttributes = (events) => ({
|
|
84
|
+
"eda.event.count": events.length,
|
|
85
|
+
"eda.event.types": eventTypeSummary(events)
|
|
86
|
+
});
|
|
87
|
+
/** Summarize a committed positioned event collection for span attributes. */
|
|
88
|
+
const committedBatchAttributes = (events) => {
|
|
89
|
+
const seqs = events.map((entry) => entry.position?.seq).filter((seq) => typeof seq === "number");
|
|
90
|
+
return {
|
|
91
|
+
...eventBatchAttributes(events),
|
|
92
|
+
"eda.seq.min": seqs.length === 0 ? void 0 : Math.min(...seqs),
|
|
93
|
+
"eda.seq.max": seqs.length === 0 ? void 0 : Math.max(...seqs)
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/** Stable, low-cardinality usage attributes for model lifecycle spans. */
|
|
97
|
+
const usageAttributes = (usage) => ({
|
|
98
|
+
"eda.usage.input_tokens": usage?.inputTokens,
|
|
99
|
+
"eda.usage.cached_input_tokens": usage?.cachedInputTokens,
|
|
100
|
+
"eda.usage.output_tokens": usage?.outputTokens,
|
|
101
|
+
"eda.usage.text_tokens": usage?.textTokens,
|
|
102
|
+
"eda.usage.reasoning_tokens": usage?.reasoningTokens
|
|
103
|
+
});
|
|
104
|
+
const eventTypeSummary = (events) => {
|
|
105
|
+
if (events.length === 0) return;
|
|
106
|
+
const seen = /* @__PURE__ */ new Set();
|
|
107
|
+
for (const event of events) {
|
|
108
|
+
const type = event.event?.type ?? event.type;
|
|
109
|
+
if (typeof type === "string") seen.add(type);
|
|
110
|
+
}
|
|
111
|
+
return seen.size === 0 ? void 0 : Array.from(seen).join(",");
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { EDAEventTrace, EDARunTrace, EDATraceContext, EDATraceLink, EDATraceMetadata, annotateEdaSpan, buildEDATraceparent, committedBatchAttributes, compactSpanAttributes, currentEDATraceContext, currentOrRootEDAEventTrace, edaTraceContextFromSpan, eventBatchAttributes, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeEdaExportingTracer, makeRootEDAEventTrace, makeRootEDATraceMetadata, parseEDATraceparent, toEdaExternalSpan, usageAttributes, withEdaTraceMetadata };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=tracing.js.map
|
|
@@ -0,0 +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,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