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
package/dist/index.mjs CHANGED
@@ -1,54 +1,95 @@
1
1
  import {
2
+ Layer,
3
+ LayerContext,
2
4
  LinkedQueue,
3
- andThen,
5
+ MissingLayerServiceError,
6
+ RuntimeRegistry,
7
+ Supervisor,
8
+ TestClock,
9
+ TestScheduler,
4
10
  assertCompletesWithin,
5
11
  assertFails,
6
12
  assertFailsWith,
7
13
  assertSucceeds,
8
- bracket,
14
+ buildLayer,
9
15
  catchTag,
10
16
  catchTags,
11
17
  compose,
18
+ consoleJsonLogger,
19
+ defaultTracer,
20
+ defineLayer,
21
+ defineService,
12
22
  delayedEffect,
13
23
  derivedRef,
14
- elapsed,
15
- ensuring,
16
- exponential,
17
- fixed,
24
+ dumpAllFibers,
18
25
  flakyEffect,
26
+ formatLayerError,
27
+ getService,
19
28
  gracefulShutdown,
20
- intersect,
21
- jittered,
29
+ joinSupervised,
22
30
  layer,
31
+ layerEffect,
23
32
  layerFail,
24
33
  layerFrom,
34
+ layerFromContext,
25
35
  layerSucceed,
36
+ layerValue,
26
37
  linkAbortController,
27
38
  makeCancelToken,
28
- makeMetrics,
39
+ makeLayerScope,
29
40
  makeRef,
41
+ makeRuntime,
30
42
  makeSemaphore,
43
+ makeServiceTag,
44
+ makeSupervisor,
31
45
  makeTestRuntime,
32
46
  makeTracer,
33
47
  makeWorkerPool,
34
- managed,
35
- managedAll,
36
48
  mapError as mapError2,
37
49
  mapLayer,
38
50
  merge,
39
51
  neverEffect,
40
52
  orElse,
53
+ provide,
54
+ provideContext,
41
55
  provideLayer,
42
- recurs,
56
+ provideLayerContext,
43
57
  registerShutdownHooks,
44
- repeatWithSchedule,
45
- retryWithSchedule,
46
- tagError,
47
- take,
48
- union,
58
+ runEffect,
59
+ runExit,
60
+ runPromise,
61
+ serviceTag,
62
+ supervise,
63
+ tagError
64
+ } from "./chunk-KH4SYAOS.mjs";
65
+ import {
66
+ Resource,
67
+ bracket,
68
+ ensuring,
69
+ makeCircuitBreaker,
70
+ makeResource,
71
+ managed,
72
+ managedAll,
73
+ resource,
74
+ resourceAll,
75
+ resourceFromManaged,
76
+ resourceSucceed,
49
77
  useManaged,
50
- whileInput
51
- } from "./chunk-JFPU5GQI.mjs";
78
+ useResource
79
+ } from "./chunk-KN32XNTH.mjs";
80
+ import {
81
+ fiberRefSnapshot,
82
+ getFiberRef,
83
+ locallyFiberRef,
84
+ locallyFiberRefWith,
85
+ makeFiberRef,
86
+ makeRuntimeRecorder,
87
+ modifyFiberRef,
88
+ setFiberRef,
89
+ unsafeGetFiberRef,
90
+ unsafeSetFiberRef,
91
+ updateFiberRef
92
+ } from "./chunk-EOC4UHBS.mjs";
52
93
  import {
53
94
  assertNever,
54
95
  collectStream,
@@ -69,30 +110,77 @@ import {
69
110
  unwrapScoped,
70
111
  widenOpt,
71
112
  zip
72
- } from "./chunk-4NHES7VK.mjs";
113
+ } from "./chunk-FHQGHPMO.mjs";
73
114
  import {
74
- makeCircuitBreaker,
115
+ collectAllPar,
116
+ race,
117
+ raceWith,
118
+ zipPar
119
+ } from "./chunk-B5JD23U7.mjs";
120
+ import {
121
+ Schedule,
122
+ andThen,
123
+ contramap,
124
+ elapsed,
125
+ exponential,
126
+ fibonacci,
127
+ fixed,
128
+ forever,
129
+ intersect,
130
+ jitter,
131
+ jittered,
132
+ jitteredSchedule,
133
+ linear,
134
+ makeScheduleDriver,
135
+ map as map2,
136
+ maxDelay,
137
+ maxElapsed,
138
+ named,
139
+ never,
140
+ once,
141
+ poll,
142
+ recurs,
143
+ repeat,
144
+ repeatWithSchedule,
75
145
  retry,
146
+ retry2,
76
147
  retryN,
77
148
  retryWithBackoff,
149
+ retryWithSchedule,
150
+ runSchedule,
151
+ scheduleDriver,
78
152
  sleep,
79
- timeout
80
- } from "./chunk-UMAZLXAB.mjs";
153
+ spaced,
154
+ take,
155
+ tapDecision,
156
+ timeout,
157
+ union,
158
+ untilInput,
159
+ untilOutput,
160
+ upTo,
161
+ whileInput,
162
+ whileOutput,
163
+ windowed
164
+ } from "./chunk-2HQTDLHF.mjs";
81
165
  import {
82
- collectAllPar,
83
- race,
84
- raceWith,
85
- zipPar
86
- } from "./chunk-ELOOF35R.mjs";
166
+ Scope,
167
+ withScope,
168
+ withScopeAsync
169
+ } from "./chunk-A2OM6NEH.mjs";
170
+ import {
171
+ EventBus,
172
+ InMemoryTracer,
173
+ makeMetrics,
174
+ makeRuntimeEventRecord,
175
+ runtimeEventRecordContext,
176
+ runtimeHooksToEventHandler
177
+ } from "./chunk-EJ6BPYVR.mjs";
87
178
  import {
88
179
  ABI_VERSION,
89
- Async,
90
- Cause,
91
180
  DefaultHostExecutor,
92
181
  EVENT_WORDS,
93
182
  EngineFiberHandle,
94
183
  EventKindCode,
95
- Exit,
96
184
  HostRegistry,
97
185
  JsFiberEngine,
98
186
  NONE_U32,
@@ -104,11 +192,45 @@ import {
104
192
  Runtime,
105
193
  RuntimeFiber,
106
194
  Scheduler,
107
- Scope,
108
195
  WasmFiberEngine,
109
196
  WasmFiberRegistryBridge,
110
197
  WasmPackFiberBridge,
111
198
  abortablePromiseStats,
199
+ ctxExtend,
200
+ ctxToObject,
201
+ decodeEvent,
202
+ decodeEventBatch,
203
+ emptyContext,
204
+ encodeOpcodeNodes,
205
+ encodeOpcodeProgram,
206
+ fork,
207
+ fromPromiseAbortable,
208
+ getBenchmarkBudget,
209
+ getCurrentFiber,
210
+ globalScheduler,
211
+ inferCallerLaneFromStack,
212
+ laneTag,
213
+ liveClock,
214
+ makeBoundedRingBuffer,
215
+ makeFiberReadyQueue,
216
+ resetAbortablePromiseStats,
217
+ resolveWasmModule,
218
+ runtimeCapabilities,
219
+ runtimeClockFromEnv,
220
+ runtimeForCaller,
221
+ sanitizeLaneKey,
222
+ setBenchmarkBudget,
223
+ toPromise,
224
+ toPromiseByCaller,
225
+ unsafeGetCurrentRuntime,
226
+ unsafeRunAsync,
227
+ unsafeRunFoldWithEnv,
228
+ withCurrentFiber
229
+ } from "./chunk-GYM3LLGS.mjs";
230
+ import {
231
+ Async,
232
+ Cause,
233
+ Exit,
112
234
  acquireRelease,
113
235
  asyncCatchAll,
114
236
  asyncEffect,
@@ -122,48 +244,29 @@ import {
122
244
  asyncSync,
123
245
  asyncTotal,
124
246
  catchAll,
125
- decodeEvent,
126
- decodeEventBatch,
127
- encodeOpcodeNodes,
128
- encodeOpcodeProgram,
129
247
  end,
130
248
  fail,
131
249
  flatMap,
132
- fork,
133
- fromPromiseAbortable,
134
- getBenchmarkBudget,
135
- getCurrentFiber,
136
- globalScheduler,
137
- inferCallerLaneFromStack,
138
- laneTag,
139
- makeBoundedRingBuffer,
140
- makeFiberReadyQueue,
250
+ formatCause,
251
+ interruptible,
252
+ isCause,
141
253
  map,
142
254
  mapAsync,
143
255
  mapError,
144
256
  mapTryAsync,
145
257
  none,
146
258
  orElseOptional,
147
- resetAbortablePromiseStats,
148
- resolveWasmModule,
149
- runtimeCapabilities,
150
- runtimeForCaller,
151
- sanitizeLaneKey,
152
- setBenchmarkBudget,
259
+ prettyCause,
153
260
  some,
154
261
  succeed,
155
262
  sync,
156
- toPromise,
157
- toPromiseByCaller,
263
+ uninterruptible,
264
+ uninterruptibleMask,
158
265
  unit,
159
- unsafeGetCurrentRuntime,
160
- unsafeRunAsync,
161
- unsafeRunFoldWithEnv,
162
- withAsyncPromise,
163
- withCurrentFiber,
164
- withScope,
165
- withScopeAsync
166
- } from "./chunk-BDF4AMWX.mjs";
266
+ withAsyncPromise
267
+ } from "./chunk-36I3M4UC.mjs";
268
+ import "./chunk-DNFJLJMW.mjs";
269
+ import "./chunk-Y6FXYEAI.mjs";
167
270
 
168
271
  // src/core/stream/queue.ts
169
272
  function bounded(capacity, strategy = "backpressure", options = {}) {
@@ -386,100 +489,6 @@ function buffer(stream, capacity, strategy = "backpressure") {
386
489
  return fromPull(pullDown);
387
490
  }
388
491
 
389
- // src/core/stream/hub.ts
390
- var toQueueStrategy = (s) => s === "BackPressure" ? "backpressure" : s === "Dropping" ? "dropping" : "sliding";
391
- function makeHub(capacity, strategy = "BackPressure") {
392
- const queues = /* @__PURE__ */ new Set();
393
- let closed = false;
394
- const publish = (a) => {
395
- if (closed) return asyncSucceed(false);
396
- const size = queues.size;
397
- if (size === 0) return asyncSucceed(true);
398
- if (size === 1) {
399
- const q = queues.values().next().value;
400
- return q.offer(a);
401
- }
402
- let eff = asyncSucceed(true);
403
- for (const q of queues) {
404
- eff = asyncFlatMap(
405
- eff,
406
- (okSoFar) => asyncFlatMap(q.offer(a), (ok) => asyncSucceed(okSoFar && ok))
407
- );
408
- }
409
- return eff;
410
- };
411
- const publishAll = (as) => {
412
- let eff = asyncSucceed(true);
413
- const it = as[Symbol.iterator]();
414
- while (true) {
415
- const n = it.next();
416
- if (n.done) break;
417
- const a = n.value;
418
- eff = asyncFlatMap(
419
- eff,
420
- (okSoFar) => asyncFlatMap(publish(a), (ok) => asyncSucceed(okSoFar && ok))
421
- );
422
- }
423
- return eff;
424
- };
425
- const subscribe = () => {
426
- if (closed) {
427
- return asyncTotal(() => {
428
- throw { _tag: "HubClosed" };
429
- });
430
- }
431
- return asyncFlatMap(
432
- bounded(capacity, toQueueStrategy(strategy)),
433
- (q) => asyncSync(() => {
434
- queues.add(q);
435
- return {
436
- ...q,
437
- unsubscribe: () => {
438
- if (!queues.has(q)) return;
439
- queues.delete(q);
440
- q.shutdown();
441
- }
442
- };
443
- })
444
- );
445
- };
446
- const shutdown = () => asyncSync(() => {
447
- if (closed) return;
448
- closed = true;
449
- for (const q of queues) q.shutdown();
450
- queues.clear();
451
- });
452
- return {
453
- publish,
454
- publishAll,
455
- subscribe,
456
- shutdown
457
- };
458
- }
459
- var broadcast = makeHub;
460
- function broadcastToHub(stream, hub) {
461
- return foreachStream(
462
- stream,
463
- (a) => asyncFlatMap(hub.publish(a), () => asyncSucceed(void 0))
464
- );
465
- }
466
- function fromHub(hub) {
467
- return managedStream(
468
- asyncFlatMap(hub.subscribe(), (sub) => {
469
- const loop = fromPull(
470
- asyncFlatMap(
471
- asyncMapError(sub.take(), (_queueClosed) => none),
472
- (a) => asyncSucceed([a, loop])
473
- )
474
- );
475
- return asyncSucceed({
476
- stream: loop,
477
- release: (_exit) => asyncSync(() => sub.unsubscribe())
478
- });
479
- })
480
- );
481
- }
482
-
483
492
  // src/core/stream/chunks.ts
484
493
  var cachedWasmChunkCtor;
485
494
  function resolveWasmChunkBuffer() {
@@ -1203,6 +1212,139 @@ function groupedP(n) {
1203
1212
  });
1204
1213
  }
1205
1214
 
1215
+ // src/core/stream/dx.ts
1216
+ var Stream = Object.freeze({
1217
+ from: (values) => asStream(fromArray(values)),
1218
+ empty: () => asStream(emptyStream()),
1219
+ range: (start, end2) => asStream(rangeStream(start, end2)),
1220
+ wrap: asStream
1221
+ });
1222
+ var Pipeline = Object.freeze({
1223
+ map: mapP,
1224
+ filter: filterP
1225
+ });
1226
+ function asStream(stream) {
1227
+ const target = stream;
1228
+ if (typeof target.pipe === "function") return target;
1229
+ Object.defineProperties(target, {
1230
+ pipe: {
1231
+ value(pipeline) {
1232
+ return asStream(via(target, pipeline));
1233
+ }
1234
+ },
1235
+ map: {
1236
+ value(f) {
1237
+ return asStream(via(target, mapP(f)));
1238
+ }
1239
+ },
1240
+ filter: {
1241
+ value(predicate) {
1242
+ return asStream(via(target, filterP(predicate)));
1243
+ }
1244
+ },
1245
+ collect: {
1246
+ value(runtime) {
1247
+ return runtime.toPromise(collectStream(target));
1248
+ }
1249
+ }
1250
+ });
1251
+ return target;
1252
+ }
1253
+
1254
+ // src/core/stream/hub.ts
1255
+ var toQueueStrategy = (s) => s === "BackPressure" ? "backpressure" : s === "Dropping" ? "dropping" : "sliding";
1256
+ function makeHub(capacity, strategy = "BackPressure") {
1257
+ const queues = /* @__PURE__ */ new Set();
1258
+ let closed = false;
1259
+ const publish = (a) => {
1260
+ if (closed) return asyncSucceed(false);
1261
+ const size = queues.size;
1262
+ if (size === 0) return asyncSucceed(true);
1263
+ if (size === 1) {
1264
+ const q = queues.values().next().value;
1265
+ return q.offer(a);
1266
+ }
1267
+ let eff = asyncSucceed(true);
1268
+ for (const q of queues) {
1269
+ eff = asyncFlatMap(
1270
+ eff,
1271
+ (okSoFar) => asyncFlatMap(q.offer(a), (ok) => asyncSucceed(okSoFar && ok))
1272
+ );
1273
+ }
1274
+ return eff;
1275
+ };
1276
+ const publishAll = (as) => {
1277
+ let eff = asyncSucceed(true);
1278
+ const it = as[Symbol.iterator]();
1279
+ while (true) {
1280
+ const n = it.next();
1281
+ if (n.done) break;
1282
+ const a = n.value;
1283
+ eff = asyncFlatMap(
1284
+ eff,
1285
+ (okSoFar) => asyncFlatMap(publish(a), (ok) => asyncSucceed(okSoFar && ok))
1286
+ );
1287
+ }
1288
+ return eff;
1289
+ };
1290
+ const subscribe = () => {
1291
+ if (closed) {
1292
+ return asyncTotal(() => {
1293
+ throw { _tag: "HubClosed" };
1294
+ });
1295
+ }
1296
+ return asyncFlatMap(
1297
+ bounded(capacity, toQueueStrategy(strategy)),
1298
+ (q) => asyncSync(() => {
1299
+ queues.add(q);
1300
+ return {
1301
+ ...q,
1302
+ unsubscribe: () => {
1303
+ if (!queues.has(q)) return;
1304
+ queues.delete(q);
1305
+ q.shutdown();
1306
+ }
1307
+ };
1308
+ })
1309
+ );
1310
+ };
1311
+ const shutdown = () => asyncSync(() => {
1312
+ if (closed) return;
1313
+ closed = true;
1314
+ for (const q of queues) q.shutdown();
1315
+ queues.clear();
1316
+ });
1317
+ return {
1318
+ publish,
1319
+ publishAll,
1320
+ subscribe,
1321
+ shutdown
1322
+ };
1323
+ }
1324
+ var broadcast = makeHub;
1325
+ function broadcastToHub(stream, hub) {
1326
+ return foreachStream(
1327
+ stream,
1328
+ (a) => asyncFlatMap(hub.publish(a), () => asyncSucceed(void 0))
1329
+ );
1330
+ }
1331
+ function fromHub(hub) {
1332
+ return managedStream(
1333
+ asyncFlatMap(hub.subscribe(), (sub) => {
1334
+ const loop = fromPull(
1335
+ asyncFlatMap(
1336
+ asyncMapError(sub.take(), (_queueClosed) => none),
1337
+ (a) => asyncSucceed([a, loop])
1338
+ )
1339
+ );
1340
+ return asyncSucceed({
1341
+ stream: loop,
1342
+ release: (_exit) => asyncSync(() => sub.unsubscribe())
1343
+ });
1344
+ })
1345
+ );
1346
+ }
1347
+
1206
1348
  // src/core/stream/operators.ts
1207
1349
  function throttle(stream, intervalMs) {
1208
1350
  let lastEmitTime = 0;
@@ -1374,21 +1516,34 @@ export {
1374
1516
  DefaultHostExecutor,
1375
1517
  EVENT_WORDS,
1376
1518
  EngineFiberHandle,
1519
+ EventBus,
1377
1520
  EventKindCode,
1378
1521
  Exit,
1379
1522
  HostRegistry,
1523
+ InMemoryTracer,
1380
1524
  JsFiberEngine,
1525
+ Layer,
1526
+ LayerContext,
1527
+ MissingLayerServiceError,
1381
1528
  NONE_U32,
1382
1529
  NoopHooks,
1383
1530
  OpcodeTagCode,
1384
1531
  PURE_PIPELINE_TAG,
1532
+ Pipeline,
1385
1533
  ProgramBuilder,
1386
1534
  PushStatus,
1535
+ Resource,
1387
1536
  RingBuffer,
1388
1537
  Runtime,
1389
1538
  RuntimeFiber,
1539
+ RuntimeRegistry,
1540
+ Schedule,
1390
1541
  Scheduler,
1391
1542
  Scope,
1543
+ Stream,
1544
+ Supervisor,
1545
+ TestClock,
1546
+ TestScheduler,
1392
1547
  WasmFiberEngine,
1393
1548
  WasmFiberRegistryBridge,
1394
1549
  WasmPackFiberBridge,
@@ -1397,6 +1552,7 @@ export {
1397
1552
  andThen2 as andThen,
1398
1553
  andThen as andThenSchedule,
1399
1554
  applyFused,
1555
+ asStream,
1400
1556
  assertCompletesWithin,
1401
1557
  assertFails,
1402
1558
  assertFailsWith,
@@ -1419,6 +1575,7 @@ export {
1419
1575
  broadcastToHub,
1420
1576
  buffer,
1421
1577
  bufferP,
1578
+ buildLayer,
1422
1579
  catchAll,
1423
1580
  catchTag,
1424
1581
  catchTags,
@@ -1429,16 +1586,25 @@ export {
1429
1586
  compose2 as compose,
1430
1587
  compose as composeLayer,
1431
1588
  concatStream,
1589
+ consoleJsonLogger,
1590
+ contramap as contramapSchedule,
1591
+ ctxExtend,
1592
+ ctxToObject,
1432
1593
  debounce,
1433
1594
  decodeEvent,
1434
1595
  decodeEventBatch,
1596
+ defaultTracer,
1597
+ defineLayer,
1598
+ defineService,
1435
1599
  delayedEffect,
1436
1600
  derivedRef,
1437
1601
  deserializeFusedPipeline,
1438
1602
  dropP,
1439
1603
  drop as dropStream,
1604
+ dumpAllFibers,
1440
1605
  elapsed,
1441
1606
  emitStream,
1607
+ emptyContext,
1442
1608
  emptyStream,
1443
1609
  encodeOpcodeNodes,
1444
1610
  encodeOpcodeProgram,
@@ -1447,6 +1613,8 @@ export {
1447
1613
  ensuring,
1448
1614
  exponential,
1449
1615
  fail,
1616
+ fiberRefSnapshot,
1617
+ fibonacci,
1450
1618
  filterMapP,
1451
1619
  filterP,
1452
1620
  fixed,
@@ -1454,7 +1622,10 @@ export {
1454
1622
  flatMap,
1455
1623
  flattenStream,
1456
1624
  foreachStream,
1625
+ forever,
1457
1626
  fork,
1627
+ formatCause,
1628
+ formatLayerError,
1458
1629
  fromArray,
1459
1630
  fromHub,
1460
1631
  fromPromiseAbortable,
@@ -1462,6 +1633,8 @@ export {
1462
1633
  fuse,
1463
1634
  getBenchmarkBudget,
1464
1635
  getCurrentFiber,
1636
+ getFiberRef,
1637
+ getService,
1465
1638
  getStats,
1466
1639
  globalScheduler,
1467
1640
  gracefulShutdown,
@@ -1470,25 +1643,46 @@ export {
1470
1643
  inferCallerLaneFromStack,
1471
1644
  initState,
1472
1645
  interleave,
1646
+ interruptible,
1473
1647
  intersect,
1648
+ isCause,
1474
1649
  isFusionEnabled,
1475
1650
  isFusionVerbose,
1651
+ jitter,
1476
1652
  jittered,
1653
+ jitteredSchedule,
1654
+ joinSupervised,
1477
1655
  laneTag,
1478
1656
  layer,
1657
+ layerEffect,
1479
1658
  layerFail,
1480
1659
  layerFrom,
1660
+ layerFromContext,
1481
1661
  layerSucceed,
1662
+ layerValue,
1663
+ linear,
1482
1664
  linkAbortController,
1665
+ liveClock,
1666
+ locallyFiberRef,
1667
+ locallyFiberRefWith,
1483
1668
  makeBoundedRingBuffer,
1484
1669
  makeCancelToken,
1485
1670
  makeCircuitBreaker,
1486
1671
  makeFiberReadyQueue,
1672
+ makeFiberRef,
1487
1673
  makeHub,
1674
+ makeLayerScope,
1488
1675
  makeMetrics,
1489
1676
  makeRef,
1677
+ makeResource,
1678
+ makeRuntime,
1679
+ makeRuntimeEventRecord,
1680
+ makeRuntimeRecorder,
1681
+ makeScheduleDriver,
1490
1682
  makeSemaphore,
1683
+ makeServiceTag,
1491
1684
  makeStreamChunker,
1685
+ makeSupervisor,
1492
1686
  makeTestRuntime,
1493
1687
  makeTracer,
1494
1688
  makeWorkerPool,
@@ -1505,62 +1699,104 @@ export {
1505
1699
  mapError2 as mapErrorTyped,
1506
1700
  mapLayer,
1507
1701
  mapP,
1702
+ map2 as mapSchedule,
1508
1703
  mapStream,
1509
1704
  mapTryAsync,
1705
+ maxDelay,
1706
+ maxElapsed,
1510
1707
  merge2 as merge,
1511
1708
  merge as mergeLayer,
1512
1709
  mergeStream,
1710
+ modifyFiberRef,
1711
+ named as namedSchedule,
1712
+ never,
1513
1713
  neverEffect,
1514
1714
  none,
1715
+ once,
1515
1716
  orElse,
1516
1717
  orElseOptional,
1718
+ poll as pollWithSchedule,
1719
+ prettyCause,
1720
+ provide,
1721
+ provideContext,
1517
1722
  provideLayer,
1723
+ provideLayerContext,
1518
1724
  race,
1519
1725
  raceWith,
1520
1726
  rangeStream,
1521
1727
  recurs,
1522
1728
  registerShutdownHooks,
1523
1729
  repeatWithSchedule,
1730
+ repeat as repeatWithScheduleAlias,
1524
1731
  resetAbortablePromiseStats,
1732
+ resource,
1733
+ resourceAll,
1734
+ resourceFromManaged,
1735
+ resourceSucceed,
1525
1736
  retry,
1526
1737
  retryN,
1527
1738
  retryWithBackoff,
1528
1739
  retryWithSchedule,
1740
+ retry2 as retryWithScheduleAlias,
1741
+ runEffect,
1742
+ runExit,
1529
1743
  runFusedArray,
1744
+ runPromise,
1745
+ runSchedule,
1530
1746
  runtimeCapabilities,
1747
+ runtimeClockFromEnv,
1748
+ runtimeEventRecordContext,
1531
1749
  runtimeForCaller,
1750
+ runtimeHooksToEventHandler,
1532
1751
  sanitizeLaneKey,
1533
1752
  scan,
1753
+ scheduleDriver,
1534
1754
  selectedEngineStats,
1535
1755
  serializeFusedPipeline,
1756
+ serviceTag,
1536
1757
  setBenchmarkBudget,
1758
+ setFiberRef,
1537
1759
  setFusionEnabled,
1538
1760
  setFusionVerbose,
1539
1761
  sleep,
1540
1762
  some,
1763
+ spaced,
1541
1764
  streamFromReadableStream,
1542
1765
  succeed,
1766
+ supervise,
1543
1767
  sync,
1544
1768
  tagError,
1545
1769
  takeP,
1546
1770
  take as takeSchedule,
1547
1771
  take2 as takeStream,
1772
+ tapDecision,
1548
1773
  tapEffectP,
1549
1774
  throttle,
1550
1775
  timeout,
1551
1776
  toPromise,
1552
1777
  toPromiseByCaller,
1553
1778
  uncons,
1779
+ uninterruptible,
1780
+ uninterruptibleMask,
1554
1781
  union,
1555
1782
  unit,
1556
1783
  unsafeGetCurrentRuntime,
1784
+ unsafeGetFiberRef,
1557
1785
  unsafeRunAsync,
1558
1786
  unsafeRunFoldWithEnv,
1787
+ unsafeSetFiberRef,
1788
+ untilInput,
1789
+ untilOutput,
1559
1790
  unwrapScoped,
1791
+ upTo,
1792
+ updateFiberRef,
1560
1793
  useManaged,
1794
+ useResource,
1561
1795
  via,
1562
1796
  whileInput,
1797
+ whileOutput,
1563
1798
  widenOpt,
1799
+ windowed,
1564
1800
  withAsyncPromise,
1565
1801
  withCurrentFiber,
1566
1802
  withScope,