@effect-agent/platform-node 0.1.0-beta.44 → 0.1.0-beta.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,8 +1,29 @@
1
- import { AbortCommand, AbortIntent, AgentRegistration, CanonicalRecordEnvelope, DurableAbortFailure, DurableAgentRuntime, DurableAwaitFailure, DurableBindingFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableRetryFailure, DurableRuntimeConfig, DurableRuntimeFailpointHandler, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, EventSources, IntegrityReport, ObligationReport, ObligationThresholds, OperationDenied, PreparedInputAdmission, Receipt, RecoveryExplanation, RecoveryReport, ResolvedBinding, RetryCommand, ScheduleAuthorizer, ScheduleStore, ScheduleValidationError, ScheduleWake, ScheduledInputAdmission, Scheduling, SchedulingLimits, Settlement, SubmissionLedger, SubscriptionAuthorizer, SubscriptionError, SubscriptionInputBindings, SubscriptionIntake, SubscriptionLimits, SubscriptionStore, Subscriptions, ThreadNotMaterialized, ThreadStore, ThreadStoreError, ToolReconciler, WakeScheduler } from "@effect-agent/thread";
1
+ import { AbortCommand, AbortIntent, AgentRegistration, CanonicalRecordEnvelope, DurableAbortFailure, DurableAgentRuntime, DurableAwaitFailure, DurableBindingFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableRetryFailure, DurableRuntimeConfig, DurableRuntimeFailpoint, DurableRuntimeFailpointHandler, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, EventSources, IntegrityReport, ObligationReport, ObligationThresholds, OperationDenied, PreparedInputAdmission, Receipt, RecoveryExplanation, RecoveryReport, ResolvedBinding, RetryCommand, ScheduleAuthorizer, ScheduleStore, ScheduleValidationError, ScheduleWake, ScheduledInputAdmission, Scheduling, SchedulingLimits, Settlement, SubmissionLedger, SubscriptionAuthorizer, SubscriptionError, SubscriptionInputBindings, SubscriptionIntake, SubscriptionLimits, SubscriptionStore, Subscriptions, ThreadNotMaterialized, ThreadStore, ThreadStoreError, ToolReconciler, WakeScheduler } from "@effect-agent/thread";
2
2
  import { Context, Crypto, Duration, Effect, Layer, Schema, Stream } from "effect";
3
3
  import { RunContextPreparation, RunCostEstimator, RunToolAuthorization, RunToolFailureObserver } from "@effect-agent/engine";
4
- import { SqliteStorageFailpointHandler, SqliteStorageInitializationError } from "@effect-agent/storage-sqlite";
4
+ import { SqliteStorageConfig, SqliteStorageFailpointHandler, SqliteStorageInitializationError } from "@effect-agent/storage-sqlite";
5
+ import { SqliteClient } from "@effect/sql-sqlite-node";
5
6
  import { SubmissionId, ThreadId } from "@effect-agent/core";
7
+ //#region src/wake-scheduler.d.ts
8
+ declare const NodeWakeSchedulerConfig_base: Context.ServiceClass<NodeWakeSchedulerConfig, "@effect-agent/platform-node/NodeWakeSchedulerConfig", {
9
+ /** Interval between ledger scans that re-emit every nonterminal Thread lane. */
10
+ readonly scanInterval: Duration.Duration;
11
+ }>;
12
+ /** Cadence authority for the Node wake scheduler's ledger-scan fallback loop. */
13
+ declare class NodeWakeSchedulerConfig extends NodeWakeSchedulerConfig_base {
14
+ static layer(options: {
15
+ readonly scanInterval: Duration.Duration;
16
+ }): Layer.Layer<NodeWakeSchedulerConfig>;
17
+ }
18
+ /**
19
+ * In-process Node `WakeScheduler`: `notify` publishes to a bounded sliding PubSub for prompt
20
+ * same-process wakeups, and every `wakes` subscription additionally runs a periodic
21
+ * `SubmissionLedger.scanNonterminal` fallback so a dropped, coalesced, or never-sent notification
22
+ * can never strand accepted work (persistence §14). Delivery may duplicate; consumers already
23
+ * treat wakes as pure liveness hints.
24
+ */
25
+ declare const nodeWakeSchedulerLayer: Layer.Layer<WakeScheduler, never, SubmissionLedger | NodeWakeSchedulerConfig>;
26
+ //#endregion
6
27
  //#region src/layers.d.ts
7
28
  declare const NodePlatformConfigError_base: Schema.Class<NodePlatformConfigError, Schema.TaggedStruct<"NodePlatformConfigError", {
8
29
  readonly message: Schema.String;
@@ -10,7 +31,7 @@ declare const NodePlatformConfigError_base: Schema.Class<NodePlatformConfigError
10
31
  }>, import("effect/Cause").YieldableError>;
11
32
  /** The supplied Node durable runtime configuration failed schema validation (DEPLOY-003). */
12
33
  declare class NodePlatformConfigError extends NodePlatformConfigError_base {}
13
- declare const NodeDurableRuntimeConfigValue_base: Schema.Class<NodeDurableRuntimeConfigValue, Schema.Struct<{
34
+ declare const NodeDurableAgentRuntimeConfigValue_base: Schema.Class<NodeDurableAgentRuntimeConfigValue, Schema.Struct<{
14
35
  /** SQLite database file backing BOTH the Thread Log and the Submission Ledger. */
15
36
  readonly filename: Schema.NonEmptyString;
16
37
  readonly deploymentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/DeploymentId">;
@@ -39,16 +60,16 @@ declare const NodeDurableRuntimeConfigValue_base: Schema.Class<NodeDurableRuntim
39
60
  * construction, exposed as a typed service). Every cadence is in milliseconds and every bound is
40
61
  * finite; `workerConcurrency` caps how many worker loops `NodeDurableHost.runWorkers` drives.
41
62
  */
42
- declare class NodeDurableRuntimeConfigValue extends NodeDurableRuntimeConfigValue_base {}
43
- declare const NodeDurableRuntimeConfig_base: Context.ServiceClass<NodeDurableRuntimeConfig, "@effect-agent/platform-node/NodeDurableRuntimeConfig", NodeDurableRuntimeConfigValue>;
63
+ declare class NodeDurableAgentRuntimeConfigValue extends NodeDurableAgentRuntimeConfigValue_base {}
64
+ declare const NodeDurableAgentRuntimeConfig_base: Context.ServiceClass<NodeDurableAgentRuntimeConfig, "@effect-agent/platform-node/NodeDurableAgentRuntimeConfig", NodeDurableAgentRuntimeConfigValue>;
44
65
  /** Explicit configuration authority for the assembled Node durable runtime. */
45
- declare class NodeDurableRuntimeConfig extends NodeDurableRuntimeConfig_base {}
66
+ declare class NodeDurableAgentRuntimeConfig extends NodeDurableAgentRuntimeConfig_base {}
46
67
  /**
47
- * Raw (unvalidated) construction options for `NodeDurableRuntime.layer`. Optional fields default
68
+ * Raw (unvalidated) construction options for `NodeDurableAgentRuntime.layer`. Optional fields default
48
69
  * to the documented production values; everything is schema-decoded into
49
- * `NodeDurableRuntimeConfigValue` before any resource opens (deployment §5 gate 1).
70
+ * `NodeDurableAgentRuntimeConfigValue` before any resource opens (deployment §5 gate 1).
50
71
  */
51
- interface NodeDurableRuntimeOptions<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never> {
72
+ interface NodeDurableAgentRuntimeOptions<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never> {
52
73
  readonly filename: string;
53
74
  readonly deploymentId: string;
54
75
  readonly producerId: string;
@@ -95,9 +116,9 @@ interface NodeDurableRuntimeOptions<ContextError = never, ContextRequirements =
95
116
  readonly toolAuthorization?: Layer.Layer<RunToolAuthorization, AuthorizationError, AuthorizationRequirements | Crypto.Crypto> | undefined;
96
117
  }
97
118
  /** Built-in construction failures. `layer` also preserves supplied service Layers' errors. */
98
- type NodeDurableRuntimeInitializationError = NodePlatformConfigError | SqliteStorageInitializationError;
99
- /** The services `NodeDurableRuntime.layer` provides. */
100
- type NodeDurableRuntimeServices = DurableAgentRuntime | SubmissionLedger | ThreadStore | ScheduleStore | WakeScheduler | DurableRuntimeConfig | NodeDurableRuntimeConfig;
119
+ type NodeDurableAgentRuntimeInitializationError = NodePlatformConfigError | SqliteStorageInitializationError;
120
+ /** The services `NodeDurableAgentRuntime.layer` provides. */
121
+ type NodeDurableAgentRuntimeServices = DurableAgentRuntime | SubmissionLedger | ThreadStore | ScheduleStore | WakeScheduler | DurableRuntimeConfig | NodeDurableAgentRuntimeConfig;
101
122
  /**
102
123
  * Shutdown-drain decorator for a `SubmissionLedger` (deployment §6 step 6): every ownership
103
124
  * period granted through this Layer is tracked — claims start tracking, renewals follow token
@@ -118,11 +139,40 @@ declare const ownershipDrainLayer: Layer.Layer<SubmissionLedger, never, Submissi
118
139
  * verified during construction: an incompatible database file fails the Layer with
119
140
  * `SqliteStorageCompatibilityError` before anything is mutated (DEPLOY-008).
120
141
  */
121
- declare class NodeDurableRuntime {
142
+ declare class NodeDurableAgentRuntime {
122
143
  /** Validated configuration Layer; fails typed when the supplied options are out of bounds. */
123
- static configLayer<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(options: NodeDurableRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableRuntimeConfig, NodePlatformConfigError>;
144
+ static configLayer<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableAgentRuntimeConfig, NodePlatformConfigError>;
124
145
  /** The full DN runtime stack over one SQLite file. */
125
- static layer<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(options: NodeDurableRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableRuntimeServices, NodeDurableRuntimeInitializationError | ContextError | AuthorizationError, Exclude<ContextRequirements | AuthorizationRequirements, Crypto.Crypto>>;
146
+ static layer<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableAgentRuntimeServices, NodeDurableAgentRuntimeInitializationError | ContextError | AuthorizationError, Exclude<ContextRequirements | AuthorizationRequirements, Crypto.Crypto>>;
147
+ /** Own typed executable registrations for every worker using this Node runtime. */
148
+ static layerRegistered<const Entries extends ReadonlyArray<AgentRegistration>, ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(registrations: Entries, options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | import("@effect-agent/thread").DigestError | NodePlatformConfigError | SqliteStorageInitializationError, Exclude<AuthorizationRequirements, Crypto.Crypto> | Exclude<ContextRequirements, Crypto.Crypto> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : Entries[number] extends (infer T_2) ? T_2 extends Entries[number] ? T_2 extends {
149
+ readonly attemptLayer: (context: import("@effect-agent/thread").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>;
150
+ } ? Requires | Exclude<T_2 extends (infer T_3) ? T_3 extends T_2 ? T_3 extends {
151
+ readonly agent: infer A extends import("@effect-agent/thread").ExecutableAgentBinding;
152
+ } ? import("@effect-agent/thread").DurableWorkerRequirements<A> : T_3 extends {
153
+ readonly agent: infer D extends import("@effect-agent/core").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown> & {
154
+ readonly instructions: import("@effect-agent/core").InstructionSource<never, unknown, unknown>;
155
+ readonly inputPrompt?: import("@effect-agent/core").InputPromptSource<never, unknown, unknown> | undefined;
156
+ };
157
+ readonly model: infer M extends import("@effect-agent/thread").ExecutableAgentBinding["model"];
158
+ } ? import("@effect-agent/thread").DurableWorkerRequirements<{
159
+ readonly definition: D;
160
+ readonly model: M;
161
+ }> : never : never : never, Provides> : T_2 extends {
162
+ readonly agent: infer A extends import("@effect-agent/thread").ExecutableAgentBinding;
163
+ } ? import("@effect-agent/thread").DurableWorkerRequirements<A> : T_2 extends {
164
+ readonly agent: infer D extends import("@effect-agent/core").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown> & {
165
+ readonly instructions: import("@effect-agent/core").InstructionSource<never, unknown, unknown>;
166
+ readonly inputPrompt?: import("@effect-agent/core").InputPromptSource<never, unknown, unknown> | undefined;
167
+ };
168
+ readonly model: infer M extends import("@effect-agent/thread").ExecutableAgentBinding["model"];
169
+ } ? import("@effect-agent/thread").DurableWorkerRequirements<{
170
+ readonly definition: D;
171
+ readonly model: M;
172
+ }> : never : never : never, import("effect/Scope").Scope>, DurableRuntimeConfig | ScheduleStore | SubmissionLedger | ThreadStore | WakeScheduler>, DurableRuntimeFailpoint | NodeWakeSchedulerConfig | ToolReconciler>, Crypto.Crypto | import("effect/unstable/sql/SqlClient").SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | import("@effect-agent/storage-sqlite").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, RunContextPreparation | RunToolAuthorization>>;
173
+ /** Construct from registrations already resolved within the enclosing application Scope. */
174
+ static layerWithBindings<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(bindings: ReadonlyArray<ResolvedBinding>, options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | NodePlatformConfigError | SqliteStorageInitializationError, Exclude<AuthorizationRequirements, Crypto.Crypto> | Exclude<ContextRequirements, Crypto.Crypto>>;
175
+ private static assemble;
126
176
  }
127
177
  //#endregion
128
178
  //#region src/host.d.ts
@@ -194,7 +244,7 @@ declare class NodeDurableHost extends NodeDurableHost_base {
194
244
  * Startup recovery and shutdown gates are unchanged. Workers start only when the caller
195
245
  * runs runResolvedWorkers; this constructor never starts a background worker.
196
246
  */
197
- static layerRegistered<const Entries extends ReadonlyArray<AgentRegistration>, ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(registrations: Entries, options: NodeDurableRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableHost | NodeDurableRuntimeServices, AuthorizationError | ContextError | DurableWorkerFailure | NodeDurableRuntimeInitializationError, Exclude<Exclude<AuthorizationRequirements, Crypto.Crypto>, Crypto.Crypto> | Exclude<Exclude<ContextRequirements, Crypto.Crypto>, Crypto.Crypto> | Exclude<Exclude<[Entries[number]] extends [never] ? never : Entries[number] extends (infer T_2) ? T_2 extends Entries[number] ? T_2 extends {
247
+ static layerRegistered<const Entries extends ReadonlyArray<AgentRegistration>, ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(registrations: Entries, options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements>): Layer.Layer<NodeDurableHost | NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | NodePlatformConfigError | DurableWorkerFailure | import("@effect-agent/storage-sqlite").SqliteStorageInitializationError, Exclude<AuthorizationRequirements, Crypto.Crypto> | Exclude<ContextRequirements, Crypto.Crypto> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : Entries[number] extends (infer T_2) ? T_2 extends Entries[number] ? T_2 extends {
198
248
  readonly attemptLayer: (context: import("@effect-agent/thread").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>;
199
249
  } ? Requires | Exclude<T_2 extends (infer T_3) ? T_3 extends T_2 ? T_3 extends {
200
250
  readonly agent: infer A extends import("@effect-agent/thread").ExecutableAgentBinding;
@@ -218,16 +268,16 @@ declare class NodeDurableHost extends NodeDurableHost_base {
218
268
  } ? import("@effect-agent/thread").DurableWorkerRequirements<{
219
269
  readonly definition: D;
220
270
  readonly model: M;
221
- }> : never : never : never, import("effect/Scope").Scope>, Crypto.Crypto>>;
271
+ }> : never : never : never, import("effect/Scope").Scope>, import("@effect-agent/thread").DurableRuntimeConfig | import("@effect-agent/thread").ScheduleStore | import("@effect-agent/thread").SubmissionLedger | import("@effect-agent/thread").ThreadStore | import("@effect-agent/thread").WakeScheduler>, import("@effect-agent/thread").DurableRuntimeFailpoint | NodeWakeSchedulerConfig | import("@effect-agent/thread").ToolReconciler>, Crypto.Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite").SqliteStorageConfig | import("@effect-agent/storage-sqlite").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("@effect-agent/engine").RunContextPreparation | import("@effect-agent/engine").RunToolAuthorization>>;
222
272
  /**
223
- * Host gates over an assembled `NodeDurableRuntime` stack. Bindings must carry the exact
224
- * digests stored by submitters. Omission registers no Agents, so resolved work fails closed.
273
+ * Host gates over an assembled `NodeDurableAgentRuntime` stack. The runtime Layer owns
274
+ * executable registrations; omission registers no Agents, so resolved work fails closed.
225
275
  */
226
- static readonly layer: (bindings?: ReadonlyArray<ResolvedBinding>) => Layer.Layer<NodeDurableHost, DurableWorkerFailure, DurableAgentRuntime | NodeDurableRuntimeConfig>;
227
- /** The complete DN host: `NodeDurableRuntime.layer(options)` plus the host lifecycle gates. */
228
- static layerStack<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(options: NodeDurableRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements> & {
276
+ static readonly layer: Layer.Layer<NodeDurableHost, DurableWorkerFailure, DurableAgentRuntime | NodeDurableAgentRuntimeConfig>;
277
+ /** The complete DN host: `NodeDurableAgentRuntime.layer(options)` plus the host lifecycle gates. */
278
+ static layerStack<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements> & {
229
279
  readonly bindings?: ReadonlyArray<ResolvedBinding>;
230
- }): Layer.Layer<NodeDurableHost | NodeDurableRuntimeServices, DurableWorkerFailure | NodeDurableRuntimeInitializationError | ContextError | AuthorizationError, Exclude<ContextRequirements | AuthorizationRequirements, Crypto.Crypto>>;
280
+ }): Layer.Layer<NodeDurableHost | NodeDurableAgentRuntimeServices, DurableWorkerFailure | NodeDurableAgentRuntimeInitializationError | ContextError | AuthorizationError, Exclude<ContextRequirements | AuthorizationRequirements, Crypto.Crypto>>;
231
281
  }
232
282
  //#endregion
233
283
  //#region src/scheduling.d.ts
@@ -259,25 +309,5 @@ declare class NodeSubscriptions {
259
309
  static layer(options?: NodeSubscriptionsOptions): Layer.Layer<Subscriptions | SubscriptionIntake, SubscriptionError, NodeDurableHost | SubscriptionStore | SubscriptionAuthorizer | EventSources | SubscriptionInputBindings>;
260
310
  }
261
311
  //#endregion
262
- //#region src/wake-scheduler.d.ts
263
- declare const NodeWakeSchedulerConfig_base: Context.ServiceClass<NodeWakeSchedulerConfig, "@effect-agent/platform-node/NodeWakeSchedulerConfig", {
264
- /** Interval between ledger scans that re-emit every nonterminal Thread lane. */
265
- readonly scanInterval: Duration.Duration;
266
- }>;
267
- /** Cadence authority for the Node wake scheduler's ledger-scan fallback loop. */
268
- declare class NodeWakeSchedulerConfig extends NodeWakeSchedulerConfig_base {
269
- static layer(options: {
270
- readonly scanInterval: Duration.Duration;
271
- }): Layer.Layer<NodeWakeSchedulerConfig>;
272
- }
273
- /**
274
- * In-process Node `WakeScheduler`: `notify` publishes to a bounded sliding PubSub for prompt
275
- * same-process wakeups, and every `wakes` subscription additionally runs a periodic
276
- * `SubmissionLedger.scanNonterminal` fallback so a dropped, coalesced, or never-sent notification
277
- * can never strand accepted work (persistence §14). Delivery may duplicate; consumers already
278
- * treat wakes as pure liveness hints.
279
- */
280
- declare const nodeWakeSchedulerLayer: Layer.Layer<WakeScheduler, never, SubmissionLedger | NodeWakeSchedulerConfig>;
281
- //#endregion
282
- export { AdmissionClosed, NodeDurableHost, NodeDurableRuntime, NodeDurableRuntimeConfig, NodeDurableRuntimeConfigValue, NodeDurableRuntimeInitializationError, NodeDurableRuntimeOptions, NodeDurableRuntimeServices, NodePlatformConfigError, NodeScheduling, NodeSchedulingOptions, NodeSubscriptions, NodeSubscriptionsOptions, NodeWakeSchedulerConfig, nodePreparedInputAdmissionLayer, nodeScheduleWakeLayer, nodeScheduledInputAdmissionLayer, nodeWakeSchedulerLayer, ownershipDrainLayer };
312
+ export { AdmissionClosed, NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig, NodeDurableAgentRuntimeConfigValue, NodeDurableAgentRuntimeInitializationError, NodeDurableAgentRuntimeOptions, NodeDurableAgentRuntimeServices, NodeDurableHost, NodePlatformConfigError, NodeScheduling, NodeSchedulingOptions, NodeSubscriptions, NodeSubscriptionsOptions, NodeWakeSchedulerConfig, nodePreparedInputAdmissionLayer, nodeScheduleWakeLayer, nodeScheduledInputAdmissionLayer, nodeWakeSchedulerLayer, ownershipDrainLayer };
283
313
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { DEFAULT_OWNERSHIP_LEASE_DURATION, DeploymentId, DurableAgentRuntime, DurableRuntimeConfig, DurableRuntimeFailpoint, PersistedJson, PreparedInputAdmission, ProducerId, ReleaseOwnershipRequest, ScheduleDriver, ScheduleStorageError, ScheduleStore, ScheduleWake, ScheduledInputAdmission, ScheduledInputRetryable, Scheduling, SubmissionLedger, SubscriptionDriver, SubscriptionIntake, SubscriptionStore, Subscriptions, ToolReconciler, WakeScheduler, compileRegistrations, defaultSchedulingLimits, defaultSubscriptionLimits, makeWakeSubscriptionHub } from "@effect-agent/thread";
2
- import { NodeCrypto } from "@effect/platform-node";
1
+ import { DEFAULT_OWNERSHIP_LEASE_DURATION, DeploymentId, DurableAgentRuntime, DurableRuntimeConfig, DurableRuntimeFailpoint, PersistedJson, PreparedInputAdmission, ProducerId, ReleaseOwnershipRequest, ScheduleDriver, ScheduleStorageError, ScheduleStore, ScheduleWake, ScheduledInputAdmission, ScheduledInputRetryable, Scheduling, SubmissionLedger, SubscriptionDriver, SubscriptionIntake, SubscriptionStore, Subscriptions, ToolReconciler, WakeScheduler, defaultSchedulingLimits, defaultSubscriptionLimits, makeWakeSubscriptionHub } from "@effect-agent/thread";
3
2
  import { Cause, Context, Duration, Effect, Exit, Layer, Option, PubSub, Ref, Result, Schema, Stream } from "effect";
4
3
  import { CurrentToolFailureObserver, RunContextPreparationPassthrough, RunToolAuthorization, toolFailureObserverLayer } from "@effect-agent/engine";
5
4
  import { SqliteStorageConfig, SqliteStorageConfigValue, scheduleStoreLayer, storageFailpointLayer, submissionLedgerLayer, threadStoreLayer } from "@effect-agent/storage-sqlite";
5
+ import { NodeCrypto } from "@effect/platform-node";
6
6
  import { SqliteClient } from "@effect/sql-sqlite-node";
7
7
  //#region src/wake-scheduler.ts
8
8
  /**
@@ -67,7 +67,7 @@ var NodePlatformConfigError = class extends Schema.TaggedError()("NodePlatformCo
67
67
  * construction, exposed as a typed service). Every cadence is in milliseconds and every bound is
68
68
  * finite; `workerConcurrency` caps how many worker loops `NodeDurableHost.runWorkers` drives.
69
69
  */
70
- var NodeDurableRuntimeConfigValue = class extends Schema.Class("@effect-agent/platform-node/NodeDurableRuntimeConfigValue")({
70
+ var NodeDurableAgentRuntimeConfigValue = class extends Schema.Class("@effect-agent/platform-node/NodeDurableAgentRuntimeConfigValue")({
71
71
  /** SQLite database file backing BOTH the Thread Log and the Submission Ledger. */
72
72
  filename: Schema.NonEmptyString,
73
73
  deploymentId: DeploymentId,
@@ -92,8 +92,8 @@ var NodeDurableRuntimeConfigValue = class extends Schema.Class("@effect-agent/pl
92
92
  verifyOnOpen: Schema.Boolean
93
93
  }) {};
94
94
  /** Explicit configuration authority for the assembled Node durable runtime. */
95
- var NodeDurableRuntimeConfig = class extends Context.Service()("@effect-agent/platform-node/NodeDurableRuntimeConfig") {};
96
- const decodeConfigValue = Schema.decodeUnknownEffect(NodeDurableRuntimeConfigValue);
95
+ var NodeDurableAgentRuntimeConfig = class extends Context.Service()("@effect-agent/platform-node/NodeDurableAgentRuntimeConfig") {};
96
+ const decodeConfigValue = Schema.decodeUnknownEffect(NodeDurableAgentRuntimeConfigValue);
97
97
  const configFromOptions = (options) => decodeConfigValue({
98
98
  filename: options.filename,
99
99
  deploymentId: options.deploymentId,
@@ -113,7 +113,7 @@ const configFromOptions = (options) => decodeConfigValue({
113
113
  })));
114
114
  /** SQLite storage configuration derived from the single validated Node configuration. */
115
115
  const sqliteStorageConfigLayer = Layer.effect(SqliteStorageConfig)(Effect.gen(function* () {
116
- const config = yield* NodeDurableRuntimeConfig;
116
+ const config = yield* NodeDurableAgentRuntimeConfig;
117
117
  return SqliteStorageConfigValue.make({
118
118
  observationPollInterval: config.observationPollInterval,
119
119
  busyTimeout: config.busyTimeout,
@@ -123,7 +123,7 @@ const sqliteStorageConfigLayer = Layer.effect(SqliteStorageConfig)(Effect.gen(fu
123
123
  }));
124
124
  /** Thread coordinator configuration derived from the single validated Node configuration. */
125
125
  const durableRuntimeConfigLayer = (estimateCostMicrousd) => Layer.effect(DurableRuntimeConfig)(Effect.gen(function* () {
126
- const config = yield* NodeDurableRuntimeConfig;
126
+ const config = yield* NodeDurableAgentRuntimeConfig;
127
127
  return DurableRuntimeConfig.make({
128
128
  deploymentId: config.deploymentId,
129
129
  producerId: config.producerId,
@@ -135,7 +135,7 @@ const durableRuntimeConfigLayer = (estimateCostMicrousd) => Layer.effect(Durable
135
135
  }));
136
136
  /** Wake fallback-scan cadence derived from the single validated Node configuration. */
137
137
  const wakeSchedulerConfigLayer = Layer.effect(NodeWakeSchedulerConfig)(Effect.gen(function* () {
138
- const config = yield* NodeDurableRuntimeConfig;
138
+ const config = yield* NodeDurableAgentRuntimeConfig;
139
139
  return { scanInterval: Duration.millis(config.wakeScanInterval) };
140
140
  }));
141
141
  const releaseTrackedOwnership = (ledger, registry) => Effect.gen(function* () {
@@ -206,15 +206,26 @@ const ownershipDrainLayer = Layer.effect(SubmissionLedger)(Effect.gen(function*
206
206
  * verified during construction: an incompatible database file fails the Layer with
207
207
  * `SqliteStorageCompatibilityError` before anything is mutated (DEPLOY-008).
208
208
  */
209
- var NodeDurableRuntime = class {
209
+ var NodeDurableAgentRuntime = class NodeDurableAgentRuntime {
210
210
  /** Validated configuration Layer; fails typed when the supplied options are out of bounds. */
211
211
  static configLayer(options) {
212
- return Layer.effect(NodeDurableRuntimeConfig)(configFromOptions(options));
212
+ return Layer.effect(NodeDurableAgentRuntimeConfig)(configFromOptions(options));
213
213
  }
214
214
  /** The full DN runtime stack over one SQLite file. */
215
215
  static layer(options) {
216
+ return NodeDurableAgentRuntime.assemble(DurableAgentRuntime.layerWithServices, options);
217
+ }
218
+ /** Own typed executable registrations for every worker using this Node runtime. */
219
+ static layerRegistered(registrations, options) {
220
+ return NodeDurableAgentRuntime.assemble(DurableAgentRuntime.layerRegistered(registrations), options);
221
+ }
222
+ /** Construct from registrations already resolved within the enclosing application Scope. */
223
+ static layerWithBindings(bindings, options) {
224
+ return NodeDurableAgentRuntime.assemble(DurableAgentRuntime.layerWithBindings(bindings), options);
225
+ }
226
+ static assemble(runtimeLayer, options) {
216
227
  return Layer.unwrap(Effect.map(configFromOptions(options), (config) => {
217
- const nodeConfigLayer = Layer.succeed(NodeDurableRuntimeConfig)(config);
228
+ const nodeConfigLayer = Layer.succeed(NodeDurableAgentRuntimeConfig)(config);
218
229
  const infrastructure = Layer.mergeAll(sqliteStorageConfigLayer, storageFailpointLayer({
219
230
  filename: config.filename,
220
231
  failpoint: options.storageFailpoint
@@ -223,7 +234,7 @@ var NodeDurableRuntime = class {
223
234
  const reconcilerLayer = options.toolReconciler ?? ToolReconciler.uncertain;
224
235
  const observerLayer = options.toolFailureObserver === void 0 ? Layer.succeed(CurrentToolFailureObserver)(void 0) : toolFailureObserverLayer(options.toolFailureObserver);
225
236
  const ports = Layer.mergeAll(threadStoreLayer, scheduleStoreLayer, nodeWakeSchedulerLayer.pipe(Layer.provideMerge(ownershipDrainLayer.pipe(Layer.provide(submissionLedgerLayer)))));
226
- return DurableAgentRuntime.layerWithServices.pipe(Layer.provideMerge(Layer.mergeAll(ports, durableRuntimeConfigLayer(options.estimateCostMicrousd))), Layer.provide(Layer.mergeAll(wakeSchedulerConfigLayer, runtimeFailpointLayer, reconcilerLayer, observerLayer)), Layer.provideMerge(infrastructure), Layer.provideMerge(nodeConfigLayer), Layer.provide(Layer.mergeAll(options.runContext ?? RunContextPreparationPassthrough, options.toolAuthorization ?? RunToolAuthorization.allowAll).pipe(Layer.provide(NodeCrypto.layer))));
237
+ return runtimeLayer.pipe(Layer.provideMerge(Layer.mergeAll(ports, durableRuntimeConfigLayer(options.estimateCostMicrousd))), Layer.provide(Layer.mergeAll(wakeSchedulerConfigLayer, runtimeFailpointLayer, reconcilerLayer, observerLayer)), Layer.provideMerge(infrastructure), Layer.provideMerge(nodeConfigLayer), Layer.provide(Layer.mergeAll(options.runContext ?? RunContextPreparationPassthrough, options.toolAuthorization ?? RunToolAuthorization.allowAll).pipe(Layer.provide(NodeCrypto.layer))));
227
238
  }));
228
239
  }
229
240
  };
@@ -234,9 +245,9 @@ var NodeDurableRuntime = class {
234
245
  * Accepted work is unaffected — only NEW admissions are refused.
235
246
  */
236
247
  var AdmissionClosed = class extends Schema.TaggedError()("AdmissionClosed", { message: Schema.String }) {};
237
- const makeHost = (bindings) => Effect.gen(function* () {
248
+ const makeHost = Effect.gen(function* () {
238
249
  const runtime = yield* DurableAgentRuntime;
239
- const config = yield* NodeDurableRuntimeConfig;
250
+ const config = yield* NodeDurableAgentRuntimeConfig;
240
251
  const startupRecovery = yield* runtime.runRecovery;
241
252
  const admission = yield* Ref.make(true);
242
253
  yield* Effect.addFinalizer(() => Ref.set(admission, false));
@@ -246,7 +257,7 @@ const makeHost = (bindings) => Effect.gen(function* () {
246
257
  concurrency: "unbounded",
247
258
  discard: true
248
259
  });
249
- const runResolvedWorkers = runWorkers(runtime.runResolvedWorker(bindings));
260
+ const runResolvedWorkers = runWorkers(runtime.runResolvedWorker);
250
261
  return NodeDurableHost.of({
251
262
  startupRecovery,
252
263
  admissionOpen: Ref.get(admission),
@@ -286,20 +297,17 @@ var NodeDurableHost = class NodeDurableHost extends Context.Service()("@effect-a
286
297
  * runs runResolvedWorkers; this constructor never starts a background worker.
287
298
  */
288
299
  static layerRegistered(registrations, options) {
289
- return Layer.unwrap(Effect.map(compileRegistrations(registrations), (bindings) => NodeDurableHost.layerStack({
290
- ...options,
291
- bindings
292
- }))).pipe(Layer.provide(NodeCrypto.layer));
300
+ return NodeDurableHost.layer.pipe(Layer.provideMerge(NodeDurableAgentRuntime.layerRegistered(registrations, options)));
293
301
  }
294
302
  /**
295
- * Host gates over an assembled `NodeDurableRuntime` stack. Bindings must carry the exact
296
- * digests stored by submitters. Omission registers no Agents, so resolved work fails closed.
303
+ * Host gates over an assembled `NodeDurableAgentRuntime` stack. The runtime Layer owns
304
+ * executable registrations; omission registers no Agents, so resolved work fails closed.
297
305
  */
298
- static layer = (bindings = []) => Layer.effect(NodeDurableHost)(makeHost(bindings));
299
- /** The complete DN host: `NodeDurableRuntime.layer(options)` plus the host lifecycle gates. */
306
+ static layer = Layer.effect(NodeDurableHost)(makeHost);
307
+ /** The complete DN host: `NodeDurableAgentRuntime.layer(options)` plus the host lifecycle gates. */
300
308
  static layerStack(options) {
301
309
  const { bindings = [], ...runtimeOptions } = options;
302
- return NodeDurableHost.layer(bindings).pipe(Layer.provideMerge(NodeDurableRuntime.layer(runtimeOptions)));
310
+ return NodeDurableHost.layer.pipe(Layer.provideMerge(NodeDurableAgentRuntime.layerWithBindings(bindings, runtimeOptions)));
303
311
  }
304
312
  };
305
313
  //#endregion
@@ -431,6 +439,6 @@ var NodeScheduling = class {
431
439
  }
432
440
  };
433
441
  //#endregion
434
- export { AdmissionClosed, NodeDurableHost, NodeDurableRuntime, NodeDurableRuntimeConfig, NodeDurableRuntimeConfigValue, NodePlatformConfigError, NodeScheduling, NodeSubscriptions, NodeWakeSchedulerConfig, nodePreparedInputAdmissionLayer, nodeScheduleWakeLayer, nodeScheduledInputAdmissionLayer, nodeWakeSchedulerLayer, ownershipDrainLayer };
442
+ export { AdmissionClosed, NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig, NodeDurableAgentRuntimeConfigValue, NodeDurableHost, NodePlatformConfigError, NodeScheduling, NodeSubscriptions, NodeWakeSchedulerConfig, nodePreparedInputAdmissionLayer, nodeScheduleWakeLayer, nodeScheduledInputAdmissionLayer, nodeWakeSchedulerLayer, ownershipDrainLayer };
435
443
 
436
444
  //# sourceMappingURL=index.mjs.map