@dudousxd/nestjs-durable 0.68.0 → 0.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1050,9 +1050,11 @@ interface DurableModuleSharedOptions {
1050
1050
  * inspects its shape.
1051
1051
  *
1052
1052
  * **Auto-feed**: if you omit this AND `@dudousxd/nestjs-context` is installed (its accessor is bound
1053
- * to the shared `CONTEXT_ACCESSOR` token), DurableModule defaults this to a reader that builds
1054
- * `{ traceId, tenantId, userRef }` from the accessor — so a workflow dispatched within a request
1055
- * automatically carries the originating context across process boundaries. Pass your own reader to
1053
+ * to the shared `CONTEXT_ACCESSOR` token), DurableModule defaults this to nestjs-context's
1054
+ * `Context.serialize()` — the fields its `carrier: [...]` allowlist names, `traceId`, `tenantId` and
1055
+ * `userRef` by default — so a workflow dispatched within a request automatically carries the
1056
+ * originating context across process boundaries, and nothing the allowlist leaves out reaches the
1057
+ * broker. (An app's own accessor bound to the token is read directly instead.) Pass your own reader to
1056
1058
  * override the auto-feed; with neither, the carrier is omitted (unchanged behavior).
1057
1059
  *
1058
1060
  * Re-evaluated at each (re)dispatch — including a retry or a crash/scale-down resume that the engine
@@ -1108,7 +1110,8 @@ interface DurableModuleSharedOptions {
1108
1110
  /**
1109
1111
  * How many tasks a worker role's co-located/thin consumer runs concurrently PER SUBSCRIBED QUEUE
1110
1112
  * (BullMQ Worker concurrency — the same limit is applied to every per-name queue the single
1111
- * `runRedisWorker` call starts). Defaults to 1. Raise it so a fanned-out batch (e.g. the N remote
1113
+ * `runRedisWorker` call starts, except the names {@link concurrencyByHandler} overrides).
1114
+ * Defaults to 1. Raise it so a fanned-out batch (e.g. the N remote
1112
1115
  * steps of a `gather`) runs in parallel instead of serially.
1113
1116
  *
1114
1117
  * Pass `'adaptive'` (or `{ mode:'adaptive', ... }`) to let the consumer self-tune its concurrency
@@ -1117,10 +1120,13 @@ interface DurableModuleSharedOptions {
1117
1120
  */
1118
1121
  concurrency?: ConcurrencyOption;
1119
1122
  /**
1120
- * Per-handler concurrency override, keyed by workflow/step NAME. Falls back to {@link concurrency}
1121
- * (then 1). NOT YET WIRED THROUGH: `runRedisWorker` (`@dudousxd/durable-worker`) currently applies
1122
- * one {@link concurrency} limit uniformly across every per-name queue it subscribes to from a
1123
- * single call — reserved here for when per-name concurrency lands there.
1123
+ * Per-handler concurrency override for a worker role's consumer (co-located or thin), keyed by
1124
+ * the exact `@Workflow({ name })` / `@Step(name)` string, namespace included (e.g.
1125
+ * `'agent.opencode.run'`, never the sanitized queue token): that name's queue runs at this limit,
1126
+ * every other queue at {@link concurrency} (then 1). A number or an adaptive config; an
1127
+ * overridden queue runs on its own controller and reports its own status on the heartbeat. A
1128
+ * name this process does not register is ignored, with one warning per name per process.
1129
+ * Ignored for a plain operator.
1124
1130
  */
1125
1131
  concurrencyByHandler?: Record<string, ConcurrencyOption>;
1126
1132
  /**
package/dist/index.d.ts CHANGED
@@ -1050,9 +1050,11 @@ interface DurableModuleSharedOptions {
1050
1050
  * inspects its shape.
1051
1051
  *
1052
1052
  * **Auto-feed**: if you omit this AND `@dudousxd/nestjs-context` is installed (its accessor is bound
1053
- * to the shared `CONTEXT_ACCESSOR` token), DurableModule defaults this to a reader that builds
1054
- * `{ traceId, tenantId, userRef }` from the accessor — so a workflow dispatched within a request
1055
- * automatically carries the originating context across process boundaries. Pass your own reader to
1053
+ * to the shared `CONTEXT_ACCESSOR` token), DurableModule defaults this to nestjs-context's
1054
+ * `Context.serialize()` — the fields its `carrier: [...]` allowlist names, `traceId`, `tenantId` and
1055
+ * `userRef` by default — so a workflow dispatched within a request automatically carries the
1056
+ * originating context across process boundaries, and nothing the allowlist leaves out reaches the
1057
+ * broker. (An app's own accessor bound to the token is read directly instead.) Pass your own reader to
1056
1058
  * override the auto-feed; with neither, the carrier is omitted (unchanged behavior).
1057
1059
  *
1058
1060
  * Re-evaluated at each (re)dispatch — including a retry or a crash/scale-down resume that the engine
@@ -1108,7 +1110,8 @@ interface DurableModuleSharedOptions {
1108
1110
  /**
1109
1111
  * How many tasks a worker role's co-located/thin consumer runs concurrently PER SUBSCRIBED QUEUE
1110
1112
  * (BullMQ Worker concurrency — the same limit is applied to every per-name queue the single
1111
- * `runRedisWorker` call starts). Defaults to 1. Raise it so a fanned-out batch (e.g. the N remote
1113
+ * `runRedisWorker` call starts, except the names {@link concurrencyByHandler} overrides).
1114
+ * Defaults to 1. Raise it so a fanned-out batch (e.g. the N remote
1112
1115
  * steps of a `gather`) runs in parallel instead of serially.
1113
1116
  *
1114
1117
  * Pass `'adaptive'` (or `{ mode:'adaptive', ... }`) to let the consumer self-tune its concurrency
@@ -1117,10 +1120,13 @@ interface DurableModuleSharedOptions {
1117
1120
  */
1118
1121
  concurrency?: ConcurrencyOption;
1119
1122
  /**
1120
- * Per-handler concurrency override, keyed by workflow/step NAME. Falls back to {@link concurrency}
1121
- * (then 1). NOT YET WIRED THROUGH: `runRedisWorker` (`@dudousxd/durable-worker`) currently applies
1122
- * one {@link concurrency} limit uniformly across every per-name queue it subscribes to from a
1123
- * single call — reserved here for when per-name concurrency lands there.
1123
+ * Per-handler concurrency override for a worker role's consumer (co-located or thin), keyed by
1124
+ * the exact `@Workflow({ name })` / `@Step(name)` string, namespace included (e.g.
1125
+ * `'agent.opencode.run'`, never the sanitized queue token): that name's queue runs at this limit,
1126
+ * every other queue at {@link concurrency} (then 1). A number or an adaptive config; an
1127
+ * overridden queue runs on its own controller and reports its own status on the heartbeat. A
1128
+ * name this process does not register is ignored, with one warning per name per process.
1129
+ * Ignored for a plain operator.
1124
1130
  */
1125
1131
  concurrencyByHandler?: Record<string, ConcurrencyOption>;
1126
1132
  /**
package/dist/index.js CHANGED
@@ -931,7 +931,102 @@ __name(tenantUnsupported, "tenantUnsupported");
931
931
  // src/durable-worker.module.ts
932
932
  import { DURABLE_OPTIONS_CANONICAL, WorkflowEngine as WorkflowEngine2, bindWorkflowClass, resolveTenantToken as resolveTenantToken2, workflowName as workflowName3 } from "@dudousxd/nestjs-durable-core";
933
933
  import { Inject, Injectable as Injectable3 } from "@nestjs/common";
934
- import { DiscoveryService, MetadataScanner } from "@nestjs/core";
934
+ import { DiscoveryService, MetadataScanner, ModuleRef } from "@nestjs/core";
935
+
936
+ // src/tokens.ts
937
+ import { RunGateway } from "@dudousxd/nestjs-durable-core";
938
+ var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
939
+ var TENANT_AUTH = Symbol("nestjs-durable:tenant-auth");
940
+ var RUN_GATEWAY = RunGateway;
941
+
942
+ // src/context-runtime.ts
943
+ function resolveAccessor(moduleRef) {
944
+ try {
945
+ return moduleRef.get(CONTEXT_ACCESSOR, {
946
+ strict: false
947
+ });
948
+ } catch {
949
+ return void 0;
950
+ }
951
+ }
952
+ __name(resolveAccessor, "resolveAccessor");
953
+ function contextSlotPresent() {
954
+ const slot = globalThis[Symbol.for("@dudousxd/nestjs-diagnostics:accessor")];
955
+ return !!slot?.current;
956
+ }
957
+ __name(contextSlotPresent, "contextSlotPresent");
958
+ function isContextRuntime(x) {
959
+ return !!x && typeof x.deserialize === "function";
960
+ }
961
+ __name(isContextRuntime, "isContextRuntime");
962
+ async function resolveContextRuntime() {
963
+ try {
964
+ const specifier = "@dudousxd/nestjs-context";
965
+ const mod = await import(specifier);
966
+ return isContextRuntime(mod.Context) ? mod.Context : void 0;
967
+ } catch {
968
+ return void 0;
969
+ }
970
+ }
971
+ __name(resolveContextRuntime, "resolveContextRuntime");
972
+ async function resolveContextSerializer(accessor) {
973
+ try {
974
+ const specifier = "@dudousxd/nestjs-context";
975
+ const mod = await import(specifier);
976
+ const serialize = mod.Context?.serialize;
977
+ if (typeof serialize !== "function" || mod.contextAccessor !== accessor) return void 0;
978
+ return () => serialize.call(mod.Context);
979
+ } catch {
980
+ return void 0;
981
+ }
982
+ }
983
+ __name(resolveContextSerializer, "resolveContextSerializer");
984
+ var CONTEXT_MODULE_OPTIONS = Symbol.for("@dudousxd/nestjs-context:options");
985
+ function contextHasCustomSerialize(moduleRef) {
986
+ try {
987
+ const options = moduleRef.get(CONTEXT_MODULE_OPTIONS, {
988
+ strict: false
989
+ });
990
+ return typeof options?.serialize === "function";
991
+ } catch {
992
+ return false;
993
+ }
994
+ }
995
+ __name(contextHasCustomSerialize, "contextHasCustomSerialize");
996
+ function rehydrateBridge(runtime) {
997
+ return (carrier, fn) => carrier && Object.keys(carrier).length > 0 ? runtime.deserialize(carrier, fn) : fn();
998
+ }
999
+ __name(rehydrateBridge, "rehydrateBridge");
1000
+ async function resolveContextRehydrate(moduleRef) {
1001
+ if (resolveAccessor(moduleRef) === void 0) return void 0;
1002
+ const runtime = await resolveContextRuntime();
1003
+ return runtime ? rehydrateBridge(runtime) : void 0;
1004
+ }
1005
+ __name(resolveContextRehydrate, "resolveContextRehydrate");
1006
+ function carrierFromContext(accessor, serialize, customSerialize) {
1007
+ if (serialize) {
1008
+ const carrier2 = {
1009
+ ...serialize() ?? {}
1010
+ };
1011
+ for (const key of Object.keys(carrier2)) if (carrier2[key] === void 0) delete carrier2[key];
1012
+ const tenant2 = customSerialize ? void 0 : accessor.tenant?.();
1013
+ if (carrier2.tenantId !== void 0 && tenant2 !== void 0 && tenant2.source !== "legacy") {
1014
+ carrier2.tenant = tenant2;
1015
+ }
1016
+ return carrier2;
1017
+ }
1018
+ const carrier = {};
1019
+ const traceId = accessor.traceId();
1020
+ if (traceId !== void 0) carrier.traceId = traceId;
1021
+ const tenantId = accessor.tenantId();
1022
+ if (tenantId !== void 0) carrier.tenantId = tenantId;
1023
+ const tenant = accessor.tenant?.();
1024
+ if (tenant !== void 0 && tenant.source !== "legacy") carrier.tenant = tenant;
1025
+ const userRef = accessor.userRef();
1026
+ if (userRef !== void 0) carrier.userRef = userRef;
1027
+ return carrier;
1028
+ }
1029
+ __name(carrierFromContext, "carrierFromContext");
935
1030
 
936
1031
  // src/schema-parse.ts
937
1032
  import { SchemaValidationError } from "@dudousxd/nestjs-durable-core";
@@ -1256,12 +1351,6 @@ function isStepInterceptor(target) {
1256
1351
  }
1257
1352
  __name(isStepInterceptor, "isStepInterceptor");
1258
1353
 
1259
- // src/tokens.ts
1260
- import { RunGateway } from "@dudousxd/nestjs-durable-core";
1261
- var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
1262
- var TENANT_AUTH = Symbol("nestjs-durable:tenant-auth");
1263
- var RUN_GATEWAY = RunGateway;
1264
-
1265
1354
  // src/durable-worker.module.ts
1266
1355
  function _ts_decorate3(decorators, target, key, desc) {
1267
1356
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1481,6 +1570,9 @@ var ThinWorkerBootstrap = class {
1481
1570
  ...options.concurrency !== void 0 ? {
1482
1571
  concurrency: options.concurrency
1483
1572
  } : {},
1573
+ ...options.concurrencyByHandler !== void 0 ? {
1574
+ concurrencyByHandler: options.concurrencyByHandler
1575
+ } : {},
1484
1576
  ...options.lockDuration !== void 0 ? {
1485
1577
  lockDuration: options.lockDuration
1486
1578
  } : {},
@@ -1586,16 +1678,24 @@ function thinWorkerProviders() {
1586
1678
  // The role gate lives HERE, not just in the consumers: constructing the runtime resolves the
1587
1679
  // optional `@dudousxd/durable-worker` peer, so an operator that never runs a worker must not
1588
1680
  // reach this branch at all.
1589
- useFactory: /* @__PURE__ */ __name((options) => isPureThinWorker(options) ? createWorkerRuntime({
1590
- workflowGroup: options.partition ?? "",
1591
- // The worker unwinds a failed turn's `localStep` undos itself, so it takes the
1592
- // module's `compensationRetries` as the engine does.
1593
- ...options.compensationRetries !== void 0 ? {
1594
- compensationRetries: options.compensationRetries
1595
- } : {}
1596
- }) : null, "useFactory"),
1681
+ useFactory: /* @__PURE__ */ __name(async (options, moduleRef) => {
1682
+ if (!isPureThinWorker(options)) return null;
1683
+ const rehydrate = await resolveContextRehydrate(moduleRef);
1684
+ return createWorkerRuntime({
1685
+ workflowGroup: options.partition ?? "",
1686
+ // The worker unwinds a failed turn's `localStep` undos itself, so it takes the
1687
+ // module's `compensationRetries` as the engine does.
1688
+ ...options.compensationRetries !== void 0 ? {
1689
+ compensationRetries: options.compensationRetries
1690
+ } : {},
1691
+ ...rehydrate !== void 0 ? {
1692
+ rehydrate
1693
+ } : {}
1694
+ });
1695
+ }, "useFactory"),
1597
1696
  inject: [
1598
- DURABLE_OPTIONS_CANONICAL
1697
+ DURABLE_OPTIONS_CANONICAL,
1698
+ ModuleRef
1599
1699
  ]
1600
1700
  },
1601
1701
  {
@@ -1667,7 +1767,7 @@ __name(unavailableRunGateway, "unavailableRunGateway");
1667
1767
  // src/durable.module.ts
1668
1768
  import { DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL8, RunGateway as RunGateway2, STATE_STORE, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL4, TRANSPORT, TRANSPORT_CANONICAL as TRANSPORT_CANONICAL3, WorkflowEngine as WorkflowEngine7, sealDurableCopies, useDurableExecution } from "@dudousxd/nestjs-durable-core";
1669
1769
  import { Inject as Inject9, Injectable as Injectable13, Module } from "@nestjs/common";
1670
- import { DiscoveryModule, ModuleRef as ModuleRef2 } from "@nestjs/core";
1770
+ import { DiscoveryModule, ModuleRef as ModuleRef4 } from "@nestjs/core";
1671
1771
 
1672
1772
  // src/durable-step.registrar.ts
1673
1773
  import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL2, TRANSPORT_CANONICAL } from "@dudousxd/nestjs-durable-core";
@@ -1752,7 +1852,7 @@ DurableStepRegistrar = _ts_decorate4([
1752
1852
  // src/in-app-worker.ts
1753
1853
  import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL3, TRANSPORT_CANONICAL as TRANSPORT_CANONICAL2 } from "@dudousxd/nestjs-durable-core";
1754
1854
  import { Inject as Inject3, Injectable as Injectable5 } from "@nestjs/common";
1755
- import { DiscoveryService as DiscoveryService3, MetadataScanner as MetadataScanner3 } from "@nestjs/core";
1855
+ import { DiscoveryService as DiscoveryService3, MetadataScanner as MetadataScanner3, ModuleRef as ModuleRef2 } from "@nestjs/core";
1756
1856
  function _ts_decorate5(decorators, target, key, desc) {
1757
1857
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1758
1858
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1845,6 +1945,9 @@ var InAppWorkerBootstrap = class {
1845
1945
  ...options.concurrency !== void 0 ? {
1846
1946
  concurrency: options.concurrency
1847
1947
  } : {},
1948
+ ...options.concurrencyByHandler !== void 0 ? {
1949
+ concurrencyByHandler: options.concurrencyByHandler
1950
+ } : {},
1848
1951
  ...options.lockDuration !== void 0 ? {
1849
1952
  lockDuration: options.lockDuration
1850
1953
  } : {},
@@ -1901,16 +2004,24 @@ function inAppWorkerProviders() {
1901
2004
  // The role gate lives HERE, not just in the consumer: constructing the runtime resolves the
1902
2005
  // optional `@dudousxd/durable-worker` peer, so an operator that never runs a worker must not
1903
2006
  // reach this branch at all.
1904
- useFactory: /* @__PURE__ */ __name((options) => isCoLocatedWorker(options) ? createWorkerRuntime({
1905
- workflowGroup: options.partition ?? "",
1906
- // The worker unwinds a failed turn's `localStep` undos itself, so it takes the
1907
- // module's `compensationRetries` as the engine does.
1908
- ...options.compensationRetries !== void 0 ? {
1909
- compensationRetries: options.compensationRetries
1910
- } : {}
1911
- }) : null, "useFactory"),
2007
+ useFactory: /* @__PURE__ */ __name(async (options, moduleRef) => {
2008
+ if (!isCoLocatedWorker(options)) return null;
2009
+ const rehydrate = await resolveContextRehydrate(moduleRef);
2010
+ return createWorkerRuntime({
2011
+ workflowGroup: options.partition ?? "",
2012
+ // The worker unwinds a failed turn's `localStep` undos itself, so it takes the
2013
+ // module's `compensationRetries` as the engine does.
2014
+ ...options.compensationRetries !== void 0 ? {
2015
+ compensationRetries: options.compensationRetries
2016
+ } : {},
2017
+ ...rehydrate !== void 0 ? {
2018
+ rehydrate
2019
+ } : {}
2020
+ });
2021
+ }, "useFactory"),
1912
2022
  inject: [
1913
- DURABLE_OPTIONS_CANONICAL3
2023
+ DURABLE_OPTIONS_CANONICAL3,
2024
+ ModuleRef2
1914
2025
  ]
1915
2026
  },
1916
2027
  {
@@ -2935,7 +3046,7 @@ __name(settleWithin, "settleWithin");
2935
3046
  // src/sweep-leases.ts
2936
3047
  import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL4 } from "@dudousxd/nestjs-durable-core";
2937
3048
  import { Inject as Inject4, Injectable as Injectable7, Logger, Optional } from "@nestjs/common";
2938
- import { ModuleRef } from "@nestjs/core";
3049
+ import { ModuleRef as ModuleRef3 } from "@nestjs/core";
2939
3050
  function _ts_decorate7(decorators, target, key, desc) {
2940
3051
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2941
3052
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3034,7 +3145,7 @@ SweepLeases = _ts_decorate7([
3034
3145
  _ts_param4(1, Inject4(DURABLE_OPTIONS_CANONICAL4)),
3035
3146
  _ts_metadata7("design:type", Function),
3036
3147
  _ts_metadata7("design:paramtypes", [
3037
- typeof ModuleRef === "undefined" ? Object : ModuleRef,
3148
+ typeof ModuleRef3 === "undefined" ? Object : ModuleRef3,
3038
3149
  typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
3039
3150
  ])
3040
3151
  ], SweepLeases);
@@ -4347,48 +4458,6 @@ function _ts_param9(paramIndex, decorator) {
4347
4458
  };
4348
4459
  }
4349
4460
  __name(_ts_param9, "_ts_param");
4350
- function resolveAccessor(moduleRef) {
4351
- try {
4352
- return moduleRef.get(CONTEXT_ACCESSOR, {
4353
- strict: false
4354
- });
4355
- } catch {
4356
- return void 0;
4357
- }
4358
- }
4359
- __name(resolveAccessor, "resolveAccessor");
4360
- function carrierFromAccessor(accessor) {
4361
- const carrier = {};
4362
- const traceId = accessor.traceId();
4363
- if (traceId !== void 0) carrier.traceId = traceId;
4364
- const tenantId = accessor.tenantId();
4365
- if (tenantId !== void 0) carrier.tenantId = tenantId;
4366
- const tenant = accessor.tenant?.();
4367
- if (tenant !== void 0 && tenant.source !== "legacy") carrier.tenant = tenant;
4368
- const userRef = accessor.userRef();
4369
- if (userRef !== void 0) carrier.userRef = userRef;
4370
- return carrier;
4371
- }
4372
- __name(carrierFromAccessor, "carrierFromAccessor");
4373
- function contextSlotPresent() {
4374
- const slot = globalThis[Symbol.for("@dudousxd/nestjs-diagnostics:accessor")];
4375
- return !!slot?.current;
4376
- }
4377
- __name(contextSlotPresent, "contextSlotPresent");
4378
- function isContextRuntime(x) {
4379
- return !!x && typeof x.deserialize === "function";
4380
- }
4381
- __name(isContextRuntime, "isContextRuntime");
4382
- async function resolveContextRuntime() {
4383
- try {
4384
- const specifier = "@dudousxd/nestjs-context";
4385
- const mod = await import(specifier);
4386
- return isContextRuntime(mod.Context) ? mod.Context : void 0;
4387
- } catch {
4388
- return void 0;
4389
- }
4390
- }
4391
- __name(resolveContextRuntime, "resolveContextRuntime");
4392
4461
  function isControlPlane(x) {
4393
4462
  return !!x && typeof x.publishControl === "function" && typeof x.onControl === "function";
4394
4463
  }
@@ -4588,7 +4657,7 @@ DurableTenancyBridge = _ts_decorate13([
4588
4657
  _ts_metadata13("design:type", Function),
4589
4658
  _ts_metadata13("design:paramtypes", [
4590
4659
  typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
4591
- typeof ModuleRef2 === "undefined" ? Object : ModuleRef2
4660
+ typeof ModuleRef4 === "undefined" ? Object : ModuleRef4
4592
4661
  ])
4593
4662
  ], DurableTenancyBridge);
4594
4663
  var DurableModule = class _DurableModule {
@@ -4654,7 +4723,7 @@ var DurableModule = class _DurableModule {
4654
4723
  }), "useFactory"),
4655
4724
  inject: [
4656
4725
  DURABLE_OPTIONS_CANONICAL8,
4657
- ModuleRef2
4726
+ ModuleRef4
4658
4727
  ]
4659
4728
  },
4660
4729
  // Deprecated tokens that published releases still import resolve to the same instances:
@@ -4706,10 +4775,12 @@ var DurableModule = class _DurableModule {
4706
4775
  }
4707
4776
  const primary = transport ?? options.transports?.[0]?.transport;
4708
4777
  const accessor = resolveAccessor(moduleRef);
4709
- const context = options.context ?? (accessor ? () => carrierFromAccessor(accessor) : void 0);
4710
4778
  const runtimeNeeded = accessor !== void 0 || contextSlotPresent();
4711
4779
  const runtime = runtimeNeeded ? await resolveContextRuntime() : void 0;
4712
- const rehydrate = runtime && ((carrier, fn) => carrier && Object.keys(carrier).length > 0 ? runtime.deserialize(carrier, fn) : fn());
4780
+ const rehydrate = runtime && rehydrateBridge(runtime);
4781
+ const serialize = options.context === void 0 && accessor ? await resolveContextSerializer(accessor) : void 0;
4782
+ const customSerialize = contextHasCustomSerialize(moduleRef);
4783
+ const context = options.context ?? (accessor ? () => carrierFromContext(accessor, serialize, customSerialize) : void 0);
4713
4784
  if (options.consumers === false) {
4714
4785
  for (const t of [
4715
4786
  transport,
@@ -4770,7 +4841,7 @@ var DurableModule = class _DurableModule {
4770
4841
  DURABLE_OPTIONS_CANONICAL8,
4771
4842
  STATE_STORE_CANONICAL4,
4772
4843
  TRANSPORT_CANONICAL3,
4773
- ModuleRef2,
4844
+ ModuleRef4,
4774
4845
  TENANT_AUTH
4775
4846
  ]
4776
4847
  },
@@ -4800,7 +4871,7 @@ var DurableModule = class _DurableModule {
4800
4871
  STATE_STORE_CANONICAL4,
4801
4872
  WorkflowEngine7,
4802
4873
  TENANT_AUTH,
4803
- ModuleRef2
4874
+ ModuleRef4
4804
4875
  ]
4805
4876
  },
4806
4877
  RunGatewayBootstrap,