@effect-agent/platform-node 0.1.0-beta.85 → 0.1.0-beta.86

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 (33) hide show
  1. package/dist/{NodeDurableAgentRuntime-eTlQCxvz.d.mts → NodeDurableAgentRuntime-Cs_E9W_9.d.mts} +31 -31
  2. package/dist/NodeDurableAgentRuntime.d.mts +1 -1
  3. package/dist/NodeDurableAgentRuntime.mjs +18 -18
  4. package/dist/NodeDurableAgentRuntime.mjs.map +1 -1
  5. package/dist/{NodeDurableHost-BMSajuQn.mjs → NodeDurableHost-CG2xAhfb.mjs} +12 -12
  6. package/dist/NodeDurableHost-CG2xAhfb.mjs.map +1 -0
  7. package/dist/NodeDurableHost.d.mts +44 -44
  8. package/dist/NodeDurableHost.mjs +1 -1
  9. package/dist/NodeScheduling.d.mts +2 -2
  10. package/dist/NodeScheduling.mjs +2 -2
  11. package/dist/NodeScheduling.mjs.map +1 -1
  12. package/dist/NodeSubscriptions.d.mts +6 -6
  13. package/dist/NodeSubscriptions.mjs +7 -7
  14. package/dist/NodeSubscriptions.mjs.map +1 -1
  15. package/dist/{NodeWakeScheduler-4ZeXYwPu.d.mts → NodeWakeScheduler-CCgm1t-G.d.mts} +3 -3
  16. package/dist/NodeWakeScheduler.d.mts +1 -1
  17. package/dist/NodeWakeScheduler.mjs +3 -3
  18. package/dist/NodeWakeScheduler.mjs.map +1 -1
  19. package/dist/NodeWorkflow.d.mts +1 -1
  20. package/dist/NodeWorkflow.mjs +1 -1
  21. package/dist/NodeWorkflow.mjs.map +1 -1
  22. package/dist/index.d.mts +2 -2
  23. package/dist/index.mjs +1 -1
  24. package/package.json +1 -1
  25. package/src/NodeDurableAgentRuntime.ts +29 -35
  26. package/src/NodeDurableHost.ts +12 -15
  27. package/src/NodeScheduling.ts +4 -8
  28. package/src/NodeSubscriptions.ts +8 -12
  29. package/src/NodeWakeScheduler.ts +3 -3
  30. package/src/NodeWorkflow.ts +1 -1
  31. package/src/internal/message-delivery.ts +2 -2
  32. package/src/internal/prepared-admission.ts +6 -6
  33. package/dist/NodeDurableHost-BMSajuQn.mjs.map +0 -1
@@ -1,19 +1,19 @@
1
- import { t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-4ZeXYwPu.mjs";
2
- import { RunContextPreparation, RunCostEstimator, RunToolAuthorization, RunToolFailureObserver } from "@effect-agent/engine/RunOptions";
3
- import { SqliteStorageConfig } from "@effect-agent/storage-sqlite/SqliteStorageConfig";
4
- import { SqliteStorageFailpoint, SqliteStorageFailpointHandler } from "@effect-agent/storage-sqlite/SqliteStorageFailpoint";
5
- import { SqliteStorageInitializationError } from "@effect-agent/storage-sqlite/SqliteThreadStore";
6
- import { AgentRegistration, ResolvedBinding } from "@effect-agent/thread/AgentRegistration";
7
- import { DurableAgentRuntime, DurableRuntimeConfig } from "@effect-agent/thread/DurableAgentRuntime";
8
- import { DurableRuntimeFailpoint, DurableRuntimeFailpointHandler } from "@effect-agent/thread/DurableFailpoint";
9
- import { MessageDeliveryError, MessageDeliveryStore } from "@effect-agent/thread/MessageDelivery";
10
- import { ScheduleStore } from "@effect-agent/thread/Schedule";
11
- import { SubmissionLedger } from "@effect-agent/thread/SubmissionLedger";
12
- import { ThreadStore } from "@effect-agent/thread/ThreadStore";
13
- import { ToolReconciler } from "@effect-agent/thread/ToolReconciler";
14
- import { WakeScheduler } from "@effect-agent/thread/WakeScheduler";
1
+ import { t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-CCgm1t-G.mjs";
2
+ import { SqliteStorageConfig } from "@effect-agent/storage-sqlite/sqlite-storage-config";
3
+ import { SqliteStorageFailpoint, SqliteStorageFailpointHandler } from "@effect-agent/storage-sqlite/sqlite-storage-failpoint";
4
+ import { SqliteStorageInitializationError } from "@effect-agent/storage-sqlite/sqlite-thread-store";
15
5
  import { SqliteClient } from "@effect/sql-sqlite-node";
16
6
  import { Context, Crypto, Layer, Schema } from "effect";
7
+ import { AgentRegistration, ResolvedBinding } from "effect-agent/agent-registration";
8
+ import { DurableAgentRuntime, DurableRuntimeConfig } from "effect-agent/durable-agent-runtime";
9
+ import { DurableRuntimeFailpoint, DurableRuntimeFailpointHandler } from "effect-agent/durable-failpoint";
10
+ import { MessageDeliveryError, MessageDeliveryStore } from "effect-agent/message-delivery";
11
+ import { RunContextPreparation, RunCostEstimator, RunToolAuthorization, RunToolFailureObserver } from "effect-agent/run-options";
12
+ import { ScheduleStore } from "effect-agent/schedule";
13
+ import { SubmissionLedger } from "effect-agent/submission-ledger";
14
+ import { ThreadStore } from "effect-agent/thread-store";
15
+ import { ToolReconciler } from "effect-agent/tool-reconciler";
16
+ import { WakeScheduler } from "effect-agent/wake-scheduler";
17
17
  import * as SqlClientService from "effect/unstable/sql/SqlClient";
18
18
  declare namespace NodeDurableAgentRuntime_d_exports {
19
19
  export { NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig, NodeDurableAgentRuntimeConfigValue, NodeDurableAgentRuntimeInitializationError, NodeDurableAgentRuntimeOptions, NodeDurableAgentRuntimeServices, NodePlatformConfigError, ownershipDrainLayer };
@@ -143,33 +143,33 @@ declare class NodeDurableAgentRuntime {
143
143
  /** The full DN runtime stack over one SQLite file. */
144
144
  static layer<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements, ReconcilerError, ReconcilerRequirements>): Layer.Layer<NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | SqliteStorageInitializationError, Exclude<AuthorizationRequirements, Crypto.Crypto> | Exclude<ContextRequirements, Crypto.Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, Crypto.Crypto | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, RunContextPreparation | RunToolAuthorization>>;
145
145
  /** Own typed executable registrations for every worker using this Node runtime. */
146
- 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<NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | import("@effect-agent/thread/Digest").DigestError | MessageDeliveryError | NodePlatformConfigError | SqliteStorageInitializationError, Exclude<AuthorizationRequirements, Crypto.Crypto> | Exclude<ContextRequirements, Crypto.Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, Crypto.Crypto | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, RunContextPreparation | RunToolAuthorization> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : 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("@effect-agent/thread/AgentRegistration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
147
- readonly agent: infer A extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding;
148
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<A> : T_3 extends {
149
- readonly agent: infer D extends import("@effect-agent/core/Agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core/Agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
150
- readonly instructions: import("@effect-agent/core/Agent").InstructionSource<never, unknown, unknown>;
151
- readonly inputPrompt?: import("@effect-agent/core/Agent").InputPromptSource<never, unknown, unknown> | undefined;
146
+ 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<NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | import("effect-agent/digest").DigestError | MessageDeliveryError | NodePlatformConfigError | SqliteStorageInitializationError, Exclude<AuthorizationRequirements, Crypto.Crypto> | Exclude<ContextRequirements, Crypto.Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, Crypto.Crypto | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, RunContextPreparation | RunToolAuthorization> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : 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("effect-agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
147
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
148
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
149
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
150
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
151
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
152
152
  };
153
- readonly model: infer M extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding["model"];
154
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<{
153
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
154
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
155
155
  readonly definition: D;
156
156
  readonly model: M;
157
157
  }> : never, Provides> : T_3 extends {
158
- readonly agent: infer A extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding;
159
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<A> : T_3 extends {
160
- readonly agent: infer D extends import("@effect-agent/core/Agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core/Agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
161
- readonly instructions: import("@effect-agent/core/Agent").InstructionSource<never, unknown, unknown>;
162
- readonly inputPrompt?: import("@effect-agent/core/Agent").InputPromptSource<never, unknown, unknown> | undefined;
158
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
159
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
160
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
161
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
162
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
163
163
  };
164
- readonly model: infer M extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding["model"];
165
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<{
164
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
165
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
166
166
  readonly definition: D;
167
167
  readonly model: M;
168
- }> : never : never : never) | ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] extends (infer T_5) ? T_5 extends T_3[keyof T_3 & "reporting"] ? T_5 extends readonly import("@effect-agent/engine/SubagentHost").WorkerReporting<unknown, unknown>[] ? [T_5[number]] extends [never] ? never : T_5[number] extends import("@effect-agent/engine/SubagentHost").WorkerReporting<unknown, infer R> ? Exclude<R, import("effect/Scope").Scope> : never : never : never : never : never) : never : never : never, import("effect/Scope").Scope>, DurableRuntimeConfig | MessageDeliveryStore | ScheduleStore | SubmissionLedger | ThreadStore | WakeScheduler>, DurableRuntimeFailpoint | NodeWakeSchedulerConfig | ToolReconciler>, Crypto.Crypto | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, RunContextPreparation | RunToolAuthorization>>;
168
+ }> : never : never : never) | ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] extends (infer T_5) ? T_5 extends T_3[keyof T_3 & "reporting"] ? T_5 extends readonly import("effect-agent/subagent-host").WorkerReporting<unknown, unknown>[] ? [T_5[number]] extends [never] ? never : T_5[number] extends import("effect-agent/subagent-host").WorkerReporting<unknown, infer R> ? Exclude<R, import("effect/Scope").Scope> : never : never : never : never : never) : never : never : never, import("effect/Scope").Scope>, DurableRuntimeConfig | MessageDeliveryStore | ScheduleStore | SubmissionLedger | ThreadStore | WakeScheduler>, DurableRuntimeFailpoint | NodeWakeSchedulerConfig | ToolReconciler>, Crypto.Crypto | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, RunContextPreparation | RunToolAuthorization>>;
169
169
  /** Construct from registrations already resolved within the enclosing application Scope. */
170
170
  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<NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | SqliteStorageInitializationError, Exclude<AuthorizationRequirements, Crypto.Crypto> | Exclude<ContextRequirements, Crypto.Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, Crypto.Crypto | SqlClientService.SqlClient | SqliteClient.SqliteClient | SqliteStorageConfig | SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, RunContextPreparation | RunToolAuthorization>>;
171
171
  private static assemble;
172
172
  }
173
173
  //#endregion
174
174
  export { NodeDurableAgentRuntimeOptions as a, NodePlatformConfigError as c, NodeDurableAgentRuntimeInitializationError as i, ownershipDrainLayer as l, NodeDurableAgentRuntimeConfig as n, NodeDurableAgentRuntimeServices as o, NodeDurableAgentRuntimeConfigValue as r, NodeDurableAgentRuntime_d_exports as s, NodeDurableAgentRuntime as t };
175
- //# sourceMappingURL=NodeDurableAgentRuntime-eTlQCxvz.d.mts.map
175
+ //# sourceMappingURL=NodeDurableAgentRuntime-Cs_E9W_9.d.mts.map
@@ -1,2 +1,2 @@
1
- import { a as NodeDurableAgentRuntimeOptions, c as NodePlatformConfigError, i as NodeDurableAgentRuntimeInitializationError, l as ownershipDrainLayer, n as NodeDurableAgentRuntimeConfig, o as NodeDurableAgentRuntimeServices, r as NodeDurableAgentRuntimeConfigValue, t as NodeDurableAgentRuntime } from "./NodeDurableAgentRuntime-eTlQCxvz.mjs";
1
+ import { a as NodeDurableAgentRuntimeOptions, c as NodePlatformConfigError, i as NodeDurableAgentRuntimeInitializationError, l as ownershipDrainLayer, n as NodeDurableAgentRuntimeConfig, o as NodeDurableAgentRuntimeServices, r as NodeDurableAgentRuntimeConfigValue, t as NodeDurableAgentRuntime } from "./NodeDurableAgentRuntime-Cs_E9W_9.mjs";
2
2
  export { NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig, NodeDurableAgentRuntimeConfigValue, NodeDurableAgentRuntimeInitializationError, NodeDurableAgentRuntimeOptions, NodeDurableAgentRuntimeServices, NodePlatformConfigError, ownershipDrainLayer };
@@ -1,26 +1,26 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { NodeWakeSchedulerConfig, nodeWakeSchedulerLayer } from "./NodeWakeScheduler.mjs";
3
- import "@effect-agent/core/Identifiers";
4
- import { CurrentToolFailureObserver, RunContextPreparationPassthrough, RunToolAuthorization, toolFailureObserverLayer } from "@effect-agent/engine/RunOptions";
5
- import { messageDeliveryStoreLayer } from "@effect-agent/storage-sqlite/SqliteMessageDeliveryStore";
6
- import { scheduleStoreLayer } from "@effect-agent/storage-sqlite/SqliteScheduleStore";
7
- import { SqliteStorageConfig, SqliteStorageConfigValue } from "@effect-agent/storage-sqlite/SqliteStorageConfig";
8
- import "@effect-agent/storage-sqlite/SqliteStorageFailpoint";
9
- import { submissionLedgerLayer } from "@effect-agent/storage-sqlite/SqliteSubmissionLedger";
10
- import { storageFailpointLayer, threadStoreLayer } from "@effect-agent/storage-sqlite/SqliteThreadStore";
11
- import "@effect-agent/thread/AgentRegistration";
12
- import { DurableAgentRuntime, DurableRuntimeConfig } from "@effect-agent/thread/DurableAgentRuntime";
13
- import { DurableRuntimeFailpoint } from "@effect-agent/thread/DurableFailpoint";
14
- import "@effect-agent/thread/MessageDelivery";
15
- import { DeploymentId, ProducerId } from "@effect-agent/thread/Records";
16
- import "@effect-agent/thread/Schedule";
17
- import { DEFAULT_OWNERSHIP_LEASE_DURATION, ReleaseOwnershipRequest, SubmissionLedger } from "@effect-agent/thread/SubmissionLedger";
18
- import "@effect-agent/thread/ThreadStore";
19
- import { ToolReconciler } from "@effect-agent/thread/ToolReconciler";
20
- import "@effect-agent/thread/WakeScheduler";
3
+ import { messageDeliveryStoreLayer } from "@effect-agent/storage-sqlite/sqlite-message-delivery-store";
4
+ import { scheduleStoreLayer } from "@effect-agent/storage-sqlite/sqlite-schedule-store";
5
+ import { SqliteStorageConfig, SqliteStorageConfigValue } from "@effect-agent/storage-sqlite/sqlite-storage-config";
6
+ import "@effect-agent/storage-sqlite/sqlite-storage-failpoint";
7
+ import { submissionLedgerLayer } from "@effect-agent/storage-sqlite/sqlite-submission-ledger";
8
+ import { storageFailpointLayer, threadStoreLayer } from "@effect-agent/storage-sqlite/sqlite-thread-store";
21
9
  import { NodeCrypto } from "@effect/platform-node";
22
10
  import { SqliteClient } from "@effect/sql-sqlite-node";
23
11
  import { Context, Duration, Effect, Layer, Ref, Schema } from "effect";
12
+ import "effect-agent/agent-registration";
13
+ import { DurableAgentRuntime, DurableRuntimeConfig } from "effect-agent/durable-agent-runtime";
14
+ import { DurableRuntimeFailpoint } from "effect-agent/durable-failpoint";
15
+ import "effect-agent/identifiers";
16
+ import "effect-agent/message-delivery";
17
+ import { DeploymentId, ProducerId } from "effect-agent/records";
18
+ import { CurrentToolFailureObserver, RunContextPreparationPassthrough, RunToolAuthorization, toolFailureObserverLayer } from "effect-agent/run-options";
19
+ import "effect-agent/schedule";
20
+ import { DEFAULT_OWNERSHIP_LEASE_DURATION, ReleaseOwnershipRequest, SubmissionLedger } from "effect-agent/submission-ledger";
21
+ import "effect-agent/thread-store";
22
+ import { ToolReconciler } from "effect-agent/tool-reconciler";
23
+ import "effect-agent/wake-scheduler";
24
24
  //#region src/NodeDurableAgentRuntime.ts
25
25
  var NodeDurableAgentRuntime_exports = /* @__PURE__ */ __exportAll({
26
26
  NodeDurableAgentRuntime: () => NodeDurableAgentRuntime,
@@ -1 +1 @@
1
- {"version":3,"file":"NodeDurableAgentRuntime.mjs","names":[],"sources":["../src/NodeDurableAgentRuntime.ts"],"sourcesContent":["import { type SubmissionId } from \"@effect-agent/core/Identifiers\";\nimport {\n CurrentToolFailureObserver,\n RunContextPreparationPassthrough,\n RunToolAuthorization,\n toolFailureObserverLayer,\n type RunContextPreparation,\n type RunCostEstimator,\n type RunToolFailureObserver,\n} from \"@effect-agent/engine/RunOptions\";\nimport { messageDeliveryStoreLayer } from \"@effect-agent/storage-sqlite/SqliteMessageDeliveryStore\";\nimport { scheduleStoreLayer } from \"@effect-agent/storage-sqlite/SqliteScheduleStore\";\nimport {\n SqliteStorageConfig,\n SqliteStorageConfigValue,\n} from \"@effect-agent/storage-sqlite/SqliteStorageConfig\";\nimport {\n type SqliteStorageFailpoint,\n type SqliteStorageFailpointHandler,\n} from \"@effect-agent/storage-sqlite/SqliteStorageFailpoint\";\nimport { submissionLedgerLayer } from \"@effect-agent/storage-sqlite/SqliteSubmissionLedger\";\nimport {\n threadStoreLayer,\n storageFailpointLayer,\n type SqliteStorageInitializationError,\n} from \"@effect-agent/storage-sqlite/SqliteThreadStore\";\nimport {\n type AgentRegistration,\n type ResolvedBinding,\n} from \"@effect-agent/thread/AgentRegistration\";\nimport {\n DurableAgentRuntime,\n DurableRuntimeConfig,\n} from \"@effect-agent/thread/DurableAgentRuntime\";\nimport {\n DurableRuntimeFailpoint,\n type DurableRuntimeFailpointHandler,\n} from \"@effect-agent/thread/DurableFailpoint\";\nimport {\n type MessageDeliveryError,\n type MessageDeliveryStore,\n} from \"@effect-agent/thread/MessageDelivery\";\nimport { DeploymentId, ProducerId } from \"@effect-agent/thread/Records\";\nimport { type ScheduleStore } from \"@effect-agent/thread/Schedule\";\nimport {\n DEFAULT_OWNERSHIP_LEASE_DURATION,\n ReleaseOwnershipRequest,\n SubmissionLedger,\n type OwnershipToken,\n} from \"@effect-agent/thread/SubmissionLedger\";\nimport { type ThreadStore } from \"@effect-agent/thread/ThreadStore\";\nimport { ToolReconciler } from \"@effect-agent/thread/ToolReconciler\";\nimport { type WakeScheduler } from \"@effect-agent/thread/WakeScheduler\";\nimport { NodeCrypto } from \"@effect/platform-node\";\nimport { SqliteClient } from \"@effect/sql-sqlite-node\";\nimport { Context, type Crypto, Duration, Effect, Layer, Ref, Schema } from \"effect\";\nimport type * as SqlClientService from \"effect/unstable/sql/SqlClient\";\n\nimport { NodeWakeSchedulerConfig, nodeWakeSchedulerLayer } from \"./NodeWakeScheduler.ts\";\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 /** Submission ownership lease duration (D5); liveness hint only, epochs stay authoritative. */\n ownershipLeaseDuration: PositiveMillis,\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 /** Worker ownership-lease renewal cadence. */\n leaseRenewalInterval: 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 /** Canonical observation poll cadence of the SQLite store. */\n observationPollInterval: NonNegativeMillis,\n /** Opt-in full payload/digest-chain audit 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 /** Milliseconds; default `DEFAULT_OWNERSHIP_LEASE_DURATION` (30s, D5). */\n readonly ownershipLeaseDuration?: number | undefined;\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 10000. */\n readonly leaseRenewalInterval?: 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 /** 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 Crypto.\n */\n readonly toolReconciler?:\n | Layer.Layer<ToolReconciler, ReconcilerError, ReconcilerRequirements | Crypto.Crypto>\n | undefined;\n /** Host prompt preparation, acquired once with the runtime; default pass-through. */\n readonly runContext?:\n | Layer.Layer<RunContextPreparation, ContextError, ContextRequirements | Crypto.Crypto>\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 Crypto to these extension Layers.\n */\n readonly toolAuthorization?:\n | Layer.Layer<\n RunToolAuthorization,\n AuthorizationError,\n AuthorizationRequirements | Crypto.Crypto\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 =\n | DurableAgentRuntime\n | SubmissionLedger\n | ThreadStore\n | ScheduleStore\n | MessageDeliveryStore\n | WakeScheduler\n | DurableRuntimeConfig\n | NodeDurableAgentRuntimeConfig\n | SqlClientService.SqlClient\n | SqliteStorageConfig\n | SqliteStorageFailpoint;\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 ownershipLeaseDuration:\n options.ownershipLeaseDuration ?? Duration.toMillis(DEFAULT_OWNERSHIP_LEASE_DURATION),\n workerConcurrency: options.workerConcurrency ?? 1,\n wakeScanInterval: options.wakeScanInterval ?? 1_000,\n settlementPollInterval: options.settlementPollInterval ?? 500,\n leaseRenewalInterval: options.leaseRenewalInterval ?? 10_000,\n abortPollInterval: options.abortPollInterval ?? 500,\n busyTimeout: options.busyTimeout ?? 5_000,\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 ownershipLeaseDuration: config.ownershipLeaseDuration,\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 leaseRenewalInterval: Duration.millis(config.leaseRenewalInterval),\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\nconst releaseTrackedOwnership = (\n ledger: SubmissionLedger[\"Service\"],\n registry: Ref.Ref<ReadonlyMap<SubmissionId, OwnershipToken>>,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n const tracked = yield* Ref.getAndSet(registry, new Map<SubmissionId, OwnershipToken>());\n\n for (const [submissionId, ownershipToken] of tracked) {\n yield* ledger\n .releaseOwnership(ReleaseOwnershipRequest.make({ submissionId, ownershipToken }))\n .pipe(\n Effect.catchTags({\n // A newer epoch already owns (or settled) the lane: nothing left to drain.\n OwnershipLost: () => Effect.void,\n // Drain is best-effort by design: the lease still expires and the durability protocol,\n // not graceful shutdown, provides correctness (DEPLOY-006).\n LedgerError: (error) =>\n Effect.logWarning(\"Ownership drain failed; the lease will expire instead\", error),\n }),\n );\n }\n });\n\n/**\n * Shutdown-drain decorator for a `SubmissionLedger` (deployment §6 step 6): every ownership\n * period granted through this Layer is tracked — claims start tracking, renewals follow token\n * rotation, releases and settlement finalizations stop it — and every ownership still held when\n * the Layer's Scope closes is released so another host can claim the lane immediately instead of\n * waiting for lease expiry. The drain is a liveness courtesy only; producer-epoch fencing remains\n * the correctness authority (DUR-006), and a forced kill simply falls back to lease expiry.\n */\nexport const ownershipDrainLayer: Layer.Layer<SubmissionLedger, never, SubmissionLedger> =\n Layer.effect(SubmissionLedger)(\n Effect.gen(function* () {\n const ledger = yield* SubmissionLedger;\n\n const registry = yield* Ref.make<ReadonlyMap<SubmissionId, OwnershipToken>>(\n new Map<SubmissionId, OwnershipToken>(),\n );\n\n const track = (submissionId: SubmissionId, ownershipToken: OwnershipToken) =>\n Ref.update(registry, (tracked) => new Map(tracked).set(submissionId, ownershipToken));\n\n const untrack = (submissionId: SubmissionId) =>\n Ref.update(registry, (tracked) => {\n const next = new Map(tracked);\n\n next.delete(submissionId);\n\n return next;\n });\n\n yield* Effect.addFinalizer(() => releaseTrackedOwnership(ledger, registry));\n\n return SubmissionLedger.of({\n capabilities: ledger.capabilities,\n admit: ledger.admit,\n markReady: ledger.markReady,\n lookup: ledger.lookup,\n // The S2 subagent ops forward untouched: none of them grants an ownership period, so\n // the drain has nothing to track for them (`suspend` below already stops tracking the\n // waitingForChild ownership period the moment it ends).\n resolveAdmission: ledger.resolveAdmission,\n recordChildSettled: ledger.recordChildSettled,\n reserveChildBudget: ledger.reserveChildBudget,\n attachChildToReservation: ledger.attachChildToReservation,\n beginChildBudgetRelease: ledger.beginChildBudgetRelease,\n releaseChildBudget: ledger.releaseChildBudget,\n claim: (request) =>\n ledger\n .claim(request)\n .pipe(\n Effect.tap((claimed) =>\n claimed._tag === \"Some\"\n ? track(claimed.value.submissionId, claimed.value.ownershipToken)\n : Effect.void,\n ),\n ),\n renewOwnership: (request) =>\n ledger.renewOwnership(request).pipe(\n Effect.tap((renewal) => track(request.submissionId, renewal.ownershipToken)),\n Effect.tapError((error) =>\n error._tag === \"OwnershipLost\" ? untrack(request.submissionId) : Effect.void,\n ),\n ),\n releaseOwnership: (request) =>\n ledger.releaseOwnership(request).pipe(\n Effect.tap(() => untrack(request.submissionId)),\n Effect.tapError((error) =>\n error._tag === \"OwnershipLost\" ? untrack(request.submissionId) : Effect.void,\n ),\n ),\n markInputApplied: ledger.markInputApplied,\n reserveSettlement: ledger.reserveSettlement,\n finalizeSettlement: (request) =>\n ledger.finalizeSettlement(request).pipe(Effect.tap(() => untrack(request.submissionId))),\n requestAbort: ledger.requestAbort,\n readAbortIntent: ledger.readAbortIntent,\n claimJoining: ledger.claimJoining,\n markJoined: ledger.markJoined,\n revertJoining: ledger.revertJoining,\n // Suspension ends the ownership period by contract, so the drain stops tracking it.\n suspend: (request) =>\n ledger.suspend(request).pipe(Effect.tap(() => untrack(request.submissionId))),\n recordApprovalDecision: ledger.recordApprovalDecision,\n markUnknown: ledger.markUnknown,\n recordUnknownResolution: ledger.recordUnknownResolution,\n scanNonterminal: ledger.scanNonterminal,\n loadRecoverySnapshot: ledger.loadRecoverySnapshot,\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 (so claims fence the same producer epochs), wires\n * the Node wake scheduler with its ledger-scan fallback, exposes independent message delivery\n * storage, wraps the ledger with the shutdown\n * ownership drain, defaults 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 NodeDurableAgentRuntime.assemble(\n DurableAgentRuntime.layerRegistered(registrations),\n options,\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.map(configFromOptions(options), (config) => {\n const nodeConfigLayer = Layer.succeed(NodeDurableAgentRuntimeConfig)(config);\n\n const infrastructure = Layer.mergeAll(\n sqliteStorageConfigLayer,\n storageFailpointLayer({\n filename: config.filename,\n failpoint: options.storageFailpoint,\n }),\n SqliteClient.layer({ filename: config.filename }),\n NodeCrypto.layer,\n );\n\n const runtimeFailpointLayer =\n options.runtimeFailpoint === undefined\n ? DurableRuntimeFailpoint.layer\n : Layer.succeed(DurableRuntimeFailpoint)({ hit: options.runtimeFailpoint });\n\n const reconcilerLayer = options.toolReconciler ?? ToolReconciler.uncertain;\n\n const observerLayer =\n options.toolFailureObserver === undefined\n ? Layer.succeed(CurrentToolFailureObserver)(undefined)\n : toolFailureObserverLayer(options.toolFailureObserver);\n\n const ports = Layer.mergeAll(\n threadStoreLayer,\n scheduleStoreLayer,\n messageDeliveryStoreLayer(),\n nodeWakeSchedulerLayer.pipe(\n Layer.provideMerge(ownershipDrainLayer.pipe(Layer.provide(submissionLedgerLayer))),\n ),\n );\n\n return runtimeLayer.pipe(\n Layer.provideMerge(\n Layer.mergeAll(ports, durableRuntimeConfigLayer(options.estimateCostMicrousd)),\n ),\n Layer.provide(\n Layer.mergeAll(\n wakeSchedulerConfigLayer,\n runtimeFailpointLayer,\n reconcilerLayer,\n observerLayer,\n ),\n ),\n Layer.provideMerge(infrastructure),\n Layer.provideMerge(nodeConfigLayer),\n Layer.provide(\n Layer.mergeAll(\n options.runContext ?? RunContextPreparationPassthrough,\n options.toolAuthorization ?? RunToolAuthorization.allowAll,\n ).pipe(Layer.provide(NodeCrypto.layer)),\n ),\n );\n }),\n );\n\n const runtime: Layer.Layer<\n NodeDurableAgentRuntimeServices,\n Layer.Error<typeof assembled>,\n Layer.Services<typeof assembled>\n > = assembled;\n\n return runtime;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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uBAAuB,CAAC,CAAC,EAAE,KAAK,QAAQ,iBAAiB,CAAC;GAE9E,MAAM,kBAAkB,QAAQ,kBAAkB,eAAe;GAEjE,MAAM,gBACJ,QAAQ,wBAAwB,KAAA,IAC5B,MAAM,QAAQ,0BAA0B,CAAC,CAAC,KAAA,CAAS,IACnD,yBAAyB,QAAQ,mBAAmB;GAE1D,MAAM,QAAQ,MAAM,SAClB,kBACA,oBACA,0BAA0B,GAC1B,uBAAuB,KACrB,MAAM,aAAa,oBAAoB,KAAK,MAAM,QAAQ,qBAAqB,CAAC,CAAC,CACnF,CACF;GAEA,OAAO,aAAa,KAClB,MAAM,aACJ,MAAM,SAAS,OAAO,0BAA0B,QAAQ,oBAAoB,CAAC,CAC/E,GACA,MAAM,QACJ,MAAM,SACJ,0BACA,uBACA,iBACA,aACF,CACF,GACA,MAAM,aAAa,cAAc,GACjC,MAAM,aAAa,eAAe,GAClC,MAAM,QACJ,MAAM,SACJ,QAAQ,cAAc,kCACtB,QAAQ,qBAAqB,qBAAqB,QACpD,CAAC,CAAC,KAAK,MAAM,QAAQ,WAAW,KAAK,CAAC,CACxC,CACF;EACF,CAAC,CASU;CACf;AACF"}
1
+ {"version":3,"file":"NodeDurableAgentRuntime.mjs","names":[],"sources":["../src/NodeDurableAgentRuntime.ts"],"sourcesContent":["import { messageDeliveryStoreLayer } from \"@effect-agent/storage-sqlite/sqlite-message-delivery-store\";\nimport { scheduleStoreLayer } from \"@effect-agent/storage-sqlite/sqlite-schedule-store\";\nimport {\n SqliteStorageConfig,\n SqliteStorageConfigValue,\n} from \"@effect-agent/storage-sqlite/sqlite-storage-config\";\nimport {\n type SqliteStorageFailpoint,\n type SqliteStorageFailpointHandler,\n} from \"@effect-agent/storage-sqlite/sqlite-storage-failpoint\";\nimport { submissionLedgerLayer } from \"@effect-agent/storage-sqlite/sqlite-submission-ledger\";\nimport {\n threadStoreLayer,\n storageFailpointLayer,\n type SqliteStorageInitializationError,\n} from \"@effect-agent/storage-sqlite/sqlite-thread-store\";\nimport { NodeCrypto } from \"@effect/platform-node\";\nimport { SqliteClient } from \"@effect/sql-sqlite-node\";\nimport { Context, type Crypto, Duration, Effect, Layer, Ref, Schema } from \"effect\";\nimport { type AgentRegistration, type ResolvedBinding } from \"effect-agent/agent-registration\";\nimport { DurableAgentRuntime, DurableRuntimeConfig } from \"effect-agent/durable-agent-runtime\";\nimport {\n DurableRuntimeFailpoint,\n type DurableRuntimeFailpointHandler,\n} from \"effect-agent/durable-failpoint\";\nimport { type SubmissionId } from \"effect-agent/identifiers\";\nimport {\n type MessageDeliveryError,\n type MessageDeliveryStore,\n} from \"effect-agent/message-delivery\";\nimport { DeploymentId, ProducerId } from \"effect-agent/records\";\nimport {\n CurrentToolFailureObserver,\n RunContextPreparationPassthrough,\n RunToolAuthorization,\n toolFailureObserverLayer,\n type RunContextPreparation,\n type RunCostEstimator,\n type RunToolFailureObserver,\n} from \"effect-agent/run-options\";\nimport { type ScheduleStore } from \"effect-agent/schedule\";\nimport {\n DEFAULT_OWNERSHIP_LEASE_DURATION,\n ReleaseOwnershipRequest,\n SubmissionLedger,\n type OwnershipToken,\n} from \"effect-agent/submission-ledger\";\nimport { type ThreadStore } from \"effect-agent/thread-store\";\nimport { ToolReconciler } from \"effect-agent/tool-reconciler\";\nimport { type WakeScheduler } from \"effect-agent/wake-scheduler\";\nimport type * as SqlClientService from \"effect/unstable/sql/SqlClient\";\n\nimport { NodeWakeSchedulerConfig, nodeWakeSchedulerLayer } from \"./NodeWakeScheduler.ts\";\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 /** Submission ownership lease duration (D5); liveness hint only, epochs stay authoritative. */\n ownershipLeaseDuration: PositiveMillis,\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 /** Worker ownership-lease renewal cadence. */\n leaseRenewalInterval: 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 /** Canonical observation poll cadence of the SQLite store. */\n observationPollInterval: NonNegativeMillis,\n /** Opt-in full payload/digest-chain audit 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 /** Milliseconds; default `DEFAULT_OWNERSHIP_LEASE_DURATION` (30s, D5). */\n readonly ownershipLeaseDuration?: number | undefined;\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 10000. */\n readonly leaseRenewalInterval?: 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 /** 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 Crypto.\n */\n readonly toolReconciler?:\n | Layer.Layer<ToolReconciler, ReconcilerError, ReconcilerRequirements | Crypto.Crypto>\n | undefined;\n /** Host prompt preparation, acquired once with the runtime; default pass-through. */\n readonly runContext?:\n | Layer.Layer<RunContextPreparation, ContextError, ContextRequirements | Crypto.Crypto>\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 Crypto to these extension Layers.\n */\n readonly toolAuthorization?:\n | Layer.Layer<\n RunToolAuthorization,\n AuthorizationError,\n AuthorizationRequirements | Crypto.Crypto\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 =\n | DurableAgentRuntime\n | SubmissionLedger\n | ThreadStore\n | ScheduleStore\n | MessageDeliveryStore\n | WakeScheduler\n | DurableRuntimeConfig\n | NodeDurableAgentRuntimeConfig\n | SqlClientService.SqlClient\n | SqliteStorageConfig\n | SqliteStorageFailpoint;\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 ownershipLeaseDuration:\n options.ownershipLeaseDuration ?? Duration.toMillis(DEFAULT_OWNERSHIP_LEASE_DURATION),\n workerConcurrency: options.workerConcurrency ?? 1,\n wakeScanInterval: options.wakeScanInterval ?? 1_000,\n settlementPollInterval: options.settlementPollInterval ?? 500,\n leaseRenewalInterval: options.leaseRenewalInterval ?? 10_000,\n abortPollInterval: options.abortPollInterval ?? 500,\n busyTimeout: options.busyTimeout ?? 5_000,\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 ownershipLeaseDuration: config.ownershipLeaseDuration,\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 leaseRenewalInterval: Duration.millis(config.leaseRenewalInterval),\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\nconst releaseTrackedOwnership = (\n ledger: SubmissionLedger[\"Service\"],\n registry: Ref.Ref<ReadonlyMap<SubmissionId, OwnershipToken>>,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n const tracked = yield* Ref.getAndSet(registry, new Map<SubmissionId, OwnershipToken>());\n\n for (const [submissionId, ownershipToken] of tracked) {\n yield* ledger\n .releaseOwnership(ReleaseOwnershipRequest.make({ submissionId, ownershipToken }))\n .pipe(\n Effect.catchTags({\n // A newer epoch already owns (or settled) the lane: nothing left to drain.\n OwnershipLost: () => Effect.void,\n // Drain is best-effort by design: the lease still expires and the durability protocol,\n // not graceful shutdown, provides correctness (DEPLOY-006).\n LedgerError: (error) =>\n Effect.logWarning(\"Ownership drain failed; the lease will expire instead\", error),\n }),\n );\n }\n });\n\n/**\n * Shutdown-drain decorator for a `SubmissionLedger` (deployment §6 step 6): every ownership\n * period granted through this Layer is tracked — claims start tracking, renewals follow token\n * rotation, releases and settlement finalizations stop it — and every ownership still held when\n * the Layer's Scope closes is released so another host can claim the lane immediately instead of\n * waiting for lease expiry. The drain is a liveness courtesy only; producer-epoch fencing remains\n * the correctness authority (DUR-006), and a forced kill simply falls back to lease expiry.\n */\nexport const ownershipDrainLayer: Layer.Layer<SubmissionLedger, never, SubmissionLedger> =\n Layer.effect(SubmissionLedger)(\n Effect.gen(function* () {\n const ledger = yield* SubmissionLedger;\n\n const registry = yield* Ref.make<ReadonlyMap<SubmissionId, OwnershipToken>>(\n new Map<SubmissionId, OwnershipToken>(),\n );\n\n const track = (submissionId: SubmissionId, ownershipToken: OwnershipToken) =>\n Ref.update(registry, (tracked) => new Map(tracked).set(submissionId, ownershipToken));\n\n const untrack = (submissionId: SubmissionId) =>\n Ref.update(registry, (tracked) => {\n const next = new Map(tracked);\n\n next.delete(submissionId);\n\n return next;\n });\n\n yield* Effect.addFinalizer(() => releaseTrackedOwnership(ledger, registry));\n\n return SubmissionLedger.of({\n capabilities: ledger.capabilities,\n admit: ledger.admit,\n markReady: ledger.markReady,\n lookup: ledger.lookup,\n // The S2 subagent ops forward untouched: none of them grants an ownership period, so\n // the drain has nothing to track for them (`suspend` below already stops tracking the\n // waitingForChild ownership period the moment it ends).\n resolveAdmission: ledger.resolveAdmission,\n recordChildSettled: ledger.recordChildSettled,\n reserveChildBudget: ledger.reserveChildBudget,\n attachChildToReservation: ledger.attachChildToReservation,\n beginChildBudgetRelease: ledger.beginChildBudgetRelease,\n releaseChildBudget: ledger.releaseChildBudget,\n claim: (request) =>\n ledger\n .claim(request)\n .pipe(\n Effect.tap((claimed) =>\n claimed._tag === \"Some\"\n ? track(claimed.value.submissionId, claimed.value.ownershipToken)\n : Effect.void,\n ),\n ),\n renewOwnership: (request) =>\n ledger.renewOwnership(request).pipe(\n Effect.tap((renewal) => track(request.submissionId, renewal.ownershipToken)),\n Effect.tapError((error) =>\n error._tag === \"OwnershipLost\" ? untrack(request.submissionId) : Effect.void,\n ),\n ),\n releaseOwnership: (request) =>\n ledger.releaseOwnership(request).pipe(\n Effect.tap(() => untrack(request.submissionId)),\n Effect.tapError((error) =>\n error._tag === \"OwnershipLost\" ? untrack(request.submissionId) : Effect.void,\n ),\n ),\n markInputApplied: ledger.markInputApplied,\n reserveSettlement: ledger.reserveSettlement,\n finalizeSettlement: (request) =>\n ledger.finalizeSettlement(request).pipe(Effect.tap(() => untrack(request.submissionId))),\n requestAbort: ledger.requestAbort,\n readAbortIntent: ledger.readAbortIntent,\n claimJoining: ledger.claimJoining,\n markJoined: ledger.markJoined,\n revertJoining: ledger.revertJoining,\n // Suspension ends the ownership period by contract, so the drain stops tracking it.\n suspend: (request) =>\n ledger.suspend(request).pipe(Effect.tap(() => untrack(request.submissionId))),\n recordApprovalDecision: ledger.recordApprovalDecision,\n markUnknown: ledger.markUnknown,\n recordUnknownResolution: ledger.recordUnknownResolution,\n scanNonterminal: ledger.scanNonterminal,\n loadRecoverySnapshot: ledger.loadRecoverySnapshot,\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 (so claims fence the same producer epochs), wires\n * the Node wake scheduler with its ledger-scan fallback, exposes independent message delivery\n * storage, wraps the ledger with the shutdown\n * ownership drain, defaults 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 NodeDurableAgentRuntime.assemble(\n DurableAgentRuntime.layerRegistered(registrations),\n options,\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.map(configFromOptions(options), (config) => {\n const nodeConfigLayer = Layer.succeed(NodeDurableAgentRuntimeConfig)(config);\n\n const infrastructure = Layer.mergeAll(\n sqliteStorageConfigLayer,\n storageFailpointLayer({\n filename: config.filename,\n failpoint: options.storageFailpoint,\n }),\n SqliteClient.layer({ filename: config.filename }),\n NodeCrypto.layer,\n );\n\n const runtimeFailpointLayer =\n options.runtimeFailpoint === undefined\n ? DurableRuntimeFailpoint.layer\n : Layer.succeed(DurableRuntimeFailpoint)({ hit: options.runtimeFailpoint });\n\n const reconcilerLayer = options.toolReconciler ?? ToolReconciler.uncertain;\n\n const observerLayer =\n options.toolFailureObserver === undefined\n ? Layer.succeed(CurrentToolFailureObserver)(undefined)\n : toolFailureObserverLayer(options.toolFailureObserver);\n\n const ports = Layer.mergeAll(\n threadStoreLayer,\n scheduleStoreLayer,\n messageDeliveryStoreLayer(),\n nodeWakeSchedulerLayer.pipe(\n Layer.provideMerge(ownershipDrainLayer.pipe(Layer.provide(submissionLedgerLayer))),\n ),\n );\n\n return runtimeLayer.pipe(\n Layer.provideMerge(\n Layer.mergeAll(ports, durableRuntimeConfigLayer(options.estimateCostMicrousd)),\n ),\n Layer.provide(\n Layer.mergeAll(\n wakeSchedulerConfigLayer,\n runtimeFailpointLayer,\n reconcilerLayer,\n observerLayer,\n ),\n ),\n Layer.provideMerge(infrastructure),\n Layer.provideMerge(nodeConfigLayer),\n Layer.provide(\n Layer.mergeAll(\n options.runContext ?? RunContextPreparationPassthrough,\n options.toolAuthorization ?? RunToolAuthorization.allowAll,\n ).pipe(Layer.provide(NodeCrypto.layer)),\n ),\n );\n }),\n );\n\n const runtime: Layer.Layer<\n NodeDurableAgentRuntimeServices,\n Layer.Error<typeof assembled>,\n Layer.Services<typeof assembled>\n > = assembled;\n\n return runtime;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,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;CACd,YAAY;;CAEZ,wBAAwB;;CAExB,mBAAmB;;CAEnB,kBAAkB;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GACjC,MAAM,aAAa,eAAe,GAClC,MAAM,QACJ,MAAM,SACJ,QAAQ,cAAc,kCACtB,QAAQ,qBAAqB,qBAAqB,QACpD,CAAC,CAAC,KAAK,MAAM,QAAQ,WAAW,KAAK,CAAC,CACxC,CACF;EACF,CAAC,CASU;CACf;AACF"}
@@ -1,18 +1,18 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig } from "./NodeDurableAgentRuntime.mjs";
3
- import "@effect-agent/core/Identifiers";
4
- import "@effect-agent/thread/AgentRegistration";
5
- import { DurableAgentRuntime } from "@effect-agent/thread/DurableAgentRuntime";
6
- import { MessageDeliveryDriver, MessageDeliveryStore } from "@effect-agent/thread/MessageDelivery";
7
- import { PersistedJson } from "@effect-agent/thread/Records";
8
- import { ScheduleStorageError, ScheduledInputRefused, ScheduledInputRetryable } from "@effect-agent/thread/Schedule";
9
- import "@effect-agent/thread/SubmissionLedger";
10
- import "@effect-agent/thread/ThreadStore";
11
3
  import { NodeCrypto } from "@effect/platform-node";
12
4
  import { Cause, Clock, Context, Effect, Exit, Fiber, Layer, Option, Ref, Schema } from "effect";
13
- import "@effect-agent/thread/Admin";
14
- import "@effect-agent/thread/OperationAuthorizer";
15
- import { PreparedInputAdmission } from "@effect-agent/thread/PreparedInputAdmission";
5
+ import "effect-agent/agent-registration";
6
+ import { DurableAgentRuntime } from "effect-agent/durable-agent-runtime";
7
+ import "effect-agent/identifiers";
8
+ import { MessageDeliveryDriver, MessageDeliveryStore } from "effect-agent/message-delivery";
9
+ import { PersistedJson } from "effect-agent/records";
10
+ import { ScheduleStorageError, ScheduledInputRefused, ScheduledInputRetryable } from "effect-agent/schedule";
11
+ import "effect-agent/submission-ledger";
12
+ import "effect-agent/thread-store";
13
+ import "effect-agent/admin";
14
+ import "effect-agent/operation-authorizer";
15
+ import { PreparedInputAdmission } from "effect-agent/prepared-input-admission";
16
16
  //#region src/internal/message-delivery.ts
17
17
  const reportFailure = (cause) => Cause.hasInterruptsOnly(cause) ? Effect.interrupt : Effect.logWarning("Node message delivery pass failed").pipe(Effect.annotateLogs({ failureTag: Option.match(Cause.findErrorOption(cause), {
18
18
  onNone: () => "Defect",
@@ -191,4 +191,4 @@ const run = Effect.gen(function* () {
191
191
  //#endregion
192
192
  export { run as a, layer as i, NodeDurableHost as n, NodeAdmission as o, NodeDurableHost_exports as r, makeNodePreparedInputAdmission as s, AdmissionClosed as t };
193
193
 
194
- //# sourceMappingURL=NodeDurableHost-BMSajuQn.mjs.map
194
+ //# sourceMappingURL=NodeDurableHost-CG2xAhfb.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeDurableHost-CG2xAhfb.mjs","names":[],"sources":["../src/internal/message-delivery.ts","../src/internal/prepared-admission.ts","../src/NodeDurableHost.ts"],"sourcesContent":["import { Cause, Clock, Effect, Exit, Option } from \"effect\";\nimport {\n MessageDeliveryDriver,\n type MessageDeliveryFailure,\n MessageDeliveryStore,\n} from \"effect-agent/message-delivery\";\n\nconst reportFailure = (cause: Cause.Cause<MessageDeliveryFailure>): Effect.Effect<void> =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.logWarning(\"Node message delivery pass failed\").pipe(\n Effect.annotateLogs({\n failureTag: Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"Defect\",\n onSome: (failure) => failure._tag,\n }),\n }),\n );\n\n/** Caller-owned loop. Indexed scans repair absent hints even when both Threads have settled. */\nexport const runNodeMessageDeliveries = Effect.fn(\"NodeMessageDelivery.run\")(function* (\n scanInterval: number,\n) {\n const driver = yield* MessageDeliveryDriver;\n const store = yield* MessageDeliveryStore;\n\n while (true) {\n const pass = yield* driver.runDue().pipe(Effect.exit);\n\n if (Exit.isFailure(pass)) {\n yield* reportFailure(pass.cause);\n yield* Effect.sleep(scanInterval);\n continue;\n }\n\n const deadline = yield* store.nextDeadline().pipe(Effect.exit);\n\n if (Exit.isFailure(deadline)) {\n yield* reportFailure(deadline.cause);\n yield* Effect.sleep(scanInterval);\n continue;\n }\n\n const nowMillis = yield* Clock.currentTimeMillis;\n\n const delay =\n deadline.value === null\n ? scanInterval\n : Math.max(1, Math.min(deadline.value - nowMillis, scanInterval));\n\n yield* Effect.sleep(delay);\n }\n});\n","import { Context, Effect } from \"effect\";\nimport { type DurableSubmitAgent } from \"effect-agent/durable-agent-runtime\";\nimport { type AgentId } from \"effect-agent/identifiers\";\nimport { PreparedInputAdmission } from \"effect-agent/prepared-input-admission\";\nimport { PersistedJson } from \"effect-agent/records\";\nimport {\n ScheduledInputRetryable,\n ScheduledInputRefused,\n ScheduleStorageError,\n} from \"effect-agent/schedule\";\n\nimport { type NodeDurableHost } from \"../NodeDurableHost.ts\";\n\nconst passthroughSubmitAgent = (agentId: AgentId): DurableSubmitAgent<typeof PersistedJson> => ({\n definition: { id: agentId, input: PersistedJson },\n});\n\nconst ambiguous = (): ScheduledInputRetryable =>\n ScheduledInputRetryable.make({ reason: \"ambiguous\" });\n\nconst corrupt = (operation: string): ScheduleStorageError =>\n ScheduleStorageError.make({ operation, reason: \"corrupt\" });\n\n/** Host-owned admission gate, available while the host's worker pool is being assembled. */\nexport class NodeAdmission extends Context.Service<\n NodeAdmission,\n Pick<NodeDurableHost[\"Service\"], \"submit\" | \"submissionStatus\">\n>()(\"@effect-agent/platform-node/internal/NodeAdmission\") {}\n\n/** Acquire the gated source once; worker callers cannot replace its admission authority. */\nexport const makeNodePreparedInputAdmission = Effect.gen(function* () {\n const host = yield* NodeAdmission;\n\n return PreparedInputAdmission.of({\n submissionStatus: (receipt) =>\n host\n .submissionStatus(receipt)\n .pipe(Effect.mapError(() => ScheduledInputRetryable.make({ reason: \"storage\" }))),\n submit: (envelope) =>\n host\n .submit(passthroughSubmitAgent(envelope.agentId), envelope.input, {\n threadId: envelope.threadId,\n principal: envelope.deliveryPrincipal,\n idempotencyKey: envelope.admissionKey,\n ...(envelope.admissionGroup === undefined\n ? {}\n : { admissionGroup: envelope.admissionGroup }),\n ...(envelope.admissionFence === undefined\n ? {}\n : { admissionFence: envelope.admissionFence }),\n ...(envelope.workerAdmission === undefined\n ? {}\n : { workerAdmission: envelope.workerAdmission }),\n ...(envelope.messageAdmission === undefined\n ? {}\n : { messageAdmission: envelope.messageAdmission }),\n definitions: envelope.definitions,\n })\n .pipe(\n Effect.catchTags({\n AdmissionClosed: () =>\n Effect.fail(ScheduledInputRetryable.make({ reason: \"host-closed\" })),\n AgentInputError: () => Effect.fail(corrupt(\"prepared admission input\")),\n AdmissionConflict: () => Effect.fail(corrupt(\"prepared admission conflict\")),\n DigestError: () => Effect.fail(ambiguous()),\n AdmissionPolicyError: (error) =>\n error.reason === \"refused\"\n ? ScheduledInputRefused.make({ code: error.code })\n : ScheduledInputRetryable.make({\n reason: error.reason === \"occupied\" ? \"capacity\" : \"storage\",\n }),\n LedgerError: () => ScheduledInputRetryable.make({ reason: \"storage\" }),\n ThreadStoreError: () => Effect.fail(ambiguous()),\n ThreadNotMaterialized: () => Effect.fail(ambiguous()),\n AppendConflict: () => Effect.fail(ambiguous()),\n FenceRejected: () => Effect.fail(ambiguous()),\n DurableRuntimeFailpointError: () => Effect.fail(ambiguous()),\n }),\n ),\n });\n});\n","import { NodeCrypto } from \"@effect/platform-node\";\nimport { type Stream, Context, Effect, Fiber, Layer, Ref, Schema } from \"effect\";\nimport {\n type IntegrityReport,\n type ObligationReport,\n type ObligationThresholds,\n type RecoveryExplanation,\n type RetryCommand,\n} from \"effect-agent/admin\";\nimport {\n type AgentRegistration,\n type ResolvedBinding,\n type DurableBindingFailure,\n} from \"effect-agent/agent-registration\";\nimport {\n DurableAgentRuntime,\n type DurableAbortFailure,\n type DurableAwaitFailure,\n type DurableExplainFailure,\n type DurableObserveOptions,\n type DurableObligationFailure,\n type DurableRetryFailure,\n type DurableSubmitAgent,\n type DurableSubmitFailure,\n type DurableSubmitOptions,\n type DurableVerifyFailure,\n type DurableWorkerFailure,\n type Receipt,\n type RecoveryReport,\n} from \"effect-agent/durable-agent-runtime\";\nimport { type ThreadId, type SubmissionId } from \"effect-agent/identifiers\";\nimport {\n type MessageDeliveryStore,\n MessageDeliveryDriver,\n type MessageDeliveryError,\n} from \"effect-agent/message-delivery\";\nimport { type OperationDenied } from \"effect-agent/operation-authorizer\";\nimport { PreparedInputAdmission } from \"effect-agent/prepared-input-admission\";\nimport { type CanonicalRecordEnvelope } from \"effect-agent/records\";\nimport {\n type AbortCommand,\n type AbortIntent,\n type Settlement,\n} from \"effect-agent/submission-ledger\";\nimport { type ThreadNotMaterialized, type ThreadStoreError } from \"effect-agent/thread-store\";\n\nimport { runNodeMessageDeliveries } from \"./internal/message-delivery.ts\";\nimport { makeNodePreparedInputAdmission, NodeAdmission } from \"./internal/prepared-admission.ts\";\nimport {\n NodeDurableAgentRuntime,\n NodeDurableAgentRuntimeConfig,\n type NodeDurableAgentRuntimeOptions,\n} from \"./NodeDurableAgentRuntime.ts\";\n\n/**\n * Admission is not open on this host: it is shutting down (deployment §6 step 1, DEPLOY-005).\n * Accepted work is unaffected — only NEW admissions are refused.\n */\nexport class AdmissionClosed extends Schema.TaggedError<AdmissionClosed>()(\"AdmissionClosed\", {\n message: Schema.String,\n}) {}\n\nconst makeHost = Effect.fn(\"NodeDurableHost.make\")(function* (startWorkers: boolean) {\n const runtime = yield* DurableAgentRuntime;\n const config = yield* NodeDurableAgentRuntimeConfig;\n\n // Startup gate (deployment §5, plan §host): configuration decoding and storage compatibility\n // already gated this Layer's dependencies; the last gate before admission opens is recovering\n // EVERY nonterminal Submission. Work needing a live Agent Binding is reported `deferred` and\n // stays a visible obligation for `runWorkers`; lanes durably blocked on an Unknown Outcome are\n // reported `unknown` and wait for the authorized `resolveUnknown` path (DUR-017) — they consume\n // no worker permit while the settlement obligation stays owed.\n const startupRecovery = yield* runtime.runRecovery;\n\n const admission = yield* Ref.make(true);\n\n const requireAdmission: Effect.Effect<void, AdmissionClosed> = Ref.get(admission).pipe(\n Effect.flatMap((open) =>\n open\n ? Effect.void\n : Effect.fail(\n AdmissionClosed.make({ message: \"The host is shutting down; admission is closed.\" }),\n ),\n ),\n );\n\n const submit = <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ): Effect.Effect<\n Receipt,\n AdmissionClosed | DurableSubmitFailure,\n InputSchema[\"EncodingServices\"]\n > => requireAdmission.pipe(Effect.andThen(runtime.submit(agent, input, options)));\n\n const deliveryServices = yield* Effect.context<MessageDeliveryStore>();\n\n const deliveryContext = yield* Layer.build(\n MessageDeliveryDriver.layer({\n batchSize: 100,\n concurrency: Math.min(config.workerConcurrency, 32),\n }).pipe(\n Layer.provide(NodeCrypto.layer),\n Layer.provide(\n Layer.effect(PreparedInputAdmission, makeNodePreparedInputAdmission).pipe(\n Layer.provide(\n Layer.succeed(NodeAdmission, { submit, submissionStatus: runtime.submissionStatus }),\n ),\n ),\n ),\n ),\n );\n\n const runDeliveries = runNodeMessageDeliveries(config.wakeScanInterval).pipe(\n Effect.provide(Context.merge(deliveryServices, deliveryContext)),\n );\n\n const runWorkers = <A, E, R>(worker: Effect.Effect<A, E, R>): Effect.Effect<void, E, R> =>\n Effect.scoped(\n // Either side exiting stops and joins the other; delivery interruption cannot leave\n // an apparently healthy worker pool running without message recovery.\n Effect.raceFirst(\n Effect.forEach(\n Array.from({ length: config.workerConcurrency }, (_, index) => index),\n () => worker,\n { concurrency: \"unbounded\", discard: true },\n ),\n runDeliveries,\n ),\n );\n\n // S2 multi-binding pool: every claimed head resolves its exact registered Binding through\n // the host's exact registrations, so one bounded\n // pool serves parent and child lanes — the spec §12 smallest-pool suspension/wakeup proof\n // runs `workerConcurrency: 1` over exactly this loop.\n const runResolvedWorkers = runWorkers(runtime.runResolvedWorker);\n\n const run = startWorkers\n ? Fiber.join(\n yield* runResolvedWorkers.pipe(\n Effect.onExit(() => Ref.set(admission, false)),\n Effect.forkScoped,\n ),\n )\n : runResolvedWorkers;\n\n // Register after the worker fiber: close admission, interrupt/join workers, drain\n // runtime ownership, then close storage and captured application services.\n yield* Effect.addFinalizer(() => Ref.set(admission, false));\n\n return NodeDurableHost.of({\n startupRecovery,\n admissionOpen: Ref.get(admission),\n submit,\n awaitSettlement: runtime.awaitSettlement,\n submissionStatus: runtime.submissionStatus,\n observe: runtime.observe,\n abort: runtime.abort,\n explain: runtime.explain,\n explainThread: runtime.explainThread,\n verify: runtime.verify,\n retry: runtime.retry,\n wake: runtime.wake,\n scanObligations: runtime.scanObligations,\n runWorkers,\n run,\n runResolvedWorkers: run,\n });\n});\n\n/**\n * Operational host service. Prefer the module's `layer` and `run` for managed workers.\n * The static constructors on this class retain explicit, manual worker ownership.\n *\n * Startup gates run during Layer construction, so the service existing implies readiness:\n * configuration was schema-decoded, the SQLite file passed the exact-version compatibility check,\n * and every nonterminal Submission went through one full recovery pass BEFORE admission opened.\n * `startupRecovery` is the auditable evidence of that reconciliation pass.\n *\n * Shutdown runs in reverse Layer order when the owning Scope closes: `submit` starts refusing\n * with `AdmissionClosed` first, then the runtime Layer's ownership drain releases every claim\n * still held so another host can take over the lanes immediately, then the SQLite resources\n * close. Forced termination at any point stays safe — the durability protocol, not graceful\n * shutdown, provides correctness (DEPLOY-006).\n */\nexport class NodeDurableHost extends Context.Service<\n NodeDurableHost,\n {\n /**\n * The recovery decisions executed (or deferred) by this host's startup reconciliation.\n * Reports with the `unknown` disposition identify lanes blocked on Unknown Outcomes that\n * only the authorized DUR-017 resolution path can release.\n */\n readonly startupRecovery: ReadonlyArray<RecoveryReport>;\n /** Admission-role readiness (deployment §7): true until shutdown begins. */\n readonly admissionOpen: Effect.Effect<boolean>;\n /** Observe the managed worker pool, preserving its failure. Manual hosts start their pool here. */\n readonly run: Effect.Effect<void, DurableWorkerFailure | DurableBindingFailure>;\n /** `DurableAgentRuntime.submit` behind the host admission gate. */\n readonly submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) => Effect.Effect<\n Receipt,\n AdmissionClosed | DurableSubmitFailure,\n InputSchema[\"EncodingServices\"]\n >;\n readonly submissionStatus: DurableAgentRuntime[\"Service\"][\"submissionStatus\"];\n readonly awaitSettlement: (receipt: Receipt) => Effect.Effect<Settlement, DurableAwaitFailure>;\n readonly observe: (\n receipt: Receipt,\n options?: DurableObserveOptions,\n ) => Stream.Stream<\n CanonicalRecordEnvelope,\n ThreadStoreError | ThreadNotMaterialized | OperationDenied\n >;\n readonly abort: (command: AbortCommand) => Effect.Effect<AbortIntent, DurableAbortFailure>;\n /** `DurableAgentRuntime.explain` — read-only recovery explanation of one Submission (P7). */\n readonly explain: (\n submissionId: SubmissionId,\n ) => Effect.Effect<RecoveryExplanation, DurableExplainFailure>;\n /** `DurableAgentRuntime.explainThread` — explain every nonterminal lane member. */\n readonly explainThread: (\n threadId: ThreadId,\n ) => Effect.Effect<ReadonlyArray<RecoveryExplanation>, DurableExplainFailure>;\n /** `DurableAgentRuntime.verify` — read-only integrity checks, never a repair (P7). */\n readonly verify: (threadId: ThreadId) => Effect.Effect<IntegrityReport, DurableVerifyFailure>;\n /** `DurableAgentRuntime.retry` — audited single-Submission re-drive with typed refusals. */\n readonly retry: (command: RetryCommand) => Effect.Effect<RecoveryReport, DurableRetryFailure>;\n /** `DurableAgentRuntime.wake` — the documented operator liveness nudge for one lane. */\n readonly wake: (threadId: ThreadId) => Effect.Effect<void, OperationDenied>;\n /** `DurableAgentRuntime.scanObligations` — the scan-based DUR-017/OPS-001 report. */\n readonly scanObligations: (\n thresholds: ObligationThresholds,\n ) => Effect.Effect<ObligationReport, DurableObligationFailure>;\n /**\n * Run `workerConcurrency` copies of the given worker effect (typically\n * `DurableAgentRuntime.runWorker(agent)`) until the caller's Scope interrupts them. The\n * same Scope drives pending message admission and settlement observation independently\n * of Submission liveness. The host never forks daemon fibers.\n */\n readonly runWorkers: <A, E, R>(worker: Effect.Effect<A, E, R>) => Effect.Effect<void, E, R>;\n /**\n * Run `workerConcurrency` copies of `DurableAgentRuntime.runResolvedWorker` over the host's\n * registered Bindings (S2): every claimed head resolves its exact stored Binding before any\n * code runs (SUB-023), so one bounded pool serves parent and attached-child lanes.\n * Hosts built with the module-level `layer` instead join their existing pool.\n */\n readonly runResolvedWorkers: Effect.Effect<void, DurableWorkerFailure | DurableBindingFailure>;\n }\n>()(\"@effect-agent/platform-node/NodeDurableHost\") {\n /**\n * Compile typed registrations and acquire the complete host in one Layer Scope.\n * Node supplies Crypto; model, tool, instruction, and schema services remain required.\n * Startup recovery and shutdown gates are unchanged. Workers start only when the caller\n * runs runResolvedWorkers; this constructor never starts a background worker.\n */\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 NodeDurableHost.layer.pipe(\n Layer.provideMerge(NodeDurableAgentRuntime.layerRegistered(registrations, options)),\n );\n }\n\n /**\n * Host gates over an assembled `NodeDurableAgentRuntime` stack. The runtime Layer owns\n * executable registrations; omission registers no Agents, so resolved work fails closed.\n */\n static readonly layer: Layer.Layer<\n NodeDurableHost,\n DurableWorkerFailure | MessageDeliveryError,\n DurableAgentRuntime | NodeDurableAgentRuntimeConfig | MessageDeliveryStore\n > = Layer.effect(NodeDurableHost)(makeHost(false));\n\n /** The complete DN host: `NodeDurableAgentRuntime.layer(options)` plus the host lifecycle gates. */\n static layerStack<\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 > & { readonly bindings?: ReadonlyArray<ResolvedBinding> },\n ) {\n const { bindings = [], ...runtimeOptions } = options;\n\n return NodeDurableHost.layer.pipe(\n Layer.provideMerge(NodeDurableAgentRuntime.layerWithBindings(bindings, runtimeOptions)),\n );\n }\n}\n\n/**\n * Acquire a complete Node host and start one bounded, scoped worker pool after recovery.\n * Provide model, tool, instruction, and schema dependencies to this Layer. Reusing the Layer\n * shares the same pool. A worker failure closes admission; observe it with `run` at the process\n * boundary so the application exits and releases the host instead of remaining idle.\n */\nexport const layer = <\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 Layer.effect(NodeDurableHost)(makeHost(true)).pipe(\n Layer.provideMerge(NodeDurableAgentRuntime.layerRegistered(registrations, options)),\n );\n\n/**\n * Supervise the host's existing workers without starting another pool. Use with\n * `Effect.provide(HostLive)` and `NodeRuntime.runMain`; race it with a server Effect when\n * the same process also serves requests. Unlike `Layer.launch`, this observes worker failures.\n */\nexport const run = Effect.gen(function* () {\n const host = yield* NodeDurableHost;\n\n return yield* host.run;\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAM,iBAAiB,UACrB,MAAM,kBAAkB,KAAK,IACzB,OAAO,YACP,OAAO,WAAW,mCAAmC,CAAC,CAAC,KACrD,OAAO,aAAa,EAClB,YAAY,OAAO,MAAM,MAAM,gBAAgB,KAAK,GAAG;CACrD,cAAc;CACd,SAAS,YAAY,QAAQ;AAC/B,CAAC,EACH,CAAC,CACH;;AAGN,MAAa,2BAA2B,OAAO,GAAG,yBAAyB,CAAC,CAAC,WAC3E,cACA;CACA,MAA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AI,WAAW,KAAK,CAAC;CAE1D,OAAO,gBAAgB,GAAG;EACxB;EACA,eAAe,IAAI,IAAI,SAAS;EAChC;EACA,iBAAiB,QAAQ;EACzB,kBAAkB,QAAQ;EAC1B,SAAS,QAAQ;EACjB,OAAO,QAAQ;EACf,SAAS,QAAQ;EACjB,eAAe,QAAQ;EACvB,QAAQ,QAAQ;EAChB,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,iBAAiB,QAAQ;EACzB;EACA;EACA,oBAAoB;CACtB,CAAC;AACH,CAAC;;;;;;;;;;;;;;;;AAiBD,IAAa,kBAAb,MAAa,wBAAwB,QAAQ,QAkE3C,CAAC,CAAC,6CAA6C,CAAC,CAAC;;;;;;;CAOjD,OAAO,gBASL,eACA,SAQA;EACA,OAAO,gBAAgB,MAAM,KAC3B,MAAM,aAAa,wBAAwB,gBAAgB,eAAe,OAAO,CAAC,CACpF;CACF;;;;;CAMA,OAAgB,QAIZ,MAAM,OAAO,eAAe,CAAC,CAAC,SAAS,KAAK,CAAC;;CAGjD,OAAO,WAQL,SAQA;EACA,MAAM,EAAE,WAAW,CAAC,GAAG,GAAG,mBAAmB;EAE7C,OAAO,gBAAgB,MAAM,KAC3B,MAAM,aAAa,wBAAwB,kBAAkB,UAAU,cAAc,CAAC,CACxF;CACF;AACF;;;;;;;AAQA,MAAa,SASX,eACA,YASA,MAAM,OAAO,eAAe,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,KAC5C,MAAM,aAAa,wBAAwB,gBAAgB,eAAe,OAAO,CAAC,CACpF;;;;;;AAOF,MAAa,MAAM,OAAO,IAAI,aAAa;CAGzC,OAAO,QAAO,OAFM,gBAAA,CAED;AACrB,CAAC"}
@@ -1,15 +1,15 @@
1
- import { t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-4ZeXYwPu.mjs";
2
- import { a as NodeDurableAgentRuntimeOptions, c as NodePlatformConfigError, n as NodeDurableAgentRuntimeConfig, o as NodeDurableAgentRuntimeServices } from "./NodeDurableAgentRuntime-eTlQCxvz.mjs";
3
- import { SubmissionId, ThreadId } from "@effect-agent/core/Identifiers";
4
- import { AgentRegistration, DurableBindingFailure, ResolvedBinding } from "@effect-agent/thread/AgentRegistration";
5
- import { DurableAbortFailure, DurableAgentRuntime, DurableAwaitFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableRetryFailure, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, Receipt, RecoveryReport } from "@effect-agent/thread/DurableAgentRuntime";
6
- import { MessageDeliveryError, MessageDeliveryStore } from "@effect-agent/thread/MessageDelivery";
7
- import { CanonicalRecordEnvelope } from "@effect-agent/thread/Records";
8
- import { AbortCommand, AbortIntent, Settlement } from "@effect-agent/thread/SubmissionLedger";
9
- import { ThreadNotMaterialized, ThreadStoreError } from "@effect-agent/thread/ThreadStore";
1
+ import { t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-CCgm1t-G.mjs";
2
+ import { a as NodeDurableAgentRuntimeOptions, c as NodePlatformConfigError, n as NodeDurableAgentRuntimeConfig, o as NodeDurableAgentRuntimeServices } from "./NodeDurableAgentRuntime-Cs_E9W_9.mjs";
10
3
  import { Context, Effect, Layer, Schema, Stream } from "effect";
11
- import { IntegrityReport, ObligationReport, ObligationThresholds, RecoveryExplanation, RetryCommand } from "@effect-agent/thread/Admin";
12
- import { OperationDenied } from "@effect-agent/thread/OperationAuthorizer";
4
+ import { AgentRegistration, DurableBindingFailure, ResolvedBinding } from "effect-agent/agent-registration";
5
+ import { DurableAbortFailure, DurableAgentRuntime, DurableAwaitFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableRetryFailure, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, Receipt, RecoveryReport } from "effect-agent/durable-agent-runtime";
6
+ import { SubmissionId, ThreadId } from "effect-agent/identifiers";
7
+ import { MessageDeliveryError, MessageDeliveryStore } from "effect-agent/message-delivery";
8
+ import { CanonicalRecordEnvelope } from "effect-agent/records";
9
+ import { AbortCommand, AbortIntent, Settlement } from "effect-agent/submission-ledger";
10
+ import { ThreadNotMaterialized, ThreadStoreError } from "effect-agent/thread-store";
11
+ import { IntegrityReport, ObligationReport, ObligationThresholds, RecoveryExplanation, RetryCommand } from "effect-agent/admin";
12
+ import { OperationDenied } from "effect-agent/operation-authorizer";
13
13
  declare namespace NodeDurableHost_d_exports {
14
14
  export { AdmissionClosed, NodeDurableHost, layer, run };
15
15
  }
@@ -87,29 +87,29 @@ declare class NodeDurableHost extends NodeDurableHost_base {
87
87
  * Startup recovery and shutdown gates are unchanged. Workers start only when the caller
88
88
  * runs runResolvedWorkers; this constructor never starts a background worker.
89
89
  */
90
- 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<NodeDurableHost | NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | DurableWorkerFailure | import("@effect-agent/storage-sqlite/SqliteThreadStore").SqliteStorageInitializationError, Exclude<AuthorizationRequirements, import("effect/Crypto").Crypto> | Exclude<ContextRequirements, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/SqliteStorageConfig").SqliteStorageConfig | import("@effect-agent/storage-sqlite/SqliteStorageFailpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("@effect-agent/engine/RunOptions").RunContextPreparation | import("@effect-agent/engine/RunOptions").RunToolAuthorization> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : 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("@effect-agent/thread/AgentRegistration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
91
- readonly agent: infer A extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding;
92
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<A> : T_3 extends {
93
- readonly agent: infer D extends import("@effect-agent/core/Agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core/Agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
94
- readonly instructions: import("@effect-agent/core/Agent").InstructionSource<never, unknown, unknown>;
95
- readonly inputPrompt?: import("@effect-agent/core/Agent").InputPromptSource<never, unknown, unknown> | undefined;
90
+ 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<NodeDurableHost | NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | DurableWorkerFailure | import("@effect-agent/storage-sqlite/sqlite-thread-store").SqliteStorageInitializationError, Exclude<AuthorizationRequirements, import("effect/Crypto").Crypto> | Exclude<ContextRequirements, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/sqlite-storage-config").SqliteStorageConfig | import("@effect-agent/storage-sqlite/sqlite-storage-failpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("effect-agent/run-options").RunContextPreparation | import("effect-agent/run-options").RunToolAuthorization> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : 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("effect-agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
91
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
92
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
93
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
94
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
95
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
96
96
  };
97
- readonly model: infer M extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding["model"];
98
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<{
97
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
98
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
99
99
  readonly definition: D;
100
100
  readonly model: M;
101
101
  }> : never, Provides> : T_3 extends {
102
- readonly agent: infer A extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding;
103
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<A> : T_3 extends {
104
- readonly agent: infer D extends import("@effect-agent/core/Agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core/Agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
105
- readonly instructions: import("@effect-agent/core/Agent").InstructionSource<never, unknown, unknown>;
106
- readonly inputPrompt?: import("@effect-agent/core/Agent").InputPromptSource<never, unknown, unknown> | undefined;
102
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
103
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
104
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
105
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
106
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
107
107
  };
108
- readonly model: infer M extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding["model"];
109
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<{
108
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
109
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
110
110
  readonly definition: D;
111
111
  readonly model: M;
112
- }> : never : never : never) | ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] extends (infer T_5) ? T_5 extends T_3[keyof T_3 & "reporting"] ? T_5 extends readonly import("@effect-agent/engine/SubagentHost").WorkerReporting<unknown, unknown>[] ? [T_5[number]] extends [never] ? never : T_5[number] extends import("@effect-agent/engine/SubagentHost").WorkerReporting<unknown, infer R> ? Exclude<R, import("effect/Scope").Scope> : never : never : never : never : never) : never : never : never, import("effect/Scope").Scope>, import("@effect-agent/thread/DurableAgentRuntime").DurableRuntimeConfig | MessageDeliveryStore | import("@effect-agent/thread/Schedule").ScheduleStore | import("@effect-agent/thread/SubmissionLedger").SubmissionLedger | import("@effect-agent/thread/ThreadStore").ThreadStore | import("@effect-agent/thread/WakeScheduler").WakeScheduler>, import("@effect-agent/thread/DurableFailpoint").DurableRuntimeFailpoint | NodeWakeSchedulerConfig | import("@effect-agent/thread/ToolReconciler").ToolReconciler>, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/SqliteStorageConfig").SqliteStorageConfig | import("@effect-agent/storage-sqlite/SqliteStorageFailpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("@effect-agent/engine/RunOptions").RunContextPreparation | import("@effect-agent/engine/RunOptions").RunToolAuthorization>>;
112
+ }> : never : never : never) | ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] extends (infer T_5) ? T_5 extends T_3[keyof T_3 & "reporting"] ? T_5 extends readonly import("effect-agent/subagent-host").WorkerReporting<unknown, unknown>[] ? [T_5[number]] extends [never] ? never : T_5[number] extends import("effect-agent/subagent-host").WorkerReporting<unknown, infer R> ? Exclude<R, import("effect/Scope").Scope> : never : never : never : never : never) : never : never : never, import("effect/Scope").Scope>, import("effect-agent/durable-agent-runtime").DurableRuntimeConfig | MessageDeliveryStore | import("effect-agent/schedule").ScheduleStore | import("effect-agent/submission-ledger").SubmissionLedger | import("effect-agent/thread-store").ThreadStore | import("effect-agent/wake-scheduler").WakeScheduler>, import("effect-agent/durable-failpoint").DurableRuntimeFailpoint | NodeWakeSchedulerConfig | import("effect-agent/tool-reconciler").ToolReconciler>, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/sqlite-storage-config").SqliteStorageConfig | import("@effect-agent/storage-sqlite/sqlite-storage-failpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("effect-agent/run-options").RunContextPreparation | import("effect-agent/run-options").RunToolAuthorization>>;
113
113
  /**
114
114
  * Host gates over an assembled `NodeDurableAgentRuntime` stack. The runtime Layer owns
115
115
  * executable registrations; omission registers no Agents, so resolved work fails closed.
@@ -118,7 +118,7 @@ declare class NodeDurableHost extends NodeDurableHost_base {
118
118
  /** The complete DN host: `NodeDurableAgentRuntime.layer(options)` plus the host lifecycle gates. */
119
119
  static layerStack<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements, ReconcilerError, ReconcilerRequirements> & {
120
120
  readonly bindings?: ReadonlyArray<ResolvedBinding>;
121
- }): Layer.Layer<NodeDurableHost | NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | DurableWorkerFailure | import("@effect-agent/storage-sqlite/SqliteThreadStore").SqliteStorageInitializationError, Exclude<AuthorizationRequirements, import("effect/Crypto").Crypto> | Exclude<ContextRequirements, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/SqliteStorageConfig").SqliteStorageConfig | import("@effect-agent/storage-sqlite/SqliteStorageFailpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("@effect-agent/engine/RunOptions").RunContextPreparation | import("@effect-agent/engine/RunOptions").RunToolAuthorization>>;
121
+ }): Layer.Layer<NodeDurableHost | NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | DurableWorkerFailure | import("@effect-agent/storage-sqlite/sqlite-thread-store").SqliteStorageInitializationError, Exclude<AuthorizationRequirements, import("effect/Crypto").Crypto> | Exclude<ContextRequirements, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/sqlite-storage-config").SqliteStorageConfig | import("@effect-agent/storage-sqlite/sqlite-storage-failpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("effect-agent/run-options").RunContextPreparation | import("effect-agent/run-options").RunToolAuthorization>>;
122
122
  }
123
123
  /**
124
124
  * Acquire a complete Node host and start one bounded, scoped worker pool after recovery.
@@ -126,29 +126,29 @@ declare class NodeDurableHost extends NodeDurableHost_base {
126
126
  * shares the same pool. A worker failure closes admission; observe it with `run` at the process
127
127
  * boundary so the application exits and releases the host instead of remaining idle.
128
128
  */
129
- declare const layer: <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<NodeDurableHost | NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | DurableWorkerFailure | import("@effect-agent/storage-sqlite/SqliteThreadStore").SqliteStorageInitializationError, Exclude<AuthorizationRequirements, import("effect/Crypto").Crypto> | Exclude<ContextRequirements, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/SqliteStorageConfig").SqliteStorageConfig | import("@effect-agent/storage-sqlite/SqliteStorageFailpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("@effect-agent/engine/RunOptions").RunContextPreparation | import("@effect-agent/engine/RunOptions").RunToolAuthorization> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : 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("@effect-agent/thread/AgentRegistration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
130
- readonly agent: infer A extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding;
131
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<A> : T_3 extends {
132
- readonly agent: infer D extends import("@effect-agent/core/Agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core/Agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
133
- readonly instructions: import("@effect-agent/core/Agent").InstructionSource<never, unknown, unknown>;
134
- readonly inputPrompt?: import("@effect-agent/core/Agent").InputPromptSource<never, unknown, unknown> | undefined;
129
+ declare const layer: <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<NodeDurableHost | NodeDurableAgentRuntimeServices, AuthorizationError | ContextError | ReconcilerError | MessageDeliveryError | NodePlatformConfigError | DurableWorkerFailure | import("@effect-agent/storage-sqlite/sqlite-thread-store").SqliteStorageInitializationError, Exclude<AuthorizationRequirements, import("effect/Crypto").Crypto> | Exclude<ContextRequirements, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<ReconcilerRequirements, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/sqlite-storage-config").SqliteStorageConfig | import("@effect-agent/storage-sqlite/sqlite-storage-failpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("effect-agent/run-options").RunContextPreparation | import("effect-agent/run-options").RunToolAuthorization> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<[Entries[number]] extends [never] ? never : 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("effect-agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
130
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
131
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
132
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
133
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
134
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
135
135
  };
136
- readonly model: infer M extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding["model"];
137
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<{
136
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
137
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
138
138
  readonly definition: D;
139
139
  readonly model: M;
140
140
  }> : never, Provides> : T_3 extends {
141
- readonly agent: infer A extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding;
142
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<A> : T_3 extends {
143
- readonly agent: infer D extends import("@effect-agent/core/Agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("@effect-agent/core/Agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
144
- readonly instructions: import("@effect-agent/core/Agent").InstructionSource<never, unknown, unknown>;
145
- readonly inputPrompt?: import("@effect-agent/core/Agent").InputPromptSource<never, unknown, unknown> | undefined;
141
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
142
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
143
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
144
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
145
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
146
146
  };
147
- readonly model: infer M extends import("@effect-agent/thread/AgentRegistration").ExecutableAgentBinding["model"];
148
- } ? import("@effect-agent/thread/DurableAgentRuntime").DurableWorkerRequirements<{
147
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
148
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
149
149
  readonly definition: D;
150
150
  readonly model: M;
151
- }> : never : never : never) | ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] extends (infer T_5) ? T_5 extends T_3[keyof T_3 & "reporting"] ? T_5 extends readonly import("@effect-agent/engine/SubagentHost").WorkerReporting<unknown, unknown>[] ? [T_5[number]] extends [never] ? never : T_5[number] extends import("@effect-agent/engine/SubagentHost").WorkerReporting<unknown, infer R> ? Exclude<R, import("effect/Scope").Scope> : never : never : never : never : never) : never : never : never, import("effect/Scope").Scope>, import("@effect-agent/thread/DurableAgentRuntime").DurableRuntimeConfig | MessageDeliveryStore | import("@effect-agent/thread/Schedule").ScheduleStore | import("@effect-agent/thread/SubmissionLedger").SubmissionLedger | import("@effect-agent/thread/ThreadStore").ThreadStore | import("@effect-agent/thread/WakeScheduler").WakeScheduler>, import("@effect-agent/thread/DurableFailpoint").DurableRuntimeFailpoint | NodeWakeSchedulerConfig | import("@effect-agent/thread/ToolReconciler").ToolReconciler>, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/SqliteStorageConfig").SqliteStorageConfig | import("@effect-agent/storage-sqlite/SqliteStorageFailpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("@effect-agent/engine/RunOptions").RunContextPreparation | import("@effect-agent/engine/RunOptions").RunToolAuthorization>>;
151
+ }> : never : never : never) | ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] extends (infer T_5) ? T_5 extends T_3[keyof T_3 & "reporting"] ? T_5 extends readonly import("effect-agent/subagent-host").WorkerReporting<unknown, unknown>[] ? [T_5[number]] extends [never] ? never : T_5[number] extends import("effect-agent/subagent-host").WorkerReporting<unknown, infer R> ? Exclude<R, import("effect/Scope").Scope> : never : never : never : never : never) : never : never : never, import("effect/Scope").Scope>, import("effect-agent/durable-agent-runtime").DurableRuntimeConfig | MessageDeliveryStore | import("effect-agent/schedule").ScheduleStore | import("effect-agent/submission-ledger").SubmissionLedger | import("effect-agent/thread-store").ThreadStore | import("effect-agent/wake-scheduler").WakeScheduler>, import("effect-agent/durable-failpoint").DurableRuntimeFailpoint | NodeWakeSchedulerConfig | import("effect-agent/tool-reconciler").ToolReconciler>, import("effect/Crypto").Crypto | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect-agent/storage-sqlite/sqlite-storage-config").SqliteStorageConfig | import("@effect-agent/storage-sqlite/sqlite-storage-failpoint").SqliteStorageFailpoint>, NodeDurableAgentRuntimeConfig>, import("effect-agent/run-options").RunContextPreparation | import("effect-agent/run-options").RunToolAuthorization>>;
152
152
  /**
153
153
  * Supervise the host's existing workers without starting another pool. Use with
154
154
  * `Effect.provide(HostLive)` and `NodeRuntime.runMain`; race it with a server Effect when
@@ -1,2 +1,2 @@
1
- import { a as run, i as layer, n as NodeDurableHost, t as AdmissionClosed } from "./NodeDurableHost-BMSajuQn.mjs";
1
+ import { a as run, i as layer, n as NodeDurableHost, t as AdmissionClosed } from "./NodeDurableHost-CG2xAhfb.mjs";
2
2
  export { AdmissionClosed, NodeDurableHost, layer, run };