brass-runtime 1.14.0 → 1.16.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 (90) hide show
  1. package/README.md +410 -135
  2. package/dist/agent/cli/main.cjs +49 -43
  3. package/dist/agent/cli/main.js +11 -5
  4. package/dist/agent/cli/main.mjs +11 -5
  5. package/dist/agent/index.cjs +8 -3
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +7 -2
  8. package/dist/agent/index.mjs +7 -2
  9. package/dist/{chunk-BMRF4FN6.js → chunk-2WC63LJK.mjs} +68 -242
  10. package/dist/chunk-3RG5ZIWI.js +10 -0
  11. package/dist/chunk-45F7OKGT.cjs +104 -0
  12. package/dist/chunk-5YOQOXEQ.cjs +2491 -0
  13. package/dist/chunk-7HUOJA4W.cjs +493 -0
  14. package/dist/{chunk-4N2JEK4H.mjs → chunk-7LVI2GIN.js} +252 -495
  15. package/dist/chunk-7TL2LHQJ.js +2491 -0
  16. package/dist/chunk-7V4KY4RL.mjs +104 -0
  17. package/dist/chunk-7XOPAB5Q.js +2143 -0
  18. package/dist/chunk-CCKHV5BT.mjs +193 -0
  19. package/dist/chunk-CY33PGEX.mjs +1110 -0
  20. package/dist/chunk-DJQ7OMMB.cjs +144 -0
  21. package/dist/chunk-F5EUMJL7.mjs +2143 -0
  22. package/dist/chunk-FM4W4QPL.js +193 -0
  23. package/dist/chunk-G3XGCZDQ.js +131 -0
  24. package/dist/{chunk-JT7D6M5H.js → chunk-G6IQOE4P.mjs} +252 -495
  25. package/dist/chunk-GOV47PPB.mjs +552 -0
  26. package/dist/chunk-H55LI6WY.js +93 -0
  27. package/dist/chunk-IJT6RRQ5.cjs +93 -0
  28. package/dist/chunk-J3H54ZRV.mjs +131 -0
  29. package/dist/chunk-JF4XXPZ5.cjs +552 -0
  30. package/dist/chunk-JNFRRJYH.cjs +2143 -0
  31. package/dist/chunk-JX3LZQJH.cjs +354 -0
  32. package/dist/chunk-K2T3DV26.mjs +93 -0
  33. package/dist/chunk-KCPT2D6G.js +552 -0
  34. package/dist/chunk-MWXMNYJS.cjs +1110 -0
  35. package/dist/{chunk-XTMZTVIT.cjs → chunk-N6VHMOWB.cjs} +140 -134
  36. package/dist/{chunk-WJESVBWN.js → chunk-NC5SDRYE.js} +16 -10
  37. package/dist/chunk-NOYZIMUJ.mjs +144 -0
  38. package/dist/chunk-NYL4D7SK.cjs +131 -0
  39. package/dist/chunk-OBGZSXTJ.cjs +10 -0
  40. package/dist/{chunk-UWMMYKVK.mjs → chunk-OOGJ73B6.js} +68 -242
  41. package/dist/chunk-PNVFW245.js +144 -0
  42. package/dist/chunk-PRWCB3QL.mjs +2491 -0
  43. package/dist/chunk-QY5FKYEQ.js +1110 -0
  44. package/dist/chunk-ROJC3NBJ.js +104 -0
  45. package/dist/chunk-SPUEME2B.cjs +343 -0
  46. package/dist/chunk-TDVMADDN.js +343 -0
  47. package/dist/chunk-TVN5I4U6.cjs +193 -0
  48. package/dist/chunk-U5KWK3PX.mjs +343 -0
  49. package/dist/chunk-VFIUZG7J.mjs +354 -0
  50. package/dist/{chunk-BKBFSOGT.cjs → chunk-WQ5QNU5R.cjs} +460 -703
  51. package/dist/chunk-XDZOO4L5.js +354 -0
  52. package/dist/chunk-Y6FXYEAI.mjs +10 -0
  53. package/dist/{chunk-MQF7HZ7Y.mjs → chunk-ZGLD4TVZ.mjs} +16 -10
  54. package/dist/client-CtFmoDvM.d.ts +645 -0
  55. package/dist/core/index.cjs +284 -0
  56. package/dist/core/index.d.ts +567 -0
  57. package/dist/core/index.js +284 -0
  58. package/dist/core/index.mjs +284 -0
  59. package/dist/{effect-DM56H743.d.ts → effect-CGNl5Rqp.d.ts} +118 -11
  60. package/dist/effectRunner-3ZHAD3LE.cjs +8 -0
  61. package/dist/effectRunner-A4CHJXJI.js +8 -0
  62. package/dist/effectRunner-OPUF6QRN.mjs +8 -0
  63. package/dist/http/index.cjs +4130 -890
  64. package/dist/http/index.d.ts +2289 -219
  65. package/dist/http/index.js +4116 -876
  66. package/dist/http/index.mjs +4116 -876
  67. package/dist/http/testing.cjs +159 -0
  68. package/dist/http/testing.d.ts +42 -0
  69. package/dist/http/testing.js +159 -0
  70. package/dist/http/testing.mjs +159 -0
  71. package/dist/index.cjs +305 -1168
  72. package/dist/index.d.ts +9 -701
  73. package/dist/index.js +176 -1039
  74. package/dist/index.mjs +176 -1039
  75. package/dist/observability/index.cjs +677 -0
  76. package/dist/observability/index.d.ts +79 -0
  77. package/dist/observability/index.js +677 -0
  78. package/dist/observability/index.mjs +677 -0
  79. package/dist/schedule-Fque9Abz.d.ts +70 -0
  80. package/dist/schema/index.cjs +25 -0
  81. package/dist/schema/index.d.ts +177 -0
  82. package/dist/schema/index.js +25 -0
  83. package/dist/schema/index.mjs +25 -0
  84. package/dist/server-C8hDXA74.d.ts +674 -0
  85. package/dist/stream-dvSs0QS5.d.ts +74 -0
  86. package/dist/tracer-B5tRH9H7.d.ts +230 -0
  87. package/dist/tracing-Dt9S_6V8.d.ts +148 -0
  88. package/package.json +37 -3
  89. package/dist/chunk-SKVY72E5.cjs +0 -667
  90. package/dist/stream-Oqe6WeLE.d.ts +0 -173
@@ -1,8 +1,18 @@
1
+ import {
2
+ raceWith
3
+ } from "./chunk-G3XGCZDQ.js";
4
+ import {
5
+ Scope
6
+ } from "./chunk-FM4W4QPL.js";
7
+ import {
8
+ getCurrentFiber,
9
+ unsafeGetCurrentRuntime,
10
+ unsafeRunFoldWithEnv
11
+ } from "./chunk-7LVI2GIN.js";
1
12
  import {
2
13
  Cause,
3
14
  Exit,
4
- Scope,
5
- async,
15
+ asyncEffect,
6
16
  asyncFail,
7
17
  asyncFlatMap,
8
18
  asyncFold,
@@ -11,225 +21,14 @@ import {
11
21
  asyncSync,
12
22
  fail,
13
23
  flatMap,
14
- getCurrentFiber,
15
24
  map,
16
25
  mapError,
17
26
  none,
18
27
  orElseOptional,
19
- raceWith,
20
28
  some,
21
29
  succeed,
22
- sync,
23
- unsafeGetCurrentRuntime,
24
- unsafeRunFoldWithEnv
25
- } from "./chunk-4N2JEK4H.mjs";
26
-
27
- // src/core/runtime/combinators.ts
28
- function sleep(ms) {
29
- return async((_env, cb) => {
30
- const delay = Math.max(0, Math.floor(ms));
31
- const id = setTimeout(() => cb({ _tag: "Success", value: void 0 }), delay);
32
- return () => clearTimeout(id);
33
- });
34
- }
35
- function timeout(effect, ms) {
36
- return async((env, cb) => {
37
- let done = false;
38
- let timerId;
39
- let effectRunning = true;
40
- timerId = setTimeout(() => {
41
- if (done) return;
42
- done = true;
43
- effectRunning = false;
44
- cb({
45
- _tag: "Failure",
46
- cause: { _tag: "Fail", error: { _tag: "TimeoutError", ms } }
47
- });
48
- }, Math.max(0, Math.floor(ms)));
49
- const runtime = unsafeGetCurrentRuntime();
50
- if (runtime) {
51
- const fiber = runtime.fork(effect);
52
- fiber.join((exit) => {
53
- if (done) return;
54
- done = true;
55
- clearTimeout(timerId);
56
- cb(exit);
57
- });
58
- return () => {
59
- if (done) return;
60
- done = true;
61
- clearTimeout(timerId);
62
- fiber.interrupt();
63
- };
64
- }
65
- return () => {
66
- if (done) return;
67
- done = true;
68
- clearTimeout(timerId);
69
- };
70
- });
71
- }
72
- function retry(effect, policy) {
73
- const shouldRetry = policy.shouldRetry ?? (() => true);
74
- const jitter = policy.jitter ?? "full";
75
- const maxElapsedMs = policy.maxElapsedMs;
76
- const computeDelay = (attempt) => {
77
- const exp = policy.baseDelayMs * Math.pow(2, attempt);
78
- const capped = Math.min(exp, policy.maxDelayMs);
79
- if (jitter === "none") return capped;
80
- return Math.floor(Math.random() * capped);
81
- };
82
- const loop = (attempt, startedAt) => asyncFold(
83
- effect,
84
- (error) => {
85
- if (attempt >= policy.maxRetries) return asyncFail(error);
86
- if (!shouldRetry(error, attempt)) return asyncFail(error);
87
- if (maxElapsedMs !== void 0) {
88
- const elapsed = performance.now() - startedAt;
89
- if (elapsed >= maxElapsedMs) return asyncFail(error);
90
- }
91
- const delay = computeDelay(attempt);
92
- return asyncFlatMap(sleep(delay), () => loop(attempt + 1, startedAt));
93
- },
94
- (value) => asyncSucceed(value)
95
- );
96
- return asyncFlatMap(
97
- { _tag: "Sync", thunk: () => performance.now() },
98
- (startedAt) => loop(0, startedAt)
99
- );
100
- }
101
- function retryN(effect, n) {
102
- return retry(effect, {
103
- maxRetries: n,
104
- baseDelayMs: 0,
105
- maxDelayMs: 0,
106
- jitter: "none"
107
- });
108
- }
109
- function retryWithBackoff(effect, opts = {}) {
110
- return retry(effect, {
111
- maxRetries: opts.maxRetries ?? 3,
112
- baseDelayMs: opts.baseDelayMs ?? 100,
113
- maxDelayMs: opts.maxDelayMs ?? 1e4,
114
- maxElapsedMs: opts.maxElapsedMs,
115
- shouldRetry: opts.shouldRetry,
116
- jitter: "full"
117
- });
118
- }
119
-
120
- // src/core/runtime/circuitBreaker.ts
121
- function makeCircuitBreaker(config = {}) {
122
- const failureThreshold = config.failureThreshold ?? 5;
123
- const resetTimeoutMs = config.resetTimeoutMs ?? 3e4;
124
- const successThreshold = config.successThreshold ?? 1;
125
- const isFailure = config.isFailure ?? (() => true);
126
- const onStateChange = config.onStateChange;
127
- let currentState = "closed";
128
- let consecutiveFailures = 0;
129
- let consecutiveSuccesses = 0;
130
- let openedAt = 0;
131
- let totalRequests = 0;
132
- let totalFailures = 0;
133
- let totalSuccesses = 0;
134
- let totalRejected = 0;
135
- let lastFailureTime = null;
136
- let lastSuccessTime = null;
137
- const transition = (to) => {
138
- if (currentState === to) return;
139
- const from = currentState;
140
- currentState = to;
141
- onStateChange?.(from, to);
142
- };
143
- const onSuccess = () => {
144
- totalSuccesses++;
145
- lastSuccessTime = Date.now();
146
- consecutiveFailures = 0;
147
- if (currentState === "half-open") {
148
- consecutiveSuccesses++;
149
- if (consecutiveSuccesses >= successThreshold) {
150
- consecutiveSuccesses = 0;
151
- transition("closed");
152
- }
153
- }
154
- };
155
- const onFailure = (error) => {
156
- if (!isFailure(error)) {
157
- onSuccess();
158
- return;
159
- }
160
- totalFailures++;
161
- lastFailureTime = Date.now();
162
- consecutiveSuccesses = 0;
163
- consecutiveFailures++;
164
- if (currentState === "half-open") {
165
- openedAt = Date.now();
166
- transition("open");
167
- } else if (currentState === "closed" && consecutiveFailures >= failureThreshold) {
168
- openedAt = Date.now();
169
- transition("open");
170
- }
171
- };
172
- const shouldAllow = () => {
173
- switch (currentState) {
174
- case "closed":
175
- return true;
176
- case "open": {
177
- const elapsed = Date.now() - openedAt;
178
- if (elapsed >= resetTimeoutMs) {
179
- transition("half-open");
180
- return true;
181
- }
182
- return false;
183
- }
184
- case "half-open":
185
- return true;
186
- }
187
- };
188
- const protect = (effect) => {
189
- totalRequests++;
190
- if (!shouldAllow()) {
191
- totalRejected++;
192
- return asyncFail({
193
- _tag: "CircuitBreakerOpen",
194
- openSince: openedAt,
195
- failures: consecutiveFailures
196
- });
197
- }
198
- return asyncFold(
199
- effect,
200
- (error) => {
201
- onFailure(error);
202
- return asyncFail(error);
203
- },
204
- (value) => {
205
- onSuccess();
206
- return asyncSucceed(value);
207
- }
208
- );
209
- };
210
- const stats = () => ({
211
- state: currentState,
212
- failures: consecutiveFailures,
213
- successes: consecutiveSuccesses,
214
- totalRequests,
215
- totalFailures,
216
- totalSuccesses,
217
- totalRejected,
218
- lastFailureTime,
219
- lastSuccessTime
220
- });
221
- const reset = () => {
222
- consecutiveFailures = 0;
223
- consecutiveSuccesses = 0;
224
- transition("closed");
225
- };
226
- return {
227
- state: () => currentState,
228
- protect,
229
- stats,
230
- reset
231
- };
232
- }
30
+ sync
31
+ } from "./chunk-PNVFW245.js";
233
32
 
234
33
  // src/core/stream/stream.ts
235
34
  var widenOpt = (opt) => opt._tag === "None" ? none : some(opt.value);
@@ -280,7 +79,7 @@ function streamToRaceWithHandler(winnerSide, leftStream, rightStream, flip, id)
280
79
  return asyncSucceed([a, next]);
281
80
  }
282
81
  if (exit.cause._tag === "Interrupt") {
283
- return async((_env, cb) => {
82
+ return asyncEffect((_env, cb) => {
284
83
  cb(Exit.failCause(Cause.interrupt()));
285
84
  });
286
85
  }
@@ -295,7 +94,7 @@ function makeMergePull(onLeft, onRight, flip, mergePullId) {
295
94
  const id = ++mergePullId;
296
95
  const onLeftHandler = streamToRaceWithHandler("L", onLeft, onRight, flip, id);
297
96
  const onRightHandler = streamToRaceWithHandler("R", onLeft, onRight, flip, id);
298
- return async((_env, cb) => {
97
+ return asyncEffect((_env, cb) => {
299
98
  const runtime = unsafeGetCurrentRuntime();
300
99
  const scope = new Scope(runtime);
301
100
  const handler = raceWith(
@@ -356,7 +155,7 @@ function uncons(self) {
356
155
  case "Merge":
357
156
  return makeMergePull(self.left, self.right, self.flip, 0);
358
157
  case "Scoped":
359
- return async((env, cb) => {
158
+ return asyncEffect((env, cb) => {
360
159
  const runtime = unsafeGetCurrentRuntime();
361
160
  const scope = new Scope(runtime);
362
161
  const fiber = getCurrentFiber();
@@ -377,7 +176,7 @@ function uncons(self) {
377
176
  scope.close(exit);
378
177
  };
379
178
  const wrap = (s) => fromPull(
380
- async((env2, cb2) => {
179
+ asyncEffect((env2, cb2) => {
381
180
  const pull = uncons(s);
382
181
  unsafeRunFoldWithEnv(
383
182
  pull,
@@ -405,7 +204,7 @@ function uncons(self) {
405
204
  });
406
205
  });
407
206
  case "Managed":
408
- return async((env, cb) => {
207
+ return asyncEffect((env, cb) => {
409
208
  const runtime = unsafeGetCurrentRuntime();
410
209
  const scope = new Scope(runtime);
411
210
  getCurrentFiber()?.addFinalizer((exit) => {
@@ -433,16 +232,19 @@ function uncons(self) {
433
232
  const { stream: inner, release } = ex.value;
434
233
  scope.addFinalizer((exit) => release(exit));
435
234
  const wrap = (s) => fromPull(
436
- async((env2, cb2) => {
437
- uncons(s)(env2, (ex2) => {
438
- if (ex2._tag === "Failure") {
235
+ asyncEffect((env2, cb2) => {
236
+ unsafeRunFoldWithEnv(
237
+ uncons(s),
238
+ env2,
239
+ (cause) => {
240
+ const ex2 = Exit.failCause(cause);
439
241
  closeWith(ex2);
440
242
  cb2(ex2);
441
- return;
243
+ },
244
+ ([a, tail]) => {
245
+ cb2(Exit.succeed([a, wrap(tail)]));
442
246
  }
443
- const [a, tail] = ex2.value;
444
- cb2(Exit.succeed([a, wrap(tail)]));
445
- });
247
+ );
446
248
  })
447
249
  );
448
250
  unsafeGetCurrentRuntime().fork(uncons(wrap(inner))).join(cb);
@@ -602,49 +404,73 @@ function drainStreamSyncFull(stream) {
602
404
  }
603
405
  }
604
406
  }
605
- function readerStream(reader, normalizeError) {
606
- const pull = async((_, cb) => {
607
- reader.read().then(({ done, value }) => {
608
- if (done) {
609
- cb({ _tag: "Failure", cause: { _tag: "Fail", error: none } });
407
+ function readerStream(reader, normalizeError, signal) {
408
+ const pull = asyncEffect((_, cb) => {
409
+ let done = false;
410
+ const cleanup = () => signal?.removeEventListener("abort", abort);
411
+ const finish = (exit) => {
412
+ if (done) return;
413
+ done = true;
414
+ cleanup();
415
+ cb(exit);
416
+ };
417
+ const abort = () => {
418
+ try {
419
+ reader.cancel();
420
+ } catch {
421
+ }
422
+ const error = typeof DOMException === "function" ? new DOMException("aborted", "AbortError") : new Error("aborted");
423
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: some(normalizeError(error)) } });
424
+ };
425
+ if (signal?.aborted) {
426
+ abort();
427
+ return;
428
+ }
429
+ signal?.addEventListener("abort", abort, { once: true });
430
+ reader.read().then(({ done: done2, value }) => {
431
+ if (done2) {
432
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: none } });
610
433
  return;
611
434
  }
612
- cb({
435
+ finish({
613
436
  _tag: "Success",
614
437
  value: [value, fromPull(pull)]
615
438
  });
616
439
  }).catch((e) => {
617
- cb({ _tag: "Failure", cause: { _tag: "Fail", error: some(normalizeError(e)) } });
440
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: some(normalizeError(e)) } });
618
441
  });
442
+ return () => {
443
+ cleanup();
444
+ try {
445
+ reader.cancel();
446
+ } catch {
447
+ }
448
+ };
619
449
  });
620
450
  return fromPull(pull);
621
451
  }
622
- function streamFromReadableStream(body, normalizeError) {
452
+ function streamFromReadableStream(body, normalizeError, options = {}) {
623
453
  if (!body) return emptyStream();
624
454
  let reader;
625
455
  return unwrapScoped(
626
456
  // acquire: produce un ZStream
627
457
  sync(() => {
628
458
  reader = body.getReader();
629
- return readerStream(reader, normalizeError);
459
+ return readerStream(reader, normalizeError, options.signal);
630
460
  }),
631
461
  // release: se corre en fin / error / interrupción
632
462
  () => asyncSync(() => {
633
463
  try {
634
464
  reader?.cancel();
635
465
  } catch {
466
+ } finally {
467
+ options.onRelease?.();
636
468
  }
637
469
  })
638
470
  );
639
471
  }
640
472
 
641
473
  export {
642
- sleep,
643
- timeout,
644
- retry,
645
- retryN,
646
- retryWithBackoff,
647
- makeCircuitBreaker,
648
474
  widenOpt,
649
475
  fromPull,
650
476
  unwrapScoped,
@@ -0,0 +1,144 @@
1
+ // src/core/types/asyncEffect.ts
2
+ var Async = {
3
+ succeed: (value) => ({ _tag: "Succeed", value }),
4
+ fail: (error) => ({ _tag: "Fail", error }),
5
+ sync: (thunk) => ({ _tag: "Sync", thunk }),
6
+ async: (register) => ({ _tag: "Async", register })
7
+ };
8
+ function asyncFold(fa, onFailure, onSuccess) {
9
+ return {
10
+ _tag: "Fold",
11
+ first: fa,
12
+ onFailure,
13
+ onSuccess
14
+ };
15
+ }
16
+ function asyncCatchAll(fa, handler) {
17
+ return asyncFold(fa, handler, asyncSucceed);
18
+ }
19
+ function asyncMapError(fa, f) {
20
+ return asyncFold(fa, (e) => asyncFail(f(e)), asyncSucceed);
21
+ }
22
+ var SUCCEED_UNDEFINED = { _tag: "Succeed", value: void 0 };
23
+ var SUCCEED_TRUE = { _tag: "Succeed", value: true };
24
+ var SUCCEED_FALSE = { _tag: "Succeed", value: false };
25
+ var SUCCEED_NULL = { _tag: "Succeed", value: null };
26
+ var unit = () => SUCCEED_UNDEFINED;
27
+ var asyncSucceed = (value) => {
28
+ if (value === void 0) return SUCCEED_UNDEFINED;
29
+ if (value === true) return SUCCEED_TRUE;
30
+ if (value === false) return SUCCEED_FALSE;
31
+ if (value === null) return SUCCEED_NULL;
32
+ return { _tag: "Succeed", value };
33
+ };
34
+ var asyncFail = (error) => ({
35
+ _tag: "Fail",
36
+ error
37
+ });
38
+ var asyncSync = (thunk) => ({
39
+ _tag: "Sync",
40
+ thunk
41
+ });
42
+ var asyncTotal = (thunk) => asyncSync(() => thunk());
43
+ var asyncEffect = (register) => ({
44
+ _tag: "Async",
45
+ register
46
+ });
47
+ function asyncMap(fa, f) {
48
+ return asyncFlatMap(fa, (a) => asyncSucceed(f(a)));
49
+ }
50
+ function asyncFlatMap(fa, f) {
51
+ return {
52
+ _tag: "FlatMap",
53
+ first: fa,
54
+ andThen: f
55
+ };
56
+ }
57
+ function acquireRelease(acquire, release, scope) {
58
+ return asyncFlatMap(acquire, (resource) => {
59
+ scope.addFinalizer((exit) => release(resource, exit));
60
+ return asyncSucceed(resource);
61
+ });
62
+ }
63
+ function asyncInterruptible(register) {
64
+ return asyncEffect(register);
65
+ }
66
+ var withAsyncPromise = (run) => (eff) => {
67
+ const anyEff = eff;
68
+ if (!anyEff.toPromise) {
69
+ anyEff.toPromise = (env) => run(eff, env);
70
+ anyEff.unsafeRunPromise = () => run(eff, {});
71
+ }
72
+ return anyEff;
73
+ };
74
+ var mapAsync = (fa, f) => asyncFlatMap(fa, (a) => asyncSucceed(f(a)));
75
+ var mapTryAsync = (fa, f) => asyncFlatMap(fa, (a) => asyncSync(() => f(a)));
76
+
77
+ // src/core/types/option.ts
78
+ var none = { _tag: "None" };
79
+ var some = (value) => ({ _tag: "Some", value });
80
+
81
+ // src/core/types/effect.ts
82
+ var Cause = {
83
+ fail: (error) => ({ _tag: "Fail", error }),
84
+ interrupt: () => ({ _tag: "Interrupt" }),
85
+ die: (defect) => ({ _tag: "Die", defect })
86
+ };
87
+ var Exit = {
88
+ succeed: (value) => ({
89
+ _tag: "Success",
90
+ value
91
+ }),
92
+ failCause: (cause) => ({
93
+ _tag: "Failure",
94
+ cause
95
+ })
96
+ };
97
+ var succeed = (value) => asyncSucceed(value);
98
+ var fail = (error) => asyncFail(error);
99
+ var sync = (thunk) => asyncSync((env) => thunk(env));
100
+ var map = (fa, f) => asyncMap(fa, f);
101
+ var flatMap = (fa, f) => asyncFlatMap(fa, f);
102
+ var mapError = (fa, f) => asyncMapError(fa, f);
103
+ var catchAll = (fa, handler) => asyncFold(fa, handler, asyncSucceed);
104
+ function orElseOptional(fa, that) {
105
+ return asyncFold(
106
+ fa,
107
+ (opt) => opt._tag === "Some" ? asyncFail(opt) : that(),
108
+ asyncSucceed
109
+ );
110
+ }
111
+ var end = () => fail(none);
112
+
113
+ export {
114
+ Async,
115
+ asyncFold,
116
+ asyncCatchAll,
117
+ asyncMapError,
118
+ unit,
119
+ asyncSucceed,
120
+ asyncFail,
121
+ asyncSync,
122
+ asyncTotal,
123
+ asyncEffect,
124
+ asyncMap,
125
+ asyncFlatMap,
126
+ acquireRelease,
127
+ asyncInterruptible,
128
+ withAsyncPromise,
129
+ mapAsync,
130
+ mapTryAsync,
131
+ none,
132
+ some,
133
+ Cause,
134
+ Exit,
135
+ succeed,
136
+ fail,
137
+ sync,
138
+ map,
139
+ flatMap,
140
+ mapError,
141
+ catchAll,
142
+ orElseOptional,
143
+ end
144
+ };