@effect-agent/platform-node 0.1.0-beta.110 → 0.1.0-beta.112
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/{NodeDurableHost-CG2xAhfb.mjs → NodeDurableHost-GDedHU6X.mjs} +5 -3
- package/dist/NodeDurableHost-GDedHU6X.mjs.map +1 -0
- package/dist/NodeDurableHost.d.mts +5 -5
- package/dist/NodeDurableHost.mjs +1 -1
- package/dist/NodeSubscriptions.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/NodeDurableHost.ts +10 -3
- package/dist/NodeDurableHost-CG2xAhfb.mjs.map +0 -1
|
@@ -98,7 +98,9 @@ var AdmissionClosed = class extends Schema.TaggedError()("AdmissionClosed", { me
|
|
|
98
98
|
const makeHost = Effect.fn("NodeDurableHost.make")(function* (startWorkers) {
|
|
99
99
|
const runtime = yield* DurableAgentRuntime;
|
|
100
100
|
const config = yield* NodeDurableAgentRuntimeConfig;
|
|
101
|
-
const startupRecovery = yield* runtime.runRecovery;
|
|
101
|
+
const startupRecovery = yield* runtime.runRecovery();
|
|
102
|
+
const blocked = startupRecovery.blocked[0];
|
|
103
|
+
if (blocked !== void 0) return yield* blocked;
|
|
102
104
|
const admission = yield* Ref.make(true);
|
|
103
105
|
const requireAdmission = Ref.get(admission).pipe(Effect.flatMap((open) => open ? Effect.void : Effect.fail(AdmissionClosed.make({ message: "The host is shutting down; admission is closed." }))));
|
|
104
106
|
const submit = (agent, input, options) => requireAdmission.pipe(Effect.andThen(runtime.submit(agent, input, options)));
|
|
@@ -119,7 +121,7 @@ const makeHost = Effect.fn("NodeDurableHost.make")(function* (startWorkers) {
|
|
|
119
121
|
const run = startWorkers ? Fiber.join(yield* runResolvedWorkers.pipe(Effect.onExit(() => Ref.set(admission, false)), Effect.forkScoped)) : runResolvedWorkers;
|
|
120
122
|
yield* Effect.addFinalizer(() => Ref.set(admission, false));
|
|
121
123
|
return NodeDurableHost.of({
|
|
122
|
-
startupRecovery,
|
|
124
|
+
startupRecovery: startupRecovery.reports,
|
|
123
125
|
admissionOpen: Ref.get(admission),
|
|
124
126
|
submit,
|
|
125
127
|
awaitSettlement: runtime.awaitSettlement,
|
|
@@ -191,4 +193,4 @@ const run = Effect.gen(function* () {
|
|
|
191
193
|
//#endregion
|
|
192
194
|
export { run as a, layer as i, NodeDurableHost as n, NodeAdmission as o, NodeDurableHost_exports as r, makeNodePreparedInputAdmission as s, AdmissionClosed as t };
|
|
193
195
|
|
|
194
|
-
//# sourceMappingURL=NodeDurableHost-
|
|
196
|
+
//# sourceMappingURL=NodeDurableHost-GDedHU6X.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeDurableHost-GDedHU6X.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 RecoveryBlocked,\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`; submissions parked 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 and later input can run.\n const startupRecovery = yield* runtime.runRecovery();\n\n // This host opens one shared worker pool. A blocked Thread cannot safely enter it:\n // recovery has not established execution authority, including after a read timeout.\n const blocked = startupRecovery.blocked[0];\n\n if (blocked !== undefined) return yield* blocked;\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 // Every claimed head resolves the current Binding for its stable agentId, 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: startupRecovery.reports,\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 parked Submissions with Unknown Outcomes.\n * They retain their settlement obligation while later input can run; authorized resolution\n * or abort advances the parked Submission.\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: every claimed head resolves the current Binding for its stable\n * agentId, 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 | RecoveryBlocked | 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,M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F;;;;;;AAOF,MAAa,MAAM,OAAO,IAAI,aAAa;CAGzC,OAAO,QAAO,OAFM,gBAAA,CAED;AACrB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-CCgm1t-G.mjs";
|
|
|
2
2
|
import { a as NodeDurableAgentRuntimeOptions, c as NodePlatformConfigError, n as NodeDurableAgentRuntimeConfig, o as NodeDurableAgentRuntimeServices } from "./NodeDurableAgentRuntime-Cs_E9W_9.mjs";
|
|
3
3
|
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
4
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";
|
|
5
|
+
import { DurableAbortFailure, DurableAgentRuntime, DurableAwaitFailure, DurableExplainFailure, DurableObligationFailure, DurableObserveOptions, DurableRetryFailure, DurableSubmitAgent, DurableSubmitFailure, DurableSubmitOptions, DurableVerifyFailure, DurableWorkerFailure, Receipt, RecoveryBlocked, RecoveryReport } from "effect-agent/durable-agent-runtime";
|
|
6
6
|
import { SubmissionId, ThreadId } from "effect-agent/identifiers";
|
|
7
7
|
import { MessageDeliveryError, MessageDeliveryStore } from "effect-agent/message-delivery";
|
|
8
8
|
import { CanonicalRecordEnvelope } from "effect-agent/records";
|
|
@@ -88,7 +88,7 @@ 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 | 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
|
+
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_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 {
|
|
92
92
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
93
93
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 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> & {
|
|
@@ -115,11 +115,11 @@ export declare class NodeDurableHost extends NodeDurableHost_base {
|
|
|
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.
|
|
117
117
|
*/
|
|
118
|
-
static readonly layer: Layer.Layer<NodeDurableHost, DurableWorkerFailure | MessageDeliveryError, DurableAgentRuntime | NodeDurableAgentRuntimeConfig | MessageDeliveryStore>;
|
|
118
|
+
static readonly layer: Layer.Layer<NodeDurableHost, DurableWorkerFailure | RecoveryBlocked | MessageDeliveryError, DurableAgentRuntime | NodeDurableAgentRuntimeConfig | MessageDeliveryStore>;
|
|
119
119
|
/** The complete DN host: `NodeDurableAgentRuntime.layer(options)` plus the host lifecycle gates. */
|
|
120
120
|
static layerStack<ContextError = never, ContextRequirements = never, AuthorizationError = never, AuthorizationRequirements = never, ReconcilerError = never, ReconcilerRequirements = never>(options: NodeDurableAgentRuntimeOptions<ContextError, ContextRequirements, AuthorizationError, AuthorizationRequirements, ReconcilerError, ReconcilerRequirements> & {
|
|
121
121
|
readonly bindings?: ReadonlyArray<ResolvedBinding>;
|
|
122
|
-
}): 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
|
+
}): 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>>;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Acquire a complete Node host and start one bounded, scoped worker pool after recovery.
|
|
@@ -127,7 +127,7 @@ 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 | 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
|
+
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_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 {
|
|
131
131
|
readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
|
|
132
132
|
} ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 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> & {
|
package/dist/NodeDurableHost.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as run, i as layer, n as NodeDurableHost, t as AdmissionClosed } from "./NodeDurableHost-
|
|
1
|
+
import { a as run, i as layer, n as NodeDurableHost, t as AdmissionClosed } from "./NodeDurableHost-GDedHU6X.mjs";
|
|
2
2
|
export { AdmissionClosed, NodeDurableHost, layer, run };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { n as NodeDurableHost, o as NodeAdmission, s as makeNodePreparedInputAdmission } from "./NodeDurableHost-
|
|
2
|
+
import { n as NodeDurableHost, o as NodeAdmission, s as makeNodePreparedInputAdmission } from "./NodeDurableHost-GDedHU6X.mjs";
|
|
3
3
|
import { NodeCrypto } from "@effect/platform-node";
|
|
4
4
|
import { Cause, Duration, Effect, Exit, Layer, Option } from "effect";
|
|
5
5
|
import { ScheduledInputAdmission } from "effect-agent/schedule";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as NodeWakeScheduler_exports } from "./NodeWakeScheduler.mjs";
|
|
2
2
|
import { t as NodeDurableAgentRuntime_exports } from "./NodeDurableAgentRuntime.mjs";
|
|
3
|
-
import { r as NodeDurableHost_exports } from "./NodeDurableHost-
|
|
3
|
+
import { r as NodeDurableHost_exports } from "./NodeDurableHost-GDedHU6X.mjs";
|
|
4
4
|
import { t as NodeSubscriptions_exports } from "./NodeSubscriptions.mjs";
|
|
5
5
|
import { t as NodeScheduling_exports } from "./NodeScheduling.mjs";
|
|
6
6
|
export { NodeDurableAgentRuntime_exports as NodeDurableAgentRuntime, NodeDurableHost_exports as NodeDurableHost, NodeScheduling_exports as NodeScheduling, NodeSubscriptions_exports as NodeSubscriptions, NodeWakeScheduler_exports as NodeWakeScheduler };
|
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.112","dependencies":{"@effect-agent/storage-sqlite":"0.1.0-beta.112","@effect-agent/workflow":"0.1.0-beta.112","@effect/platform-node":"4.0.0-rc.116","@effect/sql-sqlite-node":"4.0.0-rc.116","effect-agent":"0.1.0-beta.112"},"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"}}
|
package/src/NodeDurableHost.ts
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type DurableVerifyFailure,
|
|
27
27
|
type DurableWorkerFailure,
|
|
28
28
|
type Receipt,
|
|
29
|
+
type RecoveryBlocked,
|
|
29
30
|
type RecoveryReport,
|
|
30
31
|
} from "effect-agent/durable-agent-runtime";
|
|
31
32
|
import { type ThreadId, type SubmissionId } from "effect-agent/identifiers";
|
|
@@ -70,7 +71,13 @@ const makeHost = Effect.fn("NodeDurableHost.make")(function* (startWorkers: bool
|
|
|
70
71
|
// stays a visible obligation for `runWorkers`; submissions parked on an Unknown Outcome are
|
|
71
72
|
// reported `unknown` and wait for the authorized `resolveUnknown` path (DUR-017) — they consume
|
|
72
73
|
// no worker permit while the settlement obligation stays owed and later input can run.
|
|
73
|
-
const startupRecovery = yield* runtime.runRecovery;
|
|
74
|
+
const startupRecovery = yield* runtime.runRecovery();
|
|
75
|
+
|
|
76
|
+
// This host opens one shared worker pool. A blocked Thread cannot safely enter it:
|
|
77
|
+
// recovery has not established execution authority, including after a read timeout.
|
|
78
|
+
const blocked = startupRecovery.blocked[0];
|
|
79
|
+
|
|
80
|
+
if (blocked !== undefined) return yield* blocked;
|
|
74
81
|
|
|
75
82
|
const admission = yield* Ref.make(true);
|
|
76
83
|
|
|
@@ -149,7 +156,7 @@ const makeHost = Effect.fn("NodeDurableHost.make")(function* (startWorkers: bool
|
|
|
149
156
|
yield* Effect.addFinalizer(() => Ref.set(admission, false));
|
|
150
157
|
|
|
151
158
|
return NodeDurableHost.of({
|
|
152
|
-
startupRecovery,
|
|
159
|
+
startupRecovery: startupRecovery.reports,
|
|
153
160
|
admissionOpen: Ref.get(admission),
|
|
154
161
|
submit,
|
|
155
162
|
awaitSettlement: runtime.awaitSettlement,
|
|
@@ -287,7 +294,7 @@ export class NodeDurableHost extends Context.Service<
|
|
|
287
294
|
*/
|
|
288
295
|
static readonly layer: Layer.Layer<
|
|
289
296
|
NodeDurableHost,
|
|
290
|
-
DurableWorkerFailure | MessageDeliveryError,
|
|
297
|
+
DurableWorkerFailure | RecoveryBlocked | MessageDeliveryError,
|
|
291
298
|
DurableAgentRuntime | NodeDurableAgentRuntimeConfig | MessageDeliveryStore
|
|
292
299
|
> = Layer.effect(NodeDurableHost)(makeHost(false));
|
|
293
300
|
|
|
@@ -1 +0,0 @@
|
|
|
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`; submissions parked 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 and later input can run.\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 // Every claimed head resolves the current Binding for its stable agentId, 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 parked Submissions with Unknown Outcomes.\n * They retain their settlement obligation while later input can run; authorized resolution\n * or abort advances the parked Submission.\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: every claimed head resolves the current Binding for its stable\n * agentId, 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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