@systemfsoftware/agent-platform-node 0.0.0-stage → 0.1.0-beta.192

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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/dist/NodeDurableAgentRuntime-C5SFn9kf.mjs +218 -0
  3. package/dist/NodeDurableAgentRuntime-C5SFn9kf.mjs.map +1 -0
  4. package/dist/NodeDurableAgentRuntime-CUrOl39W.d.mts +163 -0
  5. package/dist/NodeDurableAgentRuntime.d.mts +2 -0
  6. package/dist/NodeDurableAgentRuntime.mjs +1 -0
  7. package/dist/NodeDurableHost-BztkzCGh.mjs +271 -0
  8. package/dist/NodeDurableHost-BztkzCGh.mjs.map +1 -0
  9. package/dist/NodeDurableHost-CFvVn1w1.d.mts +153 -0
  10. package/dist/NodeDurableHost.d.mts +2 -0
  11. package/dist/NodeDurableHost.mjs +1 -0
  12. package/dist/NodeScheduling-CD_CZvQ6.d.mts +20 -0
  13. package/dist/NodeScheduling-gNj8jB4g.mjs +64 -0
  14. package/dist/NodeScheduling-gNj8jB4g.mjs.map +1 -0
  15. package/dist/NodeScheduling.d.mts +2 -0
  16. package/dist/NodeScheduling.mjs +1 -0
  17. package/dist/NodeSubscriptions-Bd_3VxqD.d.mts +23 -0
  18. package/dist/NodeSubscriptions-KgvkfIMl.mjs +62 -0
  19. package/dist/NodeSubscriptions-KgvkfIMl.mjs.map +1 -0
  20. package/dist/NodeSubscriptions.d.mts +2 -0
  21. package/dist/NodeSubscriptions.mjs +1 -0
  22. package/dist/NodeWakeScheduler-Dyha4GZJ.d.mts +28 -0
  23. package/dist/NodeWakeScheduler-dVNAHWsN.mjs +58 -0
  24. package/dist/NodeWakeScheduler-dVNAHWsN.mjs.map +1 -0
  25. package/dist/NodeWakeScheduler.d.mts +2 -0
  26. package/dist/NodeWakeScheduler.mjs +1 -0
  27. package/dist/index.d.mts +6 -0
  28. package/dist/index.mjs +6 -0
  29. package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
  30. package/package.json +68 -3
  31. package/src/NodeDurableAgentRuntime.ts +603 -0
  32. package/src/NodeDurableHost.ts +403 -0
  33. package/src/NodeScheduling.ts +122 -0
  34. package/src/NodeSubscriptions.ts +124 -0
  35. package/src/NodeWakeScheduler.ts +94 -0
  36. package/src/index.ts +5 -0
  37. package/src/internal/application-context.ts +25 -0
  38. package/src/internal/exclusive-host.ts +7 -0
  39. package/src/internal/message-delivery.ts +54 -0
  40. package/src/internal/prepared-admission.ts +79 -0
  41. package/src/internal/worker-dispatch.ts +116 -0
  42. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel van der Merwe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,218 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
2
+ import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
3
+ import * as SqliteClient from "@effect/sql-sqlite-node/SqliteClient";
4
+ import { messageDeliveryStoreLayer } from "@systemfsoftware/agent-storage-sqlite/sqlite-message-delivery-store";
5
+ import { scheduleStoreLayer } from "@systemfsoftware/agent-storage-sqlite/sqlite-schedule-store";
6
+ import { SqliteStorageConfig, SqliteStorageConfigValue } from "@systemfsoftware/agent-storage-sqlite/sqlite-storage-config";
7
+ import { SqliteStorageError } from "@systemfsoftware/agent-storage-sqlite/sqlite-storage-error";
8
+ import { SqliteStorageFailpoint } from "@systemfsoftware/agent-storage-sqlite/sqlite-storage-failpoint";
9
+ import { submissionLedgerLayer } from "@systemfsoftware/agent-storage-sqlite/sqlite-submission-ledger";
10
+ import { exclusiveHostClientLayer, exclusiveRunStorageLayer, storageFailpointLayer, threadStoreLayer } from "@systemfsoftware/agent-storage-sqlite/sqlite-thread-store";
11
+ import { compileRegistrations } from "@systemfsoftware/agent/agent-registration";
12
+ import { DurableAgentRuntime, DurableRuntimeConfig } from "@systemfsoftware/agent/durable-agent-runtime";
13
+ import { DurableRuntimeFailpoint } from "@systemfsoftware/agent/durable-failpoint";
14
+ import { MessageDeliveryStore } from "@systemfsoftware/agent/message-delivery";
15
+ import { DeploymentId, ProducerId } from "@systemfsoftware/agent/records";
16
+ import { CurrentToolFailureObserver, RunContextPreparationPassthrough, RunToolAuthorization, toolFailureObserverLayer } from "@systemfsoftware/agent/run-options";
17
+ import { layer } from "@systemfsoftware/agent/run-storage";
18
+ import { ThreadReader } from "@systemfsoftware/agent/thread-store";
19
+ import { ToolReconciler } from "@systemfsoftware/agent/tool-reconciler";
20
+ import * as Context from "effect/Context";
21
+ import * as CryptoDigest from "effect/crypto/Digest";
22
+ import * as Duration from "effect/Duration";
23
+ import * as Effect from "effect/Effect";
24
+ import * as Layer from "effect/Layer";
25
+ import * as Schema from "effect/Schema";
26
+ import * as Scope from "effect/Scope";
27
+ import * as SqlClientService from "effect/sql/SqlClient";
28
+ import * as Statement from "effect/sql/Statement";
29
+ import * as Clock from "effect/Clock";
30
+ import * as References from "effect/References";
31
+ import * as Tracer from "effect/Tracer";
32
+ import { r as nodeWakeSchedulerLayer, t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-dVNAHWsN.mjs";
33
+ // src/internal/application-context.ts
34
+ /** Live lifetime and diagnostics may cross the managed host's private storage boundary. */
35
+ const applicationInvocationContext = Context.pick(Scope.Scope, Clock.Clock, Tracer.ParentSpan, Tracer.Tracer, Tracer.MinimumTraceLevel, Tracer.CurrentTraceLevel, References.TracerEnabled, References.TracerTimingEnabled, References.TracerSpanAnnotations, References.TracerSpanLinks, References.CurrentLoggers, References.CurrentLogLevel, References.MinimumLogLevel, References.CurrentStackFrame, References.CurrentLogAnnotations, References.CurrentLogSpans);
36
+ // src/internal/exclusive-host.ts
37
+ /** Only the automatically managed host owns the SQLite connection for its entire lifetime. */
38
+ const ExclusiveSqliteHost = Context.Reference("@effect-agent/platform-node/internal/ExclusiveSqliteHost", { defaultValue: () => false });
39
+ // src/NodeDurableAgentRuntime.ts
40
+ var NodeDurableAgentRuntime_exports = /* @__PURE__ */ __exportAll({
41
+ NodeDurableAgentRuntime: () => NodeDurableAgentRuntime,
42
+ NodeDurableAgentRuntimeConfig: () => NodeDurableAgentRuntimeConfig,
43
+ NodeDurableAgentRuntimeConfigValue: () => NodeDurableAgentRuntimeConfigValue,
44
+ NodePlatformConfigError: () => NodePlatformConfigError
45
+ });
46
+ const PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));
47
+ const NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
48
+ const WorkerConcurrency = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(64));
49
+ /** The supplied Node durable runtime configuration failed schema validation (DEPLOY-003). */
50
+ var NodePlatformConfigError = class extends Schema.TaggedError()("NodePlatformConfigError", {
51
+ message: Schema.String,
52
+ cause: Schema.optionalKey(Schema.Defect())
53
+ }) {};
54
+ /**
55
+ * Validated Node durable runtime configuration (deployment §4: decoded once during Layer
56
+ * construction, exposed as a typed service). Every cadence is in milliseconds and every bound is
57
+ * finite; `workerConcurrency` caps how many worker loops `NodeDurableHost.runWorkers` drives.
58
+ */
59
+ var NodeDurableAgentRuntimeConfigValue = class extends Schema.Class("@effect-agent/platform-node/NodeDurableAgentRuntimeConfigValue")({
60
+ /** SQLite database file backing the Thread Log, Submission Ledger, and delivery obligations. */
61
+ filename: Schema.NonEmptyString,
62
+ deploymentId: DeploymentId,
63
+ producerId: ProducerId,
64
+ /** Finite bound on concurrent worker loops per host (rule 10). */
65
+ workerConcurrency: WorkerConcurrency,
66
+ /** Fallback scan cadence for the Node wake scheduler and independent message delivery recovery. */
67
+ wakeScanInterval: PositiveMillis,
68
+ /** `awaitSettlement` ledger re-check cadence when no wake arrives. */
69
+ settlementPollInterval: PositiveMillis,
70
+ /** Active-Run abort-intent poll cadence. */
71
+ abortPollInterval: PositiveMillis,
72
+ /** Bounded SQLITE_BUSY retry window for write-lock acquisition. */
73
+ busyTimeout: NonNegativeMillis,
74
+ /** SQLite WAL synchronization selected for this host's connection at construction. */
75
+ synchronous: SqliteStorageConfigValue.fields.synchronous,
76
+ /** Canonical observation poll cadence of the SQLite store. */
77
+ observationPollInterval: NonNegativeMillis,
78
+ /** Opt-in full history and active-state validation while opening the store. */
79
+ verifyOnOpen: Schema.Boolean
80
+ }) {};
81
+ /** Explicit configuration authority for the assembled Node durable runtime. */
82
+ var NodeDurableAgentRuntimeConfig = class extends Context.Service()("@effect-agent/platform-node/NodeDurableAgentRuntimeConfig") {};
83
+ const decodeConfigValue = Schema.decodeUnknownEffect(NodeDurableAgentRuntimeConfigValue);
84
+ const configFromOptions = (options) => decodeConfigValue({
85
+ filename: options.filename,
86
+ deploymentId: options.deploymentId,
87
+ producerId: options.producerId,
88
+ workerConcurrency: options.workerConcurrency ?? 1,
89
+ wakeScanInterval: options.wakeScanInterval ?? 1e3,
90
+ settlementPollInterval: options.settlementPollInterval ?? 500,
91
+ abortPollInterval: options.abortPollInterval ?? 500,
92
+ busyTimeout: options.busyTimeout ?? 5e3,
93
+ synchronous: options.synchronous ?? "FULL",
94
+ observationPollInterval: options.observationPollInterval ?? 25,
95
+ verifyOnOpen: options.verifyOnOpen ?? false
96
+ }).pipe(Effect.mapError((error) => NodePlatformConfigError.make({
97
+ message: `Invalid Node durable runtime configuration: ${error.message}`,
98
+ cause: error
99
+ })));
100
+ /** SQLite storage configuration derived from the single validated Node configuration. */
101
+ const sqliteStorageConfigLayer = Layer.effect(SqliteStorageConfig)(Effect.gen(function* () {
102
+ const config = yield* NodeDurableAgentRuntimeConfig;
103
+ return SqliteStorageConfigValue.make({
104
+ observationPollInterval: config.observationPollInterval,
105
+ busyTimeout: config.busyTimeout,
106
+ synchronous: config.synchronous,
107
+ verifyOnOpen: config.verifyOnOpen
108
+ });
109
+ }));
110
+ /** Thread coordinator configuration derived from the single validated Node configuration. */
111
+ const durableRuntimeConfigLayer = (estimateCostMicrousd) => Layer.effect(DurableRuntimeConfig)(Effect.gen(function* () {
112
+ const config = yield* NodeDurableAgentRuntimeConfig;
113
+ return DurableRuntimeConfig.make({
114
+ deploymentId: config.deploymentId,
115
+ producerId: config.producerId,
116
+ settlementPollInterval: Duration.millis(config.settlementPollInterval),
117
+ abortPollInterval: Duration.millis(config.abortPollInterval),
118
+ ...estimateCostMicrousd === void 0 ? {} : { estimateCostMicrousd }
119
+ });
120
+ }));
121
+ /** Wake fallback-scan cadence derived from the single validated Node configuration. */
122
+ const wakeSchedulerConfigLayer = Layer.effect(NodeWakeSchedulerConfig)(Effect.gen(function* () {
123
+ const config = yield* NodeDurableAgentRuntimeConfig;
124
+ return { scanInterval: Duration.millis(config.wakeScanInterval) };
125
+ }));
126
+ /** The managed database stays private even when a caller supplies SQL transformers. */
127
+ const privateMessageDeliveryLayer = Layer.effect(MessageDeliveryStore)(Effect.gen(function* () {
128
+ const storageContext = (yield* Effect.context()).pipe(Context.pick(SqlClientService.SqlClient, CryptoDigest.Digest, SqliteStorageConfig, SqliteStorageFailpoint, Scope.Scope));
129
+ const sql = Context.get(storageContext, SqlClientService.SqlClient);
130
+ const bind = (effect) => Effect.contextWith((live) => Effect.setContext(effect, Context.merge(Context.omit(Statement.CurrentTransformer, sql.transactionService)(live), storageContext)));
131
+ const services = yield* bind(Layer.build(messageDeliveryStoreLayer()));
132
+ const store = Context.get(services, MessageDeliveryStore);
133
+ return MessageDeliveryStore.of({
134
+ limits: store.limits,
135
+ maxStoredValueBytes: store.maxStoredValueBytes,
136
+ insert: (record) => bind(store.insert(record)),
137
+ get: (key) => bind(store.get(key)),
138
+ list: (request) => bind(store.list(request)),
139
+ change: (key, change) => bind(store.change(key, change)),
140
+ due: (now, limit, owner) => bind(store.due(now, limit, owner)),
141
+ nextDeadline: (owner) => bind(store.nextDeadline(owner))
142
+ });
143
+ }));
144
+ /**
145
+ * The DN Layer assembly (deployment §12: a Layer-assembly library, not an app entrypoint).
146
+ * `layer(options)` decodes the configuration, opens ONE SQLite database serving both the
147
+ * Thread Log and the Submission Ledger under one scoped owner, wires the Node wake scheduler
148
+ * with its ledger-scan fallback, exposes independent message delivery storage, and defaults
149
+ * the Tool reconciliation policy to the fail-closed
150
+ * `ToolReconciler.uncertain` (override via `options.toolReconciler`), and provides a ready
151
+ * `DurableAgentRuntime` on top. Storage compatibility is
152
+ * verified during construction: an incompatible database file fails the Layer with
153
+ * `SqliteStorageCompatibilityError` before anything is mutated (DEPLOY-008).
154
+ */
155
+ var NodeDurableAgentRuntime = class NodeDurableAgentRuntime {
156
+ /** Validated configuration Layer; fails typed when the supplied options are out of bounds. */
157
+ static configLayer(options) {
158
+ return Layer.effect(NodeDurableAgentRuntimeConfig)(configFromOptions(options));
159
+ }
160
+ /** The full DN runtime stack over one SQLite file. */
161
+ static layer(options) {
162
+ return NodeDurableAgentRuntime.assemble(DurableAgentRuntime.layerWithServices, options);
163
+ }
164
+ /** Own typed executable registrations for every worker using this Node runtime. */
165
+ static layerRegistered(registrations, options) {
166
+ return Layer.unwrap(Effect.gen(function* () {
167
+ const bindings = yield* compileRegistrations(registrations);
168
+ const exclusive = yield* ExclusiveSqliteHost;
169
+ const isolate = (effect) => Effect.contextWith((live) => Effect.setContext(effect, applicationInvocationContext(live)));
170
+ return NodeDurableAgentRuntime.layerWithBindings(exclusive ? bindings.map((binding) => ({
171
+ ...binding,
172
+ attempt: (...args) => isolate(binding.attempt(...args)),
173
+ ...binding.reporting === void 0 ? {} : { reporting: binding.reporting.map((report) => ({
174
+ ...report,
175
+ prepare: (value) => isolate(report.prepare(value))
176
+ })) }
177
+ })) : bindings, options);
178
+ }).pipe(Effect.provide(NodeCrypto.layer)));
179
+ }
180
+ /** Construct from registrations already resolved within the enclosing application Scope. */
181
+ static layerWithBindings(bindings, options) {
182
+ return NodeDurableAgentRuntime.assemble(DurableAgentRuntime.layerWithBindings(bindings), options);
183
+ }
184
+ static assemble(runtimeLayer, options) {
185
+ return Layer.unwrap(Effect.gen(function* () {
186
+ const config = yield* configFromOptions(options);
187
+ const exclusive = yield* ExclusiveSqliteHost;
188
+ const nodeConfigLayer = Layer.succeed(NodeDurableAgentRuntimeConfig)(config);
189
+ const applicationContext = (yield* Effect.context()).pipe(Context.omit(Scope.Scope));
190
+ const applicationServices = yield* Layer.build(Layer.mergeAll(options.runContext ?? RunContextPreparationPassthrough, options.toolAuthorization ?? RunToolAuthorization.allowAll, options.toolReconciler ?? ToolReconciler.uncertain, options.toolFailureObserver === void 0 ? Layer.succeed(CurrentToolFailureObserver)(void 0) : toolFailureObserverLayer(options.toolFailureObserver)).pipe(Layer.provide(NodeCrypto.layer)));
191
+ const storageFailpoint = options.storageFailpoint;
192
+ const runtimeFailpoint = options.runtimeFailpoint;
193
+ const clientInfrastructure = Layer.mergeAll(sqliteStorageConfigLayer, storageFailpointLayer({
194
+ filename: config.filename,
195
+ failpoint: storageFailpoint === void 0 ? void 0 : (location) => Effect.scoped(Effect.suspend(() => storageFailpoint(location))).pipe(Effect.setContext(applicationContext))
196
+ }), SqliteClient.layer({
197
+ filename: config.filename,
198
+ disableWAL: exclusive
199
+ }).pipe(Layer.catch((cause) => Layer.effectContext(Effect.fail(SqliteStorageError.make({
200
+ operation: "open SQLite",
201
+ message: cause.message,
202
+ cause
203
+ }))))), NodeCrypto.layer).pipe(Layer.provide(nodeConfigLayer));
204
+ const exclusiveInfrastructure = Layer.effectContext(Effect.gen(function* () {
205
+ const scope = yield* Effect.scope;
206
+ return yield* Layer.build(Layer.fresh(exclusiveHostClientLayer).pipe(Layer.provideMerge(clientInfrastructure))).pipe(Effect.setContext(Context.make(Scope.Scope, scope)));
207
+ }));
208
+ const runtimeFailpointLayer = runtimeFailpoint === void 0 ? DurableRuntimeFailpoint.layer : Layer.succeed(DurableRuntimeFailpoint)({ hit: (location) => Effect.scoped(Effect.suspend(() => runtimeFailpoint(location))).pipe(Effect.setContext(applicationContext)) });
209
+ const ordinaryStorage = layer.pipe(Layer.provideMerge(Layer.mergeAll(threadStoreLayer, submissionLedgerLayer)));
210
+ const portLayers = Layer.mergeAll(ThreadReader.layer(), nodeWakeSchedulerLayer, exclusive ? privateMessageDeliveryLayer : messageDeliveryStoreLayer(), exclusive ? Layer.empty : scheduleStoreLayer);
211
+ const ports = exclusive ? portLayers.pipe(Layer.provideMerge(exclusiveRunStorageLayer), Layer.provideMerge(exclusiveInfrastructure)) : portLayers.pipe(Layer.provideMerge(ordinaryStorage), Layer.provideMerge(clientInfrastructure));
212
+ return runtimeLayer.pipe(Layer.provideMerge(Layer.mergeAll(ports, durableRuntimeConfigLayer(options.estimateCostMicrousd))), Layer.provide(Layer.mergeAll(wakeSchedulerConfigLayer, runtimeFailpointLayer)), Layer.provideMerge(nodeConfigLayer), Layer.provide(Layer.succeedContext(applicationServices)));
213
+ }));
214
+ }
215
+ };
216
+ export { NodePlatformConfigError as a, NodeDurableAgentRuntime_exports as i, NodeDurableAgentRuntimeConfig as n, ExclusiveSqliteHost as o, NodeDurableAgentRuntimeConfigValue as r, applicationInvocationContext as s, NodeDurableAgentRuntime as t };
217
+
218
+ //# sourceMappingURL=NodeDurableAgentRuntime-C5SFn9kf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeDurableAgentRuntime-C5SFn9kf.mjs","names":["runStorageLayer"],"sources":["../src/internal/application-context.ts","../src/internal/exclusive-host.ts","../src/NodeDurableAgentRuntime.ts"],"sourcesContent":["import * as Clock from 'effect/Clock'\nimport * as Context from 'effect/Context'\nimport * as References from 'effect/References'\nimport * as Scope from 'effect/Scope'\nimport * as Tracer from 'effect/Tracer'\n\n/** Live lifetime and diagnostics may cross the managed host's private storage boundary. */\nexport const applicationInvocationContext = Context.pick(\n Scope.Scope,\n Clock.Clock,\n Tracer.ParentSpan,\n Tracer.Tracer,\n Tracer.MinimumTraceLevel,\n Tracer.CurrentTraceLevel,\n References.TracerEnabled,\n References.TracerTimingEnabled,\n References.TracerSpanAnnotations,\n References.TracerSpanLinks,\n References.CurrentLoggers,\n References.CurrentLogLevel,\n References.MinimumLogLevel,\n References.CurrentStackFrame,\n References.CurrentLogAnnotations,\n References.CurrentLogSpans,\n)\n","import * as Context from 'effect/Context'\n\n/** Only the automatically managed host owns the SQLite connection for its entire lifetime. */\nexport const ExclusiveSqliteHost = Context.Reference<boolean>(\n '@effect-agent/platform-node/internal/ExclusiveSqliteHost',\n { defaultValue: () => false },\n)\n","import * as NodeCrypto from '@effect/platform-node/NodeCrypto'\nimport * as SqliteClient from '@effect/sql-sqlite-node/SqliteClient'\nimport { messageDeliveryStoreLayer } from '@systemfsoftware/agent-storage-sqlite/sqlite-message-delivery-store'\nimport { scheduleStoreLayer } from '@systemfsoftware/agent-storage-sqlite/sqlite-schedule-store'\nimport {\n SqliteStorageConfig,\n SqliteStorageConfigValue,\n} from '@systemfsoftware/agent-storage-sqlite/sqlite-storage-config'\nimport { SqliteStorageError } from '@systemfsoftware/agent-storage-sqlite/sqlite-storage-error'\nimport {\n SqliteStorageFailpoint,\n type SqliteStorageFailpointHandler,\n} from '@systemfsoftware/agent-storage-sqlite/sqlite-storage-failpoint'\nimport { submissionLedgerLayer } from '@systemfsoftware/agent-storage-sqlite/sqlite-submission-ledger'\nimport {\n exclusiveHostClientLayer,\n exclusiveRunStorageLayer,\n type SqliteStorageInitializationError,\n storageFailpointLayer,\n threadStoreLayer,\n} from '@systemfsoftware/agent-storage-sqlite/sqlite-thread-store'\nimport {\n type AgentRegistration,\n compileRegistrations,\n type ResolvedBinding,\n} from '@systemfsoftware/agent/agent-registration'\nimport { DurableAgentRuntime, DurableRuntimeConfig } from '@systemfsoftware/agent/durable-agent-runtime'\nimport { DurableRuntimeFailpoint, type DurableRuntimeFailpointHandler } from '@systemfsoftware/agent/durable-failpoint'\nimport { type MessageDeliveryError, MessageDeliveryStore } from '@systemfsoftware/agent/message-delivery'\nimport { DeploymentId, ProducerId } from '@systemfsoftware/agent/records'\nimport {\n CurrentToolFailureObserver,\n type RunContextPreparation,\n RunContextPreparationPassthrough,\n type RunCostEstimator,\n RunToolAuthorization,\n type RunToolFailureObserver,\n toolFailureObserverLayer,\n} from '@systemfsoftware/agent/run-options'\nimport { layer as runStorageLayer } from '@systemfsoftware/agent/run-storage'\nimport { ThreadReader } from '@systemfsoftware/agent/thread-store'\nimport { ToolReconciler } from '@systemfsoftware/agent/tool-reconciler'\nimport * as Context from 'effect/Context'\nimport * as CryptoDigest from 'effect/crypto/Digest'\nimport type * as SecureRandom from 'effect/crypto/SecureRandom'\nimport * as Duration from 'effect/Duration'\nimport * as Effect from 'effect/Effect'\nimport * as Layer from 'effect/Layer'\nimport * as Schema from 'effect/Schema'\nimport * as Scope from 'effect/Scope'\nimport * as SqlClientService from 'effect/sql/SqlClient'\nimport * as Statement from 'effect/sql/Statement'\n\nimport { applicationInvocationContext } from './internal/application-context'\nimport { ExclusiveSqliteHost } from './internal/exclusive-host'\nimport { NodeWakeSchedulerConfig, nodeWakeSchedulerLayer } from './NodeWakeScheduler'\n\nconst PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0))\nconst NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n\nconst WorkerConcurrency = Schema.Int.check(\n Schema.isGreaterThanOrEqualTo(1),\n Schema.isLessThanOrEqualTo(64),\n)\n\n/** The supplied Node durable runtime configuration failed schema validation (DEPLOY-003). */\nexport class NodePlatformConfigError extends Schema.TaggedError<NodePlatformConfigError>()(\n 'NodePlatformConfigError',\n {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * Validated Node durable runtime configuration (deployment §4: decoded once during Layer\n * construction, exposed as a typed service). Every cadence is in milliseconds and every bound is\n * finite; `workerConcurrency` caps how many worker loops `NodeDurableHost.runWorkers` drives.\n */\nexport class NodeDurableAgentRuntimeConfigValue extends Schema.Class<NodeDurableAgentRuntimeConfigValue>(\n '@effect-agent/platform-node/NodeDurableAgentRuntimeConfigValue',\n)({\n /** SQLite database file backing the Thread Log, Submission Ledger, and delivery obligations. */\n filename: Schema.NonEmptyString,\n deploymentId: DeploymentId,\n producerId: ProducerId,\n /** Finite bound on concurrent worker loops per host (rule 10). */\n workerConcurrency: WorkerConcurrency,\n /** Fallback scan cadence for the Node wake scheduler and independent message delivery recovery. */\n wakeScanInterval: PositiveMillis,\n /** `awaitSettlement` ledger re-check cadence when no wake arrives. */\n settlementPollInterval: PositiveMillis,\n /** Active-Run abort-intent poll cadence. */\n abortPollInterval: PositiveMillis,\n /** Bounded SQLITE_BUSY retry window for write-lock acquisition. */\n busyTimeout: NonNegativeMillis,\n /** SQLite WAL synchronization selected for this host's connection at construction. */\n synchronous: SqliteStorageConfigValue.fields.synchronous,\n /** Canonical observation poll cadence of the SQLite store. */\n observationPollInterval: NonNegativeMillis,\n /** Opt-in full history and active-state validation while opening the store. */\n verifyOnOpen: Schema.Boolean,\n}) {}\n\n/** Explicit configuration authority for the assembled Node durable runtime. */\nexport class NodeDurableAgentRuntimeConfig extends Context.Service<\n NodeDurableAgentRuntimeConfig,\n NodeDurableAgentRuntimeConfigValue\n>()('@effect-agent/platform-node/NodeDurableAgentRuntimeConfig') {}\n\n/**\n * Raw (unvalidated) construction options for `NodeDurableAgentRuntime.layer`. Optional fields default\n * to the documented production values; everything is schema-decoded into\n * `NodeDurableAgentRuntimeConfigValue` before any resource opens (deployment §5 gate 1).\n */\nexport interface NodeDurableAgentRuntimeOptions<\n ContextError = never,\n ContextRequirements = never,\n AuthorizationError = never,\n AuthorizationRequirements = never,\n ReconcilerError = never,\n ReconcilerRequirements = never,\n> {\n readonly filename: string\n readonly deploymentId: string\n readonly producerId: string\n /** Default 1; bounded to 1..64. */\n readonly workerConcurrency?: number | undefined\n /** Milliseconds; default 1000. */\n readonly wakeScanInterval?: number | undefined\n /** Milliseconds; default 500. */\n readonly settlementPollInterval?: number | undefined\n /** Milliseconds; default 500. */\n readonly abortPollInterval?: number | undefined\n /** Deployment-owned pricing authority used by durable cost budgets and settlements. */\n readonly estimateCostMicrousd?: RunCostEstimator | undefined\n /** Closed trusted Tool failure reporting. Omission masks ambient observers at construction. */\n readonly toolFailureObserver?: RunToolFailureObserver | undefined\n /** Milliseconds; default 5000. */\n readonly busyTimeout?: number | undefined\n /**\n * Defaults to FULL. NORMAL can lose acknowledged commits after power loss or an OS crash,\n * potentially repeating external effects. The choice belongs to this host's SQLite connection.\n */\n readonly synchronous?: 'FULL' | 'NORMAL' | undefined\n /** Milliseconds; default 25. */\n readonly observationPollInterval?: number | undefined\n /** Default false. */\n readonly verifyOnOpen?: boolean | undefined\n /** SQLite adapter fault injection (`ledger:*` / `append:*` locations); default none. */\n readonly storageFailpoint?: SqliteStorageFailpointHandler | undefined\n /** Coordinator fault injection (`submit:*` / `terminalize:*` locations); default none. */\n readonly runtimeFailpoint?: DurableRuntimeFailpointHandler | undefined\n /**\n * Reconciliation policy consulted for open ordinary Tool Calls before an Unknown Outcome is\n * recorded (durability §10, DUR-009). Defaults to the fail-closed `ToolReconciler.uncertain`:\n * with no registered policy, every open call stays Unknown and routes to the authorized\n * DUR-017 resolution path. Construction errors and application dependencies remain in the\n * assembled Layer's E and R; the platform supplies Digest and SecureRandom.\n */\n readonly toolReconciler?:\n | Layer.Layer<\n ToolReconciler,\n ReconcilerError,\n ReconcilerRequirements | CryptoDigest.Digest | SecureRandom.SecureRandom\n >\n | undefined\n /** Host prompt preparation, acquired once with the runtime; default pass-through. */\n readonly runContext?:\n | Layer.Layer<\n RunContextPreparation,\n ContextError,\n ContextRequirements | CryptoDigest.Digest | SecureRandom.SecureRandom\n >\n | undefined\n /**\n * Independent action-time Tool authority, acquired once with the runtime; default allow-all.\n * Construction errors and application dependencies remain in the assembled Layer's E and R.\n * The platform supplies Digest and SecureRandom to these extension Layers.\n */\n readonly toolAuthorization?:\n | Layer.Layer<\n RunToolAuthorization,\n AuthorizationError,\n AuthorizationRequirements | CryptoDigest.Digest | SecureRandom.SecureRandom\n >\n | undefined\n}\n\n/** Built-in construction failures. `layer` also preserves supplied service Layers' errors. */\nexport type NodeDurableAgentRuntimeInitializationError =\n | NodePlatformConfigError\n | MessageDeliveryError\n | SqliteStorageInitializationError\n\n/**\n * The services `NodeDurableAgentRuntime.layer` provides. Additional SQLite adapters can use\n * the same client and storage configuration, sharing its serialized connection and Scope.\n */\nexport type NodeDurableAgentRuntimeServices = Layer.Success<\n ReturnType<typeof NodeDurableAgentRuntime.layer>\n>\n\nconst decodeConfigValue = Schema.decodeUnknownEffect(NodeDurableAgentRuntimeConfigValue)\n\nconst configFromOptions = (\n options: Omit<\n NodeDurableAgentRuntimeOptions,\n 'runContext' | 'toolAuthorization' | 'toolReconciler'\n >,\n): Effect.Effect<NodeDurableAgentRuntimeConfigValue, NodePlatformConfigError> =>\n decodeConfigValue({\n filename: options.filename,\n deploymentId: options.deploymentId,\n producerId: options.producerId,\n workerConcurrency: options.workerConcurrency ?? 1,\n wakeScanInterval: options.wakeScanInterval ?? 1_000,\n settlementPollInterval: options.settlementPollInterval ?? 500,\n abortPollInterval: options.abortPollInterval ?? 500,\n busyTimeout: options.busyTimeout ?? 5_000,\n synchronous: options.synchronous ?? 'FULL',\n observationPollInterval: options.observationPollInterval ?? 25,\n verifyOnOpen: options.verifyOnOpen ?? false,\n }).pipe(\n Effect.mapError((error) =>\n NodePlatformConfigError.make({\n message: `Invalid Node durable runtime configuration: ${error.message}`,\n cause: error,\n })\n ),\n )\n\n/** SQLite storage configuration derived from the single validated Node configuration. */\nconst sqliteStorageConfigLayer: Layer.Layer<\n SqliteStorageConfig,\n never,\n NodeDurableAgentRuntimeConfig\n> = Layer.effect(SqliteStorageConfig)(\n Effect.gen(function*() {\n const config = yield* NodeDurableAgentRuntimeConfig\n\n return SqliteStorageConfigValue.make({\n observationPollInterval: config.observationPollInterval,\n busyTimeout: config.busyTimeout,\n synchronous: config.synchronous,\n verifyOnOpen: config.verifyOnOpen,\n })\n }),\n)\n\n/** Thread coordinator configuration derived from the single validated Node configuration. */\nconst durableRuntimeConfigLayer = (\n estimateCostMicrousd: RunCostEstimator | undefined,\n): Layer.Layer<DurableRuntimeConfig, never, NodeDurableAgentRuntimeConfig> =>\n Layer.effect(DurableRuntimeConfig)(\n Effect.gen(function*() {\n const config = yield* NodeDurableAgentRuntimeConfig\n\n return DurableRuntimeConfig.make({\n deploymentId: config.deploymentId,\n producerId: config.producerId,\n settlementPollInterval: Duration.millis(config.settlementPollInterval),\n abortPollInterval: Duration.millis(config.abortPollInterval),\n ...(estimateCostMicrousd === undefined ? {} : { estimateCostMicrousd }),\n })\n }),\n )\n\n/** Wake fallback-scan cadence derived from the single validated Node configuration. */\nconst wakeSchedulerConfigLayer: Layer.Layer<\n NodeWakeSchedulerConfig,\n never,\n NodeDurableAgentRuntimeConfig\n> = Layer.effect(NodeWakeSchedulerConfig)(\n Effect.gen(function*() {\n const config = yield* NodeDurableAgentRuntimeConfig\n\n return { scanInterval: Duration.millis(config.wakeScanInterval) }\n }),\n)\n\n/** The managed database stays private even when a caller supplies SQL transformers. */\nconst privateMessageDeliveryLayer = Layer.effect(MessageDeliveryStore)(\n Effect.gen(function*() {\n const storageContext = (yield* Effect.context<\n | SqlClientService.SqlClient\n | CryptoDigest.Digest\n | SqliteStorageConfig\n | SqliteStorageFailpoint\n | Scope.Scope\n >()).pipe(\n Context.pick(\n SqlClientService.SqlClient,\n CryptoDigest.Digest,\n SqliteStorageConfig,\n SqliteStorageFailpoint,\n Scope.Scope,\n ),\n )\n\n const sql = Context.get(storageContext, SqlClientService.SqlClient)\n\n const bind = <A, E>(\n effect: Effect.Effect<\n A,\n E,\n | SqlClientService.SqlClient\n | CryptoDigest.Digest\n | SqliteStorageConfig\n | SqliteStorageFailpoint\n | Scope.Scope\n >,\n ) =>\n Effect.contextWith((live: Context.Context<never>) =>\n Effect.setContext(\n effect,\n Context.merge(\n Context.omit(Statement.CurrentTransformer, sql.transactionService)(live),\n storageContext,\n ),\n )\n )\n\n const services = yield* bind(Layer.build(messageDeliveryStoreLayer()))\n\n const store = Context.get(services, MessageDeliveryStore)\n\n return MessageDeliveryStore.of({\n limits: store.limits,\n maxStoredValueBytes: store.maxStoredValueBytes,\n insert: (record) => bind(store.insert(record)),\n get: (key) => bind(store.get(key)),\n list: (request) => bind(store.list(request)),\n change: (key, change) => bind(store.change(key, change)),\n due: (now, limit, owner) => bind(store.due(now, limit, owner)),\n nextDeadline: (owner) => bind(store.nextDeadline(owner)),\n })\n }),\n)\n\n/**\n * The DN Layer assembly (deployment §12: a Layer-assembly library, not an app entrypoint).\n * `layer(options)` decodes the configuration, opens ONE SQLite database serving both the\n * Thread Log and the Submission Ledger under one scoped owner, wires the Node wake scheduler\n * with its ledger-scan fallback, exposes independent message delivery storage, and defaults\n * the Tool reconciliation policy to the fail-closed\n * `ToolReconciler.uncertain` (override via `options.toolReconciler`), and provides a ready\n * `DurableAgentRuntime` on top. Storage compatibility is\n * verified during construction: an incompatible database file fails the Layer with\n * `SqliteStorageCompatibilityError` before anything is mutated (DEPLOY-008).\n */\nexport class NodeDurableAgentRuntime {\n /** Validated configuration Layer; fails typed when the supplied options are out of bounds. */\n static configLayer<\n ContextError = never,\n ContextRequirements = never,\n AuthorizationError = never,\n AuthorizationRequirements = never,\n ReconcilerError = never,\n ReconcilerRequirements = never,\n >(\n options: NodeDurableAgentRuntimeOptions<\n ContextError,\n ContextRequirements,\n AuthorizationError,\n AuthorizationRequirements,\n ReconcilerError,\n ReconcilerRequirements\n >,\n ): Layer.Layer<NodeDurableAgentRuntimeConfig, NodePlatformConfigError> {\n return Layer.effect(NodeDurableAgentRuntimeConfig)(configFromOptions(options))\n }\n\n /** The full DN runtime stack over one SQLite file. */\n static layer<\n ContextError = never,\n ContextRequirements = never,\n AuthorizationError = never,\n AuthorizationRequirements = never,\n ReconcilerError = never,\n ReconcilerRequirements = never,\n >(\n options: NodeDurableAgentRuntimeOptions<\n ContextError,\n ContextRequirements,\n AuthorizationError,\n AuthorizationRequirements,\n ReconcilerError,\n ReconcilerRequirements\n >,\n ) {\n return NodeDurableAgentRuntime.assemble(DurableAgentRuntime.layerWithServices, options)\n }\n\n /** Own typed executable registrations for every worker using this Node runtime. */\n static layerRegistered<\n const Entries extends ReadonlyArray<AgentRegistration>,\n ContextError = never,\n ContextRequirements = never,\n AuthorizationError = never,\n AuthorizationRequirements = never,\n ReconcilerError = never,\n ReconcilerRequirements = never,\n >(\n registrations: Entries,\n options: NodeDurableAgentRuntimeOptions<\n ContextError,\n ContextRequirements,\n AuthorizationError,\n AuthorizationRequirements,\n ReconcilerError,\n ReconcilerRequirements\n >,\n ) {\n return Layer.unwrap(\n Effect.gen(function*() {\n const bindings = yield* compileRegistrations(registrations)\n const exclusive = yield* ExclusiveSqliteHost\n\n // Only the managed Node host owns a private database. Other platforms retain their\n // invocation controls, including the source identity of native maintenance writes.\n const isolate = <A, E>(effect: Effect.Effect<A, E>) =>\n Effect.contextWith((live: Context.Context<never>) =>\n Effect.setContext(effect, applicationInvocationContext(live))\n )\n\n return NodeDurableAgentRuntime.layerWithBindings(\n exclusive\n ? bindings.map((binding): ResolvedBinding => ({\n ...binding,\n attempt: (...args) => isolate(binding.attempt(...args)),\n ...(binding.reporting === undefined\n ? {}\n : {\n reporting: binding.reporting.map((report) => ({\n ...report,\n prepare: (value) => isolate(report.prepare(value)),\n })),\n }),\n }))\n : bindings,\n options,\n )\n }).pipe(Effect.provide(NodeCrypto.layer)),\n )\n }\n\n /** Construct from registrations already resolved within the enclosing application Scope. */\n static layerWithBindings<\n ContextError = never,\n ContextRequirements = never,\n AuthorizationError = never,\n AuthorizationRequirements = never,\n ReconcilerError = never,\n ReconcilerRequirements = never,\n >(\n bindings: ReadonlyArray<ResolvedBinding>,\n options: NodeDurableAgentRuntimeOptions<\n ContextError,\n ContextRequirements,\n AuthorizationError,\n AuthorizationRequirements,\n ReconcilerError,\n ReconcilerRequirements\n >,\n ) {\n return NodeDurableAgentRuntime.assemble(\n DurableAgentRuntime.layerWithBindings(bindings),\n options,\n )\n }\n\n private static assemble<\n RuntimeError,\n RuntimeRequirements,\n ContextError,\n ContextRequirements,\n AuthorizationError,\n AuthorizationRequirements,\n ReconcilerError,\n ReconcilerRequirements,\n >(\n runtimeLayer: Layer.Layer<DurableAgentRuntime, RuntimeError, RuntimeRequirements>,\n options: NodeDurableAgentRuntimeOptions<\n ContextError,\n ContextRequirements,\n AuthorizationError,\n AuthorizationRequirements,\n ReconcilerError,\n ReconcilerRequirements\n >,\n ) {\n const assembled = Layer.unwrap(\n Effect.gen(function*() {\n const config = yield* configFromOptions(options)\n const exclusive = yield* ExclusiveSqliteHost\n const nodeConfigLayer = Layer.succeed(NodeDurableAgentRuntimeConfig)(config)\n\n // Application extensions are acquired before the private database exists.\n const applicationContext = (yield* Effect.context<never>()).pipe(Context.omit(Scope.Scope))\n\n const applicationServices = yield* Layer.build(\n Layer.mergeAll(\n options.runContext ?? RunContextPreparationPassthrough,\n options.toolAuthorization ?? RunToolAuthorization.allowAll,\n options.toolReconciler ?? ToolReconciler.uncertain,\n options.toolFailureObserver === undefined\n ? Layer.succeed(CurrentToolFailureObserver)(undefined)\n : toolFailureObserverLayer(options.toolFailureObserver),\n ).pipe(Layer.provide(NodeCrypto.layer)),\n )\n\n const storageFailpoint = options.storageFailpoint\n const runtimeFailpoint = options.runtimeFailpoint\n\n const clientInfrastructure = Layer.mergeAll(\n sqliteStorageConfigLayer,\n storageFailpointLayer({\n filename: config.filename,\n failpoint: storageFailpoint === undefined\n ? undefined\n : (location) =>\n Effect.scoped(Effect.suspend(() => storageFailpoint(location))).pipe(\n Effect.setContext(applicationContext),\n ),\n }),\n SqliteClient.layer({ filename: config.filename, disableWAL: exclusive }).pipe(\n Layer.catch((cause) =>\n Layer.effectContext<\n Layer.Success<ReturnType<typeof SqliteClient.layer>>,\n SqliteStorageError,\n never\n >(\n Effect.fail(\n SqliteStorageError.make({\n operation: 'open SQLite',\n message: cause.message,\n cause,\n }),\n ),\n )\n ),\n ),\n NodeCrypto.layer,\n ).pipe(Layer.provide(nodeConfigLayer))\n\n // The managed host no longer composes its database with application SQL hooks.\n // Only the enclosing resource Scope crosses into storage construction.\n const exclusiveInfrastructure = Layer.effectContext(\n Effect.gen(function*() {\n const scope = yield* Effect.scope\n\n return yield* Layer.build(\n Layer.fresh(exclusiveHostClientLayer).pipe(Layer.provideMerge(clientInfrastructure)),\n ).pipe(Effect.setContext(Context.make(Scope.Scope, scope)))\n }),\n )\n\n const runtimeFailpointLayer = runtimeFailpoint === undefined\n ? DurableRuntimeFailpoint.layer\n : Layer.succeed(DurableRuntimeFailpoint)({\n hit: (location) =>\n Effect.scoped(Effect.suspend(() => runtimeFailpoint(location))).pipe(\n Effect.setContext(applicationContext),\n ),\n })\n\n const ordinaryStorage = runStorageLayer.pipe(\n Layer.provideMerge(Layer.mergeAll(threadStoreLayer, submissionLedgerLayer)),\n )\n\n const portLayers = Layer.mergeAll(\n ThreadReader.layer(),\n nodeWakeSchedulerLayer,\n exclusive ? privateMessageDeliveryLayer : messageDeliveryStoreLayer(),\n // Custom manual assemblies own schedules; the managed host owns only its runtime.\n exclusive ? Layer.empty : scheduleStoreLayer,\n )\n\n const ports = exclusive\n ? portLayers.pipe(\n Layer.provideMerge(exclusiveRunStorageLayer),\n Layer.provideMerge(exclusiveInfrastructure),\n )\n : portLayers.pipe(\n Layer.provideMerge(ordinaryStorage),\n Layer.provideMerge(clientInfrastructure),\n )\n\n return runtimeLayer.pipe(\n Layer.provideMerge(\n Layer.mergeAll(ports, durableRuntimeConfigLayer(options.estimateCostMicrousd)),\n ),\n Layer.provide(Layer.mergeAll(wakeSchedulerConfigLayer, runtimeFailpointLayer)),\n Layer.provideMerge(nodeConfigLayer),\n Layer.provide(Layer.succeedContext(applicationServices)),\n )\n }),\n )\n\n return assembled\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,+BAA+B,QAAQ,KAClD,MAAM,OACN,MAAM,OACN,OAAO,YACP,OAAO,QACP,OAAO,mBACP,OAAO,mBACP,WAAW,eACX,WAAW,qBACX,WAAW,uBACX,WAAW,iBACX,WAAW,gBACX,WAAW,iBACX,WAAW,iBACX,WAAW,mBACX,WAAW,uBACX,WAAW,eACb;;;ACrBA,MAAa,sBAAsB,QAAQ,UACzC,4DACA,EAAE,oBAAoB,MAAM,CAC9B;;;;;;;;ACmDA,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;AAC/D,MAAM,oBAAoB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAE3E,MAAM,oBAAoB,OAAO,IAAI,MACnC,OAAO,uBAAuB,CAAC,GAC/B,OAAO,oBAAoB,EAAE,CAC/B;;AAGA,IAAa,0BAAb,cAA6C,OAAO,YAAqC,CAAC,CACxF,2BACA;CACE,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;AAOH,IAAa,qCAAb,cAAwD,OAAO,MAC7D,gEACF,CAAC,CAAC;;CAEA,UAAU,OAAO;CACjB,cAAc;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CAAC,KAC9D,OAAO,WAAW,kBAAkB,CACtC,EACJ,CAAC;GAEH,MAAM,kBAAkBA,MAAgB,KACtC,MAAM,aAAa,MAAM,SAAS,kBAAkB,qBAAqB,CAAC,CAC5E;GAEA,MAAM,aAAa,MAAM,SACvB,aAAa,MAAM,GACnB,wBACA,YAAY,8BAA8B,0BAA0B,GAEpE,YAAY,MAAM,QAAQ,kBAC5B;GAEA,MAAM,QAAQ,YACV,WAAW,KACX,MAAM,aAAa,wBAAwB,GAC3C,MAAM,aAAa,uBAAuB,CAC5C,IACE,WAAW,KACX,MAAM,aAAa,eAAe,GAClC,MAAM,aAAa,oBAAoB,CACzC;GAEF,OAAO,aAAa,KAClB,MAAM,aACJ,MAAM,SAAS,OAAO,0BAA0B,QAAQ,oBAAoB,CAAC,CAC/E,GACA,MAAM,QAAQ,MAAM,SAAS,0BAA0B,qBAAqB,CAAC,GAC7E,MAAM,aAAa,eAAe,GAClC,MAAM,QAAQ,MAAM,eAAe,mBAAmB,CAAC,CACzD;EACF,CAAC,CAGY;CACjB;AACF"}
@@ -0,0 +1,163 @@
1
+ import * as SqliteClient from "@effect/sql-sqlite-node/SqliteClient";
2
+ import { SqliteStorageConfig } from "@systemfsoftware/agent-storage-sqlite/sqlite-storage-config";
3
+ import { SqliteStorageFailpoint, SqliteStorageFailpointHandler } from "@systemfsoftware/agent-storage-sqlite/sqlite-storage-failpoint";
4
+ import { SqliteStorageInitializationError } from "@systemfsoftware/agent-storage-sqlite/sqlite-thread-store";
5
+ import { AgentRegistration, ResolvedBinding } from "@systemfsoftware/agent/agent-registration";
6
+ import { DurableAgentRuntime, DurableRuntimeConfig } from "@systemfsoftware/agent/durable-agent-runtime";
7
+ import { DurableRuntimeFailpointHandler } from "@systemfsoftware/agent/durable-failpoint";
8
+ import { MessageDeliveryError, MessageDeliveryStore } from "@systemfsoftware/agent/message-delivery";
9
+ import { RunContextPreparation, RunCostEstimator, RunToolAuthorization, RunToolFailureObserver } from "@systemfsoftware/agent/run-options";
10
+ import { ThreadReader } from "@systemfsoftware/agent/thread-store";
11
+ import { ToolReconciler } from "@systemfsoftware/agent/tool-reconciler";
12
+ import * as Context from "effect/Context";
13
+ import * as CryptoDigest from "effect/crypto/Digest";
14
+ import * as SecureRandom from "effect/crypto/SecureRandom";
15
+ import * as Layer from "effect/Layer";
16
+ import * as Schema from "effect/Schema";
17
+ import * as Scope from "effect/Scope";
18
+ import * as SqlClientService from "effect/sql/SqlClient";
19
+ declare namespace NodeDurableAgentRuntime_d_exports {
20
+ export { NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig, NodeDurableAgentRuntimeConfigValue, NodeDurableAgentRuntimeInitializationError, NodeDurableAgentRuntimeOptions, NodeDurableAgentRuntimeServices, NodePlatformConfigError };
21
+ }
22
+ declare const NodePlatformConfigError_base: Schema.Class<NodePlatformConfigError, Schema.TaggedStruct<"NodePlatformConfigError", {
23
+ readonly message: Schema.String;
24
+ readonly cause: Schema.optionalKey<Schema.Defect>;
25
+ }>, import("effect/Cause").YieldableError>;
26
+ /** The supplied Node durable runtime configuration failed schema validation (DEPLOY-003). */
27
+ declare class NodePlatformConfigError extends NodePlatformConfigError_base {}
28
+ declare const NodeDurableAgentRuntimeConfigValue_base: Schema.Class<NodeDurableAgentRuntimeConfigValue, Schema.Struct<{
29
+ /** SQLite database file backing the Thread Log, Submission Ledger, and delivery obligations. */
30
+ readonly filename: Schema.NonEmptyString;
31
+ readonly deploymentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/DeploymentId">;
32
+ readonly producerId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/ProducerId">;
33
+ /** Finite bound on concurrent worker loops per host (rule 10). */
34
+ readonly workerConcurrency: Schema.Int;
35
+ /** Fallback scan cadence for the Node wake scheduler and independent message delivery recovery. */
36
+ readonly wakeScanInterval: Schema.Int;
37
+ /** `awaitSettlement` ledger re-check cadence when no wake arrives. */
38
+ readonly settlementPollInterval: Schema.Int;
39
+ /** Active-Run abort-intent poll cadence. */
40
+ readonly abortPollInterval: Schema.Int;
41
+ /** Bounded SQLITE_BUSY retry window for write-lock acquisition. */
42
+ readonly busyTimeout: Schema.Int;
43
+ /** SQLite WAL synchronization selected for this host's connection at construction. */
44
+ readonly synchronous: Schema.Literals<readonly ["FULL", "NORMAL"]>;
45
+ /** Canonical observation poll cadence of the SQLite store. */
46
+ readonly observationPollInterval: Schema.Int;
47
+ /** Opt-in full history and active-state validation while opening the store. */
48
+ readonly verifyOnOpen: Schema.Boolean;
49
+ }>, {}>;
50
+ /**
51
+ * Validated Node durable runtime configuration (deployment §4: decoded once during Layer
52
+ * construction, exposed as a typed service). Every cadence is in milliseconds and every bound is
53
+ * finite; `workerConcurrency` caps how many worker loops `NodeDurableHost.runWorkers` drives.
54
+ */
55
+ declare class NodeDurableAgentRuntimeConfigValue extends NodeDurableAgentRuntimeConfigValue_base {}
56
+ declare const NodeDurableAgentRuntimeConfig_base: Context.ServiceClass<NodeDurableAgentRuntimeConfig, "@effect-agent/platform-node/NodeDurableAgentRuntimeConfig", NodeDurableAgentRuntimeConfigValue>;
57
+ /** Explicit configuration authority for the assembled Node durable runtime. */
58
+ declare class NodeDurableAgentRuntimeConfig extends NodeDurableAgentRuntimeConfig_base {}
59
+ /**
60
+ * Raw (unvalidated) construction options for `NodeDurableAgentRuntime.layer`. Optional fields default
61
+ * to the documented production values; everything is schema-decoded into
62
+ * `NodeDurableAgentRuntimeConfigValue` before any resource opens (deployment §5 gate 1).
63
+ */
64
+ interface NodeDurableAgentRuntimeOptions<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never> {
65
+ readonly filename: string;
66
+ readonly deploymentId: string;
67
+ readonly producerId: string;
68
+ /** Default 1; bounded to 1..64. */
69
+ readonly workerConcurrency?: number | undefined;
70
+ /** Milliseconds; default 1000. */
71
+ readonly wakeScanInterval?: number | undefined;
72
+ /** Milliseconds; default 500. */
73
+ readonly settlementPollInterval?: number | undefined;
74
+ /** Milliseconds; default 500. */
75
+ readonly abortPollInterval?: number | undefined;
76
+ /** Deployment-owned pricing authority used by durable cost budgets and settlements. */
77
+ readonly estimateCostMicrousd?: RunCostEstimator | undefined;
78
+ /** Closed trusted Tool failure reporting. Omission masks ambient observers at construction. */
79
+ readonly toolFailureObserver?: RunToolFailureObserver | undefined;
80
+ /** Milliseconds; default 5000. */
81
+ readonly busyTimeout?: number | undefined;
82
+ /**
83
+ * Defaults to FULL. NORMAL can lose acknowledged commits after power loss or an OS crash,
84
+ * potentially repeating external effects. The choice belongs to this host's SQLite connection.
85
+ */
86
+ readonly synchronous?: 'FULL' | 'NORMAL' | undefined;
87
+ /** Milliseconds; default 25. */
88
+ readonly observationPollInterval?: number | undefined;
89
+ /** Default false. */
90
+ readonly verifyOnOpen?: boolean | undefined;
91
+ /** SQLite adapter fault injection (`ledger:*` / `append:*` locations); default none. */
92
+ readonly storageFailpoint?: SqliteStorageFailpointHandler | undefined;
93
+ /** Coordinator fault injection (`submit:*` / `terminalize:*` locations); default none. */
94
+ readonly runtimeFailpoint?: DurableRuntimeFailpointHandler | undefined;
95
+ /**
96
+ * Reconciliation policy consulted for open ordinary Tool Calls before an Unknown Outcome is
97
+ * recorded (durability §10, DUR-009). Defaults to the fail-closed `ToolReconciler.uncertain`:
98
+ * with no registered policy, every open call stays Unknown and routes to the authorized
99
+ * DUR-017 resolution path. Construction errors and application dependencies remain in the
100
+ * assembled Layer's E and R; the platform supplies Digest and SecureRandom.
101
+ */
102
+ readonly toolReconciler?: Layer.Layer<ToolReconciler, ReconcilerError, ReconcilerRequirements | CryptoDigest.Digest | SecureRandom.SecureRandom> | undefined;
103
+ /** Host prompt preparation, acquired once with the runtime; default pass-through. */
104
+ readonly runContext?: Layer.Layer<RunContextPreparation, ContextError, ContextRequirements | CryptoDigest.Digest | SecureRandom.SecureRandom> | undefined;
105
+ /**
106
+ * Independent action-time Tool authority, acquired once with the runtime; default allow-all.
107
+ * Construction errors and application dependencies remain in the assembled Layer's E and R.
108
+ * The platform supplies Digest and SecureRandom to these extension Layers.
109
+ */
110
+ readonly toolAuthorization?: Layer.Layer<RunToolAuthorization, AuthorizationError, AuthorizationRequirements | CryptoDigest.Digest | SecureRandom.SecureRandom> | undefined;
111
+ }
112
+ /** Built-in construction failures. `layer` also preserves supplied service Layers' errors. */
113
+ type NodeDurableAgentRuntimeInitializationError = NodePlatformConfigError | MessageDeliveryError | SqliteStorageInitializationError;
114
+ /**
115
+ * The services `NodeDurableAgentRuntime.layer` provides. Additional SQLite adapters can use
116
+ * the same client and storage configuration, sharing its serialized connection and Scope.
117
+ */
118
+ type NodeDurableAgentRuntimeServices = Layer.Success<ReturnType<typeof NodeDurableAgentRuntime.layer>>;
119
+ /**
120
+ * The DN Layer assembly (deployment §12: a Layer-assembly library, not an app entrypoint).
121
+ * `layer(options)` decodes the configuration, opens ONE SQLite database serving both the
122
+ * Thread Log and the Submission Ledger under one scoped owner, wires the Node wake scheduler
123
+ * with its ledger-scan fallback, exposes independent message delivery storage, and defaults
124
+ * the Tool reconciliation policy to the fail-closed
125
+ * `ToolReconciler.uncertain` (override via `options.toolReconciler`), and provides a ready
126
+ * `DurableAgentRuntime` on top. Storage compatibility is
127
+ * verified during construction: an incompatible database file fails the Layer with
128
+ * `SqliteStorageCompatibilityError` before anything is mutated (DEPLOY-008).
129
+ */
130
+ declare class NodeDurableAgentRuntime {
131
+ /** Validated configuration Layer; fails typed when the supplied options are out of bounds. */
132
+ static configLayer<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements, ReconcilerError, ReconcilerRequirements>): Layer.Layer<NodeDurableAgentRuntimeConfig, NodePlatformConfigError>;
133
+ /** The full DN runtime stack over one SQLite file. */
134
+ static layer<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements, ReconcilerError, ReconcilerRequirements>): Layer.Layer<import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | DurableAgentRuntime | DurableRuntimeConfig | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | MessageDeliveryStore | NodeDurableAgentRuntimeConfig | import("@systemfsoftware/agent/run-storage").RunStorage | import("@systemfsoftware/agent/schedule").ScheduleStore | SecureRandom.SecureRandom | import("@systemfsoftware/agent/settlement-publisher").SettlementPublisher | import("effect/crypto/Signature").Signature | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint | import("@systemfsoftware/agent/run-storage").StorageOwner | import("@systemfsoftware/agent/submission-ledger").SubmissionLedger | import("@systemfsoftware/agent/thread-import").ThreadImport | ThreadReader | import("@systemfsoftware/agent/thread-store").ThreadStore | import("@systemfsoftware/agent/wake-scheduler").WakeScheduler, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | import("@systemfsoftware/agent/thread-store").ThreadStoreError | SqliteStorageInitializationError, Exclude<Exclude<AuthorizationRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope> | Exclude<Exclude<ContextRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope> | Exclude<Exclude<ReconcilerRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope>>;
135
+ /** Own typed executable registrations for every worker using this Node runtime. */
136
+ static layerRegistered<const Entries extends ReadonlyArray<AgentRegistration>, ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never>(registrations: Entries, options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements, ReconcilerError, ReconcilerRequirements>): Layer.Layer<import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | DurableAgentRuntime | DurableRuntimeConfig | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | MessageDeliveryStore | NodeDurableAgentRuntimeConfig | import("@systemfsoftware/agent/run-storage").RunStorage | import("@systemfsoftware/agent/schedule").ScheduleStore | SecureRandom.SecureRandom | import("@systemfsoftware/agent/settlement-publisher").SettlementPublisher | import("effect/crypto/Signature").Signature | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint | import("@systemfsoftware/agent/run-storage").StorageOwner | import("@systemfsoftware/agent/submission-ledger").SubmissionLedger | import("@systemfsoftware/agent/thread-import").ThreadImport | ThreadReader | import("@systemfsoftware/agent/thread-store").ThreadStore | import("@systemfsoftware/agent/wake-scheduler").WakeScheduler, AuthorizationError | ContextError | ReconcilerError | import("@systemfsoftware/agent/digest").DigestError | MessageDeliveryError | NodePlatformConfigError | import("@systemfsoftware/agent/thread-store").ThreadStoreError | SqliteStorageInitializationError, Exclude<Exclude<AuthorizationRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope> | Exclude<Exclude<ContextRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope> | Exclude<Exclude<ReconcilerRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope> | Exclude<Exclude<Entries[number] extends (infer T_3) ? T_3 extends Entries[number] ? T_3 extends unknown ? (("attemptLayer" extends keyof T_3 ? T_3[keyof T_3 & "attemptLayer"] : undefined) extends (infer T_4) ? T_4 extends ("attemptLayer" extends keyof T_3 ? T_3[keyof T_3 & "attemptLayer"] : undefined) ? T_4 extends ((context: import("@systemfsoftware/agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
137
+ readonly agent: infer A extends import("@systemfsoftware/agent/agent-registration").ExecutableAgentBinding;
138
+ } ? import("@systemfsoftware/agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
139
+ readonly agent: infer D extends import("@systemfsoftware/agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/ai/Toolkit").Any, import("@systemfsoftware/agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
140
+ readonly instructions: import("@systemfsoftware/agent/agent").InstructionSource<never, unknown, unknown>;
141
+ readonly inputPrompt?: import("@systemfsoftware/agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
142
+ };
143
+ readonly model: infer M extends import("@systemfsoftware/agent/agent-registration").ExecutableAgentBinding['model'];
144
+ } ? import("@systemfsoftware/agent/durable-agent-runtime").DurableWorkerRequirements<{
145
+ readonly definition: D;
146
+ readonly model: M;
147
+ }> : never, Provides> : T_3 extends {
148
+ readonly agent: infer A extends import("@systemfsoftware/agent/agent-registration").ExecutableAgentBinding;
149
+ } ? import("@systemfsoftware/agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
150
+ readonly agent: infer D extends import("@systemfsoftware/agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/ai/Toolkit").Any, import("@systemfsoftware/agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
151
+ readonly instructions: import("@systemfsoftware/agent/agent").InstructionSource<never, unknown, unknown>;
152
+ readonly inputPrompt?: import("@systemfsoftware/agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
153
+ };
154
+ readonly model: infer M extends import("@systemfsoftware/agent/agent-registration").ExecutableAgentBinding['model'];
155
+ } ? import("@systemfsoftware/agent/durable-agent-runtime").DurableWorkerRequirements<{
156
+ readonly definition: D;
157
+ readonly model: M;
158
+ }> : never : never : never) | (("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] : undefined) extends (infer T_5) ? T_5 extends ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] : undefined) ? T_5 extends readonly import("@systemfsoftware/agent/subagent-host").WorkerReporting<infer _E, infer R>[] ? Exclude<R, Scope.Scope> : never : never : never) : never : never : never, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope>>;
159
+ /** Construct from registrations already resolved within the enclosing application Scope. */
160
+ static layerWithBindings<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never>(bindings: ReadonlyArray<ResolvedBinding>, options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements, ReconcilerError, ReconcilerRequirements>): Layer.Layer<import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | DurableAgentRuntime | DurableRuntimeConfig | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | MessageDeliveryStore | NodeDurableAgentRuntimeConfig | import("@systemfsoftware/agent/run-storage").RunStorage | import("@systemfsoftware/agent/schedule").ScheduleStore | SecureRandom.SecureRandom | import("@systemfsoftware/agent/settlement-publisher").SettlementPublisher | import("effect/crypto/Signature").Signature | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint | import("@systemfsoftware/agent/run-storage").StorageOwner | import("@systemfsoftware/agent/submission-ledger").SubmissionLedger | import("@systemfsoftware/agent/thread-import").ThreadImport | ThreadReader | import("@systemfsoftware/agent/thread-store").ThreadStore | import("@systemfsoftware/agent/wake-scheduler").WakeScheduler, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | import("@systemfsoftware/agent/thread-store").ThreadStoreError | SqliteStorageInitializationError, Exclude<Exclude<AuthorizationRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope> | Exclude<Exclude<ContextRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope> | Exclude<Exclude<ReconcilerRequirements, import("effect/crypto/Aead").Aead | import("effect/crypto/Cipher").Cipher | CryptoDigest.Digest | import("effect/crypto/Kdf").Kdf | import("effect/crypto/KeyAgreement").KeyAgreement | import("effect/crypto/KeyWrap").KeyWrap | import("effect/crypto/Mac").Mac | SecureRandom.SecureRandom | import("effect/crypto/Signature").Signature>, Scope.Scope>>;
161
+ private static assemble;
162
+ }
163
+ export { NodeDurableAgentRuntimeOptions as a, NodePlatformConfigError as c, NodeDurableAgentRuntimeInitializationError as i, NodeDurableAgentRuntimeConfig as n, NodeDurableAgentRuntimeServices as o, NodeDurableAgentRuntimeConfigValue as r, NodeDurableAgentRuntime_d_exports as s, NodeDurableAgentRuntime as t };
@@ -0,0 +1,2 @@
1
+ import { a as NodeDurableAgentRuntimeOptions, c as NodePlatformConfigError, i as NodeDurableAgentRuntimeInitializationError, n as NodeDurableAgentRuntimeConfig, o as NodeDurableAgentRuntimeServices, r as NodeDurableAgentRuntimeConfigValue, t as NodeDurableAgentRuntime } from "./NodeDurableAgentRuntime-CUrOl39W.mjs";
2
+ export { NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig, NodeDurableAgentRuntimeConfigValue, NodeDurableAgentRuntimeInitializationError, NodeDurableAgentRuntimeOptions, NodeDurableAgentRuntimeServices, NodePlatformConfigError };
@@ -0,0 +1 @@
1
+ export { t as NodeDurableAgentRuntime, n as NodeDurableAgentRuntimeConfig, r as NodeDurableAgentRuntimeConfigValue, a as NodePlatformConfigError } from "./NodeDurableAgentRuntime-C5SFn9kf.mjs";