lalph 0.3.46 → 0.3.48

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.
package/dist/cli.mjs CHANGED
@@ -5353,6 +5353,18 @@ const succeed$8 = succeed$9;
5353
5353
  */
5354
5354
  const fail$10 = fail$11;
5355
5355
  /**
5356
+ * A pre-built `Result<void>` holding `undefined` as its failure value.
5357
+ *
5358
+ * - Use when you need a `Result` that represents "failed with no meaningful value"
5359
+ * - Equivalent to `Result.fail(undefined)` but avoids an extra allocation
5360
+ *
5361
+ * @see {@link fail}
5362
+ *
5363
+ * @category Constructors
5364
+ * @since 4.0.0
5365
+ */
5366
+ const failVoid = /* @__PURE__ */ fail$10(void 0);
5367
+ /**
5356
5368
  * Checks whether a `Result` is a `Failure`.
5357
5369
  *
5358
5370
  * - Acts as a TypeScript type guard, narrowing to `Failure<A, E>`
@@ -13021,7 +13033,7 @@ const repeat$1 = /* @__PURE__ */ dual(2, (self, options) => {
13021
13033
  return repeatOrElse$1(self, typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options), fail$9);
13022
13034
  });
13023
13035
  /** @internal */
13024
- const retry$2 = /* @__PURE__ */ dual(2, (self, options) => {
13036
+ const retry$4 = /* @__PURE__ */ dual(2, (self, options) => {
13025
13037
  return retryOrElse$1(self, typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options), fail$9);
13026
13038
  });
13027
13039
  const passthroughForever = /* @__PURE__ */ passthrough$2(forever$1);
@@ -14800,7 +14812,7 @@ const tapCause = tapCause$1;
14800
14812
  * @since 2.0.0
14801
14813
  * @category Error Handling
14802
14814
  */
14803
- const retry$1 = retry$2;
14815
+ const retry$3 = retry$4;
14804
14816
  /**
14805
14817
  * Discards both the success and failure values of an effect.
14806
14818
  *
@@ -24046,6 +24058,90 @@ const set$9 = /* @__PURE__ */ dual(2, (self, value) => {
24046
24058
  self.current = value;
24047
24059
  return self;
24048
24060
  });
24061
+ /**
24062
+ * Sets the MutableRef to a new value and returns the new value.
24063
+ *
24064
+ * @example
24065
+ * ```ts
24066
+ * import { MutableRef } from "effect"
24067
+ *
24068
+ * const ref = MutableRef.make("old")
24069
+ *
24070
+ * // Set and get the new value
24071
+ * const newValue = MutableRef.setAndGet(ref, "new")
24072
+ * console.log(newValue) // "new"
24073
+ * console.log(MutableRef.get(ref)) // "new"
24074
+ *
24075
+ * // Useful for assignments that need the value
24076
+ * const counter = MutableRef.make(0)
24077
+ * const currentValue = MutableRef.setAndGet(counter, 42)
24078
+ * console.log(`Counter set to: ${currentValue}`) // "Counter set to: 42"
24079
+ *
24080
+ * // Pipe-able version
24081
+ * const setValue = MutableRef.setAndGet("final")
24082
+ * const result = setValue(ref)
24083
+ * console.log(result) // "final"
24084
+ *
24085
+ * // Difference from set: returns value instead of reference
24086
+ * const ref1 = MutableRef.make(1)
24087
+ * const returnedRef = MutableRef.set(ref1, 2) // Returns MutableRef
24088
+ * const returnedValue = MutableRef.setAndGet(ref1, 3) // Returns value
24089
+ * console.log(returnedValue) // 3
24090
+ * ```
24091
+ *
24092
+ * @since 2.0.0
24093
+ * @category general
24094
+ */
24095
+ const setAndGet = /* @__PURE__ */ dual(2, (self, value) => {
24096
+ self.current = value;
24097
+ return self.current;
24098
+ });
24099
+ /**
24100
+ * Updates the MutableRef with the result of applying a function to its current value,
24101
+ * and returns the new value.
24102
+ *
24103
+ * @example
24104
+ * ```ts
24105
+ * import { MutableRef } from "effect"
24106
+ *
24107
+ * const counter = MutableRef.make(5)
24108
+ *
24109
+ * // Increment and get the new value
24110
+ * const newValue = MutableRef.updateAndGet(counter, (n) => n + 1)
24111
+ * console.log(newValue) // 6
24112
+ * console.log(MutableRef.get(counter)) // 6
24113
+ *
24114
+ * // Double the value and get the result
24115
+ * const doubled = MutableRef.updateAndGet(counter, (n) => n * 2)
24116
+ * console.log(doubled) // 12
24117
+ *
24118
+ * // Transform string and get result
24119
+ * const message = MutableRef.make("hello")
24120
+ * const upperCase = MutableRef.updateAndGet(message, (s) => s.toUpperCase())
24121
+ * console.log(upperCase) // "HELLO"
24122
+ *
24123
+ * // Pipe-able version
24124
+ * const increment = MutableRef.updateAndGet((n: number) => n + 1)
24125
+ * const result = increment(counter)
24126
+ * console.log(result) // 13 (new value)
24127
+ *
24128
+ * // Useful for calculations that need the result
24129
+ * const score = MutableRef.make(100)
24130
+ * const bonus = 50
24131
+ * const newScore = MutableRef.updateAndGet(score, (s) => s + bonus)
24132
+ * console.log(`New score: ${newScore}`) // "New score: 150"
24133
+ *
24134
+ * // Array transformations
24135
+ * const list = MutableRef.make<Array<number>>([1, 2, 3])
24136
+ * const newList = MutableRef.updateAndGet(list, (arr) => arr.map((x) => x * 2))
24137
+ * console.log(newList) // [2, 4, 6]
24138
+ * console.log(MutableRef.get(list)) // [2, 4, 6]
24139
+ * ```
24140
+ *
24141
+ * @since 2.0.0
24142
+ * @category general
24143
+ */
24144
+ const updateAndGet = /* @__PURE__ */ dual(2, (self, f) => setAndGet(self, f(get$14(self))));
24049
24145
  //#endregion
24050
24146
  //#region node_modules/.pnpm/effect@4.0.0-beta.30/node_modules/effect/dist/PubSub.js
24051
24147
  /**
@@ -24356,6 +24452,50 @@ const publish = /* @__PURE__ */ dual(2, (self, value) => suspend$3(() => {
24356
24452
  return self.strategy.handleSurplus(self.pubsub, self.subscribers, [value], self.shutdownFlag);
24357
24453
  }));
24358
24454
  /**
24455
+ * Publishes all of the specified messages to the `PubSub`, returning whether they
24456
+ * were published to the `PubSub`.
24457
+ *
24458
+ * @example
24459
+ * ```ts
24460
+ * import { Effect } from "effect"
24461
+ * import * as PubSub from "effect/PubSub"
24462
+ *
24463
+ * const program = Effect.gen(function*() {
24464
+ * const pubsub = yield* PubSub.bounded<string>(10)
24465
+ *
24466
+ * // Publish multiple messages at once
24467
+ * const messages = ["Hello", "World", "from", "Effect"]
24468
+ * const allPublished = yield* PubSub.publishAll(pubsub, messages)
24469
+ * console.log("All messages published:", allPublished) // true
24470
+ *
24471
+ * // With a smaller capacity
24472
+ * const smallPubsub = yield* PubSub.bounded<string>(2)
24473
+ * const manyMessages = ["msg1", "msg2", "msg3", "msg4"]
24474
+ *
24475
+ * // Will suspend until space becomes available for all messages
24476
+ * const publishAllEffect = PubSub.publishAll(smallPubsub, manyMessages)
24477
+ *
24478
+ * // Subscribe to consume messages and free space
24479
+ * yield* Effect.scoped(Effect.gen(function*() {
24480
+ * const subscription = yield* PubSub.subscribe(smallPubsub)
24481
+ * yield* PubSub.takeAll(subscription) // consume all messages
24482
+ * const result = yield* publishAllEffect
24483
+ * console.log("All messages eventually published:", result)
24484
+ * }))
24485
+ * })
24486
+ * ```
24487
+ *
24488
+ * @since 2.0.0
24489
+ * @category publishing
24490
+ */
24491
+ const publishAll = /* @__PURE__ */ dual(2, (self, elements) => suspend$3(() => {
24492
+ if (self.shutdownFlag.current) return interrupt$1;
24493
+ const surplus = self.pubsub.publishAll(elements);
24494
+ self.strategy.completeSubscribersUnsafe(self.pubsub, self.subscribers);
24495
+ if (surplus.length === 0) return succeed$3(true);
24496
+ return self.strategy.handleSurplus(self.pubsub, self.subscribers, surplus, self.shutdownFlag);
24497
+ }));
24498
+ /**
24359
24499
  * Subscribes to receive messages from the `PubSub`. The resulting subscription can
24360
24500
  * be evaluated multiple times within the scope to take a message from the `PubSub`
24361
24501
  * each time.
@@ -27684,6 +27824,18 @@ const filterArray = /* @__PURE__ */ dual(2, (self, predicate) => transformPull$1
27684
27824
  * @since 4.0.0
27685
27825
  * @category Filtering
27686
27826
  */
27827
+ const filterMapArray = /* @__PURE__ */ dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$3(flatMap$4(pull, function loop(arr) {
27828
+ const passes = [];
27829
+ for (let i = 0; i < arr.length; i++) {
27830
+ const result = filter(arr[i]);
27831
+ if (isSuccess$5(result)) passes.push(result.success);
27832
+ }
27833
+ return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$4(pull, loop);
27834
+ }))));
27835
+ /**
27836
+ * @since 4.0.0
27837
+ * @category Filtering
27838
+ */
27687
27839
  const filterMapArrayEffect = /* @__PURE__ */ dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$3(flatMap$4(pull, function loop(arr) {
27688
27840
  return flatMap$4(filterMapEffect$1(arr, filter), (passes) => isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$4(pull, loop));
27689
27841
  }))));
@@ -27796,6 +27948,63 @@ const mapError$1 = /* @__PURE__ */ dual(2, (self, f) => catch_$1(self, (err) =>
27796
27948
  */
27797
27949
  const orDie$1 = (self) => catch_$1(self, die$1);
27798
27950
  /**
27951
+ * Returns a new channel that retries this channel according to the specified
27952
+ * schedule whenever it fails.
27953
+ *
27954
+ * @since 4.0.0
27955
+ * @category utils
27956
+ */
27957
+ const retry$2 = /* @__PURE__ */ dual(2, (self, schedule) => suspend$2(() => {
27958
+ let step = void 0;
27959
+ let meta = CurrentMetadata.defaultValue();
27960
+ const withReset = onFirst(provideServiceEffect(self, CurrentMetadata, sync(() => meta)), () => {
27961
+ step = void 0;
27962
+ return void_$1;
27963
+ });
27964
+ const resolvedSchedule = typeof schedule === "function" ? schedule(identity) : schedule;
27965
+ const loop = catch_$1(withReset, fnUntraced(function* (error) {
27966
+ if (!step) step = yield* toStepWithMetadata(resolvedSchedule);
27967
+ meta = yield* step(error);
27968
+ return loop;
27969
+ }, (effect, error) => catchDone(effect, () => succeed$3(fail$3(error))), unwrap$2));
27970
+ return loop;
27971
+ }));
27972
+ /**
27973
+ * Returns a new channel, which sequentially combines this channel, together
27974
+ * with the provided factory function, which creates a second channel based on
27975
+ * the output values of this channel. The result is a channel that will first
27976
+ * perform the functions of this channel, before performing the functions of
27977
+ * the created channel (including yielding its terminal value).
27978
+ *
27979
+ * @example
27980
+ * ```ts
27981
+ * import { Channel, Data } from "effect"
27982
+ *
27983
+ * class SwitchError extends Data.TaggedError("SwitchError")<{
27984
+ * readonly reason: string
27985
+ * }> {}
27986
+ *
27987
+ * // Create a channel that outputs numbers
27988
+ * const numberChannel = Channel.fromIterable([1, 2, 3])
27989
+ *
27990
+ * // Switch to new channels based on each value
27991
+ * const switchedChannel = Channel.switchMap(
27992
+ * numberChannel,
27993
+ * (n) => Channel.fromIterable([`value-${n}`])
27994
+ * )
27995
+ *
27996
+ * // Outputs: "value-1", "value-2", "value-3"
27997
+ * ```
27998
+ *
27999
+ * @since 2.0.0
28000
+ * @category sequencing
28001
+ */
28002
+ const switchMap$1 = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => self.pipe(map$7(f), mergeAll$1({
28003
+ ...options,
28004
+ concurrency: options?.concurrency ?? 1,
28005
+ switch: true
28006
+ })));
28007
+ /**
27799
28008
  * Merges multiple channels with specified concurrency and buffering options.
27800
28009
  *
27801
28010
  * @example
@@ -28066,6 +28275,18 @@ const onExit = /* @__PURE__ */ dual(2, (self, finalizer) => fromTransformBracket
28066
28275
  * @since 4.0.0
28067
28276
  * @category utils
28068
28277
  */
28278
+ const onFirst = /* @__PURE__ */ dual(2, (self, onFirst) => transformPull$1(self, (pull) => sync(() => {
28279
+ let isFirst = true;
28280
+ const pullFirst = tap$1(pull, (element) => {
28281
+ isFirst = false;
28282
+ return onFirst(element);
28283
+ });
28284
+ return suspend$3(() => isFirst ? pullFirst : pull);
28285
+ })));
28286
+ /**
28287
+ * @since 4.0.0
28288
+ * @category utils
28289
+ */
28069
28290
  const onEnd$1 = /* @__PURE__ */ dual(2, (self, onEnd) => transformPull$1(self, (pull) => succeed$3(catchDone(pull, (leftover) => flatMap$4(onEnd, () => done(leftover))))));
28070
28291
  /**
28071
28292
  * Returns a new channel with an attached finalizer. The finalizer is
@@ -28104,6 +28325,11 @@ const runWith$1 = (self, f, onHalt) => suspend$3(() => {
28104
28325
  */
28105
28326
  const provideService$1 = /* @__PURE__ */ dual(3, (self, key, service) => fromTransform$1((upstream, scope) => map$8(provideService$2(toTransform(self)(upstream, scope), key, service), provideService$2(key, service))));
28106
28327
  /**
28328
+ * @since 4.0.0
28329
+ * @category Services
28330
+ */
28331
+ const provideServiceEffect = /* @__PURE__ */ dual(3, (self, key, service) => fromTransform$1((upstream, scope) => flatMap$4(service, (s) => toTransform(provideService$1(self, key, s))(upstream, scope))));
28332
+ /**
28107
28333
  * Runs a channel and discards all output elements, returning only the final result.
28108
28334
  *
28109
28335
  * @example
@@ -28261,6 +28487,11 @@ const toPull$1 = /* @__PURE__ */ fnUntraced(function* (self) {
28261
28487
  const toPullScoped = (self, scope) => toTransform(self)(done(), scope);
28262
28488
  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);
28263
28489
  /**
28490
+ * @since 4.0.0
28491
+ * @category Destructors
28492
+ */
28493
+ const runIntoPubSubArray = /* @__PURE__ */ 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));
28494
+ /**
28264
28495
  * Converts a channel to a PubSub for concurrent consumption.
28265
28496
  *
28266
28497
  * @since 4.0.0
@@ -28731,9 +28962,9 @@ const getState = (self) => uninterruptibleMask((restore) => {
28731
28962
  const get$11 = /* @__PURE__ */ fnUntraced(function* (self_) {
28732
28963
  const self = self_;
28733
28964
  const state = yield* getState(self);
28734
- const scope$7 = yield* scope;
28965
+ const scope$8 = yield* scope;
28735
28966
  const isFinite = self.idleTimeToLive !== void 0 && isFinite$2(self.idleTimeToLive);
28736
- yield* addFinalizerExit(scope$7, () => {
28967
+ yield* addFinalizerExit(scope$8, () => {
28737
28968
  state.refCount--;
28738
28969
  if (state.refCount > 0) return void_$1;
28739
28970
  if (self.idleTimeToLive === void 0) {
@@ -29581,6 +29812,30 @@ const tap = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options)
29581
29812
  */
29582
29813
  const flatMap$2 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, flatMap$3((a) => f(a).channel, options), fromChannel));
29583
29814
  /**
29815
+ * Switches to the latest stream produced by the mapping function, interrupting
29816
+ * the previous stream when a new element arrives.
29817
+ *
29818
+ * @example
29819
+ * ```ts
29820
+ * import { Console, Effect, Stream } from "effect"
29821
+ *
29822
+ * const program = Stream.make(1, 2, 3).pipe(
29823
+ * Stream.switchMap((n) => (n === 3 ? Stream.make(n) : Stream.never)),
29824
+ * Stream.runCollect
29825
+ * )
29826
+ *
29827
+ * Effect.gen(function*() {
29828
+ * const result = yield* program
29829
+ * yield* Console.log(result)
29830
+ * // Output: [ 3 ]
29831
+ * })
29832
+ * ```
29833
+ *
29834
+ * @since 4.0.0
29835
+ * @category Sequencing
29836
+ */
29837
+ const switchMap = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, switchMap$1((a) => f(a).channel, options), fromChannel));
29838
+ /**
29584
29839
  * Flattens a stream of streams into a single stream by concatenating the
29585
29840
  * inner streams in strict order.
29586
29841
  *
@@ -29764,6 +30019,13 @@ const mergeAll = /* @__PURE__ */ dual(2, (streams, options) => flatten(fromItera
29764
30019
  */
29765
30020
  const filter$3 = /* @__PURE__ */ dual(2, (self, predicate) => fromChannel(filterArray(toChannel(self), predicate)));
29766
30021
  /**
30022
+ * Filters and maps stream elements in one pass using a `Filter`.
30023
+ *
30024
+ * @since 4.0.0
30025
+ * @category Filtering
30026
+ */
30027
+ const filterMap$2 = /* @__PURE__ */ dual(2, (self, filter) => fromChannel(filterMapArray(toChannel(self), filter)));
30028
+ /**
29767
30029
  * Effectfully filters and maps elements in a single pass.
29768
30030
  *
29769
30031
  * @since 4.0.0
@@ -29945,6 +30207,38 @@ const mapError = /* @__PURE__ */ dual(2, (self, f) => fromChannel(mapError$1(sel
29945
30207
  */
29946
30208
  const orDie = (self) => fromChannel(orDie$1(self.channel));
29947
30209
  /**
30210
+ * When the stream fails, retry it according to the given schedule.
30211
+ *
30212
+ * This retries the entire stream, so will re-execute all of the stream's
30213
+ * acquire operations.
30214
+ *
30215
+ * The schedule is reset as soon as the first element passes through the
30216
+ * stream again.
30217
+ *
30218
+ * @example
30219
+ * ```ts
30220
+ * import { Console, Effect, Schedule, Stream } from "effect"
30221
+ *
30222
+ * const program = Effect.gen(function*() {
30223
+ * const values = yield* Stream.make(1).pipe(
30224
+ * Stream.concat(Stream.fail("boom")),
30225
+ * Stream.retry(Schedule.recurs(1)),
30226
+ * Stream.take(2),
30227
+ * Stream.runCollect
30228
+ * )
30229
+ *
30230
+ * yield* Console.log(values)
30231
+ * })
30232
+ *
30233
+ * Effect.runPromise(program)
30234
+ * // Output: [ 1, 1 ]
30235
+ * ```
30236
+ *
30237
+ * @since 2.0.0
30238
+ * @category Error Handling
30239
+ */
30240
+ const retry$1 = /* @__PURE__ */ dual(2, (self, policy) => fromChannel(retry$2(self.channel, policy)));
30241
+ /**
29948
30242
  * Takes the first `n` elements from this stream, returning `Stream.empty` when `n < 1`.
29949
30243
  *
29950
30244
  * @example
@@ -30685,6 +30979,38 @@ const toReadableStreamWith = /* @__PURE__ */ dual((args) => isStream(args[0]), (
30685
30979
  */
30686
30980
  const toReadableStreamEffect = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => map$8(services(), (context) => toReadableStreamWith(self, context, options)));
30687
30981
  /**
30982
+ * Runs the stream, publishing elements into the provided PubSub.
30983
+ *
30984
+ * `shutdownOnEnd` controls whether the PubSub is shut down when the stream ends.
30985
+ * It only shuts down when set to `true`.
30986
+ *
30987
+ * @example
30988
+ * ```ts
30989
+ * import { Console, Effect, PubSub, Stream } from "effect"
30990
+ *
30991
+ * const program = Effect.scoped(Effect.gen(function* () {
30992
+ * const pubsub = yield* PubSub.unbounded<number>()
30993
+ * const subscription = yield* PubSub.subscribe(pubsub)
30994
+ *
30995
+ * yield* Stream.runIntoPubSub(Stream.fromIterable([1, 2]), pubsub)
30996
+ *
30997
+ * const first = yield* PubSub.take(subscription)
30998
+ * const second = yield* PubSub.take(subscription)
30999
+ *
31000
+ * yield* Console.log(first)
31001
+ * yield* Console.log(second)
31002
+ * }))
31003
+ *
31004
+ * Effect.runPromise(program)
31005
+ * //=> 1
31006
+ * //=> 2
31007
+ * ```
31008
+ *
31009
+ * @since 2.0.0
31010
+ * @category Destructors
31011
+ */
31012
+ const runIntoPubSub = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, pubsub, options) => runIntoPubSubArray(self.channel, pubsub, options));
31013
+ /**
30688
31014
  * Converts a stream to a PubSub for concurrent consumption.
30689
31015
  *
30690
31016
  * `Take` values include the stream's end and failure signals.
@@ -52727,6 +53053,32 @@ const randomWith = (f) => withFiber((fiber) => succeed$3(f(fiber.getRef(Random))
52727
53053
  * @category Random Number Generators
52728
53054
  */
52729
53055
  const next = /* @__PURE__ */ randomWith((r) => r.nextDoubleUnsafe());
53056
+ /**
53057
+ * Uses the pseudo-random number generator to shuffle the specified iterable.
53058
+ *
53059
+ * @example
53060
+ * ```ts
53061
+ * import { Effect, Random } from "effect"
53062
+ *
53063
+ * const program = Effect.gen(function*() {
53064
+ * const values = yield* Random.shuffle([1, 2, 3, 4, 5])
53065
+ * console.log(values)
53066
+ * })
53067
+ * ```
53068
+ *
53069
+ * @since 4.0.0
53070
+ * @category Random Number Generators
53071
+ */
53072
+ const shuffle = (elements) => randomWith((r) => {
53073
+ const buffer = Array.from(elements);
53074
+ for (let i = buffer.length - 1; i >= 1; i = i - 1) {
53075
+ const index = Math.min(i, Math.floor(r.nextDoubleUnsafe() * (i + 1)));
53076
+ const value = buffer[i];
53077
+ buffer[i] = buffer[index];
53078
+ buffer[index] = value;
53079
+ }
53080
+ return buffer;
53081
+ });
52730
53082
  //#endregion
52731
53083
  //#region node_modules/.pnpm/effect@4.0.0-beta.30/node_modules/effect/dist/Ref.js
52732
53084
  const RefProto = {
@@ -53135,7 +53487,7 @@ var BackingPersistence = class extends Service$1()("effect/persistence/BackingPe
53135
53487
  */
53136
53488
  const layer$21 = /* @__PURE__ */ effect$1(Persistence)(/* @__PURE__ */ gen(function* () {
53137
53489
  const backing = yield* BackingPersistence;
53138
- const scope$5 = yield* scope;
53490
+ const scope$6 = yield* scope;
53139
53491
  return Persistence.of({ make: fnUntraced(function* (options) {
53140
53492
  const storage = yield* backing.make(options.storeId);
53141
53493
  const timeToLive = options.timeToLive ?? (() => infinity);
@@ -53170,7 +53522,7 @@ const layer$21 = /* @__PURE__ */ effect$1(Persistence)(/* @__PURE__ */ gen(funct
53170
53522
  }
53171
53523
  out[i] = exit$3.value;
53172
53524
  }
53173
- if (toRemove) for (let i = 0; i < toRemove.length; i++) yield* forkIn(storage.remove(toRemove[i]), scope$5);
53525
+ if (toRemove) for (let i = 0; i < toRemove.length; i++) yield* forkIn(storage.remove(toRemove[i]), scope$6);
53174
53526
  return out;
53175
53527
  }),
53176
53528
  set(key, value) {
@@ -57286,7 +57638,7 @@ const retryTransient = /* @__PURE__ */ dual(2, (self, options) => {
57286
57638
  schedule: passthroughSchedule,
57287
57639
  times,
57288
57640
  while: isTransientResponse
57289
- }), retryOn === "response-only" ? identity : retry$1({
57641
+ }), retryOn === "response-only" ? identity : retry$3({
57290
57642
  while: isOnlySchedule || options.while === void 0 ? isTransientError : or(isTransientError, options.while),
57291
57643
  schedule,
57292
57644
  times
@@ -85252,9 +85604,9 @@ const layer$6 = /* @__PURE__ */ provideMerge(layer$20, /* @__PURE__ */ mergeAll$
85252
85604
  * @category constructors
85253
85605
  */
85254
85606
  const make$15 = /* @__PURE__ */ fnUntraced(function* (evaluate, options) {
85255
- const scope$3 = yield* scope;
85607
+ const scope$4 = yield* scope;
85256
85608
  const server = evaluate();
85257
- yield* addFinalizer$1(scope$3, callback$1((resume) => {
85609
+ yield* addFinalizer$1(scope$4, callback$1((resume) => {
85258
85610
  if (!server.listening) return resume(void_$1);
85259
85611
  server.close((error) => {
85260
85612
  if (error) resume(die$2(error));
@@ -85274,7 +85626,7 @@ const make$15 = /* @__PURE__ */ fnUntraced(function* (evaluate, options) {
85274
85626
  const address = server.address();
85275
85627
  const wss = yield* acquireRelease(sync(() => new import_websocket_server.default({ noServer: true })), (wss) => callback$1((resume) => {
85276
85628
  wss.close(() => resume(void_$1));
85277
- })).pipe(provide$4(scope$3), cached);
85629
+ })).pipe(provide$4(scope$4), cached);
85278
85630
  return make$21({
85279
85631
  address: typeof address === "string" ? {
85280
85632
  _tag: "UnixAddress",
@@ -85285,14 +85637,14 @@ const make$15 = /* @__PURE__ */ fnUntraced(function* (evaluate, options) {
85285
85637
  port: address.port
85286
85638
  },
85287
85639
  serve: fnUntraced(function* (httpApp, middleware) {
85288
- const scope$4 = yield* scope;
85640
+ const scope$5 = yield* scope;
85289
85641
  const handler = yield* makeHandler(httpApp, {
85290
85642
  middleware,
85291
- scope: scope$4
85643
+ scope: scope$5
85292
85644
  });
85293
85645
  const upgradeHandler = yield* makeUpgradeHandler(wss, httpApp, {
85294
85646
  middleware,
85295
- scope: scope$4
85647
+ scope: scope$5
85296
85648
  });
85297
85649
  yield* addFinalizer(() => sync(() => {
85298
85650
  server.off("request", handler);
@@ -86144,12 +86496,12 @@ const AtomRegistry = /* @__PURE__ */ Service$1(TypeId$6);
86144
86496
  * @category Layers
86145
86497
  */
86146
86498
  const layerOptions = (options) => effect$1(AtomRegistry, gen(function* () {
86147
- const scope$2 = yield* scope;
86499
+ const scope$3 = yield* scope;
86148
86500
  const registry = make$13({
86149
86501
  ...options,
86150
86502
  scheduleTask: options?.scheduleTask
86151
86503
  });
86152
- yield* addFinalizer$1(scope$2, sync(() => registry.dispose()));
86504
+ yield* addFinalizer$1(scope$3, sync(() => registry.dispose()));
86153
86505
  return registry;
86154
86506
  }));
86155
86507
  /**
@@ -87378,6 +87730,15 @@ var PrdIssue = class PrdIssue extends Class$1("PrdIssue")({
87378
87730
  autoMerge
87379
87731
  });
87380
87732
  }
87733
+ update(options) {
87734
+ return new PrdIssue({
87735
+ ...this,
87736
+ title: options.title ?? this.title,
87737
+ description: options.description ?? this.description,
87738
+ state: options.state ?? this.state,
87739
+ blockedBy: options.blockedBy ?? this.blockedBy
87740
+ });
87741
+ }
87381
87742
  };
87382
87743
  //#endregion
87383
87744
  //#region node_modules/.pnpm/@linear+sdk@77.0.0_graphql@16.12.0/node_modules/@linear/sdk/dist/chunk-DPPnyiuk.mjs
@@ -179923,7 +180284,7 @@ var CurrentIssueSource = class CurrentIssueSource extends Service$1()("lalph/Cur
179923
180284
  const services$8 = yield* services();
179924
180285
  const refresh = set$4(ref, build$1).pipe(provideServices(services$8));
179925
180286
  const proxy = IssueSource.of({
179926
- issues: (projectId) => get$6(ref).pipe(flatMap$4((source) => source.issues(projectId)), tapErrorTag("IssueSourceError", (e) => logWarning("Rebuilding issue source due to error", fail$7(e)).pipe(andThen(ignore$1(refresh)))), retry$1(refreshSchedule)),
180287
+ issues: (projectId) => get$6(ref).pipe(flatMap$4((source) => source.issues(projectId)), tapErrorTag("IssueSourceError", (e) => logWarning("Rebuilding issue source due to error", fail$7(e)).pipe(andThen(ignore$1(refresh)))), retry$3(refreshSchedule)),
179927
180288
  createIssue: (projectId, options) => get$6(ref).pipe(flatMap$4((source) => source.createIssue(projectId, options))),
179928
180289
  updateIssue: (options) => get$6(ref).pipe(flatMap$4((source) => source.updateIssue(options))),
179929
180290
  cancelIssue: (projectId, issueId) => get$6(ref).pipe(flatMap$4((source) => source.cancelIssue(projectId, issueId))),
@@ -180032,12 +180393,11 @@ The following instructions should be done without interaction or asking for perm
180032
180393
  Set \`githubPrNumber\` to the PR number if one exists, otherwise use \`null\`.
180033
180394
  ` : "\n\nLeave `githubPrNumber` as null."}
180034
180395
  `;
180035
- const promptChooseClanka = (options) => `Your job is to choose the next task to work on using "listEligibleTasks".
180036
- **DO NOT** implement the task yet.
180037
-
180038
- The following instructions should be done without interaction or asking for permission.
180039
-
180040
- - Decide which single task to work on next from "listEligibleTasks". This should
180396
+ const promptChooseClanka = (options) => `- Use the "listEligibleTasks" function to view the list of tasks that you can start working on.
180397
+ - **NO NOT PARSE THE yaml OUTPUT IN ANY WAY**
180398
+ - **DO NOT** implement the task yet.
180399
+ - **DO NOT** use the "delegate" function for any step in this workflow
180400
+ - After reading through the list of tasks, choose the task to work on. This should
180041
180401
  be the task YOU decide as the most important to work on next, not just the
180042
180402
  first task in the list.${options.gitFlow.requiresGithubPr ? `
180043
180403
  - Check if there is an open Github PR for the chosen task. If there is, note the PR number for inclusion when calling "chooseTask".
@@ -180775,7 +181135,7 @@ var Prd = class extends Service$1()("lalph/Prd", { make: gen(function* () {
180775
181135
  if (currentYaml === nextYaml) return;
180776
181136
  yield* fs.writeFileString(prdFile, nextYaml);
180777
181137
  }, scoped$1, withSpan("Prd.updateSync"), run$3(updateSyncHandle, { onlyIfMissing: true }), syncSemaphore.withPermitsIfAvailable(1));
180778
- yield* fs.watch(lalphDir).pipe(debounce(50), runForEach((_) => clear(updateSyncHandle).pipe(andThen(ignore$1(sync$2)))), retry$1(forever$1), forkScoped);
181138
+ yield* fs.watch(lalphDir).pipe(debounce(50), runForEach((_) => clear(updateSyncHandle).pipe(andThen(ignore$1(sync$2)))), retry$3(forever$1), forkScoped);
180779
181139
  yield* toStreamResult(registry, currentIssuesAtom(projectId)).pipe(runForEach(updateSync), forkScoped);
180780
181140
  const findById = fnUntraced(function* (issueId) {
180781
181141
  return (yield* getCurrentIssues).find((i) => i.id === issueId) ?? null;
@@ -187991,7 +188351,7 @@ var ji = Bt, Ii = Object.assign(Qe, { sync: Bt }), zi = Ut, Bi = Object.assign(e
187991
188351
  });
187992
188352
  Ze.glob = Ze;
187993
188353
  //#endregion
187994
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/ApplyPatch.js
188354
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/ApplyPatch.js
187995
188355
  /**
187996
188356
  * @since 1.0.0
187997
188357
  */
@@ -188320,7 +188680,7 @@ const patchChunks = (file, input, chunks) => {
188320
188680
  return eol === "\r\n" ? text.replace(/\n/g, "\r\n") : text;
188321
188681
  };
188322
188682
  //#endregion
188323
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/AgentTools.js
188683
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/AgentTools.js
188324
188684
  /**
188325
188685
  * @since 1.0.0
188326
188686
  */
@@ -188616,7 +188976,7 @@ const AgentToolHandlers = AgentTools.toLayer(gen(function* () {
188616
188976
  }));
188617
188977
  var ApplyPatchError = class extends TaggedClass$1("ApplyPatchError") {};
188618
188978
  //#endregion
188619
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/Executor.js
188979
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/Executor.js
188620
188980
  /**
188621
188981
  * @since 1.0.0
188622
188982
  */
@@ -188696,7 +189056,7 @@ var QueueWriteStream = class extends Writable {
188696
189056
  }
188697
189057
  };
188698
189058
  //#endregion
188699
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/TypeBuilder.js
189059
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/TypeBuilder.js
188700
189060
  const resolveDocumentation = resolveAt("documentation");
188701
189061
  const identifierPattern = /^[$A-Z_a-z][$0-9A-Z_a-z]*$/u;
188702
189062
  const Precedence = {
@@ -188969,7 +189329,7 @@ const render = (schema, options) => {
188969
189329
  return printNode({ text: documentation === void 0 ? rendered.text : `${renderJsDoc(documentation, 0, printerOptions)}${printerOptions.newLine}${rendered.text}` }, printerOptions);
188970
189330
  };
188971
189331
  //#endregion
188972
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/ToolkitRenderer.js
189332
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/ToolkitRenderer.js
188973
189333
  /**
188974
189334
  * @since 1.0.0
188975
189335
  */
@@ -188991,7 +189351,7 @@ declare function ${name}(${params}): Promise<${render(tool.successSchema)}>`);
188991
189351
  }) });
188992
189352
  };
188993
189353
  //#endregion
188994
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/Agent.js
189354
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/Agent.js
188995
189355
  /**
188996
189356
  * @since 1.0.0
188997
189357
  */
@@ -189046,7 +189406,8 @@ ${content}
189046
189406
  for (const [id, state] of outputBuffer) {
189047
189407
  outputBuffer.delete(id);
189048
189408
  offerAllUnsafe(output, state);
189049
- if (state[state.length - 1]._tag === "ReasoningDelta") {
189409
+ const lastPart = state[state.length - 1];
189410
+ if (lastPart._tag === "ScriptDelta" || lastPart._tag === "ReasoningDelta") {
189050
189411
  currentOutputAgent = id;
189051
189412
  break;
189052
189413
  }
@@ -189231,7 +189592,7 @@ ${prompt}`));
189231
189592
  case "finish": break;
189232
189593
  }
189233
189594
  return void_$1;
189234
- }), retry$1({ while: (err) => {
189595
+ }), retry$3({ while: (err) => {
189235
189596
  response = [];
189236
189597
  return err.isRetryable;
189237
189598
  } }), modelConfig.systemPromptTransform ? (effect) => modelConfig.systemPromptTransform(system, effect) : identity);
@@ -189301,11 +189662,11 @@ Javascript output:
189301
189662
  \`\`\``;
189302
189663
  };
189303
189664
  const generateSystemMulti = (toolsDts) => {
189304
- return `From now on only respond with plain javascript code which will be executed for you.
189665
+ return `You complete your tasks by **only writing javascript code** to interact with your environment.
189305
189666
 
189306
189667
  - Use \`console.log\` to print any output you need.
189307
189668
  - Top level await is supported.
189308
- - **Prefer using the functions provided** over the bash tool
189669
+ - AVOID passing scripts into the "bash" function, and instead write javascript.
189309
189670
 
189310
189671
  **When you have fully completed your task**, call the "taskComplete" function with the final output.
189311
189672
  Make sure every detail of the task is done before calling "taskComplete".
@@ -189323,7 +189684,7 @@ const generateSystemSingle = (toolsDts) => {
189323
189684
 
189324
189685
  - Use \`console.log\` to print any output you need.
189325
189686
  - Top level await is supported.
189326
- - **Prefer using the functions provided** over the bash tool
189687
+ - AVOID passing scripts into the "bash" function, and instead write javascript.
189327
189688
 
189328
189689
  You have the following functions available to you:
189329
189690
 
@@ -199759,7 +200120,7 @@ const transformToolCallParams = /* @__PURE__ */ fnUntraced(function* (tools, too
199759
200120
  })));
199760
200121
  });
199761
200122
  //#endregion
199762
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/CodexAuth.js
200123
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/CodexAuth.js
199763
200124
  /**
199764
200125
  * @since 1.0.0
199765
200126
  */
@@ -199937,7 +200298,7 @@ var CodexAuth = class CodexAuth extends Service$1()("clanka/CodexAuth") {
199937
200298
  user_code: deviceCode.userCode
199938
200299
  }));
199939
200300
  const delayMs = deviceCode.intervalMs + POLLING_SAFETY_MARGIN_MS;
199940
- return yield* httpClient.execute(request).pipe(retry$1({
200301
+ return yield* httpClient.execute(request).pipe(retry$3({
199941
200302
  while: (e) => e.response?.status === 403 || e.response?.status === 404,
199942
200303
  schedule: spaced(delayMs)
199943
200304
  }), mapError$2((cause) => requestDeviceCodeError("Failed to poll Codex device authorization", cause)), flatMap$4((response) => schemaBodyJson(AuthorizationCodeResponseSchema)(response).pipe(mapError$2((cause) => requestDeviceCodeError("Failed to decode the Codex authorization approval response", cause)), map$8((payload) => ({
@@ -199979,7 +200340,7 @@ var CodexAuth = class CodexAuth extends Service$1()("clanka/CodexAuth") {
199979
200340
  static layerClient = this.layerClientNoDeps.pipe(provide$3(CodexAuth.layer));
199980
200341
  };
199981
200342
  //#endregion
199982
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/Codex.js
200343
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/Codex.js
199983
200344
  /**
199984
200345
  * @since 1.0.0
199985
200346
  */
@@ -201294,7 +201655,7 @@ const getUsageDetailNumber = (details, field) => {
201294
201655
  return typeof value === "number" ? value : void 0;
201295
201656
  };
201296
201657
  //#endregion
201297
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/CopilotAuth.js
201658
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/CopilotAuth.js
201298
201659
  /**
201299
201660
  * @since 1.0.0
201300
201661
  */
@@ -201485,7 +201846,7 @@ var GithubCopilotAuth = class GithubCopilotAuth extends Service$1()("clanka/Gith
201485
201846
  static layerClient = this.layerClientNoDeps.pipe(provide$3(GithubCopilotAuth.layer));
201486
201847
  };
201487
201848
  //#endregion
201488
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/Copilot.js
201849
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/Copilot.js
201489
201850
  /**
201490
201851
  * @since 1.0.0
201491
201852
  */
@@ -201908,7 +202269,7 @@ Object.defineProperties(createChalk.prototype, styles);
201908
202269
  const chalk = createChalk();
201909
202270
  createChalk({ level: stderrColor ? stderrColor.level : 0 });
201910
202271
  //#endregion
201911
- //#region node_modules/.pnpm/clanka@0.0.16_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_a5af971af29a90bb95c8868bd6eda6a9/node_modules/clanka/dist/OutputFormatter.js
202272
+ //#region node_modules/.pnpm/clanka@0.0.21_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_c6e3079f8d7bc58ae58eff3c7a31d650/node_modules/clanka/dist/OutputFormatter.js
201912
202273
  /**
201913
202274
  * @since 1.0.0
201914
202275
  */
@@ -201949,9 +202310,55 @@ const scriptIcon = "󰯁";
201949
202310
  const subagentIcon = " ";
201950
202311
  const thinkingIcon = "󰟶";
201951
202312
  const doneIcon = "";
202313
+ /**
202314
+ * @since 1.0.0
202315
+ * @category Muxer
202316
+ */
202317
+ var Muxer = class extends Service$1()("clanka/OutputFormatter/Muxer") {};
202318
+ /**
202319
+ * @since 1.0.0
202320
+ * @category Muxer
202321
+ */
202322
+ const layerMuxer = (formatter) => effect$1(Muxer, gen(function* () {
202323
+ const scope$2 = yield* scope;
202324
+ const output = yield* unbounded$1();
202325
+ let agentCount = 0;
202326
+ let currentAgentId = null;
202327
+ const semaphore = makeUnsafe$8(1);
202328
+ return Muxer.of({
202329
+ add(stream) {
202330
+ const id = ++agentCount;
202331
+ return stream.pipe(tap(fnUntraced(function* (part_) {
202332
+ if (currentAgentId === null || id !== currentAgentId) yield* semaphore.take(1);
202333
+ switch ((part_._tag === "SubagentPart" ? part_.part : part_)._tag) {
202334
+ case "ReasoningStart":
202335
+ case "ScriptStart":
202336
+ currentAgentId = id;
202337
+ break;
202338
+ case "ScriptDelta":
202339
+ case "ReasoningDelta": break;
202340
+ default:
202341
+ currentAgentId = null;
202342
+ break;
202343
+ }
202344
+ if (id !== currentAgentId) yield* semaphore.release(1);
202345
+ })), formatter, runIntoPubSub(output), onExit$1(() => {
202346
+ if (currentAgentId !== id) return void_$1;
202347
+ currentAgentId = null;
202348
+ return semaphore.release(1);
202349
+ }), forkIn(scope$2), asVoid);
202350
+ },
202351
+ output: fromPubSub(output)
202352
+ });
202353
+ }));
201952
202354
  //#endregion
201953
202355
  //#region src/TaskTools.ts
201954
202356
  var ChosenTaskDeferred = class extends Reference("lalph/TaskTools/ChosenTaskDeferred", { defaultValue: makeUnsafe$13 }) {};
202357
+ var CurrentTaskRef = class CurrentTaskRef extends Service$1()("lalph/TaskTools/CurrentTaskRef") {
202358
+ static update(f) {
202359
+ return serviceOption(CurrentTaskRef).pipe(map$8(map$15((ref) => updateAndGet(ref, f))));
202360
+ }
202361
+ };
201955
202362
  const TaskList = Array$1(Struct({
201956
202363
  id: String$1.annotate({ documentation: "The unique identifier of the task." }),
201957
202364
  ...pick(PrdIssue.fields, [
@@ -201959,10 +202366,17 @@ const TaskList = Array$1(Struct({
201959
202366
  "description",
201960
202367
  "state",
201961
202368
  "priority",
201962
- "estimate",
201963
202369
  "blockedBy"
201964
202370
  ])
201965
202371
  }));
202372
+ const toTaskListItem = (issue) => ({
202373
+ id: issue.id ?? "",
202374
+ title: issue.title,
202375
+ description: issue.description,
202376
+ state: issue.state,
202377
+ priority: issue.priority,
202378
+ blockedBy: issue.blockedBy
202379
+ });
201966
202380
  var TaskTools = class extends make$9(make$7("listTasks", {
201967
202381
  description: "Returns the current list of tasks.",
201968
202382
  success: TaskList,
@@ -201974,7 +202388,6 @@ var TaskTools = class extends make$9(make$7("listTasks", {
201974
202388
  description: PrdIssue.fields.description,
201975
202389
  state: PrdIssue.fields.state,
201976
202390
  priority: PrdIssue.fields.priority,
201977
- estimate: PrdIssue.fields.estimate,
201978
202391
  blockedBy: PrdIssue.fields.blockedBy
201979
202392
  }),
201980
202393
  success: String$1,
@@ -201994,45 +202407,31 @@ var TaskTools = class extends make$9(make$7("listTasks", {
201994
202407
  parameters: String$1.annotate({ identifier: "taskId" }),
201995
202408
  dependencies: [CurrentProjectId]
201996
202409
  })) {};
201997
- var TaskToolsWithChoose = class extends merge(TaskTools, make$9(make$7("chooseTask", {
202410
+ var TaskChooseTools = class extends make$9(make$7("chooseTask", {
201998
202411
  description: "Choose the task to work on",
201999
202412
  parameters: Struct({
202000
202413
  taskId: String$1,
202001
202414
  githubPrNumber: optional$2(Number$1)
202002
202415
  })
202003
202416
  }), make$7("listEligibleTasks", {
202004
- description: "List tasks eligible for being chosen with chooseTask.",
202005
- success: TaskList,
202417
+ description: "List tasks eligible for being chosen with chooseTask in yaml format.",
202418
+ success: String$1,
202006
202419
  dependencies: [CurrentProjectId]
202007
- }))) {};
202420
+ })) {};
202421
+ var TaskToolsWithChoose = class extends merge(TaskTools, TaskChooseTools) {};
202008
202422
  const TaskToolsHandlers = TaskToolsWithChoose.toLayer(gen(function* () {
202009
202423
  const source = yield* IssueSource;
202010
202424
  return TaskToolsWithChoose.of({
202011
202425
  listTasks: fn("TaskTools.listTasks")(function* () {
202012
202426
  yield* log$1(`Calling "listTasks"`);
202013
202427
  const projectId = yield* CurrentProjectId;
202014
- return (yield* source.issues(projectId)).map((issue) => ({
202015
- id: issue.id ?? "",
202016
- title: issue.title,
202017
- description: issue.description,
202018
- state: issue.state,
202019
- priority: issue.priority,
202020
- estimate: issue.estimate,
202021
- blockedBy: issue.blockedBy
202022
- }));
202428
+ return (yield* source.issues(projectId)).map(toTaskListItem);
202023
202429
  }, orDie$2),
202024
202430
  listEligibleTasks: fn("TaskTools.listEligibleTasks")(function* () {
202025
202431
  yield* log$1(`Calling "listEligibleTasks"`);
202026
202432
  const projectId = yield* CurrentProjectId;
202027
- return (yield* source.issues(projectId)).filter((t) => t.blockedBy.length === 0 && t.state === "todo").map((issue) => ({
202028
- id: issue.id ?? "",
202029
- title: issue.title,
202030
- description: issue.description,
202031
- state: issue.state,
202032
- priority: issue.priority,
202033
- estimate: issue.estimate,
202034
- blockedBy: issue.blockedBy
202035
- }));
202433
+ const shuffled = yield* shuffle((yield* source.issues(projectId)).filter((t) => t.state === "todo" && t.blockedBy.length === 0).map(toTaskListItem));
202434
+ return import_dist.stringify(shuffled, null, 2);
202036
202435
  }, orDie$2),
202037
202436
  chooseTask: fn("TaskTools.chooseTask")(function* (options) {
202038
202437
  yield* log$1(`Calling "chooseTask"`).pipe(annotateLogs(options));
@@ -202044,12 +202443,14 @@ const TaskToolsHandlers = TaskToolsWithChoose.toLayer(gen(function* () {
202044
202443
  return (yield* source.createIssue(projectId, new PrdIssue({
202045
202444
  ...options,
202046
202445
  id: null,
202446
+ estimate: null,
202047
202447
  autoMerge: false
202048
202448
  }))).id;
202049
202449
  }, orDie$2),
202050
202450
  updateTask: fn("TaskTools.updateTask")(function* (options) {
202051
202451
  yield* log$1(`Calling "updateTask"`).pipe(annotateLogs({ taskId: options.taskId }));
202052
202452
  const projectId = yield* CurrentProjectId;
202453
+ yield* CurrentTaskRef.update((prev) => prev.update(options));
202053
202454
  yield* source.updateIssue({
202054
202455
  projectId,
202055
202456
  issueId: options.taskId,
@@ -202102,23 +202503,27 @@ const reasoningToCopilotConfig = (model, reasoning) => {
202102
202503
  };
202103
202504
  //#endregion
202104
202505
  //#region src/Clanka.ts
202105
- const runClanka = fnUntraced(
202106
- /** The working directory to run the agent in */
202107
- function* (options) {
202108
- const models = yield* ClankaModels;
202109
- const agent = yield* make$5({
202110
- ...options,
202111
- tools: options.withChoose ? TaskToolsWithChoose : TaskTools,
202112
- subagentModel: clankaSubagent(models, options.model)
202113
- }).pipe(provide$1(models.get(options.model)));
202114
- return yield* (options.stallTimeout ? withStallTimeout(options.stallTimeout)(agent.output) : agent.output).pipe(pretty, runForEachArray((out) => {
202115
- for (const item of out) process.stdout.write(item);
202116
- return void_$1;
202117
- }), (_) => _);
202118
- },
202119
- scoped$1,
202120
- provide$1([layerServices, TaskToolsHandlers])
202121
- );
202506
+ const ClankaMuxerLayer = effectDiscard(gen(function* () {
202507
+ const muxer = yield* Muxer;
202508
+ const stdio = yield* Stdio;
202509
+ yield* muxer.output.pipe(run$7(stdio.stdout()), forkScoped);
202510
+ })).pipe(provideMerge(layerMuxer(pretty)));
202511
+ const runClanka = fnUntraced(function* (options) {
202512
+ const models = yield* ClankaModels;
202513
+ const muxer = yield* Muxer;
202514
+ const agent = yield* make$5({
202515
+ ...options,
202516
+ tools: options.withChoose ? TaskChooseTools : TaskTools,
202517
+ subagentModel: clankaSubagent(models, options.model)
202518
+ }).pipe(provide$1(models.get(options.model)));
202519
+ yield* muxer.add(agent.output);
202520
+ let stream = options.stallTimeout ? withStallTimeout(options.stallTimeout)(agent.output) : agent.output;
202521
+ if (options.steer) yield* options.steer.pipe(switchMap(fnUntraced(function* (message) {
202522
+ yield* log$1(`Received steer message: ${message}`);
202523
+ yield* agent.steer(message);
202524
+ }, fromEffectDrain)), runDrain, forkScoped);
202525
+ yield* stream.pipe(runDrain, catchTag$1("AgentFinished", () => void_$1));
202526
+ }, scoped$1, provide$1([layerServices, TaskToolsHandlers]));
202122
202527
  //#endregion
202123
202528
  //#region src/Agents/worker.ts
202124
202529
  const agentWorker = fnUntraced(function* (options) {
@@ -202130,7 +202535,8 @@ const agentWorker = fnUntraced(function* (options) {
202130
202535
  model: options.preset.extraArgs.join(" "),
202131
202536
  system: options.system,
202132
202537
  prompt: options.prompt,
202133
- stallTimeout: options.stallTimeout
202538
+ stallTimeout: options.stallTimeout,
202539
+ steer: options.steer
202134
202540
  });
202135
202541
  return ExitCode(0);
202136
202542
  }
@@ -202446,11 +202852,17 @@ const run = fnUntraced(function* (options) {
202446
202852
  githubPrNumber: chosenTask.githubPrNumber ?? void 0,
202447
202853
  gitFlow
202448
202854
  });
202855
+ const issueRef = make$63(chosenTask.prd.update({ state: "in-progress" }));
202856
+ const steer = yield* taskUpdateSteer({
202857
+ issueId: taskId,
202858
+ current: issueRef
202859
+ });
202449
202860
  yield* log$1(`Agent exited with code: ${yield* agentWorker({
202450
202861
  stallTimeout: options.stallTimeout,
202451
202862
  preset: taskPreset,
202452
- prompt: instructions
202453
- }).pipe(catchStallInReview, withSpan("Main.agentWorker"))}`);
202863
+ prompt: instructions,
202864
+ steer
202865
+ }).pipe(provideService$2(CurrentTaskRef, issueRef), catchStallInReview, withSpan("Main.agentWorker"))}`);
202454
202866
  if (options.review) {
202455
202867
  registry.update(currentWorker.state, (s) => s.transitionTo(WorkerStatus.Reviewing({ issueId: taskId })));
202456
202868
  yield* agentReviewer({
@@ -202552,6 +202964,7 @@ const commandRoot = make$46("lalph", {
202552
202964
  });
202553
202965
  }, scoped$1, provide$1([
202554
202966
  ClankaModels.layer,
202967
+ ClankaMuxerLayer,
202555
202968
  PromptGen.layer,
202556
202969
  GithubCli.layer,
202557
202970
  Settings.layer,
@@ -202576,6 +202989,19 @@ const watchTaskState = fnUntraced(function* (options) {
202576
202989
  }));
202577
202990
  }), withSpan("Main.watchTaskState"));
202578
202991
  });
202992
+ const taskUpdateSteer = fnUntraced(function* (options) {
202993
+ return toStreamResult(yield* AtomRegistry, currentIssuesAtom(yield* CurrentProjectId)).pipe(drop(1), retry$1(forever$1), orDie, filterMap$2((issues) => {
202994
+ const issue = issues.find((entry) => entry.id === options.issueId);
202995
+ if (!issue) return failVoid;
202996
+ if (!issue.isChangedComparedTo(options.current.current)) return failVoid;
202997
+ set$9(options.current, issue);
202998
+ return succeed$8(`The task has been updated by the user. Here is the latest information:
202999
+
203000
+ # ${issue.title}
203001
+
203002
+ ${issue.description}`);
203003
+ }));
203004
+ });
202579
203005
  //#endregion
202580
203006
  //#region src/Agents/planner.ts
202581
203007
  const agentPlanner = fnUntraced(function* (options) {
@@ -202643,6 +203069,7 @@ const generateTasks = fnUntraced(function* ({ specsDirectory, specificationPath,
202643
203069
  });
202644
203070
  }, provide$1([
202645
203071
  ClankaModels.layer,
203072
+ ClankaMuxerLayer,
202646
203073
  Settings.layer,
202647
203074
  PromptGen.layer,
202648
203075
  Prd.layerProvided.pipe(provideMerge(layerProjectIdPrompt))
@@ -202675,7 +203102,12 @@ var Editor = class extends Service$1()("lalph/Editor", { make: gen(function* ()
202675
203102
  const content = (yield* fs.readFileString(file)).trim();
202676
203103
  if (content === initialContent) return yield* new NoSuchElementError();
202677
203104
  return content;
202678
- }, scoped$1, provideService$2(ChildProcessSpawner, spawner), option$1)
203105
+ }, scoped$1, provideService$2(ChildProcessSpawner, spawner), option$1),
203106
+ saveTemp: fnUntraced(function* (content, options) {
203107
+ const file = yield* fs.makeTempFile({ suffix: options.suffix ?? ".txt" });
203108
+ yield* fs.writeFileString(file, content);
203109
+ return file;
203110
+ })
202679
203111
  };
202680
203112
  }) }) {
202681
203113
  static layer = effect$1(this, this.make).pipe(provide$3(PlatformServices));
@@ -202692,6 +203124,10 @@ const commandPlan = make$46("plan", {
202692
203124
  onSuccess: (path) => fs.readFileString(path).pipe(asSome)
202693
203125
  });
202694
203126
  if (isNone(thePlan)) return;
203127
+ yield* addFinalizer((exit) => {
203128
+ if (isSuccess$3(exit)) return void_$1;
203129
+ return pipe(editor.saveTemp(thePlan.value, { suffix: ".md" }), flatMap$4((file) => log$1(`Saved your plan to: ${file}`)), ignore$1);
203130
+ });
202695
203131
  yield* gen(function* () {
202696
203132
  const project = withNewProject ? yield* addOrUpdateProject() : yield* selectProject;
202697
203133
  const { specsDirectory } = yield* commandRoot;
@@ -202706,9 +203142,10 @@ const commandPlan = make$46("plan", {
202706
203142
  }).pipe(provide$1([
202707
203143
  Settings.layer,
202708
203144
  CurrentIssueSource.layer,
202709
- ClankaModels.layer
203145
+ ClankaModels.layer,
203146
+ ClankaMuxerLayer
202710
203147
  ]));
202711
- }, provide$1(Editor.layer))), withSubcommands([commandPlanTasks]));
203148
+ }, scoped$1, provide$1(Editor.layer))), withSubcommands([commandPlanTasks]));
202712
203149
  const plan = fnUntraced(function* (options) {
202713
203150
  const fs = yield* FileSystem;
202714
203151
  const pathService = yield* Path$1;
@@ -202785,12 +203222,18 @@ const FrontMatterSchema = toCodecJson(Struct({
202785
203222
  autoMerge: Boolean$2
202786
203223
  }));
202787
203224
  const handler$1 = flow(withHandler(fnUntraced(function* () {
202788
- const content = yield* (yield* Editor).editTemp({
203225
+ const editor = yield* Editor;
203226
+ const content = yield* editor.editTemp({
202789
203227
  suffix: ".md",
202790
203228
  initialContent: issueTemplate
202791
203229
  });
202792
203230
  if (isNone(content)) return;
202793
- const lines = content.value.split("\n");
203231
+ const contentValue = content.value.trim();
203232
+ yield* addFinalizer((exit) => {
203233
+ if (isSuccess$3(exit)) return void_$1;
203234
+ return pipe(editor.saveTemp(contentValue, { suffix: ".md" }), flatMap$4((file) => log$1(`Saved your issue to: ${file}`)), ignore$1);
203235
+ });
203236
+ const lines = contentValue.split("\n");
202794
203237
  const yamlLines = [];
202795
203238
  let descriptionStartIndex = 0;
202796
203239
  for (let i = 0; i < lines.length; i++) {
@@ -202818,7 +203261,7 @@ const handler$1 = flow(withHandler(fnUntraced(function* () {
202818
203261
  console.log(`Created issue with ID: ${created.id}`);
202819
203262
  console.log(`URL: ${created.url}`);
202820
203263
  }).pipe(provide$1([layerProjectIdPrompt, CurrentIssueSource.layer]));
202821
- })), provide(Editor.layer));
203264
+ }, scoped$1)), provide(Editor.layer));
202822
203265
  const commandIssue = make$46("issue").pipe(withDescription("Create a new issue in your editor."), withAlias("i"), handler$1);
202823
203266
  //#endregion
202824
203267
  //#region src/commands/edit.ts
@@ -202832,7 +203275,7 @@ const commandEdit = make$46("edit").pipe(withDescription("Open the selected proj
202832
203275
  const commandSource = make$46("source").pipe(withDescription("Select the issue source to use (e.g. GitHub Issues or Linear). This applies to all projects."), withHandler(() => selectIssueSource), provide(Settings.layer));
202833
203276
  //#endregion
202834
203277
  //#region package.json
202835
- var version = "0.3.46";
203278
+ var version = "0.3.48";
202836
203279
  //#endregion
202837
203280
  //#region src/commands/projects/ls.ts
202838
203281
  const commandProjectsLs = make$46("ls").pipe(withDescription("List configured projects and how they run (enabled state, concurrency, branch, git flow, review agent)."), withHandler(fnUntraced(function* () {