brass-runtime 1.15.0 → 1.16.1

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 (209) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +673 -136
  3. package/dist/agent/cli/main.cjs +40 -35
  4. package/dist/agent/cli/main.js +9 -4
  5. package/dist/agent/cli/main.mjs +9 -4
  6. package/dist/agent/index.cjs +8 -4
  7. package/dist/agent/index.d.ts +1 -1
  8. package/dist/agent/index.js +7 -3
  9. package/dist/agent/index.mjs +7 -3
  10. package/dist/chunk-2HQTDLHF.mjs +683 -0
  11. package/dist/chunk-36I3M4UC.mjs +370 -0
  12. package/dist/chunk-3AYM6WPJ.js +1629 -0
  13. package/dist/chunk-3LOYJFRR.cjs +300 -0
  14. package/dist/chunk-3RG5ZIWI.js +10 -0
  15. package/dist/chunk-3Y2RIUMM.js +300 -0
  16. package/dist/{chunk-VEZNF5GZ.cjs → chunk-4ROBZFL6.cjs} +130 -126
  17. package/dist/{chunk-3QMOKAS5.js → chunk-52OB2ROS.js} +9 -5
  18. package/dist/chunk-52PPNNI4.cjs +416 -0
  19. package/dist/chunk-5EC274J5.cjs +2874 -0
  20. package/dist/chunk-5QC7LRZ3.js +229 -0
  21. package/dist/chunk-5VRJNBLZ.mjs +2874 -0
  22. package/dist/chunk-62AZW6UT.cjs +313 -0
  23. package/dist/chunk-6IXXWIUM.js +683 -0
  24. package/dist/chunk-74ZTY6CP.js +2871 -0
  25. package/dist/chunk-76YMRMH2.cjs +777 -0
  26. package/dist/chunk-7CMJS3QE.mjs +2871 -0
  27. package/dist/{chunk-4NHES7VK.mjs → chunk-7JIJOVCT.js} +27 -13
  28. package/dist/chunk-A2OM6NEH.mjs +194 -0
  29. package/dist/chunk-AGR5B2BC.cjs +683 -0
  30. package/dist/chunk-AVNQLJ5V.js +777 -0
  31. package/dist/chunk-B33ICAKP.js +313 -0
  32. package/dist/{chunk-ELOOF35R.mjs → chunk-B5JD23U7.mjs} +1 -1
  33. package/dist/chunk-BABBZK4Y.js +2024 -0
  34. package/dist/chunk-C3MDXTRZ.js +354 -0
  35. package/dist/chunk-CIZFIMK5.js +2193 -0
  36. package/dist/chunk-CZIVE6NT.cjs +354 -0
  37. package/dist/chunk-DNFJLJMW.mjs +354 -0
  38. package/dist/chunk-DNFO2EIZ.mjs +777 -0
  39. package/dist/chunk-EJ6BPYVR.mjs +416 -0
  40. package/dist/chunk-ENKODRU3.cjs +2193 -0
  41. package/dist/chunk-EOC4UHBS.mjs +229 -0
  42. package/dist/{chunk-BMH5AV44.js → chunk-FH2X7BVP.js} +756 -440
  43. package/dist/{chunk-PPUXIH5R.js → chunk-FHQGHPMO.mjs} +27 -13
  44. package/dist/{chunk-TGIFUAK4.cjs → chunk-GLE2WY7Z.cjs} +951 -635
  45. package/dist/{chunk-BDF4AMWX.mjs → chunk-GYM3LLGS.mjs} +756 -440
  46. package/dist/chunk-HLWLMW2F.mjs +2024 -0
  47. package/dist/chunk-JF5WGYJJ.cjs +194 -0
  48. package/dist/chunk-KH4SYAOS.mjs +1629 -0
  49. package/dist/chunk-KN32XNTH.mjs +313 -0
  50. package/dist/chunk-KQLYONSE.cjs +2871 -0
  51. package/dist/{chunk-STVLQ3XD.cjs → chunk-KZJQ723N.cjs} +92 -78
  52. package/dist/chunk-L2SYFEBS.js +194 -0
  53. package/dist/chunk-L6VB5N7Q.cjs +104 -0
  54. package/dist/{chunk-K6M7MDZ4.mjs → chunk-MBEJI5HF.mjs} +9 -5
  55. package/dist/chunk-MIIYDLGM.js +2874 -0
  56. package/dist/chunk-MOO4L7F4.mjs +104 -0
  57. package/dist/chunk-MT3OWDPC.mjs +2193 -0
  58. package/dist/chunk-MVGUEJ5Z.cjs +370 -0
  59. package/dist/chunk-OBGZSXTJ.cjs +10 -0
  60. package/dist/chunk-PD4EJTQC.cjs +229 -0
  61. package/dist/chunk-PWC3RBQE.mjs +300 -0
  62. package/dist/chunk-Q2I37RP3.cjs +1629 -0
  63. package/dist/chunk-RKGKFN2A.js +416 -0
  64. package/dist/{chunk-R3R2FVLG.cjs → chunk-SA6HUJVI.cjs} +5 -5
  65. package/dist/chunk-TRM4JUZQ.js +104 -0
  66. package/dist/chunk-UB4B6OFY.js +370 -0
  67. package/dist/{chunk-TO7IKXYT.js → chunk-UCUBNWM2.js} +1 -1
  68. package/dist/chunk-VN44DYYT.cjs +2024 -0
  69. package/dist/chunk-Y6FXYEAI.mjs +10 -0
  70. package/dist/client-CZHU674n.d.ts +820 -0
  71. package/dist/core/index.cjs +198 -4
  72. package/dist/core/index.d.ts +311 -212
  73. package/dist/core/index.js +237 -43
  74. package/dist/core/index.mjs +237 -43
  75. package/dist/{effect-CMOQKX8y.d.ts → effect-DIUHZ9IN.d.ts} +195 -1
  76. package/dist/effectRunner-CFLC32IK.cjs +8 -0
  77. package/dist/effectRunner-L4S7IPT3.js +8 -0
  78. package/dist/effectRunner-NNGG75QA.mjs +8 -0
  79. package/dist/http/index.cjs +1227 -2971
  80. package/dist/http/index.d.ts +826 -280
  81. package/dist/http/index.js +1089 -2833
  82. package/dist/http/index.mjs +1089 -2833
  83. package/dist/http/testing.cjs +161 -0
  84. package/dist/http/testing.d.ts +43 -0
  85. package/dist/http/testing.js +161 -0
  86. package/dist/http/testing.mjs +161 -0
  87. package/dist/index.cjs +486 -250
  88. package/dist/index.d.ts +87 -95
  89. package/dist/index.js +391 -155
  90. package/dist/index.mjs +391 -155
  91. package/dist/observability/index.cjs +162 -0
  92. package/dist/observability/index.d.ts +152 -0
  93. package/dist/observability/index.js +162 -0
  94. package/dist/observability/index.mjs +162 -0
  95. package/dist/perf/cli.cjs +401 -0
  96. package/dist/perf/cli.d.ts +1 -0
  97. package/dist/perf/cli.js +401 -0
  98. package/dist/perf/cli.mjs +401 -0
  99. package/dist/perf/index.cjs +141 -0
  100. package/dist/perf/index.d.ts +483 -0
  101. package/dist/perf/index.js +141 -0
  102. package/dist/perf/index.mjs +141 -0
  103. package/dist/schedule-CK3Ml_7p.d.ts +259 -0
  104. package/dist/schema/index.cjs +29 -0
  105. package/dist/schema/index.d.ts +179 -0
  106. package/dist/schema/index.js +29 -0
  107. package/dist/schema/index.mjs +29 -0
  108. package/dist/server-GJPg8ZSG.d.ts +675 -0
  109. package/dist/{stream-FQm9h4Mg.d.ts → stream-B4oK9JFP.d.ts} +1 -1
  110. package/dist/tracer-Hwt1cl7h.d.ts +189 -0
  111. package/dist/tracing-DqbTKGcf.d.ts +148 -0
  112. package/docs/ARCHITECTURE.md +292 -0
  113. package/docs/README.md +63 -0
  114. package/docs/adr/0001-ai-context-pack.md +32 -0
  115. package/docs/agent-apply-mode.md +104 -0
  116. package/docs/agent-approvals.md +110 -0
  117. package/docs/agent-batch.md +185 -0
  118. package/docs/agent-boundaries.md +112 -0
  119. package/docs/agent-chat-sessions.md +160 -0
  120. package/docs/agent-ci.md +17 -0
  121. package/docs/agent-cli.md +405 -0
  122. package/docs/agent-config.md +480 -0
  123. package/docs/agent-context-discovery.md +159 -0
  124. package/docs/agent-copilot-like-dx.md +126 -0
  125. package/docs/agent-declarative-optimized-planning.md +138 -0
  126. package/docs/agent-dx.md +224 -0
  127. package/docs/agent-env-files.md +126 -0
  128. package/docs/agent-follow-up-context.md +43 -0
  129. package/docs/agent-global-usage.md +180 -0
  130. package/docs/agent-init.md +109 -0
  131. package/docs/agent-install-and-configure.md +516 -0
  132. package/docs/agent-language-workspace-ux.md +99 -0
  133. package/docs/agent-llm-adapters.md +123 -0
  134. package/docs/agent-local-install.md +190 -0
  135. package/docs/agent-local-tests.md +51 -0
  136. package/docs/agent-observability.md +155 -0
  137. package/docs/agent-patch-quality-loop.md +162 -0
  138. package/docs/agent-presets.md +22 -0
  139. package/docs/agent-project-commands.md +237 -0
  140. package/docs/agent-project-intelligence.md +156 -0
  141. package/docs/agent-redaction.md +18 -0
  142. package/docs/agent-release-readiness.md +76 -0
  143. package/docs/agent-rollback-safety.md +162 -0
  144. package/docs/agent-rollback.md +23 -0
  145. package/docs/agent-run-artifacts.md +16 -0
  146. package/docs/agent-vscode-auto-discovery.md +137 -0
  147. package/docs/agent-vscode-batch-runner.md +100 -0
  148. package/docs/agent-vscode-chat-layout.md +90 -0
  149. package/docs/agent-vscode-clean-install.md +147 -0
  150. package/docs/agent-vscode-code-actions.md +70 -0
  151. package/docs/agent-vscode-diff-preview.md +45 -0
  152. package/docs/agent-vscode-inline-assist.md +56 -0
  153. package/docs/agent-vscode-install.md +186 -0
  154. package/docs/agent-vscode-model-setup.md +97 -0
  155. package/docs/agent-vscode-patch-preview.md +92 -0
  156. package/docs/agent-vscode-problems.md +79 -0
  157. package/docs/agent-vscode-project-dashboard.md +106 -0
  158. package/docs/agent-vscode-run-history.md +92 -0
  159. package/docs/agent-vscode-ux.md +73 -0
  160. package/docs/ai/INVARIANTS.md +84 -0
  161. package/docs/ai/PROJECT_MAP.md +338 -0
  162. package/docs/ai/PUBLIC_API.md +336 -0
  163. package/docs/ai/VALIDATION_MATRIX.md +67 -0
  164. package/docs/api-polish.md +37 -0
  165. package/docs/cancellation.md +162 -0
  166. package/docs/coverage.md +46 -0
  167. package/docs/getting-started.md +159 -0
  168. package/docs/guides/README.md +40 -0
  169. package/docs/guides/circuit-breaker.md +89 -0
  170. package/docs/guides/error-handling.md +91 -0
  171. package/docs/guides/getting-started.md +107 -0
  172. package/docs/guides/layers.md +189 -0
  173. package/docs/guides/metrics.md +101 -0
  174. package/docs/guides/resource-management.md +141 -0
  175. package/docs/guides/retry.md +215 -0
  176. package/docs/guides/semaphore.md +66 -0
  177. package/docs/guides/streams.md +117 -0
  178. package/docs/guides/supervisors.md +98 -0
  179. package/docs/guides/testing.md +162 -0
  180. package/docs/guides/tracing.md +71 -0
  181. package/docs/http-recipes.md +399 -0
  182. package/docs/http.md +749 -0
  183. package/docs/modules.md +285 -0
  184. package/docs/observability-collector-smoke.md +31 -0
  185. package/docs/observability-framework-examples.md +98 -0
  186. package/docs/observability.md +542 -0
  187. package/docs/otel-collector-smoke.yaml +27 -0
  188. package/docs/performance-profiler.md +199 -0
  189. package/docs/production-readiness.md +73 -0
  190. package/docs/recipes/README.md +12 -0
  191. package/docs/recipes/http-server.md +45 -0
  192. package/docs/recipes/layers.md +44 -0
  193. package/docs/recipes/performance.md +47 -0
  194. package/docs/recipes/runtime.md +41 -0
  195. package/docs/recipes/testing.md +41 -0
  196. package/docs/release.md +53 -0
  197. package/docs/wasm-bounded-queues.md +44 -0
  198. package/docs/wasm-engine-observability-benchmarks.md +85 -0
  199. package/docs/wasm-fiber-engine.md +117 -0
  200. package/docs/wasm-scheduler-state-machine.md +122 -0
  201. package/docs/wasm-stream-chunks.md +54 -0
  202. package/package.json +48 -2
  203. package/dist/chunk-AR22SXML.js +0 -1043
  204. package/dist/chunk-BDYEENHT.js +0 -224
  205. package/dist/chunk-JFPU5GQI.mjs +0 -1043
  206. package/dist/chunk-MS34J5LY.cjs +0 -224
  207. package/dist/chunk-UMAZLXAB.mjs +0 -224
  208. package/dist/chunk-XPZNXSVN.cjs +0 -1043
  209. package/dist/tracing-DNT9jEbr.d.ts +0 -106
@@ -1,12 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkR3R2FVLGcjs = require('./chunk-R3R2FVLG.cjs');
3
+ var _chunkSA6HUJVIcjs = require('./chunk-SA6HUJVI.cjs');
4
4
 
5
5
 
6
+ var _chunkJF5WGYJJcjs = require('./chunk-JF5WGYJJ.cjs');
6
7
 
7
8
 
8
9
 
9
10
 
11
+ var _chunkGLE2WY7Zcjs = require('./chunk-GLE2WY7Z.cjs');
10
12
 
11
13
 
12
14
 
@@ -24,10 +26,12 @@ var _chunkR3R2FVLGcjs = require('./chunk-R3R2FVLG.cjs');
24
26
 
25
27
 
26
28
 
27
- var _chunkTGIFUAK4cjs = require('./chunk-TGIFUAK4.cjs');
29
+
30
+
31
+ var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
28
32
 
29
33
  // src/core/stream/stream.ts
30
- var widenOpt = (opt) => opt._tag === "None" ? _chunkTGIFUAK4cjs.none : _chunkTGIFUAK4cjs.some.call(void 0, opt.value);
34
+ var widenOpt = (opt) => opt._tag === "None" ? _chunkMVGUEJ5Zcjs.none : _chunkMVGUEJ5Zcjs.some.call(void 0, opt.value);
31
35
  var fromPull = (pull) => ({
32
36
  _tag: "FromPull",
33
37
  pull
@@ -72,28 +76,34 @@ function streamToRaceWithHandler(winnerSide, leftStream, rightStream, flip, id)
72
76
  const [a, tailWin] = exit.value;
73
77
  otherFiber.interrupt();
74
78
  const next = winnerSide === "L" ? fromPull(makeMergePull(tailWin, rightStream, !flip, id)) : fromPull(makeMergePull(leftStream, tailWin, !flip, id));
75
- return _chunkTGIFUAK4cjs.asyncSucceed.call(void 0, [a, next]);
79
+ return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, [a, next]);
80
+ }
81
+ if (_chunkMVGUEJ5Zcjs.Cause.isInterruptedOnly(exit.cause)) {
82
+ return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (_env, cb) => {
83
+ cb(_chunkMVGUEJ5Zcjs.Exit.failCause(_chunkMVGUEJ5Zcjs.Cause.interrupt()));
84
+ });
76
85
  }
77
- if (exit.cause._tag === "Interrupt") {
78
- return _chunkTGIFUAK4cjs.asyncEffect.call(void 0, (_env, cb) => {
79
- cb(_chunkTGIFUAK4cjs.Exit.failCause(_chunkTGIFUAK4cjs.Cause.interrupt()));
86
+ const failure = _chunkMVGUEJ5Zcjs.Cause.firstFailure(exit.cause);
87
+ if (failure._tag === "None") {
88
+ return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (_env, cb) => {
89
+ cb(_chunkMVGUEJ5Zcjs.Exit.failCause(exit.cause));
80
90
  });
81
91
  }
82
- const opt = exit.cause.error;
92
+ const opt = failure.value;
83
93
  if (opt._tag === "None") {
84
94
  return winnerSide === "L" ? uncons(rightStream) : uncons(leftStream);
85
95
  }
86
- return _chunkTGIFUAK4cjs.asyncFail.call(void 0, opt);
96
+ return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, opt);
87
97
  };
88
98
  }
89
99
  function makeMergePull(onLeft, onRight, flip, mergePullId) {
90
100
  const id = ++mergePullId;
91
101
  const onLeftHandler = streamToRaceWithHandler("L", onLeft, onRight, flip, id);
92
102
  const onRightHandler = streamToRaceWithHandler("R", onLeft, onRight, flip, id);
93
- return _chunkTGIFUAK4cjs.asyncEffect.call(void 0, (_env, cb) => {
94
- const runtime = _chunkTGIFUAK4cjs.unsafeGetCurrentRuntime.call(void 0, );
95
- const scope = new (0, _chunkTGIFUAK4cjs.Scope)(runtime);
96
- const handler = _chunkR3R2FVLGcjs.raceWith.call(void 0,
103
+ return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (_env, cb) => {
104
+ const runtime = _chunkGLE2WY7Zcjs.unsafeGetCurrentRuntime.call(void 0, );
105
+ const scope = new (0, _chunkJF5WGYJJcjs.Scope)(runtime);
106
+ const handler = _chunkSA6HUJVIcjs.raceWith.call(void 0,
97
107
  uncons(onLeft),
98
108
  uncons(onRight),
99
109
  scope,
@@ -112,33 +122,33 @@ function merge(left, right) {
112
122
  function uncons(self) {
113
123
  switch (self._tag) {
114
124
  case "Empty":
115
- return _chunkTGIFUAK4cjs.fail.call(void 0, _chunkTGIFUAK4cjs.none);
125
+ return _chunkMVGUEJ5Zcjs.fail.call(void 0, _chunkMVGUEJ5Zcjs.none);
116
126
  case "FromArray": {
117
127
  const arr = self.values;
118
- if (arr.length === 0) return _chunkTGIFUAK4cjs.fail.call(void 0, _chunkTGIFUAK4cjs.none);
128
+ if (arr.length === 0) return _chunkMVGUEJ5Zcjs.fail.call(void 0, _chunkMVGUEJ5Zcjs.none);
119
129
  const tail = arr.length === 1 ? EMPTY_STREAM : { _tag: "FromArray", values: arr.slice(1) };
120
- return _chunkTGIFUAK4cjs.succeed.call(void 0, [arr[0], tail]);
130
+ return _chunkMVGUEJ5Zcjs.succeed.call(void 0, [arr[0], tail]);
121
131
  }
122
132
  case "Emit":
123
- return _chunkTGIFUAK4cjs.map.call(void 0,
124
- _chunkTGIFUAK4cjs.mapError.call(void 0, self.value, (e) => _chunkTGIFUAK4cjs.some.call(void 0, e)),
133
+ return _chunkMVGUEJ5Zcjs.map.call(void 0,
134
+ _chunkMVGUEJ5Zcjs.mapError.call(void 0, self.value, (e) => _chunkMVGUEJ5Zcjs.some.call(void 0, e)),
125
135
  (a) => [a, EMPTY_STREAM]
126
136
  );
127
137
  case "FromPull":
128
138
  return self.pull;
129
139
  case "Concat":
130
- return _chunkTGIFUAK4cjs.orElseOptional.call(void 0,
131
- _chunkTGIFUAK4cjs.map.call(void 0,
140
+ return _chunkMVGUEJ5Zcjs.orElseOptional.call(void 0,
141
+ _chunkMVGUEJ5Zcjs.map.call(void 0,
132
142
  uncons(self.left),
133
143
  ([a, tail]) => [a, concatStream(tail, self.right)]
134
144
  ),
135
145
  () => uncons(self.right)
136
146
  );
137
147
  case "Flatten":
138
- return _chunkTGIFUAK4cjs.flatMap.call(void 0,
148
+ return _chunkMVGUEJ5Zcjs.flatMap.call(void 0,
139
149
  uncons(self.stream),
140
- ([head, tail]) => _chunkTGIFUAK4cjs.orElseOptional.call(void 0,
141
- _chunkTGIFUAK4cjs.map.call(void 0,
150
+ ([head, tail]) => _chunkMVGUEJ5Zcjs.orElseOptional.call(void 0,
151
+ _chunkMVGUEJ5Zcjs.map.call(void 0,
142
152
  uncons(head),
143
153
  ([a, as]) => [
144
154
  a,
@@ -151,10 +161,10 @@ function uncons(self) {
151
161
  case "Merge":
152
162
  return makeMergePull(self.left, self.right, self.flip, 0);
153
163
  case "Scoped":
154
- return _chunkTGIFUAK4cjs.asyncEffect.call(void 0, (env, cb) => {
155
- const runtime = _chunkTGIFUAK4cjs.unsafeGetCurrentRuntime.call(void 0, );
156
- const scope = new (0, _chunkTGIFUAK4cjs.Scope)(runtime);
157
- const fiber = _chunkTGIFUAK4cjs.getCurrentFiber.call(void 0, );
164
+ return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
165
+ const runtime = _chunkGLE2WY7Zcjs.unsafeGetCurrentRuntime.call(void 0, );
166
+ const scope = new (0, _chunkJF5WGYJJcjs.Scope)(runtime);
167
+ const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
158
168
  _optionalChain([fiber, 'optionalAccess', _2 => _2.addFinalizer, 'call', _3 => _3((exit) => {
159
169
  try {
160
170
  scope.close(exit);
@@ -163,7 +173,8 @@ function uncons(self) {
163
173
  })]);
164
174
  const closeWith = (exit) => {
165
175
  if (exit._tag === "Failure") {
166
- const err = exit.cause.error;
176
+ const failure = _chunkMVGUEJ5Zcjs.Cause.firstFailure(exit.cause);
177
+ const err = failure._tag === "Some" ? failure.value : void 0;
167
178
  if (err && typeof err === "object" && err._tag === "None") {
168
179
  scope.close({ _tag: "Success", value: void 0 });
169
180
  return;
@@ -172,18 +183,18 @@ function uncons(self) {
172
183
  scope.close(exit);
173
184
  };
174
185
  const wrap = (s) => fromPull(
175
- _chunkTGIFUAK4cjs.asyncEffect.call(void 0, (env2, cb2) => {
186
+ _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env2, cb2) => {
176
187
  const pull = uncons(s);
177
- _chunkTGIFUAK4cjs.unsafeRunFoldWithEnv.call(void 0,
188
+ _chunkGLE2WY7Zcjs.unsafeRunFoldWithEnv.call(void 0,
178
189
  pull,
179
190
  env2,
180
191
  (cause) => {
181
- const ex = _chunkTGIFUAK4cjs.Exit.failCause(cause);
192
+ const ex = _chunkMVGUEJ5Zcjs.Exit.failCause(cause);
182
193
  closeWith(ex);
183
194
  cb2(ex);
184
195
  },
185
196
  ([a, tail]) => {
186
- cb2(_chunkTGIFUAK4cjs.Exit.succeed([a, wrap(tail)]));
197
+ cb2(_chunkMVGUEJ5Zcjs.Exit.succeed([a, wrap(tail)]));
187
198
  }
188
199
  );
189
200
  })
@@ -191,19 +202,20 @@ function uncons(self) {
191
202
  scope.fork(self.acquire).join((ex) => {
192
203
  if (ex._tag === "Failure") {
193
204
  closeWith(ex);
194
- cb({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkTGIFUAK4cjs.some.call(void 0, ex.cause.error) } });
205
+ const failure = _chunkMVGUEJ5Zcjs.Cause.firstFailure(ex.cause);
206
+ cb(failure._tag === "Some" ? { _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail(_chunkMVGUEJ5Zcjs.some.call(void 0, failure.value)) } : { _tag: "Failure", cause: ex.cause });
195
207
  return;
196
208
  }
197
209
  scope.addFinalizer((exit) => self.release(exit));
198
210
  const inner = ex.value;
199
- _chunkTGIFUAK4cjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
211
+ _chunkGLE2WY7Zcjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
200
212
  });
201
213
  });
202
214
  case "Managed":
203
- return _chunkTGIFUAK4cjs.asyncEffect.call(void 0, (env, cb) => {
204
- const runtime = _chunkTGIFUAK4cjs.unsafeGetCurrentRuntime.call(void 0, );
205
- const scope = new (0, _chunkTGIFUAK4cjs.Scope)(runtime);
206
- _optionalChain([_chunkTGIFUAK4cjs.getCurrentFiber.call(void 0, ), 'optionalAccess', _4 => _4.addFinalizer, 'call', _5 => _5((exit) => {
215
+ return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
216
+ const runtime = _chunkGLE2WY7Zcjs.unsafeGetCurrentRuntime.call(void 0, );
217
+ const scope = new (0, _chunkJF5WGYJJcjs.Scope)(runtime);
218
+ _optionalChain([_chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, ), 'optionalAccess', _4 => _4.addFinalizer, 'call', _5 => _5((exit) => {
207
219
  try {
208
220
  scope.close(exit);
209
221
  } catch (e4) {
@@ -211,7 +223,8 @@ function uncons(self) {
211
223
  })]);
212
224
  const closeWith = (exit) => {
213
225
  if (exit._tag === "Failure") {
214
- const err = exit.cause.error;
226
+ const failure = _chunkMVGUEJ5Zcjs.Cause.firstFailure(exit.cause);
227
+ const err = failure._tag === "Some" ? failure.value : void 0;
215
228
  if (err && typeof err === "object" && err._tag === "None") {
216
229
  scope.close({ _tag: "Success", value: void 0 });
217
230
  return;
@@ -222,28 +235,29 @@ function uncons(self) {
222
235
  scope.fork(self.acquire).join((ex) => {
223
236
  if (ex._tag === "Failure") {
224
237
  scope.close(ex);
225
- cb({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkTGIFUAK4cjs.some.call(void 0, ex.cause.error) } });
238
+ const failure = _chunkMVGUEJ5Zcjs.Cause.firstFailure(ex.cause);
239
+ cb(failure._tag === "Some" ? { _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail(_chunkMVGUEJ5Zcjs.some.call(void 0, failure.value)) } : { _tag: "Failure", cause: ex.cause });
226
240
  return;
227
241
  }
228
242
  const { stream: inner, release } = ex.value;
229
243
  scope.addFinalizer((exit) => release(exit));
230
244
  const wrap = (s) => fromPull(
231
- _chunkTGIFUAK4cjs.asyncEffect.call(void 0, (env2, cb2) => {
232
- _chunkTGIFUAK4cjs.unsafeRunFoldWithEnv.call(void 0,
245
+ _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env2, cb2) => {
246
+ _chunkGLE2WY7Zcjs.unsafeRunFoldWithEnv.call(void 0,
233
247
  uncons(s),
234
248
  env2,
235
249
  (cause) => {
236
- const ex2 = _chunkTGIFUAK4cjs.Exit.failCause(cause);
250
+ const ex2 = _chunkMVGUEJ5Zcjs.Exit.failCause(cause);
237
251
  closeWith(ex2);
238
252
  cb2(ex2);
239
253
  },
240
254
  ([a, tail]) => {
241
- cb2(_chunkTGIFUAK4cjs.Exit.succeed([a, wrap(tail)]));
255
+ cb2(_chunkMVGUEJ5Zcjs.Exit.succeed([a, wrap(tail)]));
242
256
  }
243
257
  );
244
258
  })
245
259
  );
246
- _chunkTGIFUAK4cjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
260
+ _chunkGLE2WY7Zcjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
247
261
  });
248
262
  });
249
263
  }
@@ -258,10 +272,10 @@ function mapStream(self, f) {
258
272
  case "FromArray":
259
273
  return { _tag: "FromArray", values: self.values.map(f) };
260
274
  case "Emit":
261
- return emitStream(_chunkTGIFUAK4cjs.map.call(void 0, self.value, f));
275
+ return emitStream(_chunkMVGUEJ5Zcjs.map.call(void 0, self.value, f));
262
276
  case "FromPull":
263
277
  return fromPull(
264
- _chunkTGIFUAK4cjs.map.call(void 0, self.pull, ([a, tail]) => [f(a), mapStream(tail, f)])
278
+ _chunkMVGUEJ5Zcjs.map.call(void 0, self.pull, ([a, tail]) => [f(a), mapStream(tail, f)])
265
279
  );
266
280
  case "Concat":
267
281
  return concatStream(mapStream(self.left, f), mapStream(self.right, f));
@@ -280,12 +294,12 @@ function mapStream(self, f) {
280
294
  );
281
295
  case "Scoped":
282
296
  return unwrapScoped(
283
- _chunkTGIFUAK4cjs.map.call(void 0, self.acquire, (s) => mapStream(s, f)),
297
+ _chunkMVGUEJ5Zcjs.map.call(void 0, self.acquire, (s) => mapStream(s, f)),
284
298
  self.release
285
299
  );
286
300
  case "Managed":
287
301
  return managedStream(
288
- _chunkTGIFUAK4cjs.map.call(void 0, self.acquire, ({ stream, release }) => ({
302
+ _chunkMVGUEJ5Zcjs.map.call(void 0, self.acquire, ({ stream, release }) => ({
289
303
  stream: mapStream(stream, f),
290
304
  release
291
305
  }))
@@ -296,19 +310,19 @@ function mapStream(self, f) {
296
310
  }
297
311
  function rangeStream(start, end) {
298
312
  const go = (i) => fromPull(
299
- i > end ? _chunkTGIFUAK4cjs.asyncFail.call(void 0, _chunkTGIFUAK4cjs.none) : _chunkTGIFUAK4cjs.asyncSucceed.call(void 0, [i, go(i + 1)])
313
+ i > end ? _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, _chunkMVGUEJ5Zcjs.none) : _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, [i, go(i + 1)])
300
314
  );
301
315
  return go(start);
302
316
  }
303
317
  function zip(left, right) {
304
- const pull = _chunkTGIFUAK4cjs.asyncFold.call(void 0,
305
- _chunkTGIFUAK4cjs.asyncMapError.call(void 0, uncons(left), (opt) => widenOpt(opt)),
318
+ const pull = _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
319
+ _chunkMVGUEJ5Zcjs.asyncMapError.call(void 0, uncons(left), (opt) => widenOpt(opt)),
306
320
  // si left termina o falla, el zip termina/falla igual
307
- (opt) => _chunkTGIFUAK4cjs.asyncFail.call(void 0, opt),
308
- ([a, tailL]) => _chunkTGIFUAK4cjs.asyncFold.call(void 0,
309
- _chunkTGIFUAK4cjs.asyncMapError.call(void 0, uncons(right), (opt) => widenOpt(opt)),
310
- (opt) => _chunkTGIFUAK4cjs.asyncFail.call(void 0, opt),
311
- ([b, tailR]) => _chunkTGIFUAK4cjs.asyncSucceed.call(void 0, [
321
+ (opt) => _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, opt),
322
+ ([a, tailL]) => _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
323
+ _chunkMVGUEJ5Zcjs.asyncMapError.call(void 0, uncons(right), (opt) => widenOpt(opt)),
324
+ (opt) => _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, opt),
325
+ ([b, tailR]) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, [
312
326
  [a, b],
313
327
  zip(tailL, tailR)
314
328
  ])
@@ -317,26 +331,26 @@ function zip(left, right) {
317
331
  return fromPull(pull);
318
332
  }
319
333
  function foreachStream(stream, f) {
320
- const loop = (cur) => _chunkTGIFUAK4cjs.asyncFold.call(void 0,
334
+ const loop = (cur) => _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
321
335
  // uncons: Option<E> -> Option<E|E2>
322
- _chunkTGIFUAK4cjs.asyncMapError.call(void 0, uncons(cur), (opt) => widenOpt(opt)),
336
+ _chunkMVGUEJ5Zcjs.asyncMapError.call(void 0, uncons(cur), (opt) => widenOpt(opt)),
323
337
  (opt) => {
324
- if (opt._tag === "None") return _chunkTGIFUAK4cjs.asyncSucceed.call(void 0, void 0);
325
- return _chunkTGIFUAK4cjs.asyncFail.call(void 0, opt);
338
+ if (opt._tag === "None") return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
339
+ return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, opt);
326
340
  },
327
- ([a, tail]) => _chunkTGIFUAK4cjs.asyncFlatMap.call(void 0,
341
+ ([a, tail]) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
328
342
  // f(a): E2 -> Option<E|E2>
329
- _chunkTGIFUAK4cjs.asyncMapError.call(void 0, f(a), (e2) => _chunkTGIFUAK4cjs.some.call(void 0, e2)),
343
+ _chunkMVGUEJ5Zcjs.asyncMapError.call(void 0, f(a), (e2) => _chunkMVGUEJ5Zcjs.some.call(void 0, e2)),
330
344
  () => loop(tail)
331
345
  )
332
346
  );
333
- return _chunkTGIFUAK4cjs.asyncFold.call(void 0,
347
+ return _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
334
348
  loop(stream),
335
349
  (opt) => {
336
- if (opt._tag === "None") return _chunkTGIFUAK4cjs.asyncSucceed.call(void 0, void 0);
337
- return _chunkTGIFUAK4cjs.asyncFail.call(void 0, opt.value);
350
+ if (opt._tag === "None") return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
351
+ return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, opt.value);
338
352
  },
339
- () => _chunkTGIFUAK4cjs.asyncSucceed.call(void 0, void 0)
353
+ () => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0)
340
354
  );
341
355
  }
342
356
  function fromArray(values) {
@@ -346,20 +360,20 @@ function fromArray(values) {
346
360
  function collectStream(stream) {
347
361
  const syncResult = drainStreamSyncFull(stream);
348
362
  if (syncResult !== null) {
349
- return _chunkTGIFUAK4cjs.asyncSucceed.call(void 0, syncResult);
363
+ return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, syncResult);
350
364
  }
351
- const loop = (cur, acc) => _chunkTGIFUAK4cjs.asyncFold.call(void 0,
365
+ const loop = (cur, acc) => _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
352
366
  uncons(cur),
353
367
  (opt) => {
354
- if (opt._tag === "None") return _chunkTGIFUAK4cjs.succeed.call(void 0, acc);
355
- return _chunkTGIFUAK4cjs.fail.call(void 0, opt);
368
+ if (opt._tag === "None") return _chunkMVGUEJ5Zcjs.succeed.call(void 0, acc);
369
+ return _chunkMVGUEJ5Zcjs.fail.call(void 0, opt);
356
370
  },
357
371
  ([a, tail]) => {
358
372
  acc.push(a);
359
373
  return loop(tail, acc);
360
374
  }
361
375
  );
362
- return _chunkTGIFUAK4cjs.mapError.call(void 0, loop(stream, []), (opt) => {
376
+ return _chunkMVGUEJ5Zcjs.mapError.call(void 0, loop(stream, []), (opt) => {
363
377
  if (opt._tag === "Some") return opt.value;
364
378
  throw new Error("unreachable: stream end handled as success");
365
379
  });
@@ -401,7 +415,7 @@ function drainStreamSyncFull(stream) {
401
415
  }
402
416
  }
403
417
  function readerStream(reader, normalizeError, signal) {
404
- const pull = _chunkTGIFUAK4cjs.asyncEffect.call(void 0, (_, cb) => {
418
+ const pull = _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (_, cb) => {
405
419
  let done = false;
406
420
  const cleanup = () => _optionalChain([signal, 'optionalAccess', _6 => _6.removeEventListener, 'call', _7 => _7("abort", abort)]);
407
421
  const finish = (exit) => {
@@ -416,7 +430,7 @@ function readerStream(reader, normalizeError, signal) {
416
430
  } catch (e5) {
417
431
  }
418
432
  const error = typeof DOMException === "function" ? new DOMException("aborted", "AbortError") : new Error("aborted");
419
- finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkTGIFUAK4cjs.some.call(void 0, normalizeError(error)) } });
433
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.some.call(void 0, normalizeError(error)) } });
420
434
  };
421
435
  if (_optionalChain([signal, 'optionalAccess', _8 => _8.aborted])) {
422
436
  abort();
@@ -425,7 +439,7 @@ function readerStream(reader, normalizeError, signal) {
425
439
  _optionalChain([signal, 'optionalAccess', _9 => _9.addEventListener, 'call', _10 => _10("abort", abort, { once: true })]);
426
440
  reader.read().then(({ done: done2, value }) => {
427
441
  if (done2) {
428
- finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkTGIFUAK4cjs.none } });
442
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.none } });
429
443
  return;
430
444
  }
431
445
  finish({
@@ -433,7 +447,7 @@ function readerStream(reader, normalizeError, signal) {
433
447
  value: [value, fromPull(pull)]
434
448
  });
435
449
  }).catch((e) => {
436
- finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkTGIFUAK4cjs.some.call(void 0, normalizeError(e)) } });
450
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.some.call(void 0, normalizeError(e)) } });
437
451
  });
438
452
  return () => {
439
453
  cleanup();
@@ -450,12 +464,12 @@ function streamFromReadableStream(body, normalizeError, options = {}) {
450
464
  let reader;
451
465
  return unwrapScoped(
452
466
  // acquire: produce un ZStream
453
- _chunkTGIFUAK4cjs.sync.call(void 0, () => {
467
+ _chunkMVGUEJ5Zcjs.sync.call(void 0, () => {
454
468
  reader = body.getReader();
455
469
  return readerStream(reader, normalizeError, options.signal);
456
470
  }),
457
471
  // release: se corre en fin / error / interrupción
458
- () => _chunkTGIFUAK4cjs.asyncSync.call(void 0, () => {
472
+ () => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
459
473
  try {
460
474
  _optionalChain([reader, 'optionalAccess', _11 => _11.cancel, 'call', _12 => _12()]);
461
475
  } catch (e7) {
@@ -0,0 +1,194 @@
1
+ import {
2
+ getCurrentFiber
3
+ } from "./chunk-FH2X7BVP.js";
4
+ import {
5
+ Cause,
6
+ Exit,
7
+ asyncEffect,
8
+ asyncFlatMap,
9
+ asyncFold,
10
+ unit
11
+ } from "./chunk-UB4B6OFY.js";
12
+
13
+ // src/core/runtime/scope.ts
14
+ var nextScopeId = 1;
15
+ function awaitAll(fibers) {
16
+ return asyncEffect((_env, cb) => {
17
+ let remaining = fibers.length;
18
+ if (remaining === 0) {
19
+ cb({ _tag: "Success", value: void 0 });
20
+ return;
21
+ }
22
+ for (const f of fibers) {
23
+ f.join(() => {
24
+ remaining -= 1;
25
+ if (remaining === 0) cb({ _tag: "Success", value: void 0 });
26
+ });
27
+ }
28
+ });
29
+ }
30
+ var Scope = class _Scope {
31
+ constructor(runtime, parentScopeId) {
32
+ this.runtime = runtime;
33
+ this.parentScopeId = parentScopeId;
34
+ this.id = nextScopeId++;
35
+ const inferredParent = this.parentScopeId ?? getCurrentFiber()?.scopeId;
36
+ if (this.runtime.hasActiveHooks()) {
37
+ this.runtime.emit({
38
+ type: "scope.open",
39
+ scopeId: this.id,
40
+ parentScopeId: inferredParent
41
+ });
42
+ }
43
+ }
44
+ runtime;
45
+ parentScopeId;
46
+ id;
47
+ closed = false;
48
+ children = /* @__PURE__ */ new Set();
49
+ subScopes = /* @__PURE__ */ new Set();
50
+ finalizers = [];
51
+ /** registra un finalizer (LIFO) */
52
+ addFinalizer(f) {
53
+ if (this.closed) {
54
+ throw new Error("Trying to add finalizer to closed scope");
55
+ }
56
+ this.finalizers.push(f);
57
+ }
58
+ /** crea un sub scope (mismo runtime) */
59
+ subScope() {
60
+ if (this.closed) throw new Error("Scope closed");
61
+ const s = new _Scope(this.runtime, this.id);
62
+ this.subScopes.add(s);
63
+ return s;
64
+ }
65
+ /** ✅ fork en este scope */
66
+ fork(eff) {
67
+ if (this.closed) throw new Error("Scope closed");
68
+ const f = this.runtime.fork(eff, this.id);
69
+ this.children.add(f);
70
+ f.join(() => this.children.delete(f));
71
+ return f;
72
+ }
73
+ /** close fire-and-forget (no bloquea) */
74
+ close(exit = { _tag: "Success", value: void 0 }) {
75
+ this.runtime.fork(this.closeAsync(exit));
76
+ }
77
+ /** Emit the scope.close event if hooks are active. */
78
+ emitCloseEvent(exit) {
79
+ if (this.runtime.hasActiveHooks()) {
80
+ const status = exit._tag === "Success" ? "success" : Cause.isInterruptedOnly(exit.cause) ? "interrupted" : "failure";
81
+ const failure = exit._tag === "Failure" ? Cause.firstFailure(exit.cause) : void 0;
82
+ this.runtime.emit({
83
+ type: "scope.close",
84
+ scopeId: this.id,
85
+ status,
86
+ error: failure?._tag === "Some" ? failure.value : exit._tag === "Failure" ? exit.cause : void 0
87
+ });
88
+ }
89
+ }
90
+ /**
91
+ * Build an effect that executes finalizers in LIFO order.
92
+ *
93
+ * Optimization over the original: instead of wrapping every finalizer in
94
+ * `asyncFold(fin(exit), () => unit(), () => unit())` which creates 3 effect
95
+ * nodes per finalizer (Fold + 2 Succeed), we use a single Sync thunk per
96
+ * finalizer that catches errors inline. When the finalizer returns a
97
+ * Succeed effect (like `unit()`), the Sync thunk completes without creating
98
+ * additional effect nodes.
99
+ */
100
+ buildFinalizerEffect(exit) {
101
+ const fins = this.finalizers;
102
+ if (fins.length === 0) return unit();
103
+ let chain = unit();
104
+ for (let i = fins.length - 1; i >= 0; i--) {
105
+ const fin = fins[i];
106
+ chain = asyncFlatMap(chain, () => {
107
+ let result;
108
+ try {
109
+ result = fin(exit);
110
+ } catch {
111
+ return unit();
112
+ }
113
+ if (result._tag === "Succeed") {
114
+ return unit();
115
+ }
116
+ return asyncFold(
117
+ result,
118
+ () => unit(),
119
+ () => unit()
120
+ );
121
+ });
122
+ }
123
+ return chain;
124
+ }
125
+ closeAsync(exit = { _tag: "Success", value: void 0 }, opts = { awaitChildren: true }) {
126
+ return asyncFlatMap(
127
+ unit(),
128
+ () => asyncEffect((env, cb) => {
129
+ if (this.closed) {
130
+ cb({ _tag: "Success", value: void 0 });
131
+ return;
132
+ }
133
+ this.closed = true;
134
+ const children = Array.from(this.children);
135
+ const subScopes = Array.from(this.subScopes);
136
+ for (const child of children) {
137
+ child.interrupt();
138
+ }
139
+ const closeSubs = subScopes.reduceRight(
140
+ (acc, s) => asyncFlatMap(acc, () => s.closeAsync(exit, opts)),
141
+ unit()
142
+ );
143
+ const runFinalizers = this.buildFinalizerEffect(exit);
144
+ const needsAwait = opts.awaitChildren && children.length > 0;
145
+ const awaitChildrenEff = needsAwait ? awaitAll(children) : unit();
146
+ const hasSubScopes = subScopes.length > 0;
147
+ const hasNoFinalizers = this.finalizers.length === 0;
148
+ if (!hasSubScopes && !needsAwait && hasNoFinalizers) {
149
+ this.emitCloseEvent(exit);
150
+ cb({ _tag: "Success", value: void 0 });
151
+ return;
152
+ }
153
+ const all = asyncFlatMap(closeSubs, () => asyncFlatMap(awaitChildrenEff, () => runFinalizers));
154
+ this.runtime.fork(all).join(() => {
155
+ this.emitCloseEvent(exit);
156
+ cb({ _tag: "Success", value: void 0 });
157
+ });
158
+ })
159
+ );
160
+ }
161
+ };
162
+ function withScopeAsync(runtime, f) {
163
+ return asyncEffect((_env, cb) => {
164
+ const scope = new Scope(runtime);
165
+ let done = false;
166
+ const completeAfterClose = (exit) => {
167
+ runtime.fork(scope.closeAsync(exit)).join(() => {
168
+ if (done) return;
169
+ done = true;
170
+ cb(exit);
171
+ });
172
+ };
173
+ const fiber = runtime.fork(f(scope));
174
+ fiber.join(completeAfterClose);
175
+ return () => {
176
+ if (done) return;
177
+ fiber.interrupt();
178
+ runtime.fork(scope.closeAsync(Exit.failCause(Cause.interrupt())));
179
+ };
180
+ });
181
+ }
182
+ function withScope(runtime, f) {
183
+ return withScopeAsync(runtime, (scope) => {
184
+ const out = f(scope);
185
+ if (out && typeof out === "object" && "_tag" in out) return out;
186
+ return unit();
187
+ });
188
+ }
189
+
190
+ export {
191
+ Scope,
192
+ withScopeAsync,
193
+ withScope
194
+ };