@voltro/workflow 0.63.0 → 0.65.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.
@@ -1,16 +1,17 @@
1
1
  import { Activity as e, Activity as t, DurableClock as n, DurableClock as r, DurableQueue as i, DurableQueue as a, DurableRateLimiter as o, DurableRateLimiter as s, Workflow as c, Workflow as l } from "@effect/workflow";
2
- import { Cause as u, Context as d, Cron as f, Duration as p, Effect as m, Either as h, Exit as ee, FiberRef as g, Option as te, Schedule as _, Schema as ne } from "effect";
2
+ import { Cause as u, Context as d, Cron as f, Duration as p, Effect as m, Either as h, Exit as ee, FiberRef as g, Option as _, Schedule as v, Schema as y } from "effect";
3
+ import { attachWorkflowAccess as te, resolveWorkflowAccess as ne } from "@voltro/protocol";
3
4
  //#region src/flowControl.ts
4
- var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0 || e.concurrency !== void 0 || e.throttle !== void 0 || e.rateLimit !== void 0 || e.batch !== void 0 || e.timeouts?.startMs !== void 0 || e.timeouts?.finishMs !== void 0), v = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, y = [
5
+ var b = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0 || e.concurrency !== void 0 || e.throttle !== void 0 || e.rateLimit !== void 0 || e.batch !== void 0 || e.timeouts?.startMs !== void 0 || e.timeouts?.finishMs !== void 0), x = (e) => e?.cancelOn !== void 0 && e.cancelOn.length > 0, re = [
5
6
  "debounce",
6
7
  "batch",
7
8
  "throttle",
8
9
  "concurrency"
9
- ], b = (e) => {
10
+ ], S = (e) => {
10
11
  if (e === void 0) return [];
11
12
  let t = [];
12
13
  return e.debounce !== void 0 && t.push("debounce"), e.batch !== void 0 && t.push("batch"), e.throttle !== void 0 && t.push("throttle"), e.concurrency !== void 0 && t.push("concurrency"), t;
13
- }, x = (e, t, n) => {
14
+ }, C = (e, t, n) => {
14
15
  let r;
15
16
  try {
16
17
  r = p.toMillis(p.decode(e));
@@ -19,26 +20,26 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
19
20
  }
20
21
  if (!Number.isFinite(r) || r <= 0) throw Error(`workflow '${n}': ${t} must be a positive finite duration, got ${String(e)}`);
21
22
  return r;
22
- }, S = (e, t, n) => {
23
+ }, w = (e, t, n) => {
23
24
  if (!Number.isInteger(e) || e <= 0) throw Error(`workflow '${n}': ${t} must be a positive integer, got ${String(e)}`);
24
25
  return e;
25
- }, C = (e, t, n) => {
26
+ }, T = (e, t, n) => {
26
27
  if (typeof e != "function") throw Error(`workflow '${n}': ${t} must be a function of the payload`);
27
28
  return e;
28
- }, w = (e) => {
29
+ }, E = (e) => {
29
30
  let t = e?.ast?.propertySignatures;
30
31
  if (!Array.isArray(t)) return !1;
31
32
  let n = t.find((e) => e.name === "items");
32
33
  return n !== void 0 && n.type?._tag === "TupleType";
33
- }, T = (e) => {
34
+ }, D = (e) => {
34
35
  let { workflowName: t, control: n } = e;
35
36
  if (n === void 0) return;
36
37
  let r = { workflowName: t };
37
38
  if (n.debounce !== void 0) {
38
- let e = n.debounce, i = x(e.period, "debounce.period", t), a = e.timeout === void 0 ? void 0 : x(e.timeout, "debounce.timeout", t);
39
+ let e = n.debounce, i = C(e.period, "debounce.period", t), a = e.timeout === void 0 ? void 0 : C(e.timeout, "debounce.timeout", t);
39
40
  if (a !== void 0 && a < i) throw Error(`workflow '${t}': debounce.timeout (${a}ms) is shorter than debounce.period (${i}ms), so the burst can never be collapsed — the run would be admitted before the quiet period could ever elapse. Raise the timeout or lower the period.`);
40
41
  r.debounce = {
41
- key: C(e.key, "debounce.key", t),
42
+ key: T(e.key, "debounce.key", t),
42
43
  periodMs: i,
43
44
  ...a === void 0 ? {} : { timeoutMs: a }
44
45
  };
@@ -47,7 +48,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
47
48
  let e = n.singleton;
48
49
  if (e.mode !== "skip" && e.mode !== "cancel") throw Error(`workflow '${t}': singleton.mode must be 'skip' or 'cancel'. There is no default — 'skip' discards the incoming request and 'cancel' discards the running one, and choosing for you would silently throw away work either way.`);
49
50
  r.singleton = {
50
- key: C(e.key, "singleton.key", t),
51
+ key: T(e.key, "singleton.key", t),
51
52
  mode: e.mode
52
53
  };
53
54
  }
@@ -55,34 +56,34 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
55
56
  let e = n.concurrency;
56
57
  if (e.pool !== void 0 && (typeof e.pool != "string" || e.pool.trim() === "")) throw Error(`workflow '${t}': concurrency.pool must be a non-empty name — it is the identity other workflows declare to share this budget, and an empty one would silently merge every empty-named pool in the deployment into one.`);
57
58
  r.concurrency = {
58
- limit: S(e.limit, "concurrency.limit", t),
59
- ...e.key === void 0 ? {} : { key: C(e.key, "concurrency.key", t) },
59
+ limit: w(e.limit, "concurrency.limit", t),
60
+ ...e.key === void 0 ? {} : { key: T(e.key, "concurrency.key", t) },
60
61
  ...e.pool === void 0 ? {} : { pool: e.pool.trim() }
61
62
  };
62
63
  }
63
64
  if (n.throttle !== void 0) {
64
65
  let e = n.throttle;
65
66
  r.throttle = {
66
- limit: S(e.limit, "throttle.limit", t),
67
- periodMs: x(e.period, "throttle.period", t),
68
- ...e.key === void 0 ? {} : { key: C(e.key, "throttle.key", t) }
67
+ limit: w(e.limit, "throttle.limit", t),
68
+ periodMs: C(e.period, "throttle.period", t),
69
+ ...e.key === void 0 ? {} : { key: T(e.key, "throttle.key", t) }
69
70
  };
70
71
  }
71
72
  if (n.rateLimit !== void 0) {
72
73
  let e = n.rateLimit;
73
74
  r.rateLimit = {
74
- limit: S(e.limit, "rateLimit.limit", t),
75
- periodMs: x(e.period, "rateLimit.period", t),
76
- ...e.key === void 0 ? {} : { key: C(e.key, "rateLimit.key", t) }
75
+ limit: w(e.limit, "rateLimit.limit", t),
76
+ periodMs: C(e.period, "rateLimit.period", t),
77
+ ...e.key === void 0 ? {} : { key: T(e.key, "rateLimit.key", t) }
77
78
  };
78
79
  }
79
80
  if (n.batch !== void 0) {
80
81
  let i = n.batch;
81
- if (e.payloadSchema !== void 0 && !w(e.payloadSchema)) throw Error(`workflow '${t}': batch is declared, so the workflow's own \`payload\` must be the BATCH shape — \`Schema.Struct({ items: Schema.Array(Item) })\` — while callers start it with a SINGLE item. Declare the item's schema as \`batch.item\`. Checked here rather than at admission because a decode failure on the batching replica is a failure nobody is watching.`);
82
+ if (e.payloadSchema !== void 0 && !E(e.payloadSchema)) throw Error(`workflow '${t}': batch is declared, so the workflow's own \`payload\` must be the BATCH shape — \`Schema.Struct({ items: Schema.Array(Item) })\` — while callers start it with a SINGLE item. Declare the item's schema as \`batch.item\`. Checked here rather than at admission because a decode failure on the batching replica is a failure nobody is watching.`);
82
83
  r.batch = {
83
- ...i.key === void 0 ? {} : { key: C(i.key, "batch.key", t) },
84
- maxSize: S(i.maxSize, "batch.maxSize", t),
85
- timeoutMs: x(i.timeout, "batch.timeout", t),
84
+ ...i.key === void 0 ? {} : { key: T(i.key, "batch.key", t) },
85
+ maxSize: w(i.maxSize, "batch.maxSize", t),
86
+ timeoutMs: C(i.timeout, "batch.timeout", t),
86
87
  ...i.item === void 0 ? {} : { item: i.item }
87
88
  };
88
89
  }
@@ -91,7 +92,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
91
92
  r.priority = n.priority;
92
93
  }
93
94
  if (n.timeouts !== void 0) {
94
- let e = n.timeouts, i = e.start === void 0 ? void 0 : x(e.start, "timeouts.start", t), a = e.finish === void 0 ? void 0 : x(e.finish, "timeouts.finish", t);
95
+ let e = n.timeouts, i = e.start === void 0 ? void 0 : C(e.start, "timeouts.start", t), a = e.finish === void 0 ? void 0 : C(e.finish, "timeouts.finish", t);
95
96
  (i !== void 0 || a !== void 0) && (r.timeouts = {
96
97
  ...i === void 0 ? {} : { startMs: i },
97
98
  ...a === void 0 ? {} : { finishMs: a }
@@ -111,7 +112,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
111
112
  if (typeof e?.event != "string" || e.event.length === 0) throw Error(`workflow '${t}': ${r}.event must be a non-empty event name, exactly as ctx.events.publish writes it.`);
112
113
  if (e.schema === void 0 || typeof e.schema.ast != "object") throw Error(`workflow '${t}': ${r}.schema must be a Schema for the event payload. It is decoded before \`match\` runs, so the predicate reads the domain type rather than raw JSON.`);
113
114
  if (typeof e.match != "function") throw Error(`workflow '${t}': ${r}.match is required. Omitting it would mean "cancel every live run of this workflow whenever '${e.event}' is published" — write \`match: () => true\` if that is what you mean, so it is visible in review.`);
114
- let i = e.within === void 0 ? void 0 : x(e.within, `${r}.within`, t);
115
+ let i = e.within === void 0 ? void 0 : C(e.within, `${r}.within`, t);
115
116
  return {
116
117
  event: e.event,
117
118
  schema: e.schema,
@@ -122,9 +123,9 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
122
123
  });
123
124
  e.length > 0 && (r.cancelOn = e);
124
125
  }
125
- if (r.timeouts?.startMs !== void 0 && b(r).length === 0) throw Error(`workflow '${t}': timeouts.start bounds how long a run may sit in the ADMISSION queue, but this workflow declares no control that can defer one (debounce, batch, throttle, concurrency). It would never fire. Use timeouts.finish to bound the run itself.`);
126
+ if (r.timeouts?.startMs !== void 0 && S(r).length === 0) throw Error(`workflow '${t}': timeouts.start bounds how long a run may sit in the ADMISSION queue, but this workflow declares no control that can defer one (debounce, batch, throttle, concurrency). It would never fire. Use timeouts.finish to bound the run itself.`);
126
127
  return r;
127
- }, E = (e) => {
128
+ }, O = (e) => {
128
129
  let t = /* @__PURE__ */ new Map();
129
130
  for (let n of e) {
130
131
  let e = n?.concurrency;
@@ -137,25 +138,25 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
137
138
  else if (r.limit !== e.limit) throw Error(`concurrency pool '${e.pool}': '${n.workflowName}' declares limit ${e.limit}, but ${r.workflows.map((e) => `'${e}'`).join(", ")} declare${r.workflows.length === 1 ? "s" : ""} limit ${r.limit}. A pool is ONE budget — every member must declare the same number, or the enforced limit would depend on which workflow's start arrived first. Align the limits, or give the workflows different pool names if they were never meant to share.`);
138
139
  else r.workflows.push(n.workflowName);
139
140
  }
140
- }, D = class extends d.Tag("@voltro/WorkflowRunRecorder")() {}, O = g.unsafeMake(void 0), k = g.unsafeMake(void 0), A = g.unsafeMake(void 0), j = g.unsafeMake([]), M = () => g.get(O), N = () => g.get(k), P = class extends d.Tag("@voltro/WorkflowStepInterceptor")() {}, F = 864e5, ie = /* @__PURE__ */ new Set([
141
+ }, k = class extends d.Tag("@voltro/WorkflowRunRecorder")() {}, A = g.unsafeMake(void 0), j = g.unsafeMake(void 0), M = g.unsafeMake(void 0), N = g.unsafeMake([]), P = () => g.get(A), ie = () => g.get(j), F = class extends d.Tag("@voltro/WorkflowStepInterceptor")() {}, I = 864e5, ae = /* @__PURE__ */ new Set([
141
142
  "skip",
142
143
  "buffer",
143
144
  "cancelOther"
144
- ]), ae = /* @__PURE__ */ new Set([
145
+ ]), L = /* @__PURE__ */ new Set([
145
146
  "skip",
146
147
  "latest",
147
148
  "all"
148
- ]), I = (e, t) => {
149
+ ]), R = (e, t) => {
149
150
  if (t === void 0) return;
150
151
  if (typeof t.timezone != "string" || t.timezone.trim() === "") throw Error(`workflow '${e}': schedule.timezone is required (e.g. "UTC", "Europe/Berlin") — never server-local, which differs between your machine and the container.`);
151
152
  let n = f.parse(t.cron, t.timezone);
152
153
  if (h.isLeft(n)) throw Error(`workflow '${e}': schedule.cron "${t.cron}" (tz="${t.timezone}") is not a valid cron expression — ${String(n.left)}`);
153
154
  let r = t.onOverlap ?? "skip";
154
- if (!ie.has(r)) throw Error(`workflow '${e}': schedule.onOverlap must be 'skip' | 'buffer' | 'cancelOther', got ${JSON.stringify(r)}`);
155
+ if (!ae.has(r)) throw Error(`workflow '${e}': schedule.onOverlap must be 'skip' | 'buffer' | 'cancelOther', got ${JSON.stringify(r)}`);
155
156
  let i = t.backfill ?? "skip";
156
- if (!ae.has(i)) throw Error(`workflow '${e}': schedule.backfill must be 'skip' | 'latest' | 'all', got ${JSON.stringify(i)}`);
157
- let a = F;
158
- return t.maxRuntime !== void 0 && (a = L(t.maxRuntime, e)), {
157
+ if (!L.has(i)) throw Error(`workflow '${e}': schedule.backfill must be 'skip' | 'latest' | 'all', got ${JSON.stringify(i)}`);
158
+ let a = I;
159
+ return t.maxRuntime !== void 0 && (a = z(t.maxRuntime, e)), {
159
160
  cron: t.cron,
160
161
  timezone: t.timezone,
161
162
  ...t.payload === void 0 ? {} : { payload: t.payload },
@@ -163,7 +164,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
163
164
  backfill: i,
164
165
  maxRuntimeMs: a
165
166
  };
166
- }, L = (e, t) => {
167
+ }, z = (e, t) => {
167
168
  let n;
168
169
  try {
169
170
  n = p.toMillis(p.decode(e));
@@ -172,11 +173,11 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
172
173
  }
173
174
  if (!Number.isFinite(n) || n <= 0) throw Error(`workflow '${t}': schedule.maxRuntime must be a positive finite duration`);
174
175
  return n;
175
- }, R = "__voltroWorkflowSchedule", z = (e) => {
176
+ }, B = "__voltroWorkflowSchedule", V = (e) => {
176
177
  if (typeof e != "object" || !e) return;
177
- let t = e[R];
178
+ let t = e[B];
178
179
  return t === void 0 ? void 0 : t;
179
- }, B = (e) => {
180
+ }, H = (e) => {
180
181
  let t = /* @__PURE__ */ new Map();
181
182
  for (let n of e) t.set(n.stepName, (t.get(n.stepName) ?? 0) + 1);
182
183
  let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = (e) => !r.has(e) && (r.add(e), !0);
@@ -205,79 +206,79 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
205
206
  return e;
206
207
  }
207
208
  };
208
- }, V = g.unsafeMake(void 0), H = (e) => ({
209
+ }, U = g.unsafeMake(void 0), W = (e) => ({
209
210
  kind: e.kind,
210
211
  stepName: e.stepName,
211
212
  recorded: e.recorded,
212
213
  reached: e.reached,
213
214
  detail: e.detail
214
- }), U = (e) => m.gen(function* () {
215
+ }), G = (e) => m.gen(function* () {
215
216
  if (e.length === 0) return;
216
- let t = yield* g.get(O), n = yield* m.serviceOption(D);
217
+ let t = yield* g.get(A), n = yield* m.serviceOption(k);
217
218
  if (t === void 0 || n._tag !== "Some") return;
218
219
  let r = n.value;
219
220
  for (let n of e) yield* m.promise(() => r.recordEvent({
220
221
  runId: t,
221
222
  eventType: "nondeterminism-suspected",
222
- payload: H(n)
223
+ payload: W(n)
223
224
  }).then(() => void 0).catch(() => void 0));
224
- }), W = (e) => {
225
+ }), K = (e) => {
225
226
  if (typeof e != "object" || !e) return;
226
227
  let t = e.retryAfterMillis;
227
228
  if (typeof t == "number" && Number.isFinite(t) && t >= 0) return p.millis(t);
228
229
  let n = e.retryAfter;
229
230
  if (typeof n == "number" && Number.isFinite(n) && n >= 0) return p.seconds(n);
230
- }, G = (e) => p.decode(e), K = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, q = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, J = (e) => {
231
+ }, q = (e) => p.decode(e), J = (e) => typeof e == "object" && e && "_tag" in e ? String(e._tag) : void 0, oe = (e) => e !== void 0 && (e.maxAttempts ?? 3) > 1, se = (e) => {
231
232
  if (e.retryable) return e.retryable;
232
233
  if (e.retryableErrors && e.retryableErrors.length > 0) {
233
234
  let t = new Set(e.retryableErrors);
234
235
  return (e) => {
235
- let n = K(e);
236
+ let n = J(e);
236
237
  return n !== void 0 && t.has(n);
237
238
  };
238
239
  }
239
240
  return () => !0;
240
- }, oe = (e) => {
241
- let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? _.linear(G(e.step ?? t)) : n === "fixed" ? _.spaced(G(t)) : _.exponential(G(t), e.factor ?? 2);
241
+ }, ce = (e) => {
242
+ let t = e.baseDelay ?? "200 millis", n = e.strategy ?? "exponential", r = e.maxAttempts ?? 3, i = n === "linear" ? v.linear(q(e.step ?? t)) : n === "fixed" ? v.spaced(q(t)) : v.exponential(q(t), e.factor ?? 2);
242
243
  if (e.maxDelay !== void 0) {
243
- let t = G(e.maxDelay);
244
- i = _.modifyDelay(i, (e, n) => p.min(n, t));
244
+ let t = q(e.maxDelay);
245
+ i = v.modifyDelay(i, (e, n) => p.min(n, t));
245
246
  }
246
- (e.jitter ?? !0) === !0 && (i = _.jittered(i));
247
- let a = _.intersect(i, _.recurs(Math.max(0, r - 1)));
248
- return e.maxElapsed !== void 0 && (a = _.upTo(G(e.maxElapsed))(a)), a;
249
- }, se = (e, t) => {
250
- let n = p.toMillis(G(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + p.toMillis(G(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
251
- return e.maxDelay !== void 0 && (i = Math.min(i, p.toMillis(G(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
252
- }, ce = (e, t, n, r) => m.gen(function* () {
253
- let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : p.toMillis(G(t.maxElapsed)), o = yield* m.sync(() => Date.now()), s = 0;
247
+ (e.jitter ?? !0) === !0 && (i = v.jittered(i));
248
+ let a = v.intersect(i, v.recurs(Math.max(0, r - 1)));
249
+ return e.maxElapsed !== void 0 && (a = v.upTo(q(e.maxElapsed))(a)), a;
250
+ }, le = (e, t) => {
251
+ let n = p.toMillis(q(e.baseDelay ?? "200 millis")), r = e.strategy ?? "exponential", i = r === "fixed" ? n : r === "linear" ? n + p.toMillis(q(e.step ?? e.baseDelay ?? "200 millis")) * (t - 1) : n * (e.factor ?? 2) ** (t - 1);
252
+ return e.maxDelay !== void 0 && (i = Math.min(i, p.toMillis(q(e.maxDelay)))), (e.jitter ?? !0) === !0 && (i *= Math.random()), i;
253
+ }, ue = (e, t, n, r) => m.gen(function* () {
254
+ let i = t.maxAttempts ?? 3, a = t.maxElapsed === void 0 ? Infinity : p.toMillis(q(t.maxElapsed)), o = yield* m.sync(() => Date.now()), s = 0;
254
255
  for (;;) {
255
256
  let c = yield* m.exit(e);
256
257
  if (ee.isSuccess(c)) return c.value;
257
- let l = c.cause, d = u.failureOption(l), f = te.isSome(d) ? d.value : u.squash(l);
258
+ let l = c.cause, d = u.failureOption(l), f = _.isSome(d) ? d.value : u.squash(l);
258
259
  s += 1;
259
260
  let h = (yield* m.sync(() => Date.now())) - o;
260
261
  if (s >= i || !n(f) || h >= a) return yield* m.failCause(l);
261
262
  r?.(f);
262
- let g = W(f), _ = g === void 0 ? se(t, s) : p.toMillis(g);
263
- yield* m.sleep(p.millis(_));
263
+ let g = K(f), v = g === void 0 ? le(t, s) : p.toMillis(g);
264
+ yield* m.sleep(p.millis(v));
264
265
  }
265
- }), le = (e, t, n) => {
266
- if (!q(t)) return e;
267
- let r = J(t);
268
- if (t.respectRetryAfter === !0) return ce(e, t, r, n);
269
- let i = oe(t), a = n ? m.tapError(e, (e) => m.sync(() => {
266
+ }), de = (e, t, n) => {
267
+ if (!oe(t)) return e;
268
+ let r = se(t);
269
+ if (t.respectRetryAfter === !0) return ue(e, t, r, n);
270
+ let i = ce(t), a = n ? m.tapError(e, (e) => m.sync(() => {
270
271
  r(e) && n(e);
271
272
  })) : e;
272
273
  return m.retry(a, {
273
274
  schedule: i,
274
275
  while: r
275
276
  });
276
- }, Y = Symbol.for("voltro.workflow.workerLayer"), X = Symbol.for("voltro.workflow.version"), Z = "__voltroWorkflowMessages", Q = "__voltroWorkflowFlowControl", ue = (e) => typeof e == "object" && !!e && e[Y] === !0, de = (e) => typeof e == "object" && e && e[X] !== void 0 ? e[X] : {
277
+ }, Y = Symbol.for("voltro.workflow.workerLayer"), X = Symbol.for("voltro.workflow.version"), Z = "__voltroWorkflowMessages", Q = "__voltroWorkflowFlowControl", fe = (e) => typeof e == "object" && !!e && e[Y] === !0, pe = (e) => typeof e == "object" && e && e[X] !== void 0 ? e[X] : {
277
278
  version: "1",
278
279
  compatibleWith: ["1"],
279
280
  patches: []
280
- }, fe = ((e) => {
281
+ }, me = ((e) => {
281
282
  let t = c.make(e), n = e.suspendOnFailure === !0 ? t.annotate(c.SuspendOnFailure, !0) : t, r = String(e.version ?? "1"), i = {
282
283
  version: r,
283
284
  compatibleWith: (e.compatibleWith ?? [r]).map(String),
@@ -292,8 +293,8 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
292
293
  }), Object.defineProperty(n, Z, {
293
294
  value: a,
294
295
  enumerable: !1
295
- });
296
- let o = T({
296
+ }), te(n, ne(e.name, e));
297
+ let o = D({
297
298
  workflowName: e.name,
298
299
  payloadSchema: e.payload,
299
300
  control: e
@@ -302,25 +303,25 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
302
303
  value: o,
303
304
  enumerable: !1
304
305
  });
305
- let s = I(e.name, e.schedule);
306
- return s !== void 0 && Object.defineProperty(n, R, {
306
+ let s = R(e.name, e.schedule);
307
+ return s !== void 0 && Object.defineProperty(n, B, {
307
308
  value: s,
308
309
  enumerable: !1
309
310
  }), n;
310
- }), pe = (e) => {
311
+ }), he = (e) => {
311
312
  if (typeof e != "object" || !e) return;
312
313
  let t = e[Q];
313
314
  return t === void 0 ? void 0 : t;
314
- }, me = i.make, he = i.process, ge = ((...e) => {
315
+ }, ge = i.make, _e = i.process, ve = ((...e) => {
315
316
  let t = i.worker(...e);
316
317
  return Object.defineProperty(t, Y, {
317
318
  value: !0,
318
319
  enumerable: !1
319
320
  }), t;
320
- }), _e = o.rateLimit, $ = (e) => m.gen(function* () {
321
- let t = yield* O, r = yield* m.serviceOption(D), i = p.toMillis(p.decode(e.duration));
321
+ }), ye = o.rateLimit, $ = (e) => m.gen(function* () {
322
+ let t = yield* A, r = yield* m.serviceOption(k), i = p.toMillis(p.decode(e.duration));
322
323
  if (t !== void 0 && r._tag === "Some") {
323
- let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* A;
324
+ let a = r.value, o = new Date(Date.now() + i).toISOString(), s = yield* M;
324
325
  yield* m.promise(() => a.recordEvent({
325
326
  runId: t,
326
327
  eventType: "timer-set",
@@ -344,18 +345,18 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
344
345
  return;
345
346
  }
346
347
  yield* n.sleep(e);
347
- }), ve = (t) => m.gen(function* () {
348
+ }), be = (t) => m.gen(function* () {
348
349
  let n = (yield* e.make({
349
350
  name: `sleepUntil:${t.name}`,
350
- success: ne.Number,
351
+ success: y.Number,
351
352
  execute: m.sync(() => t.until instanceof Date ? t.until.getTime() : t.until)
352
353
  })) - Date.now();
353
354
  n <= 0 || (yield* $({
354
355
  name: t.name,
355
356
  duration: `${n} millis`
356
357
  }));
357
- }), ye = (t, n, r, i) => m.gen(function* () {
358
- let a = yield* O, o = yield* e.CurrentAttempt, s = yield* m.serviceOption(D), c = yield* m.serviceOption(P), l = c._tag === "Some" ? c.value.interceptor(n, {
358
+ }), xe = (t, n, r, i) => m.gen(function* () {
359
+ let a = yield* A, o = yield* e.CurrentAttempt, s = yield* m.serviceOption(k), c = yield* m.serviceOption(F), l = c._tag === "Some" ? c.value.interceptor(n, {
359
360
  runId: a ?? "unrecorded",
360
361
  stepName: t,
361
362
  attempt: o
@@ -376,7 +377,7 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
376
377
  }
377
378
  }
378
379
  let p = Date.now();
379
- return yield* le(l, i).pipe(m.tap((e) => d && f ? m.promise(async () => {
380
+ return yield* de(l, i).pipe(m.tap((e) => d && f ? m.promise(async () => {
380
381
  try {
381
382
  await f.endStepSuccess({
382
383
  stepRecordId: d,
@@ -400,23 +401,23 @@ var re = (e) => e !== void 0 && (e.debounce !== void 0 || e.singleton !== void 0
400
401
  });
401
402
  } catch {}
402
403
  }) : m.void));
403
- }), be = (e) => m.gen(function* () {
404
- let t = yield* g.get(V);
404
+ }), Se = (e) => m.gen(function* () {
405
+ let t = yield* g.get(U);
405
406
  if (t === void 0) return;
406
407
  let n = t.reach(e);
407
- n !== void 0 && (yield* U([n]));
408
- }), xe = (e, t) => {
408
+ n !== void 0 && (yield* G([n]));
409
+ }), Ce = (e, t) => {
409
410
  let n = e;
410
411
  return {
411
412
  ...e,
412
- commit: () => m.zipRight(be(t), n)
413
+ commit: () => m.zipRight(Se(t), n)
413
414
  };
414
- }, Se = (t) => {
415
+ }, we = (t) => {
415
416
  let { input: n, retry: r, ...i } = t;
416
- return xe(e.make({
417
+ return Ce(e.make({
417
418
  ...i,
418
- execute: ye(i.name, i.execute, n, r)
419
+ execute: xe(i.name, i.execute, n, r)
419
420
  }), i.name);
420
- }, Ce = (e) => m.map(g.get(j), (t) => t.includes(e)), we = c.withCompensation, Te = e.idempotencyKey;
421
+ }, Te = (e) => m.map(g.get(N), (t) => t.includes(e)), Ee = c.withCompensation, De = e.idempotencyKey;
421
422
  //#endregion
422
- export { z as A, y as B, l as C, U as D, H as E, A as F, T as G, b as H, D as I, P as L, k as M, j as N, F as O, O as P, N as R, fe as S, B as T, v as U, E as V, re as W, ve as _, r as a, t as b, s as c, ue as d, Ce as f, $ as g, _e as h, Y as i, I as j, R as k, pe as l, ge as m, Z as n, me as o, he as p, X as r, a as s, Q as t, de as u, Se as v, V as w, we as x, Te as y, M as z };
423
+ export { V as A, re as B, l as C, G as D, W as E, M as F, D as G, S as H, k as I, F as L, j as M, N, I as O, A as P, ie as R, me as S, H as T, x as U, O as V, b as W, be as _, r as a, t as b, s as c, fe as d, Te as f, $ as g, ye as h, Y as i, R as j, B as k, he as l, ve as m, Z as n, ge as o, _e as p, X as r, a as s, Q as t, pe as u, we as v, U as w, Ee as x, De as y, P as z };
@@ -6,6 +6,7 @@ import { Effect } from 'effect';
6
6
  import { FiberRef } from 'effect';
7
7
  import { Schema } from 'effect';
8
8
  import { Activity as stepModule } from '@effect/workflow';
9
+ import { WorkflowAccessOptions } from '@voltro/protocol';
9
10
  import { Workflow as workflowModule } from '@effect/workflow';
10
11
 
11
12
  /**
@@ -881,7 +882,7 @@ declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPa
881
882
  readonly schedule?: WorkflowScheduleDeclaration<DecodedPayload<Payload>>;
882
883
  } & Omit<WorkflowBaseOptions, 'name' | 'payload' | 'idempotencyKey' | 'success' | 'error'> & WorkflowVersionOptions & {
883
884
  readonly messages?: Messages;
884
- } & WorkflowFlowControl<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
885
+ } & WorkflowFlowControl<DecodedPayload<Payload>> & WorkflowAccessOptions<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
885
886
 
886
887
  declare type WorkflowMake = typeof workflowModule.make;
887
888
 
@@ -1,2 +1,2 @@
1
- import { A as e, B as t, C as n, D as r, E as i, G as a, H as o, O as s, S as c, T as l, U as u, V as d, W as f, _ as p, a as m, b as h, c as g, d as _, f as v, g as y, h as b, i as x, j as S, k as C, l as w, m as T, n as E, o as D, p as O, r as k, s as A, t as j, u as M, v as N, w as P, x as F, y as I } from "./primitives-B-HlFCap.js";
1
+ import { A as e, B as t, C as n, D as r, E as i, G as a, H as o, O as s, S as c, T as l, U as u, V as d, W as f, _ as p, a as m, b as h, c as g, d as _, f as v, g as y, h as b, i as x, j as S, k as C, l as w, m as T, n as E, o as D, p as O, r as k, s as A, t as j, u as M, v as N, w as P, x as F, y as I } from "./primitives-CqHxfASq.js";
2
2
  export { P as CurrentWorkflowReplayShape, s as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, t as DEFERRING_CONTROLS, j as WorkflowFlowControlProperty, E as WorkflowMessagesProperty, C as WorkflowScheduleProperty, k as WorkflowVersionTypeId, x as WorkflowWorkerLayerTypeId, d as assertConsistentPools, o as deferringControlsOf, m as durableClock, D as durableQueue, A as durableQueueModule, g as durableRateLimiterModule, w as getWorkflowFlowControl, e as getWorkflowSchedule, M as getWorkflowVersionMetadata, u as hasCancelOn, f as hasFlowControl, _ as isWorkflowWorkerLayer, l as makeReplayShapeTracker, i as nondeterminismEventPayload, v as patch, O as processQueue, T as queueWorker, b as rateLimit, r as reportNondeterminism, y as sleep, p as sleepUntil, N as step, I as stepIdempotencyKey, h as stepModule, a as validateFlowControl, S as validateWorkflowSchedule, F as withCompensation, c as workflow, n as workflowModule };