effect-durable-agent 0.1.0-alpha.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/assert-never-CoyUpoRB.js +18 -0
- package/dist/assert-never-CoyUpoRB.js.map +1 -0
- package/dist/{commands-Ce1ec6kH.d.ts → commands-BUquEZVP.d.ts} +31 -12
- package/dist/{compaction-BgDr5VJy.js → compaction-D7WJa899.js} +63 -13
- package/dist/compaction-D7WJa899.js.map +1 -0
- package/dist/{context-projection-n6Rdup0N.d.ts → context-projection-Bezx3drD.d.ts} +16 -40
- package/dist/{core-CYT6DBaS.d.ts → core-BcimKMIv.d.ts} +5 -3
- package/dist/delivery-B_LDTuIB.d.ts +3169 -0
- package/dist/delivery-BoF-NZbZ.js +507 -0
- package/dist/delivery-BoF-NZbZ.js.map +1 -0
- package/dist/domain/command-queues.d.ts +81 -2
- package/dist/domain/command-queues.js +1 -1
- package/dist/domain/command-queues.js.map +1 -1
- package/dist/domain/context-projection.d.ts +1 -1
- package/dist/domain/context-projection.js +1 -1
- package/dist/domain/context-projection.js.map +1 -1
- package/dist/domain/message-transcript.d.ts +36 -2
- package/dist/domain/message-transcript.js +10 -2
- package/dist/domain/message-transcript.js.map +1 -1
- package/dist/domain/model-usage.d.ts +1 -1
- package/dist/domain/model-usage.js +1 -1
- package/dist/domain/reduced-state-schema.d.ts +3 -992
- package/dist/domain/reduced-state-schema.js +126 -7
- package/dist/domain/reduced-state-schema.js.map +1 -1
- package/dist/domain/reduced-state.d.ts +2 -2
- package/dist/domain/reduced-state.js +937 -2
- package/dist/domain/reduced-state.js.map +1 -0
- package/dist/domain/run-scheduling.d.ts +2 -0
- package/dist/domain/run-scheduling.js +127 -0
- package/dist/domain/run-scheduling.js.map +1 -0
- package/dist/{durable-br2C1bWK.d.ts → durable-BXqwM70o.d.ts} +8983 -2800
- package/dist/{durable-BGFvX7Mh.js → durable-Da57Rcml.js} +243 -15
- package/dist/durable-Da57Rcml.js.map +1 -0
- package/dist/{envelope-DxQzo5rN.js → envelope-BSI_Xh-f.js} +31 -6
- package/dist/envelope-BSI_Xh-f.js.map +1 -0
- package/dist/{envelope-DkZyMIgp.d.ts → envelope-CJnPfbjC.d.ts} +121 -11
- package/dist/{event-factory-DTFdy0Cb.js → event-factory-BUoBwqAy.js} +7 -3
- package/dist/event-factory-BUoBwqAy.js.map +1 -0
- package/dist/{events-LZFNoESe.d.ts → events-AIIwZ6dS.d.ts} +139 -137
- package/dist/{id-generator-Ckl8_XWW.d.ts → id-generator-BKGoKjt-.d.ts} +3 -3
- package/dist/in-memory-E497WhtS.js +150 -0
- package/dist/in-memory-E497WhtS.js.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +6 -6
- package/dist/interpreter-BwYN2PCC.js +1453 -0
- package/dist/interpreter-BwYN2PCC.js.map +1 -0
- package/dist/{keep-alive-Chl5SJxy.d.ts → keep-alive-_zFCUvt3.d.ts} +1 -2
- package/dist/{model-resolver-BPPJAsuh.d.ts → model-resolver-O8Kn27GH.d.ts} +11 -5
- package/dist/{model-usage-CdBEkTwU.d.ts → model-usage-mttrPN0j.d.ts} +2 -3
- package/dist/records-D0ZIAOzd.js +675 -0
- package/dist/records-D0ZIAOzd.js.map +1 -0
- package/dist/reduced-state-YbjpihEf.d.ts +52933 -0
- package/dist/reduced-state-schema-B9TYxkP9.d.ts +2338 -0
- package/dist/{reducer-registry-aFjz_ZLT.d.ts → reducer-registry-Bqn5B4JO.d.ts} +12 -6
- package/dist/run-scheduling-wakeup-DX2zRAxd.d.ts +24 -0
- package/dist/services/compaction.d.ts +2 -2
- package/dist/services/compaction.js +2 -2
- package/dist/services/decider.d.ts +2 -0
- package/dist/services/decider.js +97 -0
- package/dist/services/decider.js.map +1 -0
- package/dist/services/id-generator.d.ts +1 -1
- package/dist/services/id-generator.js +6 -12
- package/dist/services/id-generator.js.map +1 -1
- package/dist/services/keep-alive.d.ts +1 -1
- package/dist/services/keep-alive.js.map +1 -1
- package/dist/services/model-call.d.ts +15 -0
- package/dist/services/model-call.js +15 -0
- package/dist/services/model-call.js.map +1 -0
- package/dist/services/model-resolver.d.ts +1 -1
- package/dist/services/model-resolver.js +1 -1
- package/dist/services/model-resolver.js.map +1 -1
- package/dist/services/prompt-projector.d.ts +2 -2
- package/dist/services/prompt-projector.js +49 -5
- package/dist/services/prompt-projector.js.map +1 -1
- package/dist/services/reducer-registry.d.ts +1 -1
- package/dist/services/reducer-registry.js +19 -6
- package/dist/services/reducer-registry.js.map +1 -1
- package/dist/services/run-scheduler.d.ts +2 -2
- package/dist/services/run-scheduler.js +25 -2
- package/dist/services/run-scheduler.js.map +1 -0
- package/dist/services/run-scheduling-wakeup.d.ts +2 -0
- package/dist/services/run-scheduling-wakeup.js +13 -0
- package/dist/services/run-scheduling-wakeup.js.map +1 -0
- package/dist/services/runtime-layer.d.ts +21 -33
- package/dist/services/runtime-layer.js +24 -16
- package/dist/services/runtime-layer.js.map +1 -1
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +32 -20
- package/dist/services/runtime.js.map +1 -1
- package/dist/services/session-event-observer.d.ts +1 -1
- package/dist/services/session-event-observer.js.map +1 -1
- package/dist/services/session-query.d.ts +1 -1
- package/dist/services/session-query.js +57 -10
- package/dist/services/session-query.js.map +1 -1
- package/dist/services/session-state.d.ts +2 -2
- package/dist/services/session-state.js +2 -1
- package/dist/services/session-store.d.ts +2 -2
- package/dist/services/session-store.js +143 -38
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/sink-checkpoint-store.d.ts +1 -1
- package/dist/services/sink-checkpoint-store.js +2 -1
- package/dist/services/sink-checkpoint-store.js.map +1 -1
- package/dist/services/sink-registry.d.ts +2 -2
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/span-names.d.ts +1 -1
- package/dist/services/span-names.js +7 -1
- package/dist/services/span-names.js.map +1 -1
- package/dist/services/tool-registry.d.ts +2 -2
- package/dist/services/tool-registry.js +12 -3
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/tracing.d.ts +3 -3
- package/dist/services/tracing.js +2 -2
- package/dist/services/tracing.js.map +1 -1
- package/dist/session-admission-WE8J_0z9.js +138 -0
- package/dist/session-admission-WE8J_0z9.js.map +1 -0
- package/dist/{session-event-observer-DaFMKKNc.d.ts → session-event-observer-BWQUJTcN.d.ts} +3 -3
- package/dist/{session-state-Bkc6u-Wr.js → session-state-D02LCVcC.js} +815 -170
- package/dist/session-state-D02LCVcC.js.map +1 -0
- package/dist/session-store-DaSHeg8Q.d.ts +3343 -0
- package/dist/{sink-checkpoint-store-M7qIxoSH.d.ts → sink-checkpoint-store-CUvIVvlZ.d.ts} +3 -4
- package/dist/sink-registry-AOjX5_A1.js +369 -0
- package/dist/sink-registry-AOjX5_A1.js.map +1 -0
- package/dist/subscription-BhwUmsl4.d.ts +966 -0
- package/dist/subscription-D7U4Tziv.js +505 -0
- package/dist/subscription-D7U4Tziv.js.map +1 -0
- package/dist/testkit/layers.d.ts +33 -23
- package/dist/testkit/layers.js +34 -19
- package/dist/testkit/layers.js.map +1 -1
- package/dist/testkit/transcript.d.ts +232 -0
- package/dist/testkit/transcript.js +1526 -0
- package/dist/testkit/transcript.js.map +1 -0
- package/dist/{tracing-BXHAkxkx.d.ts → tracing-BwjbF285.d.ts} +1 -2
- package/dist/transcript.d.ts +101 -0
- package/dist/transcript.js +107 -0
- package/dist/transcript.js.map +1 -0
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/commands.js +8 -3
- package/dist/types/commands.js.map +1 -1
- package/dist/types/core.d.ts +2 -2
- package/dist/types/core.js +3 -1
- package/dist/types/core.js.map +1 -1
- package/dist/types/events/durable.d.ts +2 -2
- package/dist/types/events/durable.js +2 -2
- package/dist/types/events.d.ts +5 -5
- package/dist/types/events.js +3 -3
- package/dist/types/tracing.d.ts +1 -1
- package/dist/types/tracing.js.map +1 -1
- package/dist/websocket/events.d.ts +2 -0
- package/dist/websocket/events.js +2 -0
- package/dist/websocket.d.ts +2123 -2552
- package/dist/websocket.js +628 -442
- package/dist/websocket.js.map +1 -1
- package/dist/window-read-BELSkO-r.d.ts +113 -0
- package/dist/window-read-FJTCDaSq.js +264 -0
- package/dist/window-read-FJTCDaSq.js.map +1 -0
- package/package.json +41 -13
- package/dist/command-queues-DdDB_aYM.d.ts +0 -462
- package/dist/compaction-BgDr5VJy.js.map +0 -1
- package/dist/compaction-ch8z6G9x.d.ts +0 -165
- package/dist/durable-BGFvX7Mh.js.map +0 -1
- package/dist/envelope-DxQzo5rN.js.map +0 -1
- package/dist/event-factory-DTFdy0Cb.js.map +0 -1
- package/dist/event-factory-Di1jwQvm.d.ts +0 -87
- package/dist/index-BVVgDSdq.d.ts +0 -1
- package/dist/message-transcript-DQNlzxle.d.ts +0 -32
- package/dist/prompt-projector-f4ElyXCE.d.ts +0 -39
- package/dist/reduced-state-DF0-6mbR.js +0 -921
- package/dist/reduced-state-DF0-6mbR.js.map +0 -1
- package/dist/run-scheduler-CAt7dF6C.js +0 -21
- package/dist/run-scheduler-CAt7dF6C.js.map +0 -1
- package/dist/run-scheduler-xkhZyto5.d.ts +0 -44
- package/dist/runtime-DDSYP9jS.d.ts +0 -63
- package/dist/session-query-B72HY_0L.d.ts +0 -45
- package/dist/session-state-Bkc6u-Wr.js.map +0 -1
- package/dist/session-state-C9YLSAso.d.ts +0 -862
- package/dist/session-store-Cpi_NwTR.d.ts +0 -206
- package/dist/sink-registry-Bl-vQES6.d.ts +0 -133
- package/dist/sink-registry-NDgeyzO0.js +0 -272
- package/dist/sink-registry-NDgeyzO0.js.map +0 -1
- package/dist/tool-registry-BJaVNtw4.d.ts +0 -51
|
@@ -3,9 +3,18 @@ import * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
import "effect/Schema";
|
|
5
5
|
import * as Stream from "effect/Stream";
|
|
6
|
-
import * as Tool from "effect/
|
|
7
|
-
import * as Toolkit from "effect/
|
|
6
|
+
import * as Tool from "effect/ai/Tool";
|
|
7
|
+
import * as Toolkit from "effect/ai/Toolkit";
|
|
8
8
|
//#region src/services/tool-registry.ts
|
|
9
|
+
/** Effect AI tool annotation declaring a tool's {@link ToolRecoveryPolicy}. */
|
|
10
|
+
const ToolRecovery = Context.Reference("effect-durable-agent/ToolRecovery", { defaultValue: () => "fail" });
|
|
11
|
+
/** Total execution attempts, including the first, that recovery allows one tool call. */
|
|
12
|
+
const maxToolCallAttempts = 3;
|
|
13
|
+
/** The recovery policy a toolkit declares for `toolName`; `fail` for unknown tools. */
|
|
14
|
+
const toolRecoveryPolicy = (toolkit, toolName) => {
|
|
15
|
+
const tool = toolkit?.tools[toolName];
|
|
16
|
+
return tool === void 0 ? "fail" : Context.get(tool.annotations, ToolRecovery);
|
|
17
|
+
};
|
|
9
18
|
/** Build a handler-backed Effect Toolkit from tools and handlers. */
|
|
10
19
|
const makeEDAToolkit = (tools, handlers) => {
|
|
11
20
|
const toolkit = Toolkit.make(...tools);
|
|
@@ -41,6 +50,6 @@ var EDAToolRegistry = class EDAToolRegistry extends Context.Service()("@effect-d
|
|
|
41
50
|
static FromSchemas = (schemas) => Layer.succeed(EDAToolRegistry, makeToolRegistry(toolkitFromSchemas(schemas)));
|
|
42
51
|
};
|
|
43
52
|
//#endregion
|
|
44
|
-
export { EDAToolRegistry, makeEDAToolkit };
|
|
53
|
+
export { EDAToolRegistry, ToolRecovery, makeEDAToolkit, maxToolCallAttempts, toolRecoveryPolicy };
|
|
45
54
|
|
|
46
55
|
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -1 +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"}
|
|
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/ai/Tool\";\nimport * as Toolkit from \"effect/ai/Toolkit\";\n\nimport { EventId, SequenceNumber, SessionId, ToolCallId, RunId, TurnId } from \"../types/core\";\nimport { DurableEventEnvelope, ToolName } from \"../types/events\";\nimport type { EDADecider, EDADeciderError, EDADeciderOutcome } from \"./decider\";\nimport type { SessionCommandAdmissionConflict } from \"./session-admission\";\nimport type { EDASessionSnapshot } from \"./session-query\";\nimport type { CommittedDurableEvent, EDASessionStoreError } from \"./session-store\";\n\n/**\n * What startup recovery does with a call to this tool that had started when the runtime died.\n *\n * - `fail` (default): record the call as failed; the model sees the interruption and decides.\n * - `reinvoke`: run the handler again with the same tool-call id and params, passing\n * {@link EDAToolExecutionContext.recovery}. Declare it only when a second invocation of the\n * same call is safe: it must attach to, or return the outcome of, the original execution\n * rather than repeat its side effects (for example an idempotency key derived from the\n * tool-call id). Recovery re-invokes at most {@link maxToolCallAttempts} times in total.\n */\nexport type ToolRecoveryPolicy = \"fail\" | \"reinvoke\";\n\n/** Effect AI tool annotation declaring a tool's {@link ToolRecoveryPolicy}. */\nexport const ToolRecovery = Context.Reference<ToolRecoveryPolicy>(\n \"effect-durable-agent/ToolRecovery\",\n { defaultValue: () => \"fail\" },\n);\n\n/** Total execution attempts, including the first, that recovery allows one tool call. */\nexport const maxToolCallAttempts = 3;\n\n/** The recovery policy a toolkit declares for `toolName`; `fail` for unknown tools. */\nexport const toolRecoveryPolicy = (\n toolkit: EDAModelToolkit | undefined,\n toolName: string,\n): ToolRecoveryPolicy => {\n const tool = toolkit?.tools[toolName];\n return tool === undefined ? \"fail\" : Context.get(tool.annotations, ToolRecovery);\n};\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 /** Run and turn that durably created this tool call. */\n readonly runId: RunId;\n readonly turnId: TurnId;\n /** Read typed facts from this session journal, optionally only those after `afterSeq`. */\n readonly queryEvents: <E extends DurableEventEnvelope>(\n schema: Schema.Codec<E, unknown, never, never>,\n options?: { readonly limit?: number; readonly afterSeq?: SequenceNumber },\n ) => Effect.Effect<ReadonlyArray<CommittedDurableEvent<E>>, EDASessionStoreError>;\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 /**\n * Emit an app durable event through `SessionState`, never directly through the store. A payload\n * that is not JSON-native, is over `maxAppEventBytes`, or does not match the registered\n * `appEvents` schema fails with a `SessionCommandAdmissionConflict` and commits nothing.\n */\n readonly emitDurable: (\n event: DurableEventEnvelope,\n ) => Effect.Effect<CommittedDurableEvent, EDASessionStoreError | SessionCommandAdmissionConflict>;\n /**\n * Run a registered decider for this session: it reads the committed state and appends its\n * marker and items in one step, so nothing can commit in between. Use it when the fact the tool\n * emits depends on state. Pass `toolCallId` in the input and use it as the idempotency key, so a\n * call re-invoked under `ToolRecovery: \"reinvoke\"` finds the first acceptance. Return facts, not\n * commands: a command admitted from inside the run it affects is legal but confusing.\n */\n readonly decide: <Input, Result, Rejection>(\n decider: EDADecider<string, Input, Result, Rejection>,\n input: Input,\n ) => Effect.Effect<\n EDADeciderOutcome<Result, Rejection>,\n EDASessionStoreError | SessionCommandAdmissionConflict | EDADeciderError\n >;\n /**\n * Read the session's framework state and app reducer states, as `EDARuntime.snapshot` does.\n * For a tool that only reads (to prefill a form, say). The state can be stale by the time the\n * tool emits: when what the tool writes depends on it, use `decide` instead.\n */\n readonly snapshot: () => Effect.Effect<EDASessionSnapshot>;\n /**\n * Present when startup recovery re-invokes a call that had started before the runtime died\n * (its tool declares `ToolRecovery: \"reinvoke\"`). Facts the first attempt committed are in the\n * journal after `firstStartedSeq`.\n */\n readonly recovery?: {\n /** This attempt, 2 or more. */\n readonly attempt: number;\n readonly firstStartedAtMs: number;\n readonly firstStartedSeq: SequenceNumber;\n };\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":";;;;;;;;;AA4BA,MAAa,eAAe,QAAQ,UAClC,qCACA,EAAE,oBAAoB,OAAO,CAC/B;;AAGA,MAAa,sBAAsB;;AAGnC,MAAa,sBACX,SACA,aACuB;CACvB,MAAM,OAAO,SAAS,MAAM;CAC5B,OAAO,SAAS,KAAA,IAAY,SAAS,QAAQ,IAAI,KAAK,aAAa,YAAY;AACjF;;AAgFA,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,SA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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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import {
|
|
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-BwjbF285.js";
|
|
2
|
+
import { y as UsagePayload } from "../envelope-CJnPfbjC.js";
|
|
3
|
+
import "../events-AIIwZ6dS.js";
|
|
3
4
|
import * as Effect from "effect/Effect";
|
|
4
5
|
import * as Tracer from "effect/Tracer";
|
|
5
|
-
|
|
6
6
|
//#region src/services/tracing.d.ts
|
|
7
7
|
/** Attribute value types accepted by Effect span annotations after compaction. */
|
|
8
8
|
type EdaSpanAttributeValue = EDATraceAttributeValue | undefined;
|
package/dist/services/tracing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EDAEventTrace, EDARunTrace, EDATraceContext, EDATraceLink, EDATraceMetadata, buildEDATraceparent, makeEDAEventTrace, makeEDARunTrace, makeEDATraceContext, makeEDATraceMetadataFromParent, makeRootEDAEventTrace, makeRootEDATraceMetadata, parseEDATraceparent } from "../types/tracing.js";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Cause from "effect/Cause";
|
|
4
3
|
import * as Exit from "effect/Exit";
|
|
4
|
+
import * as Cause from "effect/Cause";
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
6
|
import * as Tracer from "effect/Tracer";
|
|
7
7
|
//#region src/services/tracing.ts
|
|
@@ -72,7 +72,7 @@ var ExportingNativeSpan = class extends Tracer.NativeSpan {
|
|
|
72
72
|
}
|
|
73
73
|
end(endTime, exit) {
|
|
74
74
|
super.end(endTime, exit);
|
|
75
|
-
if (endTime <= this.startTime) return;
|
|
75
|
+
if (endTime <= this.startTime && this.name !== "agent.session.hydrate" && this.name !== "agent.sinks.initialize") return;
|
|
76
76
|
const parent = Option.getOrUndefined(this.parent);
|
|
77
77
|
this.#emit({
|
|
78
78
|
attributes: compactUnknownAttributes(this.attributes),
|
|
@@ -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\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"],"mappings":";;;;;;;;AAwEA,MAAM,+BAA+B;;AAarC,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,YAAuD,CAAC;CAC9D,IAAI;EACF,IAAI,sBAAsB,KAAK;GAC7B,IAAI,QAAQ;GACZ,KAAK,MAAM,CAAC,KAAK,UAAU,YAAY;IACrC,IAAI,SAAS,8BACX;IAEF,SAAS;IACT,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,UAAU,OAAO;GAErB;GACA,OAAO;EACT;EAEA,MAAM,OAAO,OAAO,KAAK,UAAU,EAAE,MAAM,GAAG,4BAA4B;EAC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,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 // Keep the two startup summaries even within one clock tick: their checkpoint\n // and reuse counts explain why initialization was fast. Other zero-duration\n // spans add noise without describing execution.\n if (\n endTime <= this.startTime &&\n this.name !== \"agent.session.hydrate\" &&\n this.name !== \"agent.sinks.initialize\"\n ) {\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":";;;;;;;;AAwEA,MAAM,+BAA+B;;AAarC,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,YAAuD,CAAC;CAC9D,IAAI;EACF,IAAI,sBAAsB,KAAK;GAC7B,IAAI,QAAQ;GACZ,KAAK,MAAM,CAAC,KAAK,UAAU,YAAY;IACrC,IAAI,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tB,MAAM,OAAO,OACV,KAAK,UAAU,MAAM,UAAU,GAAG,CAAC,CACnC,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,CAAC,CAAC,KAAK,GAAG;AAChE"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { MessageId } from "./types/core.js";
|
|
2
|
+
import { x as maxAppEventBytes, y as effectDurableAgentNamespace } from "./envelope-BSI_Xh-f.js";
|
|
3
|
+
import { Mr as decodeRetainingExcess, qn as decodeDurableEventSync } from "./durable-Da57Rcml.js";
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Result from "effect/Result";
|
|
7
|
+
import * as Brand from "effect/Brand";
|
|
8
|
+
//#region src/services/session-admission.ts
|
|
9
|
+
/**
|
|
10
|
+
* Admission rules every app-written durable event passes before it reaches the store, shared by
|
|
11
|
+
* `submit`, decider drafts, tool `emitDurable` and sink `stageDurable`. A refusal here is not a
|
|
12
|
+
* store error, so it never makes the live runtime fatal. Internal: not an exported subpath.
|
|
13
|
+
*/
|
|
14
|
+
var SessionCommandAdmissionConflict = class extends Schema.TaggedError()("SessionCommandAdmissionConflict", {
|
|
15
|
+
code: Schema.Literals([
|
|
16
|
+
"queue_paused",
|
|
17
|
+
"paused_queue_changed",
|
|
18
|
+
"event_too_large",
|
|
19
|
+
"framework_event",
|
|
20
|
+
"invalid_event",
|
|
21
|
+
"payload_not_json"
|
|
22
|
+
]),
|
|
23
|
+
message: Schema.String,
|
|
24
|
+
pausedMessageIds: Schema.Array(MessageId)
|
|
25
|
+
}) {};
|
|
26
|
+
/**
|
|
27
|
+
* Framework event types app code may still write through `submit`, decider drafts, `emitDurable`
|
|
28
|
+
* and `stageDurable`: a session seed (`SessionConfigured`, `SystemMessageCommitted`) and imported
|
|
29
|
+
* history. Every other `effect-durable-agent` event is the framework's alone; a forged
|
|
30
|
+
* `DeciderAccepted` would make a later decision replay a result nobody decided.
|
|
31
|
+
*/
|
|
32
|
+
const appWritableFrameworkEventTypes = /* @__PURE__ */ new Set([
|
|
33
|
+
"SessionConfigured",
|
|
34
|
+
"SystemMessageCommitted",
|
|
35
|
+
"AssistantMessageImported"
|
|
36
|
+
]);
|
|
37
|
+
/** App event schemas are a union of structs with literal namespaces; throw for any other shape. */
|
|
38
|
+
const eventSchemaNamespaces = (ast) => {
|
|
39
|
+
if (ast._tag === "Union") return ast.types.flatMap(eventSchemaNamespaces);
|
|
40
|
+
if (ast._tag === "Objects") {
|
|
41
|
+
const namespace = ast.propertySignatures.find((field) => field.name === "namespace")?.type;
|
|
42
|
+
if (namespace?._tag === "Literal" && typeof namespace.literal === "string") return [namespace.literal];
|
|
43
|
+
}
|
|
44
|
+
throw new Error("App event schemas must be a union of structs with literal namespaces");
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The JSON form the store keeps, `JSON.parse(JSON.stringify(value))`, or why `value` has none.
|
|
48
|
+
* The round trip may only drop an object property whose value is `undefined`; anything else it
|
|
49
|
+
* would change is refused rather than silently rewritten: anything with a prototype (`Redacted`,
|
|
50
|
+
* `Option`, `Date`, a class instance), `undefined` in an array, a non-finite number, a bigint, a
|
|
51
|
+
* function, a symbol or a cycle. Every check that must hold for what is stored runs on this form.
|
|
52
|
+
*/
|
|
53
|
+
const storedJsonForm = (value, path) => {
|
|
54
|
+
const violation = jsonNativeAt(value, path, /* @__PURE__ */ new Set());
|
|
55
|
+
if (violation !== void 0) return Result.fail(violation);
|
|
56
|
+
const json = JSON.parse(JSON.stringify(value));
|
|
57
|
+
return Result.succeed(json);
|
|
58
|
+
};
|
|
59
|
+
const jsonNativeAt = (value, path, seen) => {
|
|
60
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return void 0;
|
|
61
|
+
if (typeof value === "number") return Number.isFinite(value) ? void 0 : `${path} is the non-finite number ${value}`;
|
|
62
|
+
if (typeof value !== "object") return `${path} is a ${typeof value}`;
|
|
63
|
+
if (seen.has(value)) return `${path} is a cycle`;
|
|
64
|
+
seen.add(value);
|
|
65
|
+
try {
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
68
|
+
if (!(index in value) || value[index] === void 0) return `${path}[${index}] is undefined`;
|
|
69
|
+
const violation = jsonNativeAt(value[index], `${path}[${index}]`, seen);
|
|
70
|
+
if (violation !== void 0) return violation;
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const prototype = Object.getPrototypeOf(value);
|
|
75
|
+
if (prototype !== Object.prototype && prototype !== null) return `${path} is not a plain object (prototype ${(typeof prototype === "object" && prototype !== null && "constructor" in prototype && typeof prototype.constructor === "function" ? prototype.constructor.name : "unknown") || "anonymous"})`;
|
|
76
|
+
if (Object.getOwnPropertySymbols(value).length > 0) return `${path} has symbol keys`;
|
|
77
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
78
|
+
if (entry === void 0) continue;
|
|
79
|
+
const violation = jsonNativeAt(entry, `${path}.${key}`, seen);
|
|
80
|
+
if (violation !== void 0) return violation;
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
} finally {
|
|
84
|
+
seen.delete(value);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const jsonEncoder = new TextEncoder();
|
|
88
|
+
/** UTF-8 size of a JSON-native value's JSON text. */
|
|
89
|
+
const jsonBytes = (value) => {
|
|
90
|
+
const json = JSON.stringify(value);
|
|
91
|
+
return json === void 0 ? 0 : jsonEncoder.encode(json).byteLength;
|
|
92
|
+
};
|
|
93
|
+
/** The runtime's registered `appEvents` union; absent for a framework-only runtime. */
|
|
94
|
+
const RegisteredAppEvents = Context.Reference("effect-durable-agent/RegisteredAppEvents", { defaultValue: () => void 0 });
|
|
95
|
+
const AdmittedAppEvent = Brand.nominal();
|
|
96
|
+
/** Build the checker for a runtime, with its registered `appEvents` codec if any. */
|
|
97
|
+
const makeAppEventAdmission = (appEvents) => {
|
|
98
|
+
const namespaces = new Set(appEvents === void 0 ? [] : eventSchemaNamespaces(appEvents.ast));
|
|
99
|
+
const decode = appEvents === void 0 ? void 0 : decodeRetainingExcess(appEvents);
|
|
100
|
+
const describe = (event) => `Event ${event.namespace}/${event.type} ${event.eventId}`;
|
|
101
|
+
const refuse = (code, message) => Result.fail({
|
|
102
|
+
code,
|
|
103
|
+
message
|
|
104
|
+
});
|
|
105
|
+
return { admit: (event) => {
|
|
106
|
+
const isFramework = event.namespace === effectDurableAgentNamespace;
|
|
107
|
+
if (isFramework && !appWritableFrameworkEventTypes.has(event.type)) return refuse("framework_event", `${describe(event)} is a framework lifecycle event; app code may write only ${Array.from(appWritableFrameworkEventTypes).join(", ")}`);
|
|
108
|
+
const payload = storedJsonForm(event.payload, "payload");
|
|
109
|
+
if (Result.isFailure(payload)) return refuse("payload_not_json", `${describe(event)} payload is not JSON-native: ${payload.failure}. Encode it before writing; the store keeps JSON only.`);
|
|
110
|
+
const stored = {
|
|
111
|
+
...event,
|
|
112
|
+
payload: payload.success
|
|
113
|
+
};
|
|
114
|
+
const bytes = jsonBytes(stored.payload);
|
|
115
|
+
if (bytes > 1048576) return refuse("event_too_large", `${describe(event)} payload is ${bytes} bytes; the limit is ${maxAppEventBytes} bytes`);
|
|
116
|
+
try {
|
|
117
|
+
if (isFramework) decodeDurableEventSync(stored);
|
|
118
|
+
} catch (cause) {
|
|
119
|
+
return refuse("invalid_event", `${describe(event)} does not match its framework event schema once stored as JSON: ${String(cause)}`);
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
if (decode !== void 0 && namespaces.has(event.namespace)) decode(stored);
|
|
123
|
+
} catch (cause) {
|
|
124
|
+
return refuse("invalid_event", `${describe(event)} does not match the registered appEvents schema once stored as JSON: ${String(cause)}`);
|
|
125
|
+
}
|
|
126
|
+
return Result.succeed(AdmittedAppEvent(stored));
|
|
127
|
+
} };
|
|
128
|
+
};
|
|
129
|
+
/** The admission conflict a refused `submit` item fails with. */
|
|
130
|
+
const appEventConflict = (refusal) => new SessionCommandAdmissionConflict({
|
|
131
|
+
code: refusal.code,
|
|
132
|
+
message: refusal.message,
|
|
133
|
+
pausedMessageIds: []
|
|
134
|
+
});
|
|
135
|
+
//#endregion
|
|
136
|
+
export { jsonBytes as a, eventSchemaNamespaces as i, SessionCommandAdmissionConflict as n, makeAppEventAdmission as o, appEventConflict as r, storedJsonForm as s, RegisteredAppEvents as t };
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=session-admission-WE8J_0z9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-admission-WE8J_0z9.js","names":[],"sources":["../src/services/session-admission.ts"],"sourcesContent":["import * as Brand from \"effect/Brand\";\nimport * as Context from \"effect/Context\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport type * as SchemaAST from \"effect/SchemaAST\";\n\nimport { MessageId } from \"../types/core\";\nimport {\n type DurableEventEnvelope,\n effectDurableAgentNamespace,\n maxAppEventBytes,\n} from \"../types/events/envelope\";\nimport { decodeDurableEventSync } from \"../types/events/durable\";\nimport { decodeRetainingExcess } from \"../types/events/internal\";\n\n/**\n * Admission rules every app-written durable event passes before it reaches the store, shared by\n * `submit`, decider drafts, tool `emitDurable` and sink `stageDurable`. A refusal here is not a\n * store error, so it never makes the live runtime fatal. Internal: not an exported subpath.\n */\n\nexport class SessionCommandAdmissionConflict extends Schema.TaggedError<SessionCommandAdmissionConflict>()(\n \"SessionCommandAdmissionConflict\",\n {\n code: Schema.Literals([\n \"queue_paused\",\n \"paused_queue_changed\",\n \"event_too_large\",\n \"framework_event\",\n \"invalid_event\",\n \"payload_not_json\",\n ]),\n message: Schema.String,\n pausedMessageIds: Schema.Array(MessageId),\n },\n) {}\n\n/** Why an app event is refused. */\nexport interface AppEventRefusal {\n readonly code: \"event_too_large\" | \"framework_event\" | \"invalid_event\" | \"payload_not_json\";\n readonly message: string;\n}\n\n/**\n * Framework event types app code may still write through `submit`, decider drafts, `emitDurable`\n * and `stageDurable`: a session seed (`SessionConfigured`, `SystemMessageCommitted`) and imported\n * history. Every other `effect-durable-agent` event is the framework's alone; a forged\n * `DeciderAccepted` would make a later decision replay a result nobody decided.\n */\nexport const appWritableFrameworkEventTypes: ReadonlySet<string> = new Set([\n \"SessionConfigured\",\n \"SystemMessageCommitted\",\n \"AssistantMessageImported\",\n]);\n\n/** App event schemas are a union of structs with literal namespaces; throw for any other shape. */\nexport const eventSchemaNamespaces = (ast: SchemaAST.AST): ReadonlyArray<string> => {\n if (ast._tag === \"Union\") return ast.types.flatMap(eventSchemaNamespaces);\n if (ast._tag === \"Objects\") {\n const namespace = ast.propertySignatures.find((field) => field.name === \"namespace\")?.type;\n if (namespace?._tag === \"Literal\" && typeof namespace.literal === \"string\")\n return [namespace.literal];\n }\n throw new Error(\"App event schemas must be a union of structs with literal namespaces\");\n};\n\n/**\n * The JSON form the store keeps, `JSON.parse(JSON.stringify(value))`, or why `value` has none.\n * The round trip may only drop an object property whose value is `undefined`; anything else it\n * would change is refused rather than silently rewritten: anything with a prototype (`Redacted`,\n * `Option`, `Date`, a class instance), `undefined` in an array, a non-finite number, a bigint, a\n * function, a symbol or a cycle. Every check that must hold for what is stored runs on this form.\n */\nexport const storedJsonForm = (\n value: unknown,\n path: string,\n): Result.Result<Schema.Json, string> => {\n const violation = jsonNativeAt(value, path, new Set());\n if (violation !== undefined) return Result.fail(violation);\n const json: Schema.Json = JSON.parse(JSON.stringify(value));\n return Result.succeed(json);\n};\n\nconst jsonNativeAt = (value: unknown, path: string, seen: Set<object>): string | undefined => {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return undefined;\n if (typeof value === \"number\") {\n return Number.isFinite(value) ? undefined : `${path} is the non-finite number ${value}`;\n }\n if (typeof value !== \"object\") return `${path} is a ${typeof value}`;\n if (seen.has(value)) return `${path} is a cycle`;\n seen.add(value);\n try {\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index += 1) {\n if (!(index in value) || value[index] === undefined) {\n return `${path}[${index}] is undefined`;\n }\n const violation = jsonNativeAt(value[index], `${path}[${index}]`, seen);\n if (violation !== undefined) return violation;\n }\n return undefined;\n }\n const prototype: unknown = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n const name =\n typeof prototype === \"object\" &&\n prototype !== null &&\n \"constructor\" in prototype &&\n typeof prototype.constructor === \"function\"\n ? prototype.constructor.name\n : \"unknown\";\n return `${path} is not a plain object (prototype ${name || \"anonymous\"})`;\n }\n if (Object.getOwnPropertySymbols(value).length > 0) return `${path} has symbol keys`;\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined) continue;\n const violation = jsonNativeAt(entry, `${path}.${key}`, seen);\n if (violation !== undefined) return violation;\n }\n return undefined;\n } finally {\n seen.delete(value);\n }\n};\n\nconst jsonEncoder = new TextEncoder();\n\n/** UTF-8 size of a JSON-native value's JSON text. */\nexport const jsonBytes = (value: unknown): number => {\n const json: string | undefined = JSON.stringify(value);\n return json === undefined ? 0 : jsonEncoder.encode(json).byteLength;\n};\n\n/** The registered application event union, if the runtime has one. */\nexport type AppEventCodec = Schema.Codec<DurableEventEnvelope, unknown, never, never>;\n\n/** The runtime's registered `appEvents` union; absent for a framework-only runtime. */\nexport const RegisteredAppEvents = Context.Reference<AppEventCodec | undefined>(\n \"effect-durable-agent/RegisteredAppEvents\",\n { defaultValue: () => undefined },\n);\n\n/**\n * An app-written durable event that passed admission. Its payload is already the JSON form the\n * store keeps, so what is appended is exactly what was checked. Only `admit` makes one.\n */\nexport type AdmittedAppEvent = DurableEventEnvelope & Brand.Brand<\"AdmittedAppEvent\">;\nconst AdmittedAppEvent = Brand.nominal<AdmittedAppEvent>();\n\n/** Admits app-written durable events under the runtime's rules. */\nexport interface AppEventAdmission {\n /**\n * The event to append in place of `event`, or why it is refused. The payload is replaced by its\n * stored JSON form first; the size, framework-schema and `appEvents` checks all read that form.\n */\n readonly admit: (event: DurableEventEnvelope) => Result.Result<AdmittedAppEvent, AppEventRefusal>;\n}\n\n/** Build the checker for a runtime, with its registered `appEvents` codec if any. */\nexport const makeAppEventAdmission = (appEvents: AppEventCodec | undefined): AppEventAdmission => {\n const namespaces = new Set(appEvents === undefined ? [] : eventSchemaNamespaces(appEvents.ast));\n const decode = appEvents === undefined ? undefined : decodeRetainingExcess(appEvents);\n const describe = (event: DurableEventEnvelope) =>\n `Event ${event.namespace}/${event.type} ${event.eventId}`;\n const refuse = (code: AppEventRefusal[\"code\"], message: string) =>\n Result.fail<AppEventRefusal>({ code, message });\n return {\n admit: (event) => {\n const isFramework = event.namespace === effectDurableAgentNamespace;\n if (isFramework && !appWritableFrameworkEventTypes.has(event.type)) {\n return refuse(\n \"framework_event\",\n `${describe(event)} is a framework lifecycle event; app code may write only ${Array.from(appWritableFrameworkEventTypes).join(\", \")}`,\n );\n }\n const payload = storedJsonForm(event.payload, \"payload\");\n if (Result.isFailure(payload)) {\n return refuse(\n \"payload_not_json\",\n `${describe(event)} payload is not JSON-native: ${payload.failure}. Encode it before writing; the store keeps JSON only.`,\n );\n }\n const stored = { ...event, payload: payload.success };\n const bytes = jsonBytes(stored.payload);\n if (bytes > maxAppEventBytes) {\n return refuse(\n \"event_too_large\",\n `${describe(event)} payload is ${bytes} bytes; the limit is ${maxAppEventBytes} bytes`,\n );\n }\n try {\n // The store decodes framework events with their own schema and would fail a malformed one\n // as a store error, so an allowlisted type is checked against that schema here.\n if (isFramework) decodeDurableEventSync(stored);\n } catch (cause) {\n return refuse(\n \"invalid_event\",\n `${describe(event)} does not match its framework event schema once stored as JSON: ${String(cause)}`,\n );\n }\n try {\n if (decode !== undefined && namespaces.has(event.namespace)) decode(stored);\n } catch (cause) {\n return refuse(\n \"invalid_event\",\n `${describe(event)} does not match the registered appEvents schema once stored as JSON: ${String(cause)}`,\n );\n }\n return Result.succeed(AdmittedAppEvent(stored));\n },\n };\n};\n\n/** The admission conflict a refused `submit` item fails with. */\nexport const appEventConflict = (refusal: AppEventRefusal): SessionCommandAdmissionConflict =>\n new SessionCommandAdmissionConflict({\n code: refusal.code,\n message: refusal.message,\n pausedMessageIds: [],\n });\n"],"mappings":";;;;;;;;;;;;;AAqBA,IAAa,kCAAb,cAAqD,OAAO,YAA6C,CAAC,CACxG,mCACA;CACE,MAAM,OAAO,SAAS;EACpB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,SAAS,OAAO;CAChB,kBAAkB,OAAO,MAAM,SAAS;AAC1C,CACF,CAAC,CAAC,CAAC;;;;;;;AAcH,MAAa,iDAAsD,IAAI,IAAI;CACzE;CACA;CACA;AACF,CAAC;;AAGD,MAAa,yBAAyB,QAA8C;CAClF,IAAI,IAAI,SAAS,SAAS,OAAO,IAAI,MAAM,QAAQ,qBAAqB;CACxE,IAAI,IAAI,SAAS,WAAW;EAC1B,MAAM,YAAY,IAAI,mBAAmB,MAAM,UAAU,MAAM,SAAS,WAAW,CAAC,EAAE;EACtF,IAAI,WAAW,SAAS,aAAa,OAAO,UAAU,YAAY,UAChE,OAAO,CAAC,UAAU,OAAO;CAC7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E,GAAG;GAAO,SAAS,QAAQ;EAAQ;EACpD,MAAM,QAAQ,UAAU,OAAO,OAAO;EACtC,IAAI,QAAA,SACF,OAAO,OACL,mBACA,GAAG,SAAS,KAAK,EAAE,cAAc,MAAM,uBAAuB,iBAAiB,OACjF;EAEF,IAAI;GAGF,IAAI,aAAa,uBAAuB,MAAM;EAChD,SAAS,OAAO;GACd,OAAO,OACL,iBACA,GAAG,SAAS,KAAK,EAAE,kEAAkE,OAAO,KAAK,GACnG;EACF;EACA,IAAI;GACF,IAAI,WAAW,KAAA,KAAa,WAAW,IAAI,MAAM,SAAS,GAAG,OAAO,MAAM;EAC5E,SAAS,OAAO;GACd,OAAO,OACL,iBACA,GAAG,SAAS,KAAK,EAAE,uEAAuE,OAAO,KAAK,GACxG;EACF;EACA,OAAO,OAAO,QAAQ,iBAAiB,MAAM,CAAC;CAChD,EACF;AACF;;AAGA,MAAa,oBAAoB,YAC/B,IAAI,gCAAgC;CAClC,MAAM,QAAQ;CACd,SAAS,QAAQ;CACjB,kBAAkB,CAAC;AACrB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as PositionedEvent } from "./envelope-CJnPfbjC.js";
|
|
2
|
+
import "./events-AIIwZ6dS.js";
|
|
2
3
|
import * as Context from "effect/Context";
|
|
3
4
|
import * as Effect from "effect/Effect";
|
|
4
5
|
import * as Layer from "effect/Layer";
|
|
5
|
-
|
|
6
6
|
//#region src/services/session-event-observer.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Outbound integration point notified synchronously after EDA publishes an event.
|
|
@@ -21,4 +21,4 @@ declare class SessionEventObserver extends SessionEventObserver_base {
|
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { SessionEventObserverShape as n, SessionEventObserver as t };
|
|
24
|
-
//# sourceMappingURL=session-event-observer-
|
|
24
|
+
//# sourceMappingURL=session-event-observer-BWQUJTcN.d.ts.map
|