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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{NodeDurableAgentRuntime-eTlQCxvz.d.mts → NodeDurableAgentRuntime-Cs_E9W_9.d.mts} +31 -31
  2. package/dist/NodeDurableAgentRuntime.d.mts +1 -1
  3. package/dist/NodeDurableAgentRuntime.mjs +18 -18
  4. package/dist/NodeDurableAgentRuntime.mjs.map +1 -1
  5. package/dist/{NodeDurableHost-BMSajuQn.mjs → NodeDurableHost-CG2xAhfb.mjs} +12 -12
  6. package/dist/NodeDurableHost-CG2xAhfb.mjs.map +1 -0
  7. package/dist/NodeDurableHost.d.mts +44 -44
  8. package/dist/NodeDurableHost.mjs +1 -1
  9. package/dist/NodeScheduling.d.mts +2 -2
  10. package/dist/NodeScheduling.mjs +2 -2
  11. package/dist/NodeScheduling.mjs.map +1 -1
  12. package/dist/NodeSubscriptions.d.mts +6 -6
  13. package/dist/NodeSubscriptions.mjs +7 -7
  14. package/dist/NodeSubscriptions.mjs.map +1 -1
  15. package/dist/{NodeWakeScheduler-4ZeXYwPu.d.mts → NodeWakeScheduler-CCgm1t-G.d.mts} +3 -3
  16. package/dist/NodeWakeScheduler.d.mts +1 -1
  17. package/dist/NodeWakeScheduler.mjs +3 -3
  18. package/dist/NodeWakeScheduler.mjs.map +1 -1
  19. package/dist/NodeWorkflow.d.mts +1 -1
  20. package/dist/NodeWorkflow.mjs +1 -1
  21. package/dist/NodeWorkflow.mjs.map +1 -1
  22. package/dist/index.d.mts +2 -2
  23. package/dist/index.mjs +1 -1
  24. package/package.json +1 -1
  25. package/src/NodeDurableAgentRuntime.ts +29 -35
  26. package/src/NodeDurableHost.ts +12 -15
  27. package/src/NodeScheduling.ts +4 -8
  28. package/src/NodeSubscriptions.ts +8 -12
  29. package/src/NodeWakeScheduler.ts +3 -3
  30. package/src/NodeWorkflow.ts +1 -1
  31. package/src/internal/message-delivery.ts +2 -2
  32. package/src/internal/prepared-admission.ts +6 -6
  33. package/dist/NodeDurableHost-BMSajuQn.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { NodeDurableHost } from "./NodeDurableHost.mjs";
2
- import { ScheduleAuthorizer, ScheduleStore, ScheduleValidationError, ScheduleWake, SchedulingLimits } from "@effect-agent/thread/Schedule";
3
2
  import { Layer } from "effect";
4
- import { Scheduling } from "@effect-agent/thread/Scheduling";
3
+ import { ScheduleAuthorizer, ScheduleStore, ScheduleValidationError, ScheduleWake, SchedulingLimits } from "effect-agent/schedule";
4
+ import { Scheduling } from "effect-agent/scheduling";
5
5
  declare namespace NodeScheduling_d_exports {
6
6
  export { NodeScheduling, NodeSchedulingOptions, nodeScheduleWakeLayer };
7
7
  }
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { nodeScheduledInputAdmissionLayer } from "./NodeSubscriptions.mjs";
3
- import { ScheduleStorageError, ScheduleStore, ScheduleWake, defaultSchedulingLimits } from "@effect-agent/thread/Schedule";
4
3
  import { NodeCrypto } from "@effect/platform-node";
5
4
  import { Cause, Duration, Effect, Layer, Option, PubSub, Result } from "effect";
6
- import { ScheduleDriver, Scheduling } from "@effect-agent/thread/Scheduling";
5
+ import { ScheduleStorageError, ScheduleStore, ScheduleWake, defaultSchedulingLimits } from "effect-agent/schedule";
6
+ import { ScheduleDriver, Scheduling } from "effect-agent/scheduling";
7
7
  //#region src/NodeScheduling.ts
8
8
  var NodeScheduling_exports = /* @__PURE__ */ __exportAll({
9
9
  NodeScheduling: () => NodeScheduling,
@@ -1 +1 @@
1
- {"version":3,"file":"NodeScheduling.mjs","names":[],"sources":["../src/NodeScheduling.ts"],"sourcesContent":["import {\n type ScheduleAuthorizer,\n type SchedulingLimits,\n ScheduleStorageError,\n ScheduleStore,\n type ScheduleValidationError,\n ScheduleWake,\n defaultSchedulingLimits,\n} from \"@effect-agent/thread/Schedule\";\nimport {\n type ScheduleProcessFailure,\n Scheduling,\n ScheduleDriver,\n} from \"@effect-agent/thread/Scheduling\";\nimport { NodeCrypto } from \"@effect/platform-node\";\nimport { Cause, Duration, Effect, Layer, Option, PubSub, Result } from \"effect\";\n\nimport type { NodeDurableHost } from \"./NodeDurableHost.ts\";\nimport { nodeScheduledInputAdmissionLayer } from \"./NodeSubscriptions.ts\";\n\n/** One bounded hint slot for the single supported Node scheduler. Indexed polling repairs loss. */\nexport const nodeScheduleWakeLayer: Layer.Layer<ScheduleWake> = Layer.effect(\n ScheduleWake,\n Effect.gen(function* () {\n const hints = yield* PubSub.sliding<void>(1);\n const subscription = yield* PubSub.subscribe(hints);\n\n yield* Effect.addFinalizer(() => PubSub.shutdown(hints));\n\n return ScheduleWake.of({\n notify: PubSub.publish(hints, undefined).pipe(Effect.asVoid),\n await: PubSub.take(subscription),\n });\n }),\n);\n\nconst reportPassFailure = (cause: Cause.Cause<ScheduleProcessFailure>): Effect.Effect<boolean> =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.logWarning(\"Node scheduling pass failed\").pipe(\n Effect.annotateLogs({\n failureTag: Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"Defect\",\n onSome: (error) => error._tag,\n }),\n }),\n Effect.as(false),\n );\n\nconst nodeSchedulingDriverLayer = (\n limits: SchedulingLimits,\n): Layer.Layer<never, never, ScheduleDriver | ScheduleStore | ScheduleWake> =>\n Layer.effectDiscard(\n Effect.gen(function* () {\n const scheduling = yield* ScheduleDriver;\n const store = yield* ScheduleStore;\n const wake = yield* ScheduleWake;\n\n const run = Effect.gen(function* () {\n while (true) {\n const passSucceeded = yield* scheduling.runDue().pipe(\n Effect.map((pass) => pass.failed === 0),\n Effect.catchCause(reportPassFailure),\n );\n\n const deadlineResult = passSucceeded\n ? yield* store.nextDeadline().pipe(Effect.result)\n : Result.fail(\n ScheduleStorageError.make({ operation: \"driver pass\", reason: \"unavailable\" }),\n );\n\n if (Result.isFailure(deadlineResult) && passSucceeded) {\n yield* Effect.logWarning(\"Node scheduling deadline query failed\");\n }\n const nowMillis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);\n\n const deadlineDelay =\n Result.isSuccess(deadlineResult) && deadlineResult.success !== null\n ? Math.max(0, deadlineResult.success - nowMillis)\n : limits.recoveryPollMillis;\n\n const delay = Math.min(deadlineDelay, limits.recoveryPollMillis);\n\n yield* Effect.raceFirst(wake.await, Effect.sleep(Duration.millis(delay)));\n }\n });\n\n yield* Effect.forkScoped(run);\n }),\n );\n\nexport interface NodeSchedulingOptions {\n readonly limits?: SchedulingLimits | undefined;\n}\n\n/**\n * Optional Scope-owned Node scheduling service and driver. The caller must provide the existing\n * host, its SQLite ScheduleStore, and an explicit ScheduleAuthorizer.\n */\nexport class NodeScheduling {\n static layer(\n options: NodeSchedulingOptions = {},\n ): Layer.Layer<\n Scheduling,\n ScheduleValidationError,\n NodeDurableHost | ScheduleStore | ScheduleAuthorizer\n > {\n const limits = options.limits ?? defaultSchedulingLimits;\n\n const schedulingWithDriver = nodeSchedulingDriverLayer(limits).pipe(\n Layer.provide(ScheduleDriver.layer(limits)),\n Layer.merge(Scheduling.layer(limits)),\n );\n\n return schedulingWithDriver.pipe(\n Layer.provide(\n Layer.mergeAll(nodeScheduledInputAdmissionLayer, nodeScheduleWakeLayer, NodeCrypto.layer),\n ),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,wBAAmD,MAAM,OACpE,cACA,OAAO,IAAI,aAAa;CACtB,MAAM,QAAQ,OAAO,OAAO,QAAc,CAAC;CAC3C,MAAM,eAAe,OAAO,OAAO,UAAU,KAAK;CAElD,OAAO,OAAO,mBAAmB,OAAO,SAAS,KAAK,CAAC;CAEvD,OAAO,aAAa,GAAG;EACrB,QAAQ,OAAO,QAAQ,OAAO,KAAA,CAAS,CAAC,CAAC,KAAK,OAAO,MAAM;EAC3D,OAAO,OAAO,KAAK,YAAY;CACj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,CAAC,GAKlC;EACA,MAAM,SAAS,QAAQ,UAAU;EAOjC,OAL6B,0BAA0B,MAAM,CAAC,CAAC,KAC7D,MAAM,QAAQ,eAAe,MAAM,MAAM,CAAC,GAC1C,MAAM,MAAM,WAAW,MAAM,MAAM,CAAC,CAGZ,CAAC,CAAC,KAC1B,MAAM,QACJ,MAAM,SAAS,kCAAkC,uBAAuB,WAAW,KAAK,CAC1F,CACF;CACF;AACF"}
1
+ {"version":3,"file":"NodeScheduling.mjs","names":[],"sources":["../src/NodeScheduling.ts"],"sourcesContent":["import { NodeCrypto } from \"@effect/platform-node\";\nimport { Cause, Duration, Effect, Layer, Option, PubSub, Result } from \"effect\";\nimport {\n type ScheduleAuthorizer,\n type SchedulingLimits,\n ScheduleStorageError,\n ScheduleStore,\n type ScheduleValidationError,\n ScheduleWake,\n defaultSchedulingLimits,\n} from \"effect-agent/schedule\";\nimport { type ScheduleProcessFailure, Scheduling, ScheduleDriver } from \"effect-agent/scheduling\";\n\nimport type { NodeDurableHost } from \"./NodeDurableHost.ts\";\nimport { nodeScheduledInputAdmissionLayer } from \"./NodeSubscriptions.ts\";\n\n/** One bounded hint slot for the single supported Node scheduler. Indexed polling repairs loss. */\nexport const nodeScheduleWakeLayer: Layer.Layer<ScheduleWake> = Layer.effect(\n ScheduleWake,\n Effect.gen(function* () {\n const hints = yield* PubSub.sliding<void>(1);\n const subscription = yield* PubSub.subscribe(hints);\n\n yield* Effect.addFinalizer(() => PubSub.shutdown(hints));\n\n return ScheduleWake.of({\n notify: PubSub.publish(hints, undefined).pipe(Effect.asVoid),\n await: PubSub.take(subscription),\n });\n }),\n);\n\nconst reportPassFailure = (cause: Cause.Cause<ScheduleProcessFailure>): Effect.Effect<boolean> =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.logWarning(\"Node scheduling pass failed\").pipe(\n Effect.annotateLogs({\n failureTag: Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"Defect\",\n onSome: (error) => error._tag,\n }),\n }),\n Effect.as(false),\n );\n\nconst nodeSchedulingDriverLayer = (\n limits: SchedulingLimits,\n): Layer.Layer<never, never, ScheduleDriver | ScheduleStore | ScheduleWake> =>\n Layer.effectDiscard(\n Effect.gen(function* () {\n const scheduling = yield* ScheduleDriver;\n const store = yield* ScheduleStore;\n const wake = yield* ScheduleWake;\n\n const run = Effect.gen(function* () {\n while (true) {\n const passSucceeded = yield* scheduling.runDue().pipe(\n Effect.map((pass) => pass.failed === 0),\n Effect.catchCause(reportPassFailure),\n );\n\n const deadlineResult = passSucceeded\n ? yield* store.nextDeadline().pipe(Effect.result)\n : Result.fail(\n ScheduleStorageError.make({ operation: \"driver pass\", reason: \"unavailable\" }),\n );\n\n if (Result.isFailure(deadlineResult) && passSucceeded) {\n yield* Effect.logWarning(\"Node scheduling deadline query failed\");\n }\n const nowMillis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);\n\n const deadlineDelay =\n Result.isSuccess(deadlineResult) && deadlineResult.success !== null\n ? Math.max(0, deadlineResult.success - nowMillis)\n : limits.recoveryPollMillis;\n\n const delay = Math.min(deadlineDelay, limits.recoveryPollMillis);\n\n yield* Effect.raceFirst(wake.await, Effect.sleep(Duration.millis(delay)));\n }\n });\n\n yield* Effect.forkScoped(run);\n }),\n );\n\nexport interface NodeSchedulingOptions {\n readonly limits?: SchedulingLimits | undefined;\n}\n\n/**\n * Optional Scope-owned Node scheduling service and driver. The caller must provide the existing\n * host, its SQLite ScheduleStore, and an explicit ScheduleAuthorizer.\n */\nexport class NodeScheduling {\n static layer(\n options: NodeSchedulingOptions = {},\n ): Layer.Layer<\n Scheduling,\n ScheduleValidationError,\n NodeDurableHost | ScheduleStore | ScheduleAuthorizer\n > {\n const limits = options.limits ?? defaultSchedulingLimits;\n\n const schedulingWithDriver = nodeSchedulingDriverLayer(limits).pipe(\n Layer.provide(ScheduleDriver.layer(limits)),\n Layer.merge(Scheduling.layer(limits)),\n );\n\n return schedulingWithDriver.pipe(\n Layer.provide(\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AAW,uCAAuC;GAElE,MAAM,YAAY,OAAO,OAAO,WAAW,UAAU,MAAM,iBAAiB;GAE5E,MAAM,gBACJ,OAAO,UAAU,cAAc,KAAK,eAAe,YAAY,OAC3D,KAAK,IAAI,GAAG,eAAe,UAAU,SAAS,IAC9C,OAAO;GAEb,MAAM,QAAQ,KAAK,IAAI,eAAe,OAAO,kBAAkB;GAE/D,OAAO,OAAO,UAAU,KAAK,OAAO,OAAO,MAAM,SAAS,OAAO,KAAK,CAAC,CAAC;EAC1E;CACF,CAAC;CAED,OAAO,OAAO,WAAW,GAAG;AAC9B,CAAC,CACH;;;;;AAUF,IAAa,iBAAb,MAA4B;CAC1B,OAAO,MACL,UAAiC,CAAC,GAKlC;EACA,MAAM,SAAS,QAAQ,UAAU;EAOjC,OAL6B,0BAA0B,MAAM,CAAC,CAAC,KAC7D,MAAM,QAAQ,eAAe,MAAM,MAAM,CAAC,GAC1C,MAAM,MAAM,WAAW,MAAM,MAAM,CAAC,CAGZ,CAAC,CAAC,KAC1B,MAAM,QACJ,MAAM,SAAS,kCAAkC,uBAAuB,WAAW,KAAK,CAC1F,CACF;CACF;AACF"}
@@ -1,11 +1,11 @@
1
1
  import { NodeDurableHost } from "./NodeDurableHost.mjs";
2
- import { ScheduledInputAdmission } from "@effect-agent/thread/Schedule";
3
2
  import { Layer } from "effect";
4
- import { PreparedInputAdmission } from "@effect-agent/thread/PreparedInputAdmission";
5
- import { EventSources } from "@effect-agent/thread/EventSource";
6
- import { SubscriptionAuthorizer, SubscriptionError, SubscriptionLimits, SubscriptionStore } from "@effect-agent/thread/Subscription";
7
- import { SubscriptionInputBindings } from "@effect-agent/thread/SubscriptionInput";
8
- import { SubscriptionIntake, Subscriptions } from "@effect-agent/thread/Subscriptions";
3
+ import { ScheduledInputAdmission } from "effect-agent/schedule";
4
+ import { PreparedInputAdmission } from "effect-agent/prepared-input-admission";
5
+ import { EventSources } from "effect-agent/event-source";
6
+ import { SubscriptionAuthorizer, SubscriptionError, SubscriptionLimits, SubscriptionStore } from "effect-agent/subscription";
7
+ import { SubscriptionInputBindings } from "effect-agent/subscription-input";
8
+ import { SubscriptionIntake, Subscriptions } from "effect-agent/subscriptions";
9
9
  declare namespace NodeSubscriptions_d_exports {
10
10
  export { NodeSubscriptions, NodeSubscriptionsOptions, nodePreparedInputAdmissionLayer, nodeScheduledInputAdmissionLayer };
11
11
  }
@@ -1,13 +1,13 @@
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-BMSajuQn.mjs";
3
- import { ScheduledInputAdmission } from "@effect-agent/thread/Schedule";
2
+ import { n as NodeDurableHost, o as NodeAdmission, s as makeNodePreparedInputAdmission } from "./NodeDurableHost-CG2xAhfb.mjs";
4
3
  import { NodeCrypto } from "@effect/platform-node";
5
4
  import { Cause, Duration, Effect, Exit, Layer, Option } from "effect";
6
- import { PreparedInputAdmission } from "@effect-agent/thread/PreparedInputAdmission";
7
- import "@effect-agent/thread/EventSource";
8
- import { SubscriptionStore, defaultSubscriptionLimits } from "@effect-agent/thread/Subscription";
9
- import "@effect-agent/thread/SubscriptionInput";
10
- import { SubscriptionDriver, SubscriptionIntake, Subscriptions } from "@effect-agent/thread/Subscriptions";
5
+ import { ScheduledInputAdmission } from "effect-agent/schedule";
6
+ import { PreparedInputAdmission } from "effect-agent/prepared-input-admission";
7
+ import "effect-agent/event-source";
8
+ import { SubscriptionStore, defaultSubscriptionLimits } from "effect-agent/subscription";
9
+ import "effect-agent/subscription-input";
10
+ import { SubscriptionDriver, SubscriptionIntake, Subscriptions } from "effect-agent/subscriptions";
11
11
  //#region src/NodeSubscriptions.ts
12
12
  var NodeSubscriptions_exports = /* @__PURE__ */ __exportAll({
13
13
  NodeSubscriptions: () => NodeSubscriptions,
@@ -1 +1 @@
1
- {"version":3,"file":"NodeSubscriptions.mjs","names":[],"sources":["../src/NodeSubscriptions.ts"],"sourcesContent":["import { type EventSources } from \"@effect-agent/thread/EventSource\";\nimport { PreparedInputAdmission } from \"@effect-agent/thread/PreparedInputAdmission\";\nimport { type ScheduledEnvelope, ScheduledInputAdmission } from \"@effect-agent/thread/Schedule\";\nimport {\n type PreparedInput,\n type SubscriptionAuthorizer,\n type SubscriptionError,\n type SubscriptionLimits,\n type SubscriptionStoreFailure,\n SubscriptionStore,\n defaultSubscriptionLimits,\n} from \"@effect-agent/thread/Subscription\";\nimport { type SubscriptionInputBindings } from \"@effect-agent/thread/SubscriptionInput\";\nimport {\n SubscriptionDriver,\n SubscriptionIntake,\n Subscriptions,\n} from \"@effect-agent/thread/Subscriptions\";\nimport { NodeCrypto } from \"@effect/platform-node\";\nimport { Cause, Duration, Effect, Exit, Layer, Option } from \"effect\";\n\nimport { makeNodePreparedInputAdmission, NodeAdmission } from \"./internal/prepared-admission.ts\";\nimport { NodeDurableHost } from \"./NodeDurableHost.ts\";\n\n/** Ordinary prepared admission through the Scope-owned Node host gate. */\nexport const nodePreparedInputAdmissionLayer: Layer.Layer<\n PreparedInputAdmission,\n never,\n NodeDurableHost\n> = Layer.effect(PreparedInputAdmission, makeNodePreparedInputAdmission).pipe(\n Layer.provide(Layer.effect(NodeAdmission, NodeDurableHost)),\n);\n\nconst preparedFromSchedule = (envelope: ScheduledEnvelope): PreparedInput => ({\n schemaVersion: 1,\n threadId: envelope.threadId,\n deliveryPrincipal: envelope.deliveryPrincipal,\n ...(envelope.admissionGroup === undefined ? {} : { admissionGroup: envelope.admissionGroup }),\n ...(envelope.admissionFence === undefined ? {} : { admissionFence: envelope.admissionFence }),\n agentId: envelope.agentId,\n definitions: envelope.definitions,\n input: envelope.input,\n inputDigest: envelope.inputDigest,\n admissionKey: envelope.admissionKey,\n authorization: envelope.authorization,\n});\n\n/** Compatibility adapter retaining the public scheduling admission port. */\nconst nodeScheduledInputAdmissionFromPreparedLayer: Layer.Layer<\n ScheduledInputAdmission,\n never,\n PreparedInputAdmission\n> = Layer.effect(\n ScheduledInputAdmission,\n Effect.map(PreparedInputAdmission, (admission) =>\n ScheduledInputAdmission.of({\n submit: (envelope) => admission.submit(preparedFromSchedule(envelope)),\n }),\n ),\n);\n\nexport const nodeScheduledInputAdmissionLayer: Layer.Layer<\n ScheduledInputAdmission,\n never,\n NodeDurableHost\n> = nodeScheduledInputAdmissionFromPreparedLayer.pipe(\n Layer.provide(nodePreparedInputAdmissionLayer),\n);\n\nconst reportPassFailure = (cause: Cause.Cause<SubscriptionStoreFailure>): Effect.Effect<boolean> =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.logWarning(\"Node subscription pass failed\").pipe(\n Effect.annotateLogs({\n failureTag: Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"Defect\",\n onSome: (error) => error._tag,\n }),\n }),\n Effect.as(false),\n );\n\nconst nodeSubscriptionDriverLayer = (\n limits: SubscriptionLimits,\n): Layer.Layer<never, never, SubscriptionDriver | SubscriptionStore> =>\n Layer.effectDiscard(\n Effect.gen(function* () {\n const driver = yield* SubscriptionDriver;\n const store = yield* SubscriptionStore;\n\n const run = Effect.gen(function* () {\n while (true) {\n const passSucceeded = yield* driver.runDue.pipe(\n Effect.map((pass) => pass.failed === 0),\n Effect.catchCause(reportPassFailure),\n );\n\n if (!passSucceeded) {\n yield* Effect.sleep(Duration.millis(limits.retryMillis));\n continue;\n }\n\n const deadline = yield* store.nextDeadline.pipe(Effect.exit);\n\n if (Exit.isFailure(deadline)) {\n yield* reportPassFailure(deadline.cause);\n yield* Effect.sleep(Duration.millis(limits.retryMillis));\n continue;\n }\n\n const nowMillis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);\n\n const delay =\n deadline.value === null\n ? limits.retryMillis\n : Math.max(1, Math.min(deadline.value - nowMillis, limits.retryMillis));\n\n yield* Effect.sleep(Duration.millis(delay));\n }\n });\n\n yield* Effect.forkScoped(run);\n }),\n );\n\nexport interface NodeSubscriptionsOptions {\n readonly limits?: SubscriptionLimits | undefined;\n}\n\n/**\n * One Scope-owned subscription partition in the sole process owning its SQLite database.\n * Indexed polling repairs restart and lost wake state; closing the Scope interrupts the driver.\n */\nexport class NodeSubscriptions {\n static layer(\n options: NodeSubscriptionsOptions = {},\n ): Layer.Layer<\n Subscriptions | SubscriptionIntake,\n SubscriptionError,\n | NodeDurableHost\n | SubscriptionStore\n | SubscriptionAuthorizer\n | EventSources\n | SubscriptionInputBindings\n > {\n const limits = options.limits ?? defaultSubscriptionLimits;\n\n const publicServices = Layer.merge(\n Subscriptions.layer(limits),\n SubscriptionIntake.layer(limits),\n );\n\n const driver = nodeSubscriptionDriverLayer(limits).pipe(\n Layer.provide(SubscriptionDriver.layer(limits)),\n );\n\n return Layer.merge(publicServices, driver).pipe(\n Layer.provide(nodePreparedInputAdmissionLayer),\n Layer.provide(NodeCrypto.layer),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,MAAa,kCAIT,MAAM,OAAO,wBAAwB,8BAA8B,CAAC,CAAC,KACvE,MAAM,QAAQ,MAAM,OAAO,eAAe,eAAe,CAAC,CAC5D;AAEA,MAAM,wBAAwB,cAAgD;CAC5E,eAAe;CACf,UAAU,SAAS;CACnB,mBAAmB,SAAS;CAC5B,GAAI,SAAS,mBAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB,SAAS,eAAe;CAC3F,GAAI,SAAS,mBAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB,SAAS,eAAe;CAC3F,SAAS,SAAS;CAClB,aAAa,SAAS;CACtB,OAAO,SAAS;CAChB,aAAa,SAAS;CACtB,cAAc,SAAS;CACvB,eAAe,SAAS;AAC1B;AAgBA,MAAa,mCATT,MAAM,OACR,yBACA,OAAO,IAAI,yBAAyB,cAClC,wBAAwB,GAAG,EACzB,SAAS,aAAa,UAAU,OAAO,qBAAqB,QAAQ,CAAC,EACvE,CAAC,CACH,CAOE,CAAA,CAA6C,KAC/C,MAAM,QAAQ,+BAA+B,CAC/C;AAEA,M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AAM,MAAM,CACjC;EAEA,MAAM,SAAS,4BAA4B,MAAM,CAAC,CAAC,KACjD,MAAM,QAAQ,mBAAmB,MAAM,MAAM,CAAC,CAChD;EAEA,OAAO,MAAM,MAAM,gBAAgB,MAAM,CAAC,CAAC,KACzC,MAAM,QAAQ,+BAA+B,GAC7C,MAAM,QAAQ,WAAW,KAAK,CAChC;CACF;AACF"}
1
+ {"version":3,"file":"NodeSubscriptions.mjs","names":[],"sources":["../src/NodeSubscriptions.ts"],"sourcesContent":["import { NodeCrypto } from \"@effect/platform-node\";\nimport { Cause, Duration, Effect, Exit, Layer, Option } from \"effect\";\nimport { type EventSources } from \"effect-agent/event-source\";\nimport { PreparedInputAdmission } from \"effect-agent/prepared-input-admission\";\nimport { type ScheduledEnvelope, ScheduledInputAdmission } from \"effect-agent/schedule\";\nimport {\n type PreparedInput,\n type SubscriptionAuthorizer,\n type SubscriptionError,\n type SubscriptionLimits,\n type SubscriptionStoreFailure,\n SubscriptionStore,\n defaultSubscriptionLimits,\n} from \"effect-agent/subscription\";\nimport { type SubscriptionInputBindings } from \"effect-agent/subscription-input\";\nimport { SubscriptionDriver, SubscriptionIntake, Subscriptions } from \"effect-agent/subscriptions\";\n\nimport { makeNodePreparedInputAdmission, NodeAdmission } from \"./internal/prepared-admission.ts\";\nimport { NodeDurableHost } from \"./NodeDurableHost.ts\";\n\n/** Ordinary prepared admission through the Scope-owned Node host gate. */\nexport const nodePreparedInputAdmissionLayer: Layer.Layer<\n PreparedInputAdmission,\n never,\n NodeDurableHost\n> = Layer.effect(PreparedInputAdmission, makeNodePreparedInputAdmission).pipe(\n Layer.provide(Layer.effect(NodeAdmission, NodeDurableHost)),\n);\n\nconst preparedFromSchedule = (envelope: ScheduledEnvelope): PreparedInput => ({\n schemaVersion: 1,\n threadId: envelope.threadId,\n deliveryPrincipal: envelope.deliveryPrincipal,\n ...(envelope.admissionGroup === undefined ? {} : { admissionGroup: envelope.admissionGroup }),\n ...(envelope.admissionFence === undefined ? {} : { admissionFence: envelope.admissionFence }),\n agentId: envelope.agentId,\n definitions: envelope.definitions,\n input: envelope.input,\n inputDigest: envelope.inputDigest,\n admissionKey: envelope.admissionKey,\n authorization: envelope.authorization,\n});\n\n/** Compatibility adapter retaining the public scheduling admission port. */\nconst nodeScheduledInputAdmissionFromPreparedLayer: Layer.Layer<\n ScheduledInputAdmission,\n never,\n PreparedInputAdmission\n> = Layer.effect(\n ScheduledInputAdmission,\n Effect.map(PreparedInputAdmission, (admission) =>\n ScheduledInputAdmission.of({\n submit: (envelope) => admission.submit(preparedFromSchedule(envelope)),\n }),\n ),\n);\n\nexport const nodeScheduledInputAdmissionLayer: Layer.Layer<\n ScheduledInputAdmission,\n never,\n NodeDurableHost\n> = nodeScheduledInputAdmissionFromPreparedLayer.pipe(\n Layer.provide(nodePreparedInputAdmissionLayer),\n);\n\nconst reportPassFailure = (cause: Cause.Cause<SubscriptionStoreFailure>): Effect.Effect<boolean> =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.interrupt\n : Effect.logWarning(\"Node subscription pass failed\").pipe(\n Effect.annotateLogs({\n failureTag: Option.match(Cause.findErrorOption(cause), {\n onNone: () => \"Defect\",\n onSome: (error) => error._tag,\n }),\n }),\n Effect.as(false),\n );\n\nconst nodeSubscriptionDriverLayer = (\n limits: SubscriptionLimits,\n): Layer.Layer<never, never, SubscriptionDriver | SubscriptionStore> =>\n Layer.effectDiscard(\n Effect.gen(function* () {\n const driver = yield* SubscriptionDriver;\n const store = yield* SubscriptionStore;\n\n const run = Effect.gen(function* () {\n while (true) {\n const passSucceeded = yield* driver.runDue.pipe(\n Effect.map((pass) => pass.failed === 0),\n Effect.catchCause(reportPassFailure),\n );\n\n if (!passSucceeded) {\n yield* Effect.sleep(Duration.millis(limits.retryMillis));\n continue;\n }\n\n const deadline = yield* store.nextDeadline.pipe(Effect.exit);\n\n if (Exit.isFailure(deadline)) {\n yield* reportPassFailure(deadline.cause);\n yield* Effect.sleep(Duration.millis(limits.retryMillis));\n continue;\n }\n\n const nowMillis = yield* Effect.clockWith((clock) => clock.currentTimeMillis);\n\n const delay =\n deadline.value === null\n ? limits.retryMillis\n : Math.max(1, Math.min(deadline.value - nowMillis, limits.retryMillis));\n\n yield* Effect.sleep(Duration.millis(delay));\n }\n });\n\n yield* Effect.forkScoped(run);\n }),\n );\n\nexport interface NodeSubscriptionsOptions {\n readonly limits?: SubscriptionLimits | undefined;\n}\n\n/**\n * One Scope-owned subscription partition in the sole process owning its SQLite database.\n * Indexed polling repairs restart and lost wake state; closing the Scope interrupts the driver.\n */\nexport class NodeSubscriptions {\n static layer(\n options: NodeSubscriptionsOptions = {},\n ): Layer.Layer<\n Subscriptions | SubscriptionIntake,\n SubscriptionError,\n | NodeDurableHost\n | SubscriptionStore\n | SubscriptionAuthorizer\n | EventSources\n | SubscriptionInputBindings\n > {\n const limits = options.limits ?? defaultSubscriptionLimits;\n\n const publicServices = Layer.merge(\n Subscriptions.layer(limits),\n SubscriptionIntake.layer(limits),\n );\n\n const driver = nodeSubscriptionDriverLayer(limits).pipe(\n Layer.provide(SubscriptionDriver.layer(limits)),\n );\n\n return Layer.merge(publicServices, driver).pipe(\n Layer.provide(nodePreparedInputAdmissionLayer),\n Layer.provide(NodeCrypto.layer),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAa,kCAIT,MAAM,OAAO,wBAAwB,8BAA8B,CAAC,CAAC,KACvE,MAAM,QAAQ,MAAM,OAAO,eAAe,eAAe,CAAC,CAC5D;AAEA,MAAM,wBAAwB,cAAgD;CAC5E,eAAe;CACf,UAAU,SAAS;CACnB,mBAAmB,SAAS;CAC5B,GAAI,SAAS,mBAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB,SAAS,eAAe;CAC3F,GAAI,SAAS,mBAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB,SAAS,eAAe;CAC3F,SAAS,SAAS;CAClB,aAAa,SAAS;CACtB,OAAO,SAAS;CAChB,aA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AM,SAAS,OAAO,KAAK,CAAC;EAC5C;CACF,CAAC;CAED,OAAO,OAAO,WAAW,GAAG;AAC9B,CAAC,CACH;;;;;AAUF,IAAa,oBAAb,MAA+B;CAC7B,OAAO,MACL,UAAoC,CAAC,GASrC;EACA,MAAM,SAAS,QAAQ,UAAU;EAEjC,MAAM,iBAAiB,MAAM,MAC3B,cAAc,MAAM,MAAM,GAC1B,mBAAmB,MAAM,MAAM,CACjC;EAEA,MAAM,SAAS,4BAA4B,MAAM,CAAC,CAAC,KACjD,MAAM,QAAQ,mBAAmB,MAAM,MAAM,CAAC,CAChD;EAEA,OAAO,MAAM,MAAM,gBAAgB,MAAM,CAAC,CAAC,KACzC,MAAM,QAAQ,+BAA+B,GAC7C,MAAM,QAAQ,WAAW,KAAK,CAChC;CACF;AACF"}
@@ -1,6 +1,6 @@
1
- import { SubmissionLedger } from "@effect-agent/thread/SubmissionLedger";
2
- import { WakeScheduler } from "@effect-agent/thread/WakeScheduler";
3
1
  import { Context, Duration, Layer } from "effect";
2
+ import { SubmissionLedger } from "effect-agent/submission-ledger";
3
+ import { WakeScheduler } from "effect-agent/wake-scheduler";
4
4
  declare namespace NodeWakeScheduler_d_exports {
5
5
  export { NodeWakeSchedulerConfig, nodeWakeSchedulerLayer };
6
6
  }
@@ -24,4 +24,4 @@ declare class NodeWakeSchedulerConfig extends NodeWakeSchedulerConfig_base {
24
24
  declare const nodeWakeSchedulerLayer: Layer.Layer<WakeScheduler, never, SubmissionLedger | NodeWakeSchedulerConfig>;
25
25
  //#endregion
26
26
  export { NodeWakeScheduler_d_exports as n, nodeWakeSchedulerLayer as r, NodeWakeSchedulerConfig as t };
27
- //# sourceMappingURL=NodeWakeScheduler-4ZeXYwPu.d.mts.map
27
+ //# sourceMappingURL=NodeWakeScheduler-CCgm1t-G.d.mts.map
@@ -1,2 +1,2 @@
1
- import { r as nodeWakeSchedulerLayer, t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-4ZeXYwPu.mjs";
1
+ import { r as nodeWakeSchedulerLayer, t as NodeWakeSchedulerConfig } from "./NodeWakeScheduler-CCgm1t-G.mjs";
2
2
  export { NodeWakeSchedulerConfig, nodeWakeSchedulerLayer };
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import "@effect-agent/core/Identifiers";
3
- import { SubmissionLedger } from "@effect-agent/thread/SubmissionLedger";
4
- import { WakeScheduler, makeWakeSubscriptionHub } from "@effect-agent/thread/WakeScheduler";
5
2
  import { Context, Effect, Layer, PubSub, Stream } from "effect";
3
+ import "effect-agent/identifiers";
4
+ import { SubmissionLedger } from "effect-agent/submission-ledger";
5
+ import { WakeScheduler, makeWakeSubscriptionHub } from "effect-agent/wake-scheduler";
6
6
  //#region src/NodeWakeScheduler.ts
7
7
  var NodeWakeScheduler_exports = /* @__PURE__ */ __exportAll({
8
8
  NodeWakeSchedulerConfig: () => NodeWakeSchedulerConfig,
@@ -1 +1 @@
1
- {"version":3,"file":"NodeWakeScheduler.mjs","names":[],"sources":["../src/NodeWakeScheduler.ts"],"sourcesContent":["import { type ThreadId } from \"@effect-agent/core/Identifiers\";\nimport { SubmissionLedger } from \"@effect-agent/thread/SubmissionLedger\";\nimport { makeWakeSubscriptionHub, WakeScheduler } from \"@effect-agent/thread/WakeScheduler\";\nimport type { Duration } from \"effect\";\nimport { Context, Effect, Layer, PubSub, Stream } from \"effect\";\n\n/**\n * Bounded in-process wake buffer. Wake hints are droppable by contract (the ledger-scan fallback\n * keeps liveness), so a full buffer slides out the oldest hint instead of growing without bound.\n */\nconst WAKE_BUFFER_CAPACITY = 1_024;\n\n/** Cadence authority for the Node wake scheduler's ledger-scan fallback loop. */\nexport class NodeWakeSchedulerConfig extends Context.Service<\n NodeWakeSchedulerConfig,\n {\n /** Interval between ledger scans that re-emit every nonterminal Thread lane. */\n readonly scanInterval: Duration.Duration;\n }\n>()(\"@effect-agent/platform-node/NodeWakeSchedulerConfig\") {\n static layer(options: {\n readonly scanInterval: Duration.Duration;\n }): Layer.Layer<NodeWakeSchedulerConfig> {\n return Layer.succeed(NodeWakeSchedulerConfig)({ scanInterval: options.scanInterval });\n }\n}\n\nconst makeWakeScheduler = Effect.gen(function* () {\n const ledger = yield* SubmissionLedger;\n const config = yield* NodeWakeSchedulerConfig;\n const hints = yield* PubSub.sliding<ThreadId>(WAKE_BUFFER_CAPACITY);\n const progress = yield* makeWakeSubscriptionHub;\n\n yield* Effect.addFinalizer(() => PubSub.shutdown(hints));\n\n /**\n * One fallback scan: every Thread lane with nonterminal work, deduplicated. A scan\n * failure degrades to \"no hints this round\" — the wake channel has no error contract and the\n * next round retries — but is logged so a persistently failing ledger stays visible.\n */\n const scanOnce: Effect.Effect<ReadonlyArray<ThreadId>> = Stream.runCollect(\n ledger.scanNonterminal,\n ).pipe(\n Effect.map((snapshots) => {\n const lanes = new Set<ThreadId>();\n\n for (const snapshot of snapshots) {\n lanes.add(snapshot.threadId);\n }\n\n return [...lanes];\n }),\n Effect.catch((error) =>\n Effect.logWarning(\"NodeWakeScheduler fallback scan failed\", error).pipe(\n Effect.as([] as ReadonlyArray<ThreadId>),\n ),\n ),\n );\n\n /**\n * Deployment §3: correctness must not depend on in-memory notifications, so every `wakes` run\n * merges its PubSub subscription with shared Clock-driven ledger scans. Share whole snapshots:\n * sliding individual lanes would strand the beginning of scans larger than the hint buffer.\n * The scan starts with the first subscriber and stops when the last subscriber leaves.\n */\n const fallbackScans = yield* Stream.share(\n Stream.fromEffectRepeat(Effect.sleep(config.scanInterval).pipe(Effect.andThen(scanOnce))),\n { capacity: 1, strategy: \"sliding\" },\n );\n\n return WakeScheduler.of({\n notify: (threadId) =>\n progress\n .notify(threadId)\n .pipe(Effect.andThen(PubSub.publish(hints, threadId)), Effect.asVoid),\n subscribe: progress.subscribe,\n wakes: Stream.merge(\n Stream.fromPubSub(hints),\n fallbackScans.pipe(Stream.flatMap(Stream.fromIterable)),\n ),\n });\n});\n\n/**\n * In-process Node `WakeScheduler`: `notify` publishes to a bounded sliding PubSub for prompt\n * same-process wakeups, and active `wakes` subscriptions share one periodic\n * `SubmissionLedger.scanNonterminal` fallback so a dropped, coalesced, or never-sent notification\n * can never strand accepted work (persistence §14). Delivery may duplicate; consumers already\n * treat wakes as pure liveness hints.\n */\nexport const nodeWakeSchedulerLayer: Layer.Layer<\n WakeScheduler,\n never,\n SubmissionLedger | NodeWakeSchedulerConfig\n> = Layer.effect(WakeScheduler)(makeWakeScheduler);\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAM,uBAAuB;;AAG7B,IAAa,0BAAb,MAAa,gCAAgC,QAAQ,QAMnD,CAAC,CAAC,qDAAqD,CAAC,CAAC;CACzD,OAAO,MAAM,SAE4B;EACvC,OAAO,MAAM,QAAQ,uBAAuB,CAAC,CAAC,EAAE,cAAc,QAAQ,aAAa,CAAC;CACtF;AACF;AAEA,MAAM,oBAAoB,OAAO,IAAI,aAAa;CAChD,MAAM,SAAS,OAAO;CACtB,MAAM,SAAS,OAAO;CACtB,MAAM,QAAQ,OAAO,OAAO,QAAkB,oBAAoB;CAClE,MAAM,WAAW,OAAO;CAExB,OAAO,OAAO,mBAAmB,OAAO,SAAS,KAAK,CAAC;;;;;;CAOvD,MAAM,WAAmD,OAAO,WAC9D,OAAO,eACT,CAAC,CAAC,KACA,OAAO,KAAK,cAAc;EACxB,MAAM,wBAAQ,IAAI,IAAc;EAEhC,KAAK,MAAM,YAAY,WACrB,MAAM,IAAI,SAAS,QAAQ;EAG7B,OAAO,CAAC,GAAG,KAAK;CAClB,CAAC,GACD,OAAO,OAAO,UACZ,OAAO,WAAW,0CAA0C,KAAK,CAAC,CAAC,KACjE,OAAO,GAAG,CAAC,CAA4B,CACzC,CACF,CACF;;;;;;;CAQA,MAAM,gBAAgB,OAAO,OAAO,MAClC,OAAO,iBAAiB,OAAO,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,OAAO,QAAQ,QAAQ,CAAC,CAAC,GACxF;EAAE,UAAU;EAAG,UAAU;CAAU,CACrC;CAEA,OAAO,cAAc,GAAG;EACtB,SAAS,aACP,SACG,OAAO,QAAQ,CAAC,CAChB,KAAK,OAAO,QAAQ,OAAO,QAAQ,OAAO,QAAQ,CAAC,GAAG,OAAO,MAAM;EACxE,WAAW,SAAS;EACpB,OAAO,OAAO,MACZ,OAAO,WAAW,KAAK,GACvB,cAAc,KAAK,OAAO,QAAQ,OAAO,YAAY,CAAC,CACxD;CACF,CAAC;AACH,CAAC;;;;;;;;AASD,MAAa,yBAIT,MAAM,OAAO,aAAa,CAAC,CAAC,iBAAiB"}
1
+ {"version":3,"file":"NodeWakeScheduler.mjs","names":[],"sources":["../src/NodeWakeScheduler.ts"],"sourcesContent":["import type { Duration } from \"effect\";\nimport { Context, Effect, Layer, PubSub, Stream } from \"effect\";\nimport { type ThreadId } from \"effect-agent/identifiers\";\nimport { SubmissionLedger } from \"effect-agent/submission-ledger\";\nimport { makeWakeSubscriptionHub, WakeScheduler } from \"effect-agent/wake-scheduler\";\n\n/**\n * Bounded in-process wake buffer. Wake hints are droppable by contract (the ledger-scan fallback\n * keeps liveness), so a full buffer slides out the oldest hint instead of growing without bound.\n */\nconst WAKE_BUFFER_CAPACITY = 1_024;\n\n/** Cadence authority for the Node wake scheduler's ledger-scan fallback loop. */\nexport class NodeWakeSchedulerConfig extends Context.Service<\n NodeWakeSchedulerConfig,\n {\n /** Interval between ledger scans that re-emit every nonterminal Thread lane. */\n readonly scanInterval: Duration.Duration;\n }\n>()(\"@effect-agent/platform-node/NodeWakeSchedulerConfig\") {\n static layer(options: {\n readonly scanInterval: Duration.Duration;\n }): Layer.Layer<NodeWakeSchedulerConfig> {\n return Layer.succeed(NodeWakeSchedulerConfig)({ scanInterval: options.scanInterval });\n }\n}\n\nconst makeWakeScheduler = Effect.gen(function* () {\n const ledger = yield* SubmissionLedger;\n const config = yield* NodeWakeSchedulerConfig;\n const hints = yield* PubSub.sliding<ThreadId>(WAKE_BUFFER_CAPACITY);\n const progress = yield* makeWakeSubscriptionHub;\n\n yield* Effect.addFinalizer(() => PubSub.shutdown(hints));\n\n /**\n * One fallback scan: every Thread lane with nonterminal work, deduplicated. A scan\n * failure degrades to \"no hints this round\" — the wake channel has no error contract and the\n * next round retries — but is logged so a persistently failing ledger stays visible.\n */\n const scanOnce: Effect.Effect<ReadonlyArray<ThreadId>> = Stream.runCollect(\n ledger.scanNonterminal,\n ).pipe(\n Effect.map((snapshots) => {\n const lanes = new Set<ThreadId>();\n\n for (const snapshot of snapshots) {\n lanes.add(snapshot.threadId);\n }\n\n return [...lanes];\n }),\n Effect.catch((error) =>\n Effect.logWarning(\"NodeWakeScheduler fallback scan failed\", error).pipe(\n Effect.as([] as ReadonlyArray<ThreadId>),\n ),\n ),\n );\n\n /**\n * Deployment §3: correctness must not depend on in-memory notifications, so every `wakes` run\n * merges its PubSub subscription with shared Clock-driven ledger scans. Share whole snapshots:\n * sliding individual lanes would strand the beginning of scans larger than the hint buffer.\n * The scan starts with the first subscriber and stops when the last subscriber leaves.\n */\n const fallbackScans = yield* Stream.share(\n Stream.fromEffectRepeat(Effect.sleep(config.scanInterval).pipe(Effect.andThen(scanOnce))),\n { capacity: 1, strategy: \"sliding\" },\n );\n\n return WakeScheduler.of({\n notify: (threadId) =>\n progress\n .notify(threadId)\n .pipe(Effect.andThen(PubSub.publish(hints, threadId)), Effect.asVoid),\n subscribe: progress.subscribe,\n wakes: Stream.merge(\n Stream.fromPubSub(hints),\n fallbackScans.pipe(Stream.flatMap(Stream.fromIterable)),\n ),\n });\n});\n\n/**\n * In-process Node `WakeScheduler`: `notify` publishes to a bounded sliding PubSub for prompt\n * same-process wakeups, and active `wakes` subscriptions share one periodic\n * `SubmissionLedger.scanNonterminal` fallback so a dropped, coalesced, or never-sent notification\n * can never strand accepted work (persistence §14). Delivery may duplicate; consumers already\n * treat wakes as pure liveness hints.\n */\nexport const nodeWakeSchedulerLayer: Layer.Layer<\n WakeScheduler,\n never,\n SubmissionLedger | NodeWakeSchedulerConfig\n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,CAAC,CACxD;CACF,CAAC;AACH,CAAC;;;;;;;;AASD,MAAa,yBAIT,MAAM,OAAO,aAAa,CAAC,CAAC,iBAAiB"}
@@ -1,5 +1,5 @@
1
1
  import { Cause, Duration, Layer, Schema } from "effect";
2
- import { WorkflowDispatchError, WorkflowDispatchStore, WorkflowRepairTrigger } from "@effect-agent/workflow/WorkflowDispatch";
2
+ import { WorkflowDispatchError, WorkflowDispatchStore, WorkflowRepairTrigger } from "@effect-agent/workflow/workflow-dispatch";
3
3
  import { SqlClient } from "effect/unstable/sql";
4
4
  //#region src/NodeWorkflow.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { Cause, Duration, Effect, Layer, Option, Schema } from "effect";
2
- import { WorkflowDispatchError, WorkflowDispatchIntent, WorkflowDispatchScan, WorkflowDispatchStore, WorkflowRepairTrigger } from "@effect-agent/workflow/WorkflowDispatch";
2
+ import { WorkflowDispatchError, WorkflowDispatchIntent, WorkflowDispatchScan, WorkflowDispatchStore, WorkflowRepairTrigger } from "@effect-agent/workflow/workflow-dispatch";
3
3
  import { SqlClient } from "effect/unstable/sql";
4
4
  //#region src/NodeWorkflow.ts
5
5
  const StoredIntent = Schema.Struct({
@@ -1 +1 @@
1
- {"version":3,"file":"NodeWorkflow.mjs","names":[],"sources":["../src/NodeWorkflow.ts"],"sourcesContent":["import {\n WorkflowDispatchError,\n WorkflowDispatchIntent,\n WorkflowDispatchScan,\n WorkflowDispatchStore,\n WorkflowRepairTrigger,\n} from \"@effect-agent/workflow/WorkflowDispatch\";\nimport { Cause, Duration, Effect, Layer, Option, Schema } from \"effect\";\nimport { SqlClient } from \"effect/unstable/sql\";\n\nconst StoredIntent = Schema.Struct({\n deployment_id: Schema.String,\n workflow_name: Schema.String,\n execution_id: Schema.String,\n intent_json: Schema.String,\n});\n\nconst IntentJson = Schema.fromJsonString(WorkflowDispatchIntent);\nconst decodeIntent = Schema.decodeUnknownEffect(IntentJson, { onExcessProperty: \"error\" });\nconst encodeIntent = Schema.encodeEffect(IntentJson);\n\nconst dispatchError = (operation: string) => (cause: unknown) =>\n Schema.is(WorkflowDispatchError)(cause)\n ? cause\n : new WorkflowDispatchError({\n operation,\n message: \"Workflow dispatch storage failed or contains incompatible data\",\n cause,\n });\n\nconst decodeRow = Effect.fn(\"SqlWorkflowDispatchStore.decodeRow\")(function* (value: unknown) {\n const row = yield* Schema.decodeUnknownEffect(StoredIntent, { onExcessProperty: \"error\" })(value);\n const intent = yield* decodeIntent(row.intent_json);\n\n if (\n row.deployment_id !== intent.deploymentId ||\n row.workflow_name !== intent.workflowName ||\n row.execution_id !== intent.executionId\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"decode\",\n message: \"Stored Workflow dispatch identity disagrees with its intent\",\n });\n }\n\n return intent;\n});\n\n/**\n * Durable dispatch outbox over an application-supplied SqlClient. This adapter uses\n * SQLite/PostgreSQL SQL syntax and is certified with SQLite. It does not own an engine\n * or a database connection. Agent admission, dispatch persistence, and native Workflow\n * storage are separate commits; the registered repair trigger closes those gaps.\n * Stored version or shape mismatches fail typed and require an explicit data reset.\n */\nexport class SqlWorkflowDispatchStore {\n static readonly layer: Layer.Layer<\n WorkflowDispatchStore,\n WorkflowDispatchError,\n SqlClient.SqlClient\n > = Layer.effect(WorkflowDispatchStore)(\n Effect.gen(function* () {\n const sql = (yield* SqlClient.SqlClient).withoutTransforms();\n\n yield* sql`\n CREATE TABLE IF NOT EXISTS effect_agent_workflow_dispatch (\n workflow_name TEXT NOT NULL,\n execution_id TEXT NOT NULL,\n deployment_id TEXT NOT NULL,\n intent_json TEXT NOT NULL,\n PRIMARY KEY (workflow_name, execution_id)\n )\n `;\n yield* sql`\n CREATE INDEX IF NOT EXISTS effect_agent_workflow_dispatch_scan\n ON effect_agent_workflow_dispatch (deployment_id, workflow_name, execution_id)\n `;\n\n const put = Effect.fn(\"SqlWorkflowDispatchStore.put\")(\n function* (input: WorkflowDispatchIntent) {\n const intent = yield* Schema.decodeEffect(WorkflowDispatchIntent)(input);\n const encoded = yield* encodeIntent(intent);\n\n yield* sql`\n INSERT INTO effect_agent_workflow_dispatch\n (workflow_name, execution_id, deployment_id, intent_json)\n VALUES (${intent.workflowName}, ${intent.executionId}, ${intent.deploymentId}, ${encoded})\n ON CONFLICT (workflow_name, execution_id) DO NOTHING\n `;\n\n const rows = yield* sql`\n SELECT deployment_id, workflow_name, execution_id, intent_json\n FROM effect_agent_workflow_dispatch\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n `;\n\n const existing = yield* decodeRow(rows[0]);\n\n const merged = new WorkflowDispatchIntent({\n ...intent,\n ...(existing.completionToken === undefined\n ? {}\n : { completionToken: existing.completionToken }),\n });\n\n if (\n (yield* encodeIntent(\n new WorkflowDispatchIntent({\n ...existing,\n ...(merged.completionToken === undefined\n ? {}\n : { completionToken: merged.completionToken }),\n }),\n )) !== (yield* encodeIntent(merged)) ||\n (intent.completionToken !== undefined &&\n existing.completionToken !== undefined &&\n intent.completionToken !== existing.completionToken)\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"put\",\n message: \"Workflow dispatch identity already belongs to a different immutable intent\",\n });\n }\n const retained = yield* encodeIntent(merged);\n const previous = yield* encodeIntent(existing);\n\n if (retained !== previous) {\n const updated = yield* sql`\n UPDATE effect_agent_workflow_dispatch SET intent_json = ${retained}\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n AND intent_json = ${previous}\n RETURNING execution_id\n `;\n\n if (updated.length !== 1) {\n return yield* new WorkflowDispatchError({\n operation: \"put\",\n message: \"Dispatch intent changed while attaching its completion token\",\n });\n }\n }\n\n return merged;\n },\n sql.withTransaction,\n Effect.mapError(dispatchError(\"put\")),\n );\n\n const scan = Effect.fn(\"SqlWorkflowDispatchStore.scan\")(\n function* (input: WorkflowDispatchScan) {\n const request = yield* Schema.decodeEffect(WorkflowDispatchScan)(input);\n\n const rows = yield* sql`\n SELECT deployment_id, workflow_name, execution_id, intent_json\n FROM effect_agent_workflow_dispatch\n WHERE deployment_id = ${request.deploymentId}\n AND workflow_name = ${request.workflowName}\n AND execution_id > ${request.after ?? \"\"}\n ORDER BY execution_id ASC\n LIMIT ${request.limit}\n `;\n\n return yield* Effect.forEach(rows, decodeRow);\n },\n Effect.mapError(dispatchError(\"scan\")),\n );\n\n const remove = Effect.fn(\"SqlWorkflowDispatchStore.remove\")(\n function* (input: WorkflowDispatchIntent) {\n const intent = yield* Schema.decodeEffect(WorkflowDispatchIntent)(input);\n\n const rows = yield* sql`\n SELECT deployment_id, workflow_name, execution_id, intent_json\n FROM effect_agent_workflow_dispatch\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n `;\n\n if (rows.length === 0) return;\n const existing = yield* decodeRow(rows[0]);\n\n if ((yield* encodeIntent(existing)) !== (yield* encodeIntent(intent))) {\n return yield* new WorkflowDispatchError({\n operation: \"remove\",\n message: \"Cannot remove a different immutable Workflow dispatch intent\",\n });\n }\n\n const removed = yield* sql`\n DELETE FROM effect_agent_workflow_dispatch\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n AND intent_json = ${yield* encodeIntent(intent)}\n RETURNING execution_id\n `;\n\n if (removed.length !== 1) {\n return yield* new WorkflowDispatchError({\n operation: \"remove\",\n message: \"Dispatch intent changed before cleanup\",\n });\n }\n },\n sql.withTransaction,\n Effect.mapError(dispatchError(\"remove\")),\n );\n\n return WorkflowDispatchStore.of({ put, scan, remove });\n }).pipe(Effect.mapError(dispatchError(\"initialize\"))),\n );\n}\n\nexport class NodeWorkflowRepairConfigError extends Schema.TaggedError<NodeWorkflowRepairConfigError>()(\n \"NodeWorkflowRepairConfigError\",\n { message: Schema.String },\n) {}\n\n/** A host-scoped startup and polling trigger. No ordinary Node agent worker is started. */\nexport class NodeWorkflowRepairTrigger {\n static layer(\n options: { readonly interval?: Duration.Input } = {},\n ): Layer.Layer<WorkflowRepairTrigger, NodeWorkflowRepairConfigError> {\n return Layer.effect(WorkflowRepairTrigger)(\n Effect.gen(function* () {\n const interval = Duration.fromInput(options.interval ?? \"1 second\");\n\n if (\n Option.isNone(interval) ||\n !Duration.isFinite(interval.value) ||\n !Duration.isPositive(interval.value)\n ) {\n return yield* new NodeWorkflowRepairConfigError({\n message: \"Workflow repair interval must be finite and greater than zero\",\n });\n }\n const delay = interval.value;\n\n return WorkflowRepairTrigger.of({\n register: Effect.fn(\"NodeWorkflowRepairTrigger.register\")(function* (repair) {\n const attempt = repair.pipe(\n Effect.catchCauseIf(\n (cause) => !Cause.hasInterruptsOnly(cause),\n (cause) =>\n Effect.logError(\"Workflow repair trigger failed; next poll will retry\", cause),\n ),\n );\n\n yield* attempt;\n yield* Effect.gen(function* () {\n while (true) {\n yield* Effect.sleep(delay);\n yield* attempt;\n }\n }).pipe(Effect.forkScoped);\n }),\n });\n }),\n );\n }\n}\n"],"mappings":";;;;AAUA,MAAM,eAAe,OAAO,OAAO;CACjC,eAAe,OAAO;CACtB,eAAe,OAAO;CACtB,cAAc,OAAO;CACrB,aAAa,OAAO;AACtB,CAAC;AAED,MAAM,aAAa,OAAO,eAAe,sBAAsB;AAC/D,MAAM,eAAe,OAAO,oBAAoB,YAAY,EAAE,kBAAkB,QAAQ,CAAC;AACzF,MAAM,eAAe,OAAO,aAAa,UAAU;AAEnD,MAAM,iBAAiB,eAAuB,UAC5C,OAAO,GAAG,qBAAqB,CAAC,CAAC,KAAK,IAClC,QACA,IAAI,sBAAsB;CACxB;CACA,SAAS;CACT;AACF,CAAC;AAEP,MAAM,YAAY,OAAO,GAAG,oCAAoC,CAAC,CAAC,WAAW,OAAgB;CAC3F,MAAM,MAAM,OAAO,OAAO,oBAAoB,cAAc,EAAE,kBAAkB,QAAQ,CAAC,CAAC,CAAC,KAAK;CAChG,MAAM,SAAS,OAAO,aAAa,IAAI,WAAW;CAElD,IACE,IAAI,kBAAkB,OAAO,gBAC7B,IAAI,kBAAkB,OAAO,gBAC7B,IAAI,iBAAiB,OAAO,aAE5B,OAAO,OAAO,IAAI,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AE;GAAK;GAAM;EAAO,CAAC;CACvD,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,cAAc,YAAY,CAAC,CAAC,CACtD;AACF;AAEA,IAAa,gCAAb,cAAmD,OAAO,YAA2C,CAAC,CACpG,iCACA,EAAE,SAAS,OAAO,OAAO,CAC3B,CAAC,CAAC,CAAC;;AAGH,IAAa,4BAAb,MAAuC;CACrC,OAAO,MACL,UAAkD,CAAC,GACgB;EACnE,OAAO,MAAM,OAAO,qBAAqB,CAAC,CACxC,OAAO,IAAI,aAAa;GACtB,MAAM,WAAW,SAAS,UAAU,QAAQ,YAAY,UAAU;GAElE,IACE,OAAO,OAAO,QAAQ,KACtB,CAAC,SAAS,SAAS,SAAS,KAAK,KACjC,CAAC,SAAS,WAAW,SAAS,KAAK,GAEnC,OAAO,OAAO,IAAI,8BAA8B,EAC9C,SAAS,gEACX,CAAC;GAEH,MAAM,QAAQ,SAAS;GAEvB,OAAO,sBAAsB,GAAG,EAC9B,UAAU,OAAO,GAAG,oCAAoC,CAAC,CAAC,WAAW,QAAQ;IAC3E,MAAM,UAAU,OAAO,KACrB,OAAO,cACJ,UAAU,CAAC,MAAM,kBAAkB,KAAK,IACxC,UACC,OAAO,SAAS,wDAAwD,KAAK,CACjF,CACF;IAEA,OAAO;IACP,OAAO,OAAO,IAAI,aAAa;KAC7B,OAAO,MAAM;MACX,OAAO,OAAO,MAAM,KAAK;MACzB,OAAO;KACT;IACF,CAAC,CAAC,CAAC,KAAK,OAAO,UAAU;GAC3B,CAAC,EACH,CAAC;EACH,CAAC,CACH;CACF;AACF"}
1
+ {"version":3,"file":"NodeWorkflow.mjs","names":[],"sources":["../src/NodeWorkflow.ts"],"sourcesContent":["import {\n WorkflowDispatchError,\n WorkflowDispatchIntent,\n WorkflowDispatchScan,\n WorkflowDispatchStore,\n WorkflowRepairTrigger,\n} from \"@effect-agent/workflow/workflow-dispatch\";\nimport { Cause, Duration, Effect, Layer, Option, Schema } from \"effect\";\nimport { SqlClient } from \"effect/unstable/sql\";\n\nconst StoredIntent = Schema.Struct({\n deployment_id: Schema.String,\n workflow_name: Schema.String,\n execution_id: Schema.String,\n intent_json: Schema.String,\n});\n\nconst IntentJson = Schema.fromJsonString(WorkflowDispatchIntent);\nconst decodeIntent = Schema.decodeUnknownEffect(IntentJson, { onExcessProperty: \"error\" });\nconst encodeIntent = Schema.encodeEffect(IntentJson);\n\nconst dispatchError = (operation: string) => (cause: unknown) =>\n Schema.is(WorkflowDispatchError)(cause)\n ? cause\n : new WorkflowDispatchError({\n operation,\n message: \"Workflow dispatch storage failed or contains incompatible data\",\n cause,\n });\n\nconst decodeRow = Effect.fn(\"SqlWorkflowDispatchStore.decodeRow\")(function* (value: unknown) {\n const row = yield* Schema.decodeUnknownEffect(StoredIntent, { onExcessProperty: \"error\" })(value);\n const intent = yield* decodeIntent(row.intent_json);\n\n if (\n row.deployment_id !== intent.deploymentId ||\n row.workflow_name !== intent.workflowName ||\n row.execution_id !== intent.executionId\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"decode\",\n message: \"Stored Workflow dispatch identity disagrees with its intent\",\n });\n }\n\n return intent;\n});\n\n/**\n * Durable dispatch outbox over an application-supplied SqlClient. This adapter uses\n * SQLite/PostgreSQL SQL syntax and is certified with SQLite. It does not own an engine\n * or a database connection. Agent admission, dispatch persistence, and native Workflow\n * storage are separate commits; the registered repair trigger closes those gaps.\n * Stored version or shape mismatches fail typed and require an explicit data reset.\n */\nexport class SqlWorkflowDispatchStore {\n static readonly layer: Layer.Layer<\n WorkflowDispatchStore,\n WorkflowDispatchError,\n SqlClient.SqlClient\n > = Layer.effect(WorkflowDispatchStore)(\n Effect.gen(function* () {\n const sql = (yield* SqlClient.SqlClient).withoutTransforms();\n\n yield* sql`\n CREATE TABLE IF NOT EXISTS effect_agent_workflow_dispatch (\n workflow_name TEXT NOT NULL,\n execution_id TEXT NOT NULL,\n deployment_id TEXT NOT NULL,\n intent_json TEXT NOT NULL,\n PRIMARY KEY (workflow_name, execution_id)\n )\n `;\n yield* sql`\n CREATE INDEX IF NOT EXISTS effect_agent_workflow_dispatch_scan\n ON effect_agent_workflow_dispatch (deployment_id, workflow_name, execution_id)\n `;\n\n const put = Effect.fn(\"SqlWorkflowDispatchStore.put\")(\n function* (input: WorkflowDispatchIntent) {\n const intent = yield* Schema.decodeEffect(WorkflowDispatchIntent)(input);\n const encoded = yield* encodeIntent(intent);\n\n yield* sql`\n INSERT INTO effect_agent_workflow_dispatch\n (workflow_name, execution_id, deployment_id, intent_json)\n VALUES (${intent.workflowName}, ${intent.executionId}, ${intent.deploymentId}, ${encoded})\n ON CONFLICT (workflow_name, execution_id) DO NOTHING\n `;\n\n const rows = yield* sql`\n SELECT deployment_id, workflow_name, execution_id, intent_json\n FROM effect_agent_workflow_dispatch\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n `;\n\n const existing = yield* decodeRow(rows[0]);\n\n const merged = new WorkflowDispatchIntent({\n ...intent,\n ...(existing.completionToken === undefined\n ? {}\n : { completionToken: existing.completionToken }),\n });\n\n if (\n (yield* encodeIntent(\n new WorkflowDispatchIntent({\n ...existing,\n ...(merged.completionToken === undefined\n ? {}\n : { completionToken: merged.completionToken }),\n }),\n )) !== (yield* encodeIntent(merged)) ||\n (intent.completionToken !== undefined &&\n existing.completionToken !== undefined &&\n intent.completionToken !== existing.completionToken)\n ) {\n return yield* new WorkflowDispatchError({\n operation: \"put\",\n message: \"Workflow dispatch identity already belongs to a different immutable intent\",\n });\n }\n const retained = yield* encodeIntent(merged);\n const previous = yield* encodeIntent(existing);\n\n if (retained !== previous) {\n const updated = yield* sql`\n UPDATE effect_agent_workflow_dispatch SET intent_json = ${retained}\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n AND intent_json = ${previous}\n RETURNING execution_id\n `;\n\n if (updated.length !== 1) {\n return yield* new WorkflowDispatchError({\n operation: \"put\",\n message: \"Dispatch intent changed while attaching its completion token\",\n });\n }\n }\n\n return merged;\n },\n sql.withTransaction,\n Effect.mapError(dispatchError(\"put\")),\n );\n\n const scan = Effect.fn(\"SqlWorkflowDispatchStore.scan\")(\n function* (input: WorkflowDispatchScan) {\n const request = yield* Schema.decodeEffect(WorkflowDispatchScan)(input);\n\n const rows = yield* sql`\n SELECT deployment_id, workflow_name, execution_id, intent_json\n FROM effect_agent_workflow_dispatch\n WHERE deployment_id = ${request.deploymentId}\n AND workflow_name = ${request.workflowName}\n AND execution_id > ${request.after ?? \"\"}\n ORDER BY execution_id ASC\n LIMIT ${request.limit}\n `;\n\n return yield* Effect.forEach(rows, decodeRow);\n },\n Effect.mapError(dispatchError(\"scan\")),\n );\n\n const remove = Effect.fn(\"SqlWorkflowDispatchStore.remove\")(\n function* (input: WorkflowDispatchIntent) {\n const intent = yield* Schema.decodeEffect(WorkflowDispatchIntent)(input);\n\n const rows = yield* sql`\n SELECT deployment_id, workflow_name, execution_id, intent_json\n FROM effect_agent_workflow_dispatch\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n `;\n\n if (rows.length === 0) return;\n const existing = yield* decodeRow(rows[0]);\n\n if ((yield* encodeIntent(existing)) !== (yield* encodeIntent(intent))) {\n return yield* new WorkflowDispatchError({\n operation: \"remove\",\n message: \"Cannot remove a different immutable Workflow dispatch intent\",\n });\n }\n\n const removed = yield* sql`\n DELETE FROM effect_agent_workflow_dispatch\n WHERE workflow_name = ${intent.workflowName} AND execution_id = ${intent.executionId}\n AND intent_json = ${yield* encodeIntent(intent)}\n RETURNING execution_id\n `;\n\n if (removed.length !== 1) {\n return yield* new WorkflowDispatchError({\n operation: \"remove\",\n message: \"Dispatch intent changed before cleanup\",\n });\n }\n },\n sql.withTransaction,\n Effect.mapError(dispatchError(\"remove\")),\n );\n\n return WorkflowDispatchStore.of({ put, scan, remove });\n }).pipe(Effect.mapError(dispatchError(\"initialize\"))),\n );\n}\n\nexport class NodeWorkflowRepairConfigError extends Schema.TaggedError<NodeWorkflowRepairConfigError>()(\n \"NodeWorkflowRepairConfigError\",\n { message: Schema.String },\n) {}\n\n/** A host-scoped startup and polling trigger. No ordinary Node agent worker is started. */\nexport class NodeWorkflowRepairTrigger {\n static layer(\n options: { readonly interval?: Duration.Input } = {},\n ): Layer.Layer<WorkflowRepairTrigger, NodeWorkflowRepairConfigError> {\n return Layer.effect(WorkflowRepairTrigger)(\n Effect.gen(function* () {\n const interval = Duration.fromInput(options.interval ?? \"1 second\");\n\n if (\n Option.isNone(interval) ||\n !Duration.isFinite(interval.value) ||\n !Duration.isPositive(interval.value)\n ) {\n return yield* new NodeWorkflowRepairConfigError({\n message: \"Workflow repair interval must be finite and greater than zero\",\n });\n }\n const delay = interval.value;\n\n return WorkflowRepairTrigger.of({\n register: Effect.fn(\"NodeWorkflowRepairTrigger.register\")(function* (repair) {\n const attempt = repair.pipe(\n Effect.catchCauseIf(\n (cause) => !Cause.hasInterruptsOnly(cause),\n (cause) =>\n Effect.logError(\"Workflow repair trigger failed; next poll will retry\", cause),\n ),\n );\n\n yield* attempt;\n yield* Effect.gen(function* () {\n while (true) {\n yield* Effect.sleep(delay);\n yield* attempt;\n }\n }).pipe(Effect.forkScoped);\n }),\n });\n }),\n );\n }\n}\n"],"mappings":";;;;AAUA,MAAM,eAAe,OAAO,OAAO;CACjC,eAAe,OAAO;CACtB,eAAe,OAAO;CACtB,cAAc,OAAO;CACrB,aAAa,OAAO;AACtB,CAAC;AAED,MAAM,aAAa,OAAO,eAAe,sBAAsB;AAC/D,MAAM,eAAe,OAAO,oBAAoB,YAAY,EAAE,kBAAkB,QAAQ,CAAC;AACzF,MAAM,eAAe,OAAO,aAAa,UAAU;AAEnD,MAAM,iBAAiB,eAAuB,UAC5C,OAAO,GAAG,qBAAqB,CAAC,CAAC,KAAK,IAClC,QACA,IAAI,sBAAsB;CACxB;CACA,SAAS;CACT;AACF,CAAC;AAEP,MAAM,YAAY,OAAO,GAAG,oCAAoC,CAAC,CAAC,WAAW,OAAgB;CAC3F,MAAM,MAAM,OAAO,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,5 +1,5 @@
1
- import { n as NodeWakeScheduler_d_exports } from "./NodeWakeScheduler-4ZeXYwPu.mjs";
2
- import { s as NodeDurableAgentRuntime_d_exports } from "./NodeDurableAgentRuntime-eTlQCxvz.mjs";
1
+ import { n as NodeWakeScheduler_d_exports } from "./NodeWakeScheduler-CCgm1t-G.mjs";
2
+ import { s as NodeDurableAgentRuntime_d_exports } from "./NodeDurableAgentRuntime-Cs_E9W_9.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/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-BMSajuQn.mjs";
3
+ import { r as NodeDurableHost_exports } from "./NodeDurableHost-CG2xAhfb.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.85","dependencies":{"@effect-agent/core":"0.1.0-beta.85","@effect-agent/engine":"0.1.0-beta.85","@effect-agent/storage-sqlite":"0.1.0-beta.85","@effect-agent/thread":"0.1.0-beta.85","@effect-agent/workflow":"0.1.0-beta.85","@effect/platform-node":"4.0.0-rc.112","@effect/sql-sqlite-node":"4.0.0-rc.112"},"devDependencies":{"@effect-agent/capabilities":"0.1.0-beta.85","@effect/vitest":"4.0.0-rc.112","effect":"4.0.0-rc.112","typescript":"7.0.2","vite-plus":"0.3.0"},"peerDependencies":{"effect":"^4.0.0-rc.112"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./NodeDurableAgentRuntime":{"types":"./dist/NodeDurableAgentRuntime.d.mts","default":"./dist/NodeDurableAgentRuntime.mjs"},"./NodeDurableHost":{"types":"./dist/NodeDurableHost.d.mts","default":"./dist/NodeDurableHost.mjs"},"./NodeScheduling":{"types":"./dist/NodeScheduling.d.mts","default":"./dist/NodeScheduling.mjs"},"./NodeSubscriptions":{"types":"./dist/NodeSubscriptions.d.mts","default":"./dist/NodeSubscriptions.mjs"},"./NodeWakeScheduler":{"types":"./dist/NodeWakeScheduler.d.mts","default":"./dist/NodeWakeScheduler.mjs"},"./NodeWorkflow":{"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"}}
1
+ {"name":"@effect-agent/platform-node","version":"0.1.0-beta.86","dependencies":{"@effect-agent/storage-sqlite":"0.1.0-beta.86","@effect-agent/workflow":"0.1.0-beta.86","@effect/platform-node":"4.0.0-rc.112","@effect/sql-sqlite-node":"4.0.0-rc.112","effect-agent":"0.1.0-beta.86"},"devDependencies":{"@effect/vitest":"4.0.0-rc.112","effect":"4.0.0-rc.112","typescript":"7.0.2","vite-plus":"0.3.0"},"peerDependencies":{"effect":"^4.0.0-rc.112"},"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"}}
@@ -1,59 +1,53 @@
1
- import { type SubmissionId } from "@effect-agent/core/Identifiers";
2
- import {
3
- CurrentToolFailureObserver,
4
- RunContextPreparationPassthrough,
5
- RunToolAuthorization,
6
- toolFailureObserverLayer,
7
- type RunContextPreparation,
8
- type RunCostEstimator,
9
- type RunToolFailureObserver,
10
- } from "@effect-agent/engine/RunOptions";
11
- import { messageDeliveryStoreLayer } from "@effect-agent/storage-sqlite/SqliteMessageDeliveryStore";
12
- import { scheduleStoreLayer } from "@effect-agent/storage-sqlite/SqliteScheduleStore";
1
+ import { messageDeliveryStoreLayer } from "@effect-agent/storage-sqlite/sqlite-message-delivery-store";
2
+ import { scheduleStoreLayer } from "@effect-agent/storage-sqlite/sqlite-schedule-store";
13
3
  import {
14
4
  SqliteStorageConfig,
15
5
  SqliteStorageConfigValue,
16
- } from "@effect-agent/storage-sqlite/SqliteStorageConfig";
6
+ } from "@effect-agent/storage-sqlite/sqlite-storage-config";
17
7
  import {
18
8
  type SqliteStorageFailpoint,
19
9
  type SqliteStorageFailpointHandler,
20
- } from "@effect-agent/storage-sqlite/SqliteStorageFailpoint";
21
- import { submissionLedgerLayer } from "@effect-agent/storage-sqlite/SqliteSubmissionLedger";
10
+ } from "@effect-agent/storage-sqlite/sqlite-storage-failpoint";
11
+ import { submissionLedgerLayer } from "@effect-agent/storage-sqlite/sqlite-submission-ledger";
22
12
  import {
23
13
  threadStoreLayer,
24
14
  storageFailpointLayer,
25
15
  type SqliteStorageInitializationError,
26
- } from "@effect-agent/storage-sqlite/SqliteThreadStore";
27
- import {
28
- type AgentRegistration,
29
- type ResolvedBinding,
30
- } from "@effect-agent/thread/AgentRegistration";
31
- import {
32
- DurableAgentRuntime,
33
- DurableRuntimeConfig,
34
- } from "@effect-agent/thread/DurableAgentRuntime";
16
+ } from "@effect-agent/storage-sqlite/sqlite-thread-store";
17
+ import { NodeCrypto } from "@effect/platform-node";
18
+ import { SqliteClient } from "@effect/sql-sqlite-node";
19
+ import { Context, type Crypto, Duration, Effect, Layer, Ref, Schema } from "effect";
20
+ import { type AgentRegistration, type ResolvedBinding } from "effect-agent/agent-registration";
21
+ import { DurableAgentRuntime, DurableRuntimeConfig } from "effect-agent/durable-agent-runtime";
35
22
  import {
36
23
  DurableRuntimeFailpoint,
37
24
  type DurableRuntimeFailpointHandler,
38
- } from "@effect-agent/thread/DurableFailpoint";
25
+ } from "effect-agent/durable-failpoint";
26
+ import { type SubmissionId } from "effect-agent/identifiers";
39
27
  import {
40
28
  type MessageDeliveryError,
41
29
  type MessageDeliveryStore,
42
- } from "@effect-agent/thread/MessageDelivery";
43
- import { DeploymentId, ProducerId } from "@effect-agent/thread/Records";
44
- import { type ScheduleStore } from "@effect-agent/thread/Schedule";
30
+ } from "effect-agent/message-delivery";
31
+ import { DeploymentId, ProducerId } from "effect-agent/records";
32
+ import {
33
+ CurrentToolFailureObserver,
34
+ RunContextPreparationPassthrough,
35
+ RunToolAuthorization,
36
+ toolFailureObserverLayer,
37
+ type RunContextPreparation,
38
+ type RunCostEstimator,
39
+ type RunToolFailureObserver,
40
+ } from "effect-agent/run-options";
41
+ import { type ScheduleStore } from "effect-agent/schedule";
45
42
  import {
46
43
  DEFAULT_OWNERSHIP_LEASE_DURATION,
47
44
  ReleaseOwnershipRequest,
48
45
  SubmissionLedger,
49
46
  type OwnershipToken,
50
- } from "@effect-agent/thread/SubmissionLedger";
51
- import { type ThreadStore } from "@effect-agent/thread/ThreadStore";
52
- import { ToolReconciler } from "@effect-agent/thread/ToolReconciler";
53
- import { type WakeScheduler } from "@effect-agent/thread/WakeScheduler";
54
- import { NodeCrypto } from "@effect/platform-node";
55
- import { SqliteClient } from "@effect/sql-sqlite-node";
56
- import { Context, type Crypto, Duration, Effect, Layer, Ref, Schema } from "effect";
47
+ } from "effect-agent/submission-ledger";
48
+ import { type ThreadStore } from "effect-agent/thread-store";
49
+ import { ToolReconciler } from "effect-agent/tool-reconciler";
50
+ import { type WakeScheduler } from "effect-agent/wake-scheduler";
57
51
  import type * as SqlClientService from "effect/unstable/sql/SqlClient";
58
52
 
59
53
  import { NodeWakeSchedulerConfig, nodeWakeSchedulerLayer } from "./NodeWakeScheduler.ts";
@@ -1,16 +1,17 @@
1
- import { type ThreadId, type SubmissionId } from "@effect-agent/core/Identifiers";
1
+ import { NodeCrypto } from "@effect/platform-node";
2
+ import { type Stream, Context, Effect, Fiber, Layer, Ref, Schema } from "effect";
2
3
  import {
3
4
  type IntegrityReport,
4
5
  type ObligationReport,
5
6
  type ObligationThresholds,
6
7
  type RecoveryExplanation,
7
8
  type RetryCommand,
8
- } from "@effect-agent/thread/Admin";
9
+ } from "effect-agent/admin";
9
10
  import {
10
11
  type AgentRegistration,
11
12
  type ResolvedBinding,
12
13
  type DurableBindingFailure,
13
- } from "@effect-agent/thread/AgentRegistration";
14
+ } from "effect-agent/agent-registration";
14
15
  import {
15
16
  DurableAgentRuntime,
16
17
  type DurableAbortFailure,
@@ -26,26 +27,22 @@ import {
26
27
  type DurableWorkerFailure,
27
28
  type Receipt,
28
29
  type RecoveryReport,
29
- } from "@effect-agent/thread/DurableAgentRuntime";
30
+ } from "effect-agent/durable-agent-runtime";
31
+ import { type ThreadId, type SubmissionId } from "effect-agent/identifiers";
30
32
  import {
31
33
  type MessageDeliveryStore,
32
34
  MessageDeliveryDriver,
33
35
  type MessageDeliveryError,
34
- } from "@effect-agent/thread/MessageDelivery";
35
- import { type OperationDenied } from "@effect-agent/thread/OperationAuthorizer";
36
- import { PreparedInputAdmission } from "@effect-agent/thread/PreparedInputAdmission";
37
- import { type CanonicalRecordEnvelope } from "@effect-agent/thread/Records";
36
+ } from "effect-agent/message-delivery";
37
+ import { type OperationDenied } from "effect-agent/operation-authorizer";
38
+ import { PreparedInputAdmission } from "effect-agent/prepared-input-admission";
39
+ import { type CanonicalRecordEnvelope } from "effect-agent/records";
38
40
  import {
39
41
  type AbortCommand,
40
42
  type AbortIntent,
41
43
  type Settlement,
42
- } from "@effect-agent/thread/SubmissionLedger";
43
- import {
44
- type ThreadNotMaterialized,
45
- type ThreadStoreError,
46
- } from "@effect-agent/thread/ThreadStore";
47
- import { NodeCrypto } from "@effect/platform-node";
48
- import { type Stream, Context, Effect, Fiber, Layer, Ref, Schema } from "effect";
44
+ } from "effect-agent/submission-ledger";
45
+ import { type ThreadNotMaterialized, type ThreadStoreError } from "effect-agent/thread-store";
49
46
 
50
47
  import { runNodeMessageDeliveries } from "./internal/message-delivery.ts";
51
48
  import { makeNodePreparedInputAdmission, NodeAdmission } from "./internal/prepared-admission.ts";
@@ -1,3 +1,5 @@
1
+ import { NodeCrypto } from "@effect/platform-node";
2
+ import { Cause, Duration, Effect, Layer, Option, PubSub, Result } from "effect";
1
3
  import {
2
4
  type ScheduleAuthorizer,
3
5
  type SchedulingLimits,
@@ -6,14 +8,8 @@ import {
6
8
  type ScheduleValidationError,
7
9
  ScheduleWake,
8
10
  defaultSchedulingLimits,
9
- } from "@effect-agent/thread/Schedule";
10
- import {
11
- type ScheduleProcessFailure,
12
- Scheduling,
13
- ScheduleDriver,
14
- } from "@effect-agent/thread/Scheduling";
15
- import { NodeCrypto } from "@effect/platform-node";
16
- import { Cause, Duration, Effect, Layer, Option, PubSub, Result } from "effect";
11
+ } from "effect-agent/schedule";
12
+ import { type ScheduleProcessFailure, Scheduling, ScheduleDriver } from "effect-agent/scheduling";
17
13
 
18
14
  import type { NodeDurableHost } from "./NodeDurableHost.ts";
19
15
  import { nodeScheduledInputAdmissionLayer } from "./NodeSubscriptions.ts";
@@ -1,6 +1,8 @@
1
- import { type EventSources } from "@effect-agent/thread/EventSource";
2
- import { PreparedInputAdmission } from "@effect-agent/thread/PreparedInputAdmission";
3
- import { type ScheduledEnvelope, ScheduledInputAdmission } from "@effect-agent/thread/Schedule";
1
+ import { NodeCrypto } from "@effect/platform-node";
2
+ import { Cause, Duration, Effect, Exit, Layer, Option } from "effect";
3
+ import { type EventSources } from "effect-agent/event-source";
4
+ import { PreparedInputAdmission } from "effect-agent/prepared-input-admission";
5
+ import { type ScheduledEnvelope, ScheduledInputAdmission } from "effect-agent/schedule";
4
6
  import {
5
7
  type PreparedInput,
6
8
  type SubscriptionAuthorizer,
@@ -9,15 +11,9 @@ import {
9
11
  type SubscriptionStoreFailure,
10
12
  SubscriptionStore,
11
13
  defaultSubscriptionLimits,
12
- } from "@effect-agent/thread/Subscription";
13
- import { type SubscriptionInputBindings } from "@effect-agent/thread/SubscriptionInput";
14
- import {
15
- SubscriptionDriver,
16
- SubscriptionIntake,
17
- Subscriptions,
18
- } from "@effect-agent/thread/Subscriptions";
19
- import { NodeCrypto } from "@effect/platform-node";
20
- import { Cause, Duration, Effect, Exit, Layer, Option } from "effect";
14
+ } from "effect-agent/subscription";
15
+ import { type SubscriptionInputBindings } from "effect-agent/subscription-input";
16
+ import { SubscriptionDriver, SubscriptionIntake, Subscriptions } from "effect-agent/subscriptions";
21
17
 
22
18
  import { makeNodePreparedInputAdmission, NodeAdmission } from "./internal/prepared-admission.ts";
23
19
  import { NodeDurableHost } from "./NodeDurableHost.ts";
@@ -1,8 +1,8 @@
1
- import { type ThreadId } from "@effect-agent/core/Identifiers";
2
- import { SubmissionLedger } from "@effect-agent/thread/SubmissionLedger";
3
- import { makeWakeSubscriptionHub, WakeScheduler } from "@effect-agent/thread/WakeScheduler";
4
1
  import type { Duration } from "effect";
5
2
  import { Context, Effect, Layer, PubSub, Stream } from "effect";
3
+ import { type ThreadId } from "effect-agent/identifiers";
4
+ import { SubmissionLedger } from "effect-agent/submission-ledger";
5
+ import { makeWakeSubscriptionHub, WakeScheduler } from "effect-agent/wake-scheduler";
6
6
 
7
7
  /**
8
8
  * Bounded in-process wake buffer. Wake hints are droppable by contract (the ledger-scan fallback
@@ -4,7 +4,7 @@ import {
4
4
  WorkflowDispatchScan,
5
5
  WorkflowDispatchStore,
6
6
  WorkflowRepairTrigger,
7
- } from "@effect-agent/workflow/WorkflowDispatch";
7
+ } from "@effect-agent/workflow/workflow-dispatch";
8
8
  import { Cause, Duration, Effect, Layer, Option, Schema } from "effect";
9
9
  import { SqlClient } from "effect/unstable/sql";
10
10
 
@@ -1,9 +1,9 @@
1
+ import { Cause, Clock, Effect, Exit, Option } from "effect";
1
2
  import {
2
3
  MessageDeliveryDriver,
3
4
  type MessageDeliveryFailure,
4
5
  MessageDeliveryStore,
5
- } from "@effect-agent/thread/MessageDelivery";
6
- import { Cause, Clock, Effect, Exit, Option } from "effect";
6
+ } from "effect-agent/message-delivery";
7
7
 
8
8
  const reportFailure = (cause: Cause.Cause<MessageDeliveryFailure>): Effect.Effect<void> =>
9
9
  Cause.hasInterruptsOnly(cause)
@@ -1,13 +1,13 @@
1
- import { type AgentId } from "@effect-agent/core/Identifiers";
2
- import { type DurableSubmitAgent } from "@effect-agent/thread/DurableAgentRuntime";
3
- import { PreparedInputAdmission } from "@effect-agent/thread/PreparedInputAdmission";
4
- import { PersistedJson } from "@effect-agent/thread/Records";
1
+ import { Context, Effect } from "effect";
2
+ import { type DurableSubmitAgent } from "effect-agent/durable-agent-runtime";
3
+ import { type AgentId } from "effect-agent/identifiers";
4
+ import { PreparedInputAdmission } from "effect-agent/prepared-input-admission";
5
+ import { PersistedJson } from "effect-agent/records";
5
6
  import {
6
7
  ScheduledInputRetryable,
7
8
  ScheduledInputRefused,
8
9
  ScheduleStorageError,
9
- } from "@effect-agent/thread/Schedule";
10
- import { Context, Effect } from "effect";
10
+ } from "effect-agent/schedule";
11
11
 
12
12
  import { type NodeDurableHost } from "../NodeDurableHost.ts";
13
13