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
@@ -0,0 +1,104 @@
1
+ import {
2
+ unsafeGetCurrentRuntime
3
+ } from "./chunk-G6IQOE4P.mjs";
4
+ import {
5
+ asyncEffect,
6
+ asyncFail,
7
+ asyncFlatMap,
8
+ asyncFold,
9
+ asyncSucceed
10
+ } from "./chunk-NOYZIMUJ.mjs";
11
+
12
+ // src/core/runtime/combinators.ts
13
+ function sleep(ms) {
14
+ return asyncEffect((_env, cb) => {
15
+ const delay = Math.max(0, Math.floor(ms));
16
+ const id = setTimeout(() => cb({ _tag: "Success", value: void 0 }), delay);
17
+ return () => clearTimeout(id);
18
+ });
19
+ }
20
+ function timeout(effect, ms) {
21
+ return asyncEffect((env, cb) => {
22
+ let done = false;
23
+ let timerId;
24
+ let effectRunning = true;
25
+ timerId = setTimeout(() => {
26
+ if (done) return;
27
+ done = true;
28
+ effectRunning = false;
29
+ cb({
30
+ _tag: "Failure",
31
+ cause: { _tag: "Fail", error: { _tag: "TimeoutError", ms } }
32
+ });
33
+ }, Math.max(0, Math.floor(ms)));
34
+ const runtime = unsafeGetCurrentRuntime();
35
+ const fiber = runtime.fork(effect);
36
+ fiber.join((exit) => {
37
+ if (done) return;
38
+ done = true;
39
+ clearTimeout(timerId);
40
+ cb(exit);
41
+ });
42
+ return () => {
43
+ if (done) return;
44
+ done = true;
45
+ clearTimeout(timerId);
46
+ fiber.interrupt();
47
+ };
48
+ });
49
+ }
50
+ function retry(effect, policy) {
51
+ const shouldRetry = policy.shouldRetry ?? (() => true);
52
+ const jitter = policy.jitter ?? "full";
53
+ const maxElapsedMs = policy.maxElapsedMs;
54
+ const computeDelay = (attempt) => {
55
+ const exp = policy.baseDelayMs * Math.pow(2, attempt);
56
+ const capped = Math.min(exp, policy.maxDelayMs);
57
+ if (jitter === "none") return capped;
58
+ return Math.floor(Math.random() * capped);
59
+ };
60
+ const loop = (attempt, startedAt) => asyncFold(
61
+ effect,
62
+ (error) => {
63
+ if (attempt >= policy.maxRetries) return asyncFail(error);
64
+ if (!shouldRetry(error, attempt)) return asyncFail(error);
65
+ if (maxElapsedMs !== void 0) {
66
+ const elapsed = performance.now() - startedAt;
67
+ if (elapsed >= maxElapsedMs) return asyncFail(error);
68
+ }
69
+ const delay = computeDelay(attempt);
70
+ return asyncFlatMap(sleep(delay), () => loop(attempt + 1, startedAt));
71
+ },
72
+ (value) => asyncSucceed(value)
73
+ );
74
+ return asyncFlatMap(
75
+ { _tag: "Sync", thunk: () => performance.now() },
76
+ (startedAt) => loop(0, startedAt)
77
+ );
78
+ }
79
+ function retryN(effect, n) {
80
+ return retry(effect, {
81
+ maxRetries: n,
82
+ baseDelayMs: 0,
83
+ maxDelayMs: 0,
84
+ jitter: "none"
85
+ });
86
+ }
87
+ function retryWithBackoff(effect, opts = {}) {
88
+ return retry(effect, {
89
+ maxRetries: opts.maxRetries ?? 3,
90
+ baseDelayMs: opts.baseDelayMs ?? 100,
91
+ maxDelayMs: opts.maxDelayMs ?? 1e4,
92
+ maxElapsedMs: opts.maxElapsedMs,
93
+ shouldRetry: opts.shouldRetry,
94
+ jitter: "full"
95
+ });
96
+ }
97
+
98
+ export {
99
+ sleep,
100
+ timeout,
101
+ retry,
102
+ retryN,
103
+ retryWithBackoff
104
+ };