@effect-agent/platform-node 0.1.0-beta.113 → 0.1.0-beta.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{NodeDurableAgentRuntime-Cs_E9W_9.d.mts → NodeDurableAgentRuntime-PVzGBhyG.d.mts} +6 -6
- package/dist/NodeDurableAgentRuntime.d.mts +1 -1
- package/dist/NodeDurableAgentRuntime.mjs +1 -21
- package/dist/NodeDurableAgentRuntime.mjs.map +1 -1
- package/dist/NodeDurableHost.d.mts +11 -11
- package/dist/index.d.mts +1 -1
- package/package.json +1 -1
- package/src/NodeDurableAgentRuntime.ts +1 -24
package/dist/{NodeDurableAgentRuntime-Cs_E9W_9.d.mts → NodeDurableAgentRuntime-PVzGBhyG.d.mts}
RENAMED
|
@@ -143,9 +143,9 @@ 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/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
|
|
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_2) ? T_2 extends Entries[number] ? T_2 extends unknown ? ("attemptLayer" extends keyof T_2 ? T_2[keyof T_2 & "attemptLayer"] : undefined) extends (infer T_3) ? T_3 extends ("attemptLayer" extends keyof T_2 ? T_2[keyof T_2 & "attemptLayer"] : undefined) ? T_3 extends ((context: import("effect-agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_2 extends {
|
|
147
147
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
148
|
-
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> :
|
|
148
|
+
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_2 extends {
|
|
149
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
150
|
readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
|
|
151
151
|
readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
|
|
@@ -154,9 +154,9 @@ declare class NodeDurableAgentRuntime {
|
|
|
154
154
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
|
|
155
155
|
readonly definition: D;
|
|
156
156
|
readonly model: M;
|
|
157
|
-
}> : never, Provides> :
|
|
157
|
+
}> : never, Provides> : T_2 extends {
|
|
158
158
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
159
|
-
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> :
|
|
159
|
+
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_2 extends {
|
|
160
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
161
|
readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
|
|
162
162
|
readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
|
|
@@ -165,11 +165,11 @@ declare class NodeDurableAgentRuntime {
|
|
|
165
165
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
|
|
166
166
|
readonly definition: D;
|
|
167
167
|
readonly model: M;
|
|
168
|
-
}> : never : never : never
|
|
168
|
+
}> : 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-
|
|
175
|
+
//# sourceMappingURL=NodeDurableAgentRuntime-PVzGBhyG.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-
|
|
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-PVzGBhyG.mjs";
|
|
2
2
|
export { NodeDurableAgentRuntime, NodeDurableAgentRuntimeConfig, NodeDurableAgentRuntimeConfigValue, NodeDurableAgentRuntimeInitializationError, NodeDurableAgentRuntimeOptions, NodeDurableAgentRuntimeServices, NodePlatformConfigError, ownershipDrainLayer };
|
|
@@ -142,32 +142,12 @@ const ownershipDrainLayer = Layer.effect(SubmissionLedger)(Effect.gen(function*
|
|
|
142
142
|
});
|
|
143
143
|
yield* Effect.addFinalizer(() => releaseTrackedOwnership(ledger, registry));
|
|
144
144
|
return SubmissionLedger.of({
|
|
145
|
-
|
|
146
|
-
admit: ledger.admit,
|
|
147
|
-
markReady: ledger.markReady,
|
|
148
|
-
lookup: ledger.lookup,
|
|
149
|
-
resolveAdmission: ledger.resolveAdmission,
|
|
150
|
-
recordChildSettled: ledger.recordChildSettled,
|
|
151
|
-
reserveChildBudget: ledger.reserveChildBudget,
|
|
152
|
-
attachChildToReservation: ledger.attachChildToReservation,
|
|
153
|
-
beginChildBudgetRelease: ledger.beginChildBudgetRelease,
|
|
154
|
-
releaseChildBudget: ledger.releaseChildBudget,
|
|
145
|
+
...ledger,
|
|
155
146
|
claim: (request) => ledger.claim(request).pipe(Effect.tap((claimed) => claimed._tag === "Some" ? track(claimed.value.submissionId, claimed.value.ownershipToken) : Effect.void)),
|
|
156
147
|
renewOwnership: (request) => ledger.renewOwnership(request).pipe(Effect.tap((renewal) => track(request.submissionId, renewal.ownershipToken)), Effect.tapError((error) => error._tag === "OwnershipLost" ? untrack(request.submissionId) : Effect.void)),
|
|
157
148
|
releaseOwnership: (request) => ledger.releaseOwnership(request).pipe(Effect.tap(() => untrack(request.submissionId)), Effect.tapError((error) => error._tag === "OwnershipLost" ? untrack(request.submissionId) : Effect.void)),
|
|
158
|
-
markInputApplied: ledger.markInputApplied,
|
|
159
|
-
reserveSettlement: ledger.reserveSettlement,
|
|
160
149
|
finalizeSettlement: (request) => ledger.finalizeSettlement(request).pipe(Effect.tap(() => untrack(request.submissionId))),
|
|
161
|
-
requestAbort: ledger.requestAbort,
|
|
162
|
-
readAbortIntent: ledger.readAbortIntent,
|
|
163
|
-
claimJoining: ledger.claimJoining,
|
|
164
|
-
markJoined: ledger.markJoined,
|
|
165
|
-
revertJoining: ledger.revertJoining,
|
|
166
150
|
suspend: (request) => ledger.suspend(request).pipe(Effect.tap(() => untrack(request.submissionId))),
|
|
167
|
-
recordApprovalDecision: ledger.recordApprovalDecision,
|
|
168
|
-
markUnknown: ledger.markUnknown,
|
|
169
|
-
recordUnknownResolution: ledger.recordUnknownResolution,
|
|
170
|
-
scanNonterminal: ledger.scanNonterminal,
|
|
171
151
|
loadRecoverySnapshot: ledger.loadRecoverySnapshot
|
|
172
152
|
});
|
|
173
153
|
}));
|
|
@@ -1 +1 @@
|
|
|
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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jE,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 ...ledger,\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 finalizeSettlement: (request) =>\n ledger.finalizeSettlement(request).pipe(Effect.tap(() => untrack(request.submissionId))),\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 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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,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,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import { a as NodeDurableAgentRuntimeOptions, c as NodePlatformConfigError, n as NodeDurableAgentRuntimeConfig, o as NodeDurableAgentRuntimeServices } from "./NodeDurableAgentRuntime-PVzGBhyG.mjs";
|
|
3
3
|
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
4
4
|
import { AgentRegistration, DurableBindingFailure, ResolvedBinding } from "effect-agent/agent-registration";
|
|
5
5
|
import { DurableAbortFailure, DurableAgentRuntime, DurableAwaitFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableRetryFailure, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, Receipt, RecoveryBlocked, RecoveryReport } from "effect-agent/durable-agent-runtime";
|
|
@@ -88,9 +88,9 @@ export declare class NodeDurableHost extends NodeDurableHost_base {
|
|
|
88
88
|
* Startup recovery and shutdown gates are unchanged. Workers start only when the caller
|
|
89
89
|
* runs runResolvedWorkers; this constructor never starts a background worker.
|
|
90
90
|
*/
|
|
91
|
-
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 | RecoveryBlocked | 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
|
|
91
|
+
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 | RecoveryBlocked | 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_2) ? T_2 extends Entries[number] ? T_2 extends unknown ? ("attemptLayer" extends keyof T_2 ? T_2[keyof T_2 & "attemptLayer"] : undefined) extends (infer T_3) ? T_3 extends ("attemptLayer" extends keyof T_2 ? T_2[keyof T_2 & "attemptLayer"] : undefined) ? T_3 extends ((context: import("effect-agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_2 extends {
|
|
92
92
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
93
|
-
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> :
|
|
93
|
+
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_2 extends {
|
|
94
94
|
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> & {
|
|
95
95
|
readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
|
|
96
96
|
readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
|
|
@@ -99,9 +99,9 @@ export declare class NodeDurableHost extends NodeDurableHost_base {
|
|
|
99
99
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
|
|
100
100
|
readonly definition: D;
|
|
101
101
|
readonly model: M;
|
|
102
|
-
}> : never, Provides> :
|
|
102
|
+
}> : never, Provides> : T_2 extends {
|
|
103
103
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
104
|
-
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> :
|
|
104
|
+
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_2 extends {
|
|
105
105
|
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> & {
|
|
106
106
|
readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
|
|
107
107
|
readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
|
|
@@ -110,7 +110,7 @@ export declare class NodeDurableHost extends NodeDurableHost_base {
|
|
|
110
110
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
|
|
111
111
|
readonly definition: D;
|
|
112
112
|
readonly model: M;
|
|
113
|
-
}> : never : never : never
|
|
113
|
+
}> : 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>>;
|
|
114
114
|
/**
|
|
115
115
|
* Host gates over an assembled `NodeDurableAgentRuntime` stack. The runtime Layer owns
|
|
116
116
|
* executable registrations; omission registers no Agents, so resolved work fails closed.
|
|
@@ -127,9 +127,9 @@ export declare class NodeDurableHost extends NodeDurableHost_base {
|
|
|
127
127
|
* shares the same pool. A worker failure closes admission; observe it with `run` at the process
|
|
128
128
|
* boundary so the application exits and releases the host instead of remaining idle.
|
|
129
129
|
*/
|
|
130
|
-
export 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 | RecoveryBlocked | 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
|
|
130
|
+
export 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 | RecoveryBlocked | 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_2) ? T_2 extends Entries[number] ? T_2 extends unknown ? ("attemptLayer" extends keyof T_2 ? T_2[keyof T_2 & "attemptLayer"] : undefined) extends (infer T_3) ? T_3 extends ("attemptLayer" extends keyof T_2 ? T_2[keyof T_2 & "attemptLayer"] : undefined) ? T_3 extends ((context: import("effect-agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_2 extends {
|
|
131
131
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
132
|
-
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> :
|
|
132
|
+
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_2 extends {
|
|
133
133
|
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> & {
|
|
134
134
|
readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
|
|
135
135
|
readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
|
|
@@ -138,9 +138,9 @@ export declare const layer: <const Entries extends ReadonlyArray<AgentRegistrati
|
|
|
138
138
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
|
|
139
139
|
readonly definition: D;
|
|
140
140
|
readonly model: M;
|
|
141
|
-
}> : never, Provides> :
|
|
141
|
+
}> : never, Provides> : T_2 extends {
|
|
142
142
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
143
|
-
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> :
|
|
143
|
+
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_2 extends {
|
|
144
144
|
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> & {
|
|
145
145
|
readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
|
|
146
146
|
readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
|
|
@@ -149,7 +149,7 @@ export declare const layer: <const Entries extends ReadonlyArray<AgentRegistrati
|
|
|
149
149
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
|
|
150
150
|
readonly definition: D;
|
|
151
151
|
readonly model: M;
|
|
152
|
-
}> : never : never : never
|
|
152
|
+
}> : 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>>;
|
|
153
153
|
/**
|
|
154
154
|
* Supervise the host's existing workers without starting another pool. Use with
|
|
155
155
|
* `Effect.provide(HostLive)` and `NodeRuntime.runMain`; race it with a server Effect when
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as NodeWakeScheduler_d_exports } from "./NodeWakeScheduler-CCgm1t-G.mjs";
|
|
2
|
-
import { s as NodeDurableAgentRuntime_d_exports } from "./NodeDurableAgentRuntime-
|
|
2
|
+
import { s as NodeDurableAgentRuntime_d_exports } from "./NodeDurableAgentRuntime-PVzGBhyG.mjs";
|
|
3
3
|
import { t as NodeDurableHost_d_exports } from "./NodeDurableHost.mjs";
|
|
4
4
|
import { t as NodeScheduling_d_exports } from "./NodeScheduling.mjs";
|
|
5
5
|
import { t as NodeSubscriptions_d_exports } from "./NodeSubscriptions.mjs";
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@effect-agent/platform-node","version":"0.1.0-beta.
|
|
1
|
+
{"name":"@effect-agent/platform-node","version":"0.1.0-beta.115","dependencies":{"@effect-agent/storage-sqlite":"0.1.0-beta.115","@effect-agent/workflow":"0.1.0-beta.115","@effect/platform-node":"4.0.0-rc.116","@effect/sql-sqlite-node":"4.0.0-rc.116","effect-agent":"0.1.0-beta.115"},"devDependencies":{"@effect/vitest":"4.0.0-rc.116","effect":"4.0.0-rc.116","typescript":"7.0.2","vite-plus":"0.3.2"},"peerDependencies":{"effect":"^4.0.0-rc.116"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./node-durable-agent-runtime":{"types":"./dist/NodeDurableAgentRuntime.d.mts","default":"./dist/NodeDurableAgentRuntime.mjs"},"./node-durable-host":{"types":"./dist/NodeDurableHost.d.mts","default":"./dist/NodeDurableHost.mjs"},"./node-scheduling":{"types":"./dist/NodeScheduling.d.mts","default":"./dist/NodeScheduling.mjs"},"./node-subscriptions":{"types":"./dist/NodeSubscriptions.d.mts","default":"./dist/NodeSubscriptions.mjs"},"./node-wake-scheduler":{"types":"./dist/NodeWakeScheduler.d.mts","default":"./dist/NodeWakeScheduler.mjs"},"./node-workflow":{"types":"./dist/NodeWorkflow.d.mts","default":"./dist/NodeWorkflow.mjs"}},"description":"Class DN layer assembly for Effect Agent: the durable Node/SQLite runtime host, wake scheduler, and ownership drain.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/platform-node"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json"}}
|
|
@@ -336,19 +336,7 @@ export const ownershipDrainLayer: Layer.Layer<SubmissionLedger, never, Submissio
|
|
|
336
336
|
yield* Effect.addFinalizer(() => releaseTrackedOwnership(ledger, registry));
|
|
337
337
|
|
|
338
338
|
return SubmissionLedger.of({
|
|
339
|
-
|
|
340
|
-
admit: ledger.admit,
|
|
341
|
-
markReady: ledger.markReady,
|
|
342
|
-
lookup: ledger.lookup,
|
|
343
|
-
// The S2 subagent ops forward untouched: none of them grants an ownership period, so
|
|
344
|
-
// the drain has nothing to track for them (`suspend` below already stops tracking the
|
|
345
|
-
// waitingForChild ownership period the moment it ends).
|
|
346
|
-
resolveAdmission: ledger.resolveAdmission,
|
|
347
|
-
recordChildSettled: ledger.recordChildSettled,
|
|
348
|
-
reserveChildBudget: ledger.reserveChildBudget,
|
|
349
|
-
attachChildToReservation: ledger.attachChildToReservation,
|
|
350
|
-
beginChildBudgetRelease: ledger.beginChildBudgetRelease,
|
|
351
|
-
releaseChildBudget: ledger.releaseChildBudget,
|
|
339
|
+
...ledger,
|
|
352
340
|
claim: (request) =>
|
|
353
341
|
ledger
|
|
354
342
|
.claim(request)
|
|
@@ -373,22 +361,11 @@ export const ownershipDrainLayer: Layer.Layer<SubmissionLedger, never, Submissio
|
|
|
373
361
|
error._tag === "OwnershipLost" ? untrack(request.submissionId) : Effect.void,
|
|
374
362
|
),
|
|
375
363
|
),
|
|
376
|
-
markInputApplied: ledger.markInputApplied,
|
|
377
|
-
reserveSettlement: ledger.reserveSettlement,
|
|
378
364
|
finalizeSettlement: (request) =>
|
|
379
365
|
ledger.finalizeSettlement(request).pipe(Effect.tap(() => untrack(request.submissionId))),
|
|
380
|
-
requestAbort: ledger.requestAbort,
|
|
381
|
-
readAbortIntent: ledger.readAbortIntent,
|
|
382
|
-
claimJoining: ledger.claimJoining,
|
|
383
|
-
markJoined: ledger.markJoined,
|
|
384
|
-
revertJoining: ledger.revertJoining,
|
|
385
366
|
// Suspension ends the ownership period by contract, so the drain stops tracking it.
|
|
386
367
|
suspend: (request) =>
|
|
387
368
|
ledger.suspend(request).pipe(Effect.tap(() => untrack(request.submissionId))),
|
|
388
|
-
recordApprovalDecision: ledger.recordApprovalDecision,
|
|
389
|
-
markUnknown: ledger.markUnknown,
|
|
390
|
-
recordUnknownResolution: ledger.recordUnknownResolution,
|
|
391
|
-
scanNonterminal: ledger.scanNonterminal,
|
|
392
369
|
loadRecoverySnapshot: ledger.loadRecoverySnapshot,
|
|
393
370
|
});
|
|
394
371
|
}),
|