clanka 0.8.3 → 0.8.5

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 (40) hide show
  1. package/dist/AgentExecutor.d.ts.map +1 -1
  2. package/dist/AgentExecutor.js +1 -1
  3. package/dist/AgentExecutor.js.map +1 -1
  4. package/dist/AgentExecutor.test.d.ts +2 -0
  5. package/dist/AgentExecutor.test.d.ts.map +1 -0
  6. package/dist/AgentExecutor.test.js +87 -0
  7. package/dist/AgentExecutor.test.js.map +1 -0
  8. package/dist/AgentSkills.test.js +1 -0
  9. package/dist/AgentSkills.test.js.map +1 -1
  10. package/dist/AgentTools.d.ts.map +1 -1
  11. package/dist/AgentTools.js +2 -1
  12. package/dist/AgentTools.js.map +1 -1
  13. package/dist/Compaction.test.js +1 -0
  14. package/dist/Compaction.test.js.map +1 -1
  15. package/dist/bin/{Effect-BCeySOy1.mjs → Effect-BEUn4I5E.mjs} +339 -288
  16. package/dist/bin/Effect-BEUn4I5E.mjs.map +1 -0
  17. package/dist/bin/{McpClient-DP4jlaD1.mjs → McpClient-C0FVuDj2.mjs} +218 -62
  18. package/dist/bin/McpClient-C0FVuDj2.mjs.map +1 -0
  19. package/dist/bin/{OutputFormatter-Ch8yFytV.mjs → OutputFormatter-DffD5oxX.mjs} +8 -8
  20. package/dist/bin/OutputFormatter-DffD5oxX.mjs.map +1 -0
  21. package/dist/bin/{Schema-C9JQ5hI0.mjs → Schema-CjUGw2Xh.mjs} +480 -384
  22. package/dist/bin/Schema-CjUGw2Xh.mjs.map +1 -0
  23. package/dist/bin/{SemanticSearch-BJGnYhFt.mjs → SemanticSearch-CFB73IPb.mjs} +321 -268
  24. package/dist/bin/SemanticSearch-CFB73IPb.mjs.map +1 -0
  25. package/dist/bin/{Stream-CgH3SuLu.mjs → Stream-Cu6P7ZHo.mjs} +180 -172
  26. package/dist/bin/Stream-Cu6P7ZHo.mjs.map +1 -0
  27. package/dist/bin/cli.mjs +306 -259
  28. package/dist/bin/cli.mjs.map +1 -1
  29. package/package.json +20 -20
  30. package/src/AgentExecutor.test.ts +133 -0
  31. package/src/AgentExecutor.ts +1 -2
  32. package/src/AgentSkills.test.ts +1 -0
  33. package/src/AgentTools.ts +2 -1
  34. package/src/Compaction.test.ts +1 -0
  35. package/dist/bin/Effect-BCeySOy1.mjs.map +0 -1
  36. package/dist/bin/McpClient-DP4jlaD1.mjs.map +0 -1
  37. package/dist/bin/OutputFormatter-Ch8yFytV.mjs.map +0 -1
  38. package/dist/bin/Schema-C9JQ5hI0.mjs.map +0 -1
  39. package/dist/bin/SemanticSearch-BJGnYhFt.mjs.map +0 -1
  40. package/dist/bin/Stream-CgH3SuLu.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
- import { $i as headUnsafe, $r as exitInterrupt$1, A as ensuring$2, B as fnUntraced, Br as succeed$3, C as catch_$2, Ci as succeedNone, Cn as isDoneCause, Ct as promise, Do as exitSucceed, Dr as doneUnsafe, Dt as raceFirst, E as contextWith, Ei as uninterruptibleMask, Eo as exitFailCause, Es as dual, Et as provideService$2, Fn as done, Fr as failCause$4, G as forkIn, Gr as andThen$1, Gt as tap$1, H as forEach, I as flatMap$2, Io as toJson, Ir as interrupt$1, K as forkScoped, Kr as asSome, L as flatMapEager, Lr as isExit, M as fail$3, Mr as makeUnsafe$3, N as failCause$3, Nt as runForkWith, Oa as get$1, Oi as void_$1, Oo as withFiber$1, Or as interruptWith, Os as identity, Pn as die$2, Pr as fail$5, Ps as pipeArguments, Qt as uninterruptible, R as flatten$1, Rn as findError, Rt as scopedWith, Si as succeed$4, Sn as filterDone, Ss as constTrue, T as context, Ti as sync$1, To as exitFail, Tr as _await, Ts as constant, Tt as provideContext$2, U as forever, Ui as isReadonlyArrayNonEmpty, Ut as suspend$2, Vi as isArrayNonEmpty, Vr as void_$2, Vt as succeed$2, W as forkChild, Wt as sync, Y as gen, Yi as of, Yt as tryPromise, Z as interrupt$2, _r as close, _s as isTagged, _t as onExit$1, a as andThen, aa as isSuccess$1, ai as fiberInterruptAllAs, an as whileLoop, bn as catchDone, br as makeUnsafe$2, c as as, ca as succeed$5, ci as fiberRunIn, di as getCurrentFiber, ea as fail$4, ei as exitVoid, es as hasProperty, gr as addFinalizerExit, gs as isString$1, gt as onError, hi as makeLatchUnsafe, hr as addFinalizer, ht as never, ia as isFailure, ii as fiberInterruptAll, in as when, io as some, j as exit, li as flatMap$3, m as catchCause$1, mi as makeLatch, mr as Scope, ni as fiberAwait, oi as fiberInterruptAs, on as withFiber, ot as map$2, pt as matchCauseEffect, qi as map$3, qr as callback$1, ri as fiberInterrupt, rn as void_, si as fiberJoin, t as acquireRelease, ti as exitZipRight, to as none, u as asVoid, un as yieldNow, vr as forkUnsafe, wi as suspend$3, wn as matchEffect, wo as causeFail, ws as constVoid, xi as scopeFinalizerCountUnsafe, xn as doneExitFromCause, xo as PipeInspectableProto, xr as provide, yi as onExitPrimitive, yo as Done, yt as onInterrupt, zi as fromIterable$1, zr as isSuccess } from "./Effect-BCeySOy1.mjs";
2
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/internal/count.js
1
+ import { $t as uninterruptible, Bi as fromIterable$1, Br as isSuccess, Ci as succeed$4, Cn as filterDone, Cs as constTrue, D as contextWith, Di as uninterruptibleMask, Do as exitFailCause, Ds as dual, Dt as provideService$2, E as context, Ei as sync$1, Eo as exitFail, Es as constant, Et as provideContext$2, Fn as die$2, Fr as fail$5, Fs as pipeArguments, G as forkChild, Gt as sync, Hi as isArrayNonEmpty, Hr as void_$2, Ht as succeed$3, In as done, Ir as failCause$4, Ji as map$3, Jr as callback$2, K as forkIn, Kr as andThen$1, Kt as tap$1, L as flatMap$2, Lo as toJson, Lr as interrupt$1, M as exit, N as fail$3, Nr as makeUnsafe$3, Oo as exitSucceed, Or as doneUnsafe, Ot as raceFirst, P as failCause$3, Pt as runForkWith, Q as interrupt$2, Qa as isSome, R as flatMapEager, Rr as isExit, Sn as doneExitFromCause, So as PipeInspectableProto, Sr as provide, Ti as suspend$3, Tn as matchEffect, To as causeFail, Ts as constVoid, U as forEach, V as fnUntraced, Vr as succeed$2, W as forever, Wi as isReadonlyArrayNonEmpty, Wt as suspend$2, X as gen, Xi as of, Xt as tryPromise, _r as addFinalizerExit, _s as isString$1, _t as onError, a as andThen, aa as isFailure, ai as fiberInterruptAll, an as when, ao as some, bo as Done, bt as onInterrupt, c as as, ci as fiberJoin, dn as yieldNow, ea as headUnsafe, ei as exitInterrupt$1, fi as getCurrentFiber, gi as makeLatchUnsafe, gr as addFinalizer, gt as never, hi as makeLatch, hr as Scope, ii as fiberInterrupt, in as void_, j as ensuring$2, ka as get$1, ki as void_$1, ko as withFiber$1, kr as interruptWith, ks as identity, la as succeed$5, li as fiberRunIn, m as catchCause$1, mt as matchCauseEffect, ni as exitZipRight, no as none, oa as isSuccess$1, oi as fiberInterruptAllAs, on as whileLoop, p as callback$1, q as forkScoped, qr as asSome, ri as fiberAwait, si as fiberInterruptAs, sn as withFiber, st as map$2, t as acquireRelease, ta as fail$4, ti as exitVoid, ts as hasProperty, u as asVoid, ui as flatMap$3, vr as close, vs as isTagged, vt as onExit$1, w as catch_$2, wi as succeedNone, wn as isDoneCause, wt as promise, xi as onExitPrimitive, xn as catchDone, xr as makeUnsafe$2, yr as forkUnsafe, z as flatten$1, zn as findError, zt as scopedWith } from "./Effect-BEUn4I5E.mjs";
2
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/count.js
3
3
  const normalize = (n) => n > 0 ? Math.floor(n) : 0;
4
4
  const normalizeNonEmpty = (n) => Math.max(1, normalize(n));
5
5
  //#endregion
6
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Number.js
6
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Number.js
7
7
  const Number$1 = globalThis.Number;
8
8
  const nextPow2 = (n) => {
9
9
  const nextPow = Math.ceil(Math.log(n) / Math.log(2));
@@ -22,13 +22,13 @@ const round = dual(2, (self, precision) => {
22
22
  return Math.round(self * factor) / factor;
23
23
  });
24
24
  //#endregion
25
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/String.js
25
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/String.js
26
26
  const String = globalThis.String;
27
27
  const isString = isString$1;
28
28
  const toLowerCase = (self) => self.toLowerCase();
29
29
  const camelToSnake = (self) => self.replace(/([A-Z])/g, "_$1").toLowerCase();
30
30
  //#endregion
31
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Fiber.js
31
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Fiber.js
32
32
  const await_ = fiberAwait;
33
33
  const join = fiberJoin;
34
34
  const interrupt = fiberInterrupt;
@@ -38,11 +38,11 @@ const interruptAllAs = fiberInterruptAllAs;
38
38
  const getCurrent = getCurrentFiber;
39
39
  const runIn = fiberRunIn;
40
40
  //#endregion
41
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Latch.js
41
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Latch.js
42
42
  const makeUnsafe$1 = makeLatchUnsafe;
43
43
  const make$5 = makeLatch;
44
44
  //#endregion
45
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/MutableRef.js
45
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/MutableRef.js
46
46
  const TypeId$5 = "~effect/MutableRef";
47
47
  const MutableRefProto = {
48
48
  [TypeId$5]: TypeId$5,
@@ -66,13 +66,22 @@ const set = dual(2, (self, value) => {
66
66
  });
67
67
  const update = dual(2, (self, f) => set(self, f(get(self))));
68
68
  //#endregion
69
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/MutableList.js
69
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/MutableList.js
70
70
  const Empty = Symbol.for("effect/MutableList/Empty");
71
71
  const make$3 = () => ({
72
72
  head: void 0,
73
73
  tail: void 0,
74
74
  length: 0
75
75
  });
76
+ const compactHead = (self) => {
77
+ const head = self.head;
78
+ if (head.offset >= 1024 && head === self.tail && head.mutable && (head.array.length - head.offset) * 8 <= head.offset) self.head = self.tail = {
79
+ array: head.array.slice(head.offset),
80
+ mutable: true,
81
+ offset: 0,
82
+ next: void 0
83
+ };
84
+ };
76
85
  const emptyBucket = () => ({
77
86
  array: [],
78
87
  mutable: true,
@@ -134,9 +143,10 @@ const takeN = (self, n) => {
134
143
  if (chunk.mutable) chunk.array[chunk.offset] = void 0;
135
144
  chunk.offset++;
136
145
  if (index === n) {
137
- self.head = chunk;
146
+ self.head = chunk.offset === chunk.array.length && chunk.next ? chunk.next : chunk;
138
147
  self.length -= n;
139
148
  if (self.length === 0) clear(self);
149
+ else compactHead(self);
140
150
  return array;
141
151
  }
142
152
  }
@@ -155,14 +165,15 @@ const take$3 = (self) => {
155
165
  if (self.head.offset === self.head.array.length) {
156
166
  if (self.head.next) self.head = self.head.next;
157
167
  else clear(self);
158
- }
168
+ } else compactHead(self);
159
169
  return message;
160
170
  };
161
171
  const filter$1 = (self, f) => {
162
172
  const array = [];
163
173
  let chunk = self.head;
174
+ let index = 0;
164
175
  while (chunk) {
165
- for (let i = chunk.offset; i < chunk.array.length; i++) if (f(chunk.array[i], i)) array.push(chunk.array[i]);
176
+ for (let i = chunk.offset; i < chunk.array.length; i++) if (f(chunk.array[i], index++)) array.push(chunk.array[i]);
166
177
  chunk = chunk.next;
167
178
  }
168
179
  if (array.length === 0) {
@@ -179,10 +190,10 @@ const filter$1 = (self, f) => {
179
190
  };
180
191
  const remove = (self, value) => filter$1(self, (v) => v !== value);
181
192
  //#endregion
182
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/PubSub.js
193
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/PubSub.js
183
194
  const TypeId$4 = "~effect/PubSub";
184
195
  const SubscriptionTypeId = "~effect/PubSub/Subscription";
185
- const make$2 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), new Map(), makeUnsafe$2(), makeUnsafe$1(false), make$4(false), options.strategy()));
196
+ const make$2 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), new Map(), makeUnsafe$2(), makeUnsafe$1(false), make$4(false), options.strategy(), make$4(none())));
186
197
  const bounded$1 = (capacity) => make$2({
187
198
  atomicPubSub: () => makeAtomicBounded(capacity),
188
199
  strategy: () => new BackPressureStrategy()
@@ -202,6 +213,7 @@ const unbounded$1 = (options) => make$2({
202
213
  const makeAtomicBounded = (capacity) => {
203
214
  const options = typeof capacity === "number" ? { capacity } : capacity;
204
215
  ensureCapacity(options.capacity);
216
+ if (options.capacity === Infinity) return makeAtomicUnbounded(options);
205
217
  const replayBuffer = options.replay && options.replay > 0 ? new ReplayBuffer(Math.ceil(options.replay)) : void 0;
206
218
  if (options.capacity === 1) return new BoundedPubSubSingle(replayBuffer);
207
219
  else if (nextPow2(options.capacity) === options.capacity) return new BoundedPubSubPow2(options.capacity, replayBuffer);
@@ -215,25 +227,40 @@ const shutdown$1 = (self) => uninterruptible(withFiber((fiber) => {
215
227
  set(self.shutdownFlag, true);
216
228
  return close(self.scope, interrupt$1(fiber.id)).pipe(andThen(self.strategy.shutdown), when(self.shutdownHook.open), asVoid);
217
229
  }));
230
+ const end$1 = dual(2, (self, value) => sync(() => endUnsafe$1(self, value)));
231
+ const endUnsafe$1 = dual(2, (self, value) => {
232
+ if (self.shutdownFlag.current || isSome(self.ended.current)) return false;
233
+ set(self.ended, some(value));
234
+ if (self.strategy instanceof BackPressureStrategy) {
235
+ for (const [_, deferred, last] of takeAll$2(self.strategy.publishers)) if (last) doneUnsafe(deferred, succeed$2(false));
236
+ }
237
+ const exit = succeed$2(value);
238
+ for (const pollersSet of self.subscribers.values()) for (const pollers of pollersSet) {
239
+ let poller;
240
+ while ((poller = take$3(pollers)) !== Empty) doneUnsafe(poller, exit);
241
+ }
242
+ self.subscribers.clear();
243
+ return true;
244
+ });
218
245
  const publish = dual(2, (self, value) => suspend$2(() => {
219
- if (self.shutdownFlag.current) return succeed$2(false);
246
+ if (self.shutdownFlag.current || isSome(self.ended.current)) return succeed$3(false);
220
247
  if (self.pubsub.publish(value)) {
221
248
  self.strategy.completeSubscribersUnsafe(self.pubsub, self.subscribers);
222
- return succeed$2(true);
249
+ return succeed$3(true);
223
250
  }
224
251
  return self.strategy.handleSurplus(self.pubsub, self.subscribers, [value], self.shutdownFlag);
225
252
  }));
226
253
  const publishAll = dual(2, (self, elements) => suspend$2(() => {
227
- if (self.shutdownFlag.current) return succeed$2(false);
254
+ if (self.shutdownFlag.current || isSome(self.ended.current)) return succeed$3(false);
228
255
  const surplus = self.pubsub.publishAll(elements);
229
256
  self.strategy.completeSubscribersUnsafe(self.pubsub, self.subscribers);
230
- if (surplus.length === 0) return succeed$2(true);
257
+ if (surplus.length === 0) return succeed$3(true);
231
258
  return self.strategy.handleSurplus(self.pubsub, self.subscribers, surplus, self.shutdownFlag);
232
259
  }));
233
260
  const subscribe = (self) => uninterruptible(contextWith((services) => {
234
261
  const localScope = get$1(services, Scope);
235
262
  const scope = forkUnsafe(self.scope);
236
- const subscription = makeSubscriptionUnsafe(self.pubsub, self.subscribers, self.strategy);
263
+ const subscription = makeSubscriptionUnsafe(self.pubsub, self.subscribers, self.strategy, self.ended);
237
264
  return addFinalizer(scope, unsubscribe(subscription)).pipe(andThen(addFinalizerExit(localScope, (exit) => close(scope, exit))), as(subscription));
238
265
  }));
239
266
  const unsubscribe = (self) => uninterruptible(withFiber((state) => {
@@ -252,13 +279,13 @@ const take$2 = (self) => suspend$2(() => {
252
279
  if (self.shutdownFlag.current) return interrupt$2;
253
280
  if (self.replayWindow.remaining > 0) {
254
281
  const message = self.replayWindow.take();
255
- return succeed$2(message);
282
+ return succeed$3(message);
256
283
  }
257
284
  const message = self.pollers.length === 0 ? self.subscription.poll() : Empty;
258
285
  if (message === Empty) return pollForItem(self);
259
286
  else {
260
287
  self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
261
- return succeed$2(message);
288
+ return succeed$3(message);
262
289
  }
263
290
  });
264
291
  const takeAll$1 = (self) => suspend$2(function loop(value) {
@@ -266,11 +293,13 @@ const takeAll$1 = (self) => suspend$2(function loop(value) {
266
293
  let as = self.pollers.length === 0 ? self.subscription.pollUpTo(Number.POSITIVE_INFINITY) : [];
267
294
  if (value) as = value.concat(as);
268
295
  self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
269
- if (self.replayWindow.remaining > 0) return succeed$2(self.replayWindow.takeAll().concat(as));
296
+ if (self.replayWindow.remaining > 0) return succeed$3(self.replayWindow.takeAll().concat(as));
270
297
  else if (!isArrayNonEmpty(as)) return flatMap$2(pollForItem(self), (item) => loop([item]));
271
- return succeed$2(as);
298
+ return succeed$3(as);
272
299
  });
273
- const pollForItem = (self) => {
300
+ const pollForItem = (self) => callback$1((resume) => {
301
+ if (self.shutdownFlag.current) return resume(interrupt$2);
302
+ if (isSome(self.ended.current)) return resume(succeed$3(self.ended.current.value));
274
303
  const deferred = makeUnsafe$3();
275
304
  let set = self.subscribers.get(self.subscription);
276
305
  if (!set) {
@@ -280,11 +309,10 @@ const pollForItem = (self) => {
280
309
  set.add(self.pollers);
281
310
  append(self.pollers, deferred);
282
311
  self.strategy.completePollersUnsafe(self.pubsub, self.subscribers, self.subscription, self.pollers);
283
- return onInterrupt(_await(deferred), () => {
284
- remove(self.pollers, deferred);
285
- return void_;
286
- });
287
- };
312
+ if (deferred.effect) return resume(deferred.effect);
313
+ deferred.resumes = [resume];
314
+ return sync(() => remove(self.pollers, deferred));
315
+ });
288
316
  const AbsentValue = Symbol.for("effect/PubSub/AbsentValue");
289
317
  const addSubscribers = (subscribers, subscription, pollers) => {
290
318
  if (!subscribers.has(subscription)) subscribers.set(subscription, new Set());
@@ -296,7 +324,7 @@ const removeSubscribers = (subscribers, subscription, pollers) => {
296
324
  set.delete(pollers);
297
325
  if (set.size === 0) subscribers.delete(subscription);
298
326
  };
299
- const makeSubscriptionUnsafe = (pubsub, subscribers, strategy) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$3(), makeUnsafe$1(false), make$4(false), strategy, pubsub.replayWindow());
327
+ const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$3(), makeUnsafe$1(false), make$4(false), strategy, pubsub.replayWindow(), ended);
300
328
  var BoundedPubSubArb = class {
301
329
  array;
302
330
  replayIndices;
@@ -853,7 +881,8 @@ var SubscriptionImpl = class {
853
881
  shutdownFlag;
854
882
  strategy;
855
883
  replayWindow;
856
- constructor(pubsub, subscribers, subscription, pollers, shutdownHook, shutdownFlag, strategy, replayWindow) {
884
+ ended;
885
+ constructor(pubsub, subscribers, subscription, pollers, shutdownHook, shutdownFlag, strategy, replayWindow, ended) {
857
886
  this.pubsub = pubsub;
858
887
  this.subscribers = subscribers;
859
888
  this.subscription = subscription;
@@ -862,6 +891,7 @@ var SubscriptionImpl = class {
862
891
  this.shutdownFlag = shutdownFlag;
863
892
  this.strategy = strategy;
864
893
  this.replayWindow = replayWindow;
894
+ this.ended = ended;
865
895
  }
866
896
  pipe() {
867
897
  return pipeArguments(this, arguments);
@@ -875,19 +905,21 @@ var PubSubImpl = class {
875
905
  shutdownHook;
876
906
  shutdownFlag;
877
907
  strategy;
878
- constructor(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy) {
908
+ ended;
909
+ constructor(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended) {
879
910
  this.pubsub = pubsub;
880
911
  this.subscribers = subscribers;
881
912
  this.scope = scope;
882
913
  this.shutdownHook = shutdownHook;
883
914
  this.shutdownFlag = shutdownFlag;
884
915
  this.strategy = strategy;
916
+ this.ended = ended;
885
917
  }
886
918
  pipe() {
887
919
  return pipeArguments(this, arguments);
888
920
  }
889
921
  };
890
- const makePubSubUnsafe = (pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy) => new PubSubImpl(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy);
922
+ const makePubSubUnsafe = (pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended) => new PubSubImpl(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended);
891
923
  const ensureCapacity = (capacity) => {
892
924
  if (capacity <= 0) throw new Error(`Cannot construct PubSub with capacity of ${capacity}`);
893
925
  };
@@ -900,15 +932,18 @@ var BackPressureStrategy = class {
900
932
  }));
901
933
  }
902
934
  handleSurplus(pubsub, subscribers, elements, isShutdown) {
903
- return suspend$2(() => {
935
+ return callback$1((resume) => {
904
936
  const deferred = makeUnsafe$3();
905
937
  this.offerUnsafe(elements, deferred);
906
938
  this.onPubSubEmptySpaceUnsafe(pubsub, subscribers);
907
939
  this.completeSubscribersUnsafe(pubsub, subscribers);
908
- return (get(isShutdown) ? interrupt$2 : _await(deferred)).pipe(onInterrupt(() => {
940
+ if (get(isShutdown)) {
909
941
  this.removeUnsafe(deferred);
910
- return void_;
911
- }));
942
+ return resume(interrupt$2);
943
+ }
944
+ if (deferred.effect) return resume(deferred.effect);
945
+ deferred.resumes = [resume];
946
+ return sync(() => this.removeUnsafe(deferred));
912
947
  });
913
948
  }
914
949
  onPubSubEmptySpaceUnsafe(pubsub, subscribers) {
@@ -919,7 +954,7 @@ var BackPressureStrategy = class {
919
954
  else {
920
955
  const [value, deferred] = publisher;
921
956
  const published = pubsub.publish(value);
922
- if (published && publisher[2]) doneUnsafe(deferred, succeed$3(true));
957
+ if (published && publisher[2]) doneUnsafe(deferred, succeed$2(true));
923
958
  else if (!published) prepend(this.publishers, publisher);
924
959
  this.completeSubscribersUnsafe(pubsub, subscribers);
925
960
  }
@@ -961,7 +996,7 @@ var DroppingStrategy = class {
961
996
  return void_;
962
997
  }
963
998
  handleSurplus(_pubsub, _subscribers, _elements, _isShutdown) {
964
- return succeed$2(false);
999
+ return succeed$3(false);
965
1000
  }
966
1001
  onPubSubEmptySpaceUnsafe(_pubsub, _subscribers) {}
967
1002
  completePollersUnsafe(pubsub, subscribers, subscription, pollers) {
@@ -1016,7 +1051,7 @@ const strategyCompletePollersUnsafe = (strategy, pubsub, subscribers, subscripti
1016
1051
  const pollResult = subscription.poll();
1017
1052
  if (pollResult === Empty) prepend(pollers, poller);
1018
1053
  else {
1019
- doneUnsafe(poller, succeed$3(pollResult));
1054
+ doneUnsafe(poller, succeed$2(pollResult));
1020
1055
  strategy.onPubSubEmptySpaceUnsafe(pubsub, subscribers);
1021
1056
  }
1022
1057
  }
@@ -1132,7 +1167,7 @@ const emptyReplayWindow = {
1132
1167
  close: () => void 0
1133
1168
  };
1134
1169
  //#endregion
1135
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Queue.js
1170
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Queue.js
1136
1171
  const TypeId$3 = "~effect/Queue";
1137
1172
  const EnqueueTypeId = "~effect/Queue/Enqueue";
1138
1173
  const DequeueTypeId = "~effect/Queue/Dequeue";
@@ -1170,26 +1205,7 @@ const make$1 = (options) => withFiber$1((fiber) => {
1170
1205
  });
1171
1206
  const bounded = (capacity) => make$1({ capacity });
1172
1207
  const unbounded = () => make$1();
1173
- const offer = dual(2, (self, message) => suspend$3(() => {
1174
- if (self.state._tag !== "Open") return exitFalse;
1175
- else if (self.messages.length >= self.capacity) switch (self.strategy) {
1176
- case "dropping": return exitFalse;
1177
- case "suspend":
1178
- if (self.capacity <= 0 && self.state.takers.size > 0) {
1179
- append(self.messages, message);
1180
- releaseTakers(self);
1181
- return exitTrue;
1182
- }
1183
- return offerRemainingSingle(self, message);
1184
- case "sliding":
1185
- take$3(self.messages);
1186
- append(self.messages, message);
1187
- return exitTrue;
1188
- }
1189
- append(self.messages, message);
1190
- scheduleReleaseTaker(self);
1191
- return exitTrue;
1192
- }));
1208
+ const offer = dual(2, (self, message) => suspend$3(() => offerUnsafe(self, message) ? exitTrue : self.state._tag === "Open" && self.strategy === "suspend" ? offerOrWait(self, message) : exitFalse));
1193
1209
  const offerUnsafe = (self, message) => {
1194
1210
  if (self.state._tag !== "Open") return false;
1195
1211
  else if (self.messages.length >= self.capacity) {
@@ -1208,12 +1224,15 @@ const offerUnsafe = (self, message) => {
1208
1224
  scheduleReleaseTaker(self);
1209
1225
  return true;
1210
1226
  };
1211
- const offerAll = dual(2, (self, messages) => suspend$3(() => {
1212
- if (self.state._tag !== "Open") return succeed$4(fromIterable$1(messages));
1227
+ const offerAll = dual(2, (self, messages) => callback$2((resume) => {
1213
1228
  const remaining = offerAllUnsafe(self, messages);
1214
- if (remaining.length === 0) return exitSucceed([]);
1215
- else if (self.strategy === "dropping") return succeed$4(remaining);
1216
- return offerRemainingArray(self, remaining);
1229
+ if (remaining.length === 0 || self.strategy === "dropping") return resume(exitSucceed(remaining));
1230
+ return waitToOffer(self, {
1231
+ _tag: "Array",
1232
+ remaining,
1233
+ offset: 0,
1234
+ resume
1235
+ });
1217
1236
  }));
1218
1237
  const offerAllUnsafe = (self, messages) => {
1219
1238
  if (self.state._tag !== "Open") return fromIterable$1(messages);
@@ -1250,6 +1269,7 @@ const failCauseUnsafe = (self, cause) => {
1250
1269
  _tag: "Closing",
1251
1270
  exit: fail
1252
1271
  };
1272
+ scheduleReleaseTaker(self);
1253
1273
  return true;
1254
1274
  };
1255
1275
  const end = (self) => failCause$2(self, causeFail(Done()));
@@ -1260,17 +1280,16 @@ const shutdownUnsafe = (self) => {
1260
1280
  clear(self.messages);
1261
1281
  const offers = self.state.offers;
1262
1282
  finalize(self, self.state._tag === "Open" ? exitInterrupt : self.state.exit);
1263
- for (const entry of offers) if (entry._tag === "Single") entry.resume(exitFalse);
1264
- else entry.resume(exitSucceed(entry.remaining.slice(entry.offset)));
1283
+ for (const entry of offers) resumeUnoffered(entry);
1265
1284
  return true;
1266
1285
  };
1267
1286
  const takeAll = (self) => takeBetween(self, 1, Number.POSITIVE_INFINITY);
1268
1287
  const takeBetween = dual(3, (self, min, max) => {
1269
1288
  min = normalize(min);
1270
1289
  max = normalize(max);
1271
- return suspend$3(() => takeBetweenUnsafe(self, min, max) ?? andThen$1(awaitTake(self), takeBetween(self, 1, max)));
1290
+ return suspend$3(() => takeBetweenUnsafe(self, min, max) ?? andThen$1(awaitTake(self, () => canTake(self, min)), takeBetween(self, min, max)));
1272
1291
  });
1273
- const take$1 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake(self), take$1(self)));
1292
+ const take$1 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake(self, () => canTake(self, 1)), take$1(self)));
1274
1293
  const poll = (self) => suspend$3(() => {
1275
1294
  const result = takeUnsafe(self);
1276
1295
  if (result === void 0) return succeed$4(none());
@@ -1297,8 +1316,9 @@ const exitInterrupt = exitInterrupt$1();
1297
1316
  const releaseTakers = (self) => {
1298
1317
  if (self.state._tag === "Done" || self.state.takers.size === 0) return;
1299
1318
  for (const taker of self.state.takers) {
1319
+ if (!taker.ready()) continue;
1300
1320
  self.state.takers.delete(taker);
1301
- taker(exitVoid);
1321
+ taker.resume(exitVoid);
1302
1322
  if (self.messages.length === 0) break;
1303
1323
  }
1304
1324
  };
@@ -1313,47 +1333,40 @@ const scheduleReleaseTaker = (self) => {
1313
1333
  const takeBetweenUnsafe = (self, min, max) => {
1314
1334
  if (self.state._tag === "Done") return self.state.exit;
1315
1335
  else if (max <= 0 || min <= 0) return exitSucceed([]);
1316
- else if (self.capacity <= 0 && self.messages.length === 0 && self.state.offers.size > 0) {
1317
- const messages = [takeOfferUnsafe(self.state.offers)];
1318
- releaseCapacity(self);
1319
- return exitSucceed(messages);
1320
- }
1321
- min = Math.min(min, self.capacity || 1);
1322
- if (min <= self.messages.length) {
1323
- const messages = takeN(self.messages, max);
1324
- releaseCapacity(self);
1325
- return exitSucceed(messages);
1326
- }
1336
+ else if (!canTake(self, min)) return;
1337
+ const messages = self.messages.length > 0 ? takeN(self.messages, max) : [takeOfferUnsafe(self.state.offers)];
1338
+ releaseCapacity(self);
1339
+ return exitSucceed(messages);
1327
1340
  };
1328
- const offerRemainingSingle = (self, message) => {
1329
- return callback$1((resume) => {
1330
- if (self.state._tag !== "Open") return resume(exitFalse);
1331
- const entry = {
1332
- _tag: "Single",
1333
- message,
1334
- resume
1335
- };
1336
- self.state.offers.add(entry);
1337
- return sync$1(() => {
1338
- if (self.state._tag === "Open") self.state.offers.delete(entry);
1339
- });
1341
+ const canTake = (self, min) => self.messages.length >= (self.state._tag === "Closing" ? 1 : Math.min(min, self.capacity || 1)) || self.capacity <= 0 && self.state._tag !== "Done" && self.state.offers.size > 0;
1342
+ const awaitTake = (self, ready) => callback$2((resume) => {
1343
+ if (self.state._tag === "Done") return resume(self.state.exit);
1344
+ if (ready()) return resume(exitVoid);
1345
+ const taker = {
1346
+ ready,
1347
+ resume
1348
+ };
1349
+ self.state.takers.add(taker);
1350
+ return sync$1(() => {
1351
+ if (self.state._tag !== "Done") self.state.takers.delete(taker);
1340
1352
  });
1341
- };
1342
- const offerRemainingArray = (self, remaining) => {
1343
- return callback$1((resume) => {
1344
- if (self.state._tag !== "Open") return resume(exitSucceed(remaining));
1345
- const entry = {
1346
- _tag: "Array",
1347
- remaining,
1348
- offset: 0,
1349
- resume
1350
- };
1351
- self.state.offers.add(entry);
1352
- return sync$1(() => {
1353
- if (self.state._tag === "Open") self.state.offers.delete(entry);
1354
- });
1353
+ });
1354
+ const offerOrWait = (self, message) => callback$2((resume) => offerUnsafe(self, message) ? resume(exitTrue) : waitToOffer(self, {
1355
+ _tag: "Single",
1356
+ message,
1357
+ resume
1358
+ }));
1359
+ const waitToOffer = (self, entry) => {
1360
+ if (self.state._tag !== "Open") return resumeUnoffered(entry);
1361
+ const offers = self.state.offers;
1362
+ offers.add(entry);
1363
+ return sync$1(() => {
1364
+ if (self.state._tag === "Done") return;
1365
+ offers.delete(entry);
1366
+ if (self.state._tag === "Closing" && offers.size === 0 && self.messages.length === 0) finalize(self, self.state.exit);
1355
1367
  });
1356
1368
  };
1369
+ const resumeUnoffered = (entry) => entry._tag === "Single" ? entry.resume(exitFalse) : entry.resume(exitSucceed(entry.remaining.slice(entry.offset)));
1357
1370
  const takeOfferUnsafe = (offers) => {
1358
1371
  const entry = offers.values().next().value;
1359
1372
  if (entry._tag === "Single") {
@@ -1396,13 +1409,6 @@ const releaseCapacity = (self) => {
1396
1409
  }
1397
1410
  return false;
1398
1411
  };
1399
- const awaitTake = (self) => callback$1((resume) => {
1400
- if (self.state._tag === "Done") return resume(self.state.exit);
1401
- self.state.takers.add(resume);
1402
- return sync$1(() => {
1403
- if (self.state._tag !== "Done") self.state.takers.delete(resume);
1404
- });
1405
- });
1406
1412
  const finalize = (self, exit) => {
1407
1413
  if (self.state._tag === "Done") return;
1408
1414
  const openState = self.state;
@@ -1410,15 +1416,15 @@ const finalize = (self, exit) => {
1410
1416
  _tag: "Done",
1411
1417
  exit
1412
1418
  };
1413
- for (const taker of openState.takers) taker(exit);
1419
+ for (const taker of openState.takers) taker.resume(exit);
1414
1420
  openState.takers.clear();
1415
1421
  for (const awaiter of openState.awaiters) awaiter(exit);
1416
1422
  openState.awaiters.clear();
1417
1423
  };
1418
1424
  //#endregion
1419
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Semaphore.js
1425
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Semaphore.js
1420
1426
  const makeUnsafe = (permits) => new SemaphoreImpl(permits);
1421
- const waitForPermits = (self, n, effect) => callback$1((resume) => {
1427
+ const waitForPermits = (self, n, effect) => callback$2((resume) => {
1422
1428
  if (self.free >= n) return resume(effect);
1423
1429
  const observer = () => {
1424
1430
  if (self.free < n) return;
@@ -1507,10 +1513,10 @@ var SemaphoreImpl = class {
1507
1513
  };
1508
1514
  const make = (permits) => sync$1(() => new SemaphoreImpl(permits));
1509
1515
  //#endregion
1510
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Take.js
1511
- const toPull = (take) => isExit(take) ? isSuccess(take) ? done(take.value) : take : succeed$2(take);
1516
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Take.js
1517
+ const toPull = (take) => isExit(take) ? isSuccess(take) ? done(take.value) : take : succeed$3(take);
1512
1518
  //#endregion
1513
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Channel.js
1519
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Channel.js
1514
1520
  const TypeId$2 = "~effect/Channel";
1515
1521
  const isChannel = (u) => hasProperty(u, TypeId$2);
1516
1522
  const ChannelProto = {
@@ -1527,7 +1533,7 @@ const ChannelProto = {
1527
1533
  };
1528
1534
  const fromTransform = (transform) => {
1529
1535
  const self = Object.create(ChannelProto);
1530
- self.transform = (upstream, scope) => catchCause$1(transform(upstream, scope), (cause) => succeed$2(failCause$3(cause)));
1536
+ self.transform = (upstream, scope) => catchCause$1(transform(upstream, scope), (cause) => succeed$3(failCause$3(cause)));
1531
1537
  return self;
1532
1538
  };
1533
1539
  const transformPull$1 = (self, f) => fromTransform((upstream, scope) => flatMap$2(toTransform(self)(upstream, scope), (pull) => f(pull, scope)));
@@ -1550,40 +1556,40 @@ const fromIteratorArray = (iterator, chunkSize = DefaultChunkSize) => {
1550
1556
  const size = normalizeNonEmpty(chunkSize);
1551
1557
  return fromPull$1(sync(() => {
1552
1558
  const iter = iterator();
1553
- let done$14 = none();
1559
+ let done$11 = none();
1554
1560
  return suspend$2(() => {
1555
- if (done$14._tag === "Some") return done(done$14.value);
1561
+ if (done$11._tag === "Some") return done(done$11.value);
1556
1562
  const buffer = [];
1557
1563
  while (buffer.length < size) {
1558
1564
  const state = iter.next();
1559
1565
  if (state.done) {
1560
1566
  if (buffer.length === 0) return done(state.value);
1561
- done$14 = some(state.value);
1567
+ done$11 = some(state.value);
1562
1568
  break;
1563
1569
  }
1564
1570
  buffer.push(state.value);
1565
1571
  }
1566
- return succeed$2(buffer);
1572
+ return succeed$3(buffer);
1567
1573
  });
1568
1574
  }));
1569
1575
  };
1570
1576
  const fromIterableArray = (iterable, chunkSize = DefaultChunkSize) => fromIteratorArray(() => iterable[Symbol.iterator](), chunkSize);
1571
- const succeed$1 = (value) => fromEffect$1(succeed$2(value));
1572
- const empty$1 = fromPull$1(succeed$2(done()));
1573
- const fail$1 = (error) => fromPull$1(succeed$2(fail$3(error)));
1577
+ const succeed$1 = (value) => fromEffect$1(succeed$3(value));
1578
+ const empty$1 = fromPull$1(succeed$3(done()));
1579
+ const fail$1 = (error) => fromPull$1(succeed$3(fail$3(error)));
1574
1580
  const failCause$1 = (cause) => fromPull$1(failCause$3(cause));
1575
1581
  const die$1 = (defect) => failCause$1(die$2(defect));
1576
1582
  const fromEffect$1 = (effect) => fromPull$1(sync(() => {
1577
- let done$15 = false;
1583
+ let done$14 = false;
1578
1584
  return suspend$2(() => {
1579
- if (done$15) return done();
1580
- done$15 = true;
1585
+ if (done$14) return done();
1586
+ done$14 = true;
1581
1587
  return effect;
1582
1588
  });
1583
1589
  }));
1584
- const fromEffectTake = (effect) => fromPull$1(succeed$2(flatMap$2(effect, toPull)));
1585
- const fromQueueArray = (queue) => fromPull$1(succeed$2(takeAll(queue)));
1586
- const fromSubscriptionArray = (subscription) => fromPull$1(succeed$2(onInterrupt(takeAll$1(subscription), () => done())));
1590
+ const fromEffectTake = (effect) => fromPull$1(succeed$3(flatMap$2(effect, toPull)));
1591
+ const fromQueueArray = (queue) => fromPull$1(succeed$3(takeAll(queue)));
1592
+ const fromSubscriptionArray = (subscription) => fromPull$1(succeed$3(onInterrupt(takeAll$1(subscription), () => done())));
1587
1593
  const fromPubSubArray = (pubsub) => unwrap$1(map$2(subscribe(pubsub), fromSubscriptionArray));
1588
1594
  const fromPubSubTake$1 = (pubsub) => unwrap$1(map$2(subscribe(pubsub), (sub) => fromEffectTake(take$2(sub))));
1589
1595
  const fromReadableStream$1 = (options) => fromTransform((_, scope) => readableStreamToPullUnsafe({
@@ -1602,9 +1608,9 @@ const readableStreamToPullUnsafe = (options) => {
1602
1608
  catch: options.onError
1603
1609
  }), {
1604
1610
  onFailure: (cause) => exit.current ?? failCause$3(cause),
1605
- onSuccess: ({ done: done$10, value }) => {
1611
+ onSuccess: ({ done: done$15, value }) => {
1606
1612
  if (exit.current) return exit.current;
1607
- return done$10 ? done() : succeed$2(of(value));
1613
+ return done$15 ? done() : succeed$3(of(value));
1608
1614
  }
1609
1615
  });
1610
1616
  });
@@ -1614,8 +1620,8 @@ const map$1 = dual(2, (self, f) => transformPull$1(self, (pull) => sync(() => {
1614
1620
  let i = 0;
1615
1621
  return map$2(pull, (o) => f(o, i++));
1616
1622
  })));
1617
- const mapDone = dual(2, (self, f) => mapDoneEffect(self, (o) => succeed$2(f(o))));
1618
- const mapDoneEffect = dual(2, (self, f) => transformPull$1(self, (pull) => succeed$2(catchDone(pull, (done$11) => flatMap$2(f(done$11), done)))));
1623
+ const mapDone = dual(2, (self, f) => mapDoneEffect(self, (o) => succeed$3(f(o))));
1624
+ const mapDoneEffect = dual(2, (self, f) => transformPull$1(self, (pull) => succeed$3(catchDone(pull, (done$16) => flatMap$2(f(done$16), done)))));
1619
1625
  const concurrencyIsSequential = (concurrency) => concurrency === void 0 || concurrency !== "unbounded" && concurrency <= 1;
1620
1626
  const mapEffect$1 = dual((args) => isChannel(args[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? mapEffectSequential(self, f) : mapEffectConcurrent(self, f, options));
1621
1627
  const mapEffectSequential = (self, f) => fromTransform((upstream, scope) => {
@@ -1638,7 +1644,8 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
1638
1644
  onSuccess: (value) => flatMap$2(offer(queue, value), release)
1639
1645
  });
1640
1646
  yield* semaphore.take(1).pipe(flatMap$2(() => pull), flatMap$2((value) => {
1641
- trackFiber(runFork(handle(f(value, i++))));
1647
+ const index = i++;
1648
+ trackFiber(runFork(handle(suspend$2(() => f(value, index)))));
1642
1649
  return void_;
1643
1650
  }), forever({ disableYield: true }), catchCause$1((cause) => semaphore.withPermits(concurrencyN - 1)(failCause$2(queue, cause))), forkIn(forkedScope));
1644
1651
  } else {
@@ -1653,7 +1660,8 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
1653
1660
  };
1654
1661
  yield* pull.pipe(flatMap$2((value) => {
1655
1662
  if (errorCause) return failCause$3(errorCause);
1656
- const fiber = runFork(f(value, i++));
1663
+ const index = i++;
1664
+ const fiber = runFork(suspend$2(() => f(value, index)));
1657
1665
  trackFiber(fiber);
1658
1666
  fiber.addObserver(onExit);
1659
1667
  return offer(effects, join(fiber));
@@ -1674,7 +1682,7 @@ const flatMapSequential = (self, f) => fromTransform((upstream, scope) => map$2(
1674
1682
  });
1675
1683
  const catchHalt = catchDone((_) => {
1676
1684
  childPull = void 0;
1677
- if (childScope.state._tag === "Open" && scopeFinalizerCountUnsafe(childScope) === 1) return makePull;
1685
+ if (childScope.state._tag === "Empty") return makePull;
1678
1686
  const close$2 = close(childScope, void_$2);
1679
1687
  childScope = void 0;
1680
1688
  return flatMap$2(close$2, () => makePull);
@@ -1689,10 +1697,10 @@ const flattenArray = (self) => transformPull$1(self, (pull) => {
1689
1697
  if (array === void 0) return flatMap$2(pull, (array_) => {
1690
1698
  switch (array_.length) {
1691
1699
  case 0: return loop();
1692
- case 1: return succeed$2(array_[0]);
1700
+ case 1: return succeed$3(array_[0]);
1693
1701
  default:
1694
1702
  array = array_;
1695
- return succeed$2(array_[index++]);
1703
+ return succeed$3(array_[index++]);
1696
1704
  }
1697
1705
  });
1698
1706
  const next = array[index++];
@@ -1700,22 +1708,22 @@ const flattenArray = (self) => transformPull$1(self, (pull) => {
1700
1708
  array = void 0;
1701
1709
  index = 0;
1702
1710
  }
1703
- return succeed$2(next);
1711
+ return succeed$3(next);
1704
1712
  });
1705
- return succeed$2(pump);
1713
+ return succeed$3(pump);
1706
1714
  });
1707
- const filterArray = dual(2, (self, predicate) => transformPull$1(self, (pull) => succeed$2(flatMap$2(pull, function loop(arr) {
1715
+ const filterArray = dual(2, (self, predicate) => transformPull$1(self, (pull) => succeed$3(flatMap$2(pull, function loop(arr) {
1708
1716
  const passes = [];
1709
1717
  for (let i = 0; i < arr.length; i++) if (predicate(arr[i])) passes.push(arr[i]);
1710
- return isReadonlyArrayNonEmpty(passes) ? succeed$2(passes) : flatMap$2(pull, loop);
1718
+ return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
1711
1719
  }))));
1712
- const filterMapArray = dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$2(flatMap$2(pull, function loop(arr) {
1720
+ const filterMapArray = dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$3(flatMap$2(pull, function loop(arr) {
1713
1721
  const passes = [];
1714
1722
  for (let i = 0; i < arr.length; i++) {
1715
1723
  const result = filter(arr[i]);
1716
1724
  if (isSuccess$1(result)) passes.push(result.success);
1717
1725
  }
1718
- return isReadonlyArrayNonEmpty(passes) ? succeed$2(passes) : flatMap$2(pull, loop);
1726
+ return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
1719
1727
  }))));
1720
1728
  const catchCause = dual(2, (self, f) => fromTransform((upstream, scope) => {
1721
1729
  let forkedScope = forkUnsafe(scope);
@@ -1783,7 +1791,7 @@ const mergeAll$1 = dual(2, (channels, { bufferSize = 16, concurrency, switch: sw
1783
1791
  }
1784
1792
  const fiber = yield* childPull.pipe(tap$1(() => yieldNow), flatMap$2((value) => offer(queue, value)), forever({ disableYield: true }), onError(fnUntraced(function* (cause) {
1785
1793
  const halt = filterDone(cause);
1786
- yield* exit(close(childScope, !isFailure(halt) ? succeed$3(halt.success.value) : failCause$4(halt.failure)));
1794
+ yield* exit(close(childScope, !isFailure(halt) ? succeed$2(halt.success.value) : failCause$4(halt.failure)));
1787
1795
  if (!fibers.has(fiber)) return;
1788
1796
  fibers.delete(fiber);
1789
1797
  if (semaphore) yield* semaphore.release(1);
@@ -1879,7 +1887,7 @@ const splitLines$1 = () => fromTransform((upstream, _scope) => sync(() => {
1879
1887
  const last = stringBuilder;
1880
1888
  stringBuilder = "";
1881
1889
  midCRLF = false;
1882
- return succeed$2([last]);
1890
+ return succeed$3([last]);
1883
1891
  }
1884
1892
  return done(leftover);
1885
1893
  }
@@ -1887,25 +1895,25 @@ const splitLines$1 = () => fromTransform((upstream, _scope) => sync(() => {
1887
1895
  });
1888
1896
  function loop(chunk) {
1889
1897
  const lines = splitLinesArray(chunk);
1890
- return lines !== null ? succeed$2(lines) : pullOrFlush;
1898
+ return lines !== null ? succeed$3(lines) : pullOrFlush;
1891
1899
  }
1892
1900
  return pullOrFlush;
1893
1901
  }));
1894
1902
  const pipeTo = dual(2, (self, that) => fromTransform((upstream, scope) => flatMap$2(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope))));
1895
1903
  const unwrap$1 = (channel) => fromTransform((upstream, scope) => {
1896
1904
  let pull;
1897
- return succeed$2(suspend$2(() => {
1905
+ return succeed$3(suspend$2(() => {
1898
1906
  if (pull) return pull;
1899
1907
  return channel.pipe(provide(scope), flatMap$2((channel) => toTransform(channel)(upstream, scope)), flatMap$2((pull_) => pull = pull_));
1900
1908
  }));
1901
1909
  });
1902
1910
  const onExit = dual(2, (self, finalizer) => fromTransformBracket((upstream, scope, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen(toTransform(self)(upstream, scope)))));
1903
- const onEnd$1 = dual(2, (self, onEnd) => transformPull$1(self, (pull) => succeed$2(catchDone(pull, (leftover) => flatMap$2(onEnd, () => done(leftover))))));
1911
+ const onEnd$1 = dual(2, (self, onEnd) => transformPull$1(self, (pull) => succeed$3(catchDone(pull, (leftover) => flatMap$2(onEnd, () => done(leftover))))));
1904
1912
  const ensuring$1 = dual(2, (self, finalizer) => onExit(self, (_) => finalizer));
1905
1913
  const runWith = (self, f, onHalt) => suspend$2(() => {
1906
1914
  const scope = makeUnsafe$2();
1907
1915
  const makePull = toTransform(self)(done(), scope);
1908
- return catchDone(flatMap$2(makePull, f), onHalt ? onHalt : succeed$2).pipe(onExit$1((exit) => close(scope, exit)));
1916
+ return catchDone(flatMap$2(makePull, f), onHalt ? onHalt : succeed$3).pipe(onExit$1((exit) => close(scope, exit)));
1909
1917
  });
1910
1918
  const provideContext$1 = dual(2, (self, context) => fromTransform((upstream, scope) => map$2(provideContext$2(toTransform(self)(upstream, scope), context), provideContext$2(context))));
1911
1919
  const provideService$1 = dual(3, (self, key, service) => fromTransform((upstream, scope) => map$2(provideService$2(toTransform(self)(upstream, scope), key, service), provideService$2(key, service))));
@@ -1919,18 +1927,18 @@ const runFold$1 = dual(3, (self, initial, f) => suspend$2(() => {
1919
1927
  step: (value) => {
1920
1928
  state = f(state, value);
1921
1929
  }
1922
- }), () => succeed$2(state));
1930
+ }), () => succeed$3(state));
1923
1931
  }));
1924
1932
  const toPullScoped = (self, scope) => toTransform(self)(done(), scope);
1925
1933
  const makePubSub = (options) => acquireRelease(options.capacity === "unbounded" ? unbounded$1(options) : options.strategy === "dropping" ? dropping(options) : options.strategy === "sliding" ? sliding(options) : bounded$1(options), shutdown$1);
1926
1934
  const runIntoPubSubArray = dual((args) => isChannel(args[0]), (self, pubsub, options) => runForEach$1(self, (value) => publishAll(pubsub, value)).pipe(options?.shutdownOnEnd === true ? ensuring$2(shutdown$1(pubsub)) : identity));
1927
1935
  const toPubSubTake$1 = dual(2, fnUntraced(function* (self, options) {
1928
1936
  const pubsub = yield* makePubSub(options);
1929
- yield* runForEach$1(self, (value) => publish(pubsub, value)).pipe(onExit$1((exit) => publish(pubsub, exit)), forkScoped);
1937
+ yield* runForEach$1(self, (value) => publish(pubsub, value)).pipe(onExit$1((exit) => end$1(pubsub, exit)), forkScoped);
1930
1938
  return pubsub;
1931
1939
  }));
1932
1940
  //#endregion
1933
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/internal/stream.js
1941
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/stream.js
1934
1942
  const TypeId$1 = "~effect/Stream";
1935
1943
  const streamVariance = {
1936
1944
  _R: identity,
@@ -1948,7 +1956,7 @@ Stream.prototype = {
1948
1956
  };
1949
1957
  const fromChannel$1 = (channel) => new Stream(channel);
1950
1958
  //#endregion
1951
- //#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect+effect@b3032f0_f95638f588f5b9b247401a051448b365/node_modules/effect/dist/Stream.js
1959
+ //#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Stream.js
1952
1960
  const TypeId = "~effect/Stream";
1953
1961
  const isStream = (u) => hasProperty(u, TypeId);
1954
1962
  const fromChannel = fromChannel$1;
@@ -2005,15 +2013,15 @@ const take = dual(2, (self, n) => {
2005
2013
  });
2006
2014
  const takeUntil = dual((args) => isStream(args[0]), (self, predicate, options) => transformPull(self, (pull, _scope) => sync(() => {
2007
2015
  let i = 0;
2008
- let done$4 = false;
2009
- return flatMap$2(suspend$2(() => done$4 ? done() : pull), (chunk) => {
2016
+ let done$7 = false;
2017
+ return flatMap$2(suspend$2(() => done$7 ? done() : pull), (chunk) => {
2010
2018
  const index = chunk.findIndex((a) => predicate(a, i++));
2011
2019
  if (index >= 0) {
2012
- done$4 = true;
2020
+ done$7 = true;
2013
2021
  const arr = chunk.slice(0, options?.excludeLast ? index : index + 1);
2014
- return isReadonlyArrayNonEmpty(arr) ? succeed$2(arr) : done();
2022
+ return isReadonlyArrayNonEmpty(arr) ? succeed$3(arr) : done();
2015
2023
  }
2016
- return succeed$2(chunk);
2024
+ return succeed$3(chunk);
2017
2025
  });
2018
2026
  })));
2019
2027
  const drop = dual(2, (self, n) => {
@@ -2022,33 +2030,33 @@ const drop = dual(2, (self, n) => {
2022
2030
  return transformPull(self, (pull, _scope) => sync(() => {
2023
2031
  let dropped = 0;
2024
2032
  const pump = pull.pipe(flatMap$2((chunk) => {
2025
- if (dropped >= count) return succeed$2(chunk);
2033
+ if (dropped >= count) return succeed$3(chunk);
2026
2034
  dropped += chunk.length;
2027
2035
  if (dropped <= count) return pump;
2028
- return succeed$2(chunk.slice(count - dropped));
2036
+ return succeed$3(chunk.slice(count - dropped));
2029
2037
  }));
2030
2038
  return pump;
2031
2039
  }));
2032
2040
  });
2033
2041
  const transduce = dual(2, (self, sink) => transformPull(self, (upstream, scope) => sync(() => {
2034
- let done$1;
2042
+ let done$5;
2035
2043
  let leftover;
2036
2044
  const upstreamWithLeftover = suspend$2(() => {
2037
2045
  if (leftover !== void 0) {
2038
2046
  const chunk = leftover;
2039
2047
  leftover = void 0;
2040
- return succeed$2(chunk);
2048
+ return succeed$3(chunk);
2041
2049
  }
2042
2050
  return upstream;
2043
2051
  }).pipe(catch_$2((error) => {
2044
- done$1 = fail$5(error);
2052
+ done$5 = fail$5(error);
2045
2053
  return done();
2046
2054
  }));
2047
2055
  const pull = map$2(suspend$2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => {
2048
2056
  leftover = leftover_;
2049
2057
  return of(value);
2050
2058
  });
2051
- return suspend$2(() => done$1 ? done$1 : pull);
2059
+ return suspend$2(() => done$5 ? done$5 : pull);
2052
2060
  })));
2053
2061
  const broadcast = dual(2, (self, options) => map$2(toPubSubTake(self, options), fromPubSubTake));
2054
2062
  const pipeThroughChannel = dual(2, (self, channel) => fromChannel(pipeTo(self.channel, channel)));
@@ -2084,6 +2092,6 @@ const mkString = (self) => runFold$1(self.channel, () => "", (acc, chunk) => acc
2084
2092
  const runIntoPubSub = dual((args) => isStream(args[0]), (self, pubsub, options) => runIntoPubSubArray(self.channel, pubsub, options));
2085
2093
  const toPubSubTake = dual(2, (self, options) => toPubSubTake$1(self.channel, options));
2086
2094
  //#endregion
2087
- export { tap as $, mapArrayEffect as A, getCurrent as At, provideService as B, round as Bt, fromPubSub as C, unbounded as Ct, isStream as D, update as Dt, fromReadableStream as E, set as Et, mkString as F, join as Ft, runForEach as G, runCollect as H, onEnd as I, runIn as It, splitLines as J, runForEachArray as K, orDie as L, camelToSnake as Lt, mapError as M, interruptAll as Mt, merge as N, interruptAllAs as Nt, map as O, makeUnsafe$1 as Ot, mergeAll as P, interruptAs as Pt, takeUntil as Q, pipeThroughChannel as R, toLowerCase as Rt, fromIterable as S, take$1 as St, fromQueue as T, make$4 as Tt, runDrain as U, run as V, normalizeNonEmpty as Vt, runFold as W, suspend as X, succeed as Y, take as Z, flattenIterable as _, offer as _t, catchTags as a, pipeTo as at, fromChannel as b, offerUnsafe as bt, die as c, make as ct, ensuring as d, end as dt, transduce as et, fail as f, endUnsafe as ft, flatMap as g, make$1 as gt, filterMap as h, failCauseUnsafe as ht, catchReason as i, mapDone as it, mapEffect as j, interrupt as jt, mapArray as k, await_ as kt, drop as l, makeUnsafe as lt, filter as m, failCause$2 as mt, callback as n, fromTransform as nt, catch_ as o, toTransform as ot, failCause as p, fail$2 as pt, runIntoPubSub as q, catchIf as r, map$1 as rt, decodeText as s, unwrap$1 as st, broadcast as t, unwrap as tt, empty as u, bounded as ut, fromArray as v, offerAll as vt, fromPull as w, unbounded$1 as wt, fromEffect as x, poll as xt, fromArrayEffect as y, offerAllUnsafe as yt, provideContext as z, parse as zt };
2095
+ export { tap as $, mapArrayEffect as A, await_ as At, provideService as B, parse as Bt, fromPubSub as C, take$1 as Ct, isStream as D, set as Dt, fromReadableStream as E, make$4 as Et, mkString as F, interruptAs as Ft, runForEach as G, runCollect as H, normalizeNonEmpty as Ht, onEnd as I, join as It, splitLines as J, runForEachArray as K, orDie as L, runIn as Lt, mapError as M, interrupt as Mt, merge as N, interruptAll as Nt, map as O, update as Ot, mergeAll as P, interruptAllAs as Pt, takeUntil as Q, pipeThroughChannel as R, camelToSnake as Rt, fromIterable as S, shutdownUnsafe as St, fromQueue as T, unbounded$1 as Tt, runDrain as U, run as V, round as Vt, runFold as W, suspend as X, succeed as Y, take as Z, flattenIterable as _, offer as _t, catchTags as a, pipeTo as at, fromChannel as b, offerUnsafe as bt, die as c, make as ct, ensuring as d, end as dt, transduce as et, fail as f, endUnsafe as ft, flatMap as g, make$1 as gt, filterMap as h, failCauseUnsafe as ht, catchReason as i, mapDone as it, mapEffect as j, getCurrent as jt, mapArray as k, makeUnsafe$1 as kt, drop as l, makeUnsafe as lt, filter as m, failCause$2 as mt, callback as n, fromTransform as nt, catch_ as o, toTransform as ot, failCause as p, fail$2 as pt, runIntoPubSub as q, catchIf as r, map$1 as rt, decodeText as s, unwrap$1 as st, broadcast as t, unwrap as tt, empty as u, bounded as ut, fromArray as v, offerAll as vt, fromPull as w, unbounded as wt, fromEffect as x, poll as xt, fromArrayEffect as y, offerAllUnsafe as yt, provideContext as z, toLowerCase as zt };
2088
2096
 
2089
- //# sourceMappingURL=Stream-CgH3SuLu.mjs.map
2097
+ //# sourceMappingURL=Stream-Cu6P7ZHo.mjs.map