@hatchet-dev/typescript-sdk 1.15.2 → 1.17.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.
Files changed (202) hide show
  1. package/README.md +14 -2
  2. package/clients/admin/admin-client.d.ts +2 -2
  3. package/clients/admin/admin-client.js +8 -9
  4. package/clients/dispatcher/action-listener.d.ts +3 -6
  5. package/clients/dispatcher/action-listener.js +54 -23
  6. package/clients/dispatcher/dispatcher-client.js +5 -8
  7. package/clients/dispatcher/heartbeat/heartbeat-worker.js +7 -4
  8. package/clients/event/event-client.d.ts +2 -2
  9. package/clients/event/event-client.js +5 -11
  10. package/clients/hatchet-client/hatchet-logger.js +8 -17
  11. package/clients/listeners/durable-listener/durable-listener-client.d.ts +115 -15
  12. package/clients/listeners/durable-listener/durable-listener-client.js +769 -19
  13. package/clients/listeners/durable-listener/pooled-durable-listener-client.js +11 -22
  14. package/clients/listeners/run-listener/child-listener-client.d.ts +1 -1
  15. package/clients/listeners/run-listener/child-listener-client.js +34 -30
  16. package/clients/listeners/run-listener/pooled-child-listener-client.js +9 -19
  17. package/clients/rest/generated/Api.d.ts +25 -1
  18. package/clients/rest/generated/Api.js +20 -0
  19. package/clients/rest/generated/data-contracts.d.ts +60 -1
  20. package/clients/rest/generated/data-contracts.js +9 -1
  21. package/legacy/examples/affinity-workers.js +2 -3
  22. package/legacy/examples/byo-logger.js +0 -2
  23. package/legacy/examples/concurrency/cancel-in-progress/concurrency-worker.js +4 -2
  24. package/legacy/examples/concurrency/group-round-robin/concurrency-event.js +0 -1
  25. package/legacy/examples/concurrency/group-round-robin/concurrency-worker-expression.js +4 -2
  26. package/legacy/examples/concurrency/group-round-robin/concurrency-worker-key-fn.js +4 -2
  27. package/legacy/examples/example-event.js +0 -3
  28. package/legacy/examples/logger.js +0 -1
  29. package/legacy/examples/sticky-worker-with-check.js +0 -1
  30. package/legacy/examples/sticky-worker.js +0 -1
  31. package/legacy/legacy-client.js +2 -2
  32. package/legacy/legacy-transformer.js +2 -4
  33. package/legacy/step.d.ts +16 -16
  34. package/legacy/step.js +8 -17
  35. package/legacy/workflow.d.ts +81 -81
  36. package/package.json +20 -29
  37. package/protoc/dispatcher/dispatcher.d.ts +20 -0
  38. package/protoc/dispatcher/dispatcher.js +136 -2
  39. package/protoc/v1/dispatcher.d.ts +168 -0
  40. package/protoc/v1/dispatcher.js +1920 -1
  41. package/protoc/v1/shared/trigger.d.ts +89 -0
  42. package/protoc/v1/shared/trigger.js +493 -0
  43. package/protoc/v1/workflows.d.ts +34 -34
  44. package/protoc/v1/workflows.js +252 -200
  45. package/protoc/workflows/workflows.d.ts +2 -75
  46. package/protoc/workflows/workflows.js +16 -491
  47. package/util/abort-error.d.ts +15 -1
  48. package/util/abort-error.js +30 -5
  49. package/util/config-loader/config-loader.js +4 -3
  50. package/util/config-loader/token.js +9 -2
  51. package/util/errors/eviction-not-supported-error.d.ts +5 -0
  52. package/util/errors/eviction-not-supported-error.js +18 -0
  53. package/util/errors/hatchet-error.d.ts +9 -1
  54. package/util/errors/hatchet-error.js +23 -2
  55. package/util/errors/non-determinism-error.d.ts +7 -0
  56. package/util/errors/non-determinism-error.js +21 -0
  57. package/util/errors/task-run-terminated-error.d.ts +6 -0
  58. package/util/errors/task-run-terminated-error.js +15 -0
  59. package/util/grpc-error.d.ts +9 -0
  60. package/util/grpc-error.js +25 -0
  61. package/util/hatchet-promise/hatchet-promise.d.ts +6 -1
  62. package/util/hatchet-promise/hatchet-promise.js +16 -2
  63. package/util/logger/logger.js +0 -1
  64. package/util/parse.d.ts +1 -1
  65. package/util/parse.js +4 -2
  66. package/util/retrier.js +2 -3
  67. package/util/sleep.d.ts +3 -2
  68. package/util/sleep.js +6 -4
  69. package/util/workflow-run-ref.js +5 -3
  70. package/v1/client/admin.d.ts +2 -2
  71. package/v1/client/admin.js +2 -6
  72. package/v1/client/client.d.ts +7 -11
  73. package/v1/client/client.interface.d.ts +5 -8
  74. package/v1/client/client.js +34 -40
  75. package/v1/client/duration.d.ts +11 -1
  76. package/v1/client/duration.js +44 -0
  77. package/v1/client/features/cel.js +1 -1
  78. package/v1/client/features/crons.js +2 -2
  79. package/v1/client/features/index.d.ts +5 -0
  80. package/v1/client/features/index.js +5 -0
  81. package/v1/client/features/logs.d.ts +37 -0
  82. package/v1/client/features/logs.js +46 -0
  83. package/v1/client/features/runs.d.ts +16 -3
  84. package/v1/client/features/runs.js +38 -4
  85. package/v1/client/features/schedules.js +4 -4
  86. package/v1/client/features/webhooks.js +4 -2
  87. package/v1/client/features/workflows.js +1 -1
  88. package/v1/client/worker/context.d.ts +101 -6
  89. package/v1/client/worker/context.js +257 -44
  90. package/v1/client/worker/deprecated/deprecation.js +8 -4
  91. package/v1/client/worker/deprecated/index.d.ts +1 -1
  92. package/v1/client/worker/deprecated/index.js +2 -1
  93. package/v1/client/worker/deprecated/legacy-worker.d.ts +5 -0
  94. package/v1/client/worker/deprecated/legacy-worker.js +33 -24
  95. package/v1/client/worker/deprecated/pre-eviction.d.ts +12 -0
  96. package/v1/client/worker/deprecated/pre-eviction.js +37 -0
  97. package/v1/client/worker/engine-version.d.ts +5 -0
  98. package/v1/client/worker/engine-version.js +14 -0
  99. package/v1/client/worker/eviction/eviction-cache.d.ts +33 -0
  100. package/v1/client/worker/eviction/eviction-cache.js +139 -0
  101. package/v1/client/worker/eviction/eviction-manager.d.ts +42 -0
  102. package/v1/client/worker/eviction/eviction-manager.js +132 -0
  103. package/v1/client/worker/eviction/eviction-policy.d.ts +19 -0
  104. package/v1/client/worker/eviction/eviction-policy.js +8 -0
  105. package/v1/client/worker/eviction/index.d.ts +3 -0
  106. package/v1/client/worker/eviction/index.js +11 -0
  107. package/v1/client/worker/health-server.js +3 -3
  108. package/v1/client/worker/slot-utils.js +0 -3
  109. package/v1/client/worker/worker-internal.d.ts +23 -4
  110. package/v1/client/worker/worker-internal.js +216 -148
  111. package/v1/client/worker/worker.d.ts +1 -0
  112. package/v1/client/worker/worker.js +34 -0
  113. package/v1/conditions/base.js +0 -1
  114. package/v1/conditions/index.js +2 -4
  115. package/v1/conditions/sleep-condition.js +2 -1
  116. package/v1/conditions/transformer.js +2 -1
  117. package/v1/declaration.d.ts +6 -4
  118. package/v1/declaration.js +20 -7
  119. package/v1/examples/__e2e__/harness.d.ts +5 -0
  120. package/v1/examples/__e2e__/harness.js +17 -3
  121. package/v1/examples/affinity/affinity-workers.js +0 -1
  122. package/v1/examples/bulk_operations/workflow.js +0 -1
  123. package/v1/examples/cancellation/run.js +0 -1
  124. package/v1/examples/cancellations/run.js +0 -1
  125. package/v1/examples/child_workflows/run.js +0 -2
  126. package/v1/examples/child_workflows/workflow.js +0 -1
  127. package/v1/examples/concurrency-rr/load.js +0 -1
  128. package/v1/examples/concurrency-rr/run.js +0 -3
  129. package/v1/examples/concurrency_limit_rr/load.js +0 -1
  130. package/v1/examples/concurrency_limit_rr/run.js +0 -3
  131. package/v1/examples/concurrency_workflow_level/workflow.d.ts +1 -1
  132. package/v1/examples/concurrency_workflow_level/workflow.js +1 -1
  133. package/v1/examples/conditions/event.js +0 -1
  134. package/v1/examples/conditions/run.js +0 -1
  135. package/v1/examples/dag/run.js +0 -1
  136. package/v1/examples/dag_match_condition/event.js +0 -1
  137. package/v1/examples/dag_match_condition/run.js +0 -1
  138. package/v1/examples/deep/run.js +0 -2
  139. package/v1/examples/durable/workflow.d.ts +57 -0
  140. package/v1/examples/durable/workflow.js +164 -10
  141. package/v1/examples/durable-event/event.js +0 -1
  142. package/v1/examples/durable-event/run.js +0 -2
  143. package/v1/examples/durable-event/workflow.js +2 -7
  144. package/v1/examples/durable-sleep/event.js +0 -1
  145. package/v1/examples/durable-sleep/run.js +0 -2
  146. package/v1/examples/durable_event/event.js +0 -1
  147. package/v1/examples/durable_event/run.js +0 -2
  148. package/v1/examples/durable_event/workflow.d.ts +1 -0
  149. package/v1/examples/durable_event/workflow.js +4 -9
  150. package/v1/examples/durable_eviction/capacity-worker.d.ts +1 -0
  151. package/v1/examples/durable_eviction/capacity-worker.js +31 -0
  152. package/v1/examples/durable_eviction/worker.d.ts +1 -0
  153. package/v1/examples/durable_eviction/worker.js +34 -0
  154. package/v1/examples/durable_eviction/workflow.d.ts +44 -0
  155. package/v1/examples/durable_eviction/workflow.js +129 -0
  156. package/v1/examples/durable_sleep/event.js +0 -1
  157. package/v1/examples/durable_sleep/run.js +0 -2
  158. package/v1/examples/e2e-worker.js +42 -19
  159. package/v1/examples/events/event.js +0 -1
  160. package/v1/examples/high-memory/run.js +0 -1
  161. package/v1/examples/inferred-typing/run.js +0 -1
  162. package/v1/examples/landing_page/durable-excution.js +0 -1
  163. package/v1/examples/landing_page/queues.js +0 -1
  164. package/v1/examples/legacy/run.js +0 -1
  165. package/v1/examples/logger/byo-logger.js +0 -2
  166. package/v1/examples/logger/logger.js +0 -1
  167. package/v1/examples/logging/byo-logger.js +0 -2
  168. package/v1/examples/logging/logger.js +0 -1
  169. package/v1/examples/middleware/recipes.js +3 -1
  170. package/v1/examples/migration-guides/mergent.js +2 -1
  171. package/v1/examples/multiple_wf_concurrency/run.js +0 -3
  172. package/v1/examples/non_retryable/run.js +0 -1
  173. package/v1/examples/on_event/event.js +0 -1
  174. package/v1/examples/on_failure/run.js +0 -1
  175. package/v1/examples/on_failure/workflow.js +0 -1
  176. package/v1/examples/on_success/run.js +0 -1
  177. package/v1/examples/on_success/workflow.js +0 -1
  178. package/v1/examples/priority/run.js +0 -1
  179. package/v1/examples/priority/workflow.js +0 -1
  180. package/v1/examples/retries/run.js +0 -1
  181. package/v1/examples/retries/workflow.js +0 -1
  182. package/v1/examples/simple/bulk.js +0 -1
  183. package/v1/examples/simple/cron.js +0 -2
  184. package/v1/examples/simple/delay.js +0 -1
  185. package/v1/examples/simple/enqueue.js +0 -2
  186. package/v1/examples/simple/run.js +0 -1
  187. package/v1/examples/simple/schedule.js +0 -1
  188. package/v1/examples/simple/workflow-with-child.js +10 -4
  189. package/v1/examples/sticky/run.js +0 -1
  190. package/v1/examples/sticky/workflow.js +0 -1
  191. package/v1/examples/streaming/nextjs-proxy.js +0 -1
  192. package/v1/examples/streaming/run.js +0 -1
  193. package/v1/examples/timeout/run.js +0 -1
  194. package/v1/examples/timeouts/run.js +0 -1
  195. package/v1/index.d.ts +5 -0
  196. package/v1/index.js +10 -0
  197. package/v1/parent-run-context-vars.d.ts +6 -0
  198. package/v1/slot-types.js +0 -1
  199. package/v1/task.d.ts +10 -2
  200. package/v1/task.js +2 -1
  201. package/version.d.ts +1 -1
  202. package/version.js +1 -1
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -21,11 +54,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
21
54
  Object.defineProperty(exports, "__esModule", { value: true });
22
55
  exports.InternalWorker = void 0;
23
56
  exports.mapRateLimitPb = mapRateLimitPb;
24
- /* eslint-disable no-underscore-dangle */
25
- /* eslint-disable no-nested-ternary */
57
+ exports.resolveExecutionTimeout = resolveExecutionTimeout;
58
+ exports.resolveScheduleTimeout = resolveScheduleTimeout;
26
59
  const hatchet_error_1 = __importDefault(require("../../../util/errors/hatchet-error"));
60
+ const task_run_terminated_error_1 = require("../../../util/errors/task-run-terminated-error");
27
61
  const dispatcher_1 = require("../../../protoc/dispatcher");
28
- const hatchet_promise_1 = __importDefault(require("../../../util/hatchet-promise/hatchet-promise"));
62
+ const hatchet_promise_1 = __importStar(require("../../../util/hatchet-promise/hatchet-promise"));
29
63
  const workflows_1 = require("../../../protoc/workflows");
30
64
  const logger_1 = require("../../../util/logger");
31
65
  const task_1 = require("../../task");
@@ -34,12 +68,18 @@ const zod_to_json_schema_1 = require("zod-to-json-schema");
34
68
  const apply_namespace_1 = require("../../../util/apply-namespace");
35
69
  const sleep_1 = __importDefault(require("../../../util/sleep"));
36
70
  const abort_error_1 = require("../../../util/abort-error");
71
+ const duration_1 = require("../duration");
37
72
  const context_1 = require("./context");
38
73
  const parent_run_context_vars_1 = require("../../parent-run-context-vars");
39
74
  const health_server_1 = require("./health-server");
75
+ const eviction_manager_1 = require("./eviction/eviction-manager");
76
+ const eviction_policy_1 = require("./eviction/eviction-policy");
77
+ const engine_version_1 = require("./engine-version");
40
78
  class InternalWorker {
41
79
  constructor(client, options) {
42
80
  var _a, _b, _c, _d;
81
+ this.durable_action_set = new Set();
82
+ this.eviction_policies = new Map();
43
83
  this.workflow_registry = [];
44
84
  this.futures = {};
45
85
  this.contexts = {};
@@ -97,7 +137,12 @@ class InternalWorker {
97
137
  const newActions = workflow._durableTasks
98
138
  .filter((task) => !!task.fn)
99
139
  .reduce((acc, task) => {
100
- acc[`${(0, apply_namespace_1.applyNamespace)(workflow.name, this.client.config.namespace).toLowerCase()}:${task.name.toLowerCase()}`] = (ctx) => task.fn(ctx.input, ctx);
140
+ const actionId = `${(0, apply_namespace_1.applyNamespace)(workflow.name, this.client.config.namespace).toLowerCase()}:${task.name.toLowerCase()}`;
141
+ acc[actionId] = (ctx) => task.fn(ctx.input, ctx);
142
+ this.durable_action_set.add(actionId);
143
+ this.eviction_policies.set(actionId, task.evictionPolicy !== undefined
144
+ ? task.evictionPolicy
145
+ : eviction_policy_1.DEFAULT_DURABLE_TASK_EVICTION_POLICY);
101
146
  return acc;
102
147
  }, {});
103
148
  this.action_registry = Object.assign(Object.assign({}, this.action_registry), newActions);
@@ -123,7 +168,7 @@ class InternalWorker {
123
168
  }
124
169
  registerWorkflow(initWorkflow_1) {
125
170
  return __awaiter(this, arguments, void 0, function* (initWorkflow, durable = false) {
126
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
171
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
127
172
  // patch the namespace
128
173
  const workflow = Object.assign(Object.assign({}, initWorkflow.definition), { name: (0, apply_namespace_1.applyNamespace)(initWorkflow.definition.name, this.client.config.namespace).toLowerCase() });
129
174
  try {
@@ -146,19 +191,20 @@ class InternalWorker {
146
191
  }
147
192
  if (workflow.onFailure && typeof workflow.onFailure === 'object') {
148
193
  const onFailure = workflow.onFailure;
194
+ const scheduleTimeout = (_a = onFailure.scheduleTimeout) !== null && _a !== void 0 ? _a : (_b = workflow.taskDefaults) === null || _b === void 0 ? void 0 : _b.scheduleTimeout;
149
195
  onFailureTask = {
150
196
  readableId: 'on-failure-task',
151
197
  action: onFailureTaskName(workflow),
152
- timeout: onFailure.executionTimeout || ((_a = workflow.taskDefaults) === null || _a === void 0 ? void 0 : _a.executionTimeout) || '60s',
153
- scheduleTimeout: onFailure.scheduleTimeout || ((_b = workflow.taskDefaults) === null || _b === void 0 ? void 0 : _b.scheduleTimeout),
198
+ timeout: (0, duration_1.durationToString)(onFailure.executionTimeout || ((_c = workflow.taskDefaults) === null || _c === void 0 ? void 0 : _c.executionTimeout) || '60s'),
199
+ scheduleTimeout: scheduleTimeout ? (0, duration_1.durationToString)(scheduleTimeout) : undefined,
154
200
  inputs: '{}',
155
201
  parents: [],
156
- retries: onFailure.retries || ((_c = workflow.taskDefaults) === null || _c === void 0 ? void 0 : _c.retries) || 0,
157
- rateLimits: mapRateLimitPb(onFailure.rateLimits || ((_d = workflow.taskDefaults) === null || _d === void 0 ? void 0 : _d.rateLimits)),
158
- workerLabels: mapWorkerLabelPb(onFailure.desiredWorkerLabels || ((_e = workflow.taskDefaults) === null || _e === void 0 ? void 0 : _e.workerLabels)),
202
+ retries: onFailure.retries || ((_d = workflow.taskDefaults) === null || _d === void 0 ? void 0 : _d.retries) || 0,
203
+ rateLimits: mapRateLimitPb(onFailure.rateLimits || ((_e = workflow.taskDefaults) === null || _e === void 0 ? void 0 : _e.rateLimits)),
204
+ workerLabels: mapWorkerLabelPb(onFailure.desiredWorkerLabels || ((_f = workflow.taskDefaults) === null || _f === void 0 ? void 0 : _f.workerLabels)),
159
205
  concurrency: [],
160
- backoffFactor: ((_f = onFailure.backoff) === null || _f === void 0 ? void 0 : _f.factor) || ((_h = (_g = workflow.taskDefaults) === null || _g === void 0 ? void 0 : _g.backoff) === null || _h === void 0 ? void 0 : _h.factor),
161
- backoffMaxSeconds: ((_j = onFailure.backoff) === null || _j === void 0 ? void 0 : _j.maxSeconds) || ((_l = (_k = workflow.taskDefaults) === null || _k === void 0 ? void 0 : _k.backoff) === null || _l === void 0 ? void 0 : _l.maxSeconds),
206
+ backoffFactor: ((_g = onFailure.backoff) === null || _g === void 0 ? void 0 : _g.factor) || ((_j = (_h = workflow.taskDefaults) === null || _h === void 0 ? void 0 : _h.backoff) === null || _j === void 0 ? void 0 : _j.factor),
207
+ backoffMaxSeconds: ((_k = onFailure.backoff) === null || _k === void 0 ? void 0 : _k.maxSeconds) || ((_m = (_l = workflow.taskDefaults) === null || _l === void 0 ? void 0 : _l.backoff) === null || _m === void 0 ? void 0 : _m.maxSeconds),
162
208
  isDurable: false,
163
209
  slotRequests: { default: 1 },
164
210
  };
@@ -183,14 +229,14 @@ class InternalWorker {
183
229
  onSuccessTask = {
184
230
  name: 'on-success-task',
185
231
  fn: onSuccess.fn,
186
- executionTimeout: onSuccess.executionTimeout || ((_m = workflow.taskDefaults) === null || _m === void 0 ? void 0 : _m.executionTimeout) || '60s',
187
- scheduleTimeout: onSuccess.scheduleTimeout || ((_o = workflow.taskDefaults) === null || _o === void 0 ? void 0 : _o.scheduleTimeout),
232
+ executionTimeout: onSuccess.executionTimeout || ((_o = workflow.taskDefaults) === null || _o === void 0 ? void 0 : _o.executionTimeout) || '60s',
233
+ scheduleTimeout: onSuccess.scheduleTimeout || ((_p = workflow.taskDefaults) === null || _p === void 0 ? void 0 : _p.scheduleTimeout),
188
234
  parents,
189
- retries: onSuccess.retries || ((_p = workflow.taskDefaults) === null || _p === void 0 ? void 0 : _p.retries) || 0,
190
- rateLimits: onSuccess.rateLimits || ((_q = workflow.taskDefaults) === null || _q === void 0 ? void 0 : _q.rateLimits),
191
- desiredWorkerLabels: onSuccess.desiredWorkerLabels || ((_r = workflow.taskDefaults) === null || _r === void 0 ? void 0 : _r.workerLabels),
192
- concurrency: onSuccess.concurrency || ((_s = workflow.taskDefaults) === null || _s === void 0 ? void 0 : _s.concurrency),
193
- backoff: onSuccess.backoff || ((_t = workflow.taskDefaults) === null || _t === void 0 ? void 0 : _t.backoff),
235
+ retries: onSuccess.retries || ((_q = workflow.taskDefaults) === null || _q === void 0 ? void 0 : _q.retries) || 0,
236
+ rateLimits: onSuccess.rateLimits || ((_r = workflow.taskDefaults) === null || _r === void 0 ? void 0 : _r.rateLimits),
237
+ desiredWorkerLabels: onSuccess.desiredWorkerLabels || ((_s = workflow.taskDefaults) === null || _s === void 0 ? void 0 : _s.workerLabels),
238
+ concurrency: onSuccess.concurrency || ((_t = workflow.taskDefaults) === null || _t === void 0 ? void 0 : _t.concurrency),
239
+ backoff: onSuccess.backoff || ((_u = workflow.taskDefaults) === null || _u === void 0 ? void 0 : _u.backoff),
194
240
  };
195
241
  }
196
242
  if (onSuccessTask) {
@@ -217,7 +263,6 @@ class InternalWorker {
217
263
  // Convert Zod schema to JSON Schema if provided
218
264
  let inputJsonSchema;
219
265
  if (workflow.inputValidator) {
220
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
221
266
  const jsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(workflow.inputValidator);
222
267
  inputJsonSchema = new TextEncoder().encode(JSON.stringify(jsonSchema));
223
268
  }
@@ -255,23 +300,20 @@ class InternalWorker {
255
300
  defaultPriority: workflow.defaultPriority,
256
301
  inputJsonSchema,
257
302
  tasks: [...workflow._tasks, ...workflow._durableTasks].map((task) => {
258
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
303
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
259
304
  return ({
260
305
  readableId: task.name,
261
306
  action: `${workflow.name}:${task.name}`,
262
- timeout: task.executionTimeout ||
263
- task.timeout ||
264
- ((_a = workflow.taskDefaults) === null || _a === void 0 ? void 0 : _a.executionTimeout) ||
265
- '60s',
266
- scheduleTimeout: task.scheduleTimeout || ((_b = workflow.taskDefaults) === null || _b === void 0 ? void 0 : _b.scheduleTimeout),
307
+ timeout: resolveExecutionTimeout(task, workflow.taskDefaults),
308
+ scheduleTimeout: resolveScheduleTimeout(task, workflow.taskDefaults),
267
309
  inputs: '{}',
268
- parents: (_d = (_c = task.parents) === null || _c === void 0 ? void 0 : _c.map((p) => p.name)) !== null && _d !== void 0 ? _d : [],
310
+ parents: (_b = (_a = task.parents) === null || _a === void 0 ? void 0 : _a.map((p) => p.name)) !== null && _b !== void 0 ? _b : [],
269
311
  userData: '{}',
270
- retries: task.retries || ((_e = workflow.taskDefaults) === null || _e === void 0 ? void 0 : _e.retries) || 0,
271
- rateLimits: mapRateLimitPb(task.rateLimits || ((_f = workflow.taskDefaults) === null || _f === void 0 ? void 0 : _f.rateLimits)),
272
- workerLabels: mapWorkerLabelPb(task.desiredWorkerLabels || ((_g = workflow.taskDefaults) === null || _g === void 0 ? void 0 : _g.workerLabels)),
273
- backoffFactor: ((_h = task.backoff) === null || _h === void 0 ? void 0 : _h.factor) || ((_k = (_j = workflow.taskDefaults) === null || _j === void 0 ? void 0 : _j.backoff) === null || _k === void 0 ? void 0 : _k.factor),
274
- backoffMaxSeconds: ((_l = task.backoff) === null || _l === void 0 ? void 0 : _l.maxSeconds) || ((_o = (_m = workflow.taskDefaults) === null || _m === void 0 ? void 0 : _m.backoff) === null || _o === void 0 ? void 0 : _o.maxSeconds),
312
+ retries: task.retries || ((_c = workflow.taskDefaults) === null || _c === void 0 ? void 0 : _c.retries) || 0,
313
+ rateLimits: mapRateLimitPb(task.rateLimits || ((_d = workflow.taskDefaults) === null || _d === void 0 ? void 0 : _d.rateLimits)),
314
+ workerLabels: mapWorkerLabelPb(task.desiredWorkerLabels || ((_e = workflow.taskDefaults) === null || _e === void 0 ? void 0 : _e.workerLabels)),
315
+ backoffFactor: ((_f = task.backoff) === null || _f === void 0 ? void 0 : _f.factor) || ((_h = (_g = workflow.taskDefaults) === null || _g === void 0 ? void 0 : _g.backoff) === null || _h === void 0 ? void 0 : _h.factor),
316
+ backoffMaxSeconds: ((_j = task.backoff) === null || _j === void 0 ? void 0 : _j.maxSeconds) || ((_l = (_k = workflow.taskDefaults) === null || _k === void 0 ? void 0 : _k.backoff) === null || _l === void 0 ? void 0 : _l.maxSeconds),
275
317
  conditions: (0, transformer_1.taskConditionsToPb)(task, this.client.config.namespace),
276
318
  isDurable: durableTaskSet.has(task),
277
319
  slotRequests: task.slotRequests || (durableTaskSet.has(task) ? { durable: 1 } : { default: 1 }),
@@ -279,7 +321,7 @@ class InternalWorker {
279
321
  ? Array.isArray(task.concurrency)
280
322
  ? task.concurrency
281
323
  : [task.concurrency]
282
- : ((_p = workflow.taskDefaults) === null || _p === void 0 ? void 0 : _p.concurrency)
324
+ : ((_m = workflow.taskDefaults) === null || _m === void 0 ? void 0 : _m.concurrency)
283
325
  ? Array.isArray(workflow.taskDefaults.concurrency)
284
326
  ? workflow.taskDefaults.concurrency
285
327
  : [workflow.taskDefaults.concurrency]
@@ -287,11 +329,11 @@ class InternalWorker {
287
329
  });
288
330
  }),
289
331
  concurrency: concurrencySolo,
290
- defaultFilters: (_v = (_u = workflow.defaultFilters) === null || _u === void 0 ? void 0 : _u.map((f) => ({
332
+ defaultFilters: (_w = (_v = workflow.defaultFilters) === null || _v === void 0 ? void 0 : _v.map((f) => ({
291
333
  scope: f.scope,
292
334
  expression: f.expression,
293
335
  payload: f.payload ? new TextEncoder().encode(JSON.stringify(f.payload)) : undefined,
294
- }))) !== null && _v !== void 0 ? _v : [],
336
+ }))) !== null && _w !== void 0 ? _w : [],
295
337
  });
296
338
  this.registeredWorkflowPromises.push(registeredWorkflow);
297
339
  yield registeredWorkflow;
@@ -303,17 +345,83 @@ class InternalWorker {
303
345
  this.registerActions(workflow);
304
346
  });
305
347
  }
348
+ ensureEvictionManager() {
349
+ var _a, _b, _c;
350
+ if (this.evictionManager)
351
+ return this.evictionManager;
352
+ const totalDurableSlots = (_c = (_b = (_a = this.slotConfig) === null || _a === void 0 ? void 0 : _a.durable) !== null && _b !== void 0 ? _b : this.durableSlots) !== null && _c !== void 0 ? _c : 0;
353
+ this.evictionManager = new eviction_manager_1.DurableEvictionManager({
354
+ durableSlots: totalDurableSlots,
355
+ cancelLocal: (key) => {
356
+ var _a;
357
+ const err = new task_run_terminated_error_1.TaskRunTerminatedError('evicted');
358
+ const ctx = this.contexts[key];
359
+ if (ctx) {
360
+ const invocationCount = (_a = ctx.invocationCount) !== null && _a !== void 0 ? _a : 1;
361
+ this.client.durableListener.cleanupTaskState(ctx.action.taskRunExternalId, invocationCount);
362
+ if (ctx.abortController) {
363
+ ctx.abortController.abort(err);
364
+ }
365
+ }
366
+ const future = this.futures[key];
367
+ if (future) {
368
+ future.promise.catch(() => undefined);
369
+ future.cancel(hatchet_promise_1.CancellationReason.EVICTED_BY_WORKER);
370
+ }
371
+ },
372
+ requestEvictionWithAck: (key, rec) => __awaiter(this, void 0, void 0, function* () {
373
+ var _a;
374
+ const ctx = this.contexts[key];
375
+ const invocationCount = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.invocationCount) !== null && _a !== void 0 ? _a : 1;
376
+ yield this.client.durableListener.sendEvictInvocation(rec.taskRunExternalId, invocationCount, rec.evictionReason);
377
+ }),
378
+ logger: this.logger,
379
+ });
380
+ this.client.durableListener.onServerEvict = (durableTaskExternalId, invocationCount) => {
381
+ var _a;
382
+ (_a = this.evictionManager) === null || _a === void 0 ? void 0 : _a.handleServerEviction(durableTaskExternalId, invocationCount);
383
+ };
384
+ this.evictionManager.start();
385
+ return this.evictionManager;
386
+ }
387
+ cleanupRun(key) {
388
+ var _a;
389
+ const ctx = this.contexts[key];
390
+ if (ctx instanceof context_1.DurableContext) {
391
+ this.client.durableListener.cleanupTaskState(ctx.action.taskRunExternalId, ctx.invocationCount);
392
+ }
393
+ (_a = this.evictionManager) === null || _a === void 0 ? void 0 : _a.unregisterRun(key);
394
+ delete this.futures[key];
395
+ delete this.contexts[key];
396
+ }
306
397
  handleStartStepRun(action) {
307
398
  return __awaiter(this, void 0, void 0, function* () {
399
+ var _a;
308
400
  const { actionId, taskRunExternalId, taskName } = action;
401
+ const actionKey = action.key;
309
402
  try {
310
- // Note: we always use a DurableContext since its a superset of the Context class
311
- const context = new context_1.DurableContext(action, this.client, this);
312
- this.contexts[taskRunExternalId] = context;
403
+ const isDurable = this.durable_action_set.has(actionId);
404
+ let context;
405
+ if (isDurable) {
406
+ const { durableListener } = this.client;
407
+ let mgr;
408
+ if ((0, engine_version_1.supportsEviction)(this.engineVersion)) {
409
+ yield durableListener.ensureStarted(this.workerId || '');
410
+ mgr = this.ensureEvictionManager();
411
+ const evictionPolicy = this.eviction_policies.get(actionId);
412
+ mgr.registerRun(actionKey, taskRunExternalId, (_a = action.durableTaskInvocationCount) !== null && _a !== void 0 ? _a : 1, evictionPolicy);
413
+ }
414
+ context = new context_1.DurableContext(action, this.client, this, durableListener, mgr, this.engineVersion);
415
+ }
416
+ else {
417
+ context = new context_1.Context(action, this.client, this);
418
+ }
419
+ this.contexts[actionKey] = context;
313
420
  const step = this.action_registry[actionId];
314
421
  if (!step) {
315
422
  this.logger.error(`Registered actions: '${Object.keys(this.action_registry).join(', ')}'`);
316
423
  this.logger.error(`Could not find step '${actionId}'`);
424
+ this.cleanupRun(actionKey);
317
425
  return;
318
426
  }
319
427
  const run = () => __awaiter(this, void 0, void 0, function* () {
@@ -337,8 +445,8 @@ class InternalWorker {
337
445
  childIndex: 0,
338
446
  desiredWorkerId: this.workerId || '',
339
447
  signal: context.abortController.signal,
448
+ durableContext: isDurable && context instanceof context_1.DurableContext ? context : undefined,
340
449
  }, () => {
341
- // Precheck: if cancellation already happened, don't execute user code.
342
450
  (0, abort_error_1.throwIfAborted)(context.abortController.signal);
343
451
  return step(context);
344
452
  });
@@ -359,13 +467,11 @@ class InternalWorker {
359
467
  return;
360
468
  }
361
469
  this.logger.info((0, logger_1.taskRunLog)(taskName, taskRunExternalId, 'completed'));
362
- // Send the action event to the dispatcher
363
470
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, false, result || null, action.retryCount);
364
471
  yield this.client.dispatcher.sendStepActionEvent(event);
365
472
  }
366
473
  catch (actionEventError) {
367
474
  this.logger.error(`Could not send completed action event: ${actionEventError.message || actionEventError}`);
368
- // send a failure event
369
475
  const failureEvent = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, false, actionEventError.message, action.retryCount);
370
476
  try {
371
477
  yield this.client.dispatcher.sendStepActionEvent(failureEvent);
@@ -376,9 +482,7 @@ class InternalWorker {
376
482
  this.logger.error(`Could not send action event: ${actionEventError.message || actionEventError}`);
377
483
  }
378
484
  finally {
379
- // delete the run from the futures
380
- delete this.futures[taskRunExternalId];
381
- delete this.contexts[taskRunExternalId];
485
+ this.cleanupRun(actionKey);
382
486
  }
383
487
  });
384
488
  const failure = (error) => __awaiter(this, void 0, void 0, function* () {
@@ -391,7 +495,6 @@ class InternalWorker {
391
495
  if (error.stack) {
392
496
  this.logger.error(error.stack);
393
497
  }
394
- // Send the action event to the dispatcher
395
498
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, shouldNotRetry, {
396
499
  message: error === null || error === void 0 ? void 0 : error.message,
397
500
  stack: error === null || error === void 0 ? void 0 : error.stack,
@@ -402,9 +505,7 @@ class InternalWorker {
402
505
  this.logger.error(`Could not send action event: ${e.message}`);
403
506
  }
404
507
  finally {
405
- // delete the run from the futures
406
- delete this.futures[taskRunExternalId];
407
- delete this.contexts[taskRunExternalId];
508
+ this.cleanupRun(actionKey);
408
509
  }
409
510
  });
410
511
  const future = new hatchet_promise_1.default((() => __awaiter(this, void 0, void 0, function* () {
@@ -427,7 +528,7 @@ class InternalWorker {
427
528
  (0, abort_error_1.throwIfAborted)(context.abortController.signal);
428
529
  yield success(result);
429
530
  }))());
430
- this.futures[taskRunExternalId] = future;
531
+ this.futures[actionKey] = future;
431
532
  // Send the action event to the dispatcher
432
533
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED, false, undefined, action.retryCount);
433
534
  this.client.dispatcher.sendStepActionEvent(event).catch((e) => {
@@ -437,87 +538,18 @@ class InternalWorker {
437
538
  yield future.promise;
438
539
  }
439
540
  catch (e) {
440
- const message = (e === null || e === void 0 ? void 0 : e.message) || String(e);
441
- // TODO is this cased correctly...
442
- if (!message.includes('Cancelled')) {
541
+ if (!(0, task_run_terminated_error_1.isTaskRunTerminatedError)(e)) {
443
542
  this.logger.error(`Could not wait for task run ${taskRunExternalId} to finish. ` +
444
543
  `See https://docs.hatchet.run/home/cancellation for best practices on handling cancellation: `, e);
445
544
  }
446
545
  }
447
- }
448
- catch (e) {
449
- this.logger.error('Could not send action event (outer): ', e);
450
- }
451
- });
452
- }
453
- handleStartGroupKeyRun(action) {
454
- return __awaiter(this, void 0, void 0, function* () {
455
- const { actionId, getGroupKeyRunId, taskRunExternalId, taskName } = action;
456
- this.logger.error('Concurrency Key Functions have been deprecated and will be removed in a future release. Use Concurrency Expressions instead.');
457
- try {
458
- const context = new context_1.Context(action, this.client, this);
459
- const key = getGroupKeyRunId;
460
- if (!key) {
461
- this.logger.error(`No group key run id provided for action ${actionId}`);
462
- return;
463
- }
464
- this.contexts[key] = context;
465
- this.logger.debug(`Starting group key run ${key}`);
466
- const step = this.action_registry[actionId];
467
- if (!step) {
468
- this.logger.error(`Could not find step '${actionId}'`);
469
- return;
546
+ finally {
547
+ this.cleanupRun(actionKey);
470
548
  }
471
- const run = () => __awaiter(this, void 0, void 0, function* () {
472
- return step(context);
473
- });
474
- const success = (result) => {
475
- this.logger.info((0, logger_1.taskRunLog)(taskName, taskRunExternalId, 'completed'));
476
- try {
477
- // Send the action event to the dispatcher
478
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
479
- this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
480
- this.logger.error(`Could not send action event: ${e.message}`);
481
- });
482
- }
483
- catch (e) {
484
- this.logger.error(`Could not send action event: ${e.message}`);
485
- }
486
- finally {
487
- // delete the run from the futures
488
- delete this.futures[key];
489
- delete this.contexts[key];
490
- }
491
- };
492
- const failure = (error) => {
493
- this.logger.error((0, logger_1.taskRunLog)(taskName, taskRunExternalId, `failed: ${error.message}`));
494
- try {
495
- // Send the action event to the dispatcher
496
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
497
- this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
498
- this.logger.error(`Could not send action event: ${e.message}`);
499
- });
500
- }
501
- catch (e) {
502
- this.logger.error(`Could not send action event: ${e.message}`);
503
- }
504
- finally {
505
- // delete the run from the futures
506
- delete this.futures[key];
507
- delete this.contexts[key];
508
- }
509
- };
510
- const future = new hatchet_promise_1.default(run().then(success).catch(failure));
511
- this.futures[key] = future;
512
- // Send the action event to the dispatcher
513
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_STARTED);
514
- this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
515
- this.logger.error(`Could not send action event: ${e.message}`);
516
- });
517
- yield future.promise;
518
549
  }
519
550
  catch (e) {
520
- this.logger.error(`Could not send action event: ${e.message}`);
551
+ this.cleanupRun(actionKey);
552
+ this.logger.error('Could not send action event (outer): ', e);
521
553
  }
522
554
  });
523
555
  }
@@ -554,11 +586,13 @@ class InternalWorker {
554
586
  return __awaiter(this, void 0, void 0, function* () {
555
587
  var _a, _b, _c;
556
588
  const { taskRunExternalId, taskName } = action;
589
+ const actionKey = action.key;
557
590
  try {
558
- const future = this.futures[taskRunExternalId];
559
- const context = this.contexts[taskRunExternalId];
591
+ const future = this.futures[actionKey];
592
+ const context = this.contexts[actionKey];
593
+ const cancelErr = new task_run_terminated_error_1.TaskRunTerminatedError('cancelled', 'Cancelled by worker');
560
594
  if (context && context.abortController) {
561
- context.abortController.abort('Cancelled by worker'); // TODO this reason is nonsensical
595
+ context.abortController.abort(cancelErr);
562
596
  }
563
597
  if (future) {
564
598
  const start = Date.now();
@@ -570,7 +604,7 @@ class InternalWorker {
570
604
  // where the main action handler isn't currently awaiting `future.promise`.
571
605
  future.promise.catch(() => undefined);
572
606
  // Cancel the future (rejects the wrapper); user code must still cooperate with AbortSignal.
573
- future.cancel('Cancelled by worker'); // TODO this reason is nonsensical
607
+ future.cancel(hatchet_promise_1.CancellationReason.CANCELLED_BY_WORKER);
574
608
  // Track completion of the underlying work (not the cancelable wrapper).
575
609
  // Ensure this promise never throws into our supervision flow.
576
610
  const completion = ((_c = future.inner) !== null && _c !== void 0 ? _c : future.promise).catch(() => undefined);
@@ -608,8 +642,7 @@ class InternalWorker {
608
642
  this.logger.error(`Cancellation: error while supervising cancellation for task run ${taskRunExternalId}: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
609
643
  }
610
644
  finally {
611
- delete this.futures[taskRunExternalId];
612
- delete this.contexts[taskRunExternalId];
645
+ this.cleanupRun(actionKey);
613
646
  }
614
647
  });
615
648
  }
@@ -624,6 +657,33 @@ class InternalWorker {
624
657
  this.killing = true;
625
658
  this.setStatus(health_server_1.workerStatus.UNHEALTHY);
626
659
  this.logger.info('Starting to exit...');
660
+ // Pause the worker on the server so it stops receiving new task assignments
661
+ // before we evict waiting durable runs, mirroring Python's pause_task_assignment().
662
+ if (this.workerId) {
663
+ try {
664
+ yield this.client.workers.pause(this.workerId);
665
+ }
666
+ catch (e) {
667
+ this.logger.error(`Could not pause worker: ${e.message}`);
668
+ }
669
+ }
670
+ if (this.evictionManager) {
671
+ try {
672
+ const evicted = yield this.evictionManager.evictAllWaiting();
673
+ if (evicted > 0) {
674
+ this.logger.info(`Evicted ${evicted} waiting durable run(s) during shutdown`);
675
+ }
676
+ }
677
+ catch (e) {
678
+ this.logger.error(`Could not evict waiting runs: ${e.message}`);
679
+ }
680
+ }
681
+ try {
682
+ yield this.client.durableListener.stop();
683
+ }
684
+ catch (e) {
685
+ this.logger.error(`Could not stop durable listener: ${e.message}`);
686
+ }
627
687
  try {
628
688
  yield ((_a = this.listener) === null || _a === void 0 ? void 0 : _a.unregister());
629
689
  }
@@ -719,20 +779,22 @@ class InternalWorker {
719
779
  }
720
780
  handleAction(action) {
721
781
  return __awaiter(this, void 0, void 0, function* () {
722
- const type = action.actionType
723
- ? (0, dispatcher_1.actionTypeFromJSON)(action.actionType)
724
- : dispatcher_1.ActionType.START_STEP_RUN;
725
- if (type === dispatcher_1.ActionType.START_STEP_RUN) {
726
- yield this.handleStartStepRun(action);
727
- }
728
- else if (type === dispatcher_1.ActionType.CANCEL_STEP_RUN) {
729
- yield this.handleCancelStepRun(action);
730
- }
731
- else if (type === dispatcher_1.ActionType.START_GET_GROUP_KEY) {
732
- yield this.handleStartGroupKeyRun(action);
733
- }
734
- else {
735
- this.logger.error(`Worker ${this.name} received unknown action type ${type}`);
782
+ const type = (0, dispatcher_1.actionTypeFromJSON)(action.actionType) || dispatcher_1.ActionType.START_STEP_RUN;
783
+ switch (type) {
784
+ case dispatcher_1.ActionType.START_STEP_RUN:
785
+ return this.handleStartStepRun(action);
786
+ case dispatcher_1.ActionType.CANCEL_STEP_RUN:
787
+ return this.handleCancelStepRun(action);
788
+ case dispatcher_1.ActionType.START_GET_GROUP_KEY:
789
+ this.logger.error(`Worker ${this.name} received unsupported action type START_GET_GROUP_KEY, please upgrade to V1...`);
790
+ return Promise.resolve();
791
+ case dispatcher_1.ActionType.UNRECOGNIZED:
792
+ this.logger.error(`Worker ${this.name} received unrecognized action type ${action.actionType}`);
793
+ return Promise.resolve();
794
+ default: {
795
+ const _ = type;
796
+ throw new Error(`Unhandled action type: ${_}`);
797
+ }
736
798
  }
737
799
  });
738
800
  }
@@ -791,15 +853,15 @@ function isLeafTask(task, allTasks) {
791
853
  return !allTasks.some((t) => { var _a; return (_a = t.parents) === null || _a === void 0 ? void 0 : _a.some((p) => p.name === task.name); });
792
854
  }
793
855
  function mapRateLimitPb(limits) {
794
- if (!limits)
856
+ if (!limits) {
795
857
  return [];
858
+ }
796
859
  return limits.map((l) => {
797
860
  let key = l.staticKey;
798
861
  const keyExpression = l.dynamicKey;
799
862
  if (l.key !== undefined) {
800
- // eslint-disable-next-line no-console
801
863
  console.warn('key is deprecated and will be removed in a future release, please use staticKey instead');
802
- key = l.key;
864
+ ({ key } = l);
803
865
  }
804
866
  if (keyExpression !== undefined) {
805
867
  if (key !== undefined) {
@@ -816,7 +878,7 @@ function mapRateLimitPb(limits) {
816
878
  let units;
817
879
  let unitsExpression;
818
880
  if (typeof l.units === 'number') {
819
- units = l.units;
881
+ ({ units } = l);
820
882
  }
821
883
  else {
822
884
  if (!validateCelExpression(l.units)) {
@@ -853,9 +915,15 @@ function mapRateLimitPb(limits) {
853
915
  });
854
916
  }
855
917
  // Helper function to validate CEL expressions
856
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
857
918
  function validateCelExpression(_expr) {
858
919
  // FIXME: this is a placeholder. In a real implementation, you'd need to use a CEL parser or validator.
859
920
  // For now, we'll just return true to mimic the behavior.
860
921
  return true;
861
922
  }
923
+ function resolveExecutionTimeout(task, workflowDefaults) {
924
+ return (0, duration_1.durationToString)(task.executionTimeout || task.timeout || (workflowDefaults === null || workflowDefaults === void 0 ? void 0 : workflowDefaults.executionTimeout) || '60s');
925
+ }
926
+ function resolveScheduleTimeout(task, workflowDefaults) {
927
+ const value = task.scheduleTimeout || (workflowDefaults === null || workflowDefaults === void 0 ? void 0 : workflowDefaults.scheduleTimeout);
928
+ return value ? (0, duration_1.durationToString)(value) : undefined;
929
+ }
@@ -61,6 +61,7 @@ export declare class Worker {
61
61
  * @returns Promise that resolves when the worker is stopped or killed
62
62
  */
63
63
  start(): Promise<void>;
64
+ private _checkEvictionSupport;
64
65
  /**
65
66
  * Stops the worker
66
67
  * @returns Promise that resolves when the worker stops